Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp631960ybz; Wed, 29 Apr 2020 06:42:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLteejgPXPszguMoFmsNNj/a+JMPHj1PgikCMua7tIHjW11Lg+lMzxotrvS8Cxwka0xC4V/ X-Received: by 2002:a17:906:74c:: with SMTP id z12mr2693294ejb.87.1588167778839; Wed, 29 Apr 2020 06:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167778; cv=none; d=google.com; s=arc-20160816; b=VvGiE+hJ/uuzLghtb7xdFNI+jAPSvoRKYS6ucEwihO5DsLcR4JooBBqOelhWkBa2SI E85FyD1b4suQzXDAHmGJ4rs71KSlqckxPfwDNettncagtuz5ZQIwxp5gVq5sRz0oXEqW VtegHL8CPOwXDlT0nw9dkWhxw4XikoyOYoEU95VvcqR41hxFrvBHSM3KY8erpNnyg13i 2bR1/d1kapG0m0EznsL/e+c+JSEdxVZfF4ZUrYEEG4kkFH95RJoyxc7PrzzCdc3jTWbp 0vQk4dmA837/U2vDbGI0tRKl90HH4+conQTwbRWe4hLINfblIXkcnLrFE+bNeae6NHWV oFGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=u22J+aG7dOxw9lVWVDTcHx3nf6ToGbBFHizqV/r17t8=; b=yUjQwMOvnI00IVl7aTLW0CU+C+w49nnEfIupbfpbPWAhzcIvU5h4M5xOgIdAVvYvHG O/YUf/CKM7IjI5JaYE5faG0VUi9/PLKUo6ku09oGyW5HQr9facrKmEUt4MS6qNtw8wO1 rf8/vebT6M3yYrkWWqeZnrgzY0izD9dXpX+DwzG30oetj8o/Ndgp/myEYxKOfCH30pey XrjPQyFNFCqaeAvZoZDK3JxXqOhgDKvUUbvjNlC8gufQwsSqgs2f8iDqIQMeZ2A+YxAT sOHoKe7t9UEnpeThfbfI57z+xo1wnZEWsZMYVDLf2jzHiaPLrR33Xb8TG2UciriuOYAc OAIw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si3400886edv.388.2020.04.29.06.42.35; Wed, 29 Apr 2020 06:42:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbgD2Njy (ORCPT + 99 others); Wed, 29 Apr 2020 09:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbgD2Nhs (ORCPT ); Wed, 29 Apr 2020 09:37:48 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D9BAC03C1AD; Wed, 29 Apr 2020 06:37:47 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id DF2F0E06; Wed, 29 Apr 2020 15:37:37 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Jean-Philippe Brucker Cc: Daniel Drake , jonathan.derrick@intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: [PATCH v3 14/34] iommu/amd: Remove dev_data->passthrough Date: Wed, 29 Apr 2020 15:36:52 +0200 Message-Id: <20200429133712.31431-15-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429133712.31431-1-joro@8bytes.org> References: <20200429133712.31431-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Make use of generic IOMMU infrastructure to gather the same information carried in dev_data->passthrough and remove the struct member. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 10 +++++----- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 3e0d27f7622e..0b4b4faa876d 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2047,8 +2047,8 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev) static int attach_device(struct device *dev, struct protection_domain *domain) { - struct pci_dev *pdev; struct iommu_dev_data *dev_data; + struct pci_dev *pdev; unsigned long flags; int ret; @@ -2067,8 +2067,10 @@ static int attach_device(struct device *dev, pdev = to_pci_dev(dev); if (domain->flags & PD_IOMMUV2_MASK) { + struct iommu_domain *def_domain = iommu_get_dma_domain(dev); + ret = -EINVAL; - if (!dev_data->passthrough) + if (def_domain->type != IOMMU_DOMAIN_IDENTITY) goto out; if (dev_data->iommu_v2) { @@ -2189,9 +2191,7 @@ static int amd_iommu_add_device(struct device *dev) /* Domains are initialized for this device - have a look what we ended up with */ domain = iommu_get_domain_for_dev(dev); - if (domain->type == IOMMU_DOMAIN_IDENTITY) - dev_data->passthrough = true; - else if (domain->type == IOMMU_DOMAIN_DMA) + if (domain->type == IOMMU_DOMAIN_DMA) iommu_setup_dma_ops(dev, IOVA_START_PFN << PAGE_SHIFT, 0); out: diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index ca8c4522045b..d0d7b6a0c3d8 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -640,7 +640,6 @@ struct iommu_dev_data { struct pci_dev *pdev; u16 devid; /* PCI Device ID */ bool iommu_v2; /* Device can make use of IOMMUv2 */ - bool passthrough; /* Device is identity mapped */ struct { bool enabled; int qdep; -- 2.17.1