From mboxrd@z Thu Jan 1 00:00:00 1970 From: Niklas Schnelle 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 Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=8Of+ionZ0K44S7zzH2G1wGenaNNg9cYQDtiQ0dQz6+E=; b=BMc79y1KhhQKUFZbOrAhtcEP61wGvhCcKpBh3YItmYniaHy7RinkekOStAMhwPcVbV8g tA8KdxQW6CmdQCUDo7HXnXeBDvsxeO1Bxcn4vmR46+BPBqB7+8Ctzlwih1eoet+d/O4e U7lnzCYwkCmnuQ2N7TeXEVQB0tNbOBoSC9rb2wWdVRh2ThxQaLFsKo3f4ZcKX5kegGXy lsJ/BZHBXKo8Vpdp79tRxovqbQ5nmEvbTtQHpKKZhzPMbI6YKxeWxAqOAKu0r38O+7Ex 7l5jIUCj1b6+Lwrw1Hy8lrhsFTfLuxB+ksipWyRyg3640fKq4qgCXYb8/oO8DK9d7iju gA== In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> List-ID: Content-Type: text/plain; charset="us-ascii" To: Logan Gunthorpe , 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 , Marek Szyprowski , Robin Murphy , Stephen Bates , Martin Oliveira , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger On Thu, 2021-07-15 at 10:45 -0600, Logan Gunthorpe wrote: > From: Martin Oliveira > > 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 > Signed-off-by: Logan Gunthorpe > Cc: Niklas Schnelle > Cc: Gerald Schaefer > Cc: Heiko Carstens > Cc: Vasily Gorbik > Cc: Christian Borntraeger > --- > 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