<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/gpu/drm/drm_drv.c, branch linux-4.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-4.16.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2018-05-22T16:56:22Z</updated>
<entry>
<title>drm: Match sysfs name in link removal to link creation</title>
<updated>2018-05-22T16:56:22Z</updated>
<author>
<name>Haneen Mohammed</name>
<email>hamohammed.sa@gmail.com</email>
</author>
<published>2018-05-11T04:15:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1ff5be16439ad7718dd96f484427514cd53ecee1'/>
<id>urn:sha1:1ff5be16439ad7718dd96f484427514cd53ecee1</id>
<content type='text'>
commit 7f6df440b8623c441c42d070bf592e2d2c1fa9bb upstream.

This patch matches the sysfs name used in the unlinking with the
linking function. Otherwise, remove_compat_control_link() fails to remove
sysfs created by create_compat_control_link() in drm_dev_register().

Fixes: 6449b088dd51 ("drm: Add fake controlD* symlinks for backwards
compat")
Cc: Dave Airlie &lt;airlied@gmail.com&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Cc: Emil Velikov &lt;emil.l.velikov@gmail.com&gt;
Cc: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: Maarten Lankhorst &lt;maarten.lankhorst@linux.intel.com&gt;
Cc: Sean Paul &lt;seanpaul@chromium.org&gt;
Cc: David Airlie &lt;airlied@linux.ie&gt;
Cc: dri-devel@lists.freedesktop.org
Cc: &lt;stable@vger.kernel.org&gt; # v4.10+
Signed-off-by: Haneen Mohammed &lt;hamohammed.sa@gmail.com&gt;
[seanpaul added Fixes and Cc tags]
Signed-off-by: Sean Paul &lt;seanpaul@chromium.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20180511041542.GA4253@haneen-vb
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Merge airlied/drm-next into drm-misc-next</title>
<updated>2017-11-21T13:17:56Z</updated>
<author>
<name>Daniel Vetter</name>
<email>daniel.vetter@ffwll.ch</email>
</author>
<published>2017-11-21T10:33:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=70c5f93669249886b151812076509f30569aff80'/>
<id>urn:sha1:70c5f93669249886b151812076509f30569aff80</id>
<content type='text'>
Bake in the conflict between the drm_print.h extraction and the
addition of DRM_DEBUG_LEASES since we lost it a few too many times.

Also fix a new use of drm_plane_helper_check_state in msm to follow
Ville's conversion in

commit a01cb8ba3f6282934cff65e89ab36b18b14cbe27
Author: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Date:   Wed Nov 1 22:16:19 2017 +0200

    drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c

Acked-by: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
</content>
</entry>
<entry>
<title>drm: Add new LEASE debug level</title>
<updated>2017-10-25T06:31:29Z</updated>
<author>
<name>Keith Packard</name>
<email>keithp@keithp.com</email>
</author>
<published>2017-03-17T22:33:22Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e7646f84ad4f654e1ee503b03a12e520d947884f'/>
<id>urn:sha1:e7646f84ad4f654e1ee503b03a12e520d947884f</id>
<content type='text'>
Separate out lease debugging from the core.

Signed-off-by: Keith Packard &lt;keithp@keithp.com&gt;
Signed-off-by: Dave Airlie &lt;airlied@redhat.com&gt;
</content>
</entry>
<entry>
<title>drm: Move debug macros out of drmP.h</title>
<updated>2017-10-20T17:14:48Z</updated>
<author>
<name>Haneen Mohammed</name>
<email>hamohammed.sa@gmail.com</email>
</author>
<published>2017-10-18T04:30:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=02c9656b2f0d6997939933d8573c2ffb587427e6'/>
<id>urn:sha1:02c9656b2f0d6997939933d8573c2ffb587427e6</id>
<content type='text'>
This patch extract DRM_* debug macros from drmP.h to drm_print.h and
move printing related functions used by these macros from drm_drv.[hc]
to drm_print.[hc].

Signed-off-by: Haneen Mohammed &lt;hamohammed.sa@gmail.com&gt;
Signed-off-by: Sean Paul &lt;seanpaul@chromium.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/4020bc7c5ffad2af516919f78bb837c7f366b82b.1508297716.git.hamohammed.sa@gmail.com
</content>
</entry>
<entry>
<title>drm: introduce drm_dev_{get/put} functions</title>
<updated>2017-09-26T11:12:15Z</updated>
<author>
<name>Aishwarya Pant</name>
<email>aishpant@gmail.com</email>
</author>
<published>2017-09-26T08:28:49Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9a96f55034e41b4e002b767e9218d55f03bdff7d'/>
<id>urn:sha1:9a96f55034e41b4e002b767e9218d55f03bdff7d</id>
<content type='text'>
Reference counting functions in the kernel typically use get/put suffixes. For
maintaining coding style consistency, introduce drm_dev_{get/put} functions. All
callers of drm_dev_ref() API have been converted in this patch and hence it has
been dropped while the drm_dev_unref() API with non-trivial number of users
remains for compatibility.

The semantic patch scripts/coccinelle/api/drm-get-put.cocci has been updated
with the new helper for conversion of drm_dev_unref() to drm_dev_put()

Signed-off-by: Aishwarya Pant &lt;aishpant@gmail.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/6babda56134035a98220d5d37a4fd4048df214ce.1506413698.git.aishpant@gmail.com
</content>
</entry>
<entry>
<title>drm: Clean up drm_dev_unplug</title>
<updated>2017-08-11T08:49:21Z</updated>
<author>
<name>Daniel Vetter</name>
<email>daniel.vetter@ffwll.ch</email>
</author>
<published>2017-08-02T11:56:04Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0469901ea4beaa4a326ffcc9b1d6b5baf9738a42'/>
<id>urn:sha1:0469901ea4beaa4a326ffcc9b1d6b5baf9738a42</id>
<content type='text'>
Use drm_dev_unregister to unregister the interfaces, which also allows
us to simplify the open_count == 0 case.

Reviewed-by: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20170802115604.12734-5-daniel.vetter@ffwll.ch
</content>
</entry>
<entry>
<title>drm: Only lastclose on unload for legacy drivers</title>
<updated>2017-08-11T08:48:12Z</updated>
<author>
<name>Daniel Vetter</name>
<email>daniel.vetter@ffwll.ch</email>
</author>
<published>2017-08-02T11:56:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2e45eeac7c1f80a90768e667545591a1e25ff288'/>
<id>urn:sha1:2e45eeac7c1f80a90768e667545591a1e25ff288</id>
<content type='text'>
The only thing modern drivers are supposed to do in lastclose is
restore the fb emulation state. Which is entirely optional, and
there's really no reason to do that. So restrict it to legacy drivers
(where the driver cleanup essentially happens in lastclose).

This will also allow us to share the unregister function with
drm_dev_unplug().

Quoting my reply to Alex on dri-devel:
On Thu, Aug 3, 2017 at 1:17 AM, Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt; wrote:
&gt; On Wed, Aug 2, 2017 at 10:50 PM, Alex Deucher &lt;alexdeucher@gmail.com&gt; wrote:
&gt;&gt; On Wed, Aug 2, 2017 at 7:56 AM, Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt; wrote:
&gt;&gt;&gt; The only thing modern drivers are supposed to do in lastclose is
&gt;&gt;&gt; restore the fb emulation state. Which is entirely optional, and
&gt;&gt;&gt; there's really no reason to do that. So restrict it to legacy drivers
&gt;&gt;&gt; (where the driver cleanup essentially happens in lastclose).
&gt;&gt;
&gt;&gt; vga_switcheroo_process_delayed_switch() gets called in lastclose.
&gt;&gt; Won't that need to get moved elsewhere for this to work?
&gt;
&gt; Hm right, I forgot the lazy way to do runtime pm by keeping the device
&gt; alive as long as anyone has an open fd for it ... This shouldn't be a
&gt; problem, since you need to unregister from vgaswitcheroo anyway on
&gt; unload. Maybe that blows up, I'll check the code and augment the patch
&gt; as needed.

So I think there's 3 cases:
- Trying to unload the module. You can't do that while anyone has the
fd still open, so lastclose is guaranteeed to run.
- Forcefully unbinding the driver through sysfs. Not any better, since
the can_switch stuff checks for the open count, and so will delay the
delayed switch no matter what.
- Actual hotremoval: a) not implemented since none of the drivers
taking part in vgaswitcheroo correctly unplug the drm device and b)
you can't hotremove a chip from a laptop.

v2: Extend commit message with m-l discussion.

Reviewed-by: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20170802115604.12734-4-daniel.vetter@ffwll.ch
</content>
</entry>
<entry>
<title>drm: Document device unplug infrastructure</title>
<updated>2017-08-11T08:48:03Z</updated>
<author>
<name>Daniel Vetter</name>
<email>daniel.vetter@ffwll.ch</email>
</author>
<published>2017-08-02T11:56:02Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=c07dcd61a0e57c6840c23d90cb1beddad7d682a1'/>
<id>urn:sha1:c07dcd61a0e57c6840c23d90cb1beddad7d682a1</id>
<content type='text'>
While at it, also ocd and give them a consistent drm_dev_ prefix, like
the other device instance functionality. Plus move the functions into
the right places.

Reviewed-by: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20170802115604.12734-3-daniel.vetter@ffwll.ch
</content>
</entry>
<entry>
<title>drm: inhibit drm drivers register to uninitialized drm core</title>
<updated>2017-07-11T10:03:11Z</updated>
<author>
<name>Alexandru Moise</name>
<email>00moses.alexander00@gmail.com</email>
</author>
<published>2017-07-08T21:43:52Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=371c2279aa705c32730e738b3f173fb2e62b33e7'/>
<id>urn:sha1:371c2279aa705c32730e738b3f173fb2e62b33e7</id>
<content type='text'>
If the DRM core fails to init for whatever reason, ensure that
no driver ever calls drm_dev_register().

