Skip to contentSkip to conversation

drm/nouveau: handle -EACCES runtime PM return code

PATCH Superseded Alexandre Courbot 4 participants 5 messages Feb 10, 2014 – Feb 14, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau: handle -EACCES runtime PM return code

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.

---
 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(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +1 -1
index 0e3270c3ffd2..1caef1fd139e 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
index 1674882d60d5..cddef546d9b0 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -2
index 8a4630a1fc45..2617168af244 100644
@@ -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);
Signature · 1 line
1.8.5.4
#1 lore raw
Quoted 1 line · Alexandre Courbot

pm_runtime_get*() may return -EACCESS to indicate a device does not have

s/-EACCESS/-EACCES/

Quoted 10 lines

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.

---
 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

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 4 lines · Thierry Reding
Quoted 1 line · Alexandre Courbot

pm_runtime_get*() may return -EACCESS to indicate a device does not have

s/-EACCESS/-EACCES/

Oops.

Quoted 16 lines
Quoted 10 lines

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.

---
 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.

Quoted 6 lines

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.

#3 lore raw

PATCH v2 1/1 drm/nouveau: handle -EACCES runtime PM return code

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.

---
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(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +1 -1
index 0e3270c3ffd2..1caef1fd139e 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
index 1674882d60d5..cddef546d9b0 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -2
index b45fd1a0ab28..c677a09aac3f 100644
@@ -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);
Signature · 1 line
1.8.5.4
Applied
#4 lore raw
Quoted 6 lines · Alexandre Courbot

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.

Merged, thanks :)

Quoted 64 lines

---
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(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +1 -1
index 0e3270c3ffd2..1caef1fd139e 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
index 1674882d60d5..cddef546d9b0 100644
@@ -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);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -3
index b45fd1a0ab28..c677a09aac3f 100644
@@ -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
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel