From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: Re: [PATCH 03/13] set iommu agaw Date: Thu, 04 Dec 2008 17:12:41 +0000 Message-ID: <1228410761.3732.138.camel@blaa> References: <715D42877B251141A38726ABF5CABF2C018BF05989@pdsmsx503.ccr.corp.intel.com> Reply-To: Mark McLoughlin Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: "'Avi Kivity'" , "Woodhouse, David" , "'Jesse Barnes'" , "Yu, Fenghua" , "'iommu@lists.linux-foundation.org'" , "'kvm@vger.kernel.org'" To: "Han, Weidong" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:35276 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209AbYLDROK (ORCPT ); Thu, 4 Dec 2008 12:14:10 -0500 In-Reply-To: <715D42877B251141A38726ABF5CABF2C018BF05989@pdsmsx503.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 2008-12-02 at 22:22 +0800, Han, Weidong wrote: > agaw may be different across iommus. > > Signed-off-by: Weidong Han > --- > drivers/pci/dmar.c | 14 ++++++++++++++ > include/linux/dma_remapping.h | 2 ++ > include/linux/intel-iommu.h | 1 + > 3 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c > index 691b3ad..ebcc7c2 100644 > --- a/drivers/pci/dmar.c > +++ b/drivers/pci/dmar.c > @@ -491,6 +491,8 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) > int map_size; > u32 ver; > static int iommu_allocated = 0; > + unsigned long sagaw; > + int agaw; > > iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); > if (!iommu) > @@ -506,6 +508,18 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) > iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); > iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); > > + /* set agaw, "SAGAW" may be different across iommus */ > + sagaw = cap_sagaw(iommu->cap); > + for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH); > + agaw >= 0; agaw--) > + if (test_bit(agaw, &sagaw)) > + break; > + if (agaw < 0) { > + printk(KERN_ERR "IOMMU: unsupported sagaw %lx\n", sagaw); > + goto error; > + } > + iommu->agaw = agaw; Could we add something like intel_iommu_calculate_agaw() and keep the agaw code internal to intel-iommu.c? Also, "unsupported sagaw" expands to "unsupported supported adjusted guest address width" which doesn't make much sense :-) "unsupported address width" would be sufficient, I think. Cheers, Mark.