[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE2F3rCZhgLOPKMmAqvNaQt3mUdj0kez9_MDxM3nGVOpgr5wuA@mail.gmail.com>
Date: Mon, 29 Sep 2025 13:42:29 -0700
From: Daniel Mentz <danielmentz@...gle.com>
To: Pranjal Shrivastava <praan@...gle.com>
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
Will Deacon <will@...nel.org>, Mostafa Saleh <smostafa@...gle.com>, Liviu Dudau <liviu.dudau@....com>,
Jason Gunthorpe <jgg@...dia.com>, Rob Clark <robin.clark@....qualcomm.com>
Subject: Re: [PATCH 1/2] iommu/io-pgtable-arm: Implement .iotlb_sync_map callback
On Mon, Sep 29, 2025 at 12:57 PM Pranjal Shrivastava <praan@...gle.com> wrote:
>
> On Sat, Sep 27, 2025 at 10:39:52PM +0000, Daniel Mentz wrote:
> > +static int __arm_lpae_iotlb_sync_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
> > + size_t size, int lvl, arm_lpae_iopte *ptep)
> > +{
> > + struct io_pgtable *iop = &data->iop;
> > + size_t block_size = ARM_LPAE_BLOCK_SIZE(lvl, data);
> > + int ret = 0, num_entries, max_entries;
> > + unsigned long iova_offset, sync_idx_start, sync_idx_end;
> > + int i, shift, synced_entries = 0;
> > +
> > + shift = (ARM_LPAE_LVL_SHIFT(lvl - 1, data) + ARM_LPAE_PGD_IDX(lvl - 1, data));
> > + iova_offset = iova & ((1ULL << shift) - 1);
> > + sync_idx_start = ARM_LPAE_LVL_IDX(iova, lvl, data);
> > + sync_idx_end = (iova_offset + size + block_size - ARM_LPAE_GRANULE(data)) >>
> > + ARM_LPAE_LVL_SHIFT(lvl, data);
> > + max_entries = arm_lpae_max_entries(sync_idx_start, data);
> > + num_entries = min_t(unsigned long, sync_idx_end - sync_idx_start, max_entries);
> > + ptep += sync_idx_start;
> > +
> > + if (lvl < (ARM_LPAE_MAX_LEVELS - 1)) {
> > + for (i = 0; i < num_entries; i++) {
> > + arm_lpae_iopte pte = READ_ONCE(ptep[i]);
> > + unsigned long synced;
> > +
> > + WARN_ON(!pte);
> > +
> > + if (iopte_type(pte) == ARM_LPAE_PTE_TYPE_TABLE) {
> > + int n = i - synced_entries;
> > +
> > + if (n) {
> > + __arm_lpae_sync_pte(&ptep[synced_entries], n, &iop->cfg);
> > + synced_entries += n;
> > + }
> > + ret = __arm_lpae_iotlb_sync_map(data, iova, size, lvl + 1,
> > + iopte_deref(pte, data));
>
> I think we must check the returned value here and break the loop on
> error. Otherwise, we might burry a failure by continuing the loop.
> We should add something like:
>
> if (ret)
> break;
>
Now, I'm realising that __arm_lpae_iotlb_sync_map always returns 0, in
which case I could change the return type to void. Would that work for
you?
Powered by blists - more mailing lists