Skip to content

Commit 013d382

Browse files
committed
drm/vc4: Call drm_atomic_helper_shutdown() at shutdown time
Based on grepping through the source code these drivers appear to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard <mripard@kernel.org> Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230901163944.RFT.3.I10dbe099fb1059d304ba847d19fc45054f7ffe9f@changeid
1 parent ce3d99c commit 013d382

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

drivers/gpu/drm/vc4/vc4_drv.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,35 +324,37 @@ static int vc4_drm_bind(struct device *dev)
324324
if (!is_vc5) {
325325
ret = drmm_mutex_init(drm, &vc4->bin_bo_lock);
326326
if (ret)
327-
return ret;
327+
goto err;
328328

329329
ret = vc4_bo_cache_init(drm);
330330
if (ret)
331-
return ret;
331+
goto err;
332332
}
333333

334334
ret = drmm_mode_config_init(drm);
335335
if (ret)
336-
return ret;
336+
goto err;
337337

338338
if (!is_vc5) {
339339
ret = vc4_gem_init(drm);
340340
if (ret)
341-
return ret;
341+
goto err;
342342
}
343343

344344
node = of_find_compatible_node(NULL, NULL, "raspberrypi,bcm2835-firmware");
345345
if (node) {
346346
firmware = rpi_firmware_get(node);
347347
of_node_put(node);
348348

349-
if (!firmware)
350-
return -EPROBE_DEFER;
349+
if (!firmware) {
350+
ret = -EPROBE_DEFER;
351+
goto err;
352+
}
351353
}
352354

353355
ret = drm_aperture_remove_framebuffers(driver);
354356
if (ret)
355-
return ret;
357+
goto err;
356358

357359
if (firmware) {
358360
ret = rpi_firmware_property(firmware,
@@ -366,32 +368,33 @@ static int vc4_drm_bind(struct device *dev)
366368

367369
ret = component_bind_all(dev, drm);
368370
if (ret)
369-
return ret;
371+
goto err;
370372

371373
ret = devm_add_action_or_reset(dev, vc4_component_unbind_all, vc4);
372374
if (ret)
373-
return ret;
375+
goto err;
374376

375377
ret = vc4_plane_create_additional_planes(drm);
376378
if (ret)
377-
goto unbind_all;
379+
goto err;
378380

379381
ret = vc4_kms_load(drm);
380382
if (ret < 0)
381-
goto unbind_all;
383+
goto err;
382384

383385
drm_for_each_crtc(crtc, drm)
384386
vc4_crtc_disable_at_boot(crtc);
385387

386388
ret = drm_dev_register(drm, 0);
387389
if (ret < 0)
388-
goto unbind_all;
390+
goto err;
389391

390392
drm_fbdev_dma_setup(drm, 16);
391393

392394
return 0;
393395

394-
unbind_all:
396+
err:
397+
platform_set_drvdata(pdev, NULL);
395398
return ret;
396399
}
397400

@@ -401,6 +404,7 @@ static void vc4_drm_unbind(struct device *dev)
401404

402405
drm_dev_unplug(drm);
403406
drm_atomic_helper_shutdown(drm);
407+
dev_set_drvdata(dev, NULL);
404408
}
405409

406410
static const struct component_master_ops vc4_drm_ops = {
@@ -444,6 +448,11 @@ static void vc4_platform_drm_remove(struct platform_device *pdev)
444448
component_master_del(&pdev->dev, &vc4_drm_ops);
445449
}
446450

451+
static void vc4_platform_drm_shutdown(struct platform_device *pdev)
452+
{
453+
drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
454+
}
455+
447456
static const struct of_device_id vc4_of_match[] = {
448457
{ .compatible = "brcm,bcm2711-vc5", },
449458
{ .compatible = "brcm,bcm2835-vc4", },
@@ -455,6 +464,7 @@ MODULE_DEVICE_TABLE(of, vc4_of_match);
455464
static struct platform_driver vc4_platform_driver = {
456465
.probe = vc4_platform_drm_probe,
457466
.remove_new = vc4_platform_drm_remove,
467+
.shutdown = vc4_platform_drm_shutdown,
458468
.driver = {
459469
.name = "vc4-drm",
460470
.of_match_table = vc4_of_match,

0 commit comments

Comments
 (0)