Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp607251pxv; Thu, 15 Jul 2021 11:22:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3/0D/VIKccUE5CiklR0J8duLrCfRKz22JPz5gTlP0OJ6ptuLhL0LINJNfxaQB2fMNZUPI X-Received: by 2002:a02:90cb:: with SMTP id c11mr5270521jag.53.1626373342374; Thu, 15 Jul 2021 11:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626373342; cv=none; d=google.com; s=arc-20160816; b=qT2b2zXXbC8kLK9BBb/n9I4JWCv5u1TF6HyK17hLZxi/+VDAxSDrjD6MjFyIcyVcl7 N6cBveuTsWydvqPPd6pijwJIkQJhqu6bmMJk64AWztTQXSkzNiGjFZlMenkixohOcO88 anzCsEeYhCSNXwBYd4jl8qpnbS0TlVYtd0IAvpwAM4Ifnt1zoy01IrMZD5LEteJSyHr3 jjdNfCFqdOVKZS5Yw32pLEBRV/9gGyuVpkValzlSILmZwoQdCpPnc/UTRBzysbtEP//r fQoOwkfMspVto9Zu8ez27E7xu8OwMKC7CZl8PWpiY5NyUT0NoaLQrpr9ilFNShFzYvJk Tw3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=tVzBPY6/Bgdpsr8bmfZpwFmQV8rVEWLD9Ju+AXRRB/Q=; b=ZY3uB5AlWoQTkbfAKtpqq+N40baZo+/Kcy6Ik65lBskTe7q+vAjGZv5My08nl7LOKC JRcPu4yCpPs63B0Oy7GSqGTdlJuhrllf0b5UI3aKxb1wkjCPlDEqiO9vSMtwNh+95S60 g8yTmY1A+VUzizW7BsElviqJHTGl1Pj9IIn2rivjsYOdPjG6J7UnY4jXRA3sZW6DONvV G9RrZLiAMO0iaRI0QwhB3e/49N6lt/kVQ5ic5M5Jrr/AFpXkqcK+tFasbc2rqKyH/mOx gbnyJMpbyLCyUk3YsJhAQqfoS3YG3VlqUXh5LHMVEGcGybV3HxTO40qAJgVdn/s09g+I yKbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=sT6nIphY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si7140658iot.9.2021.07.15.11.22.09; Thu, 15 Jul 2021 11:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=sT6nIphY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235914AbhGOQtj (ORCPT + 99 others); Thu, 15 Jul 2021 12:49:39 -0400 Received: from ale.deltatee.com ([204.191.154.188]:50190 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234292AbhGOQtJ (ORCPT ); Thu, 15 Jul 2021 12:49:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=tVzBPY6/Bgdpsr8bmfZpwFmQV8rVEWLD9Ju+AXRRB/Q=; b=sT6nIphYRpQg2LPmIHPAN9+aTu GJh+kG/x4SM7ujeEOwTJw5ilEgyuKzytEd4BRwwLa0nLKahIc7+GQ9qJ4fA5Hu9384ZtjsbuG2b92 s51DHr3LmCxuscjDOqlyMZ7uwWmozJZCa9HkoIp885CAsrDYo/QLqd7pHbw54nqIDcuExXUrrVRfw hZPArbok7AiyAtDvc1e+GRkLRV8zgo/jTjvTVyD1VZI/lSLxAe/izWpR6ucAyWORMvAeNpU6T2dEP ToPwTmhEJvkkerb0Tb9hn7uJF1hapwuF3GeNQtxgW4wYN95t0lZGeB9IRWqetmlEjHzeTZ71Uml4S 1lVZm5YQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m44V1-0001yg-Li; Thu, 15 Jul 2021 10:46:12 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1m44Uo-0001nN-8x; Thu, 15 Jul 2021 10:45:58 -0600 From: Logan Gunthorpe 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 , Marek Szyprowski , Robin Murphy , Stephen Bates , Martin Oliveira , Logan Gunthorpe , Russell King , Thomas Bogendoerfer Date: Thu, 15 Jul 2021 10:45:34 -0600 Message-Id: <20210715164544.6827-7-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210715164544.6827-1-logang@deltatee.com> References: <20210715164544.6827-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-parisc@vger.kernel.org, xen-devel@lists.xenproject.org, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, sbates@raithlin.com, martin.oliveira@eideticom.com, logang@deltatee.com, linux@armlinux.org.uk, tsbogend@alpha.franken.de X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v1 06/16] ARM/dma-mapping: return error code from .map_sg() ops X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Oliveira The .map_sg() op now expects an error code instead of zero on failure, so propagate any errors that may happen all the way up. Signed-off-by: Martin Oliveira Signed-off-by: Logan Gunthorpe Cc: Russell King Cc: Thomas Bogendoerfer --- arch/arm/mm/dma-mapping.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c4b8df2ad328..8c286e690756 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -980,7 +980,7 @@ int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, { const struct dma_map_ops *ops = get_dma_ops(dev); struct scatterlist *s; - int i, j; + int i, j, ret; for_each_sg(sg, s, nents, i) { #ifdef CONFIG_NEED_SG_DMA_LENGTH @@ -988,7 +988,8 @@ int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, #endif s->dma_address = ops->map_page(dev, sg_page(s), s->offset, s->length, dir, attrs); - if (dma_mapping_error(dev, s->dma_address)) + ret = dma_mapping_error(dev, s->dma_address); + if (ret) goto bad_mapping; } return nents; @@ -996,7 +997,7 @@ int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, bad_mapping: for_each_sg(sg, s, i, j) ops->unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir, attrs); - return 0; + return ret; } /** @@ -1622,7 +1623,7 @@ static int __iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, bool is_coherent) { struct scatterlist *s = sg, *dma = sg, *start = sg; - int i, count = 0; + int i, count = 0, ret; unsigned int offset = s->offset; unsigned int size = s->offset + s->length; unsigned int max = dma_get_max_seg_size(dev); @@ -1634,8 +1635,10 @@ static int __iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, s->dma_length = 0; if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) { - if (__map_sg_chunk(dev, start, size, &dma->dma_address, - dir, attrs, is_coherent) < 0) + ret = __map_sg_chunk(dev, start, size, + &dma->dma_address, dir, attrs, + is_coherent); + if (ret < 0) goto bad_mapping; dma->dma_address += offset; @@ -1648,8 +1651,9 @@ static int __iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, } size += s->length; } - if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir, attrs, - is_coherent) < 0) + ret = __map_sg_chunk(dev, start, size, &dma->dma_address, dir, attrs, + is_coherent); + if (ret < 0) goto bad_mapping; dma->dma_address += offset; @@ -1660,7 +1664,7 @@ static int __iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, bad_mapping: for_each_sg(sg, s, count, i) __iommu_remove_mapping(dev, sg_dma_address(s), sg_dma_len(s)); - return 0; + return ret; } /** -- 2.20.1