From patchwork Fri Apr 9 17:49:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai X-Patchwork-Id: 91732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o39HoXG2000794 for ; Fri, 9 Apr 2010 17:52:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755009Ab0DIRww (ORCPT ); Fri, 9 Apr 2010 13:52:52 -0400 Received: from rcsinet12.oracle.com ([148.87.113.124]:31120 "EHLO rcsinet12.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008Ab0DIRwv (ORCPT ); Fri, 9 Apr 2010 13:52:51 -0400 Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet12.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o39Hqbpv007193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 9 Apr 2010 17:52:38 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o39AYpcU029907; Fri, 9 Apr 2010 17:52:31 GMT Received: from abhmt001.oracle.com by acsmt353.oracle.com with ESMTP id 149635781270835448; Fri, 09 Apr 2010 10:50:48 -0700 Received: from [10.6.76.26] (/10.6.76.26) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Apr 2010 10:50:47 -0700 Message-ID: <4BBF68AD.9010405@oracle.com> Date: Fri, 09 Apr 2010 10:49:33 -0700 From: Yinghai User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100228 SUSE/3.0.3-1.1.1 Thunderbird/3.0.3 MIME-Version: 1.0 To: David Woodhouse CC: Jesse Barnes , Chris Wright , "Yu, Fenghua" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "iommu@lists.linux-foundation.org" Subject: Re: [PATCH 6/6] intel-iommu: Don't call domain_exit if can not attach with iommu References: <1270753107-15881-1-git-send-email-yinghai@kernel.org> <1270753107-15881-7-git-send-email-yinghai@kernel.org> <1270827783.4478.10459.camel@macbook.infradead.org> In-Reply-To: <1270827783.4478.10459.camel@macbook.infradead.org> X-Source-IP: acsmt353.oracle.com [141.146.40.153] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090201.4BBF6964.00C8:SCFMA4539814,ss=1,fgs=0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 09 Apr 2010 17:52:53 +0000 (UTC) Index: linux-2.6/drivers/pci/intel-iommu.c =================================================================== --- linux-2.6.orig/drivers/pci/intel-iommu.c +++ linux-2.6/drivers/pci/intel-iommu.c @@ -1379,24 +1379,10 @@ static int domain_init(struct dmar_domai domain_reserve_special_ranges(domain); - /* calculate AGAW */ - iommu = domain_get_iommu(domain); - if (guest_width > cap_mgaw(iommu->cap)) - guest_width = cap_mgaw(iommu->cap); - domain->gaw = guest_width; - adjust_width = guestwidth_to_adjustwidth(guest_width); - agaw = width_to_agaw(adjust_width); - sagaw = cap_sagaw(iommu->cap); - if (!test_bit(agaw, &sagaw)) { - /* hardware doesn't support it, choose a bigger one */ - pr_debug("IOMMU: hardware doesn't support agaw %d\n", agaw); - agaw = find_next_bit(&sagaw, 5, agaw); - if (agaw >= 5) - return -ENODEV; - } - domain->agaw = agaw; INIT_LIST_HEAD(&domain->devices); + iommu = domain_get_iommu(domain); + if (ecap_coherent(iommu->ecap)) domain->iommu_coherency = 1; else @@ -1415,6 +1401,23 @@ static int domain_init(struct dmar_domai if (!domain->pgd) return -ENOMEM; __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE); + + /* calculate AGAW */ + if (guest_width > cap_mgaw(iommu->cap)) + guest_width = cap_mgaw(iommu->cap); + domain->gaw = guest_width; + adjust_width = guestwidth_to_adjustwidth(guest_width); + agaw = width_to_agaw(adjust_width); + sagaw = cap_sagaw(iommu->cap); + if (!test_bit(agaw, &sagaw)) { + /* hardware doesn't support it, choose a bigger one */ + pr_debug("IOMMU: hardware doesn't support agaw %d\n", agaw); + agaw = find_next_bit(&sagaw, 5, agaw); + if (agaw >= 5) + return -ENODEV; + } + domain->agaw = agaw; + return 0; } @@ -1853,7 +1856,7 @@ static struct dmar_domain *get_domain_fo ret = iommu_attach_domain(domain, iommu); if (ret) { - domain_exit(domain); + free_domain_mem(domain); goto error; }