Skip to content

Commit ce3d99c

Browse files
committed
drm: Call drm_atomic_helper_shutdown() at shutdown time for misc drivers
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. All of the drivers in this patch were fairly straightforward to fix since they already had a call to drm_atomic_helper_shutdown() at remove/unbind time but were just lacking one at system shutdown. The only hitch is that some of these drivers use the component model to register/unregister their DRM devices. The shutdown callback is part of the original device. The typical solution here, based on how other DRM drivers do this, is to keep track of whether the device is bound based on drvdata. In most cases the drvdata is the drm_device, so we can just make sure it is NULL when the device is not bound. In some drivers, this required minor code changes. To make things simpler, drm_atomic_helper_shutdown() has been modified to consider a NULL drm_device as a noop in the patch ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"). Suggested-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Acked-by: Maxime Ripard <mripard@kernel.org> Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn> Tested-by: Sui Jingfeng <suijingfeng@loongson.cn> Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230901163944.RFT.2.I9115e5d094a43e687978b0699cc1fe9f2a3452ea@changeid
1 parent c478768 commit ce3d99c

File tree

19 files changed

+125
-0
lines changed

19 files changed

+125
-0
lines changed

drivers/gpu/drm/arm/display/komeda/komeda_drv.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ static void komeda_platform_remove(struct platform_device *pdev)
4545
devm_kfree(dev, mdrv);
4646
}
4747

48+
static void komeda_platform_shutdown(struct platform_device *pdev)
49+
{
50+
struct device *dev = &pdev->dev;
51+
struct komeda_drv *mdrv = dev_get_drvdata(dev);
52+
53+
komeda_kms_shutdown(mdrv->kms);
54+
}
55+
4856
static int komeda_platform_probe(struct platform_device *pdev)
4957
{
5058
struct device *dev = &pdev->dev;
@@ -142,6 +150,7 @@ static const struct dev_pm_ops komeda_pm_ops = {
142150
static struct platform_driver komeda_platform_driver = {
143151
.probe = komeda_platform_probe,
144152
.remove_new = komeda_platform_remove,
153+
.shutdown = komeda_platform_shutdown,
145154
.driver = {
146155
.name = "komeda",
147156
.of_match_table = komeda_of_match,

drivers/gpu/drm/arm/display/komeda/komeda_kms.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,10 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
340340
komeda_kms_cleanup_private_objs(kms);
341341
drm->dev_private = NULL;
342342
}
343+
344+
void komeda_kms_shutdown(struct komeda_kms_dev *kms)
345+
{
346+
struct drm_device *drm = &kms->base;
347+
348+
drm_atomic_helper_shutdown(drm);
349+
}

drivers/gpu/drm/arm/display/komeda/komeda_kms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,6 @@ void komeda_crtc_flush_and_wait_for_flip_done(struct komeda_crtc *kcrtc,
190190

191191
struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev);
192192
void komeda_kms_detach(struct komeda_kms_dev *kms);
193+
void komeda_kms_shutdown(struct komeda_kms_dev *kms);
193194

194195
#endif /*_KOMEDA_KMS_H_*/

drivers/gpu/drm/arm/hdlcd_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ static void hdlcd_remove(struct platform_device *pdev)
372372
component_master_del(&pdev->dev, &hdlcd_master_ops);
373373
}
374374

375+
static void hdlcd_shutdown(struct platform_device *pdev)
376+
{
377+
drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
378+
}
379+
375380
static const struct of_device_id hdlcd_of_match[] = {
376381
{ .compatible = "arm,hdlcd" },
377382
{},
@@ -399,6 +404,7 @@ static SIMPLE_DEV_PM_OPS(hdlcd_pm_ops, hdlcd_pm_suspend, hdlcd_pm_resume);
399404
static struct platform_driver hdlcd_platform_driver = {
400405
.probe = hdlcd_probe,
401406
.remove_new = hdlcd_remove,
407+
.shutdown = hdlcd_shutdown,
402408
.driver = {
403409
.name = "hdlcd",
404410
.pm = &hdlcd_pm_ops,

drivers/gpu/drm/arm/malidp_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,11 @@ static void malidp_platform_remove(struct platform_device *pdev)
941941
component_master_del(&pdev->dev, &malidp_master_ops);
942942
}
943943

944+
static void malidp_platform_shutdown(struct platform_device *pdev)
945+
{
946+
drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
947+
}
948+
944949
static int __maybe_unused malidp_pm_suspend(struct device *dev)
945950
{
946951
struct drm_device *drm = dev_get_drvdata(dev);
@@ -982,6 +987,7 @@ static const struct dev_pm_ops malidp_pm_ops = {
982987
static struct platform_driver malidp_platform_driver = {
983988
.probe = malidp_platform_probe,
984989
.remove_new = malidp_platform_remove,
990+
.shutdown = malidp_platform_shutdown,
985991
.driver = {
986992
.name = "mali-dp",
987993
.pm = &malidp_pm_ops,

drivers/gpu/drm/ast/ast_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ static void ast_pci_remove(struct pci_dev *pdev)
125125
drm_atomic_helper_shutdown(dev);
126126
}
127127

128+
static void ast_pci_shutdown(struct pci_dev *pdev)
129+
{
130+
drm_atomic_helper_shutdown(pci_get_drvdata(pdev));
131+
}
132+
128133
static int ast_drm_freeze(struct drm_device *dev)
129134
{
130135
int error;
@@ -209,6 +214,7 @@ static struct pci_driver ast_pci_driver = {
209214
.id_table = ast_pciidlist,
210215
.probe = ast_pci_probe,
211216
.remove = ast_pci_remove,
217+
.shutdown = ast_pci_shutdown,
212218
.driver.pm = &ast_pm_ops,
213219
};
214220

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,11 @@ static void atmel_hlcdc_dc_drm_remove(struct platform_device *pdev)
782782
drm_dev_put(ddev);
783783
}
784784

785+
static void atmel_hlcdc_dc_drm_shutdown(struct platform_device *pdev)
786+
{
787+
drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
788+
}
789+
785790
static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
786791
{
787792
struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -825,6 +830,7 @@ static const struct of_device_id atmel_hlcdc_dc_of_match[] = {
825830
static struct platform_driver atmel_hlcdc_dc_platform_driver = {
826831
.probe = atmel_hlcdc_dc_drm_probe,
827832
.remove_new = atmel_hlcdc_dc_drm_remove,
833+
.shutdown = atmel_hlcdc_dc_drm_shutdown,
828834
.driver = {
829835
.name = "atmel-hlcdc-display-controller",
830836
.pm = pm_sleep_ptr(&atmel_hlcdc_dc_drm_pm_ops),

drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,17 @@ static void fsl_dcu_drm_remove(struct platform_device *pdev)
356356
clk_unregister(fsl_dev->pix_clk);
357357
}
358358

359+
static void fsl_dcu_drm_shutdown(struct platform_device *pdev)
360+
{
361+
struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
362+
363+
drm_atomic_helper_shutdown(fsl_dev->drm);
364+
}
365+
359366
static struct platform_driver fsl_dcu_drm_platform_driver = {
360367
.probe = fsl_dcu_drm_probe,
361368
.remove_new = fsl_dcu_drm_remove,
369+
.shutdown = fsl_dcu_drm_shutdown,
362370
.driver = {
363371
.name = "fsl-dcu",
364372
.pm = &fsl_dcu_drm_pm_ops,

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ static void hibmc_pci_remove(struct pci_dev *pdev)
357357
hibmc_unload(dev);
358358
}
359359

360+
static void hibmc_pci_shutdown(struct pci_dev *pdev)
361+
{
362+
drm_atomic_helper_shutdown(pci_get_drvdata(pdev));
363+
}
364+
360365
static const struct pci_device_id hibmc_pci_table[] = {
361366
{ PCI_VDEVICE(HUAWEI, 0x1711) },
362367
{0,}
@@ -367,6 +372,7 @@ static struct pci_driver hibmc_pci_driver = {
367372
.id_table = hibmc_pci_table,
368373
.probe = hibmc_pci_probe,
369374
.remove = hibmc_pci_remove,
375+
.shutdown = hibmc_pci_shutdown,
370376
.driver.pm = &hibmc_pm_ops,
371377
};
372378

drivers/gpu/drm/hyperv/hyperv_drm_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ static void hyperv_vmbus_remove(struct hv_device *hdev)
178178
vmbus_free_mmio(hv->mem->start, hv->fb_size);
179179
}
180180

181+
static void hyperv_vmbus_shutdown(struct hv_device *hdev)
182+
{
183+
drm_atomic_helper_shutdown(hv_get_drvdata(hdev));
184+
}
185+
181186
static int hyperv_vmbus_suspend(struct hv_device *hdev)
182187
{
183188
struct drm_device *dev = hv_get_drvdata(hdev);
@@ -220,6 +225,7 @@ static struct hv_driver hyperv_hv_driver = {
220225
.id_table = hyperv_vmbus_tbl,
221226
.probe = hyperv_vmbus_probe,
222227
.remove = hyperv_vmbus_remove,
228+
.shutdown = hyperv_vmbus_shutdown,
223229
.suspend = hyperv_vmbus_suspend,
224230
.resume = hyperv_vmbus_resume,
225231
.driver = {

0 commit comments

Comments
 (0)