Skip to content

iommu: bcm2712-iommu: Map and unmap multiple pages in a single call #5977

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

Merged

Conversation

njhollinghurst
Copy link
Contributor

For efficiency, the map_pages() and unmap_pages() calls now pay attention to their "count" argument, at least in successful cases.

Fix a bugette where we omitted to set mapped to 0 in case of error. Minor style fix.

@njhollinghurst
Copy link
Contributor Author

This is a leftover from #5833. The efficiency improvement is admittedly quite modest; the average count (when exercised by camera) seems to be about 2.

Note that count does not feature in the large-page/alignment flags: because pages might get freed in a different order to the order in which they were allocated. We aren't bothering to check e.g. that pages are aligned to their own size, because we trust the framework to get it right.

There is no change in the "pass-thru" default case (which perhaps should be an error case, as it's never used), which still returns one page at a time. The bug fix in the "off-the-top" error case is needed, I think.

@njhollinghurst njhollinghurst requested a review from 6by9 February 21, 2024 18:39
@6by9
Copy link
Contributor

6by9 commented Feb 21, 2024

Looks reasonable based on my knowledge of it (ie very limited).
In theory a patch should do one thing, but this will all get squashed before upstreaming, so I don't care.

@njhollinghurst
Copy link
Contributor Author

Tested with camera/ISP; I'll do a bit more testing with other Pi 5 blocks then de-draft it.

@njhollinghurst
Copy link
Contributor Author

I'm going to push a tidied-up version that ignores special treatment of the "pass-through" region.
IOMMU-aware DMA drivers aren't told it exists and should never use it -- they should respect the force_aperture flag.
Meanwhile non-IOMMU-aware ones won't use this API.

For efficiency, the map_pages() and unmap_pages() calls now pay
attention to their "count" argument.

Remove a special case for a "pass-through" address range, which
the DMA/IOMMU subsystem isn't told exists and should never use.

Fix a bug where we omitted to set *mapped to 0 in error cases.
Minor style fixes and tidying.

Signed-off-by: Nick Hollinghurst <[email protected]>
@njhollinghurst njhollinghurst marked this pull request as ready for review February 22, 2024 13:32
@njhollinghurst njhollinghurst merged commit 3bff9ed into raspberrypi:rpi-6.7.y Feb 22, 2024
@njhollinghurst njhollinghurst deleted the iommu-pagecount branch February 22, 2024 16:35
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.

2 participants