Re: [PATCH v9 3/4] iommu/io-pgtable-arm: Add way to debug pgtable walk

From: Rob Clark
Date: Fri Aug 30 2024 - 10:32:37 EST


On Fri, Aug 30, 2024 at 6:20 AM Will Deacon <will@xxxxxxxxxx> wrote:
>
> On Tue, Aug 27, 2024 at 11:17:11AM -0700, Rob Clark wrote:
> > From: Rob Clark <robdclark@xxxxxxxxxxxx>
> >
> > Add an io-pgtable method to walk the pgtable returning the raw PTEs that
> > would be traversed for a given iova access.
> >
> > Signed-off-by: Rob Clark <robdclark@xxxxxxxxxxxx>
> > ---
> > drivers/iommu/io-pgtable-arm.c | 25 +++++++++++++++++++++++++
> > include/linux/io-pgtable.h | 15 +++++++++++++++
> > 2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> > index efed8e519111..11af49119f37 100644
> > --- a/drivers/iommu/io-pgtable-arm.c
> > +++ b/drivers/iommu/io-pgtable-arm.c
> > @@ -759,6 +759,30 @@ static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
> > return iopte_to_paddr(d.pte, data) | iova;
> > }
> >
> > +static int visit_pgtable_walk(struct io_pgtable_walk_data *walk_data, int lvl,
> > + arm_lpae_iopte *ptep, size_t size)
> > +{
> > + struct arm_lpae_io_pgtable_walk_data *data = walk_data->data;
> > + data->ptes[data->level++] = *ptep;
> > + return 0;
> > +}
>
> I'm struggling to see how this works given that the ->visit() callback
> is only called for leaf entries in the page-table. What am I missing?

Yeah, we should just go back to my v6 before I tried to re-use the
arm_lpae_read_and_clear_dirty() walker.. addressing review comments is
just making it worse since then

BR,
-R