Skip to content

.map_sg() error cleanup

Logan Gunthorpe linux-alpha linux-arm-kernel linux-ia64 linux-iommu linux-mips linux-parisc linux-s390 linuxppc-dev lkml sparclinux xen-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest21 patches 1 replyIn review
  2. v221 patches 3 repliesSuperseded
  3. v116 patches 11 repliesSuperseded

Changes in v3 from the cover letter

- Move the validation of errnos into __dma_map_sg_attrs() (Per Christoph)
- Fix the out of date commit message in patch 21 (Per Eike)

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21dma-mapping: Allow map_sg() ops to return negative error codesinclude/linux/dma-map-ops.h include/linux/dma-mapping.h kernel/dma/mapping.c+86 -380 replies
2/21dma-direct: Return appropriate error code from dma_direct_map_sg()kernel/dma/direct.c+1 -10 replies
3/21iommu: Return full error code from iommu_map_sg[_atomic]()drivers/iommu/iommu.c include/linux/iommu.h+18 -190 replies
4/21dma-iommu: Return error code from iommu_dma_map_sg()drivers/iommu/dma-iommu.c+16 -70 replies
5/21alpha: return error code from alpha_pci_map_sg()arch/alpha/kernel/pci_iommu.c+7 -30 replies
6/21ARM/dma-mapping: return error code from .map_sg() opsarch/arm/mm/dma-mapping.c+16 -90 replies
7/21ARM/dma-mapping: don't set failed sg dma_address to DMA_MAPPING_ERRORarch/arm/mm/dma-mapping.c+0 -10 replies
8/21ia64/sba_iommu: return error code from sba_map_sg_attrs()arch/ia64/hp/common/sba_iommu.c+3 -30 replies
9/21MIPS/jazzdma: return error code from jazz_dma_map_sg()arch/mips/jazz/jazzdma.c+1 -10 replies
10/21powerpc/iommu: return error code from .map_sg() opsarch/powerpc/kernel/iommu.c arch/powerpc/platforms/ps3/system-bus.c arch/powerpc/platforms/pseries/vio.c+6 -50 replies
11/21powerpc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERRORarch/powerpc/kernel/iommu.c+0 -20 replies
12/21s390/pci: return error code from s390_dma_map_sg()arch/s390/pci/pci_dma.c+7 -50 replies
13/21s390/pci: don't set failed sg dma_address to DMA_MAPPING_ERRORarch/s390/pci/pci_dma.c+0 -10 replies
14/21sparc/iommu: return error codes from .map_sg() opsarch/sparc/kernel/iommu.c arch/sparc/kernel/pci_sun4v.c arch/sparc/mm/iommu.c+5 -50 replies
15/21sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERRORarch/sparc/kernel/iommu.c arch/sparc/kernel/pci_sun4v.c+0 -40 replies
16/21parisc: return error code from .map_sg() opsdrivers/parisc/ccio-dma.c drivers/parisc/sba_iommu.c+2 -20 replies
17/21xen: swiotlb: return error code from xen_swiotlb_map_sg()drivers/xen/swiotlb-xen.c+1 -10 replies
18/21x86/amd_gart: return error code from gart_map_sg()arch/x86/kernel/amd_gart_64.c+9 -70 replies
19/21x86/amd_gart: don't set failed sg dma_address to DMA_MAPPING_ERRORarch/x86/kernel/amd_gart_64.c+0 -20 replies
20/21dma-mapping: return error code from dma_dummy_map_sg()kernel/dma/dummy.c+1 -10 replies
21/21dma-mapping: Disallow .map_sg operations from returning zero on errorkernel/dma/mapping.c+3 -50 replies

Reviews trailers per patch

2 of 21 patches have a Reviewed-by or Acked-by.

PatchNiklas SchnelleBoris Ostrovsky
1/21
2/21
3/21
4/21
5/21
6/21
7/21
8/21
9/21
10/21
11/21
12/21A-b
13/21
14/21
15/21
16/21
17/21R-b
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/21] .map_sg() error cleanup

Hi,

This v3 of the series is spun out and expanded from my work to add P2PDMA support to DMA map operations[1]. v2 is at [2]. The main changes in v1 are to more carefully define the meaning of the error codes for dma_map_sgtable().

