From d2b16f741ae9f1d0720e729159f5ab0453ef4bb1 Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Fri, 28 Aug 2015 18:54:56 +0100 Subject: [PATCH] fb/xen-fbfront: Support 64KB pages Signed-off-by: Julien Grall --- drivers/video/fbdev/xen-fbfront.c | 22 +++++++++++++--------- include/xen/interface/io/fbif.h | 6 +++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index 0567d517eed3..5e1423712011 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c @@ -43,7 +43,7 @@ struct xenfb_info { int x1, y1, x2, y2; /* dirty rectangle, protected by dirty_lock */ spinlock_t dirty_lock; - int nr_pages; + int nr_gfns; int irq; struct xenfb_page *page; unsigned long *gfns; @@ -400,9 +400,11 @@ static int xenfb_probe(struct xenbus_device *dev, if (info->fb == NULL) goto error_nomem; - info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; + info->nr_gfns = XEN_PFN_UP(fb_size); + printk("%s: fb_size %u nr_gfns = %u\n", + __FUNCTION__, fb_size, info->nr_gfns); - info->gfns = vmalloc(sizeof(unsigned long) * info->nr_pages); + info->gfns = vmalloc(sizeof(unsigned long) * info->nr_gfns); if (!info->gfns) goto error_nomem; @@ -537,21 +539,23 @@ static int xenfb_remove(struct xenbus_device *dev) return 0; } -static unsigned long vmalloc_to_gfn(void *address) +static unsigned long vmalloc_to_gfn(void *v) { - return xen_page_to_gfn(vmalloc_to_page(address)); + struct page *p = vmalloc_to_page(v); + + return pfn_to_gfn(XEN_PFN_DOWN(page_to_phys(p) + offset_in_page(v))); } static void xenfb_init_shared_page(struct xenfb_info *info, struct fb_info *fb_info) { int i; - int epd = PAGE_SIZE / sizeof(info->gfns[0]); + int epd = XEN_PAGE_SIZE / sizeof(info->gfns[0]); - for (i = 0; i < info->nr_pages; i++) - info->gfns[i] = vmalloc_to_gfn(info->fb + i * PAGE_SIZE); + for (i = 0; i < info->nr_gfns; i++) + info->gfns[i] = vmalloc_to_gfn(info->fb + i * XEN_PAGE_SIZE); - for (i = 0; i * epd < info->nr_pages; i++) + for (i = 0; i * epd < info->nr_gfns; i++) info->page->pd[i] = vmalloc_to_gfn(&info->gfns[i * epd]); info->page->width = fb_info->var.xres; diff --git a/include/xen/interface/io/fbif.h b/include/xen/interface/io/fbif.h index 974a51ed9165..7b2c7d520d9b 100644 --- a/include/xen/interface/io/fbif.h +++ b/include/xen/interface/io/fbif.h @@ -118,9 +118,9 @@ struct xenfb_page { /* * Framebuffer page directory * - * Each directory page holds PAGE_SIZE / sizeof(*pd) - * framebuffer pages, and can thus map up to PAGE_SIZE * - * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and + * Each directory page holds XEN_PAGE_SIZE / sizeof(*pd) + * framebuffer pages, and can thus map up to XEN_PAGE_SIZE * + * XEN_PAGE_SIZE / sizeof(*pd) bytes. With XEN_PAGE_SIZE == 4096 and * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 * Megs 64 bit. 256 directories give enough room for a 512 * Meg framebuffer with a max resolution of 12,800x10,240. -- 2.39.5