linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Logan Gunthorpe <logang@deltatee.com>,
	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>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg()
Date: Fri, 16 Jul 2021 10:24:08 +0200	[thread overview]
Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> (raw)
In-Reply-To: <20210715164544.6827-11-logang@deltatee.com>

On Thu, 2021-07-15 at 10:45 -0600, Logan Gunthorpe wrote:
> From: Martin Oliveira <martin.oliveira@eideticom.com>
> 
> The .map_sg() op now expects an error code instead of zero on failure.
> 
> So propagate the error from __s390_dma_map_sg() up.
> 
> Signed-off-by: Martin Oliveira <martin.oliveira@eideticom.com>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: 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>
> ---
>  arch/s390/pci/pci_dma.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
> index ebc9a49523aa..c78b02012764 100644
> --- a/arch/s390/pci/pci_dma.c
> +++ b/arch/s390/pci/pci_dma.c
> @@ -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 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
>  		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,

So the error codes we return are -ENOMEM if allocating a DMA
translation entry fails and -EINVAL if the DMA translation table hasn't
been initialized or the caller tries to map 0 sized memory. Are these
error codes that you would expect? If yes then this change looks good
to me.

Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>


  reply	other threads:[~2021-07-16  8:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 16:45 [PATCH v1 00/16] .map_sg() error cleanup Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 01/16] dma-mapping: Allow map_sg() ops to return negative error codes Logan Gunthorpe
2021-07-16  6:29   ` Christoph Hellwig
2021-07-15 16:45 ` [PATCH v1 02/16] dma-direct: Return appropriate error code from dma_direct_map_sg() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 03/16] iommu: Return full error code from iommu_map_sg[_atomic]() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 04/16] dma-iommu: Return error code from iommu_dma_map_sg() Logan Gunthorpe
2021-07-16  6:31   ` Christoph Hellwig
2021-07-15 16:45 ` [PATCH v1 05/16] alpha: return error code from alpha_pci_map_sg() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 06/16] ARM/dma-mapping: return error code from .map_sg() ops Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 07/16] ia64/sba_iommu: return error code from sba_map_sg_attrs() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 08/16] MIPS/jazzdma: return error code from jazz_dma_map_sg() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 09/16] powerpc/iommu: return error code from .map_sg() ops Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() Logan Gunthorpe
2021-07-16  8:24   ` Niklas Schnelle [this message]
2021-07-15 16:45 ` [PATCH v1 11/16] sparc/iommu: return error codes from .map_sg() ops Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 12/16] parisc: return error code " Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 13/16] xen: swiotlb: return error code from xen_swiotlb_map_sg() Logan Gunthorpe
2021-07-19 20:22   ` Boris Ostrovsky
2021-07-15 16:45 ` [PATCH v1 14/16] x86/amd_gart: return error code from gart_map_sg() Logan Gunthorpe
2021-07-16  6:32   ` Christoph Hellwig
2021-07-16 12:11     ` Robin Murphy
2021-07-15 16:45 ` [PATCH v1 15/16] dma-mapping: return error code from dma_dummy_map_sg() Logan Gunthorpe
2021-07-15 16:45 ` [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error Logan Gunthorpe
2021-07-16  6:33   ` Christoph Hellwig
2021-07-16 12:19     ` Robin Murphy
2021-07-16 16:17     ` Logan Gunthorpe
2021-07-15 16:53 ` [PATCH v1 00/16] .map_sg() error cleanup Russell King (Oracle)
2021-07-15 16:56   ` Logan Gunthorpe

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=352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --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=logang@deltatee.com \
    --cc=m.szyprowski@samsung.com \
    --cc=martin.oliveira@eideticom.com \
    --cc=robin.murphy@arm.com \
    --cc=sbates@raithlin.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_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
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).