All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	gregkh@suse.de, avi@redhat.com, mingo@redhat.com,
	dwmw2@infradead.org, weidong.han@intel.com,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org
Subject: Re: [GIT PULL] various IOMMU updates for 2.6.29
Date: Sun, 4 Jan 2009 11:05:11 +0100	[thread overview]
Message-ID: <20090104100511.GC12938@elte.hu> (raw)
In-Reply-To: <20090103225627.GA21841@amd.com>


* Joerg Roedel <joerg.roedel@amd.com> 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

----------------------------->
>From c66b9906f863696159e05890bb7123269bb9a9de Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Sun, 4 Jan 2009 10:55:02 +0100
Subject: [PATCH] intel-iommu: fix build error with INTR_REMAP=y and DMAR=n

dmar.o can be built in the CONFIG_INTR_REMAP=y case but
iommu_calculate_agaw() is only available if VT-d is built as well.

So create an inline version of iommu_calculate_agaw() for the
!CONFIG_DMAR case. The iommu->agaw value wont be used in this
case, but the code is cleaner (has less #ifdefs) if we have it around
unconditionally.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/dma_remapping.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 136f170..af1dab4 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -17,7 +17,15 @@ struct dmar_domain;
 struct root_entry;
 
 extern void free_dmar_iommu(struct intel_iommu *iommu);
+
+#ifdef CONFIG_DMAR
 extern int iommu_calculate_agaw(struct intel_iommu *iommu);
+#else
+static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
+{
+	return 0;
+}
+#endif
 
 extern int dmar_disabled;
 

  reply	other threads:[~2009-01-04 10:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-03 17:31 [GIT PULL] various IOMMU updates for 2.6.29 Joerg Roedel
2009-01-03 22:06 ` Ingo Molnar
2009-01-03 22:11   ` Joerg Roedel
2009-01-03 22:56     ` Joerg Roedel
2009-01-04 10:05       ` Ingo Molnar [this message]
2009-01-04 10:30         ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090104100511.GC12938@elte.hu \
    --to=mingo@elte.hu \
    --cc=avi@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@suse.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joerg.roedel@amd.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=weidong.han@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.