|
|
|
|
|
|
|
|
|
|
xen-ia64-devel
Re: [Xen-ia64-devel] [RFC] gnttab unmap_and_replace
On Tue, 2007-06-05 at 23:27 +0900, Isaku Yamahata wrote:
> # HG changeset patch
> # User yamahata@xxxxxxxxxxxxx
> # Date 1181053183 -32400
> # Node ID 6278e52f8cb6aa4c61635acf7a324b5d7c288eb5
> # Parent d537f6f5a5de527613b4d2045e0f8d5a24c05cf1
> gnttab_dma_map/unmap_page() should use dma_addr_t, not maddr_t
> PATCHNAME: dma_addr_t_gnttab_dma_map_unmap_page
>
> Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
>
> diff -r d537f6f5a5de -r 6278e52f8cb6
> linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
> --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Tue Jun 05
> 15:44:51 2007 +0900
> +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Tue Jun 05
> 23:19:43 2007 +0900
> @@ -591,15 +591,14 @@ 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 mfn = pfn_to_mfn(page_to_pfn(page)), mfn2;
> -
> - if (!PageForeign(page))
> - return mfn << PAGE_SHIFT;
> -
> - if (pfn_valid(mfn_to_local_pfn(mfn)))
> - return mfn << PAGE_SHIFT;
> +dma_addr_t gnttab_dma_map_page(struct page *page)
> +{
> + dma_addr_t dma_address = page_to_bus(page);
> + maddr_t mfn = pfn_to_mfn(page_to_pfn(page));
> +
> + if (!is_running_on_xen() ||
> + !PageForeign(page) || pfn_valid(mfn_to_local_pfn(mfn)))
> + return dma_address;
>
> atomic_set(&page->_mapcount, 0);
>
> @@ -607,9 +606,7 @@ maddr_t gnttab_dma_map_page(struct page
> smp_mb();
>
> /* Has this page been copied in the mean time? */
> - mfn2 = pfn_to_mfn(page_to_pfn(page));
> -
> - return mfn2 << PAGE_SHIFT;
> + return page_to_bus(page);
> }
Ouch, we're adding an unnecessary hypercall every time we call this
function. How about:
dma_addr_t gnttab_dma_map_page(struct page *page)
{
maddr_t mfn = pfn_to_mfn(page_to_pfn(page));
if (!is_running_on_xen() ||
!PageForeign(page) || pfn_valid(mfn_to_local_pfn(mfn)))
return page_to_bus(page);
** OR **
return dma_address;
Thanks,
Alex
--
Alex Williamson HP Open Source & Linux Org.
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
|
|
|
|
|