Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp7835pxt; Wed, 4 Aug 2021 14:09:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuyREXHN1NkcqYMiPvHdqyh/WNH9E1oB0Mc96SaS0LtYyoR1n4JyF+NfZ5z6vt6MnouPK7 X-Received: by 2002:a92:d1cf:: with SMTP id u15mr1203921ilg.81.1628111383975; Wed, 04 Aug 2021 14:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628111383; cv=none; d=google.com; s=arc-20160816; b=cZ6GkNCaVgLKBOOqTF6FmOzXdI2tYAmpVSJleuL2GzfdMdes3fVFNX6iJREBdxyeMf 1dntDhtpX1SIlVmWtLc6teMQhvonOCJ/SIWSi1c8Q8D3hiV3Kxp2s8nZwMkw4PwHTmTo T6T7jRRa17MZOLyM4cKUpTdIfhP1qC4p13DmOddbaosjaFUgmplHc3yxIz/6IWgUZRAA Ce5/VQYyHWKNt9D4Que133GC1NwN7SwX6PME4kWFJGlTzofW23mJJehxsFS17aPfx97F yVCRWwI2Z6SI+bgHtxuMFc9XNtStrHePSZrc1AWN+rfNKmlTN8SyJ2h3etloEitvu6BR BcrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uDUvfY+BKfPQcYlRqKaFpfS5kNzjTVES+Nkd0VbUh08=; b=Ij/bsU78RZJsJ7dZ1jJ6MjjmLz7F8UyR4S0tZMPm5iC3UNXfkNPydY9bvD3PSEMGf6 veyxgw/6NioVPw2RxsWWyefvTBAOeO7dKzh01z2QKX88nzEkGF0rP3AJQpcQmPW+CaWE 9B86AKZULBhkO/LA+LqRVmCpo5wQ90h7HrurE9JGu7pFS46DDr6r7zbJ4T2ox7G/n6iL +CCKVIQCUpptQrpdoFNS79IPvA5wMS9QRSbKIYheG+oXossMWIONG+AkAfvAlj3iHCfo UTRqe1PHQE6f9xBtaQv8/oRaf2at55Y3rgFLnHd0kebK0gqKW0N9lEn98KIgzvIdEXMj A4Dg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si2966310ior.60.2021.08.04.14.09.29; Wed, 04 Aug 2021 14:09:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239453AbhHDSxJ (ORCPT + 99 others); Wed, 4 Aug 2021 14:53:09 -0400 Received: from gloria.sntech.de ([185.11.138.130]:50026 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239186AbhHDSxI (ORCPT ); Wed, 4 Aug 2021 14:53:08 -0400 Received: from ip5f5aa64a.dynamic.kabel-deutschland.de ([95.90.166.74] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBM0O-0002bp-FX; Wed, 04 Aug 2021 20:52:40 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: joro@8bytes.org, will@kernel.org, Robin Murphy Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, suravee.suthikulpanit@amd.com, baolu.lu@linux.intel.com, john.garry@huawei.com, dianders@chromium.org, rajatja@google.com, chenxiang66@hisilicon.com, Marek Szyprowski , Yoshihiro Shimoda , Geert Uytterhoeven , Yong Wu , Chunyan Zhang , Maxime Ripard , Jean-Philippe Brucker Subject: Re: [PATCH v3 01/25] iommu: Pull IOVA cookie management into the core Date: Wed, 04 Aug 2021 20:52:39 +0200 Message-ID: <2535689.1BCLMh4Saa@diego> In-Reply-To: <46f4cda8215bd5f8a9f9fd5a4a6451805f75efa3.1628094600.git.robin.murphy@arm.com> References: <46f4cda8215bd5f8a9f9fd5a4a6451805f75efa3.1628094600.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, 4. August 2021, 19:15:29 CEST schrieb Robin Murphy: > Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA > support, we can abandon the notion of drivers being responsible for the > cookie type, and consolidate all the management into the core code. > > CC: Marek Szyprowski > CC: Yoshihiro Shimoda > CC: Geert Uytterhoeven > CC: Yong Wu > CC: Heiko Stuebner > CC: Chunyan Zhang > CC: Maxime Ripard > Reviewed-by: Jean-Philippe Brucker > Reviewed-by: Lu Baolu > Signed-off-by: Robin Murphy On a Rockchip rk3288 (arm32), rk3399 (arm64) and px30 (arm64) with the graphics pipeline using the iommu Tested-by: Heiko Stuebner Heiko > > --- > > v3: Use a simpler temporary check instead of trying to be clever with > the error code > --- > drivers/iommu/iommu.c | 7 +++++++ > include/linux/iommu.h | 3 ++- > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index f2cda9950bd5..b65fcc66ffa4 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -7,6 +7,7 @@ > #define pr_fmt(fmt) "iommu: " fmt > > #include > +#include > #include > #include > #include > @@ -1946,6 +1947,11 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus, > /* Assume all sizes by default; the driver may override this later */ > domain->pgsize_bitmap = bus->iommu_ops->pgsize_bitmap; > > + /* Temporarily avoid -EEXIST while drivers still get their own cookies */ > + if (type == IOMMU_DOMAIN_DMA && !domain->iova_cookie && iommu_get_dma_cookie(domain)) { > + iommu_domain_free(domain); > + domain = NULL; > + } > return domain; > } > > @@ -1957,6 +1963,7 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc); > > void iommu_domain_free(struct iommu_domain *domain) > { > + iommu_put_dma_cookie(domain); > domain->ops->domain_free(domain); > } > EXPORT_SYMBOL_GPL(iommu_domain_free); > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 4997c78e2670..141779d76035 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -40,6 +40,7 @@ struct iommu_domain; > struct notifier_block; > struct iommu_sva; > struct iommu_fault_event; > +struct iommu_dma_cookie; > > /* iommu fault flags */ > #define IOMMU_FAULT_READ 0x0 > @@ -86,7 +87,7 @@ struct iommu_domain { > iommu_fault_handler_t handler; > void *handler_token; > struct iommu_domain_geometry geometry; > - void *iova_cookie; > + struct iommu_dma_cookie *iova_cookie; > }; > > enum iommu_cap { >