Re: [GIT PULL] various IOMMU updates for 2.6.29

From: Ingo Molnar
Date: Sun Jan 04 2009 - 05:05:48 EST



* Joerg Roedel <joerg.roedel@xxxxxxx> wrote:

> @@ -491,7 +491,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
> int map_size;
> u32 ver;
> static int iommu_allocated = 0;
> - int agaw;
> + int agaw = 0;
>
> iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
> if (!iommu)
> @@ -507,6 +507,7 @@ 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);
>
> +#ifdef CONFIG_DMAR
> agaw = iommu_calculate_agaw(iommu);
> if (agaw < 0) {
> printk(KERN_ERR

yeah, setting it to zero should be safe in this case - agaw == 0 is a
potentially bogus value as far as the hw is concerned, but the only user
of it is intel-iommu.c which is only built if CONFIG_DMAR is set - and
this is the non-DMA-remap case so it should not matter. David, do you
agree?

but, that #ifdef in your patch is inacceptably ugly. The right approach is
for iommu_calculate_agaw() to be an inline function in the !CONFIG_DMAR
case, which returns 0. That makes the above code sequence work out of box,
without any ugly #ifdefs.

See the patch below - i have queued it up in tip/core/urgent.

Ingo

----------------------------->