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>
This commit is contained in:
committed by
Christoph Hellwig
parent
173735c346
commit
fffe3cc8c2
@@ -41,8 +41,9 @@ struct dma_map_ops {
|
||||
size_t size, enum dma_data_direction dir,
|
||||
unsigned long attrs);
|
||||
/*
|
||||
* map_sg returns 0 on error and a value > 0 on success.
|
||||
* It should never return a value < 0.
|
||||
* map_sg should return a negative error code on error. See
|
||||
* dma_map_sgtable() for a list of appropriate error codes
|
||||
* and their meanings.
|
||||
*/
|
||||
int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction dir, unsigned long attrs);
|
||||
|
||||
Reference in New Issue
Block a user