This is best done at drm_dev_init() as it covers drivers that call
drm_dev_alloc() as well as drivers that prefer to embed struct
drm_device into their own device struct and call drm_dev_init()
themselves.

In my case I had so many dynamic device majors used that the major
number for DRM (226) was stolen, causing DRM core init to fail after
failing to register a chrdev, and ultimately calling debugfs_remove()
on drm_debugfs_root in drm_core_exit().

After drm core failed to init, VGEM was still calling drm_dev_register(),
ultimately leading to drm_debugfs_init(), with drm_debugfs_root passed
as the root for the new debugfs dir at debugfs_create_dir().

This led to a kernel panic once we were either derefencing root-&gt;d_inode
while it was NULL or calling root-&gt;d_inode-&gt;i_op-&gt;lookup() while it was
NULL in debugfs at inode_lock() or lookup_*().

Signed-off-by: Alexandru Moise &lt;00moses.alexander00@gmail.com&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170708214352.GA27205@gmail.com
</content>
</entry>
<entry>
<title>drm: Fix oops + Xserver hang when unplugging USB drm devices</title>
<updated>2017-06-02T15:09:35Z</updated>
<author>
<name>Hans de Goede</name>
<email>hdegoede@redhat.com</email>
</author>
<published>2017-06-01T11:54:30Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=75fb636324a839c2c31be9f81644034c6142e469'/>
<id>urn:sha1:75fb636324a839c2c31be9f81644034c6142e469</id>
<content type='text'>
commit a39be606f99d ("drm: Do a full device unregister when unplugging")
causes backtraces like this one when unplugging an usb drm device while
it is in use:

usb 2-3: USB disconnect, device number 25
------------[ cut here ]------------
WARNING: CPU: 0 PID: 242 at drivers/gpu/drm/drm_mode_config.c:424
   drm_mode_config_cleanup+0x220/0x280 [drm]
...
RIP: 0010:drm_mode_config_cleanup+0x220/0x280 [drm]
...
Call Trace:
 gm12u320_modeset_cleanup+0xe/0x10 [gm12u320]
 gm12u320_driver_unload+0x35/0x70 [gm12u320]
 drm_dev_unregister+0x3c/0xe0 [drm]
 drm_unplug_dev+0x12/0x60 [drm]
 gm12u320_usb_disconnect+0x36/0x40 [gm12u320]
 usb_unbind_interface+0x72/0x280
 device_release_driver_internal+0x158/0x210
 device_release_driver+0x12/0x20
 bus_remove_device+0x104/0x180
 device_del+0x1d2/0x350
 usb_disable_device+0x9f/0x270
 usb_disconnect+0xc6/0x260
