hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/gpu/drm/vc4/vc4_irq.c
....@@ -59,15 +59,22 @@
5959 {
6060 struct vc4_dev *vc4 =
6161 container_of(work, struct vc4_dev, overflow_mem_work);
62
- struct vc4_bo *bo = vc4->bin_bo;
62
+ struct vc4_bo *bo;
6363 int bin_bo_slot;
6464 struct vc4_exec_info *exec;
6565 unsigned long irqflags;
6666
67
+ mutex_lock(&vc4->bin_bo_lock);
68
+
69
+ if (!vc4->bin_bo)
70
+ goto complete;
71
+
72
+ bo = vc4->bin_bo;
73
+
6774 bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
6875 if (bin_bo_slot < 0) {
6976 DRM_ERROR("Couldn't allocate binner overflow mem\n");
70
- return;
77
+ goto complete;
7178 }
7279
7380 spin_lock_irqsave(&vc4->job_lock, irqflags);
....@@ -98,6 +105,9 @@
98105 V3D_WRITE(V3D_INTCTL, V3D_INT_OUTOMEM);
99106 V3D_WRITE(V3D_INTENA, V3D_INT_OUTOMEM);
100107 spin_unlock_irqrestore(&vc4->job_lock, irqflags);
108
+
109
+complete:
110
+ mutex_unlock(&vc4->bin_bo_lock);
101111 }
102112
103113 static void
....@@ -229,6 +239,9 @@
229239 {
230240 struct vc4_dev *vc4 = to_vc4_dev(dev);
231241
242
+ if (!vc4->v3d)
243
+ return;
244
+
232245 init_waitqueue_head(&vc4->job_wait_queue);
233246 INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work);
234247
....@@ -243,8 +256,13 @@
243256 {
244257 struct vc4_dev *vc4 = to_vc4_dev(dev);
245258
246
- /* Enable both the render done and out of memory interrupts. */
247
- V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS);
259
+ if (!vc4->v3d)
260
+ return 0;
261
+
262
+ /* Enable the render done interrupts. The out-of-memory interrupt is
263
+ * enabled as soon as we have a binner BO allocated.
264
+ */
265
+ V3D_WRITE(V3D_INTENA, V3D_INT_FLDONE | V3D_INT_FRDONE);
248266
249267 return 0;
250268 }
....@@ -254,6 +272,9 @@
254272 {
255273 struct vc4_dev *vc4 = to_vc4_dev(dev);
256274
275
+ if (!vc4->v3d)
276
+ return;
277
+
257278 /* Disable sending interrupts for our driver's IRQs. */
258279 V3D_WRITE(V3D_INTDIS, V3D_DRIVER_IRQS);
259280