[PATCH 16/19] iommu/amd: Use roundup_pow_two() instead of get_order()
Jason Gunthorpe
jgg at nvidia.com
Wed Feb 5 09:59:52 PST 2025
On Wed, Feb 05, 2025 at 04:11:00PM +0000, Robin Murphy wrote:
> On 2025-02-04 6:34 pm, Jason Gunthorpe wrote:
> > 1 << (get_order(x) + PAGE_SHIFT) == roundup_pow_two()
>
> ...unless x < 2048, which does seem possible here if last_bdf is
> sufficiently small.
Yes.. I was thinking that sub page was what this stuff wanted however
I missed:
> but I do wonder about the use of dev_table_size in
> iommu_set_device_table(), and whether this change might break it, or
> whether it's already wrong for that case and this might actually fix
> it...
Indeed, the spec says 4k pages here:
This field contains an unsigned value m that specifies the size of
the Device Table for this segment in 4 Kbyte
increments. The size in bytes is equal to (m + 1) * 4 Kbytes.
And it certainly has to be algined, so it does need a PAGE_ALIGN()
around it.
I'm going to add another patch to change rlookup_table and
irq_lookup_table to use a simple kvzalloc(), they are not used with HW
and just need to be some simple CPU memory of the proper page size,
Then do:
- pci_seg->dev_table_size = tbl_size(DEV_TABLE_ENTRY_SIZE, last_bdf);
+ pci_seg->dev_table_size =
+ PAGE_ALIGN(tbl_size(DEV_TABLE_ENTRY_SIZE, last_bdf));
To fixup the HW memory.
Thanks,
Jason
More information about the linux-riscv
mailing list