From patchwork Fri Apr 10 08:42:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Zhen-Hua" X-Patchwork-Id: 6193071 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 95FE39F2E9 for ; Fri, 10 Apr 2015 08:43:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5CF020353 for ; Fri, 10 Apr 2015 08:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7D6E203C4 for ; Fri, 10 Apr 2015 08:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932321AbbDJInU (ORCPT ); Fri, 10 Apr 2015 04:43:20 -0400 Received: from g4t3427.houston.hp.com ([15.201.208.55]:41788 "EHLO g4t3427.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754270AbbDJInP (ORCPT ); Fri, 10 Apr 2015 04:43:15 -0400 Received: from g5t1633.atlanta.hp.com (g5t1633.atlanta.hp.com [16.201.144.132]) by g4t3427.houston.hp.com (Postfix) with ESMTP id 7C63296; Fri, 10 Apr 2015 08:43:13 +0000 (UTC) Received: from localhost.localdomain (linuxtest.chn.hp.com [16.155.255.10]) by g5t1633.atlanta.hp.com (Postfix) with ESMTP id 312BE70; Fri, 10 Apr 2015 08:43:05 +0000 (UTC) From: "Li, Zhen-Hua" To: , , , , , Cc: , , , , , , , , , , , , , , , Subject: [PATCH v10 01/10] iommu/vt-d: New function to attach domain with id Date: Fri, 10 Apr 2015 16:42:04 +0800 Message-Id: <1428655333-19504-2-git-send-email-zhen-hual@hp.com> X-Mailer: git-send-email 2.0.0-rc0 In-Reply-To: <1428655333-19504-1-git-send-email-zhen-hual@hp.com> References: <1428655333-19504-1-git-send-email-zhen-hual@hp.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow specification of the domain-id for the new domain. This patch only adds a new function iommu_attach_domain_with_id, it is like the function iommu_attach_domain(), only adding a parameter "did". Bill Sumner: (In older versions) Add new 'did' parameter to iommu_attach_domain(); The caller of this function. Li, Zhenhua: New function iommu_attach_domain_with_id(), instead of updating function iommu_attach_domain(); Signed-off-by: Bill Sumner Signed-off-by: Li, Zhen-Hua --- drivers/iommu/intel-iommu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 2d1e05b..3a93ce0 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1558,6 +1558,16 @@ static int iommu_attach_domain(struct dmar_domain *domain, return num; } +static int iommu_attach_domain_with_id(struct dmar_domain *domain, + struct intel_iommu *iommu, + int domain_number) +{ + if (domain_number >= 0) + return domain_number; + + return iommu_attach_domain(domain, iommu); +} + static int iommu_attach_vm_domain(struct dmar_domain *domain, struct intel_iommu *iommu) { @@ -2224,6 +2234,7 @@ static struct dmar_domain *get_domain_for_dev(struct device *dev, int gaw) u16 dma_alias; unsigned long flags; u8 bus, devfn; + int did = -1; /* Default to "no domain_id supplied" */ domain = find_domain(dev); if (domain) @@ -2257,7 +2268,7 @@ static struct dmar_domain *get_domain_for_dev(struct device *dev, int gaw) domain = alloc_domain(0); if (!domain) return NULL; - domain->id = iommu_attach_domain(domain, iommu); + domain->id = iommu_attach_domain_with_id(domain, iommu, did); if (domain->id < 0) { free_domain_mem(domain); return NULL;