linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org,
	linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
	iommu@lists.linux-foundation.org, linux-parisc@vger.kernel.org,
	xen-devel@lists.xenproject.org
Cc: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Stephen Bates <sbates@raithlin.com>,
	Martin Oliveira <martin.oliveira@eideticom.com>,
	Logan Gunthorpe <logang@deltatee.com>,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>
Subject: [PATCH v3 05/21] alpha: return error code from alpha_pci_map_sg()
Date: Thu, 29 Jul 2021 14:15:23 -0600	[thread overview]
Message-ID: <20210729201539.5602-6-logang@deltatee.com> (raw)
In-Reply-To: <20210729201539.5602-1-logang@deltatee.com>

From: Martin Oliveira <martin.oliveira@eideticom.com>

The .map_sg() op now expects an error code instead of zero on failure.

pci_map_single_1() can fail for different reasons, but since the only
supported type of error return is DMA_MAPPING_ERROR, we coalesce those
errors into EIO.

ENOMEM is returned when no page tables can be allocated.

Signed-off-by: Martin Oliveira <martin.oliveira@eideticom.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
 arch/alpha/kernel/pci_iommu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 35d7b3096d6e..21f9ac101324 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -649,7 +649,9 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
 		sg->dma_address
 		  = pci_map_single_1(pdev, SG_ENT_VIRT_ADDRESS(sg),
 				     sg->length, dac_allowed);
-		return sg->dma_address != DMA_MAPPING_ERROR;
+		if (sg->dma_address == DMA_MAPPING_ERROR)
+			return -EIO;
+		return 1;
 	}
 
 	start = sg;
@@ -685,8 +687,10 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
 	if (out < end)
 		out->dma_length = 0;
 
-	if (out - start == 0)
+	if (out - start == 0) {
 		printk(KERN_WARNING "pci_map_sg failed: no entries?\n");
+		return -ENOMEM;
+	}
 	DBGA("pci_map_sg: %ld entries\n", out - start);
 
 	return out - start;
@@ -699,7 +703,7 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
 	   entries.  Unmap them now.  */
 	if (out > start)
 		pci_unmap_sg(pdev, start, out - start, dir);
-	return 0;
+	return -ENOMEM;
 }
 
 /* Unmap a set of streaming mode DMA translations.  Again, cpu read
-- 
2.20.1


  parent reply	other threads:[~2021-07-29 20:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 20:15 [PATCH v3 00/21] .map_sg() error cleanup Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 01/21] dma-mapping: Allow map_sg() ops to return negative error codes Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 02/21] dma-direct: Return appropriate error code from dma_direct_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 03/21] iommu: Return full error code from iommu_map_sg[_atomic]() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 04/21] dma-iommu: Return error code from iommu_dma_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` Logan Gunthorpe [this message]
2021-07-29 20:15 ` [PATCH v3 06/21] ARM/dma-mapping: return error code from .map_sg() ops Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 07/21] ARM/dma-mapping: don't set failed sg dma_address to DMA_MAPPING_ERROR Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 08/21] ia64/sba_iommu: return error code from sba_map_sg_attrs() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 09/21] MIPS/jazzdma: return error code from jazz_dma_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 10/21] powerpc/iommu: return error code from .map_sg() ops Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 11/21] powerpc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 12/21] s390/pci: return error code from s390_dma_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 13/21] s390/pci: don't set failed sg dma_address to DMA_MAPPING_ERROR Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 14/21] sparc/iommu: return error codes from .map_sg() ops Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 15/21] sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 16/21] parisc: return error code from .map_sg() ops Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 17/21] xen: swiotlb: return error code from xen_swiotlb_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 18/21] x86/amd_gart: return error code from gart_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 19/21] x86/amd_gart: don't set failed sg dma_address to DMA_MAPPING_ERROR Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 20/21] dma-mapping: return error code from dma_dummy_map_sg() Logan Gunthorpe
2021-07-29 20:15 ` [PATCH v3 21/21] dma-mapping: Disallow .map_sg operations from returning zero on error Logan Gunthorpe
2021-08-09 15:16 ` [PATCH v3 00/21] .map_sg() error cleanup Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210729201539.5602-6-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=hch@lst.de \
    --cc=ink@jurassic.park.msu.ru \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m.szyprowski@samsung.com \
    --cc=martin.oliveira@eideticom.com \
    --cc=mattst88@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=rth@twiddle.net \
    --cc=sbates@raithlin.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [PATCH v3 05/21] alpha: return error code from alpha_pci_map_sg()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox