1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include "qxl_drv.h"
27
28irqreturn_t qxl_irq_handler(int irq, void *arg)
29{
30 struct drm_device *dev = (struct drm_device *) arg;
31 struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
32 uint32_t pending;
33
34 pending = xchg(&qdev->ram_header->int_pending, 0);
35
36 if (!pending)
37 return IRQ_NONE;
38
39 atomic_inc(&qdev->irq_received);
40
41 if (pending & QXL_INTERRUPT_DISPLAY) {
42 atomic_inc(&qdev->irq_received_display);
43 wake_up_all(&qdev->display_event);
44 qxl_queue_garbage_collect(qdev, false);
45 }
46 if (pending & QXL_INTERRUPT_CURSOR) {
47 atomic_inc(&qdev->irq_received_cursor);
48 wake_up_all(&qdev->cursor_event);
49 }
50 if (pending & QXL_INTERRUPT_IO_CMD) {
51 atomic_inc(&qdev->irq_received_io_cmd);
52 wake_up_all(&qdev->io_cmd_event);
53 }
54 if (pending & QXL_INTERRUPT_ERROR) {
55
56
57
58
59 qdev->irq_received_error++;
60 qxl_io_log(qdev, "%s: driver is in bug mode.\n", __func__);
61 }
62 if (pending & QXL_INTERRUPT_CLIENT_MONITORS_CONFIG) {
63 qxl_io_log(qdev, "QXL_INTERRUPT_CLIENT_MONITORS_CONFIG\n");
64 schedule_work(&qdev->client_monitors_config_work);
65 }
66 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
67 outb(0, qdev->io_base + QXL_IO_UPDATE_IRQ);
68 return IRQ_HANDLED;
69}
70
71static void qxl_client_monitors_config_work_func(struct work_struct *work)
72{
73 struct qxl_device *qdev = container_of(work, struct qxl_device,
74 client_monitors_config_work);
75
76 qxl_display_read_client_monitors_config(qdev);
77}
78
79int qxl_irq_init(struct qxl_device *qdev)
80{
81 int ret;
82
83 init_waitqueue_head(&qdev->display_event);
84 init_waitqueue_head(&qdev->cursor_event);
85 init_waitqueue_head(&qdev->io_cmd_event);
86 INIT_WORK(&qdev->client_monitors_config_work,
87 qxl_client_monitors_config_work_func);
88 atomic_set(&qdev->irq_received, 0);
89 atomic_set(&qdev->irq_received_display, 0);
90 atomic_set(&qdev->irq_received_cursor, 0);
91 atomic_set(&qdev->irq_received_io_cmd, 0);
92 qdev->irq_received_error = 0;
93 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
94 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
95 if (unlikely(ret != 0)) {
96 DRM_ERROR("Failed installing irq: %d\n", ret);
97 return 1;
98 }
99 return 0;
100}
101