diff options
author | Dave Airlie <airlied@redhat.com> | 2013-07-04 20:55:33 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-07-04 20:55:33 -0400 |
commit | 7c6ca3040e9ac174e6d2189811da603e9c19a150 (patch) | |
tree | 4cf36c62b7a7b6c6a2ad66e4d79d3f5912a3438b | |
parent | 69163ea82732894e8c1e17df4010372ed078efdd (diff) | |
parent | 5ff91e442652ec33a648c3b9ae5025faaff1e813 (diff) |
Merge branch 'qxl-next' of git://people.freedesktop.org/~airlied/linux into drm-next
Adds 3 features that UMS had to the KMS driver.
dynamic resizing - resizing remote-viewer makes guest resize
multiple crtcs - remote-viewer can access > 1 crtc.
suspend/resume/hibernate: guests can do suspend/resume/hibernate now.
* 'qxl-next' of git://people.freedesktop.org/~airlied/linux:
qxl: use drm helper hotplug support
qxl: add suspend/resume/hibernate support.
qxl: add fb and ttm entry points for use by suspend/resume.
qxl: add ring prep code for s/r
qxl: prepare memslot code for suspend/resume
qxl: split monitors_config object creation out.
drm/qxl: set time on drawables from userspace
drm/qxl: add support for > 1 output
drm/qxl: make dynamic resizing work properly.
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_cmd.c | 17 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_display.c | 229 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_drv.c | 138 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_drv.h | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_fb.c | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_ioctl.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_kms.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_object.c | 10 |
8 files changed, 326 insertions, 128 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c index f86771481317..93c2f2cceb51 100644 --- a/drivers/gpu/drm/qxl/qxl_cmd.c +++ b/drivers/gpu/drm/qxl/qxl_cmd.c | |||
@@ -49,6 +49,11 @@ void qxl_ring_free(struct qxl_ring *ring) | |||
49 | kfree(ring); | 49 | kfree(ring); |
50 | } | 50 | } |
51 | 51 | ||
52 | void qxl_ring_init_hdr(struct qxl_ring *ring) | ||
53 | { | ||
54 | ring->ring->header.notify_on_prod = ring->n_elements; | ||
55 | } | ||
56 | |||
52 | struct qxl_ring * | 57 | struct qxl_ring * |
53 | qxl_ring_create(struct qxl_ring_header *header, | 58 | qxl_ring_create(struct qxl_ring_header *header, |
54 | int element_size, | 59 | int element_size, |
@@ -69,7 +74,7 @@ qxl_ring_create(struct qxl_ring_header *header, | |||
69 | ring->prod_notify = prod_notify; | 74 | ring->prod_notify = prod_notify; |
70 | ring->push_event = push_event; | 75 | ring->push_event = push_event; |
71 | if (set_prod_notify) | 76 | if (set_prod_notify) |
72 | header->notify_on_prod = ring->n_elements; | 77 | qxl_ring_init_hdr(ring); |
73 | spin_lock_init(&ring->lock); | 78 | spin_lock_init(&ring->lock); |
74 | return ring; | 79 | return ring; |
75 | } | 80 | } |
@@ -87,7 +92,7 @@ static int qxl_check_header(struct qxl_ring *ring) | |||
87 | return ret; | 92 | return ret; |
88 | } | 93 | } |
89 | 94 | ||
90 | static int qxl_check_idle(struct qxl_ring *ring) | 95 | int qxl_check_idle(struct qxl_ring *ring) |
91 | { | 96 | { |
92 | int ret; | 97 | int ret; |
93 | struct qxl_ring_header *header = &(ring->ring->header); | 98 | struct qxl_ring_header *header = &(ring->ring->header); |
@@ -375,8 +380,8 @@ void qxl_io_destroy_primary(struct qxl_device *qdev) | |||
375 | wait_for_io_cmd(qdev, 0, QXL_IO_DESTROY_PRIMARY_ASYNC); | 380 | wait_for_io_cmd(qdev, 0, QXL_IO_DESTROY_PRIMARY_ASYNC); |
376 | } | 381 | } |
377 | 382 | ||
378 | void qxl_io_create_primary(struct qxl_device *qdev, unsigned width, | 383 | void qxl_io_create_primary(struct qxl_device *qdev, |
379 | unsigned height, unsigned offset, struct qxl_bo *bo) | 384 | unsigned offset, struct qxl_bo *bo) |
380 | { | 385 | { |
381 | struct qxl_surface_create *create; | 386 | struct qxl_surface_create *create; |
382 | 387 | ||
@@ -384,8 +389,8 @@ void qxl_io_create_primary(struct qxl_device *qdev, unsigned width, | |||
384 | qdev->ram_header); | 389 | qdev->ram_header); |
385 | create = &qdev->ram_header->create_surface; | 390 | create = &qdev->ram_header->create_surface; |
386 | create->format = bo->surf.format; | 391 | create->format = bo->surf.format; |
387 | create->width = width; | 392 | create->width = bo->surf.width; |
388 | create->height = height; | 393 | create->height = bo->surf.height; |
389 | create->stride = bo->surf.stride; | 394 | create->stride = bo->surf.stride; |
390 | create->mem = qxl_bo_physical_address(qdev, bo, offset); | 395 | create->mem = qxl_bo_physical_address(qdev, bo, offset); |
391 | 396 | ||
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c index 686a937675cb..f76f5dd7bfc4 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c | |||
@@ -30,53 +30,9 @@ | |||
30 | #include "qxl_object.h" | 30 | #include "qxl_object.h" |
31 | #include "drm_crtc_helper.h" | 31 | #include "drm_crtc_helper.h" |
32 | 32 | ||
33 | static void qxl_crtc_set_to_mode(struct qxl_device *qdev, | 33 | static bool qxl_head_enabled(struct qxl_head *head) |
34 | struct drm_connector *connector, | ||
35 | struct qxl_head *head) | ||
36 | { | 34 | { |
37 | struct drm_device *dev = connector->dev; | 35 | return head->width && head->height; |
38 | struct drm_display_mode *mode, *t; | ||
39 | int width = head->width; | ||
40 | int height = head->height; | ||
41 | |||
42 | if (width < 320 || height < 240) { | ||
43 | qxl_io_log(qdev, "%s: bad head: %dx%d", width, height); | ||
44 | width = 1024; | ||
45 | height = 768; | ||
46 | } | ||
47 | if (width * height * 4 > 16*1024*1024) { | ||
48 | width = 1024; | ||
49 | height = 768; | ||
50 | } | ||
51 | /* TODO: go over regular modes and removed preferred? */ | ||
52 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) | ||
53 | drm_mode_remove(connector, mode); | ||
54 | mode = drm_cvt_mode(dev, width, height, 60, false, false, false); | ||
55 | mode->type |= DRM_MODE_TYPE_PREFERRED; | ||
56 | mode->status = MODE_OK; | ||
57 | drm_mode_probed_add(connector, mode); | ||
58 | qxl_io_log(qdev, "%s: %d x %d\n", __func__, width, height); | ||
59 | } | ||
60 | |||
61 | void qxl_crtc_set_from_monitors_config(struct qxl_device *qdev) | ||
62 | { | ||
63 | struct drm_connector *connector; | ||
64 | int i; | ||
65 | struct drm_device *dev = qdev->ddev; | ||
66 | |||
67 | i = 0; | ||
68 | qxl_io_log(qdev, "%s: %d, %d\n", __func__, | ||
69 | dev->mode_config.num_connector, | ||
70 | qdev->monitors_config->count); | ||
71 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
72 | if (i > qdev->monitors_config->count) { | ||
73 | /* crtc will be reported as disabled */ | ||
74 | continue; | ||
75 | } | ||
76 | qxl_crtc_set_to_mode(qdev, connector, | ||
77 | &qdev->monitors_config->heads[i]); | ||
78 | ++i; | ||
79 | } | ||
80 | } | 36 | } |
81 | 37 | ||
82 | void qxl_alloc_client_monitors_config(struct qxl_device *qdev, unsigned count) | 38 | void qxl_alloc_client_monitors_config(struct qxl_device *qdev, unsigned count) |
@@ -106,7 +62,6 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
106 | int num_monitors; | 62 | int num_monitors; |
107 | uint32_t crc; | 63 | uint32_t crc; |
108 | 64 | ||
109 | BUG_ON(!qdev->monitors_config); | ||
110 | num_monitors = qdev->rom->client_monitors_config.count; | 65 | num_monitors = qdev->rom->client_monitors_config.count; |
111 | crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config, | 66 | crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config, |
112 | sizeof(qdev->rom->client_monitors_config)); | 67 | sizeof(qdev->rom->client_monitors_config)); |
@@ -117,8 +72,8 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
117 | return 1; | 72 | return 1; |
118 | } | 73 | } |
119 | if (num_monitors > qdev->monitors_config->max_allowed) { | 74 | if (num_monitors > qdev->monitors_config->max_allowed) { |
120 | DRM_INFO("client monitors list will be truncated: %d < %d\n", | 75 | DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n", |
121 | qdev->monitors_config->max_allowed, num_monitors); | 76 | qdev->monitors_config->max_allowed, num_monitors); |
122 | num_monitors = qdev->monitors_config->max_allowed; | 77 | num_monitors = qdev->monitors_config->max_allowed; |
123 | } else { | 78 | } else { |
124 | num_monitors = qdev->rom->client_monitors_config.count; | 79 | num_monitors = qdev->rom->client_monitors_config.count; |
@@ -132,18 +87,15 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
132 | &qdev->rom->client_monitors_config.heads[i]; | 87 | &qdev->rom->client_monitors_config.heads[i]; |
133 | struct qxl_head *client_head = | 88 | struct qxl_head *client_head = |
134 | &qdev->client_monitors_config->heads[i]; | 89 | &qdev->client_monitors_config->heads[i]; |
135 | struct qxl_head *head = &qdev->monitors_config->heads[i]; | 90 | client_head->x = c_rect->left; |
136 | client_head->x = head->x = c_rect->left; | 91 | client_head->y = c_rect->top; |
137 | client_head->y = head->y = c_rect->top; | 92 | client_head->width = c_rect->right - c_rect->left; |
138 | client_head->width = head->width = | 93 | client_head->height = c_rect->bottom - c_rect->top; |
139 | c_rect->right - c_rect->left; | 94 | client_head->surface_id = 0; |
140 | client_head->height = head->height = | 95 | client_head->id = i; |
141 | c_rect->bottom - c_rect->top; | 96 | client_head->flags = 0; |
142 | client_head->surface_id = head->surface_id = 0; | 97 | DRM_DEBUG_KMS("read %dx%d+%d+%d\n", client_head->width, client_head->height, |
143 | client_head->id = head->id = i; | 98 | client_head->x, client_head->y); |
144 | client_head->flags = head->flags = 0; | ||
145 | QXL_DEBUG(qdev, "read %dx%d+%d+%d\n", head->width, head->height, | ||
146 | head->x, head->y); | ||
147 | } | 99 | } |
148 | return 0; | 100 | return 0; |
149 | } | 101 | } |
@@ -155,10 +107,7 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) | |||
155 | qxl_io_log(qdev, "failed crc check for client_monitors_config," | 107 | qxl_io_log(qdev, "failed crc check for client_monitors_config," |
156 | " retrying\n"); | 108 | " retrying\n"); |
157 | } | 109 | } |
158 | qxl_crtc_set_from_monitors_config(qdev); | 110 | drm_helper_hpd_irq_event(qdev->ddev); |
159 | /* fire off a uevent and let userspace tell us what to do */ | ||
160 | qxl_io_log(qdev, "calling drm_sysfs_hotplug_event\n"); | ||
161 | drm_sysfs_hotplug_event(qdev->ddev); | ||
162 | } | 111 | } |
163 | 112 | ||
164 | static int qxl_add_monitors_config_modes(struct drm_connector *connector) | 113 | static int qxl_add_monitors_config_modes(struct drm_connector *connector) |
@@ -170,9 +119,9 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector) | |||
170 | struct drm_display_mode *mode = NULL; | 119 | struct drm_display_mode *mode = NULL; |
171 | struct qxl_head *head; | 120 | struct qxl_head *head; |
172 | 121 | ||
173 | if (!qdev->monitors_config) | 122 | if (!qdev->client_monitors_config) |
174 | return 0; | 123 | return 0; |
175 | head = &qdev->monitors_config->heads[h]; | 124 | head = &qdev->client_monitors_config->heads[h]; |
176 | 125 | ||
177 | mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false, | 126 | mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false, |
178 | false); | 127 | false); |
@@ -499,7 +448,7 @@ qxl_send_monitors_config(struct qxl_device *qdev) | |||
499 | for (i = 0 ; i < qdev->monitors_config->count ; ++i) { | 448 | for (i = 0 ; i < qdev->monitors_config->count ; ++i) { |
500 | struct qxl_head *head = &qdev->monitors_config->heads[i]; | 449 | struct qxl_head *head = &qdev->monitors_config->heads[i]; |
501 | 450 | ||
502 | if (head->y > 8192 || head->y < head->x || | 451 | if (head->y > 8192 || head->x > 8192 || |
503 | head->width > 8192 || head->height > 8192) { | 452 | head->width > 8192 || head->height > 8192) { |
504 | DRM_ERROR("head %d wrong: %dx%d+%d+%d\n", | 453 | DRM_ERROR("head %d wrong: %dx%d+%d+%d\n", |
505 | i, head->width, head->height, | 454 | i, head->width, head->height, |
@@ -510,16 +459,19 @@ qxl_send_monitors_config(struct qxl_device *qdev) | |||
510 | qxl_io_monitors_config(qdev); | 459 | qxl_io_monitors_config(qdev); |
511 | } | 460 | } |
512 | 461 | ||
513 | static void qxl_monitors_config_set_single(struct qxl_device *qdev, | 462 | static void qxl_monitors_config_set(struct qxl_device *qdev, |
514 | unsigned x, unsigned y, | 463 | int index, |
515 | unsigned width, unsigned height) | 464 | unsigned x, unsigned y, |
465 | unsigned width, unsigned height, | ||
466 | unsigned surf_id) | ||
516 | { | 467 | { |
517 | DRM_DEBUG("%dx%d+%d+%d\n", width, height, x, y); | 468 | DRM_DEBUG_KMS("%d:%dx%d+%d+%d\n", index, width, height, x, y); |
518 | qdev->monitors_config->count = 1; | 469 | qdev->monitors_config->heads[index].x = x; |
519 | qdev->monitors_config->heads[0].x = x; | 470 | qdev->monitors_config->heads[index].y = y; |
520 | qdev->monitors_config->heads[0].y = y; | 471 | qdev->monitors_config->heads[index].width = width; |
521 | qdev->monitors_config->heads[0].width = width; | 472 | qdev->monitors_config->heads[index].height = height; |
522 | qdev->monitors_config->heads[0].height = height; | 473 | qdev->monitors_config->heads[index].surface_id = surf_id; |
474 | |||
523 | } | 475 | } |
524 | 476 | ||
525 | static int qxl_crtc_mode_set(struct drm_crtc *crtc, | 477 | static int qxl_crtc_mode_set(struct drm_crtc *crtc, |
@@ -533,10 +485,11 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
533 | struct qxl_mode *m = (void *)mode->private; | 485 | struct qxl_mode *m = (void *)mode->private; |
534 | struct qxl_framebuffer *qfb; | 486 | struct qxl_framebuffer *qfb; |
535 | struct qxl_bo *bo, *old_bo = NULL; | 487 | struct qxl_bo *bo, *old_bo = NULL; |
488 | struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); | ||
536 | uint32_t width, height, base_offset; | 489 | uint32_t width, height, base_offset; |
537 | bool recreate_primary = false; | 490 | bool recreate_primary = false; |
538 | int ret; | 491 | int ret; |
539 | 492 | int surf_id; | |
540 | if (!crtc->fb) { | 493 | if (!crtc->fb) { |
541 | DRM_DEBUG_KMS("No FB bound\n"); | 494 | DRM_DEBUG_KMS("No FB bound\n"); |
542 | return 0; | 495 | return 0; |
@@ -560,7 +513,8 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
560 | adjusted_mode->hdisplay, | 513 | adjusted_mode->hdisplay, |
561 | adjusted_mode->vdisplay); | 514 | adjusted_mode->vdisplay); |
562 | 515 | ||
563 | recreate_primary = true; | 516 | if (qcrtc->index == 0) |
517 | recreate_primary = true; | ||
564 | 518 | ||
565 | width = mode->hdisplay; | 519 | width = mode->hdisplay; |
566 | height = mode->vdisplay; | 520 | height = mode->vdisplay; |
@@ -581,8 +535,11 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
581 | "recreate primary: %dx%d (was %dx%d,%d,%d)\n", | 535 | "recreate primary: %dx%d (was %dx%d,%d,%d)\n", |
582 | width, height, bo->surf.width, | 536 | width, height, bo->surf.width, |
583 | bo->surf.height, bo->surf.stride, bo->surf.format); | 537 | bo->surf.height, bo->surf.stride, bo->surf.format); |
584 | qxl_io_create_primary(qdev, width, height, base_offset, bo); | 538 | qxl_io_create_primary(qdev, base_offset, bo); |
585 | bo->is_primary = true; | 539 | bo->is_primary = true; |
540 | surf_id = 0; | ||
541 | } else { | ||
542 | surf_id = bo->surface_id; | ||
586 | } | 543 | } |
587 | 544 | ||
588 | if (old_bo && old_bo != bo) { | 545 | if (old_bo && old_bo != bo) { |
@@ -592,11 +549,9 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
592 | qxl_bo_unreserve(old_bo); | 549 | qxl_bo_unreserve(old_bo); |
593 | } | 550 | } |
594 | 551 | ||
595 | if (qdev->monitors_config->count == 0) { | 552 | qxl_monitors_config_set(qdev, qcrtc->index, x, y, |
596 | qxl_monitors_config_set_single(qdev, x, y, | 553 | mode->hdisplay, |
597 | mode->hdisplay, | 554 | mode->vdisplay, surf_id); |
598 | mode->vdisplay); | ||
599 | } | ||
600 | return 0; | 555 | return 0; |
601 | } | 556 | } |
602 | 557 | ||
@@ -612,15 +567,36 @@ static void qxl_crtc_commit(struct drm_crtc *crtc) | |||
612 | DRM_DEBUG("\n"); | 567 | DRM_DEBUG("\n"); |
613 | } | 568 | } |
614 | 569 | ||
570 | static void qxl_crtc_disable(struct drm_crtc *crtc) | ||
571 | { | ||
572 | struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); | ||
573 | struct drm_device *dev = crtc->dev; | ||
574 | struct qxl_device *qdev = dev->dev_private; | ||
575 | if (crtc->fb) { | ||
576 | struct qxl_framebuffer *qfb = to_qxl_framebuffer(crtc->fb); | ||
577 | struct qxl_bo *bo = gem_to_qxl_bo(qfb->obj); | ||
578 | int ret; | ||
579 | ret = qxl_bo_reserve(bo, false); | ||
580 | qxl_bo_unpin(bo); | ||
581 | qxl_bo_unreserve(bo); | ||
582 | crtc->fb = NULL; | ||
583 | } | ||
584 | |||
585 | qxl_monitors_config_set(qdev, qcrtc->index, 0, 0, 0, 0, 0); | ||
586 | |||
587 | qxl_send_monitors_config(qdev); | ||
588 | } | ||
589 | |||
615 | static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = { | 590 | static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = { |
616 | .dpms = qxl_crtc_dpms, | 591 | .dpms = qxl_crtc_dpms, |
592 | .disable = qxl_crtc_disable, | ||
617 | .mode_fixup = qxl_crtc_mode_fixup, | 593 | .mode_fixup = qxl_crtc_mode_fixup, |
618 | .mode_set = qxl_crtc_mode_set, | 594 | .mode_set = qxl_crtc_mode_set, |
619 | .prepare = qxl_crtc_prepare, | 595 | .prepare = qxl_crtc_prepare, |
620 | .commit = qxl_crtc_commit, | 596 | .commit = qxl_crtc_commit, |
621 | }; | 597 | }; |
622 | 598 | ||
623 | static int qdev_crtc_init(struct drm_device *dev, int num_crtc) | 599 | static int qdev_crtc_init(struct drm_device *dev, int crtc_id) |
624 | { | 600 | { |
625 | struct qxl_crtc *qxl_crtc; | 601 | struct qxl_crtc *qxl_crtc; |
626 | 602 | ||
@@ -629,7 +605,7 @@ static int qdev_crtc_init(struct drm_device *dev, int num_crtc) | |||
629 | return -ENOMEM; | 605 | return -ENOMEM; |
630 | 606 | ||
631 | drm_crtc_init(dev, &qxl_crtc->base, &qxl_crtc_funcs); | 607 | drm_crtc_init(dev, &qxl_crtc->base, &qxl_crtc_funcs); |
632 | 608 | qxl_crtc->index = crtc_id; | |
633 | drm_mode_crtc_set_gamma_size(&qxl_crtc->base, 256); | 609 | drm_mode_crtc_set_gamma_size(&qxl_crtc->base, 256); |
634 | drm_crtc_helper_add(&qxl_crtc->base, &qxl_crtc_helper_funcs); | 610 | drm_crtc_helper_add(&qxl_crtc->base, &qxl_crtc_helper_funcs); |
635 | return 0; | 611 | return 0; |
@@ -657,18 +633,13 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
657 | struct drm_encoder *encoder) | 633 | struct drm_encoder *encoder) |
658 | { | 634 | { |
659 | int i; | 635 | int i; |
636 | struct qxl_output *output = drm_encoder_to_qxl_output(encoder); | ||
660 | struct qxl_head *head; | 637 | struct qxl_head *head; |
661 | struct drm_display_mode *mode; | 638 | struct drm_display_mode *mode; |
662 | 639 | ||
663 | BUG_ON(!encoder); | 640 | BUG_ON(!encoder); |
664 | /* TODO: ugly, do better */ | 641 | /* TODO: ugly, do better */ |
665 | for (i = 0 ; (encoder->possible_crtcs != (1 << i)) && i < 32; ++i) | 642 | i = output->index; |
666 | ; | ||
667 | if (encoder->possible_crtcs != (1 << i)) { | ||
668 | DRM_ERROR("encoder has wrong possible_crtcs: %x\n", | ||
669 | encoder->possible_crtcs); | ||
670 | return; | ||
671 | } | ||
672 | if (!qdev->monitors_config || | 643 | if (!qdev->monitors_config || |
673 | qdev->monitors_config->max_allowed <= i) { | 644 | qdev->monitors_config->max_allowed <= i) { |
674 | DRM_ERROR( | 645 | DRM_ERROR( |
@@ -686,7 +657,6 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
686 | DRM_DEBUG("missing for multiple monitors: no head holes\n"); | 657 | DRM_DEBUG("missing for multiple monitors: no head holes\n"); |
687 | head = &qdev->monitors_config->heads[i]; | 658 | head = &qdev->monitors_config->heads[i]; |
688 | head->id = i; | 659 | head->id = i; |
689 | head->surface_id = 0; | ||
690 | if (encoder->crtc->enabled) { | 660 | if (encoder->crtc->enabled) { |
691 | mode = &encoder->crtc->mode; | 661 | mode = &encoder->crtc->mode; |
692 | head->width = mode->hdisplay; | 662 | head->width = mode->hdisplay; |
@@ -701,8 +671,8 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
701 | head->x = 0; | 671 | head->x = 0; |
702 | head->y = 0; | 672 | head->y = 0; |
703 | } | 673 | } |
704 | DRM_DEBUG("setting head %d to +%d+%d %dx%d\n", | 674 | DRM_DEBUG_KMS("setting head %d to +%d+%d %dx%d out of %d\n", |
705 | i, head->x, head->y, head->width, head->height); | 675 | i, head->x, head->y, head->width, head->height, qdev->monitors_config->count); |
706 | head->flags = 0; | 676 | head->flags = 0; |
707 | /* TODO - somewhere else to call this for multiple monitors | 677 | /* TODO - somewhere else to call this for multiple monitors |
708 | * (config_commit?) */ | 678 | * (config_commit?) */ |
@@ -797,8 +767,9 @@ static enum drm_connector_status qxl_conn_detect( | |||
797 | 767 | ||
798 | /* The first monitor is always connected */ | 768 | /* The first monitor is always connected */ |
799 | connected = (output->index == 0) || | 769 | connected = (output->index == 0) || |
800 | (qdev->monitors_config && | 770 | (qdev->client_monitors_config && |
801 | qdev->monitors_config->count > output->index); | 771 | qdev->client_monitors_config->count > output->index && |
772 | qxl_head_enabled(&qdev->client_monitors_config->heads[output->index])); | ||
802 | 773 | ||
803 | DRM_DEBUG("\n"); | 774 | DRM_DEBUG("\n"); |
804 | return connected ? connector_status_connected | 775 | return connected ? connector_status_connected |
@@ -862,6 +833,8 @@ static int qdev_output_init(struct drm_device *dev, int num_output) | |||
862 | drm_encoder_init(dev, &qxl_output->enc, &qxl_enc_funcs, | 833 | drm_encoder_init(dev, &qxl_output->enc, &qxl_enc_funcs, |
863 | DRM_MODE_ENCODER_VIRTUAL); | 834 | DRM_MODE_ENCODER_VIRTUAL); |
864 | 835 | ||
836 | /* we get HPD via client monitors config */ | ||
837 | connector->polled = DRM_CONNECTOR_POLL_HPD; | ||
865 | encoder->possible_crtcs = 1 << num_output; | 838 | encoder->possible_crtcs = 1 << num_output; |
866 | drm_mode_connector_attach_encoder(&qxl_output->base, | 839 | drm_mode_connector_attach_encoder(&qxl_output->base, |
867 | &qxl_output->enc); | 840 | &qxl_output->enc); |
@@ -901,16 +874,14 @@ static const struct drm_mode_config_funcs qxl_mode_funcs = { | |||
901 | .fb_create = qxl_user_framebuffer_create, | 874 | .fb_create = qxl_user_framebuffer_create, |
902 | }; | 875 | }; |
903 | 876 | ||
904 | int qxl_modeset_init(struct qxl_device *qdev) | 877 | int qxl_create_monitors_object(struct qxl_device *qdev) |
905 | { | 878 | { |
906 | int i; | ||
907 | int ret; | 879 | int ret; |
908 | struct drm_gem_object *gobj; | 880 | struct drm_gem_object *gobj; |
909 | int max_allowed = QXL_NUM_OUTPUTS; | 881 | int max_allowed = qxl_num_crtc; |
910 | int monitors_config_size = sizeof(struct qxl_monitors_config) + | 882 | int monitors_config_size = sizeof(struct qxl_monitors_config) + |
911 | max_allowed * sizeof(struct qxl_head); | 883 | max_allowed * sizeof(struct qxl_head); |
912 | 884 | ||
913 | drm_mode_config_init(qdev->ddev); | ||
914 | ret = qxl_gem_object_create(qdev, monitors_config_size, 0, | 885 | ret = qxl_gem_object_create(qdev, monitors_config_size, 0, |
915 | QXL_GEM_DOMAIN_VRAM, | 886 | QXL_GEM_DOMAIN_VRAM, |
916 | false, false, NULL, &gobj); | 887 | false, false, NULL, &gobj); |
@@ -919,13 +890,59 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
919 | return -ENOMEM; | 890 | return -ENOMEM; |
920 | } | 891 | } |
921 | qdev->monitors_config_bo = gem_to_qxl_bo(gobj); | 892 | qdev->monitors_config_bo = gem_to_qxl_bo(gobj); |
893 | |||
894 | ret = qxl_bo_reserve(qdev->monitors_config_bo, false); | ||
895 | if (ret) | ||
896 | return ret; | ||
897 | |||
898 | ret = qxl_bo_pin(qdev->monitors_config_bo, QXL_GEM_DOMAIN_VRAM, NULL); | ||
899 | if (ret) { | ||
900 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
901 | return ret; | ||
902 | } | ||
903 | |||
904 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
905 | |||
922 | qxl_bo_kmap(qdev->monitors_config_bo, NULL); | 906 | qxl_bo_kmap(qdev->monitors_config_bo, NULL); |
907 | |||
923 | qdev->monitors_config = qdev->monitors_config_bo->kptr; | 908 | qdev->monitors_config = qdev->monitors_config_bo->kptr; |
924 | qdev->ram_header->monitors_config = | 909 | qdev->ram_header->monitors_config = |
925 | qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0); | 910 | qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0); |
926 | 911 | ||
927 | memset(qdev->monitors_config, 0, monitors_config_size); | 912 | memset(qdev->monitors_config, 0, monitors_config_size); |
928 | qdev->monitors_config->max_allowed = max_allowed; | 913 | qdev->monitors_config->max_allowed = max_allowed; |
914 | return 0; | ||
915 | } | ||
916 | |||
917 | int qxl_destroy_monitors_object(struct qxl_device *qdev) | ||
918 | { | ||
919 | int ret; | ||
920 | |||
921 | qdev->monitors_config = NULL; | ||
922 | qdev->ram_header->monitors_config = 0; | ||
923 | |||
924 | qxl_bo_kunmap(qdev->monitors_config_bo); | ||
925 | ret = qxl_bo_reserve(qdev->monitors_config_bo, false); | ||
926 | if (ret) | ||
927 | return ret; | ||
928 | |||
929 | qxl_bo_unpin(qdev->monitors_config_bo); | ||
930 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
931 | |||
932 | qxl_bo_unref(&qdev->monitors_config_bo); | ||
933 | return 0; | ||
934 | } | ||
935 | |||
936 | int qxl_modeset_init(struct qxl_device *qdev) | ||
937 | { | ||
938 | int i; | ||
939 | int ret; | ||
940 | |||
941 | drm_mode_config_init(qdev->ddev); | ||
942 | |||
943 | ret = qxl_create_monitors_object(qdev); | ||
944 | if (ret) | ||
945 | return ret; | ||
929 | 946 | ||
930 | qdev->ddev->mode_config.funcs = (void *)&qxl_mode_funcs; | 947 | qdev->ddev->mode_config.funcs = (void *)&qxl_mode_funcs; |
931 | 948 | ||
@@ -936,7 +953,7 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
936 | qdev->ddev->mode_config.max_height = 8192; | 953 | qdev->ddev->mode_config.max_height = 8192; |
937 | 954 | ||
938 | qdev->ddev->mode_config.fb_base = qdev->vram_base; | 955 | qdev->ddev->mode_config.fb_base = qdev->vram_base; |
939 | for (i = 0 ; i < QXL_NUM_OUTPUTS; ++i) { | 956 | for (i = 0 ; i < qxl_num_crtc; ++i) { |
940 | qdev_crtc_init(qdev->ddev, i); | 957 | qdev_crtc_init(qdev->ddev, i); |
941 | qdev_output_init(qdev->ddev, i); | 958 | qdev_output_init(qdev->ddev, i); |
942 | } | 959 | } |
@@ -953,6 +970,8 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
953 | void qxl_modeset_fini(struct qxl_device *qdev) | 970 | void qxl_modeset_fini(struct qxl_device *qdev) |
954 | { | 971 | { |
955 | qxl_fbdev_fini(qdev); | 972 | qxl_fbdev_fini(qdev); |
973 | |||
974 | qxl_destroy_monitors_object(qdev); | ||
956 | if (qdev->mode_info.mode_config_initialized) { | 975 | if (qdev->mode_info.mode_config_initialized) { |
957 | drm_mode_config_cleanup(qdev->ddev); | 976 | drm_mode_config_cleanup(qdev->ddev); |
958 | qdev->mode_info.mode_config_initialized = false; | 977 | qdev->mode_info.mode_config_initialized = false; |
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index aa291d8a98a2..df0b577a6608 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c | |||
@@ -33,8 +33,9 @@ | |||
33 | 33 | ||
34 | #include "drmP.h" | 34 | #include "drmP.h" |
35 | #include "drm/drm.h" | 35 | #include "drm/drm.h" |
36 | 36 | #include "drm_crtc_helper.h" | |
37 | #include "qxl_drv.h" | 37 | #include "qxl_drv.h" |
38 | #include "qxl_object.h" | ||
38 | 39 | ||
39 | extern int qxl_max_ioctls; | 40 | extern int qxl_max_ioctls; |
40 | static DEFINE_PCI_DEVICE_TABLE(pciidlist) = { | 41 | static DEFINE_PCI_DEVICE_TABLE(pciidlist) = { |
@@ -47,10 +48,14 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = { | |||
47 | MODULE_DEVICE_TABLE(pci, pciidlist); | 48 | MODULE_DEVICE_TABLE(pci, pciidlist); |
48 | 49 | ||
49 | static int qxl_modeset = -1; | 50 | static int qxl_modeset = -1; |
51 | int qxl_num_crtc = 4; | ||
50 | 52 | ||
51 | MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); | 53 | MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); |
52 | module_param_named(modeset, qxl_modeset, int, 0400); | 54 | module_param_named(modeset, qxl_modeset, int, 0400); |
53 | 55 | ||
56 | MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)"); | ||
57 | module_param_named(num_heads, qxl_num_crtc, int, 0400); | ||
58 | |||
54 | static struct drm_driver qxl_driver; | 59 | static struct drm_driver qxl_driver; |
55 | static struct pci_driver qxl_pci_driver; | 60 | static struct pci_driver qxl_pci_driver; |
56 | 61 | ||
@@ -73,13 +78,6 @@ qxl_pci_remove(struct pci_dev *pdev) | |||
73 | drm_put_dev(dev); | 78 | drm_put_dev(dev); |
74 | } | 79 | } |
75 | 80 | ||
76 | static struct pci_driver qxl_pci_driver = { | ||
77 | .name = DRIVER_NAME, | ||
78 | .id_table = pciidlist, | ||
79 | .probe = qxl_pci_probe, | ||
80 | .remove = qxl_pci_remove, | ||
81 | }; | ||
82 | |||
83 | static const struct file_operations qxl_fops = { | 81 | static const struct file_operations qxl_fops = { |
84 | .owner = THIS_MODULE, | 82 | .owner = THIS_MODULE, |
85 | .open = drm_open, | 83 | .open = drm_open, |
@@ -90,6 +88,130 @@ static const struct file_operations qxl_fops = { | |||
90 | .mmap = qxl_mmap, | 88 | .mmap = qxl_mmap, |
91 | }; | 89 | }; |
92 | 90 | ||
91 | static int qxl_drm_freeze(struct drm_device *dev) | ||
92 | { | ||
93 | struct pci_dev *pdev = dev->pdev; | ||
94 | struct qxl_device *qdev = dev->dev_private; | ||
95 | struct drm_crtc *crtc; | ||
96 | |||
97 | drm_kms_helper_poll_disable(dev); | ||
98 | |||
99 | console_lock(); | ||
100 | qxl_fbdev_set_suspend(qdev, 1); | ||
101 | console_unlock(); | ||
102 | |||
103 | /* unpin the front buffers */ | ||
104 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
105 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; | ||
106 | if (crtc->enabled) | ||
107 | (*crtc_funcs->disable)(crtc); | ||
108 | } | ||
109 | |||
110 | qxl_destroy_monitors_object(qdev); | ||
111 | qxl_surf_evict(qdev); | ||
112 | qxl_vram_evict(qdev); | ||
113 | |||
114 | while (!qxl_check_idle(qdev->command_ring)); | ||
115 | while (!qxl_check_idle(qdev->release_ring)) | ||
116 | qxl_queue_garbage_collect(qdev, 1); | ||
117 | |||
118 | pci_save_state(pdev); | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | static int qxl_drm_resume(struct drm_device *dev, bool thaw) | ||
124 | { | ||
125 | struct qxl_device *qdev = dev->dev_private; | ||
126 | |||
127 | qdev->ram_header->int_mask = QXL_INTERRUPT_MASK; | ||
128 | if (!thaw) { | ||
129 | qxl_reinit_memslots(qdev); | ||
130 | qxl_ring_init_hdr(qdev->release_ring); | ||
131 | } | ||
132 | |||
133 | qxl_create_monitors_object(qdev); | ||
134 | drm_helper_resume_force_mode(dev); | ||
135 | |||
136 | console_lock(); | ||
137 | qxl_fbdev_set_suspend(qdev, 0); | ||
138 | console_unlock(); | ||
139 | |||
140 | drm_kms_helper_poll_enable(dev); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int qxl_pm_suspend(struct device *dev) | ||
145 | { | ||
146 | struct pci_dev *pdev = to_pci_dev(dev); | ||
147 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
148 | int error; | ||
149 | |||
150 | error = qxl_drm_freeze(drm_dev); | ||
151 | if (error) | ||
152 | return error; | ||
153 | |||
154 | pci_disable_device(pdev); | ||
155 | pci_set_power_state(pdev, PCI_D3hot); | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int qxl_pm_resume(struct device *dev) | ||
160 | { | ||
161 | struct pci_dev *pdev = to_pci_dev(dev); | ||
162 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
163 | |||
164 | pci_set_power_state(pdev, PCI_D0); | ||
165 | pci_restore_state(pdev); | ||
166 | if (pci_enable_device(pdev)) { | ||
167 | return -EIO; | ||
168 | } | ||
169 | |||
170 | return qxl_drm_resume(drm_dev, false); | ||
171 | } | ||
172 | |||
173 | static int qxl_pm_thaw(struct device *dev) | ||
174 | { | ||
175 | struct pci_dev *pdev = to_pci_dev(dev); | ||
176 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
177 | |||
178 | return qxl_drm_resume(drm_dev, true); | ||
179 | } | ||
180 | |||
181 | static int qxl_pm_freeze(struct device *dev) | ||
182 | { | ||
183 | struct pci_dev *pdev = to_pci_dev(dev); | ||
184 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
185 | |||
186 | return qxl_drm_freeze(drm_dev); | ||
187 | } | ||
188 | |||
189 | static int qxl_pm_restore(struct device *dev) | ||
190 | { | ||
191 | struct pci_dev *pdev = to_pci_dev(dev); | ||
192 | struct drm_device *drm_dev = pci_get_drvdata(pdev); | ||
193 | struct qxl_device *qdev = drm_dev->dev_private; | ||
194 | |||
195 | qxl_io_reset(qdev); | ||
196 | return qxl_drm_resume(drm_dev, false); | ||
197 | } | ||
198 | |||
199 | static const struct dev_pm_ops qxl_pm_ops = { | ||
200 | .suspend = qxl_pm_suspend, | ||
201 | .resume = qxl_pm_resume, | ||
202 | .freeze = qxl_pm_freeze, | ||
203 | .thaw = qxl_pm_thaw, | ||
204 | .poweroff = qxl_pm_freeze, | ||
205 | .restore = qxl_pm_restore, | ||
206 | }; | ||
207 | static struct pci_driver qxl_pci_driver = { | ||
208 | .name = DRIVER_NAME, | ||
209 | .id_table = pciidlist, | ||
210 | .probe = qxl_pci_probe, | ||
211 | .remove = qxl_pci_remove, | ||
212 | .driver.pm = &qxl_pm_ops, | ||
213 | }; | ||
214 | |||
93 | static struct drm_driver qxl_driver = { | 215 | static struct drm_driver qxl_driver = { |
94 | .driver_features = DRIVER_GEM | DRIVER_MODESET | | 216 | .driver_features = DRIVER_GEM | DRIVER_MODESET | |
95 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, | 217 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, |
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 43d06ab28a21..aacb791464a3 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h | |||
@@ -55,11 +55,10 @@ | |||
55 | #define DRIVER_MINOR 1 | 55 | #define DRIVER_MINOR 1 |
56 | #define DRIVER_PATCHLEVEL 0 | 56 | #define DRIVER_PATCHLEVEL 0 |
57 | 57 | ||
58 | #define QXL_NUM_OUTPUTS 1 | ||
59 | |||
60 | #define QXL_DEBUGFS_MAX_COMPONENTS 32 | 58 | #define QXL_DEBUGFS_MAX_COMPONENTS 32 |
61 | 59 | ||
62 | extern int qxl_log_level; | 60 | extern int qxl_log_level; |
61 | extern int qxl_num_crtc; | ||
63 | 62 | ||
64 | enum { | 63 | enum { |
65 | QXL_INFO_LEVEL = 1, | 64 | QXL_INFO_LEVEL = 1, |
@@ -139,6 +138,7 @@ struct qxl_reloc_list { | |||
139 | 138 | ||
140 | struct qxl_crtc { | 139 | struct qxl_crtc { |
141 | struct drm_crtc base; | 140 | struct drm_crtc base; |
141 | int index; | ||
142 | int cur_x; | 142 | int cur_x; |
143 | int cur_y; | 143 | int cur_y; |
144 | }; | 144 | }; |
@@ -156,7 +156,7 @@ struct qxl_framebuffer { | |||
156 | 156 | ||
157 | #define to_qxl_crtc(x) container_of(x, struct qxl_crtc, base) | 157 | #define to_qxl_crtc(x) container_of(x, struct qxl_crtc, base) |
158 | #define drm_connector_to_qxl_output(x) container_of(x, struct qxl_output, base) | 158 | #define drm_connector_to_qxl_output(x) container_of(x, struct qxl_output, base) |
159 | #define drm_encoder_to_qxl_output(x) container_of(x, struct qxl_output, base) | 159 | #define drm_encoder_to_qxl_output(x) container_of(x, struct qxl_output, enc) |
160 | #define to_qxl_framebuffer(x) container_of(x, struct qxl_framebuffer, base) | 160 | #define to_qxl_framebuffer(x) container_of(x, struct qxl_framebuffer, base) |
161 | 161 | ||
162 | struct qxl_mman { | 162 | struct qxl_mman { |
@@ -331,6 +331,10 @@ void qxl_modeset_fini(struct qxl_device *qdev); | |||
331 | int qxl_bo_init(struct qxl_device *qdev); | 331 | int qxl_bo_init(struct qxl_device *qdev); |
332 | void qxl_bo_fini(struct qxl_device *qdev); | 332 | void qxl_bo_fini(struct qxl_device *qdev); |
333 | 333 | ||
334 | void qxl_reinit_memslots(struct qxl_device *qdev); | ||
335 | int qxl_surf_evict(struct qxl_device *qdev); | ||
336 | int qxl_vram_evict(struct qxl_device *qdev); | ||
337 | |||
334 | struct qxl_ring *qxl_ring_create(struct qxl_ring_header *header, | 338 | struct qxl_ring *qxl_ring_create(struct qxl_ring_header *header, |
335 | int element_size, | 339 | int element_size, |
336 | int n_elements, | 340 | int n_elements, |
@@ -338,6 +342,8 @@ struct qxl_ring *qxl_ring_create(struct qxl_ring_header *header, | |||
338 | bool set_prod_notify, | 342 | bool set_prod_notify, |
339 | wait_queue_head_t *push_event); | 343 | wait_queue_head_t *push_event); |
340 | void qxl_ring_free(struct qxl_ring *ring); | 344 | void qxl_ring_free(struct qxl_ring *ring); |
345 | void qxl_ring_init_hdr(struct qxl_ring *ring); | ||
346 | int qxl_check_idle(struct qxl_ring *ring); | ||
341 | 347 | ||
342 | static inline void * | 348 | static inline void * |
343 | qxl_fb_virtual_address(struct qxl_device *qdev, unsigned long physical) | 349 | qxl_fb_virtual_address(struct qxl_device *qdev, unsigned long physical) |
@@ -365,6 +371,7 @@ void qxl_fbdev_fini(struct qxl_device *qdev); | |||
365 | int qxl_get_handle_for_primary_fb(struct qxl_device *qdev, | 371 | int qxl_get_handle_for_primary_fb(struct qxl_device *qdev, |
366 | struct drm_file *file_priv, | 372 | struct drm_file *file_priv, |
367 | uint32_t *handle); | 373 | uint32_t *handle); |
374 | void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state); | ||
368 | 375 | ||
369 | /* qxl_display.c */ | 376 | /* qxl_display.c */ |
370 | int | 377 | int |
@@ -374,6 +381,8 @@ qxl_framebuffer_init(struct drm_device *dev, | |||
374 | struct drm_gem_object *obj); | 381 | struct drm_gem_object *obj); |
375 | void qxl_display_read_client_monitors_config(struct qxl_device *qdev); | 382 | void qxl_display_read_client_monitors_config(struct qxl_device *qdev); |
376 | void qxl_send_monitors_config(struct qxl_device *qdev); | 383 | void qxl_send_monitors_config(struct qxl_device *qdev); |
384 | int qxl_create_monitors_object(struct qxl_device *qdev); | ||
385 | int qxl_destroy_monitors_object(struct qxl_device *qdev); | ||
377 | 386 | ||
378 | /* used by qxl_debugfs only */ | 387 | /* used by qxl_debugfs only */ |
379 | void qxl_crtc_set_from_monitors_config(struct qxl_device *qdev); | 388 | void qxl_crtc_set_from_monitors_config(struct qxl_device *qdev); |
@@ -435,7 +444,7 @@ void qxl_update_screen(struct qxl_device *qxl); | |||
435 | /* qxl io operations (qxl_cmd.c) */ | 444 | /* qxl io operations (qxl_cmd.c) */ |
436 | 445 | ||
437 | void qxl_io_create_primary(struct qxl_device *qdev, | 446 | void qxl_io_create_primary(struct qxl_device *qdev, |
438 | unsigned width, unsigned height, unsigned offset, | 447 | unsigned offset, |
439 | struct qxl_bo *bo); | 448 | struct qxl_bo *bo); |
440 | void qxl_io_destroy_primary(struct qxl_device *qdev); | 449 | void qxl_io_destroy_primary(struct qxl_device *qdev); |
441 | void qxl_io_memslot_add(struct qxl_device *qdev, uint8_t id); | 450 | void qxl_io_memslot_add(struct qxl_device *qdev, uint8_t id); |
@@ -528,6 +537,7 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS); | |||
528 | 537 | ||
529 | /* qxl_fb.c */ | 538 | /* qxl_fb.c */ |
530 | int qxl_fb_init(struct qxl_device *qdev); | 539 | int qxl_fb_init(struct qxl_device *qdev); |
540 | bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj); | ||
531 | 541 | ||
532 | int qxl_debugfs_add_files(struct qxl_device *qdev, | 542 | int qxl_debugfs_add_files(struct qxl_device *qdev, |
533 | struct drm_info_list *files, | 543 | struct drm_info_list *files, |
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c index 4b955b04ce1e..76f39d88d684 100644 --- a/drivers/gpu/drm/qxl/qxl_fb.c +++ b/drivers/gpu/drm/qxl/qxl_fb.c | |||
@@ -538,7 +538,7 @@ int qxl_fbdev_init(struct qxl_device *qdev) | |||
538 | qfbdev->helper.funcs = &qxl_fb_helper_funcs; | 538 | qfbdev->helper.funcs = &qxl_fb_helper_funcs; |
539 | 539 | ||
540 | ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper, | 540 | ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper, |
541 | 1 /* num_crtc - QXL supports just 1 */, | 541 | qxl_num_crtc /* num_crtc - QXL supports just 1 */, |
542 | QXLFB_CONN_LIMIT); | 542 | QXLFB_CONN_LIMIT); |
543 | if (ret) { | 543 | if (ret) { |
544 | kfree(qfbdev); | 544 | kfree(qfbdev); |
@@ -560,4 +560,14 @@ void qxl_fbdev_fini(struct qxl_device *qdev) | |||
560 | qdev->mode_info.qfbdev = NULL; | 560 | qdev->mode_info.qfbdev = NULL; |
561 | } | 561 | } |
562 | 562 | ||
563 | void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state) | ||
564 | { | ||
565 | fb_set_suspend(qdev->mode_info.qfbdev->helper.fbdev, state); | ||
566 | } | ||
563 | 567 | ||
568 | bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj) | ||
569 | { | ||
570 | if (qobj == gem_to_qxl_bo(qdev->mode_info.qfbdev->qfb.obj)) | ||
571 | return true; | ||
572 | return false; | ||
573 | } | ||
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c index a4b71b25fa53..6ba49d9922f2 100644 --- a/drivers/gpu/drm/qxl/qxl_ioctl.c +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c | |||
@@ -183,6 +183,12 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, | |||
183 | /* TODO copy slow path code from i915 */ | 183 | /* TODO copy slow path code from i915 */ |
184 | fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE)); | 184 | fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE)); |
185 | unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)user_cmd.command, user_cmd.command_size); | 185 | unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)user_cmd.command, user_cmd.command_size); |
186 | |||
187 | { | ||
188 | struct qxl_drawable *draw = fb_cmd; | ||
189 | |||
190 | draw->mm_time = qdev->rom->mm_clock; | ||
191 | } | ||
186 | qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd); | 192 | qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd); |
187 | if (unwritten) { | 193 | if (unwritten) { |
188 | DRM_ERROR("got unwritten %d\n", unwritten); | 194 | DRM_ERROR("got unwritten %d\n", unwritten); |
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c index e27ce2a907cf..9e8da9ee9731 100644 --- a/drivers/gpu/drm/qxl/qxl_kms.c +++ b/drivers/gpu/drm/qxl/qxl_kms.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "qxl_drv.h" | 26 | #include "qxl_drv.h" |
27 | #include "qxl_object.h" | 27 | #include "qxl_object.h" |
28 | 28 | ||
29 | #include <drm/drm_crtc_helper.h> | ||
29 | #include <linux/io-mapping.h> | 30 | #include <linux/io-mapping.h> |
30 | 31 | ||
31 | int qxl_log_level; | 32 | int qxl_log_level; |
@@ -72,21 +73,28 @@ static bool qxl_check_device(struct qxl_device *qdev) | |||
72 | return true; | 73 | return true; |
73 | } | 74 | } |
74 | 75 | ||
76 | static void setup_hw_slot(struct qxl_device *qdev, int slot_index, | ||
77 | struct qxl_memslot *slot) | ||
78 | { | ||
79 | qdev->ram_header->mem_slot.mem_start = slot->start_phys_addr; | ||
80 | qdev->ram_header->mem_slot.mem_end = slot->end_phys_addr; | ||
81 | qxl_io_memslot_add(qdev, slot_index); | ||
82 | } | ||
83 | |||
75 | static uint8_t setup_slot(struct qxl_device *qdev, uint8_t slot_index_offset, | 84 | static uint8_t setup_slot(struct qxl_device *qdev, uint8_t slot_index_offset, |
76 | unsigned long start_phys_addr, unsigned long end_phys_addr) | 85 | unsigned long start_phys_addr, unsigned long end_phys_addr) |
77 | { | 86 | { |
78 | uint64_t high_bits; | 87 | uint64_t high_bits; |
79 | struct qxl_memslot *slot; | 88 | struct qxl_memslot *slot; |
80 | uint8_t slot_index; | 89 | uint8_t slot_index; |
81 | struct qxl_ram_header *ram_header = qdev->ram_header; | ||
82 | 90 | ||
83 | slot_index = qdev->rom->slots_start + slot_index_offset; | 91 | slot_index = qdev->rom->slots_start + slot_index_offset; |
84 | slot = &qdev->mem_slots[slot_index]; | 92 | slot = &qdev->mem_slots[slot_index]; |
85 | slot->start_phys_addr = start_phys_addr; | 93 | slot->start_phys_addr = start_phys_addr; |
86 | slot->end_phys_addr = end_phys_addr; | 94 | slot->end_phys_addr = end_phys_addr; |
87 | ram_header->mem_slot.mem_start = slot->start_phys_addr; | 95 | |
88 | ram_header->mem_slot.mem_end = slot->end_phys_addr; | 96 | setup_hw_slot(qdev, slot_index, slot); |
89 | qxl_io_memslot_add(qdev, slot_index); | 97 | |
90 | slot->generation = qdev->rom->slot_generation; | 98 | slot->generation = qdev->rom->slot_generation; |
91 | high_bits = slot_index << qdev->slot_gen_bits; | 99 | high_bits = slot_index << qdev->slot_gen_bits; |
92 | high_bits |= slot->generation; | 100 | high_bits |= slot->generation; |
@@ -95,6 +103,12 @@ static uint8_t setup_slot(struct qxl_device *qdev, uint8_t slot_index_offset, | |||
95 | return slot_index; | 103 | return slot_index; |
96 | } | 104 | } |
97 | 105 | ||
106 | void qxl_reinit_memslots(struct qxl_device *qdev) | ||
107 | { | ||
108 | setup_hw_slot(qdev, qdev->main_mem_slot, &qdev->mem_slots[qdev->main_mem_slot]); | ||
109 | setup_hw_slot(qdev, qdev->surfaces_mem_slot, &qdev->mem_slots[qdev->surfaces_mem_slot]); | ||
110 | } | ||
111 | |||
98 | static void qxl_gc_work(struct work_struct *work) | 112 | static void qxl_gc_work(struct work_struct *work) |
99 | { | 113 | { |
100 | struct qxl_device *qdev = container_of(work, struct qxl_device, gc_work); | 114 | struct qxl_device *qdev = container_of(work, struct qxl_device, gc_work); |
@@ -294,6 +308,8 @@ int qxl_driver_load(struct drm_device *dev, unsigned long flags) | |||
294 | goto out; | 308 | goto out; |
295 | } | 309 | } |
296 | 310 | ||
311 | drm_kms_helper_poll_init(qdev->ddev); | ||
312 | |||
297 | return 0; | 313 | return 0; |
298 | out: | 314 | out: |
299 | kfree(qdev); | 315 | kfree(qdev); |
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index d9b12e7bc6e1..1191fe7788c9 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c | |||
@@ -363,3 +363,13 @@ int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo) | |||
363 | return ret; | 363 | return ret; |
364 | return 0; | 364 | return 0; |
365 | } | 365 | } |
366 | |||
367 | int qxl_surf_evict(struct qxl_device *qdev) | ||
368 | { | ||
369 | return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV0); | ||
370 | } | ||
371 | |||
372 | int qxl_vram_evict(struct qxl_device *qdev) | ||
373 | { | ||
374 | return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM); | ||
375 | } | ||