Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1318537ybi; Fri, 24 May 2019 22:50:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCjgEHKabBigFi6m0muOKherqoLMou5oMSudR+H8BP+urVY8Z3Gwx5e+Om5cbKlcjFo7ve X-Received: by 2002:a17:90a:9dc1:: with SMTP id x1mr14388069pjv.102.1558763441884; Fri, 24 May 2019 22:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558763441; cv=none; d=google.com; s=arc-20160816; b=0v3W6VeMvGVhSPISGA3A+FlgCC1I6mwNVjRKzaCCLJ8wf1hOtdo6oXDqtKohXigZvw REvvXTsvdHo+slAFEYeA19QfQ+KX0yXuecEDqceUdC8iDx46qSYKv1uzH40EoAWT/45S REHir0rLQ+pluhOlJlm01O2L85tyoxOw/z2iYs52gYndDkA8vmC8gHyjzLc4WHqsDbZf OBa9THs0ogtyJXfWoK4RZu21UVBymIP4EPREP6tqS04FhWVAKbFvTD3yuEnDmlRZXtnz 2g6g93JA1tnkv/u8OnjT80K3qI0VXI+t4o7/rSryNoNUbZ+vXiBxONYfPdT5w6WazvoP 8V3g== 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=7MWetCA1Xm/leXMh6KMFDSPcWh1McBQejplbLNqGT64=; b=h/dfeF+baUMq4j241vfi8Y/EPuUtC8HFfsZXoYS1wmsKsql6kvX8LwtpcKJLuoiZD2 Gf02wLZinDEC7jSEBzgPFa2J3w8L9WCeBZld3GzbKiUeRqNbkKSQQ4v8M44BXt0m/zl0 ZzOL+KPF4c+FyijKSIWmhusqIoY/uVhfQ/R7DzubShwN536fOxgDcqEoYV975GIR96FZ LfIAqbkFJu00Hprg8/3B4QVFcSxR1EL/CCeHVD/A1rTczROtPAHnKM7JC1x0nrNhrkIu k/fROzJRlUgv6XOuxtvKGSLEUqb2niTDsyjVpdBlg6a+yTSlMOizPrq4DwEf2MmqsuUe m47A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si7116838pfp.288.2019.05.24.22.50.27; Fri, 24 May 2019 22:50:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbfEYFtI (ORCPT + 99 others); Sat, 25 May 2019 01:49:08 -0400 Received: from mga05.intel.com ([192.55.52.43]:46780 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbfEYFtH (ORCPT ); Sat, 25 May 2019 01:49:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2019 22:49:07 -0700 X-ExtLoop1: 1 Received: from allen-box.sh.intel.com ([10.239.159.136]) by fmsmga006.fm.intel.com with ESMTP; 24 May 2019 22:49:04 -0700 From: Lu Baolu To: David Woodhouse , Joerg Roedel Cc: ashok.raj@intel.com, jacob.jun.pan@intel.com, kevin.tian@intel.com, jamessewart@arista.com, tmurphy@arista.com, dima@arista.com, sai.praneeth.prakhya@intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v4 10/15] iommu/vt-d: Probe DMA-capable ACPI name space devices Date: Sat, 25 May 2019 13:41:31 +0800 Message-Id: <20190525054136.27810-11-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190525054136.27810-1-baolu.lu@linux.intel.com> References: <20190525054136.27810-1-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some platforms may support ACPI name-space enumerated devices that are capable of generating DMA requests. Platforms which support DMA remapping explicitly declares any such DMA-capable ACPI name-space devices in the platform through ACPI Name-space Device Declaration (ANDD) structure and enumerate them through the Device Scope of the appropriate remapping hardware unit. Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b7f5a6390be6..7f9cf9188f5f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -4816,6 +4816,48 @@ static int __init platform_optin_force_iommu(void) return 1; } +static int __init probe_acpi_namespace_devices(void) +{ + struct dmar_drhd_unit *drhd; + struct intel_iommu *iommu; + struct device *dev; + int i, ret = 0; + + for_each_active_iommu(iommu, drhd) { + for_each_active_dev_scope(drhd->devices, + drhd->devices_cnt, i, dev) { + struct acpi_device_physical_node *pn; + struct iommu_group *group; + struct acpi_device *adev; + + if (dev->bus != &acpi_bus_type) + continue; + + adev = to_acpi_device(dev); + mutex_lock(&adev->physical_node_lock); + list_for_each_entry(pn, + &adev->physical_node_list, node) { + group = iommu_group_get(pn->dev); + if (group) { + iommu_group_put(group); + continue; + } + + pn->dev->bus->iommu_ops = &intel_iommu_ops; + ret = iommu_probe_device(pn->dev); + if (ret) + break; + } + mutex_unlock(&adev->physical_node_lock); + + if (ret) + return ret; + } + } + + return 0; +} + int __init intel_iommu_init(void) { int ret = -ENODEV; @@ -4928,6 +4970,9 @@ int __init intel_iommu_init(void) cpuhp_setup_state(CPUHP_IOMMU_INTEL_DEAD, "iommu/intel:dead", NULL, intel_iommu_cpu_dead); + if (probe_acpi_namespace_devices()) + pr_warn("ACPI name space devices didn't probe correctly\n"); + /* Finally, we enable the DMA remapping hardware. */ for_each_iommu(iommu, drhd) { if (!translation_pre_enabled(iommu)) -- 2.17.1