linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remove the ->mapping_error method from dma_map_ops V3
@ 2018-11-30 13:22 Christoph Hellwig
  2018-11-30 13:22 ` [PATCH 01/23] dma-mapping: provide a generic DMA_MAPPING_ERROR Christoph Hellwig
                   ` (26 more replies)
  0 siblings, 27 replies; 31+ messages in thread
From: Christoph Hellwig @ 2018-11-30 13:22 UTC (permalink / raw)
  To: iommu
  Cc: Linus Torvalds, Jon Mason, Joerg Roedel, David Woodhouse,
	Marek Szyprowski, Robin Murphy, x86, linux-alpha,
	linux-arm-kernel, linux-ia64, linux-parisc, xen-devel,
	linux-arch, linux-kernel

Error reporting for the dma_map_single and dma_map_page operations is
currently a mess.  Both APIs directly return the dma_addr_t to be used for
the DMA, with a magic error escape that is specific to the instance and
checked by another method provided.  This has a few downsides:

 - the error check is easily forgotten and a __must_check marker doesn't
   help as the value always is consumed anyway
 - the error checking requires another indirect call, which have gotten
   incredibly expensive
 - a lot of code is wasted on implementing these methods

The historical reason for this is that people thought DMA mappings would
not fail when the API was created, which sounds like a really bad
assumption in retrospective, and then we tried to cram error handling
onto it later on.

There basically are two variants:  the error code is 0 because the
implementation will never return 0 as a valid DMA address, or the error
code is all-F as the implementation won't ever return an address that
high.  The old AMD GART is the only one not falling into these two camps
as it picks sort of a relative zero relative to where it is mapped.

The 0 return doesn't work for direct mappings that have ram at address
zero and a lot of IOMMUs that start allocating bus space from address
zero, so we can't consolidate on that, but I think we can move everyone
to all-Fs, which the patch here does.  The reason for that is that
there is only one way to ever get this address: by doing a 1-byte long,
1-byte aligned mapping, but all our mappings are not only longer but
generally aligned, and the mappings have to keep at least the basic
alignment.

A git tree is also available here:

    git://git.infradead.org/users/hch/misc.git dma-mapping-error.3

Gitweb:

    http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-mapping-error.3

Changes since v2:
 - fix a compile error in the ia64 sba_iommu driver
 - return an errno value from dma_mapping_error

Changes since v1:
 - dropped the signature change
 - split into multiple patches
 - fixed the iova allocator return check in amd-iommu
 - remove EMERGENCY_PAGES in amd_gart and calgary

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

end of thread, other threads:[~2018-12-06 14:58 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-30 13:22 remove the ->mapping_error method from dma_map_ops V3 Christoph Hellwig
2018-11-30 13:22 ` [PATCH 01/23] dma-mapping: provide a generic DMA_MAPPING_ERROR Christoph Hellwig
2018-12-04 16:41   ` Robin Murphy
2018-12-04 22:33     ` Christoph Hellwig
2018-11-30 13:22 ` [PATCH 02/23] dma-direct: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-30 13:22 ` [PATCH 03/23] arm: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 04/23] powerpc/iommu: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 05/23] mips/jazz: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 06/23] s390: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 07/23] sparc: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 08/23] parisc/ccio: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 09/23] parisc/sba_iommu: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 10/23] arm64: remove the dummy_dma_ops mapping_error method Christoph Hellwig
2018-11-30 13:22 ` [PATCH 11/23] alpha: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-30 13:22 ` [PATCH 12/23] ia64/sba_iommu: improve internal map_page users Christoph Hellwig
2018-11-30 13:22 ` [PATCH 13/23] ia64/sba_iommu: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-30 13:22 ` [PATCH 14/23] ia64/sn: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 15/23] x86/amd_gart: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 16/23] x86/calgary: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 17/23] iommu: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 18/23] iommu/intel: small map_page cleanup Christoph Hellwig
2018-11-30 13:22 ` [PATCH 19/23] iommu/vt-d: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-30 13:22 ` [PATCH 20/23] iommu/dma-iommu: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 21/23] xen-swiotlb: " Christoph Hellwig
2018-12-02 12:42   ` Konrad Rzeszutek Wilk
2018-11-30 13:22 ` [PATCH 22/23] dma-mapping: " Christoph Hellwig
2018-11-30 13:22 ` [PATCH 23/23] dma-mapping: return an error code from dma_mapping_error Christoph Hellwig
2018-11-30 18:59 ` remove the ->mapping_error method from dma_map_ops V3 Russell King - ARM Linux
2018-11-30 19:43 ` Linus Torvalds
2018-12-03 17:27 ` Christoph Hellwig
2018-12-06 14:57 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).