WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

Re: [Xen-ia64-devel] [RFC] gnttab unmap_and_replace

To: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Subject: Re: [Xen-ia64-devel] [RFC] gnttab unmap_and_replace
From: Alex Williamson <alex.williamson@xxxxxx>
Date: Tue, 05 Jun 2007 11:58:16 -0600
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 05 Jun 2007 10:56:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070605142710.GB25309%yamahata@xxxxxxxxxxxxx>
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: HP OSLO R&D
References: <20070605142710.GB25309%yamahata@xxxxxxxxxxxxx>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
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