From: Jambunathan K <jambunathan@netxen.com>
To: xen-devel@lists.xensource.com
Cc: Sanjeev Jorapur <sanjeev@netxen.com>
Subject: [PATCH] Added xen_is_contiguous_region
Date: Fri, 13 Apr 2007 23:17:05 +0530 [thread overview]
Message-ID: <461FC219.7040606@netxen.com> (raw)
Continuation of the following thread
http://lists.xensource.com/archives/html/xen-devel/2007-04/msg00135.html
I haven't compiled the changes for IA64. Consider the changes as indicative.
Added xen_is_contiguous_region
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Fri Apr 13 23:16:15 2007
@@ -327,7 +327,7 @@
dma = swiotlb_map_single(dev, ptr, size, direction);
} else {
dma = virt_to_bus(ptr);
- IOMMU_BUG_ON(range_straddles_page_boundary(ptr, size));
+ IOMMU_BUG_ON(!xen_is_contiguous_region(ptr, size));
IOMMU_BUG_ON(address_needs_mapping(dev, dma));
}
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Fri Apr 13 23:16:15 2007
@@ -479,7 +479,7 @@
* we can safely return the device addr and not worry about bounce
* buffering it.
*/
- if (!range_straddles_page_boundary(ptr, size) &&
+ if (xen_is_contiguous_region(ptr, size) &&
!address_needs_mapping(hwdev, dev_addr))
return dev_addr;
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Fri Apr 13 23:16:15 2007
@@ -440,6 +440,13 @@
}
EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
+int xen_is_contiguous_region(void *vaddr, size_t size)
+{
+ return (((((unsigned long)vaddr & ~PAGE_MASK) + size) <= PAGE_SIZE) ||
+ test_bit(__pa(vaddr) >> PAGE_SHIFT, contiguous_bitmap));
+}
+EXPORT_SYMBOL_GPL(xen_is_contiguous_region);
+
#ifdef __i386__
int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
{
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h Fri Apr 13 23:16:15 2007
@@ -25,9 +25,7 @@
static inline int
range_straddles_page_boundary(void *p, size_t size)
{
- extern unsigned long *contiguous_bitmap;
- return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
- !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+ return !xen_is_contiguous_region(p, size);
}
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Fri Apr 13 23:16:15 2007
@@ -118,6 +118,7 @@
unsigned long vstart, unsigned int order, unsigned int address_bits);
void xen_destroy_contiguous_region(
unsigned long vstart, unsigned int order);
+int xen_is_contiguous_region(void *vaddr, size_t size);
/* Turn jiffies into Xen system time. */
u64 jiffies_to_st(unsigned long jiffies);
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Fri Apr 13 23:16:15 2007
@@ -127,9 +127,7 @@
static inline int
range_straddles_page_boundary(void *p, size_t size)
{
- extern unsigned long *contiguous_bitmap;
- return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
- !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+ return !xen_is_contiguous_region(p, size);
}
#endif
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Fri Apr 13 23:16:15 2007
@@ -146,7 +146,7 @@
#ifndef CONFIG_VMX_GUEST
int __xen_create_contiguous_region(unsigned long vstart, unsigned int order, unsigned int address_bits);
-static inline int
+int
xen_create_contiguous_region(unsigned long vstart,
unsigned int order, unsigned int address_bits)
{
@@ -157,14 +157,24 @@
}
return ret;
}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
void __xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
-static inline void
+void
xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
{
if (is_running_on_xen())
__xen_destroy_contiguous_region(vstart, order);
}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
+int xen_is_contiguous_region(void *vaddr, size_t size)
+{
+ return (((((unsigned long)vaddr & ~PAGE_MASK) + size) <= PAGE_SIZE) ||
+ test_bit(__pa(vaddr) >> PAGE_SHIFT, contiguous_bitmap));
+}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
#endif /* !CONFIG_VMX_GUEST */
reply other threads:[~2007-04-13 17:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=461FC219.7040606@netxen.com \
--to=jambunathan@netxen.com \
--cc=sanjeev@netxen.com \
--cc=xen-devel@lists.xensource.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.