From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
Albert Herranz <albert_herranz@yahoo.es>,
x86@kernel.org, Jesse Barnes <jbarnes@virtuousgeek.org>,
linux-kernel@vger.kernel.org,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
iommu@lists.linux-foundation.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 9/9] x86: Detect whether we should use Xen SWIOTLB.
Date: Tue, 27 Jul 2010 15:41:05 -0400 [thread overview]
Message-ID: <20100727194105.GA18647@phenom.dumpdata.com> (raw)
In-Reply-To: <4C4F2D9C.4020303@zytor.com>
On Tue, Jul 27, 2010 at 12:03:56PM -0700, H. Peter Anvin wrote:
> On 07/27/2010 10:00 AM, Konrad Rzeszutek Wilk wrote:
> > It is paramount that we call pci_xen_swiotlb_detect before
> > pci_swiotlb_detect as both implementations use the 'swiotlb'
> > and 'swiotlb_force' flags. The pci-xen_swiotlb_detect inhibits
> > the swiotlb_force and swiotlb flag so that the native SWIOTLB
> > implementation is not enabled when running under Xen.
> >
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> > Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > Cc: Albert Herranz <albert_herranz@yahoo.es>
> > Cc: Ian Campbell <Ian.Campbell@citrix.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Cc: x86@kernel.org
> > Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> > ---
> > arch/x86/kernel/pci-dma.c | 7 +++++--
> > 1 files changed, 5 insertions(+), 2 deletions(-)
> >
>
> Is there any way we can abstract this out a bit more instead of crapping
> on generic code?
I was toying with something like this:
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 9f07cfc..e0cd388 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -45,6 +45,25 @@ int iommu_detected __read_mostly = 0;
*/
int iommu_pass_through __read_mostly;
+initcall_t __swiotlb_initcall_detect[] =
+ {pci_xen_swiotlb_detect,
+ pci_swiotlb_detect,
+ NULL};
+
+initcall_t __swiotlb_initcall_init[] = {
+ pci_xen_swiotlb_init,
+ pci_swiotlb_init,
+ NULL};
+
+
+initcall_t __iommu_initcall_detect[] = {
+ gart_iommu_hole_init,
+ detect_calgary,
+ detect_intel_iommu,
+ /* needs to be called after gart_iommu_hole_init */
+ amd_iommu_detect,
+ NULL};
+
/* Dummy device used for NULL arguments (normally ISA). */
struct device x86_dma_fallback_dev = {
.init_name = "fallback device",
@@ -130,24 +149,22 @@ static void __init dma32_free_bootmem(void)
void __init pci_iommu_alloc(void)
{
+ initcall_t *fn;
+
/* free the range so iommu could get some range less than 4G */
dma32_free_bootmem();
- if (pci_xen_swiotlb_detect() || pci_swiotlb_detect())
- goto out;
-
- gart_iommu_hole_init();
-
- detect_calgary();
+ /* First do the SWIOTLB - if they work, skip the IOMMUs. */
+ for (fn = __swiotlb_initcall_detect; fn != NULL; fn++)
+ if ((*fn)())
+ goto swiotlb_init;
- detect_intel_iommu();
-
- /* needs to be called after gart_iommu_hole_init */
- amd_iommu_detect();
-out:
- pci_xen_swiotlb_init();
+ for (fn = __iommu_initcall_detect; fn != NULL; fn++)
+ (*fn)();
- pci_swiotlb_init();
+swiotlb_init:
+ for (fn = __swiotlb_initcall_init; fn != NULL; fn++)
+ (*fn)();
}
void *dma_generic_alloc_coherent(struct device *dev, size_t size,
(compiles with warnings and has not yet been completly flushed), but
Fujita mentioned that it might the right choice to use this
when we have more than just these two swiotlb-implentors.
>
> -hpa
> --
> H. Peter Anvin, Intel Open Source Technology Center
> I work for Intel. I don't speak on their behalf.
>
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2010-07-27 19:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-27 16:59 [PATCH] Xen-SWIOTLB v0.8.6 used for Xen PCI pass through for PV guests Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 1/9] xen: use _PAGE_IOMAP in ioremap to do machine mappings Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 2/9] xen: Allow unprivileged Xen domains to create iomap pages Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 3/9] xen: Rename the balloon lock Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 4/9] xen: Add xen_create_contiguous_region Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 5/9] vmap: add flag to allow lazy unmap to be disabled at runtime Konrad Rzeszutek Wilk
2010-07-27 16:59 ` [PATCH 6/9] xen/mmu: inhibit vmap aliases rather than trying to clear them out Konrad Rzeszutek Wilk
2010-07-27 17:00 ` [PATCH 7/9] swiotlb-xen: SWIOTLB library for Xen PV guest with PCI passthrough Konrad Rzeszutek Wilk
2010-07-27 17:00 ` [PATCH 8/9] pci-swiotlb-xen: Add glue code to setup dma_ops utilizing xen_swiotlb_* functions Konrad Rzeszutek Wilk
2010-07-27 17:00 ` [PATCH 9/9] x86: Detect whether we should use Xen SWIOTLB Konrad Rzeszutek Wilk
2010-07-27 19:03 ` H. Peter Anvin
2010-07-27 19:41 ` Konrad Rzeszutek Wilk [this message]
2010-07-27 23:36 ` FUJITA Tomonori
2010-07-28 0:19 ` H. Peter Anvin
2010-07-28 0:52 ` FUJITA Tomonori
2010-07-28 22:38 ` Konrad Rzeszutek Wilk
2010-07-28 22:52 ` H. Peter Anvin
2010-07-29 7:17 ` FUJITA Tomonori
2010-07-29 13:44 ` H. Peter Anvin
2010-07-29 16:05 ` Konrad Rzeszutek Wilk
2010-08-02 15:25 ` Konrad Rzeszutek Wilk
2010-08-02 15:30 ` H. Peter Anvin
2010-08-02 15:43 ` FUJITA Tomonori
2010-08-02 15:47 ` H. Peter Anvin
2010-08-02 16:01 ` FUJITA Tomonori
2010-08-02 16:42 ` Konrad Rzeszutek Wilk
2010-08-02 16:53 ` H. Peter Anvin
2010-08-03 5:35 ` FUJITA Tomonori
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=20100727194105.GA18647@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=albert_herranz@yahoo.es \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox