Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp276845imm; Wed, 29 Aug 2018 21:14:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0k78uRRW7oQK/K8gyJ8Js1oVvpsADx/nvVVLxRGxlNeFD0w7dgGc+ZE+9OdiiWhE/n8Sk X-Received: by 2002:a65:42c9:: with SMTP id l9-v6mr2856428pgp.200.1535602478107; Wed, 29 Aug 2018 21:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535602478; cv=none; d=google.com; s=arc-20160816; b=Wkcqk1JHRk1GsZZVVDYJMvJ6Pc5qSy0cjPkUPRXtBDAGKw3OIjp+y2XB91N+CNh12k zueZu4NfE1TeLWvEYcYVsJOrPsRAjg89Zj2RYFF7Bdbpm8h35fjVjkXgptSFbMEoSC7F pJMpZTC6Ff7UCiuCMzwv6W+tv4xzFTgU8C69I6I90iiRl0189O1r3hmUJzGEBAsFigzU wka45DffxoF7Nu1do693rPoJ7aytkAV3iUe77azEdg9fxYv1+QOFDDhZaahmpo/BXdKJ keSkS7sOR+0tDeSEvvhscf3o70IRPTwAF8DBQ9NFXSVgYndFpms2M6149Ll24XdGtlIG tMLg== 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:arc-authentication-results; bh=KhR3vTFmYg69/RbUc8TudW5dUbnBGP9/HOcXMgJqQLY=; b=H4+R9EcTd2oaexTz5Jtaf+nWyU0NBm92/bfdN7Igzhw1SLOd2u3gGhv9NlTP8lApUW ThRgqufF8++RTPlyXd/fmGB0nZEjmMx8DbPH3HsiuuR5Pd5Hf6FxqV/JJD8p+OUPgSHf Ryrf4oeNKO0QnvWn3396gKYUFdX7f7X5Kn3J7oof9wz69jUcXXs2pkmuebMWJ9BhaphZ MdAAjbc9LzyFzzd5RutvleRcvtm0paeKWNsXrcucYty6vLpnGX/a0lfosQPi5CHCg9dC Z84HULAmUMimnxHmrTkUGQf8/hjqWoimHU3H9Qm9p9TKh1n99i28bQn2KRq1dPr7UhwR 5eqQ== 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 i12-v6si5796941pgr.267.2018.08.29.21.14.23; Wed, 29 Aug 2018 21:14:38 -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 S1727944AbeH3IMR (ORCPT + 99 others); Thu, 30 Aug 2018 04:12:17 -0400 Received: from mga12.intel.com ([192.55.52.136]:20666 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727627AbeH3IML (ORCPT ); Thu, 30 Aug 2018 04:12:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 21:10:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,306,1531810800"; d="scan'208";a="68959954" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga007.jf.intel.com with ESMTP; 29 Aug 2018 21:10:54 -0700 From: Lu Baolu To: Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede Cc: ashok.raj@intel.com, sanjay.k.kumar@intel.com, jacob.jun.pan@intel.com, kevin.tian@intel.com, Jean-Philippe Brucker , yi.l.liu@intel.com, yi.y.sun@intel.com, peterx@redhat.com, tiwei.bie@intel.com, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [RFC PATCH v2 04/10] iommu/vt-d: Enable/disable multiple domains per device Date: Thu, 30 Aug 2018 12:09:16 +0800 Message-Id: <20180830040922.30426-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830040922.30426-1-baolu.lu@linux.intel.com> References: <20180830040922.30426-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 Add iommu ops for enabling and disabling multiple domains for a device. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/intel-iommu.h | 1 + 2 files changed, 37 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 891ae70e7bf2..3606d25bc40c 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2501,6 +2501,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, info->domain = domain; info->iommu = iommu; info->pasid_table = NULL; + info->auxd_enabled = 0; if (dev && dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(info->dev); @@ -5384,6 +5385,39 @@ struct intel_iommu *intel_svm_device_to_iommu(struct device *dev) } #endif /* CONFIG_INTEL_IOMMU_SVM */ +static int intel_iommu_enable_auxd(struct device *dev) +{ + struct device_domain_info *info; + struct dmar_domain *domain; + unsigned long flags; + + if (!scalable_mode_support()) + return -ENODEV; + + domain = get_valid_domain_for_dev(dev); + if (!domain) + return -ENODEV; + + spin_lock_irqsave(&device_domain_lock, flags); + info = dev->archdata.iommu; + info->auxd_enabled = 1; + spin_unlock_irqrestore(&device_domain_lock, flags); + + return 0; +} + +static void intel_iommu_disable_auxd(struct device *dev) +{ + struct device_domain_info *info; + unsigned long flags; + + spin_lock_irqsave(&device_domain_lock, flags); + info = dev->archdata.iommu; + if (!WARN_ON(!info)) + info->auxd_enabled = 0; + spin_unlock_irqrestore(&device_domain_lock, flags); +} + const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .domain_alloc = intel_iommu_domain_alloc, @@ -5398,6 +5432,8 @@ const struct iommu_ops intel_iommu_ops = { .get_resv_regions = intel_iommu_get_resv_regions, .put_resv_regions = intel_iommu_put_resv_regions, .device_group = pci_device_group, + .enable_auxd = intel_iommu_enable_auxd, + .disable_auxd = intel_iommu_disable_auxd, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index b34cf8b887a0..15981245796e 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h @@ -487,6 +487,7 @@ struct device_domain_info { u8 pri_enabled:1; u8 ats_supported:1; u8 ats_enabled:1; + u8 auxd_enabled:1; /* Multiple domains per device */ u8 ats_qdep; struct device *dev; /* it's NULL for PCIe-to-PCI bridge */ struct intel_iommu *iommu; /* IOMMU used by this device */ -- 2.17.1