public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] dma: fix dma_opt_mapping_size() returning bogus value when no backend hint exists
@ 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)
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Ionut Nechita (Wind River) @ 2026-03-16 20:39 UTC (permalink / raw)
  To: m.szyprowski, kbusch, axboe, hch, sagi
  Cc: robin.murphy, martin.petersen, damien.lemoal, john.g.garry,
	ahuang12, iommu, linux-nvme, linux-kernel, stable, ionut_n2001,
	sunlightlinux, Ionut Nechita (Wind River)

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.

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(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-17 15:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 20:39 [PATCH v1 0/2] dma: fix dma_opt_mapping_size() returning bogus value when no backend hint exists 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
2026-03-17 14:36   ` Christoph Hellwig
2026-03-17 15:18     ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox