Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp889422pxb; Wed, 27 Oct 2021 14:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXROpkzdpti8KBr08kcq1ipei7sYyMJyaUk+6YCwhccDH80wMWusKbJL3N1BpteSRi+7yJ X-Received: by 2002:a17:907:a412:: with SMTP id sg18mr158133ejc.108.1635370333905; Wed, 27 Oct 2021 14:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370333; cv=none; d=google.com; s=arc-20160816; b=fPOnbHRkdh8S4bAknRjerQEJ2pI/xHexqkm5uWXT6Q22sXmH9n6ijPZf5qBglBsFHZ ZC0uauNGcJViNaElmM3tmSOIyrrFHYsE2EhZpdoGB75UpYJcw6mb+JpFsggGHlkXmZc/ sXLWM6abto9JKw0nq2dFtenkJlj4SlcCVVz/NtBnLUT7VvulrjeiCs7fhHqLMFp5zcQR UWf3jkXJtB9JtHDu90CurvvU7SZ7PRpZTKcO30ANeAZjWtlWcitPXbHvZ97ioU5kQ95w 1plsY4xWUeE7YKOJI3ElJlkzGyWWgUblOX7iyMD3PV3CPTgU/vK8KZ8L58+94zeP1+NE 54EA== 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 :message-id:date:cc:to:from:dkim-signature; bh=ixLSC4o+uhsNJFfM+3WjU/KW6d5SsHJCs8Tnj6YC5pw=; b=kYyX9jl27ZvzlI00LTEn/jObedCtFWsiQplEYsi1e/Q/VwVslzvguf866QhnbqVUkK 0Wylamwnwa5VuZJ91KIWoHvYeU4yWXfbUwCP2I2SvvmGN4y7WnmC2V3GoN+WURMWjKQw zwhu8/R/eN0YYRyUTywV2npVF4BXOFxnSJDa66747Lk4a6/mM5BW3lsbJlhKj/e80WV9 Xe6jLeAAO8gDRclufPAuV60R7DU5sr1TMo+N8gKoQhcBJCFXXmyte3v7H+BJ/tv61dPo Han+jfrIo0I0jhT9I+XJS3c/6VlI5HngPKowBNRq5Ay3lMcO0T54ZuQtoC2ehkhda+fG gGhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=okyWYXdf; 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 a40si1378546edf.583.2021.10.27.14.31.50; Wed, 27 Oct 2021 14:32:13 -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=okyWYXdf; 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 S238398AbhJ0Rup (ORCPT + 97 others); Wed, 27 Oct 2021 13:50:45 -0400 Received: from ale.deltatee.com ([204.191.154.188]:59054 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243484AbhJ0Ru2 (ORCPT ); Wed, 27 Oct 2021 13:50:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:Message-Id:Date:Cc:To:From :references:content-disposition:in-reply-to; bh=ixLSC4o+uhsNJFfM+3WjU/KW6d5SsHJCs8Tnj6YC5pw=; b=okyWYXdfSdHHJ5UP8SDWqAugiu PNPBruGGXoL5gOPZZFve7iL8xSnqUboGitotenc2EGldMrHEPhsCmQpeuKRsPiyFfL1rxPYHxP+bI qx91AlufbsY9c6CzEP1UoU0D4W37kM79WlgDnWL+I/O6/zs3J95MqLOYZrp1OlGJHw4Gvlpmv4KMq pXGuSD2AWOVu7WdJtvQ6oFX8cJ0qRKOxxM18074DQ3yV4IuuGZvupWg+KFylymBtlDTQne5hk7xux xOcJtPeOmkuEOHbr/ltyTBGHg4atELLPHTBBxVq+++6kTUVKOl9WBMUmKn+ja+vsK9FgliI2XdPcE EeACUFOA==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mfn1t-000kp8-0E; Wed, 27 Oct 2021 11:48:02 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1mfn1s-000VAK-Jp; Wed, 27 Oct 2021 11:48:00 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Christoph Hellwig Cc: Logan Gunthorpe , Marshall Midden , Joerg Roedel , Will Deacon Date: Wed, 27 Oct 2021 11:47:57 -0600 Message-Id: <20211027174757.119755-1-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, hch@lst.de, logang@deltatee.com, marshallmidden@gmail.com, joro@8bytes.org, will@kernel.org X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT,MYRULES_URI_HASH autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org scsi_dma_map() was reporting a failure during boot on an AMD machine with the IOMMU enabled. scsi_dma_map failed: request for 36 bytes! The issue was tracked down to a mistake in logic: should not return an error if iommu_deferred_attach() returns zero. Reported-by: Marshall Midden Fixes: dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()") Link: https://lore.kernel.org/all/CAD2CkAWjS8=kKwEEN4cgVNjyFORUibzEiCUA-X+SMtbo0JoMmA@mail.gmail.com Signed-off-by: Logan Gunthorpe Cc: Joerg Roedel Cc: Will Deacon --- drivers/iommu/dma-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) If possible, this fix should really get into Linus's tree before the v5.15 release. diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 896bea04c347..3e5a21b0bb24 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1016,7 +1016,8 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, if (static_branch_unlikely(&iommu_deferred_attach_enabled)) { ret = iommu_deferred_attach(dev, domain); - goto out; + if (ret) + goto out; } if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) base-commit: 3906fe9bb7f1a2c8667ae54e967dc8690824f4ea -- 2.30.2