The P2PDMA work requires distinguishing different error conditions in a map_sg operation. dma_map_sgtable() already allows for returning an error code (where as dma_map_sg() is only allowed to return zero) however, it currently only returns -EINVAL when a .map_sg() call returns zero.

This series cleans up all .map_sg() implementations to return appropriate error codes. After the cleanup, dma_map_sg() will still return zero, however dma_map_sgtable() will pass the error code from the .map_sg() call. Thanks go to Martn Oliveira for doing a lot of the cleanup of the obscure implementations.

The patch set is based off of v5.14-rc2 and a git repo can be found here:

https://github.com/sbates130272/linux-p2pmem map_sg_err_cleanup_v2

Thanks,

Logan

[1] https://lore.kernel.org/linux-block/[email protected]/
[2] https://lore.kernel.org/linux-mips/[email protected]/

--

Changes in v3:
- Move the validation of errnos into __dma_map_sg_attrs() (Per Christoph)
- Fix the out of date commit message in patch 21 (Per Eike)
Changes in v2:
- Attempt to define the meanings of the errors returned by dma_map_sgtable() and restrict the valid return codes of .map_sg implementations. (Per Christoph)
- Change dma_map_sgtable() to EXPORT_SYMBOL_GPL() (Per Christoph)
- Add patches to remove the erroneous setting of sg->dma_address to DMA_MAP_ERROR in a few .map_sg(0 implementations. (Per Christoph).

--

Logan Gunthorpe (10):
dma-mapping: Allow map_sg() ops to return negative error codes
dma-direct: Return appropriate error code from dma_direct_map_sg()
iommu: Return full error code from iommu_map_sg[_atomic]()
dma-iommu: Return error code from iommu_dma_map_sg() ARM/dma-mapping: don't set failed sg dma_address to DMA_MAPPING_ERROR powerpc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR s390/pci: don't set failed sg dma_address to DMA_MAPPING_ERROR sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR x86/amd_gart: don't set failed sg dma_address to DMA_MAPPING_ERROR
dma-mapping: Disallow .map_sg operations from returning zero on error

Martin Oliveira (11):
alpha: return error code from alpha_pci_map_sg() ARM/dma-mapping: return error code from .map_sg() ops ia64/sba_iommu: return error code from sba_map_sg_attrs() MIPS/jazzdma: return error code from jazz_dma_map_sg() powerpc/iommu: return error code from .map_sg() ops s390/pci: return error code from s390_dma_map_sg() sparc/iommu: return error codes from .map_sg() ops
parisc: return error code from .map_sg() ops
xen: swiotlb: return error code from xen_swiotlb_map_sg() x86/amd_gart: return error code from gart_map_sg()
dma-mapping: return error code from dma_dummy_map_sg()

 arch/alpha/kernel/pci_iommu.c           | 10 ++-
 arch/arm/mm/dma-mapping.c               | 26 +++++---
 arch/ia64/hp/common/sba_iommu.c         |  6 +-
 arch/mips/jazz/jazzdma.c                |  2 +-
 arch/powerpc/kernel/iommu.c             |  6 +-
 arch/powerpc/platforms/ps3/system-bus.c |  2 +-
 arch/powerpc/platforms/pseries/vio.c    |  5 +-
 arch/s390/pci/pci_dma.c                 | 13 ++--
 arch/sparc/kernel/iommu.c               |  6 +-
 arch/sparc/kernel/pci_sun4v.c           |  6 +-
 arch/sparc/mm/iommu.c                   |  2 +-
 arch/x86/kernel/amd_gart_64.c           | 18 +++---
 drivers/iommu/dma-iommu.c               | 23 ++++---
 drivers/iommu/iommu.c                   | 15 +++--
 drivers/parisc/ccio-dma.c               |  2 +-
 drivers/parisc/sba_iommu.c              |  2 +-
 drivers/xen/swiotlb-xen.c               |  2 +-
 include/linux/dma-map-ops.h             |  5 +-
 include/linux/dma-mapping.h             | 35 +++--------
 include/linux/iommu.h                   | 22 +++----
 kernel/dma/direct.c                     |  2 +-
 kernel/dma/dummy.c                      |  2 +-
 kernel/dma/mapping.c                    | 82 ++++++++++++++++++++++---
 23 files changed, 177 insertions(+), 117 deletions(-)

base-commit: ff1176468d368232b684f75e82563369208bc371 --
2.20.1