From: Jeremy Fitzhardinge <jeremy@goop.org>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: x86@kernel.org, mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] swiotlb updates for Xen dom0
Date: Thu, 02 Apr 2009 00:12:44 -0700 [thread overview]
Message-ID: <49D4656C.20009@goop.org> (raw)
In-Reply-To: <20090402152918I.fujita.tomonori@lab.ntt.co.jp>
FUJITA Tomonori wrote:
> On Tue, 31 Mar 2009 15:52:06 -0700
> Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
>
>> This series adds Xen support to x86 swiotlb. This is mostly a matter of
>> adding some Xen code into the existing hooks in pci-swiotlb_64.c:
>> - swiotlb_alloc_boot
>> - swiotlb_arch_range_needs_mapping
>> - swiotlb_phys_to_bus/bus_to_phys
>>
>> These hooks are conditional on xen_pv_domain(), which compiles to a
>> constant 0 when CONFIG_XEN is not enabled (and is a simple variable
>> read when it is).
>>
>> All the Xen-specific code is in xen-iommu.c.
>>
>> This series is just the patches which touch lib/swiotlb.c or
>> pci-swiotlb_64.c. You can see them with more context in:
>> git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git for-linus/xen/dom0/swiotlb
>>
>> Thanks,
>> J
>>
>> arch/x86/kernel/pci-swiotlb_64.c | 31 ++++++++++++++++-
>> arch/x86/xen/Kconfig | 1
>> drivers/pci/xen-iommu.c | 68 ++++++++++++++++++++++++++++++++++++---
>> include/xen/swiotlb.h | 38 +++++++++++++++++++++
>> lib/swiotlb.c | 3 +
>> 5 files changed, 133 insertions(+), 8 deletions(-)
>>
>
> This patchset looks ugly.
>
> You add 'if we are Xen, we do A. We do B if not' code into 6 functions
> though pic-swiotlb_64.c has only 8 functions. In addition, 5 of 8
> functions were added for Xen.
>
> Why can't you have something like arch/x86/xen/pci-swiotlb.c, which
> works as arch/x86/kernel/pci-swiotlb_64.c? That should be much
> cleaner.
>
Sure. Something like this? (Applied on top of the rest of the series,
after kernel/pci-swiotlb_64.c => pci_swiotlb.c) It leaves one if(xen)
in the init function, but its consistent with the other clauses setting
swiotlb=1.
My only concern with this scheme is that if there's ever a non-Xen x86
user who wants to override these functions, we'll need to move them back
out into a common file because its not possible to have two overriding
definitions for a weak function (one hopes that the linker will warn if
that arises).
J
Subject: [PATCH] xen/swiotlb: move all Xen-specific swiotlb operations to separate file
Most of these functions are no-ops on non-Xen systems, so we can fall
back to the default functions if CONFIG_XEN is not defined.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index ead556f..2d8dd35 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -12,54 +12,9 @@
#include <asm/dma.h>
#include <xen/swiotlb.h>
-#include <asm/xen/hypervisor.h>
int swiotlb __read_mostly;
-void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
-{
- void *ret = alloc_bootmem_low_pages(size);
-
- if (ret && xen_pv_domain())
- xen_swiotlb_fixup(ret, size, nslabs);
-
- return ret;
-}
-
-void *swiotlb_alloc(unsigned order, unsigned long nslabs)
-{
- void *ret = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
-
- if (ret && xen_pv_domain())
- xen_swiotlb_fixup(ret, 1u << order, nslabs);
-
- return ret;
-}
-
-dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
-{
- if (xen_pv_domain())
- return xen_phys_to_bus(paddr);
-
- return paddr;
-}
-
-phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr)
-{
- if (xen_pv_domain())
- return xen_bus_to_phys(baddr);
-
- return baddr;
-}
-
-int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
-{
- if (xen_pv_domain())
- return xen_range_needs_mapping(paddr, size);
-
- return 0;
-}
-
static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags)
{
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 639965a..b021e72 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -12,4 +12,4 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
obj-$(CONFIG_SMP) += smp.o spinlock.o
obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o
obj-$(CONFIG_XEN_DOM0) += vga.o apic.o
-obj-$(CONFIG_XEN_DOM0_PCI) += pci.o
\ No newline at end of file
+obj-$(CONFIG_XEN_DOM0_PCI) += pci.o pci-swiotlb.o
\ No newline at end of file
diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c
new file mode 100644
index 0000000..82b2291
--- /dev/null
+++ b/arch/x86/xen/pci-swiotlb.c
@@ -0,0 +1,51 @@
+#include <linux/bootmem.h>
+#include <linux/gfp.h>
+
+#include <xen/swiotlb.h>
+#include <asm/xen/hypervisor.h>
+
+/*
+ * This file defines overrides for weak functions with default
+ * implementations in lib/swiotlb.c.
+ */
+
+void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+{
+ void *ret = alloc_bootmem_low_pages(size);
+
+ if (ret && xen_pv_domain())
+ xen_swiotlb_fixup(ret, size, nslabs);
+
+ return ret;
+}
+
+void *swiotlb_alloc(unsigned order, unsigned long nslabs)
+{
+ /* Never called on x86. Warn, just in case. */
+ WARN_ON(1);
+ return NULL;
+}
+
+dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
+{
+ if (xen_pv_domain())
+ return xen_phys_to_bus(paddr);
+
+ return paddr;
+}
+
+phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr)
+{
+ if (xen_pv_domain())
+ return xen_bus_to_phys(baddr);
+
+ return baddr;
+}
+
+int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
+{
+ if (xen_pv_domain())
+ return xen_range_needs_mapping(paddr, size);
+
+ return 0;
+}
prev parent reply other threads:[~2009-04-02 7:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 22:52 [PATCH] swiotlb updates for Xen dom0 Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 1/9] xen: make sure swiotlb allocation is physically contigious Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 2/9] xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 3/9] xen: add hooks for mapping phys<->bus addresses in swiotlb Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 4/9] xen/swiotlb: add hook for swiotlb_arch_range_needs_mapping Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 5/9] xen: enable swiotlb for xen domain 0 Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 6/9] swiotlb: use swiotlb_alloc_boot to allocate emergency pool Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 7/9] xen/swiotlb: improve comment on gfp flags in xen_alloc_coherent() Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 8/9] xen/swiotlb: add sync functions Jeremy Fitzhardinge
2009-03-31 22:52 ` [PATCH 9/9] pci-swiotlb: remove __weak vs __weak binding Jeremy Fitzhardinge
2009-04-02 6:29 ` [PATCH] swiotlb updates for Xen dom0 FUJITA Tomonori
2009-04-02 7:12 ` Jeremy Fitzhardinge [this message]
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=49D4656C.20009@goop.org \
--to=jeremy@goop.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 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.