Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta-hailo support #569

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add meta-hailo support #569

wants to merge 8 commits into from

Conversation

huaqianli
Copy link
Collaborator

meta-hailo: Fix the CMA issue when PVU was integrated
linux-iot2050: Make PVU only available for secureboot build
README: Add SENS SM firmware update tool info
iot2050-conf-webui: Fix the wrong article number of SM1231 4AI
linux-iot2050: Add support for PVU-based DMA isolation on AM654
u-boot-iot2050: Add support for PVU-based DMA isolation on AM654
Add support for Hailo Card

@huaqianli huaqianli requested a review from BaochengSu December 3, 2024 07:10
@huaqianli huaqianli force-pushed the lee/hailo-card branch 3 times, most recently from d71b261 to 57d9565 Compare December 3, 2024 08:21
Kconfig Outdated Show resolved Hide resolved
kas/opt/meta-hailo.yml Outdated Show resolved Hide resolved
Comment on lines +16 to +18
> Note: `numpy==1.23.3` is preinstalled. Please do not upgrade it, as
> `hailort v4.18.0` requires this specific version. Upgrading `numpy` may cause
> `pyhailort` to fail to execute.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will apt-upgrade updates it? If do, I bet you need a package pin config.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would need to pin it via apt preferences then. But that is security-wise a bad idea as well, thus this issue of hailo stack needs fixing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we are using Hailo V4.18, which officially requires numpy 1.23.3. Even if Hailo fixes this issue, they may not backport the fix to V4.18, making the situation quite challenging. There are significant differences between numpy 1.23 and 1.24, meaning that backporting the patches to V4.18 would require a substantial effort.

So far, IMHO, it would be a good choice for us.

Copy link
Collaborator

@jan-kiszka jan-kiszka Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already patching hailo for other reasons. Key question is what is breaking when using a (distro-)maintained numpy version in their stack? Your version will not receive any updates (EOL in upstream, not under Debian maintenance), even if there should be bugs or even CVEs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the issue is caused by the changes mentioned in the numpy 1.24.0 release notes:
https://numpy.org/doc/2.0/release/1.24.0-notes.html

There are also a large number of new and expired deprecations due to changes in promotion and cleanups. This might be called a deprecation release. Highlights are

    Many new deprecations, check them out.

    Many expired deprecations,

    New F2PY features and fixes.

    New “dtype” and “casting” keywords for stacking functions.

Copy link
Collaborator Author

@huaqianli huaqianli Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose Hailort will require a bunch of modifications to eliminate the deprecations. Anyway I'll suggest Hailo to follow the numpy version of the Debian LTS.

@huaqianli huaqianli force-pushed the lee/hailo-card branch 3 times, most recently from af68e5c to cbd7b7a Compare December 4, 2024 07:34
hailo-firmware \
hailortcli \
python3-hailort \
"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate CI image? Did the build time exceeded the limit on github?

You want to explain such details, at least in the commit message (reasoning, not feature-listing).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above #569 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That unfortunately makes no sense yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, I'll drop this and refine the commit message

@huaqianli huaqianli force-pushed the lee/hailo-card branch 3 times, most recently from a5ac6ac to e0392a7 Compare December 5, 2024 06:59
This commit integrates the following main components:

- hailo-pci (OSS kernel module)
- hailo-firmware (proprietary firmware for hailo8 chip)
- hailort (Userspace Libraries)
  - hailortcli (tool)
  - hailort (service)
  - libhailort (c library)
  - libhailort-dev (dev package)
  - python3-hailort (python library)
  - libgsthailo (gstreamer element)

Signed-off-by: Li Hua Qian <[email protected]>
Reserve a 64M memory region and ensure that all PCI devices do their DMA
only inside that region. This is configured via a restricted-dma-pool
and enforced with the help of the first PVU.

Applying this isolation is not totally free in terms of overhead and
memory consumption. It  makes only sense for variants that support
secure booting, and generally only when this is actually enable.
Therefore model it as overlay that can be activated on demand. The
firmware will take care of this via DT fixup during boot and will also
provide a way to adjust the pool size.

Signed-off-by: Li Hua Qian <[email protected]>
The AM654 lacks an IOMMU, thus does not support isolating DMA requests
from untrusted PCI devices to selected memory regions this way. Use
static PVU-based protection instead.

For this, we use the availability of restricted-dma-pool memory regions
as trigger and register those as valid DMA targets with the PVU. In
addition, we need to enable the mapping of requester IDs to VirtIDs in
the PCI RC. We only use a single VirtID so far, catching all devices.
This may be extended later on.

Signed-off-by: Li Hua Qian <[email protected]>
PVU-based DMA isolation brings SWIO TLB to the table and
the maximum allowable number of contiguous slabs to map
is 128 by default, but meta-hailo requires more than 128.
Hence increase it to 256 when meta-hailo is included.

Signed-off-by: Li Hua Qian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants