Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp607228pxv; Thu, 15 Jul 2021 11:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGyvI5R2yuLOg365rf3pNq5nxwqcSTKROHbtrHTbk7J10Fm1smh5z+qav1YTTvfoPnE1J8 X-Received: by 2002:a05:6e02:e02:: with SMTP id a2mr3555049ilk.127.1626373340691; Thu, 15 Jul 2021 11:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626373340; cv=none; d=google.com; s=arc-20160816; b=VIbUeIws9qrxT71W1Tb+o6OFOm9jNJJmwWdUyWHSg+lWLj3k0qA9dvKZs+fM03PsQh tj1pvvM8h7GyRnWvvZHe6i7nDjvOdZij9kwENDmtG/mF/tWA3DBheWa5k+c/BIQba0X9 Gdv/KR3bUpgcg8q4/SQYWmoHVSGpQHxgfMmqLCowqZv9D17fVAsmcraADPIUuGHARdIT ZqXHPSdW63Fe2HyPCFBePfhwl/K1XU+GHpETym/CizG00f7KkuF6ne0fDEBX6fS8ZoRW IFXDs3Kv1wtCv6tXDwBLAowKMUgW7pTqJGBPzkNRqfoKE2YKjr29BhmYxQj1s1WyWLQk 5CJw== 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=j6Pr/OuRQ0FDOA0vFikKAhizbVvYkzaBamOZP0pmeEg=; b=bcP5v/X++boKzMCPZtBVbZA+z9Qpvr4Yd9YvTjlGu196mFqeJSz12HtBAy2TD936OV FNeaK8Bh+XeHEMkWvTwijNwlG7drCO0xuyxpvHTb4r69EWOvQhjcirFjzWcwSoYocNEQ jk4fwmiBEaMK6OGz+B7wSGHphMhiBD9u9JLYeatcdbmXXfWI3lSQoGnkUmTRx3lGmzwn BhKpQFPmjN+EEI2Z18wqvWpdyTviyvrWPzV+jNpT4kcwpCqb5qYVPYnJjIDKGTygE7WR RvosX2PttekDHkeMQcw9ArDYdD/QmJxAkktJCmw2O3IzTbTxz4a86smuZOZTDBDcei1f tSvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Dkn3q4LV; 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 z25si4833696iod.45.2021.07.15.11.22.08; Thu, 15 Jul 2021 11:22:20 -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=Dkn3q4LV; 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 S234683AbhGOQtc (ORCPT + 99 others); Thu, 15 Jul 2021 12:49:32 -0400 Received: from ale.deltatee.com ([204.191.154.188]:50126 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbhGOQtH (ORCPT ); Thu, 15 Jul 2021 12:49:07 -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=j6Pr/OuRQ0FDOA0vFikKAhizbVvYkzaBamOZP0pmeEg=; b=Dkn3q4LV3x6P2TnAQ4dHbiy0gT dHrqGIqsYfANtr88cB4SDDmwoDAm+3uMXwwUMCZ5FDoIEaICaRygRCgjZCR1YWHKgaDLwGd7pcIds LPRHC56e5Ne+6AJEfCgMVy5UwvTjTaLVsU9csxkrEf4u+SsNzIhl19BpCNJzR+mGxBoNX+XpJZ1Th hwJWkb9pyr1rz6+CFF31AEDrthTPJGyTTUWW58QveoemPsYFHnAnEhW+LulIW1Nl3aByuE69itje2 t2Vw4QfVY/ws9zJK0WYtD95XW1HBnPxc3TFddZSrjQawxAgva8UCldcIeIcd0Pt4xkD5WIL0MUWWt wyEWisGw==; 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 1m44V0-0001yc-48; Thu, 15 Jul 2021 10:46:11 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1m44Uo-0001nW-Ns; 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 , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Geoff Levand Date: Thu, 15 Jul 2021 10:45:37 -0600 Message-Id: <20210715164544.6827-10-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, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, geoff@infradead.org 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 09/16] powerpc/iommu: 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. Propagate the error up if vio_dma_iommu_map_sg() fails. ppc_iommu_map_sg() may fail either because of iommu_range_alloc() or because of tbl->it_ops->set(). The former only supports returning an error with DMA_MAPPING_ERROR and an examination of the latter indicates that it may return arch-specific errors (for example, tce_buildmulti_pSeriesLP()). Hence, coalesce all of those errors into -EINVAL; Signed-off-by: Martin Oliveira Signed-off-by: Logan Gunthorpe Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Geoff Levand --- arch/powerpc/kernel/iommu.c | 4 ++-- arch/powerpc/platforms/ps3/system-bus.c | 2 +- arch/powerpc/platforms/pseries/vio.c | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 2af89a5e379f..bd0ed618bfa5 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -473,7 +473,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, BUG_ON(direction == DMA_NONE); if ((nelems == 0) || !tbl) - return 0; + return -EINVAL; outs = s = segstart = &sglist[0]; outcount = 1; @@ -599,7 +599,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, if (s == outs) break; } - return 0; + return -EINVAL; } diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c index 1a5665875165..c54eb46f0cfb 100644 --- a/arch/powerpc/platforms/ps3/system-bus.c +++ b/arch/powerpc/platforms/ps3/system-bus.c @@ -663,7 +663,7 @@ static int ps3_ioc0_map_sg(struct device *_dev, struct scatterlist *sg, unsigned long attrs) { BUG(); - return 0; + return -EINVAL; } static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg, diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c index e00f3725ec96..e31e59c54f30 100644 --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -560,7 +560,8 @@ static int vio_dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, for_each_sg(sglist, sgl, nelems, count) alloc_size += roundup(sgl->length, IOMMU_PAGE_SIZE(tbl)); - if (vio_cmo_alloc(viodev, alloc_size)) + ret = vio_cmo_alloc(viodev, alloc_size); + if (ret) goto out_fail; ret = ppc_iommu_map_sg(dev, tbl, sglist, nelems, dma_get_mask(dev), direction, attrs); @@ -577,7 +578,7 @@ static int vio_dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, vio_cmo_dealloc(viodev, alloc_size); out_fail: atomic_inc(&viodev->cmo.allocs_failed); - return 0; + return ret; } static void vio_dma_iommu_unmap_sg(struct device *dev, -- 2.20.1