Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3740413imu; Sun, 11 Nov 2018 22:49:58 -0800 (PST) X-Google-Smtp-Source: AJdET5fyiJHyD5MkmU8wM9BbmJ6sVGhwEBcub3xId2cmUv+VpTPropf1D2rFK082ouz6b61sde4j X-Received: by 2002:a62:8a91:: with SMTP id o17-v6mr18891816pfk.210.1542005398732; Sun, 11 Nov 2018 22:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542005398; cv=none; d=google.com; s=arc-20160816; b=t9N/uteV5WjeDzyLaFGA/FOP+cSKMV9kkO06GK0hGCdhzfG8/RDdSzOVIe1F9ku2iS kMXFe3Nyj1m+akcJPo10lpJ41h3c+ZMx6PF1MsHw+KLrbLpmnUmg8bjlAi6M+/0rzJu8 PQF+MDDu9tVrVq9V3fXOx46OtKxsAs4Y6nfOeAxWV/ZqHRtF0jWrshkj1VVL0MKP2iwO 6YNz4qXQhRwSAdlGsmxmYPSrKoS/4aMR3XPYdjO33Njm7xxVhgPEEdryB5ynCebYMTSD ZOXi3TByh313CgNlfF7QI1d/9IpLL4g1xeHgZh9JrrAwsbEMIjpQMK/dc75T9fDj+ORB tTLA== 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=eD+XVyODQX9p5XvWb4BogN5r5mUbDSFomiKgkz9H164=; b=i0o7jHp5AisdP2jaRsJgSW04w3DAwbtgN1FGEJb/zLbTa48Kdd1oYKYG6UdunKuLON 3ML7zoRr79PomZ+6H5G0e7esMkJFCBwGDAWSMxC6cS1EOOEP2IlssPDQfnJkcmAMzwFC +W7eOw7bIeJsOIoUntmN9UK7F7SiWeOUiMrZmd0YItHYguGW3zPUsvBHmamiUeEQ2Sxg 70hY7KfSpFMnfqNH9Qg6CcEdZM1ELEfNCtJyZhvIOzmiFozUwIf/yesWbd2F8nxcPg29 qf1uLEfi1kcKbMS051oJDu5Om5Qy9KLqMS2463Pr0bDF9NupJvc0MRS54/6FhZC+cy7B C3Tg== 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 16si15739791pgh.58.2018.11.11.22.49.43; Sun, 11 Nov 2018 22:49:58 -0800 (PST) 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 S1732022AbeKLQj5 (ORCPT + 99 others); Mon, 12 Nov 2018 11:39:57 -0500 Received: from mga17.intel.com ([192.55.52.151]:53355 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731284AbeKLQjx (ORCPT ); Mon, 12 Nov 2018 11:39:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2018 22:48:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,494,1534834800"; d="scan'208";a="88579665" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga007.jf.intel.com with ESMTP; 11 Nov 2018 22:47:57 -0800 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, Zeng Xin , iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [RFC PATCH 2/5] iommu/vt-d: Initialize a PASID consumer Date: Mon, 12 Nov 2018 14:44:58 +0800 Message-Id: <20181112064501.2290-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181112064501.2290-1-baolu.lu@linux.intel.com> References: <20181112064501.2290-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 This adds the Intel vt-d specific ops to initialize a PASID consumer. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 49a278a699b0..769b7059d52f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5597,6 +5597,35 @@ static int intel_iommu_domain_get_attr(struct iommu_domain *domain, return ret; } +static int intel_iommu_pasid_init(struct iommu_pasid *pasid) +{ + struct dmar_drhd_unit *drhd; + struct intel_iommu *iommu = NULL, *temp; + + /* + * Iterate the iommu units and get a scalable mode capable one + * for virtual command usages. Return failure if scalable mode + * doesn't support by any unit. + */ + rcu_read_lock(); + for_each_active_iommu(temp, drhd) { + if (sm_supported(temp)) { + iommu = temp; + break; + } + } + rcu_read_unlock(); + + if (!iommu) + return -ENODEV; + + pasid->max = intel_pasid_max_id; + pasid->min = PASID_MIN; + pasid->priv = iommu; + + return 0; +} + const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .domain_alloc = intel_iommu_domain_alloc, @@ -5616,6 +5645,7 @@ const struct iommu_ops intel_iommu_ops = { .domain_get_attr = intel_iommu_domain_get_attr, .get_dev_attr = intel_iommu_get_dev_attr, .set_dev_attr = intel_iommu_set_dev_attr, + .pasid_init = intel_iommu_pasid_init, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; -- 2.17.1