...
[drm:drm_mode_config_cleanup [drm]] *ERROR* connector Unknown-1 leaked!
------------[ cut here ]------------
WARNING: CPU: 0 PID: 242 at drivers/gpu/drm/drm_mode_config.c:458
   drm_mode_config_cleanup+0x268/0x280 [drm]
...
&lt;same Call Trace&gt;
---[ end trace 80df975dae439ed6 ]---
general protection fault: 0000 [#1] SMP
...
Call Trace:
 ? __switch_to+0x225/0x450
 drm_mode_rmfb_work_fn+0x55/0x70 [drm]
 process_one_work+0x193/0x3c0
 worker_thread+0x4a/0x3a0
...
RIP: drm_framebuffer_remove+0x62/0x3f0 [drm] RSP: ffffb776c39dfd98
---[ end trace 80df975dae439ed7 ]---

After which the system is unusable this is caused by drm_dev_unregister
getting called immediately on unplug, which calls the drivers unload
function which calls drm_mode_config_cleanup which removes the framebuffer
object while userspace is still holding a reference to it.

Reverting commit a39be606f99d ("drm: Do a full device unregister
when unplugging") leads to the following oops on unplug instead,
when userspace closes the last fd referencing the drm_dev:

sysfs group 'power' not found for kobject 'card1-Unknown-1'
------------[ cut here ]------------
WARNING: CPU: 0 PID: 2459 at fs/sysfs/group.c:237
   sysfs_remove_group+0x80/0x90
...
RIP: 0010:sysfs_remove_group+0x80/0x90
...
Call Trace:
 dpm_sysfs_remove+0x57/0x60
 device_del+0xfd/0x350
 device_unregister+0x1a/0x60
 drm_sysfs_connector_remove+0x39/0x50 [drm]
 drm_connector_unregister+0x5a/0x70 [drm]
 drm_connector_unregister_all+0x45/0xa0 [drm]
 drm_modeset_unregister_all+0x12/0x30 [drm]
 drm_dev_unregister+0xca/0xe0 [drm]
 drm_put_dev+0x32/0x60 [drm]
 drm_release+0x2f3/0x380 [drm]
 __fput+0xdf/0x1e0
...
---[ end trace ecfb91ac85688bbe ]---
BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8
IP: down_write+0x1f/0x40
...
Call Trace:
 debugfs_remove_recursive+0x55/0x1b0
 drm_debugfs_connector_remove+0x21/0x40 [drm]
 drm_connector_unregister+0x62/0x70 [drm]
 drm_connector_unregister_all+0x45/0xa0 [drm]
 drm_modeset_unregister_all+0x12/0x30 [drm]
 drm_dev_unregister+0xca/0xe0 [drm]
 drm_put_dev+0x32/0x60 [drm]
 drm_release+0x2f3/0x380 [drm]
 __fput+0xdf/0x1e0
...
---[ end trace ecfb91ac85688bbf ]---

This is caused by the revert moving back to drm_unplug_dev calling
drm_minor_unregister which does:

        device_del(minor-&gt;kdev);
        dev_set_drvdata(minor-&gt;kdev, NULL); /* safety belt */
        drm_debugfs_cleanup(minor);

Causing the sysfs entries to already be removed even though we still
have references to them in e.g. drm_connector.

Note we must call drm_minor_unregister to notify userspace of the unplug
of the device, so calling drm_dev_unregister is not completely wrong the
problem is that drm_dev_unregister does too much.

This commit fixes drm_unplug_dev by not only reverting
commit a39be606f99d ("drm: Do a full device unregister when unplugging")
but by also adding a call to drm_modeset_unregister_all before the
drm_minor_unregister calls to make sure all sysfs entries are removed
before calling device_del(minor-&gt;kdev) thereby also fixing the second
set of oopses caused by just reverting the commit.

Fixes: a39be606f99d ("drm: Do a full device unregister when unplugging")
Cc: stable@vger.kernel.org
Cc: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Jeffy &lt;jeffy.chen@rock-chips.com&gt;
Cc: Marco Diego Aurélio Mesquita &lt;marcodiegomesquita@gmail.com&gt;
Reported-by: Marco Diego Aurélio Mesquita &lt;marcodiegomesquita@gmail.com&gt;
Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Reviewed-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Signed-off-by: Sean Paul &lt;seanpaul@chromium.org&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170601115430.4113-1-hdegoede@redhat.com
</content>
</entry>
</feed>
