Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp276958imm; Wed, 29 Aug 2018 21:14:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZZdRKADKz9echE3tl2GkI+tb5poRG4xTcUoAUXOTw2xkLt9H251225jAG5HMinpVmmIpBh X-Received: by 2002:a62:565c:: with SMTP id k89-v6mr8670141pfb.212.1535602493616; Wed, 29 Aug 2018 21:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535602493; cv=none; d=google.com; s=arc-20160816; b=RVLXHT37dfbFe4SBDk24rsY13fTDY9O5bQgVIqAsWz2JcYCzsvIPa+JLpFor2roKCf qQbohxcK+jEjbnxMpRYOHkQ0hI/EeR+by2ursShpEBliJzbnbg7oN93zmD71CHaGoBaV bWMsm4im0Kf2pauWK9QLjLqbPNSWXgkKg6Jt26R2GVdWvGLhmhtg3ichKUS22NpY1uyc dFgnsSDq0pRByt20Slu1ee0uTpBvneZMvy1po37IxwFmspTfY5v8GQA6Fnupz21WuooF iwtF5/EqucEObWEo2KjzCyA496f8x2sdrKPqJF3dRQrJX4vSr7anYCpN1U7Yg6HjNdIT kvVQ== 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=nNC2JsyrNyi5tShDpX6ytBxpgg7E3RG6MIamn71UAOI=; b=rq+rFSUUW6flk13Tp6zGmk+F2XY/JPq4Z4uE2MZYIbjmD4Gqy+bKbvTANFnSkHDT6F GJcDgxYySb2ry2k/aqCtJSysP/+vBR7ceNW1unv39Sz+FGvhb/s0b22UQBDH9SlIibz2 fhhZtCbZINlEbOiGtg8aZCRVybHadpsj/TuSdcIbBzAIFxPOl6OEEvN+Eg7eXki2RSdI UayG5QV02xjEQMZARNP6WMBuwDLrMDxk5RS4Lm3IVPH/Gl8uhrhxt1ONsgMLePROQ2Ee HmlYcZxiyXEffnIGkmF42zBi3vDFqCq1b+gxHr/IyRKD735SuCrXAxygqsN5+81+Wis5 1atA== 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 k6-v6si4305005pls.426.2018.08.29.21.14.39; Wed, 29 Aug 2018 21:14:53 -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 S1727957AbeH3IMb (ORCPT + 99 others); Thu, 30 Aug 2018 04:12:31 -0400 Received: from mga12.intel.com ([192.55.52.136]:20569 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbeH3IML (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="68959950" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga007.jf.intel.com with ESMTP; 29 Aug 2018 21:10:48 -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 02/10] iommu/vt-d: Add multiple domains per device query Date: Thu, 30 Aug 2018 12:09:14 +0800 Message-Id: <20180830040922.30426-3-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 the response to IOMMU_CAP_AUX_DOMAIN capability query through iommu_capable(). Return true if IOMMUs support the scalable mode, return false otherwise. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 3e49d4029058..891ae70e7bf2 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5193,12 +5193,39 @@ 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) + switch (cap) { + case IOMMU_CAP_CACHE_COHERENCY: return domain_update_iommu_snooping(NULL) == 1; - if (cap == IOMMU_CAP_INTR_REMAP) + case IOMMU_CAP_INTR_REMAP: return irq_remapping_enabled == 1; + case IOMMU_CAP_AUX_DOMAIN: + return scalable_mode_support(); + case IOMMU_CAP_NOEXEC: + /* PASSTHROUGH */ + default: + pr_info("Unsupported capability query %d\n", cap); + break; + } return false; } -- 2.17.1