# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1181203954 -32400 # Node ID 9fcca2df865e61f96d6f32eb2b5f1a1aa4fe9099 # Parent 1c4aac883f56c707306b57221c20a0d12549e4ad separated out dma address conversion part from grant table dma map api into arch specific file. sorted out confusing maddr_t with dma_addr_t. PATCHNAME: separate_dma_address_conversion Signed-off-by: Isaku Yamahata diff -r 1c4aac883f56 -r 9fcca2df865e 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 Jun 07 17:03:56 2007 +0900 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Thu Jun 07 17:12:34 2007 +0900 @@ -19,6 +19,7 @@ #include #include #include +#include #include #ifdef __x86_64__ diff -r 1c4aac883f56 -r 9fcca2df865e linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c --- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Thu Jun 07 17:03:56 2007 +0900 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Thu Jun 07 17:12:34 2007 +0900 @@ -27,6 +27,7 @@ #include #include #include +#include int swiotlb; EXPORT_SYMBOL(swiotlb); diff -r 1c4aac883f56 -r 9fcca2df865e linux-2.6-xen-sparse/drivers/xen/core/gnttab.c --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Thu Jun 07 17:03:56 2007 +0900 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Thu Jun 07 17:12:34 2007 +0900 @@ -593,20 +593,19 @@ EXPORT_SYMBOL(gnttab_copy_grant_page); * * All other pages are simply returned as is. */ -maddr_t gnttab_dma_map_page(struct page *page) -{ - maddr_t maddr = page_to_bus(page); +void __gnttab_dma_map_page(struct page *page, + int (*local_pfn)(struct page *page)) +{ + extern seqlock_t gnttab_dma_lock; unsigned int seq; - if (!PageForeign(page)) - return maddr; + if (!is_running_on_xen() || !PageForeign(page)) + return; do { seq = read_seqbegin(&gnttab_dma_lock); - maddr = page_to_bus(page); - - /* Has it become a local MFN? */ - if (pfn_valid(mfn_to_local_pfn(maddr >> PAGE_SHIFT))) + + if (local_pfn && (*local_pfn)(page)) break; atomic_set(&page->_mapcount, 0); @@ -614,8 +613,6 @@ maddr_t gnttab_dma_map_page(struct page /* Make _mapcount visible before read_seqretry. */ smp_mb(); } while (unlikely(read_seqretry(&gnttab_dma_lock, seq))); - - return maddr; } int gnttab_resume(void) diff -r 1c4aac883f56 -r 9fcca2df865e linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/gnttab_dma.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/gnttab_dma.h Thu Jun 07 17:12:34 2007 +0900 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2007 Herbert Xu + * Copyright (c) 2007 Isaku Yamahata + * VA Linux Systems Japan K.K. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _ASM_I386_GNTTAB_DMA_H +#define _ASM_I386_GNTTAB_DMA_H + +static inline int gnttab_dma_local_pfn(struct page *page) +{ + return pfn_valid(mfn_to_local_pfn(pfn_to_mfn(page_to_pfn(page)))); +} + +static inline dma_addr_t gnttab_dma_map_page(struct page *page) +{ + __gnttab_dma_map_page(page, &gnttab_dma_local_pfn); + return page_to_bus(page); +} + +static inline void gnttab_dma_unmap_page(dma_addr_t dma_address) +{ + __gnttab_dma_unmap_page(virt_to_page(bus_to_virt(dma_address))); +} + +#endif /* _ASM_I386_GNTTAB_DMA_H */ diff -r 1c4aac883f56 -r 9fcca2df865e linux-2.6-xen-sparse/include/xen/gnttab.h --- a/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Jun 07 17:03:56 2007 +0900 +++ b/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Jun 07 17:12:34 2007 +0900 @@ -103,9 +103,9 @@ void gnttab_grant_foreign_transfer_ref(g unsigned long pfn); int gnttab_copy_grant_page(grant_ref_t ref, struct page **pagep); -maddr_t gnttab_dma_map_page(struct page *page); - -static inline void gnttab_dma_unmap_page(maddr_t mfn) +void __gnttab_dma_map_page(struct page *page, + int (*local_pfn)(struct page *page)); +static inline void __gnttab_dma_unmap_page(struct page *page) { }