dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/backlight: Fix LVDS backlight detection on some laptops
@ 2022-02-04 18:05 Lyude Paul
  2022-02-08 12:21 ` Karol Herbst
  0 siblings, 1 reply; 2+ messages in thread
From: Lyude Paul @ 2022-02-04 18:05 UTC (permalink / raw)
  To: nouveau
  Cc: Karol Herbst, David Airlie, open list, stable, dri-devel, Ben Skeggs

It seems that some laptops will report having both an eDP and LVDS
connector, even though only the LVDS connector is actually hooked up. This
can lead to issues with backlight registration if the eDP connector ends up
getting registered before the LVDS connector, as the backlight device will
then be registered to the eDP connector instead of the LVDS connector.

So, fix this by only registering the backlight on connectors that are
reported as being connected.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Fixes: 6eca310e8924 ("drm/nouveau/kms/nv50-: Add basic DPCD backlight support for nouveau")
Bugzilla: https://gitlab.freedesktop.org/drm/nouveau/-/issues/137
Cc: <stable@vger.kernel.org> # v5.15+
---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index ae2f2abc8f5a..6af12dc99d7f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -294,7 +294,8 @@ nv50_backlight_init(struct nouveau_backlight *bl,
 	struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
 	struct nvif_object *device = &drm->client.device.object;
 
-	if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(ffs(nv_encoder->dcb->or) - 1)))
+	if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(ffs(nv_encoder->dcb->or) - 1)) ||
+	    nv_conn->base.status != connector_status_connected)
 		return -ENODEV;
 
 	if (nv_conn->type == DCB_CONNECTOR_eDP) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/nouveau/backlight: Fix LVDS backlight detection on some laptops
  2022-02-04 18:05 [PATCH] drm/nouveau/backlight: Fix LVDS backlight detection on some laptops Lyude Paul
@ 2022-02-08 12:21 ` Karol Herbst
  0 siblings, 0 replies; 2+ messages in thread
From: Karol Herbst @ 2022-02-08 12:21 UTC (permalink / raw)
  To: Lyude Paul
  Cc: David Airlie, nouveau, open list, stable, dri-devel, Ben Skeggs

On Fri, Feb 4, 2022 at 7:05 PM Lyude Paul <lyude@redhat.com> wrote:
>
> It seems that some laptops will report having both an eDP and LVDS
> connector, even though only the LVDS connector is actually hooked up. This
> can lead to issues with backlight registration if the eDP connector ends up
> getting registered before the LVDS connector, as the backlight device will
> then be registered to the eDP connector instead of the LVDS connector.
>
> So, fix this by only registering the backlight on connectors that are
> reported as being connected.
>

I think the patch might risk breaking muxed systems where we have two
GPUs, but.. the systems I know of have different ways of controlling
the backlight anyway. So unless there is something I missed this is

Reviewed-by: Karol Herbst <kherbst@redhat.com>

> Signed-off-by: Lyude Paul <lyude@redhat.com>
> Fixes: 6eca310e8924 ("drm/nouveau/kms/nv50-: Add basic DPCD backlight support for nouveau")
> Bugzilla: https://gitlab.freedesktop.org/drm/nouveau/-/issues/137
> Cc: <stable@vger.kernel.org> # v5.15+
> ---
>  drivers/gpu/drm/nouveau/nouveau_backlight.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index ae2f2abc8f5a..6af12dc99d7f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -294,7 +294,8 @@ nv50_backlight_init(struct nouveau_backlight *bl,
>         struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
>         struct nvif_object *device = &drm->client.device.object;
>
> -       if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(ffs(nv_encoder->dcb->or) - 1)))
> +       if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(ffs(nv_encoder->dcb->or) - 1)) ||
> +           nv_conn->base.status != connector_status_connected)
>                 return -ENODEV;
>
>         if (nv_conn->type == DCB_CONNECTOR_eDP) {
> --
> 2.34.1
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-08 12:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 18:05 [PATCH] drm/nouveau/backlight: Fix LVDS backlight detection on some laptops Lyude Paul
2022-02-08 12:21 ` Karol Herbst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).