s390/pci: return error code from s390_dma_map_sg()
authorMartin Oliveira <martin.oliveira@eideticom.com>
Thu, 29 Jul 2021 20:15:30 +0000 (14:15 -0600)
committerChristoph Hellwig <hch@lst.de>
Mon, 9 Aug 2021 15:13:06 +0000 (17:13 +0200)
The .map_sg() op now expects an error code instead of zero on failure.

So propagate the error from __s390_dma_map_sg() up. __s390_dma_map_sg()
returns either -ENOMEM on allocation failure or -EINVAL which is
the same as what's expected by dma_map_sgtable().

Signed-off-by: Martin Oliveira <martin.oliveira@eideticom.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
arch/s390/pci/pci_dma.c

index ebc9a49..c78b020 100644 (file)
@@ -487,7 +487,7 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
        unsigned int max = dma_get_max_seg_size(dev);
        unsigned int size = s->offset + s->length;
        unsigned int offset = s->offset;
-       int count = 0, i;
+       int count = 0, i, ret;
 
        for (i = 1; i < nr_elements; i++) {
                s = sg_next(s);
@@ -497,8 +497,9 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
 
                if (s->offset || (size & ~PAGE_MASK) ||
                    size + s->length > max) {
-                       if (__s390_dma_map_sg(dev, start, size,
-                                             &dma->dma_address, dir))
+                       ret = __s390_dma_map_sg(dev, start, size,
+                                               &dma->dma_address, dir);
+                       if (ret)
                                goto unmap;
 
                        dma->dma_address += offset;
@@ -511,7 +512,8 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
                }
                size += s->length;
        }
-       if (__s390_dma_map_sg(dev, start, size, &dma->dma_address, dir))
+       ret = __s390_dma_map_sg(dev, start, size, &dma->dma_address, dir);
+       if (ret)
                goto unmap;
 
        dma->dma_address += offset;
@@ -523,7 +525,7 @@ unmap:
                s390_dma_unmap_pages(dev, sg_dma_address(s), sg_dma_len(s),
                                     dir, attrs);
 
-       return 0;
+       return ret;
 }
 
 static void s390_dma_unmap_sg(struct device *dev, struct scatterlist *sg,