From: Logan Gunthorpe blk_dma_map_iter_start() reports BLK_STS_INVAL when a P2PDMA transfer is attempted between two devices whose PCIe topology cannot route it. blk_path_error() treats INVAL as retryable, so multipath requeues the I/O forever, and callers cannot tell it apart from an invalid request. md also ignores it for member failures, so a mirror silently diverges. Restoring the old BLK_STS_TARGET would stay ambiguous -- nvme maps NS_NOT_READY, LBA_RANGE and CMD_INTERRUPTED to it too. Add a dedicated BLK_STS_P2PDMA, non-retryable in blk_path_error(), and return it from blk_dma_map_iter_start(). Fixes: 858299dc6160 ("block: add scatterlist-less DMA mapping helpers") Fixes: 7ce3c1dd78fc ("nvme-pci: convert the data mapping to blk_rq_dma_map") Cc: stable@vger.kernel.org # v6.17 Signed-off-by: Logan Gunthorpe Signed-off-by: Mykola Marzhan --- block/blk-core.c | 3 +++ block/blk-mq-dma.c | 3 ++- include/linux/blk_types.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 365641266c9e..83cb5464265f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -177,6 +177,9 @@ static const struct { /* Command duration limit device-side timeout */ ENT(DURATION_LIMIT, -ETIME, "duration limit exceeded"), + + /* no PCIe P2PDMA route between initiator and target */ + ENT(P2PDMA, -EREMOTEIO, "peer-to-peer transfer unroutable"), ENT(INVAL, -EINVAL, "invalid"), /* everything else not covered above: */ diff --git a/block/blk-mq-dma.c b/block/blk-mq-dma.c index bfdb9ed70741..e88d6b3524e6 100644 --- a/block/blk-mq-dma.c +++ b/block/blk-mq-dma.c @@ -189,8 +189,9 @@ static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev, */ case PCI_P2PDMA_MAP_NONE: break; + case PCI_P2PDMA_MAP_NOT_SUPPORTED: default: - iter->status = BLK_STS_INVAL; + iter->status = BLK_STS_P2PDMA; return false; } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 8808ee76e73c..c8de7809320a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -165,6 +165,15 @@ typedef u16 blk_short_t; */ #define BLK_STS_DURATION_LIMIT ((__force blk_status_t)17) +/* + * BLK_STS_P2PDMA is returned when a peer-to-peer DMA transfer cannot be + * mapped (typically because there is no route between the initiator and the + * target that the platform's PCIe topology and ACS settings allow). This + * is a property of the initiator/target pair, not of the target device's + * health. This error should never be retried. + */ +#define BLK_STS_P2PDMA ((__force blk_status_t)18) + /* * Invalid size or alignment. */ @@ -188,6 +197,7 @@ static inline bool blk_path_error(blk_status_t error) case BLK_STS_NOTSUPP: case BLK_STS_NOSPC: case BLK_STS_TARGET: + case BLK_STS_P2PDMA: case BLK_STS_RESV_CONFLICT: case BLK_STS_MEDIUM: case BLK_STS_PROTECTION: -- 2.52.0