public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: handle -EACCES runtime PM return code
@ 2014-02-10  5:58 Alexandre Courbot
  2014-02-10 12:34 ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Courbot @ 2014-02-10  5:58 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau, dri-devel, linux-kernel, gnurou, Alexandre Courbot

pm_runtime_get*() may return -EACCESS to indicate a device does not have
runtime PM enabled. This is the case when the nouveau.runpm parameter is
set to 0, and is not an error in that context. Handle this case without
failure.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c     | 2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 0e3270c3ffd2..1caef1fd139e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1048,7 +1048,7 @@ nouveau_crtc_set_config(struct drm_mode_set *set)
 
 	/* get a pm reference here */
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = drm_crtc_helper_set_config(set);
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 1674882d60d5..cddef546d9b0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -255,7 +255,7 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
 	}
 
 	ret = pm_runtime_get_sync(connector->dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return conn_status;
 
 	i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 8a4630a1fc45..2617168af244 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -696,7 +696,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
 
 	/* need to bring up power immediately if opening device */
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	get_task_comm(tmpname, current);
@@ -781,7 +781,7 @@ long nouveau_drm_ioctl(struct file *filp,
 	dev = file_priv->minor->dev;
 
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = drm_ioctl(filp, cmd, arg);
-- 
1.8.5.4


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

* Re: [PATCH] drm/nouveau: handle -EACCES runtime PM return code
  2014-02-10  5:58 [PATCH] drm/nouveau: handle -EACCES runtime PM return code Alexandre Courbot
@ 2014-02-10 12:34 ` Thierry Reding
  2014-02-11  4:14   ` Alexandre Courbot
  0 siblings, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2014-02-10 12:34 UTC (permalink / raw)
  To: Alexandre Courbot; +Cc: Ben Skeggs, nouveau, linux-kernel, dri-devel, gnurou

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]

On Mon, Feb 10, 2014 at 02:58:12PM +0900, Alexandre Courbot wrote:
> pm_runtime_get*() may return -EACCESS to indicate a device does not have

s/-EACCESS/-EACCES/

> runtime PM enabled. This is the case when the nouveau.runpm parameter is
> set to 0, and is not an error in that context. Handle this case without
> failure.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c     | 2 +-
>  drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
>  drivers/gpu/drm/nouveau/nouveau_drm.c       | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)

I'm not sure if the commit message is entirely accurate. Looking at the
various runtime power-management functions in nouveau_drm.c (such as
nouveau_pmops_runtime_suspend() for example), they seem to return
-EINVAL if the nouveau.runpm parameter is set to 0.

However it seems like -EACCES is indeed returned when runtime power-
management hasn't been enabled for a device. This is done automatically
for PCI devices, but not for platform devices. We don't support runtime
power-management on gk20a yet, therefore pm_runtime_enable() is never
called, causing disable_depth to remain at -1 and therefore runtime PM
helpers return -EACCES.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] drm/nouveau: handle -EACCES runtime PM return code
  2014-02-10 12:34 ` Thierry Reding
@ 2014-02-11  4:14   ` Alexandre Courbot
  2014-02-12  5:00     ` [PATCH v2] " Alexandre Courbot
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Courbot @ 2014-02-11  4:14 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Alexandre Courbot, Ben Skeggs, nouveau@lists.freedesktop.org,
	Linux Kernel Mailing List, dri-devel@lists.freedesktop.org

On Mon, Feb 10, 2014 at 9:34 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Mon, Feb 10, 2014 at 02:58:12PM +0900, Alexandre Courbot wrote:
>> pm_runtime_get*() may return -EACCESS to indicate a device does not have
>
> s/-EACCESS/-EACCES/

Oops.

>> runtime PM enabled. This is the case when the nouveau.runpm parameter is
>> set to 0, and is not an error in that context. Handle this case without
>> failure.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>  drivers/gpu/drm/nouveau/dispnv04/crtc.c     | 2 +-
>>  drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
>>  drivers/gpu/drm/nouveau/nouveau_drm.c       | 4 ++--
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> I'm not sure if the commit message is entirely accurate. Looking at the
> various runtime power-management functions in nouveau_drm.c (such as
> nouveau_pmops_runtime_suspend() for example), they seem to return
> -EINVAL if the nouveau.runpm parameter is set to 0.
>
> However it seems like -EACCES is indeed returned when runtime power-
> management hasn't been enabled for a device. This is done automatically
> for PCI devices, but not for platform devices. We don't support runtime
> power-management on gk20a yet, therefore pm_runtime_enable() is never
> called, causing disable_depth to remain at -1 and therefore runtime PM
> helpers return -EACCES.

I will fix the commit message, as indeed the -EACCES code is not
directly related to the runpm parameter, but rather to the fact
pm_runtime_enable() is not called for platform devices yet.

Do we however agree on the issue that this patch addresses, and the
way it addresses it?

Thanks,
Alex.

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

* [PATCH v2] drm/nouveau: handle -EACCES runtime PM return code
  2014-02-11  4:14   ` Alexandre Courbot
@ 2014-02-12  5:00     ` Alexandre Courbot
  2014-02-14  1:59       ` Ben Skeggs
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Courbot @ 2014-02-12  5:00 UTC (permalink / raw)
  To: Thierry Reding, Ben Skeggs
  Cc: Alexandre Courbot, nouveau, dri-devel, linux-kernel, gnurou

pm_runtime_get*() may return -EACCES to indicate a device does not have
runtime PM enabled. This is currently the case with platform devices
on Nouveau, and is not an error in that context. Handle this case
without failure.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Changes since v1:
- Fixed typo and inaccuracy in commit message

 drivers/gpu/drm/nouveau/dispnv04/crtc.c     | 2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 0e3270c3ffd2..1caef1fd139e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1048,7 +1048,7 @@ nouveau_crtc_set_config(struct drm_mode_set *set)
 
 	/* get a pm reference here */
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = drm_crtc_helper_set_config(set);
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 1674882d60d5..cddef546d9b0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -255,7 +255,7 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
 	}
 
 	ret = pm_runtime_get_sync(connector->dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return conn_status;
 
 	i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index b45fd1a0ab28..c677a09aac3f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -696,7 +696,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
 
 	/* need to bring up power immediately if opening device */
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	get_task_comm(tmpname, current);
@@ -781,7 +781,7 @@ long nouveau_drm_ioctl(struct file *filp,
 	dev = file_priv->minor->dev;
 
 	ret = pm_runtime_get_sync(dev->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = drm_ioctl(filp, cmd, arg);
-- 
1.8.5.4


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

* Re: [PATCH v2] drm/nouveau: handle -EACCES runtime PM return code
  2014-02-12  5:00     ` [PATCH v2] " Alexandre Courbot
@ 2014-02-14  1:59       ` Ben Skeggs
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Skeggs @ 2014-02-14  1:59 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Thierry Reding, Ben Skeggs, nouveau@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Alexandre Courbot

On Wed, Feb 12, 2014 at 3:00 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> pm_runtime_get*() may return -EACCES to indicate a device does not have
> runtime PM enabled. This is currently the case with platform devices
> on Nouveau, and is not an error in that context. Handle this case
> without failure.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Merged, thanks :)

> ---
> Changes since v1:
> - Fixed typo and inaccuracy in commit message
>
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c     | 2 +-
>  drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
>  drivers/gpu/drm/nouveau/nouveau_drm.c       | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> index 0e3270c3ffd2..1caef1fd139e 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> @@ -1048,7 +1048,7 @@ nouveau_crtc_set_config(struct drm_mode_set *set)
>
>         /* get a pm reference here */
>         ret = pm_runtime_get_sync(dev->dev);
> -       if (ret < 0)
> +       if (ret < 0 && ret != -EACCES)
>                 return ret;
>
>         ret = drm_crtc_helper_set_config(set);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index 1674882d60d5..cddef546d9b0 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -255,7 +255,7 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
>         }
>
>         ret = pm_runtime_get_sync(connector->dev->dev);
> -       if (ret < 0)
> +       if (ret < 0 && ret != -EACCES)
>                 return conn_status;
>
>         i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index b45fd1a0ab28..c677a09aac3f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -696,7 +696,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
>
>         /* need to bring up power immediately if opening device */
>         ret = pm_runtime_get_sync(dev->dev);
> -       if (ret < 0)
> +       if (ret < 0 && ret != -EACCES)
>                 return ret;
>
>         get_task_comm(tmpname, current);
> @@ -781,7 +781,7 @@ long nouveau_drm_ioctl(struct file *filp,
>         dev = file_priv->minor->dev;
>
>         ret = pm_runtime_get_sync(dev->dev);
> -       if (ret < 0)
> +       if (ret < 0 && ret != -EACCES)
>                 return ret;
>
>         ret = drm_ioctl(filp, cmd, arg);
> --
> 1.8.5.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2014-02-14  1:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-10  5:58 [PATCH] drm/nouveau: handle -EACCES runtime PM return code Alexandre Courbot
2014-02-10 12:34 ` Thierry Reding
2014-02-11  4:14   ` Alexandre Courbot
2014-02-12  5:00     ` [PATCH v2] " Alexandre Courbot
2014-02-14  1:59       ` Ben Skeggs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox