Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1318396ybi; Fri, 24 May 2019 22:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpXav7r+wDeXphIwsjHTFN4QLhb6mCB2npIn/o1deZLA2sKZoTuF9bx50MdhXRAH/B9xLu X-Received: by 2002:a17:90a:a593:: with SMTP id b19mr14103642pjq.31.1558763427110; Fri, 24 May 2019 22:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558763427; cv=none; d=google.com; s=arc-20160816; b=hCzd0zP9r+YbsCKSqdIAUi5Su0Npj7eoZkZByaMbuQ3gpbXQhmY0c/ox5WsPTjRLHB Y7UcVb0unKUWSFBn1gMSEe3JhIgGWqKWVcTwT+kcc2bzBxgwzwAYaidxj1DzooDw4JqN /T2lkVi9JAib6MD3bIZV+Vf/w5aoPSnRTfXmDbZHUXIXSkuef8RVmeaGrkASQm5RBUxu 7KoqmtHS4RfQ/MJeBJft6XZJ9ZLqcZ1sKl3gPRJySDG8vdUT52osnloy4XFxqEDarFom GQV98BpUHE24MOTdfM5RDefiM1cO3LeRKzbbnIF3INkjk3HCyC30AP7cQgkKhGmdgsGS 5KnQ== 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=81U0M8jBbBKguXtqDfoy6+qKxh6lZqPCZm+VqDwKQ9Y=; b=Zi8hShGfCQVIa/2KVEZmmEpDKYsa2J97lNCK2W4kihJB/EQAlVbHSZjEatMjCQ4aee VLa9cYpB6WaEhe0JmO5sOcihpEy33k7CayPDexu/g7Srcm4fYeX+s/wCqALvzBaN4sCL Q/DkJRBoPZqXaYVLTvUxMwOC8maS4bGsAEwL/VIQcouWVeEo+DJeJRTKOO2rPpuN/xOD KdHI0m7sRYcjbdJGParV8A1G6+5QB0buVF5/czObSlopsDPpV9STHncU2x9girF8tgsY L9onQkwcl50+SPNix5YNe5eyZJA5Vkq6Tw6GEdq0RmsnipcXmGs7Ug4mY4l+Z9jq1U/T JVEQ== 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 t74si3454286pgc.265.2019.05.24.22.50.12; Fri, 24 May 2019 22:50:27 -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 S1726807AbfEYFs7 (ORCPT + 99 others); Sat, 25 May 2019 01:48:59 -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 S1726762AbfEYFsz (ORCPT ); Sat, 25 May 2019 01:48:55 -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:48:55 -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:48:52 -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 04/15] iommu/vt-d: Enable DMA remapping after rmrr mapped Date: Sat, 25 May 2019 13:41:25 +0800 Message-Id: <20190525054136.27810-5-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 The rmrr devices require identity map of the rmrr regions before enabling DMA remapping. Otherwise, there will be a window during which DMA from/to the rmrr regions will be blocked. In order to alleviate this, we move enabling DMA remapping after all rmrr regions get mapped. Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index c42317e27b0c..bac226dc8360 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3538,11 +3538,6 @@ static int __init init_dmars(void) ret = dmar_set_interrupt(iommu); if (ret) goto free_iommu; - - if (!translation_pre_enabled(iommu)) - iommu_enable_translation(iommu); - - iommu_disable_protect_mem_regions(iommu); } return 0; @@ -4922,7 +4917,6 @@ int __init intel_iommu_init(void) goto out_free_reserved_range; } up_write(&dmar_global_lock); - pr_info("Intel(R) Virtualization Technology for Directed I/O\n"); #if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB) swiotlb = 0; @@ -4945,6 +4939,16 @@ int __init intel_iommu_init(void) register_memory_notifier(&intel_iommu_memory_nb); cpuhp_setup_state(CPUHP_IOMMU_INTEL_DEAD, "iommu/intel:dead", NULL, intel_iommu_cpu_dead); + + /* Finally, we enable the DMA remapping hardware. */ + for_each_iommu(iommu, drhd) { + if (!translation_pre_enabled(iommu)) + iommu_enable_translation(iommu); + + iommu_disable_protect_mem_regions(iommu); + } + pr_info("Intel(R) Virtualization Technology for Directed I/O\n"); + intel_iommu_enabled = 1; intel_iommu_debugfs_init(); -- 2.17.1