From patchwork Tue May 26 13:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1298046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49WZ1q4t1yz9sSt; Tue, 26 May 2020 23:05:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jdZGK-00073t-VS; Tue, 26 May 2020 13:04:57 +0000 Received: from mail-pj1-f67.google.com ([209.85.216.67]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZEx-00062F-KD for kernel-team@lists.ubuntu.com; Tue, 26 May 2020 13:03:31 +0000 Received: by mail-pj1-f67.google.com with SMTP id nu7so1406026pjb.0 for ; Tue, 26 May 2020 06:03:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q/YB43mHgOLTXlWbudqXsk3Zzo6HqToGVRWoKIxiAik=; b=A6l8z67hA4k7kkxc8B/WLSMFiwlC24xkCUpqETj2tNTQj3sUrZu+lZ0+XYgDf2Haor 57V7rYt30To4cKBk3qZpqlkeOEDOoJWO/rHDIZyBhSCGucYmEANeXGTlxIbZGv6uFolm mG0W+FZuYrBtEQ3HOibw7uXvbWzzRZCOlbdEut5dejzKZDj6d7DR9nz/daNfM7runBVg l76Sy3xoxm55TSWYxVhpjZorQR1ym3H4v1fElzdeSRA43Rzm0bJXmG4PIgAE7d/923uD xGKes4NlaKa8UzWAcg9fU7zGq38BXThAPSKfKUv28lAyRp2mcZ/Gef25qjqotKQ/vbBn B1BQ== X-Gm-Message-State: AOAM532ytWOqGSJr2DXfR+8jCvwWdWN75bn+1JNYmBstkwJj94JxBaBT K/vJ/xt4ZrICIR/P/1jtB+fCP0VR7Ck= X-Google-Smtp-Source: ABdhPJzCj/kjOKojAwJetPldjaHJh40uTzxR3wRkCR3hs0twwgIVE2IzcFT53sEFl2rQNKIsb7+jXw== X-Received: by 2002:a17:90a:9904:: with SMTP id b4mr13618299pjp.207.1590498209315; Tue, 26 May 2020 06:03:29 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id o69sm9999803pfd.213.2020.05.26.06.03.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 06:03:28 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 32/60][SRU][OEM-5.6] UBUNTU: SAUCE: iommu/amd: Remove dev_data->passthrough Date: Tue, 26 May 2020 21:01:36 +0800 Message-Id: <20200526130204.238445-33-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200526130204.238445-1-vicamo.yang@canonical.com> References: <20200526130204.238445-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joerg Roedel BugLink: https://bugs.launchpad.net/bugs/1876707 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 Link: https://lore.kernel.org/r/20200429133712.31431-15-joro@8bytes.org Signed-off-by: Joerg Roedel (cherry picked from commit 57f9842e48840684f596db1de936d7c6d44cd087 iommu/next) Signed-off-by: You-Sheng Yang --- 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 b61e22aee2e0..579fbff27c42 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2102,8 +2102,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; @@ -2122,8 +2122,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) { @@ -2244,9 +2246,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 7a8fdec138bd..f7e7c96bc298 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -645,7 +645,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;