Skip to content

Commit 13bc32b

Browse files
committed
Merge tag 'drm-fixes-2022-04-23' of git://anongit.freedesktop.org/drm/drm
Pull more drm fixes from Dave Airlie: "Maarten was away, so Maxine stepped up and sent me the drm-fixes merge, so no point leaving it for another week. The big change is an OF revert around bridge/panels, it may have some driver fallout, but hopefully this revert gets them shook out in the next week easier. Otherwise it's a bunch of locking/refcounts across drivers, a radeon dma_resv logic fix and some raspberry pi panel fixes. panel: - revert of patch that broke panel/bridge issues dma-buf: - remove unused header file. amdgpu: - partial revert of locking change radeon: - fix dma_resv logic inversion panel: - pi touchscreen panel init fixes vc4: - build fix - runtime pm refcount fix vmwgfx: - refcounting fix" * tag 'drm-fixes-2022-04-23' of git://anongit.freedesktop.org/drm/drm: drm/amdgpu: partial revert "remove ctx->lock" v2 Revert "drm: of: Lookup if child node has panel or bridge" Revert "drm: of: Properly try all possible cases for bridge/panel detection" drm/vc4: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage drm/vmwgfx: Fix gem refcounting and memory evictions drm/vc4: Fix build error when CONFIG_DRM_VC4=y && CONFIG_RASPBERRYPI_FIRMWARE=m drm/panel/raspberrypi-touchscreen: Initialise the bridge in prepare drm/panel/raspberrypi-touchscreen: Avoid NULL deref if not initialised dma-buf-map: remove renamed header file drm/radeon: fix logic inversion in radeon_sync_resv
2 parents 0fe86b2 + c18a2a2 commit 13bc32b

File tree

12 files changed

+94
-358
lines changed

12 files changed

+94
-358
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
128128
goto free_chunk;
129129
}
130130

131+
mutex_lock(&p->ctx->lock);
132+
131133
/* skip guilty context job */
132134
if (atomic_read(&p->ctx->guilty) == 1) {
133135
ret = -ECANCELED;
@@ -709,6 +711,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error,
709711
dma_fence_put(parser->fence);
710712

711713
if (parser->ctx) {
714+
mutex_unlock(&parser->ctx->lock);
712715
amdgpu_ctx_put(parser->ctx);
713716
}
714717
if (parser->bo_list)
@@ -1157,6 +1160,9 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
11571160
{
11581161
int i, r;
11591162

1163+
/* TODO: Investigate why we still need the context lock */
1164+
mutex_unlock(&p->ctx->lock);
1165+
11601166
for (i = 0; i < p->nchunks; ++i) {
11611167
struct amdgpu_cs_chunk *chunk;
11621168

@@ -1167,32 +1173,34 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
11671173
case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
11681174
r = amdgpu_cs_process_fence_dep(p, chunk);
11691175
if (r)
1170-
return r;
1176+
goto out;
11711177
break;
11721178
case AMDGPU_CHUNK_ID_SYNCOBJ_IN:
11731179
r = amdgpu_cs_process_syncobj_in_dep(p, chunk);
11741180
if (r)
1175-
return r;
1181+
goto out;
11761182
break;
11771183
case AMDGPU_CHUNK_ID_SYNCOBJ_OUT:
11781184
r = amdgpu_cs_process_syncobj_out_dep(p, chunk);
11791185
if (r)
1180-
return r;
1186+
goto out;
11811187
break;
11821188
case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT:
11831189
r = amdgpu_cs_process_syncobj_timeline_in_dep(p, chunk);
11841190
if (r)
1185-
return r;
1191+
goto out;
11861192
break;
11871193
case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL:
11881194
r = amdgpu_cs_process_syncobj_timeline_out_dep(p, chunk);
11891195
if (r)
1190-
return r;
1196+
goto out;
11911197
break;
11921198
}
11931199
}
11941200

1195-
return 0;
1201+
out:
1202+
mutex_lock(&p->ctx->lock);
1203+
return r;
11961204
}
11971205

11981206
static void amdgpu_cs_post_dependencies(struct amdgpu_cs_parser *p)
@@ -1368,6 +1376,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
13681376
goto out;
13691377

13701378
r = amdgpu_cs_submit(&parser, cs);
1379+
13711380
out:
13721381
amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
13731382

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,
237237

238238
kref_init(&ctx->refcount);
239239
spin_lock_init(&ctx->ring_lock);
240+
mutex_init(&ctx->lock);
240241

241242
ctx->reset_counter = atomic_read(&adev->gpu_reset_counter);
242243
ctx->reset_counter_query = ctx->reset_counter;
@@ -357,6 +358,7 @@ static void amdgpu_ctx_fini(struct kref *ref)
357358
drm_dev_exit(idx);
358359
}
359360

361+
mutex_destroy(&ctx->lock);
360362
kfree(ctx);
361363
}
362364

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct amdgpu_ctx {
4949
bool preamble_presented;
5050
int32_t init_priority;
5151
int32_t override_priority;
52+
struct mutex lock;
5253
atomic_t guilty;
5354
unsigned long ras_counter_ce;
5455
unsigned long ras_counter_ue;

drivers/gpu/drm/drm_of.c

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -214,29 +214,6 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
214214
}
215215
EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
216216

217-
static int find_panel_or_bridge(struct device_node *node,
218-
struct drm_panel **panel,
219-
struct drm_bridge **bridge)
220-
{
221-
if (panel) {
222-
*panel = of_drm_find_panel(node);
223-
if (!IS_ERR(*panel))
224-
return 0;
225-
226-
/* Clear the panel pointer in case of error. */
227-
*panel = NULL;
228-
}
229-
230-
/* No panel found yet, check for a bridge next. */
231-
if (bridge) {
232-
*bridge = of_drm_find_bridge(node);
233-
if (*bridge)
234-
return 0;
235-
}
236-
237-
return -EPROBE_DEFER;
238-
}
239-
240217
/**
241218
* drm_of_find_panel_or_bridge - return connected panel or bridge device
242219
* @np: device tree node containing encoder output ports
@@ -259,44 +236,49 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
259236
struct drm_panel **panel,
260237
struct drm_bridge **bridge)
261238
{
262-
struct device_node *node;
263-
int ret;
239+
int ret = -EPROBE_DEFER;
240+
struct device_node *remote;
264241

265242
if (!panel && !bridge)
266243
return -EINVAL;
267-
268244
if (panel)
269245
*panel = NULL;
270-
if (bridge)
271-
*bridge = NULL;
272-
273-
/* Check for a graph on the device node first. */
274-
if (of_graph_is_present(np)) {
275-
node = of_graph_get_remote_node(np, port, endpoint);
276-
if (node) {
277-
ret = find_panel_or_bridge(node, panel, bridge);
278-
of_node_put(node);
279-
280-
if (!ret)
281-
return 0;
282-
}
283-
}
284246

285-
/* Otherwise check for any child node other than port/ports. */
286-
for_each_available_child_of_node(np, node) {
287-
if (of_node_name_eq(node, "port") ||
288-
of_node_name_eq(node, "ports"))
289-
continue;
247+
/*
248+
* of_graph_get_remote_node() produces a noisy error message if port
249+
* node isn't found and the absence of the port is a legit case here,
250+
* so at first we silently check whether graph presents in the
251+
* device-tree node.
252+
*/
253+
if (!of_graph_is_present(np))
254+
return -ENODEV;
290255

291-
ret = find_panel_or_bridge(node, panel, bridge);
292-
of_node_put(node);
256+
remote = of_graph_get_remote_node(np, port, endpoint);
257+
if (!remote)
258+
return -ENODEV;
259+
260+
if (panel) {
261+
*panel = of_drm_find_panel(remote);
262+
if (!IS_ERR(*panel))
263+
ret = 0;
264+
else
265+
*panel = NULL;
266+
}
267+
268+
/* No panel found yet, check for a bridge next. */
269+
if (bridge) {
270+
if (ret) {
271+
*bridge = of_drm_find_bridge(remote);
272+
if (*bridge)
273+
ret = 0;
274+
} else {
275+
*bridge = NULL;
276+
}
293277

294-
/* Stop at the first found occurrence. */
295-
if (!ret)
296-
return 0;
297278
}
298279

299-
return -EPROBE_DEFER;
280+
of_node_put(remote);
281+
return ret;
300282
}
301283
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
302284

drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static void rpi_touchscreen_i2c_write(struct rpi_touchscreen *ts,
229229

230230
ret = i2c_smbus_write_byte_data(ts->i2c, reg, val);
231231
if (ret)
232-
dev_err(&ts->dsi->dev, "I2C write failed: %d\n", ret);
232+
dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret);
233233
}
234234

235235
static int rpi_touchscreen_write(struct rpi_touchscreen *ts, u16 reg, u32 val)
@@ -265,7 +265,7 @@ static int rpi_touchscreen_noop(struct drm_panel *panel)
265265
return 0;
266266
}
267267

268-
static int rpi_touchscreen_enable(struct drm_panel *panel)
268+
static int rpi_touchscreen_prepare(struct drm_panel *panel)
269269
{
270270
struct rpi_touchscreen *ts = panel_to_ts(panel);
271271
int i;
@@ -295,6 +295,13 @@ static int rpi_touchscreen_enable(struct drm_panel *panel)
295295
rpi_touchscreen_write(ts, DSI_STARTDSI, 0x01);
296296
msleep(100);
297297

298+
return 0;
299+
}
300+
301+
static int rpi_touchscreen_enable(struct drm_panel *panel)
302+
{
303+
struct rpi_touchscreen *ts = panel_to_ts(panel);
304+
298305
/* Turn on the backlight. */
299306
rpi_touchscreen_i2c_write(ts, REG_PWM, 255);
300307

@@ -349,7 +356,7 @@ static int rpi_touchscreen_get_modes(struct drm_panel *panel,
349356
static const struct drm_panel_funcs rpi_touchscreen_funcs = {
350357
.disable = rpi_touchscreen_disable,
351358
.unprepare = rpi_touchscreen_noop,
352-
.prepare = rpi_touchscreen_noop,
359+
.prepare = rpi_touchscreen_prepare,
353360
.enable = rpi_touchscreen_enable,
354361
.get_modes = rpi_touchscreen_get_modes,
355362
};

drivers/gpu/drm/radeon/radeon_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int radeon_sync_resv(struct radeon_device *rdev,
9696
struct dma_fence *f;
9797
int r = 0;
9898

99-
dma_resv_for_each_fence(&cursor, resv, shared, f) {
99+
dma_resv_for_each_fence(&cursor, resv, !shared, f) {
100100
fence = to_radeon_fence(f);
101101
if (fence && fence->rdev == rdev)
102102
radeon_sync_fence(sync, fence);

drivers/gpu/drm/vc4/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
config DRM_VC4
33
tristate "Broadcom VC4 Graphics"
44
depends on ARCH_BCM || ARCH_BCM2835 || COMPILE_TEST
5+
# Make sure not 'y' when RASPBERRYPI_FIRMWARE is 'm'. This can only
6+
# happen when COMPILE_TEST=y, hence the added !RASPBERRYPI_FIRMWARE.
7+
depends on RASPBERRYPI_FIRMWARE || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
58
depends on DRM
69
depends on SND && SND_SOC
710
depends on COMMON_CLK

drivers/gpu/drm/vc4/vc4_dsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
846846
unsigned long phy_clock;
847847
int ret;
848848

849-
ret = pm_runtime_get_sync(dev);
849+
ret = pm_runtime_resume_and_get(dev);
850850
if (ret) {
851851
DRM_ERROR("Failed to runtime PM enable on DSI%d\n", dsi->variant->port);
852852
return;

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ vmw_buffer_object(struct ttm_buffer_object *bo)
4646
return container_of(bo, struct vmw_buffer_object, base);
4747
}
4848

49+
/**
50+
* bo_is_vmw - check if the buffer object is a &vmw_buffer_object
51+
* @bo: ttm buffer object to be checked
52+
*
53+
* Uses destroy function associated with the object to determine if this is
54+
* a &vmw_buffer_object.
55+
*
56+
* Returns:
57+
* true if the object is of &vmw_buffer_object type, false if not.
58+
*/
59+
static bool bo_is_vmw(struct ttm_buffer_object *bo)
60+
{
61+
return bo->destroy == &vmw_bo_bo_free ||
62+
bo->destroy == &vmw_gem_destroy;
63+
}
4964

5065
/**
5166
* vmw_bo_pin_in_placement - Validate a buffer to placement.
@@ -615,8 +630,9 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
615630

616631
ret = vmw_user_bo_synccpu_grab(vbo, arg->flags);
617632
vmw_bo_unreference(&vbo);
618-
if (unlikely(ret != 0 && ret != -ERESTARTSYS &&
619-
ret != -EBUSY)) {
633+
if (unlikely(ret != 0)) {
634+
if (ret == -ERESTARTSYS || ret == -EBUSY)
635+
return -EBUSY;
620636
DRM_ERROR("Failed synccpu grab on handle 0x%08x.\n",
621637
(unsigned int) arg->handle);
622638
return ret;
@@ -798,7 +814,7 @@ int vmw_dumb_create(struct drm_file *file_priv,
798814
void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
799815
{
800816
/* Is @bo embedded in a struct vmw_buffer_object? */
801-
if (vmw_bo_is_vmw_bo(bo))
817+
if (!bo_is_vmw(bo))
802818
return;
803819

804820
/* Kill any cached kernel maps before swapout */
@@ -822,7 +838,7 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,
822838
struct vmw_buffer_object *vbo;
823839

824840
/* Make sure @bo is embedded in a struct vmw_buffer_object? */
825-
if (vmw_bo_is_vmw_bo(bo))
841+
if (!bo_is_vmw(bo))
826842
return;
827843

828844
vbo = container_of(bo, struct vmw_buffer_object, base);
@@ -843,22 +859,3 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,
843859
if (mem->mem_type != VMW_PL_MOB && bo->resource->mem_type == VMW_PL_MOB)
844860
vmw_resource_unbind_list(vbo);
845861
}
846-
847-
/**
848-
* vmw_bo_is_vmw_bo - check if the buffer object is a &vmw_buffer_object
849-
* @bo: buffer object to be checked
850-
*
851-
* Uses destroy function associated with the object to determine if this is
852-
* a &vmw_buffer_object.
853-
*
854-
* Returns:
855-
* true if the object is of &vmw_buffer_object type, false if not.
856-
*/
857-
bool vmw_bo_is_vmw_bo(struct ttm_buffer_object *bo)
858-
{
859-
if (bo->destroy == &vmw_bo_bo_free ||
860-
bo->destroy == &vmw_gem_destroy)
861-
return true;
862-
863-
return false;
864-
}

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,10 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
998998
goto out_no_fman;
999999
}
10001000

1001-
drm_vma_offset_manager_init(&dev_priv->vma_manager,
1002-
DRM_FILE_PAGE_OFFSET_START,
1003-
DRM_FILE_PAGE_OFFSET_SIZE);
10041001
ret = ttm_device_init(&dev_priv->bdev, &vmw_bo_driver,
10051002
dev_priv->drm.dev,
10061003
dev_priv->drm.anon_inode->i_mapping,
1007-
&dev_priv->vma_manager,
1004+
dev_priv->drm.vma_offset_manager,
10081005
dev_priv->map_mode == vmw_dma_alloc_coherent,
10091006
false);
10101007
if (unlikely(ret != 0)) {
@@ -1174,7 +1171,6 @@ static void vmw_driver_unload(struct drm_device *dev)
11741171
vmw_devcaps_destroy(dev_priv);
11751172
vmw_vram_manager_fini(dev_priv);
11761173
ttm_device_fini(&dev_priv->bdev);
1177-
drm_vma_offset_manager_destroy(&dev_priv->vma_manager);
11781174
vmw_release_device_late(dev_priv);
11791175
vmw_fence_manager_takedown(dev_priv->fman);
11801176
if (dev_priv->capabilities & SVGA_CAP_IRQMASK)
@@ -1398,7 +1394,7 @@ vmw_get_unmapped_area(struct file *file, unsigned long uaddr,
13981394
struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
13991395

14001396
return drm_get_unmapped_area(file, uaddr, len, pgoff, flags,
1401-
&dev_priv->vma_manager);
1397+
dev_priv->drm.vma_offset_manager);
14021398
}
14031399

14041400
static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,

0 commit comments

Comments
 (0)