Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3740472imu; Sun, 11 Nov 2018 22:50:04 -0800 (PST) X-Google-Smtp-Source: AJdET5daIOwcVVyGzWhoV2tX25Sj2LVBBNxeVYAFdZ1yE91GJ1fOojwif2+zBwmeSpxlDRFGAqRG X-Received: by 2002:a17:902:3e3:: with SMTP id d90-v6mr18696977pld.118.1542005404259; Sun, 11 Nov 2018 22:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542005404; cv=none; d=google.com; s=arc-20160816; b=XwCWpsSIQwpLRb3W2/YJs/Cqnj5tEdBG9+9KviaXyW1vwOaWzJxc06l7s0xFoZ3UYm +AXN39ctyee6qUsxkV7t8u2c055kNBIuIs/AxKVdqPIpaMxPbwJlXYm5vmqiAabcJM1h btTayLpzujk/2z+7Loueh++sJ/u4M8vGSGyDBihQ0mmGby1SFlzq1wzNmubxQb0ll5/x RGdKhLq6u3XmShm6bPSW2pUEcbLMVvEnVbtGUUVw0OjQDkgfmFKO3VfBQDK4YdylL4T8 cibuPNoBM8NunSjwoOxkr8lvc1k7XxWB13Yp08WQeqishLaJBleLfxETNUvVSZpYORF6 bMkg== 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=KMkOmChi7MtnOHIJIPV5Kae170llm+u3vbgLvYSKKOc=; b=qgoNWznyuz0LzScYOQiX9HxnpQ3DNHpjK+UBZdxX202XgRV17d28kdFLzsZSM8of+P fCs5x67YO0RfmEA53NgX62ucg5RcXwNUZYru8f+NQNUpDOumBPKt6Y1sye3y/rkSSHLG 7yrrDzN7qrrc3QdZgV5QWICqjwEn/n6ILrNYqWOtLH4z2WwewjAamPuMOzDrViRl31xC tPXjFvgfCgE7nlDc10Y3qfBWsSBhbqxyjq9kE0OmvkTTDVJoJ/OpxckxwDLLL8LP2A5/ t6tcWrYOjTDwcCX0TeA2EuKpeT55F52FGSLBKq3uN2+nAsBcHUaVp+w79qmOWhKBi+Hx hHTA== 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 j7-v6si15881370plt.349.2018.11.11.22.49.49; Sun, 11 Nov 2018 22:50:04 -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 S1732046AbeKLQkB (ORCPT + 99 others); Mon, 12 Nov 2018 11:40:01 -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 S1731284AbeKLQkA (ORCPT ); Mon, 12 Nov 2018 11:40:00 -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:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,494,1534834800"; d="scan'208";a="88579707" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga007.jf.intel.com with ESMTP; 11 Nov 2018 22:48:04 -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 4/5] iommu/vt-d: Allocate and free a pasid Date: Mon, 12 Nov 2018 14:45:00 +0800 Message-Id: <20181112064501.2290-5-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 allocate and free a pasid value. 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 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 769b7059d52f..8dbd0c601dab 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5626,6 +5626,37 @@ static int intel_iommu_pasid_init(struct iommu_pasid *pasid) return 0; } +static int intel_iommu_pasid_alloc(struct iommu_pasid *pasid, ioasid_t start, + ioasid_t end, ioasid_t *ioasid) +{ + struct intel_iommu *iommu; + + iommu = pasid->priv; + if (!iommu) + return -EINVAL; + + /* + * In caching mode, PASID ID should be allocated and freed + * through the virtual command registers. Otherwise, rely + * on the iommu global idr. + */ + if (!cap_caching_mode(iommu->cap)) + return -EAGAIN; + + return vcmd_alloc_pasid(iommu, ioasid); +} + +static void intel_iommu_pasid_free(struct iommu_pasid *pasid, ioasid_t ioasid) +{ + struct intel_iommu *iommu; + + iommu = pasid->priv; + if (!iommu || !cap_caching_mode(iommu->cap)) + return; + + vcmd_free_pasid(iommu, ioasid); +} + const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .domain_alloc = intel_iommu_domain_alloc, @@ -5646,6 +5677,8 @@ const struct iommu_ops intel_iommu_ops = { .get_dev_attr = intel_iommu_get_dev_attr, .set_dev_attr = intel_iommu_set_dev_attr, .pasid_init = intel_iommu_pasid_init, + .pasid_alloc = intel_iommu_pasid_alloc, + .pasid_free = intel_iommu_pasid_free, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; -- 2.17.1