• Logan Gunthorpe's avatar
    dma-mapping: allow map_sg() ops to return negative error codes · fffe3cc8
    Logan Gunthorpe authored
    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: default avatarLogan Gunthorpe <logang@deltatee.com>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    fffe3cc8
mapping.c 23.3 KB