From: Damien Le Moal <dlemoal@kernel.org>
To: John Garry <john.g.garry@oracle.com>,
"Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>,
m.szyprowski@samsung.com, kbusch@kernel.org, axboe@kernel.dk,
hch@lst.de, sagi@grimberg.me
Cc: robin.murphy@arm.com, martin.petersen@oracle.com,
damien.lemoal@opensource.wdc.com, ahuang12@lenovo.com,
iommu@lists.linux.dev, linux-nvme@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
ionut_n2001@yahoo.com, sunlightlinux@gmail.com
Subject: Re: [PATCH v1 0/2] dma: fix dma_opt_mapping_size() returning bogus value when no backend hint exists
Date: Tue, 17 Mar 2026 18:18:17 +0900 [thread overview]
Message-ID: <861b88b8-ba58-4264-8892-282c39194d68@kernel.org> (raw)
In-Reply-To: <8b7706a0-41be-44a2-8247-ebbc33fee937@oracle.com>
On 3/17/26 18:11, John Garry wrote:
> On 16/03/2026 20:39, Ionut Nechita (Wind River) wrote:
>> dma_opt_mapping_size() currently returns min(dma_max_mapping_size(),
>> SIZE_MAX) when neither an IOMMU nor a DMA ops opt_mapping_size callback
>> is present. That value is the DMA maximum, not an optimal transfer
>> size, yet callers treat it as a genuine optimization hint.
>>
>> The concrete problem shows up on SAS controllers (e.g. mpt3sas) running
>> with IOMMU in passthrough mode. The bogus value propagates through
>> scsi_transport_sas into Scsi_Host.opt_sectors and then into the block
>> device's optimal_io_size. mkfs.xfs picks it up, computes
>> swidth=4095 / sunit=2, and fails with:
>>
>> XFS: SB stripe unit sanity check failed
>>
>> making it impossible to create filesystems during system bootstrap.
>
> For SAS controllers, don't we limit shost->opt_sectors at
> shost->max_sectors, and then in sd_revalidate_disk() this value is
> ignored as sdkp->opt_xfer_blocks would be smaller, right?
>
> What value are you seeing for max_sectors and opt_sectors? That mpt3sas
> driver seems to have many methods to set max_sectors.
And mpi3mr is also very similar.
>
> Thanks,
> John
>
>>
>> Patch 1 changes dma_opt_mapping_size() to return 0 ("no preference")
>> when no backend provides a real hint.
>>
>> Patch 2 adjusts the only other in-tree caller (nvme-pci) to handle the
>> new 0 return value, falling back to its existing default instead of
>> setting max_hw_sectors to 0.
>>
>> Note: the scsi_transport_sas caller (the one that triggers the XFS
>> issue) already handles 0 safely. It passes the return value through
>> min_t() into shost->opt_sectors, which becomes 0; sd.c then feeds that
>> into min_not_zero() when computing io_opt, so a zero opt_sectors is
>> correctly treated as "no preference" and ignored.
>>
>> Based on linux-next (next-20260316).
>>
>> Ionut Nechita (2):
>> dma: return 0 from dma_opt_mapping_size() when no real hint exists
>> nvme-pci: handle dma_opt_mapping_size() returning 0
>>
>> drivers/nvme/host/pci.c | 15 ++++++++++-----
>> kernel/dma/mapping.c | 13 ++++++++-----
>> 2 files changed, 18 insertions(+), 10 deletions(-)
>>
>
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-03-17 9:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 20:39 Ionut Nechita (Wind River)
2026-03-16 20:39 ` [PATCH v1 1/2] dma: return 0 from dma_opt_mapping_size() when no real " Ionut Nechita (Wind River)
2026-03-17 9:43 ` Robin Murphy
2026-03-17 14:19 ` Christoph Hellwig
2026-03-16 20:39 ` [PATCH v1 2/2] nvme-pci: handle dma_opt_mapping_size() returning 0 Ionut Nechita (Wind River)
2026-03-16 21:21 ` Damien Le Moal
2026-03-17 8:55 ` John Garry
2026-03-17 14:14 ` Christoph Hellwig
2026-03-17 9:11 ` [PATCH v1 0/2] dma: fix dma_opt_mapping_size() returning bogus value when no backend hint exists John Garry
2026-03-17 9:18 ` Damien Le Moal [this message]
2026-03-17 14:36 ` Christoph Hellwig
2026-03-17 15:18 ` John Garry
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=861b88b8-ba58-4264-8892-282c39194d68@kernel.org \
--to=dlemoal@kernel.org \
--cc=ahuang12@lenovo.com \
--cc=axboe@kernel.dk \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=ionut.nechita@windriver.com \
--cc=ionut_n2001@yahoo.com \
--cc=john.g.garry@oracle.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=martin.petersen@oracle.com \
--cc=robin.murphy@arm.com \
--cc=sagi@grimberg.me \
--cc=stable@vger.kernel.org \
--cc=sunlightlinux@gmail.com \
/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
all inboxes | Powered by JetHome®