Skip to content

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

Merged
njhollinghurst merged 1 commit into
raspberrypi:rpi-6.7.yfrom
njhollinghurst:iommu-pagecount
Feb 22, 2024
Merged

iommu: bcm2712-iommu: Map and unmap multiple pages in a single call#5977
njhollinghurst merged 1 commit into
raspberrypi:rpi-6.7.yfrom
njhollinghurst:iommu-pagecount

Conversation

@njhollinghurst

Copy link
Copy Markdown
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
Copy Markdown
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

6by9 commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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 <nick.hollinghurst@raspberrypi.com>
@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