From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54078C07E95 for ; Fri, 16 Jul 2021 08:24:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F84F613ED for ; Fri, 16 Jul 2021 08:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237520AbhGPI1i (ORCPT ); Fri, 16 Jul 2021 04:27:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:29638 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237504AbhGPI1i (ORCPT ); Fri, 16 Jul 2021 04:27:38 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16G82sot034778; Fri, 16 Jul 2021 04:24:15 -0400 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== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 39tw3vn83n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 04:24:15 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16G8EkKq007904; Fri, 16 Jul 2021 08:24:13 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 39s3p78tv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 08:24:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16G8OAou20840890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jul 2021 08:24:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 167C84C04A; Fri, 16 Jul 2021 08:24:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C04E4C04E; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Received: from sig-9-145-73-130.uk.ibm.com (unknown [9.145.73.130]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() From: Niklas Schnelle 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 Date: Fri, 16 Jul 2021 10:24:08 +0200 In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-ORIG-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-16_02:2021-07-16,2021-07-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 clxscore=1011 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107160048 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5F6DC12002 for ; Fri, 16 Jul 2021 08:25:09 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F93D613ED for ; Fri, 16 Jul 2021 08:25:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F93D613ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GR46p6qzdz3bdW for ; Fri, 16 Jul 2021 18:25:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=BMc79y1K; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=schnelle@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=BMc79y1K; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GR4691Pckz2yyP for ; Fri, 16 Jul 2021 18:24:32 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16G82sot034778; Fri, 16 Jul 2021 04:24:15 -0400 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== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 39tw3vn83n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 04:24:15 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16G8EkKq007904; Fri, 16 Jul 2021 08:24:13 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 39s3p78tv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 08:24:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16G8OAou20840890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jul 2021 08:24:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 167C84C04A; Fri, 16 Jul 2021 08:24:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C04E4C04E; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Received: from sig-9-145-73-130.uk.ibm.com (unknown [9.145.73.130]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() From: Niklas Schnelle 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 Date: Fri, 16 Jul 2021 10:24:08 +0200 In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-ORIG-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-16_02:2021-07-16, 2021-07-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 clxscore=1011 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107160048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Gorbik , Heiko Carstens , Martin Oliveira , Stephen Bates , Christian Borntraeger , Gerald Schaefer , Robin Murphy , Christoph Hellwig , Marek Szyprowski Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3C5CC07E95 for ; Fri, 16 Jul 2021 12:44:04 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94E18613E3 for ; Fri, 16 Jul 2021 12:44:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94E18613E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5D5F060DA5; Fri, 16 Jul 2021 12:44:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hu7cmXv1TSif; Fri, 16 Jul 2021 12:44:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 517CA60677; Fri, 16 Jul 2021 12:44:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 269D0C0010; Fri, 16 Jul 2021 12:44:02 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 338A3C000E for ; Fri, 16 Jul 2021 08:24:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 19ED440545 for ; Fri, 16 Jul 2021 08:24:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=ibm.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PuLOP7PeHxG2 for ; Fri, 16 Jul 2021 08:24:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0FE504047F for ; Fri, 16 Jul 2021 08:24:29 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16G82sot034778; Fri, 16 Jul 2021 04:24:15 -0400 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== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 39tw3vn83n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 04:24:15 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16G8EkKq007904; Fri, 16 Jul 2021 08:24:13 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 39s3p78tv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 08:24:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16G8OAou20840890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jul 2021 08:24:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 167C84C04A; Fri, 16 Jul 2021 08:24:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C04E4C04E; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Received: from sig-9-145-73-130.uk.ibm.com (unknown [9.145.73.130]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() From: Niklas Schnelle 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 Date: Fri, 16 Jul 2021 10:24:08 +0200 In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-ORIG-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-16_02:2021-07-16, 2021-07-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 clxscore=1011 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107160048 X-Mailman-Approved-At: Fri, 16 Jul 2021 12:44:01 +0000 Cc: Vasily Gorbik , Heiko Carstens , Martin Oliveira , Stephen Bates , Christian Borntraeger , Gerald Schaefer , Robin Murphy , Christoph Hellwig X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC55C07E95 for ; Fri, 16 Jul 2021 08:26:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E15DB6128B for ; Fri, 16 Jul 2021 08:26:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E15DB6128B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CP07y7VMwRZv4LMgWD+Pq09nehGxZ6e/x5F1kAWcJYI=; b=eNEfwjUZ3ro2e9 wcrcjWlJOUSNsCaxOB3s9ZmxRQc2FrHM5lbiXbJXcorQb9IzTb/M3UAIjzlnLqfZaY5jEnYhRw2yf +VdmKthvYgJhgCyvl31nele3Fy7zYL33nKn1E9c+9CA/har9dN4Oxv5UXzQZ5RC6eL4ibjfNFQ8fy Ebb0x6ox63DItPE1okhFmQnJw9Xm5Rj6eDSYMaN7MAAlzRVjMXjjlCHQISPbHVYOtBY60VS7uZLkE k6hy/Rg2ja14hznvgH5euUjvAGX/FehxFMPQXJLcIvhpBm7vLZlPd5szdekdJM1baNf6onh7XITWw WK0rze9HMZiATXAjbQ5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4J94-003iBy-PK; Fri, 16 Jul 2021 08:24:30 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4J90-003iAH-VZ for linux-arm-kernel@lists.infradead.org; Fri, 16 Jul 2021 08:24:28 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16G82sot034778; Fri, 16 Jul 2021 04:24:15 -0400 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== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 39tw3vn83n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 04:24:15 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16G8EkKq007904; Fri, 16 Jul 2021 08:24:13 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 39s3p78tv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 08:24:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16G8OAou20840890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jul 2021 08:24:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 167C84C04A; Fri, 16 Jul 2021 08:24:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C04E4C04E; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Received: from sig-9-145-73-130.uk.ibm.com (unknown [9.145.73.130]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 16 Jul 2021 08:24:09 +0000 (GMT) Message-ID: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() From: Niklas Schnelle 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 Date: Fri, 16 Jul 2021 10:24:08 +0200 In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-ORIG-GUID: Au675VXZyfEIxm3kG5FUCjrWY9DzzlcG X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-16_02:2021-07-16, 2021-07-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 clxscore=1011 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107160048 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_012427_246188_3D99BB07 X-CRM114-Status: GOOD ( 28.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Niklas Schnelle Date: Fri, 16 Jul 2021 08:24:08 +0000 Subject: Re: [PATCH v1 10/16] s390/pci: return error code from s390_dma_map_sg() Message-Id: <352f2a35d62399fce1dca0ce1158974ecda3904c.camel@linux.ibm.com> List-Id: References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-11-logang@deltatee.com> In-Reply-To: <20210715164544.6827-11-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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