1 From 00f06424b180f1f6a3f52df718eae07c36fc72e5 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Wed, 20 Feb 2019 13:03:41 -0800
4 Subject: [PATCH 582/703] drm/vc4: Disable V3D interactions if the v3d
5 component didn't probe.
7 One might want to use the VC4 display stack without using Mesa.
8 Similar to the debugfs fixes for not having all of the possible
9 display bits enabled, make sure you can't oops in vc4 if v3d isn't
12 Signed-off-by: Eric Anholt <eric@anholt.net>
14 drivers/gpu/drm/vc4/vc4_drv.c | 11 +++++++++++
15 drivers/gpu/drm/vc4/vc4_gem.c | 10 ++++++++++
16 drivers/gpu/drm/vc4/vc4_irq.c | 9 +++++++++
17 drivers/gpu/drm/vc4/vc4_perfmon.c | 18 ++++++++++++++++++
18 4 files changed, 48 insertions(+)
20 --- a/drivers/gpu/drm/vc4/vc4_drv.c
21 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
22 @@ -71,6 +71,9 @@ static int vc4_get_param_ioctl(struct dr
29 switch (args->param) {
30 case DRM_VC4_PARAM_V3D_IDENT0:
31 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
32 @@ -271,6 +274,7 @@ static int vc4_drm_bind(struct device *d
33 struct platform_device *pdev = to_platform_device(dev);
34 struct drm_device *drm;
36 + struct device_node *node;
39 dev->coherent_dma_mask = DMA_BIT_MASK(32);
40 @@ -279,6 +283,13 @@ static int vc4_drm_bind(struct device *d
44 + /* If VC4 V3D is missing, don't advertise render nodes. */
45 + node = of_find_compatible_node(NULL, NULL, "brcm,bcm2835-v3d");
49 + vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
51 drm = drm_dev_alloc(&vc4_drm_driver, dev);
54 --- a/drivers/gpu/drm/vc4/vc4_gem.c
55 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
56 @@ -74,6 +74,11 @@ vc4_get_hang_state_ioctl(struct drm_devi
61 + DRM_DEBUG("VC4_GET_HANG_STATE with no VC4 V3D probed\n");
65 spin_lock_irqsave(&vc4->job_lock, irqflags);
66 kernel_state = vc4->hang_state;
68 @@ -1124,6 +1129,11 @@ vc4_submit_cl_ioctl(struct drm_device *d
69 struct dma_fence *in_fence;
73 + DRM_DEBUG("VC4_SUBMIT_CL with no VC4 V3D probed\n");
77 if ((args->flags & ~(VC4_SUBMIT_CL_USE_CLEAR_COLOR |
78 VC4_SUBMIT_CL_FIXED_RCL_ORDER |
79 VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X |
80 --- a/drivers/gpu/drm/vc4/vc4_irq.c
81 +++ b/drivers/gpu/drm/vc4/vc4_irq.c
82 @@ -229,6 +229,9 @@ vc4_irq_preinstall(struct drm_device *de
84 struct vc4_dev *vc4 = to_vc4_dev(dev);
89 init_waitqueue_head(&vc4->job_wait_queue);
90 INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work);
92 @@ -243,6 +246,9 @@ vc4_irq_postinstall(struct drm_device *d
94 struct vc4_dev *vc4 = to_vc4_dev(dev);
99 /* Enable both the render done and out of memory interrupts. */
100 V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS);
102 @@ -254,6 +260,9 @@ vc4_irq_uninstall(struct drm_device *dev
104 struct vc4_dev *vc4 = to_vc4_dev(dev);
109 /* Disable sending interrupts for our driver's IRQs. */
110 V3D_WRITE(V3D_INTDIS, V3D_DRIVER_IRQS);
112 --- a/drivers/gpu/drm/vc4/vc4_perfmon.c
113 +++ b/drivers/gpu/drm/vc4/vc4_perfmon.c
114 @@ -100,12 +100,18 @@ void vc4_perfmon_close_file(struct vc4_f
115 int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data,
116 struct drm_file *file_priv)
118 + struct vc4_dev *vc4 = to_vc4_dev(dev);
119 struct vc4_file *vc4file = file_priv->driver_priv;
120 struct drm_vc4_perfmon_create *req = data;
121 struct vc4_perfmon *perfmon;
126 + DRM_DEBUG("Creating perfmon no VC4 V3D probed\n");
130 /* Number of monitored counters cannot exceed HW limits. */
131 if (req->ncounters > DRM_VC4_MAX_PERF_COUNTERS ||
133 @@ -146,10 +152,16 @@ int vc4_perfmon_create_ioctl(struct drm_
134 int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
135 struct drm_file *file_priv)
137 + struct vc4_dev *vc4 = to_vc4_dev(dev);
138 struct vc4_file *vc4file = file_priv->driver_priv;
139 struct drm_vc4_perfmon_destroy *req = data;
140 struct vc4_perfmon *perfmon;
143 + DRM_DEBUG("Destroying perfmon no VC4 V3D probed\n");
147 mutex_lock(&vc4file->perfmon.lock);
148 perfmon = idr_remove(&vc4file->perfmon.idr, req->id);
149 mutex_unlock(&vc4file->perfmon.lock);
150 @@ -164,11 +176,17 @@ int vc4_perfmon_destroy_ioctl(struct drm
151 int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
152 struct drm_file *file_priv)
154 + struct vc4_dev *vc4 = to_vc4_dev(dev);
155 struct vc4_file *vc4file = file_priv->driver_priv;
156 struct drm_vc4_perfmon_get_values *req = data;
157 struct vc4_perfmon *perfmon;
161 + DRM_DEBUG("Getting perfmon no VC4 V3D probed\n");
165 mutex_lock(&vc4file->perfmon.lock);
166 perfmon = idr_find(&vc4file->perfmon.idr, req->id);
167 vc4_perfmon_get(perfmon);