Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp346714imm; Thu, 11 Oct 2018 22:19:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV63kRFVtV3X6F/4c/eqxxhQ59eypEFvGr1z1oS7Gpov9nKxM6w7JClmNpUGJJ9o8UZxCEZIs X-Received: by 2002:a63:1f0a:: with SMTP id f10-v6mr4132585pgf.313.1539321567802; Thu, 11 Oct 2018 22:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539321567; cv=none; d=google.com; s=arc-20160816; b=M+8pmwMG5CohZacCS//PKr0q8bVUWgP+7ilGztttdx6yRJtZerganCdrMkNE/cCbJo UIJpLVJtdfk/RdN74ieqHIF8Ihp+Qh/o7Yj0rntwvc0QVAxLk8/sQOFJwLRwDuA8Iv1t Jszcm9RJ4NTKMQpCnbZLQFJzWP6nljXEMdeT6K7gpdCURnK2ZwwY38SUkgFcc8T000dt 4tXXn2wTaEB/p7Lm9KYOugXMNWngvT79+5x6/xAu6eV33TgMfgpoUln+LmQEtPblf2ZS 8Eeh+p0w2aDeW25bbwJxvkfSUHNba7CdqvgbgQ/8yxFnC9hpm6CEizygeCCA1MlH/lSE L7TA== 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=qnGDGiQ9AhcMlsUFZEoh2g0gdMSfcCXz2R4vGPkLeec=; b=HYT1WiInXJQv2qNusB42uZ/7zP5bpT6HbhoetgLeOc8cRE7e/IwgvoKXqGiQEUKexM FWyoQmf+mPTipsTffNozVDPElI5UcSOcNPSTbHTc7eUVCXRlXUrVChtH0ik0e0z8ZE0k 0uioiniuCJ9DfunY+sVIfCtBVKneIwO7wtz28yKuUDQVjqS5+unUGYvIFTkp12Is4IBZ B395lrlh6vd4Kyz8JF+qoMTdKVwC53gUK+gGGM69I18bn8kIoF3VlLTmPXIapjTmqtOx KNnIvXEP7wC20Qdk077/lj6A5GEXuMZ77oSFyhzU1Sx31E7A9mqIZQeV8+JRoUPuGlu2 ceag== 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 r3-v6si119172plb.221.2018.10.11.22.19.13; Thu, 11 Oct 2018 22:19: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 S1727446AbeJLMt1 (ORCPT + 99 others); Fri, 12 Oct 2018 08:49:27 -0400 Received: from mga11.intel.com ([192.55.52.93]:62493 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbeJLMt1 (ORCPT ); Fri, 12 Oct 2018 08:49:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 22:18:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,371,1534834800"; d="scan'208";a="80842220" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2018 22:18:44 -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: [PATCH v3 2/8] iommu/vt-d: Add multiple domains per device query Date: Fri, 12 Oct 2018 13:16:26 +0800 Message-Id: <20181012051632.26064-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012051632.26064-1-baolu.lu@linux.intel.com> References: <20181012051632.26064-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 the response to IOMMU_DEV_ATTR_AUXD_CAPABILITY capability query through iommu_get_dev_attr(). Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 4b1f7426acea..3133216e5733 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5170,6 +5170,24 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, return phys; } +static inline bool scalable_mode_support(void) +{ + struct dmar_drhd_unit *drhd; + struct intel_iommu *iommu; + bool ret = true; + + rcu_read_lock(); + for_each_active_iommu(iommu, drhd) { + if (!sm_supported(iommu)) { + ret = false; + break; + } + } + rcu_read_unlock(); + + return ret; +} + static bool intel_iommu_capable(enum iommu_cap cap) { if (cap == IOMMU_CAP_CACHE_COHERENCY) @@ -5334,6 +5352,25 @@ struct intel_iommu *intel_svm_device_to_iommu(struct device *dev) } #endif /* CONFIG_INTEL_IOMMU_SVM */ +static int intel_iommu_get_dev_attr(struct device *dev, + enum iommu_dev_attr attr, void *data) +{ + int ret = 0; + bool *auxd_capable; + + switch (attr) { + case IOMMU_DEV_ATTR_AUXD_CAPABILITY: + auxd_capable = data; + *auxd_capable = scalable_mode_support(); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .domain_alloc = intel_iommu_domain_alloc, @@ -5348,6 +5385,7 @@ 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, + .get_dev_attr = intel_iommu_get_dev_attr, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; -- 2.17.1