All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: Fix drm poll_helper handling
@ 2017-05-15  9:04 ` Peter Ujfalusi
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2017-05-15  9:04 UTC (permalink / raw)
  To: bskeggs, airlied
  Cc: dri-devel, nouveau, linux-kernel, Lyude Paul, Dave Airlie,
	Gleb Nemshilov

Commit cae9ff036eea effectively disabled the drm poll_helper by checking
the wrong flag to see if the driver should enable the poll or not:
mode_config.poll_enabled is only set to true by poll_init and it is not
indicating if the poll is enabled or not.
nouveau_display_create() will initialize the poll and going to disable it
right away. After poll_init() the mode_config.poll_enabled will be true,
but the poll itself is disabled.

To avoid the race caused by calling the poll_enable() from different paths,
this patch will enable the poll from one place, in the
nouveau_display_hpd_work().

In case the pm_runtime is disabled we will enable the poll in
nouveau_drm_load() once.

Fixes: cae9ff036eea ("drm/nouveau: Don't enabling polling twice on runtime resume")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gleb Nemshilov <gleb@fastmail.com>
---
Hi,

this patch was created and tested in connection of:
https://bugs.freedesktop.org/show_bug.cgi?id=98690

Regards,
Peter

 drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++----
 drivers/gpu/drm/nouveau/nouveau_drm.c     | 6 +++---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 21b10f9840c9..549763f5e17d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct *work)
 	pm_runtime_get_sync(drm->dev->dev);
 
 	drm_helper_hpd_irq_event(drm->dev);
+	/* enable polling for external displays */
+	drm_kms_helper_poll_enable(drm->dev);
 
 	pm_runtime_mark_last_busy(drm->dev->dev);
 	pm_runtime_put_sync(drm->dev->dev);
@@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
 	if (ret)
 		return ret;
 
-	/* enable polling for external displays */
-	if (!dev->mode_config.poll_enabled)
-		drm_kms_helper_poll_enable(dev);
-
 	/* enable hotplug interrupts */
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 		struct nouveau_connector *conn = nouveau_connector(connector);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 2b6ac24ce690..36268e1802b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 		pm_runtime_allow(dev->dev);
 		pm_runtime_mark_last_busy(dev->dev);
 		pm_runtime_put(dev->dev);
+	} else {
+		/* enable polling for external displays */
+		drm_kms_helper_poll_enable(dev);
 	}
 	return 0;
 
@@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
 
 	ret = nouveau_do_resume(drm_dev, true);
 
-	if (!drm_dev->mode_config.poll_enabled)
-		drm_kms_helper_poll_enable(drm_dev);
-
 	/* do magic */
 	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
-- 
2.12.2

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

* [PATCH] drm/nouveau: Fix drm poll_helper handling
@ 2017-05-15  9:04 ` Peter Ujfalusi
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2017-05-15  9:04 UTC (permalink / raw)
  To: bskeggs, airlied
  Cc: dri-devel, nouveau, linux-kernel, Lyude Paul, Dave Airlie,
	Gleb Nemshilov

Commit cae9ff036eea effectively disabled the drm poll_helper by checking
the wrong flag to see if the driver should enable the poll or not:
mode_config.poll_enabled is only set to true by poll_init and it is not
indicating if the poll is enabled or not.
nouveau_display_create() will initialize the poll and going to disable it
right away. After poll_init() the mode_config.poll_enabled will be true,
but the poll itself is disabled.

To avoid the race caused by calling the poll_enable() from different paths,
this patch will enable the poll from one place, in the
nouveau_display_hpd_work().

In case the pm_runtime is disabled we will enable the poll in
nouveau_drm_load() once.

Fixes: cae9ff036eea ("drm/nouveau: Don't enabling polling twice on runtime resume")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gleb Nemshilov <gleb@fastmail.com>
---
Hi,

this patch was created and tested in connection of:
https://bugs.freedesktop.org/show_bug.cgi?id=98690

Regards,
Peter

 drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++----
 drivers/gpu/drm/nouveau/nouveau_drm.c     | 6 +++---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 21b10f9840c9..549763f5e17d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct *work)
 	pm_runtime_get_sync(drm->dev->dev);
 
 	drm_helper_hpd_irq_event(drm->dev);
+	/* enable polling for external displays */
+	drm_kms_helper_poll_enable(drm->dev);
 
 	pm_runtime_mark_last_busy(drm->dev->dev);
 	pm_runtime_put_sync(drm->dev->dev);
@@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
 	if (ret)
 		return ret;
 
-	/* enable polling for external displays */
-	if (!dev->mode_config.poll_enabled)
-		drm_kms_helper_poll_enable(dev);
-
 	/* enable hotplug interrupts */
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 		struct nouveau_connector *conn = nouveau_connector(connector);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 2b6ac24ce690..36268e1802b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 		pm_runtime_allow(dev->dev);
 		pm_runtime_mark_last_busy(dev->dev);
 		pm_runtime_put(dev->dev);
+	} else {
+		/* enable polling for external displays */
+		drm_kms_helper_poll_enable(dev);
 	}
 	return 0;
 
@@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
 
 	ret = nouveau_do_resume(drm_dev, true);
 
-	if (!drm_dev->mode_config.poll_enabled)
-		drm_kms_helper_poll_enable(drm_dev);
-
 	/* do magic */
 	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
-- 
2.12.2

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

* Re: [PATCH] drm/nouveau: Fix drm poll_helper handling
  2017-05-15  9:04 ` Peter Ujfalusi
@ 2017-05-15 14:11   ` Lyude Paul
  -1 siblings, 0 replies; 4+ messages in thread
From: Lyude Paul @ 2017-05-15 14:11 UTC (permalink / raw)
  To: Peter Ujfalusi, bskeggs, airlied
  Cc: dri-devel, nouveau, linux-kernel, Dave Airlie, Gleb Nemshilov

Good catch!

Reviewed-by: Lyude <lyude@redhat.com>

On Mon, 2017-05-15 at 12:04 +0300, Peter Ujfalusi wrote:
> Commit cae9ff036eea effectively disabled the drm poll_helper by
> checking
> the wrong flag to see if the driver should enable the poll or not:
> mode_config.poll_enabled is only set to true by poll_init and it is
> not
> indicating if the poll is enabled or not.
> nouveau_display_create() will initialize the poll and going to
> disable it
> right away. After poll_init() the mode_config.poll_enabled will be
> true,
> but the poll itself is disabled.
> 
> To avoid the race caused by calling the poll_enable() from different
> paths,
> this patch will enable the poll from one place, in the
> nouveau_display_hpd_work().
> 
> In case the pm_runtime is disabled we will enable the poll in
> nouveau_drm_load() once.
> 
> Fixes: cae9ff036eea ("drm/nouveau: Don't enabling polling twice on
> runtime resume")
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gleb Nemshilov <gleb@fastmail.com>
> ---
> Hi,
> 
> this patch was created and tested in connection of:
> https://bugs.freedesktop.org/show_bug.cgi?id=98690
> 
> Regards,
> Peter
> 
>  drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++----
>  drivers/gpu/drm/nouveau/nouveau_drm.c     | 6 +++---
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c
> b/drivers/gpu/drm/nouveau/nouveau_display.c
> index 21b10f9840c9..549763f5e17d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct
> *work)
>  	pm_runtime_get_sync(drm->dev->dev);
>  
>  	drm_helper_hpd_irq_event(drm->dev);
> +	/* enable polling for external displays */
> +	drm_kms_helper_poll_enable(drm->dev);
>  
>  	pm_runtime_mark_last_busy(drm->dev->dev);
>  	pm_runtime_put_sync(drm->dev->dev);
> @@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
>  	if (ret)
>  		return ret;
>  
> -	/* enable polling for external displays */
> -	if (!dev->mode_config.poll_enabled)
> -		drm_kms_helper_poll_enable(dev);
> -
>  	/* enable hotplug interrupts */
>  	list_for_each_entry(connector, &dev-
> >mode_config.connector_list, head) {
>  		struct nouveau_connector *conn =
> nouveau_connector(connector);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
> b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 2b6ac24ce690..36268e1802b5 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned
> long flags)
>  		pm_runtime_allow(dev->dev);
>  		pm_runtime_mark_last_busy(dev->dev);
>  		pm_runtime_put(dev->dev);
> +	} else {
> +		/* enable polling for external displays */
> +		drm_kms_helper_poll_enable(dev);
>  	}
>  	return 0;
>  
> @@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
>  
>  	ret = nouveau_do_resume(drm_dev, true);
>  
> -	if (!drm_dev->mode_config.poll_enabled)
> -		drm_kms_helper_poll_enable(drm_dev);
> -
>  	/* do magic */
>  	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
>  	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);

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

