dma-mapping: allow map_sg() ops to return negative error codes
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 29 Jul 2021 20:15:19 +0000 (14:15 -0600)
committerChristoph Hellwig <hch@lst.de>
Mon, 9 Aug 2021 15:13:02 +0000 (17:13 +0200)
commitfffe3cc8c2194f60c4af4fac7f27d25e8828f001
tree355e3659644e50766165690c2d549fd154d684ed
parent173735c346c412d9f084825ecb04f24ada0e2986
dma-mapping: allow map_sg() ops to return negative error codes

Allow dma_map_sgtable() to pass errors from the map_sg() ops. This
will be required for returning appropriate error codes when mapping
P2PDMA memory.

Introduce __dma_map_sg_attrs() which will return the raw error code
from the map_sg operation (whether it be negative or zero). Then add a
dma_map_sg_attrs() wrapper to convert any negative errors to zero to
satisfy the existing calling convention.

dma_map_sgtable() defines three error codes that .map_sg implementations
are allowed to return: -EINVAL, -ENOMEM and -EIO. The latter of which
is a generic return for cases that are passing DMA_MAPPING_ERROR
through.

dma_map_sgtable() will convert a zero error return for old map_sg() ops
into a -EIO return and return any negative errors as reported.

This allows map_sg implementations to start returning multiple
negative error codes. Legacy map_sg implementations can continue
to return zero until they are all converted.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
include/linux/dma-map-ops.h
include/linux/dma-mapping.h
kernel/dma/mapping.c