From patchwork Tue May 26 12:59:26 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: 1297985 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 49WYwz27j6z9sT0; Tue, 26 May 2020 23:00:51 +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 1jdZCG-00043z-Nl; Tue, 26 May 2020 13:00:44 +0000 Received: from mail-pf1-f193.google.com ([209.85.210.193]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZC9-0003ws-EV for kernel-team@lists.ubuntu.com; Tue, 26 May 2020 13:00:37 +0000 Received: by mail-pf1-f193.google.com with SMTP id 23so10144254pfy.8 for ; Tue, 26 May 2020 06:00:37 -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=64ZwMKH2ZY+Ocrd4UB74mXLGmFlRaH02C3Ry3hb9LmE=; b=Ob0RdqPap1TWvcvJHaHcpV8Wb4EOpQZJq9XIM+z4Esl1DCdeIhcl38D2aCXRUnMkno wYpmhDl3Onzm7E7jZ7q9YL3W/69r7Mb2X7I5Ir2jB0HycSsYH2xJnI58edGfFyFHiAbt qNppmSsGZ3qQcnUDC497fp2pvHZh8zXuhfpecKKAb1V3K4Tz8QCGQY/vBtenCFE2EJ/3 t/gfpNNNiUNR443ccqyk0dv2lC7vbIN5/eR+an8MIt/gmm8X7ZdC+IxzG5yI0ISZp+tf Zzypywq8BAH17Qmfv5j3Nm5KigcijR70XBo6HcCqe+Sy1ztnvBr1ndABWrfAHfqHYUpE cJhA== X-Gm-Message-State: AOAM533ESzfspxykELgoxR9BWEI4L3QyvrFNSA4X0PElSnbThEr50soI 3uHLVFXT8XqdFzwEQj1qBsVxvyRi2Es= X-Google-Smtp-Source: ABdhPJwku3GHJRcrt2/uN8ZwlPTe+qcefWY66vSqAqoMO264ttzWnPjPzqVgoBAT60RXr4iPuyl6vw== X-Received: by 2002:a62:1681:: with SMTP id 123mr20970966pfw.306.1590498035065; Tue, 26 May 2020 06:00:35 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id n205sm15702709pfd.50.2020.05.26.06.00.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 06:00:34 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 14/42][SRU][U] UBUNTU: SAUCE: iommu/amd: Remove dev_data->passthrough Date: Tue, 26 May 2020 20:59:26 +0800 Message-Id: <20200526125954.237403-15-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200526125954.237403-1-vicamo.yang@canonical.com> References: <20200526125954.237403-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 8dbde24d196d..3a584cf76bc1 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2118,8 +2118,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; @@ -2138,8 +2138,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) { @@ -2260,9 +2262,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;