* Re: [PATCH] drm/nouveau: Fix drm poll_helper handling
@ 2017-05-15 14:11   ` Lyude Paul
  0 siblings, 0 replies; 4+ messages in thread
From: Lyude Paul @ 2017-05-15 14:11 UTC (permalink / raw)
  To: Peter Ujfalusi, bskeggs, airlied
  Cc: nouveau, Gleb Nemshilov, linux-kernel, dri-devel, Dave Airlie

Good catch!

Reviewed-by: Lyude <lyude@redhat.com>

On Mon, 2017-05-15 at 12:04 +0300, Peter Ujfalusi wrote:
> Commit cae9ff036eea effectively disabled the drm poll_helper by
> checking
> the wrong flag to see if the driver should enable the poll or not:
> mode_config.poll_enabled is only set to true by poll_init and it is
> not
> indicating if the poll is enabled or not.
> nouveau_display_create() will initialize the poll and going to
> disable it
> right away. After poll_init() the mode_config.poll_enabled will be
> true,
> but the poll itself is disabled.
> 
> To avoid the race caused by calling the poll_enable() from different
> paths,
> this patch will enable the poll from one place, in the
> nouveau_display_hpd_work().
> 
> In case the pm_runtime is disabled we will enable the poll in
> nouveau_drm_load() once.
> 
> Fixes: cae9ff036eea ("drm/nouveau: Don't enabling polling twice on
> runtime resume")
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gleb Nemshilov <gleb@fastmail.com>
> ---
> Hi,
> 
> this patch was created and tested in connection of:
> https://bugs.freedesktop.org/show_bug.cgi?id=98690
> 
> Regards,
> Peter
> 
>  drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++----
>  drivers/gpu/drm/nouveau/nouveau_drm.c     | 6 +++---
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c
> b/drivers/gpu/drm/nouveau/nouveau_display.c
> index 21b10f9840c9..549763f5e17d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct
> *work)
>  	pm_runtime_get_sync(drm->dev->dev);
>  
>  	drm_helper_hpd_irq_event(drm->dev);
> +	/* enable polling for external displays */
> +	drm_kms_helper_poll_enable(drm->dev);
>  
>  	pm_runtime_mark_last_busy(drm->dev->dev);
>  	pm_runtime_put_sync(drm->dev->dev);
> @@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
>  	if (ret)
>  		return ret;
>  
> -	/* enable polling for external displays */
> -	if (!dev->mode_config.poll_enabled)
> -		drm_kms_helper_poll_enable(dev);
> -
>  	/* enable hotplug interrupts */
>  	list_for_each_entry(connector, &dev-
> >mode_config.connector_list, head) {
>  		struct nouveau_connector *conn =
> nouveau_connector(connector);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
> b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 2b6ac24ce690..36268e1802b5 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned
> long flags)
>  		pm_runtime_allow(dev->dev);
>  		pm_runtime_mark_last_busy(dev->dev);
>  		pm_runtime_put(dev->dev);
> +	} else {
> +		/* enable polling for external displays */
> +		drm_kms_helper_poll_enable(dev);
>  	}
>  	return 0;
>  
> @@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
>  
>  	ret = nouveau_do_resume(drm_dev, true);
>  
> -	if (!drm_dev->mode_config.poll_enabled)
> -		drm_kms_helper_poll_enable(drm_dev);
> -
>  	/* do magic */
>  	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
>  	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-05-15 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15  9:04 [PATCH] drm/nouveau: Fix drm poll_helper handling Peter Ujfalusi
2017-05-15  9:04 ` Peter Ujfalusi
2017-05-15 14:11 ` Lyude Paul
2017-05-15 14:11   ` Lyude Paul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.