Message ID | 1431622863-28575-13-git-send-email-julien.grall@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 14/05/15 18:00, Julien Grall wrote: > With 64KB page granularity support in Linux, a page will be split accross > multiple MFN (Xen is using 4KB page granularity). Thoses MFNs may not be > contiguous. > > With the offset in the page, the helper will be able to know which MFN > the driver needs to retrieve. I think a gnttab_grant_foreign_access_ref()-like helper that takes a page would be better. You will probably want this helper able to return/fill a set of refs for 64 KiB pages. David
Hi David, On 19/05/15 14:57, David Vrabel wrote: > On 14/05/15 18:00, Julien Grall wrote: >> With 64KB page granularity support in Linux, a page will be split accross >> multiple MFN (Xen is using 4KB page granularity). Thoses MFNs may not be >> contiguous. >> >> With the offset in the page, the helper will be able to know which MFN >> the driver needs to retrieve. > > I think a gnttab_grant_foreign_access_ref()-like helper that takes a > page would be better. > > You will probably want this helper able to return/fill a set of refs for > 64 KiB pages. I will see what I can do. Although, I think this patch is still valid to avoid wrong usage with 64KB page granularity by the caller. The developer may think that MFN are contiguous which is not always true. Regards,
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 381d38f..6a0e329 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -431,7 +431,7 @@ static struct xen_netif_tx_request *xennet_make_one_txreq( BUG_ON((signed short)ref < 0); gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, - page_to_mfn(page), GNTMAP_readonly); + page_to_mfn(page, 0), GNTMAP_readonly); queue->tx_skbs[id].skb = skb; queue->grant_tx_page[id] = page; diff --git a/include/xen/page.h b/include/xen/page.h index 89ae01c..8848da1 100644 --- a/include/xen/page.h +++ b/include/xen/page.h @@ -20,9 +20,9 @@ #include <asm/xen/page.h> -static inline unsigned long page_to_mfn(struct page *page) +static inline unsigned long page_to_mfn(struct page *page, unsigned int offset) { - return pfn_to_mfn(xen_page_to_pfn(page)); + return pfn_to_mfn(xen_page_to_pfn(page) + (offset >> XEN_PAGE_SHIFT)); } struct xen_memory_region {
With 64KB page granularity support in Linux, a page will be split accross multiple MFN (Xen is using 4KB page granularity). Thoses MFNs may not be contiguous. With the offset in the page, the helper will be able to know which MFN the driver needs to retrieve. Signed-off-by: Julien Grall <julien.grall@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: netdev@vger.kernel.org --- drivers/net/xen-netfront.c | 2 +- include/xen/page.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)