Re: [PATCH 3/9] iommu/generic_pt: implement iova_to_phys_length

From: guanghuifeng@xxxxxxxxxxxxxxxxx

Date: Mon Jun 01 2026 - 05:30:21 EST



在 2026/6/1 7:54, Jason Gunthorpe 写道:
On Sun, May 31, 2026 at 05:36:31PM +0800, Guanghui Feng wrote:
@@ -159,45 +164,51 @@ static __always_inline int __do_iova_to_phys(struct pt_range *range, void *arg,
case PT_ENTRY_TABLE:
return pt_descend(&pts, arg, descend_fn);
case PT_ENTRY_OA:
- *res = pt_entry_oa_exact(&pts);
+ data->phys = pt_entry_oa_exact(&pts);
+ data->length = BIT(pt_entry_oa_lg2sz(&pts));
BIT is the wrong function, it uses the wrong type. log2_to_int() is
type'd properly

Yes, log2_to_int should be used.

This also needs to keep walking and accumulating length for
consecutive PTEs until it reaches a non-contiguity.

The other drivers don't need to have that complexity.

Yes

Jason