From: Keith Busch <kbusch@kernel.org>
To: Chaitanya Kulkarni <chaitanyak@nvidia.com>
Cc: Sebastian Ott <sebott@redhat.com>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
Robin Murphy <robin.murphy@arm.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
Jens Axboe <axboe@fb.com>, Christoph Hellwig <hch@lst.de>,
Will Deacon <will@kernel.org>, Carlos Maiolino <cem@kernel.org>
Subject: Re: WARNING: drivers/iommu/io-pgtable-arm.c:639
Date: Wed, 10 Dec 2025 13:05:41 +0900 [thread overview]
Message-ID: <aTjxleV96jE3PIBh@kbusch-mbp> (raw)
In-Reply-To: <30ae8fc4-94ff-4467-835e-28b4a4dfcd8f@nvidia.com>
On Wed, Dec 10, 2025 at 02:30:50AM +0000, Chaitanya Kulkarni wrote:
> @@ -126,17 +126,26 @@ static bool blk_rq_dma_map_iova(struct request *req, struct device *dma_dev,
> error = dma_iova_link(dma_dev, state, vec->paddr, mapped,
> vec->len, dir, attrs);
> if (error)
> - break;
> + goto out_unlink;
> mapped += vec->len;
> } while (blk_map_iter_next(req, &iter->iter, vec));
>
> error = dma_iova_sync(dma_dev, state, 0, mapped);
> - if (error) {
> - iter->status = errno_to_blk_status(error);
> - return false;
> - }
> + if (error)
> + goto out_unlink;
>
> return true;
> +
> +out_unlink:
> + /*
> + * Unlink any partial mapping to avoid unmap mismatch later.
> + * If we mapped some bytes but not all, we must clean up now
> + * to prevent attempting to unmap more than was actually mapped.
> + */
> + if (mapped)
> + dma_iova_unlink(dma_dev, state, 0, mapped, dir, attrs);
> + iter->status = errno_to_blk_status(error);
> + return false;
> }
It does look like a bug to continue on when dma_iova_link() fails as the
caller thinks the entire mapping was successful, but I think you also
need to call dma_iova_free() to undo the earlier dma_iova_try_alloc(),
otherwise iova space is leaked.
I'm a bit doubtful this error condition was hit though: this sequence
is largely the same as it was in v6.18 before the regression. The only
difference since then should just be for handling P2P DMA across a host
bridge, which I don't think applies to the reported bug since that's a
pretty unusual thing to do.
next prev parent reply other threads:[~2025-12-10 4:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 11:43 WARNING: drivers/iommu/io-pgtable-arm.c:639 Sebastian Ott
2025-12-09 11:50 ` Robin Murphy
2025-12-09 17:29 ` Chaitanya Kulkarni
2025-12-09 17:34 ` Robin Murphy
2025-12-09 17:59 ` Chaitanya Kulkarni
2025-12-09 21:05 ` Sebastian Ott
2025-12-10 2:30 ` Chaitanya Kulkarni
2025-12-10 4:05 ` Keith Busch [this message]
2025-12-10 4:59 ` Chaitanya Kulkarni
2025-12-10 17:12 ` Sebastian Ott
2025-12-10 21:12 ` Chaitanya Kulkarni
2025-12-10 5:02 ` Keith Busch
2025-12-10 5:33 ` Keith Busch
2025-12-10 11:08 ` Sebastian Ott
2025-12-10 11:21 ` Keith Busch
2025-12-10 16:57 ` Sebastian Ott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aTjxleV96jE3PIBh@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@fb.com \
--cc=cem@kernel.org \
--cc=chaitanyak@nvidia.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=sebott@redhat.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox