Skip to contentSkip to conversation

drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())

PATCH Applied Noralf Trønnes 5 participants 8 messages Feb 8, 2019 – Feb 21, 2019 2 messages not in the archive

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

v2 cover drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())

This series makes drm_dev_unplug() compatible with the upcoming devm_drm_dev_init(), fixes a double drm_dev_unregister() situation and simplifies the drm_device ref handling wrt to the last fd closed after unregister.

The first version of this patchset removed drm_dev_unplug(), see here for the discussion as to why it is kept for the time being:

[2/6] drm/drv: Prepare to remove drm_dev_unplug()
https://patchwork.freedesktop.org/patch/282902/

Noralf.

Noralf Trønnes (2):
drm: Fix drm_release() and device unplug drm/drv: drm_dev_unplug(): Move out drm_dev_put() call

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 drivers/gpu/drm/drm_drv.c               | 5 -----
 drivers/gpu/drm/drm_file.c              | 6 ++----
 drivers/gpu/drm/udl/udl_drv.c           | 1 +
 drivers/gpu/drm/xen/xen_drm_front.c     | 1 +
 5 files changed, 5 insertions(+), 9 deletions(-)
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20190208140103.28919-1-noralf-L59+Z2yzLopAfugRpC6u6w@public.gmane.org

#2 lore raw

PATCH v2 1/2 drm: Fix drm_release() and device unplug

If userspace has open fd(s) when drm_dev_unplug() is run, it will result in drm_dev_unregister() being called twice. First in drm_dev_unplug() and then later in drm_release() through the call to drm_put_dev().

Since userspace already holds a ref on drm_device through the drm_minor, it's not necessary to add extra ref counting based on no open file handles. Instead just drm_dev_put() unconditionally in drm_dev_unplug().

We now have this:
- Userpace holds a ref on drm_device as long as there's open fd(s)
- The driver holds a ref on drm_device as long as it's bound to the struct device

When both sides are done with drm_device, it is released.

---
 drivers/gpu/drm/drm_drv.c  | 6 +-----
 drivers/gpu/drm/drm_file.c | 6 ++----
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_drv.c +1 -5
index 381581b01d48..05bbc2b622fc 100644
@@ -376,11 +376,7 @@ void drm_dev_unplug(struct drm_device *dev)
 	synchronize_srcu(&drm_unplug_srcu);
 
 	drm_dev_unregister(dev);
-
-	mutex_lock(&drm_global_mutex);
-	if (dev->open_count == 0)
-		drm_dev_put(dev);
-	mutex_unlock(&drm_global_mutex);
+	drm_dev_put(dev);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
drivers/gpu/drm/drm_file.c +2 -4
index 46f48f245eb5..3f20f598cd7c 100644
@@ -479,11 +479,9 @@ int drm_release(struct inode *inode, struct file *filp)
 
 	drm_file_free(file_priv);
 
-	if (!--dev->open_count) {
+	if (!--dev->open_count)
 		drm_lastclose(dev);
-		if (drm_dev_is_unplugged(dev))
-			drm_put_dev(dev);
-	}
+
 	mutex_unlock(&drm_global_mutex);
 
 	drm_minor_release(minor);
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH v2 2/2 drm/drv: drm_dev_unplug(): Move out drm_dev_put() call

In reply to a message not in the archive

This makes it possible to use drm_dev_unplug() with the upcoming devm_drm_dev_init() which will do drm_dev_put() in its release callback.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Sean Paul <[email protected]>
Cc Oleksandr Andrushchenko <[email protected]>
Cc Daniel Vetter <[email protected]>

---

I will take this through drm-misc-next.

Noralf.

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 drivers/gpu/drm/drm_drv.c               | 1 -
 drivers/gpu/drm/udl/udl_drv.c           | 1 +
 drivers/gpu/drm/xen/xen_drm_front.c     | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index a1bb3773087b..d1f37ba3c118 100644
@@ -971,6 +971,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 
 	DRM_ERROR("Device removal is currently not supported outside of fbcon\n");
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 }
drivers/gpu/drm/drm_drv.c +0 -1
index 05bbc2b622fc..b04982101fcb 100644
@@ -376,7 +376,6 @@ void drm_dev_unplug(struct drm_device *dev)
 	synchronize_srcu(&drm_unplug_srcu);
 
 	drm_dev_unregister(dev);
