drm/nouveau: don't attempt to schedule hpd_work on headless cards
Subsystems (3)
PATCH v2 1/1 drm/nouveau: don't attempt to schedule hpd_work on headless cards
If the card doesn't have display hardware, hpd_work and hpd_lock are left uninitialized which causes BUG when attempting to schedule hpd_work on runtime PM resume.
Fix it by adding headless flag to DRM and skip any hpd if it's set.
---
v2: drop extra checks in nouveau_display_hpd_work() and nouveau_connector_hpd()
drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 6 +++++- drivers/gpu/drm/nouveau/nouveau_drv.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/disp.c +1 -1
@@ -68,7 +68,7 @@ nv04_display_fini(struct drm_device *dev, bool runtime, bool suspend)if (nv_two_heads (dev))NVWriteCRTC (dev,1 ,NV_PCRTC_INTR_EN_0 ,0 ); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);if (!suspend)
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -1
@@ -2680,7 +2680,7 @@ nv50_display_fini(struct drm_device *dev, bool runtime, bool suspend)nv50_mstm_fini (nouveau_encoder (encoder)); } -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work); }
drivers/gpu/drm/nouveau/nouveau_display.c +5 -1
@@ -450,6 +450,9 @@ nouveau_display_hpd_resume(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +if (drm->headless) +return ; +spin_lock_irq (&drm->hpd_lock); drm->hpd_pending = ~0 ;spin_unlock_irq (&drm->hpd_lock);
@@ -635,7 +638,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) }drm_connector_list_iter_end (&conn_iter); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);drm_kms_helper_poll_disable (dev);
@@ -729,6 +732,7 @@ nouveau_display_create(struct drm_device *dev)/* no display hw */ if (ret == -ENODEV ) { ret =0 ; + drm->headless = true; goto disp_create_err; }
drivers/gpu/drm/nouveau/nouveau_drv.h +1 -0
@@ -276,6 +276,7 @@ struct nouveau_drm {/* modesetting */ struct nvbios vbios;struct nouveau_display *display; +bool headless;struct work_struct hpd_work;spinlock_t hpd_lock;u32 hpd_pending;
Signature · 1 line
2.45.2
Quoted 9 lines · Vasily Khoruzhick
If the card doesn't have display hardware,
hpd_workandhpd_lockare left uninitialized which causes BUG when attempting to schedulehpd_workon runtime PM resume.Fix it by adding headless flag to DRM and skip any hpd if it's set.
Fixes ae1aadb1eb8d ("nouveau: don't fail driver load if no display hw present.")Signed-off-by Vasily Khoruzhick <[email protected]>
Quoted 79 lines
---
v2: drop extra checks innouveau_display_hpd_work()andnouveau_connector_hpd()drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 6 +++++- drivers/gpu/drm/nouveau/nouveau_drv.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)drivers/gpu/drm/nouveau/dispnv04/disp.c +1
-1@@ -68,7 +68,7 @@ nv04_display_fini(struct drm_device *dev, bool runtime, bool suspend)if (nv_two_heads (dev))NVWriteCRTC (dev,1 ,NV_PCRTC_INTR_EN_0 ,0 ); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);if (!suspend)drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1@@ -2680,7 +2680,7 @@ nv50_display_fini(struct drm_device *dev, bool runtime, bool suspend)nv50_mstm_fini (nouveau_encoder (encoder)); } -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work); }drivers/gpu/drm/nouveau/nouveau_display.c +5
-1@@ -450,6 +450,9 @@ nouveau_display_hpd_resume(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +if (drm->headless) +return ; +spin_lock_irq (&drm->hpd_lock); drm->hpd_pending = ~0 ;spin_unlock_irq (&drm->hpd_lock);@@ -635,7 +638,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) }drm_connector_list_iter_end (&conn_iter); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);drm_kms_helper_poll_disable (dev);@@ -729,6 +732,7 @@ nouveau_display_create(struct drm_device *dev)/* no display hw */ if (ret == -ENODEV ) { ret =0 ; + drm->headless = true; goto disp_create_err; }drivers/gpu/drm/nouveau/nouveau_drv.h +1
-0@@ -276,6 +276,7 @@ struct nouveau_drm {/* modesetting */ struct nvbios vbios;struct nouveau_display *display; +bool headless;struct work_struct hpd_work;spinlock_t hpd_lock;u32 hpd_pending;
Danilo Krummrich
AppliedQuoted 9 lines · Vasily Khoruzhick
If the card doesn't have display hardware,
hpd_workandhpd_lockare left uninitialized which causes BUG when attempting to schedulehpd_workon runtime PM resume.Fix it by adding headless flag to DRM and skip any hpd if it's set.
Fixes ae1aadb1eb8d ("nouveau: don't fail driver load if no display hw present.")Signed-off-by Vasily Khoruzhick <[email protected]>
Applied to drm-misc-fixes, thanks!
Quoted 79 lines
---
v2: drop extra checks innouveau_display_hpd_work()andnouveau_connector_hpd()drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 6 +++++- drivers/gpu/drm/nouveau/nouveau_drv.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)drivers/gpu/drm/nouveau/dispnv04/disp.c +1
-1@@ -68,7 +68,7 @@ nv04_display_fini(struct drm_device *dev, bool runtime, bool suspend)if (nv_two_heads (dev))NVWriteCRTC (dev,1 ,NV_PCRTC_INTR_EN_0 ,0 ); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);if (!suspend)drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1@@ -2680,7 +2680,7 @@ nv50_display_fini(struct drm_device *dev, bool runtime, bool suspend)nv50_mstm_fini (nouveau_encoder (encoder)); } -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work); }drivers/gpu/drm/nouveau/nouveau_display.c +5
-1@@ -450,6 +450,9 @@ nouveau_display_hpd_resume(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +if (drm->headless) +return ; +spin_lock_irq (&drm->hpd_lock); drm->hpd_pending = ~0 ;spin_unlock_irq (&drm->hpd_lock);@@ -635,7 +638,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) }drm_connector_list_iter_end (&conn_iter); -if (!runtime) +if (!runtime && !drm->headless)cancel_work_sync (&drm->hpd_work);drm_kms_helper_poll_disable (dev);@@ -729,6 +732,7 @@ nouveau_display_create(struct drm_device *dev)/* no display hw */ if (ret == -ENODEV ) { ret =0 ; + drm->headless = true; goto disp_create_err; }drivers/gpu/drm/nouveau/nouveau_drv.h +1
-0@@ -276,6 +276,7 @@ struct nouveau_drm {/* modesetting */ struct nvbios vbios;struct nouveau_display *display; +bool headless;struct work_struct hpd_work;spinlock_t hpd_lock;u32 hpd_pending;