Blame view
drivers/video/xen-fbfront.c
17.3 KB
4ee36dc08 xen pvfb: Para-vi... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* * Xen para-virtual frame buffer device * * Copyright (C) 2005-2006 Anthony Liguori <aliguori@us.ibm.com> * Copyright (C) 2006-2008 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> * * Based on linux/drivers/video/q40fb.c * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. */ /* * TODO: * * Switch to grant tables when they become capable of dealing with the * frame buffer. */ |
9e124fe16 xen: Enable conso... |
20 |
#include <linux/console.h> |
4ee36dc08 xen pvfb: Para-vi... |
21 22 23 24 |
#include <linux/kernel.h> #include <linux/errno.h> #include <linux/fb.h> #include <linux/module.h> |
5a0e3ad6a include cleanup: ... |
25 |
#include <linux/slab.h> |
4ee36dc08 xen pvfb: Para-vi... |
26 27 |
#include <linux/vmalloc.h> #include <linux/mm.h> |
1ccbf5344 xen: move Xen-tes... |
28 |
|
4ee36dc08 xen pvfb: Para-vi... |
29 |
#include <asm/xen/hypervisor.h> |
1ccbf5344 xen: move Xen-tes... |
30 31 |
#include <xen/xen.h> |
4ee36dc08 xen pvfb: Para-vi... |
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include <xen/events.h> #include <xen/page.h> #include <xen/interface/io/fbif.h> #include <xen/interface/io/protocols.h> #include <xen/xenbus.h> struct xenfb_info { unsigned char *fb; struct fb_info *fb_info; int x1, y1, x2, y2; /* dirty rectangle, protected by dirty_lock */ spinlock_t dirty_lock; int nr_pages; int irq; struct xenfb_page *page; unsigned long *mfns; int update_wanted; /* XENFB_TYPE_UPDATE wanted */ |
e4dcff1f6 xen pvfb: Dynamic... |
49 50 51 52 |
int feature_resize; /* XENFB_TYPE_RESIZE ok */ struct xenfb_resize resize; /* protected by resize_lock */ int resize_dpy; /* ditto */ spinlock_t resize_lock; |
4ee36dc08 xen pvfb: Para-vi... |
53 54 55 |
struct xenbus_device *xbdev; }; |
e4dcff1f6 xen pvfb: Dynamic... |
56 57 58 59 60 61 62 |
#define XENFB_DEFAULT_FB_LEN (XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8) enum { KPARAM_MEM, KPARAM_WIDTH, KPARAM_HEIGHT, KPARAM_CNT }; static int video[KPARAM_CNT] = { 2, XENFB_WIDTH, XENFB_HEIGHT }; module_param_array(video, int, NULL, 0); MODULE_PARM_DESC(video, "Video memory size in MB, width, height in pixels (default 2,800,600)"); |
4ee36dc08 xen pvfb: Para-vi... |
63 |
|
9e124fe16 xen: Enable conso... |
64 |
static void xenfb_make_preferred_console(void); |
4ee36dc08 xen pvfb: Para-vi... |
65 |
static int xenfb_remove(struct xenbus_device *); |
e4dcff1f6 xen pvfb: Dynamic... |
66 |
static void xenfb_init_shared_page(struct xenfb_info *, struct fb_info *); |
4ee36dc08 xen pvfb: Para-vi... |
67 68 |
static int xenfb_connect_backend(struct xenbus_device *, struct xenfb_info *); static void xenfb_disconnect_backend(struct xenfb_info *); |
e4dcff1f6 xen pvfb: Dynamic... |
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
static void xenfb_send_event(struct xenfb_info *info, union xenfb_out_event *event) { u32 prod; prod = info->page->out_prod; /* caller ensures !xenfb_queue_full() */ mb(); /* ensure ring space available */ XENFB_OUT_RING_REF(info->page, prod) = *event; wmb(); /* ensure ring contents visible */ info->page->out_prod = prod + 1; notify_remote_via_irq(info->irq); } |
4ee36dc08 xen pvfb: Para-vi... |
83 84 85 86 |
static void xenfb_do_update(struct xenfb_info *info, int x, int y, int w, int h) { union xenfb_out_event event; |
4ee36dc08 xen pvfb: Para-vi... |
87 |
|
f4ad1ebd7 xen pvfb: Zero un... |
88 |
memset(&event, 0, sizeof(event)); |
4ee36dc08 xen pvfb: Para-vi... |
89 90 91 92 93 |
event.type = XENFB_TYPE_UPDATE; event.update.x = x; event.update.y = y; event.update.width = w; event.update.height = h; |
4ee36dc08 xen pvfb: Para-vi... |
94 |
/* caller ensures !xenfb_queue_full() */ |
e4dcff1f6 xen pvfb: Dynamic... |
95 96 |
xenfb_send_event(info, &event); } |
4ee36dc08 xen pvfb: Para-vi... |
97 |
|
e4dcff1f6 xen pvfb: Dynamic... |
98 99 100 101 102 103 104 105 106 |
static void xenfb_do_resize(struct xenfb_info *info) { union xenfb_out_event event; memset(&event, 0, sizeof(event)); event.resize = info->resize; /* caller ensures !xenfb_queue_full() */ xenfb_send_event(info, &event); |
4ee36dc08 xen pvfb: Para-vi... |
107 108 109 110 111 112 113 114 115 116 |
} static int xenfb_queue_full(struct xenfb_info *info) { u32 cons, prod; prod = info->page->out_prod; cons = info->page->out_cons; return prod - cons == XENFB_OUT_RING_LEN; } |
e4dcff1f6 xen pvfb: Dynamic... |
117 118 119 120 121 122 123 124 125 126 127 128 129 |
static void xenfb_handle_resize_dpy(struct xenfb_info *info) { unsigned long flags; spin_lock_irqsave(&info->resize_lock, flags); if (info->resize_dpy) { if (!xenfb_queue_full(info)) { info->resize_dpy = 0; xenfb_do_resize(info); } } spin_unlock_irqrestore(&info->resize_lock, flags); } |
4ee36dc08 xen pvfb: Para-vi... |
130 131 132 133 |
static void xenfb_refresh(struct xenfb_info *info, int x1, int y1, int w, int h) { unsigned long flags; |
4ee36dc08 xen pvfb: Para-vi... |
134 |
int x2 = x1 + w - 1; |
e4dcff1f6 xen pvfb: Dynamic... |
135 136 137 |
int y2 = y1 + h - 1; xenfb_handle_resize_dpy(info); |
4ee36dc08 xen pvfb: Para-vi... |
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
if (!info->update_wanted) return; spin_lock_irqsave(&info->dirty_lock, flags); /* Combine with dirty rectangle: */ if (info->y1 < y1) y1 = info->y1; if (info->y2 > y2) y2 = info->y2; if (info->x1 < x1) x1 = info->x1; if (info->x2 > x2) x2 = info->x2; if (xenfb_queue_full(info)) { /* Can't send right now, stash it in the dirty rectangle */ info->x1 = x1; info->x2 = x2; info->y1 = y1; info->y2 = y2; spin_unlock_irqrestore(&info->dirty_lock, flags); return; } /* Clear dirty rectangle: */ info->x1 = info->y1 = INT_MAX; info->x2 = info->y2 = 0; spin_unlock_irqrestore(&info->dirty_lock, flags); if (x1 <= x2 && y1 <= y2) xenfb_do_update(info, x1, y1, x2 - x1 + 1, y2 - y1 + 1); } static void xenfb_deferred_io(struct fb_info *fb_info, struct list_head *pagelist) { struct xenfb_info *info = fb_info->par; struct page *page; unsigned long beg, end; int y1, y2, miny, maxy; miny = INT_MAX; maxy = 0; list_for_each_entry(page, pagelist, lru) { beg = page->index << PAGE_SHIFT; end = beg + PAGE_SIZE - 1; y1 = beg / fb_info->fix.line_length; y2 = end / fb_info->fix.line_length; if (y2 >= fb_info->var.yres) y2 = fb_info->var.yres - 1; if (miny > y1) miny = y1; if (maxy < y2) maxy = y2; } xenfb_refresh(info, 0, miny, fb_info->var.xres, maxy - miny + 1); } static struct fb_deferred_io xenfb_defio = { .delay = HZ / 20, .deferred_io = xenfb_deferred_io, }; static int xenfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { u32 v; if (regno > info->cmap.len) return 1; #define CNVT_TOHW(val, width) ((((val)<<(width))+0x7FFF-(val))>>16) red = CNVT_TOHW(red, info->var.red.length); green = CNVT_TOHW(green, info->var.green.length); blue = CNVT_TOHW(blue, info->var.blue.length); transp = CNVT_TOHW(transp, info->var.transp.length); #undef CNVT_TOHW v = (red << info->var.red.offset) | (green << info->var.green.offset) | (blue << info->var.blue.offset); switch (info->var.bits_per_pixel) { case 16: case 24: case 32: ((u32 *)info->pseudo_palette)[regno] = v; break; } return 0; } static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) { struct xenfb_info *info = p->par; sys_fillrect(p, rect); xenfb_refresh(info, rect->dx, rect->dy, rect->width, rect->height); } static void xenfb_imageblit(struct fb_info *p, const struct fb_image *image) { struct xenfb_info *info = p->par; sys_imageblit(p, image); xenfb_refresh(info, image->dx, image->dy, image->width, image->height); } static void xenfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) { struct xenfb_info *info = p->par; sys_copyarea(p, area); xenfb_refresh(info, area->dx, area->dy, area->width, area->height); } static ssize_t xenfb_write(struct fb_info *p, const char __user *buf, size_t count, loff_t *ppos) { struct xenfb_info *info = p->par; ssize_t res; res = fb_sys_write(p, buf, count, ppos); xenfb_refresh(info, 0, 0, info->page->width, info->page->height); return res; } |
e4dcff1f6 xen pvfb: Dynamic... |
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
static int xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct xenfb_info *xenfb_info; int required_mem_len; xenfb_info = info->par; if (!xenfb_info->feature_resize) { if (var->xres == video[KPARAM_WIDTH] && var->yres == video[KPARAM_HEIGHT] && var->bits_per_pixel == xenfb_info->page->depth) { return 0; } return -EINVAL; } /* Can't resize past initial width and height */ if (var->xres > video[KPARAM_WIDTH] || var->yres > video[KPARAM_HEIGHT]) return -EINVAL; required_mem_len = var->xres * var->yres * xenfb_info->page->depth / 8; if (var->bits_per_pixel == xenfb_info->page->depth && var->xres <= info->fix.line_length / (XENFB_DEPTH / 8) && required_mem_len <= info->fix.smem_len) { var->xres_virtual = var->xres; var->yres_virtual = var->yres; return 0; } return -EINVAL; } static int xenfb_set_par(struct fb_info *info) { struct xenfb_info *xenfb_info; unsigned long flags; xenfb_info = info->par; spin_lock_irqsave(&xenfb_info->resize_lock, flags); xenfb_info->resize.type = XENFB_TYPE_RESIZE; xenfb_info->resize.width = info->var.xres; xenfb_info->resize.height = info->var.yres; xenfb_info->resize.stride = info->fix.line_length; xenfb_info->resize.depth = info->var.bits_per_pixel; xenfb_info->resize.offset = 0; xenfb_info->resize_dpy = 1; spin_unlock_irqrestore(&xenfb_info->resize_lock, flags); return 0; } |
4ee36dc08 xen pvfb: Para-vi... |
319 320 321 322 323 324 325 326 |
static struct fb_ops xenfb_fb_ops = { .owner = THIS_MODULE, .fb_read = fb_sys_read, .fb_write = xenfb_write, .fb_setcolreg = xenfb_setcolreg, .fb_fillrect = xenfb_fillrect, .fb_copyarea = xenfb_copyarea, .fb_imageblit = xenfb_imageblit, |
e4dcff1f6 xen pvfb: Dynamic... |
327 328 |
.fb_check_var = xenfb_check_var, .fb_set_par = xenfb_set_par, |
4ee36dc08 xen pvfb: Para-vi... |
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
}; static irqreturn_t xenfb_event_handler(int rq, void *dev_id) { /* * No in events recognized, simply ignore them all. * If you need to recognize some, see xen-kbdfront's * input_handler() for how to do that. */ struct xenfb_info *info = dev_id; struct xenfb_page *page = info->page; if (page->in_cons != page->in_prod) { info->page->in_cons = info->page->in_prod; notify_remote_via_irq(info->irq); } /* Flush dirty rectangle: */ xenfb_refresh(info, INT_MAX, INT_MAX, -INT_MAX, -INT_MAX); return IRQ_HANDLED; } static int __devinit xenfb_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { struct xenfb_info *info; struct fb_info *fb_info; |
e4dcff1f6 xen pvfb: Dynamic... |
357 358 |
int fb_size; int val; |
4ee36dc08 xen pvfb: Para-vi... |
359 360 361 362 363 364 365 |
int ret; info = kzalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) { xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure"); return -ENOMEM; } |
e4dcff1f6 xen pvfb: Dynamic... |
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
/* Limit kernel param videoram amount to what is in xenstore */ if (xenbus_scanf(XBT_NIL, dev->otherend, "videoram", "%d", &val) == 1) { if (val < video[KPARAM_MEM]) video[KPARAM_MEM] = val; } /* If requested res does not fit in available memory, use default */ fb_size = video[KPARAM_MEM] * 1024 * 1024; if (video[KPARAM_WIDTH] * video[KPARAM_HEIGHT] * XENFB_DEPTH / 8 > fb_size) { video[KPARAM_WIDTH] = XENFB_WIDTH; video[KPARAM_HEIGHT] = XENFB_HEIGHT; fb_size = XENFB_DEFAULT_FB_LEN; } |
1b713e005 xen: remove drive... |
381 |
dev_set_drvdata(&dev->dev, info); |
4ee36dc08 xen pvfb: Para-vi... |
382 383 384 385 |
info->xbdev = dev; info->irq = -1; info->x1 = info->y1 = INT_MAX; spin_lock_init(&info->dirty_lock); |
e4dcff1f6 xen pvfb: Dynamic... |
386 |
spin_lock_init(&info->resize_lock); |
4ee36dc08 xen pvfb: Para-vi... |
387 |
|
1b86d775d video: Convert vm... |
388 |
info->fb = vzalloc(fb_size); |
4ee36dc08 xen pvfb: Para-vi... |
389 390 |
if (info->fb == NULL) goto error_nomem; |
4ee36dc08 xen pvfb: Para-vi... |
391 |
|
e4dcff1f6 xen pvfb: Dynamic... |
392 |
info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; |
4ee36dc08 xen pvfb: Para-vi... |
393 394 395 396 397 398 399 400 401 |
info->mfns = vmalloc(sizeof(unsigned long) * info->nr_pages); if (!info->mfns) goto error_nomem; /* set up shared page */ info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); if (!info->page) goto error_nomem; |
4ee36dc08 xen pvfb: Para-vi... |
402 403 404 405 406 407 408 409 410 411 412 413 |
/* abusing framebuffer_alloc() to allocate pseudo_palette */ fb_info = framebuffer_alloc(sizeof(u32) * 256, NULL); if (fb_info == NULL) goto error_nomem; /* complete the abuse: */ fb_info->pseudo_palette = fb_info->par; fb_info->par = info; fb_info->screen_base = info->fb; fb_info->fbops = &xenfb_fb_ops; |
e4dcff1f6 xen pvfb: Dynamic... |
414 415 416 |
fb_info->var.xres_virtual = fb_info->var.xres = video[KPARAM_WIDTH]; fb_info->var.yres_virtual = fb_info->var.yres = video[KPARAM_HEIGHT]; fb_info->var.bits_per_pixel = XENFB_DEPTH; |
4ee36dc08 xen pvfb: Para-vi... |
417 418 419 420 421 422 423 424 425 426 427 |
fb_info->var.red = (struct fb_bitfield){16, 8, 0}; fb_info->var.green = (struct fb_bitfield){8, 8, 0}; fb_info->var.blue = (struct fb_bitfield){0, 8, 0}; fb_info->var.activate = FB_ACTIVATE_NOW; fb_info->var.height = -1; fb_info->var.width = -1; fb_info->var.vmode = FB_VMODE_NONINTERLACED; fb_info->fix.visual = FB_VISUAL_TRUECOLOR; |
e4dcff1f6 xen pvfb: Dynamic... |
428 |
fb_info->fix.line_length = fb_info->var.xres * XENFB_DEPTH / 8; |
4ee36dc08 xen pvfb: Para-vi... |
429 |
fb_info->fix.smem_start = 0; |
e4dcff1f6 xen pvfb: Dynamic... |
430 |
fb_info->fix.smem_len = fb_size; |
4ee36dc08 xen pvfb: Para-vi... |
431 432 433 |
strcpy(fb_info->fix.id, "xen"); fb_info->fix.type = FB_TYPE_PACKED_PIXELS; fb_info->fix.accel = FB_ACCEL_NONE; |
df11303c9 xen pvfb: Inhibit... |
434 |
fb_info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB; |
4ee36dc08 xen pvfb: Para-vi... |
435 436 437 438 439 440 441 442 443 444 |
ret = fb_alloc_cmap(&fb_info->cmap, 256, 0); if (ret < 0) { framebuffer_release(fb_info); xenbus_dev_fatal(dev, ret, "fb_alloc_cmap"); goto error; } fb_info->fbdefio = &xenfb_defio; fb_deferred_io_init(fb_info); |
e4dcff1f6 xen pvfb: Dynamic... |
445 |
xenfb_init_shared_page(info, fb_info); |
0a80fb102 xenfb: connect to... |
446 447 448 |
ret = xenfb_connect_backend(dev, info); if (ret < 0) goto error; |
4ee36dc08 xen pvfb: Para-vi... |
449 450 451 452 453 454 455 456 457 |
ret = register_framebuffer(fb_info); if (ret) { fb_deferred_io_cleanup(fb_info); fb_dealloc_cmap(&fb_info->cmap); framebuffer_release(fb_info); xenbus_dev_fatal(dev, ret, "register_framebuffer"); goto error; } info->fb_info = fb_info; |
9e124fe16 xen: Enable conso... |
458 |
xenfb_make_preferred_console(); |
4ee36dc08 xen pvfb: Para-vi... |
459 460 461 462 463 464 465 466 467 |
return 0; error_nomem: ret = -ENOMEM; xenbus_dev_fatal(dev, ret, "allocating device memory"); error: xenfb_remove(dev); return ret; } |
9e124fe16 xen: Enable conso... |
468 469 470 471 472 473 474 |
static __devinit void xenfb_make_preferred_console(void) { struct console *c; if (console_set_on_cmdline) return; |
ac751efa6 console: rename a... |
475 |
console_lock(); |
281e66057 VIDEO: xen-fb, sw... |
476 |
for_each_console(c) { |
9e124fe16 xen: Enable conso... |
477 478 479 |
if (!strcmp(c->name, "tty") && c->index == 0) break; } |
ac751efa6 console: rename a... |
480 |
console_unlock(); |
9e124fe16 xen: Enable conso... |
481 482 483 484 485 486 487 |
if (c) { unregister_console(c); c->flags |= CON_CONSDEV; c->flags &= ~CON_PRINTBUFFER; /* don't print again */ register_console(c); } } |
4ee36dc08 xen pvfb: Para-vi... |
488 489 |
static int xenfb_resume(struct xenbus_device *dev) { |
1b713e005 xen: remove drive... |
490 |
struct xenfb_info *info = dev_get_drvdata(&dev->dev); |
4ee36dc08 xen pvfb: Para-vi... |
491 492 |
xenfb_disconnect_backend(info); |
e4dcff1f6 xen pvfb: Dynamic... |
493 |
xenfb_init_shared_page(info, info->fb_info); |
4ee36dc08 xen pvfb: Para-vi... |
494 495 496 497 498 |
return xenfb_connect_backend(dev, info); } static int xenfb_remove(struct xenbus_device *dev) { |
1b713e005 xen: remove drive... |
499 |
struct xenfb_info *info = dev_get_drvdata(&dev->dev); |
4ee36dc08 xen pvfb: Para-vi... |
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
xenfb_disconnect_backend(info); if (info->fb_info) { fb_deferred_io_cleanup(info->fb_info); unregister_framebuffer(info->fb_info); fb_dealloc_cmap(&info->fb_info->cmap); framebuffer_release(info->fb_info); } free_page((unsigned long)info->page); vfree(info->mfns); vfree(info->fb); kfree(info); return 0; } static unsigned long vmalloc_to_mfn(void *address) { return pfn_to_mfn(vmalloc_to_pfn(address)); } |
e4dcff1f6 xen pvfb: Dynamic... |
520 521 |
static void xenfb_init_shared_page(struct xenfb_info *info, struct fb_info *fb_info) |
4ee36dc08 xen pvfb: Para-vi... |
522 523 |
{ int i; |
e4dcff1f6 xen pvfb: Dynamic... |
524 |
int epd = PAGE_SIZE / sizeof(info->mfns[0]); |
4ee36dc08 xen pvfb: Para-vi... |
525 526 527 |
for (i = 0; i < info->nr_pages; i++) info->mfns[i] = vmalloc_to_mfn(info->fb + i * PAGE_SIZE); |
e4dcff1f6 xen pvfb: Dynamic... |
528 529 530 531 532 533 534 535 |
for (i = 0; i * epd < info->nr_pages; i++) info->page->pd[i] = vmalloc_to_mfn(&info->mfns[i * epd]); info->page->width = fb_info->var.xres; info->page->height = fb_info->var.yres; info->page->depth = fb_info->var.bits_per_pixel; info->page->line_length = fb_info->fix.line_length; info->page->mem_length = fb_info->fix.smem_len; |
4ee36dc08 xen pvfb: Para-vi... |
536 537 538 539 540 541 542 |
info->page->in_cons = info->page->in_prod = 0; info->page->out_cons = info->page->out_prod = 0; } static int xenfb_connect_backend(struct xenbus_device *dev, struct xenfb_info *info) { |
fc550e959 xen/fb: fix poten... |
543 |
int ret, evtchn, irq; |
4ee36dc08 xen pvfb: Para-vi... |
544 545 546 547 548 |
struct xenbus_transaction xbt; ret = xenbus_alloc_evtchn(dev, &evtchn); if (ret) return ret; |
fc550e959 xen/fb: fix poten... |
549 |
irq = bind_evtchn_to_irqhandler(evtchn, xenfb_event_handler, |
4ee36dc08 xen pvfb: Para-vi... |
550 |
0, dev->devicetype, info); |
fc550e959 xen/fb: fix poten... |
551 |
if (irq < 0) { |
4ee36dc08 xen pvfb: Para-vi... |
552 553 |
xenbus_free_evtchn(dev, evtchn); xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler"); |
fc550e959 xen/fb: fix poten... |
554 |
return irq; |
4ee36dc08 xen pvfb: Para-vi... |
555 |
} |
4ee36dc08 xen pvfb: Para-vi... |
556 557 558 559 |
again: ret = xenbus_transaction_start(&xbt); if (ret) { xenbus_dev_fatal(dev, ret, "starting transaction"); |
fc550e959 xen/fb: fix poten... |
560 |
goto unbind_irq; |
4ee36dc08 xen pvfb: Para-vi... |
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
} ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", virt_to_mfn(info->page)); if (ret) goto error_xenbus; ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u", evtchn); if (ret) goto error_xenbus; ret = xenbus_printf(xbt, dev->nodename, "protocol", "%s", XEN_IO_PROTO_ABI_NATIVE); if (ret) goto error_xenbus; ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1"); if (ret) goto error_xenbus; ret = xenbus_transaction_end(xbt, 0); if (ret) { if (ret == -EAGAIN) goto again; xenbus_dev_fatal(dev, ret, "completing transaction"); |
fc550e959 xen/fb: fix poten... |
582 |
goto unbind_irq; |
4ee36dc08 xen pvfb: Para-vi... |
583 584 585 |
} xenbus_switch_state(dev, XenbusStateInitialised); |
fc550e959 xen/fb: fix poten... |
586 |
info->irq = irq; |
4ee36dc08 xen pvfb: Para-vi... |
587 588 589 590 591 |
return 0; error_xenbus: xenbus_transaction_end(xbt, 1); xenbus_dev_fatal(dev, ret, "writing xenstore"); |
fc550e959 xen/fb: fix poten... |
592 593 |
unbind_irq: unbind_from_irqhandler(irq, info); |
4ee36dc08 xen pvfb: Para-vi... |
594 595 596 597 598 |
return ret; } static void xenfb_disconnect_backend(struct xenfb_info *info) { |
731f3ab66 xen/fb: fix xenfb... |
599 600 |
/* Prevent xenfb refresh */ info->update_wanted = 0; |
4ee36dc08 xen pvfb: Para-vi... |
601 602 603 604 605 606 607 608 |
if (info->irq >= 0) unbind_from_irqhandler(info->irq, info); info->irq = -1; } static void xenfb_backend_changed(struct xenbus_device *dev, enum xenbus_state backend_state) { |
1b713e005 xen: remove drive... |
609 |
struct xenfb_info *info = dev_get_drvdata(&dev->dev); |
4ee36dc08 xen pvfb: Para-vi... |
610 611 612 613 614 |
int val; switch (backend_state) { case XenbusStateInitialising: case XenbusStateInitialised: |
b78c95125 xenbus: prevent w... |
615 616 |
case XenbusStateReconfiguring: case XenbusStateReconfigured: |
4ee36dc08 xen pvfb: Para-vi... |
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
case XenbusStateUnknown: case XenbusStateClosed: break; case XenbusStateInitWait: InitWait: xenbus_switch_state(dev, XenbusStateConnected); break; case XenbusStateConnected: /* * Work around xenbus race condition: If backend goes * through InitWait to Connected fast enough, we can * get Connected twice here. */ if (dev->state != XenbusStateConnected) goto InitWait; /* no InitWait seen yet, fudge it */ if (xenbus_scanf(XBT_NIL, info->xbdev->otherend, "request-update", "%d", &val) < 0) val = 0; if (val) info->update_wanted = 1; |
e4dcff1f6 xen pvfb: Dynamic... |
640 641 642 643 644 |
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-resize", "%d", &val) < 0) val = 0; info->feature_resize = val; |
4ee36dc08 xen pvfb: Para-vi... |
645 646 647 648 649 650 651 |
break; case XenbusStateClosing: xenbus_frontend_closed(dev); break; } } |
73db144b5 Xen: consolidate ... |
652 |
static const struct xenbus_device_id xenfb_ids[] = { |
4ee36dc08 xen pvfb: Para-vi... |
653 654 655 |
{ "vfb" }, { "" } }; |
73db144b5 Xen: consolidate ... |
656 |
static DEFINE_XENBUS_DRIVER(xenfb, , |
4ee36dc08 xen pvfb: Para-vi... |
657 658 659 660 |
.probe = xenfb_probe, .remove = xenfb_remove, .resume = xenfb_resume, .otherend_changed = xenfb_backend_changed, |
73db144b5 Xen: consolidate ... |
661 |
); |
4ee36dc08 xen pvfb: Para-vi... |
662 663 664 |
static int __init xenfb_init(void) { |
bee6ab53e x86: early PV on ... |
665 |
if (!xen_pv_domain()) |
4ee36dc08 xen pvfb: Para-vi... |
666 667 668 |
return -ENODEV; /* Nothing to do if running in dom0. */ |
6e833587e xen: clean up dom... |
669 |
if (xen_initial_domain()) |
4ee36dc08 xen pvfb: Para-vi... |
670 |
return -ENODEV; |
ffb78a261 get xenbus_driver... |
671 |
return xenbus_register_frontend(&xenfb_driver); |
4ee36dc08 xen pvfb: Para-vi... |
672 673 674 675 |
} static void __exit xenfb_cleanup(void) { |
ffb78a261 get xenbus_driver... |
676 |
xenbus_unregister_driver(&xenfb_driver); |
4ee36dc08 xen pvfb: Para-vi... |
677 678 679 680 |
} module_init(xenfb_init); module_exit(xenfb_cleanup); |
1e892c959 xen pvfb: Module ... |
681 |
MODULE_DESCRIPTION("Xen virtual framebuffer device frontend"); |
4ee36dc08 xen pvfb: Para-vi... |
682 |
MODULE_LICENSE("GPL"); |
1e892c959 xen pvfb: Module ... |
683 |
MODULE_ALIAS("xen:vfb"); |