-	drm_dev_put(dev);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
drivers/gpu/drm/udl/udl_drv.c +1 -0
index 22cd2d13e272..53b7b8c04bc6 100644
@@ -107,6 +107,7 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 	udl_fbdev_unplug(dev);
 	udl_drop_usb(dev);
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 }
 
 /*
drivers/gpu/drm/xen/xen_drm_front.c +1 -0
index 3e78a832d7f9..84aa4d61dc42 100644
@@ -582,6 +582,7 @@ static void xen_drm_drv_fini(struct xen_drm_front_info *front_info)
 
 	drm_kms_helper_poll_fini(dev);
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 
 	front_info->drm_info = NULL;
 
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] drm/drv: drm_dev_unplug(): Move out drm_dev_put() call

Quoted 64 lines · Noralf Trønnes

This makes it possible to use drm_dev_unplug() with the upcoming devm_drm_dev_init() which will do drm_dev_put() in its release callback.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Sean Paul <[email protected]>
Cc Oleksandr Andrushchenko <[email protected]>
Cc Daniel Vetter <[email protected]>

---

I will take this through drm-misc-next.

Noralf.

  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
  drivers/gpu/drm/drm_drv.c               | 1 -
  drivers/gpu/drm/udl/udl_drv.c           | 1 +
  drivers/gpu/drm/xen/xen_drm_front.c     | 1 +
  4 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index a1bb3773087b..d1f37ba3c118 100644
@@ -971,6 +971,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 
  	DRM_ERROR("Device removal is currently not supported outside of fbcon\n");
  	drm_dev_unplug(dev);
+	drm_dev_put(dev);
  	pci_disable_device(pdev);
  	pci_set_drvdata(pdev, NULL);
  }
drivers/gpu/drm/drm_drv.c +0 -1
index 05bbc2b622fc..b04982101fcb 100644
@@ -376,7 +376,6 @@ void drm_dev_unplug(struct drm_device *dev)
  	synchronize_srcu(&drm_unplug_srcu);
 
  	drm_dev_unregister(dev);
-	drm_dev_put(dev);
  }
  EXPORT_SYMBOL(drm_dev_unplug);
 
drivers/gpu/drm/udl/udl_drv.c +1 -0
index 22cd2d13e272..53b7b8c04bc6 100644
@@ -107,6 +107,7 @@ static void udl_usb_disconnect(struct usb_interface *interface)
  	udl_fbdev_unplug(dev);
  	udl_drop_usb(dev);
  	drm_dev_unplug(dev);
+	drm_dev_put(dev);
  }
 
  /*
drivers/gpu/drm/xen/xen_drm_front.c +0 -0
index 3e78a832d7f9..84aa4d61dc42 100644

drivers/gpu/drm/xen/xen_drm_front.c static void xen_drm_drv_fini(struct xen_drm_front_info *front_info) · line 586

Quoted 5 lines
drivers/gpu/drm/xen/xen_drm_front.c +1 -0
@@ -582,6 +582,7 @@ static void xen_drm_drv_fini(struct xen_drm_front_info *front_info)
 
  	drm_kms_helper_poll_fini(dev);
  	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 

drivers/gpu/drm/xen/xen_drm_front.c static void xen_drm_drv_fini(struct xen_drm_front_info *front_info) · line 588

Quoted 2 lines
drivers/gpu/drm/xen/xen_drm_front.c +0 -0
  	front_info->drm_info = NULL;
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20190208140103.28919-3-noralf-L59+Z2yzLopAfugRpC6u6w@public.gmane.org

Reviewed-by
#6 lore raw

Re: [PATCH v2 2/2] drm/drv: drm_dev_unplug(): Move out drm_dev_put() call

Quoted 11 lines · Noralf Trønnes

This makes it possible to use drm_dev_unplug() with the upcoming devm_drm_dev_init() which will do drm_dev_put() in its release callback.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David (ChunMing) Zhou <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Sean Paul <[email protected]>
Cc Oleksandr Andrushchenko <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 63 lines

---

I will take this through drm-misc-next.

Noralf.

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 drivers/gpu/drm/drm_drv.c               | 1 -
 drivers/gpu/drm/udl/udl_drv.c           | 1 +
 drivers/gpu/drm/xen/xen_drm_front.c     | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index a1bb3773087b..d1f37ba3c118 100644
@@ -971,6 +971,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 
 	DRM_ERROR("Device removal is currently not supported outside of fbcon\n");
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 }
drivers/gpu/drm/drm_drv.c +0 -1
index 05bbc2b622fc..b04982101fcb 100644
@@ -376,7 +376,6 @@ void drm_dev_unplug(struct drm_device *dev)
 	synchronize_srcu(&drm_unplug_srcu);
 
 	drm_dev_unregister(dev);
-	drm_dev_put(dev);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
drivers/gpu/drm/udl/udl_drv.c +1 -0
index 22cd2d13e272..53b7b8c04bc6 100644
@@ -107,6 +107,7 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 	udl_fbdev_unplug(dev);
 	udl_drop_usb(dev);
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 }
 
 /*
drivers/gpu/drm/xen/xen_drm_front.c +1 -0
index 3e78a832d7f9..84aa4d61dc42 100644
@@ -582,6 +582,7 @@ static void xen_drm_drv_fini(struct xen_drm_front_info *front_info)
 
 	drm_kms_helper_poll_fini(dev);
 	drm_dev_unplug(dev);
+	drm_dev_put(dev);
 
 	front_info->drm_info = NULL;
 
Signature · 1 line
2.20.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#7 lore raw

✓ Fi.CI.BAT: success for drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())

In reply to Noralf Trønnes
== Series Details ==

== Series Details ==

Series: drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())
URL : https://patchwork.freedesktop.org/series/56404/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5567 -> Patchwork_12178
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56404/revisions/1/mbox/

Known issues
------------

Here are the changes found in Patchwork_12178 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: PASS -> WARN [fdo#109380]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: PASS -> FAIL [fdo#109485]

#### Possible fixes ####

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109380]: https://bugs.freedesktop.org/show_bug.cgi?id=109380
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485

Participating hosts (49 -> 44)
------------------------------

Missing (5): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-glk-j4005

Build changes
-------------

* Linux: CI_DRM_5567 -> Patchwork_12178

CI_DRM_5567: 5725867972123d46f4a4d382ed5fa2eb0348b00c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4815: 947301563259726b65ce47d3a3fe37931ed42efe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12178: 20393ed4cb4a1398dba9733930bb8618f4974f6e @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

20393ed4cb4a drm/drv: drm_dev_unplug(): Move out drm_dev_put() call 77e99b422efe drm: Fix drm_release() and device unplug

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12178/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

✓ Fi.CI.IGT: success for drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())

In reply to Noralf Trønnes
== Series Details ==

== Series Details ==

Series: drm/drv: Rework drm_dev_unplug() (was: Remove drm_dev_unplug())
URL : https://patchwork.freedesktop.org/series/56404/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5567_full -> Patchwork_12178_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Known issues
------------

Here are the changes found in Patchwork_12178_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-apl: PASS -> FAIL [fdo#103191] / [fdo#103232]

* igt@kms_cursor_legacy@cursor-vs-flip-atomic:
- shard-hsw: PASS -> INCOMPLETE [fdo#103540]

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
- shard-glk: PASS -> FAIL [fdo#103167] +1

* igt@kms_plane@plane-position-covered-pipe-a-planes:
- shard-glk: PASS -> FAIL [fdo#103166] +1
- shard-apl: PASS -> FAIL [fdo#103166]

#### Possible fixes ####

* igt@gem_mmap_gtt@hang:
- shard-glk: FAIL [fdo#109469] -> PASS

* igt@kms_cursor_crc@cursor-256x256-dpms:
- shard-apl: FAIL [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-alpha-opaque:
- shard-apl: FAIL [fdo#109350] -> PASS

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-apl: FAIL [fdo#103167] -> PASS +1

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: FAIL [fdo#103167] -> PASS +3

* igt@kms_plane@pixel-format-pipe-a-planes-source-clamping:
- shard-apl: FAIL [fdo#108948] -> PASS

* igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
- shard-glk: FAIL [fdo#103166] -> PASS +1

* igt@kms_plane_multiple@atomic-pipe-b-tiling-x:
- shard-apl: FAIL [fdo#103166] -> PASS

* igt@kms_setmode@basic:
- shard-apl: FAIL [fdo#99912] -> PASS

#### Warnings ####

* igt@kms_atomic_transition@2x-modeset-transitions-fencing:
- shard-apl: {SKIP} [fdo#109271] -> INCOMPLETE [fdo#103927]

* igt@kms_frontbuffer_tracking@fbc-farfromfence:
- shard-snb: DMESG-FAIL [fdo#107469] -> INCOMPLETE [fdo#105411]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#107469]: https://bugs.freedesktop.org/show_bug.cgi?id=107469
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
[fdo#109469]: https://bugs.freedesktop.org/show_bug.cgi?id=109469
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (7 -> 5)
------------------------------

Missing (2): shard-skl shard-iclb

Build changes
-------------

* Linux: CI_DRM_5567 -> Patchwork_12178

CI_DRM_5567: 5725867972123d46f4a4d382ed5fa2eb0348b00c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4815: 947301563259726b65ce47d3a3fe37931ed42efe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12178: 20393ed4cb4a1398dba9733930bb8618f4974f6e @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12178/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw
In reply to Noralf Trønnes

Den 08.02.2019 15.01, skrev Noralf Trønnes:

Quoted 17 lines

This series makes drm_dev_unplug() compatible with the upcoming devm_drm_dev_init(), fixes a double drm_dev_unregister() situation and simplifies the drm_device ref handling wrt to the last fd closed after unregister.

The first version of this patchset removed drm_dev_unplug(), see here for the discussion as to why it is kept for the time being:

[2/6] drm/drv: Prepare to remove drm_dev_unplug()
https://patchwork.freedesktop.org/patch/282902/

Noralf.

Noralf Trønnes (2):
drm: Fix drm_release() and device unplug drm/drv: drm_dev_unplug(): Move out drm_dev_put() call

Quoted 7 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 drivers/gpu/drm/drm_drv.c               | 5 -----
 drivers/gpu/drm/drm_file.c              | 6 ++----
 drivers/gpu/drm/udl/udl_drv.c           | 1 +
 drivers/gpu/drm/xen/xen_drm_front.c     | 1 +
 5 files changed, 5 insertions(+), 9 deletions(-)

Applied to drm-misc-next, thanks for reviewing.

Noralf.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx