1. 11 5月, 2018 1 次提交
    • H
      drm: Match sysfs name in link removal to link creation · 7f6df440
      Haneen Mohammed 提交于
      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: 6449b088 ("drm: Add fake controlD* symlinks for backwards
      compat")
      Cc: Dave Airlie <airlied@gmail.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Emil Velikov <emil.l.velikov@gmail.com>
      Cc: David Herrmann <dh.herrmann@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Daniel Vetter <daniel.vetter@intel.com>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: David Airlie <airlied@linux.ie>
      Cc: dri-devel@lists.freedesktop.org
      Cc: <stable@vger.kernel.org> # v4.10+
      Signed-off-by: NHaneen Mohammed <hamohammed.sa@gmail.com>
      [seanpaul added Fixes and Cc tags]
      Signed-off-by: NSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180511041542.GA4253@haneen-vb
      7f6df440
  2. 06 3月, 2018 1 次提交
  3. 25 10月, 2017 1 次提交
  4. 21 10月, 2017 1 次提交
  5. 26 9月, 2017 1 次提交
  6. 11 8月, 2017 3 次提交
  7. 11 7月, 2017 1 次提交
    • A
      drm: inhibit drm drivers register to uninitialized drm core · 371c2279
      Alexandru Moise 提交于
      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->d_inode
      while it was NULL or calling root->d_inode->i_op->lookup() while it was
      NULL in debugfs at inode_lock() or lookup_*().
      Signed-off-by: NAlexandru Moise <00moses.alexander00@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/20170708214352.GA27205@gmail.com
      371c2279
  8. 02 6月, 2017 1 次提交
    • H
      drm: Fix oops + Xserver hang when unplugging USB drm devices · 75fb6363
      Hans de Goede 提交于
      commit a39be606 ("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]
      ...
      <same Call Trace>
      ---[ 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 a39be606 ("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->kdev);
              dev_set_drvdata(minor->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 a39be606 ("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->kdev) thereby also fixing the second
      set of oopses caused by just reverting the commit.
      
      Fixes: a39be606 ("drm: Do a full device unregister when unplugging")
      Cc: stable@vger.kernel.org
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Jeffy <jeffy.chen@rock-chips.com>
      Cc: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
      Reported-by: NMarco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NSean Paul <seanpaul@chromium.org>
      Link: http://patchwork.freedesktop.org/patch/msgid/20170601115430.4113-1-hdegoede@redhat.com
      75fb6363
  9. 02 2月, 2017 1 次提交
    • C
      drm: Provide a driver hook for drm_dev_release() · f30c9257
      Chris Wilson 提交于
      Some state is coupled into the device lifetime outside of the
      load/unload timeframe and requires teardown during final unreference
      from drm_dev_release(). For example, dmabufs hold both a device and
      module reference and may live longer than expected (i.e. the current
      pattern of the driver tearing down its state and then releasing a
      reference to the drm device) and yet touch driver private state when
      destroyed.
      
      v2: Export drm_dev_fini() and move the responsibility for finalizing the
      drm_device and freeing it to the release callback. (If no callback is
      provided, the core will call drm_dev_fini() and kfree(dev) as before.)
      v3: Remember to add drm_dev_fini() to drm_drv.h
      v4: Tidy language for kerneldoc
      v5: Cross reference from drm_dev_init() to note that driver->release()
      allows for arbitrary embedding.
      v6: Refer to driver data rather than driver state, as state is now
      becoming associated with the struct drm_atomic_state and friends.
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      [danvet: Use the proper reference for struct members, which is
      &drm_driver.release.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/20170202093632.31017-1-chris@chris-wilson.co.uk
      f30c9257
  10. 30 1月, 2017 1 次提交
  11. 27 1月, 2017 1 次提交
  12. 25 1月, 2017 1 次提交
  13. 30 12月, 2016 4 次提交
  14. 19 12月, 2016 1 次提交
  15. 11 12月, 2016 1 次提交
    • D
      drm: Add fake controlD* symlinks for backwards compat · 6449b088
      Daniel Vetter 提交于
      We thought that no userspace is using them, but oops libdrm is using
      them to figure out whether a driver supports modesetting. Check out
      drmCheckModesettingSupported but maybe don't because it's horrible and
      totally runs counter to where we want to go with libdrm device
      handling. The function looks in the device hierarchy for whether
      controlD* exist using the following format string:
      
      /sys/bus/pci/devices/%04x:%02x:%02x.%d/drm/controlD%d
      
      The "/drm" subdirectory is the glue directory from the sysfs class
      stuff, and the only way to get at it seems to through
      kdev->kobj.parent (when kdev is represents e.g. the card0 chardev
      instance in sysfs). Git grep says we're not the only ones touching
      that, so I hope it's ok we dig into such internals - I couldn't find a
      proper interface for getting at the glue directory.
      
      Quick git grep shows that at least -amdgpu, -ati are using this.
      -modesetting do not, and on -intel it's only about the 4th fallback
      path for device lookup, which is why this didn't blow up earlier.
      
      Oh well, we need to keep it working, and the simplest way is to add a
      symlink at the right place in sysfs from controlD* to card*.
      
      v2:
      - Fix error path handling by adding if (!minor) return checks (David)
      - Fix the controlD* numbers to match what's been there (David)
      - Add a comment what exactly userspace minimally needs.
      - Correct the analysis for -intel (Chris).
      
      Fixes: 8a357d10 ("drm: Nerf DRM_CONTROL nodes")
      Cc: Dave Airlie <airlied@gmail.com>
      Reported-and-tested-by: NAlex Deucher <alexander.deucher@amd.com>
      Acked-by: NEmil Velikov <emil.l.velikov@gmail.com>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: David Herrmann <dh.herrmann@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20161209135656.14881-1-daniel.vetter@ffwll.ch
      6449b088
  16. 08 12月, 2016 1 次提交
  17. 17 11月, 2016 1 次提交
    • D
      drm: Nerf DRM_CONTROL nodes · 8a357d10
      Daniel Vetter 提交于
      Looking at the ioctl permission checks I noticed that it's impossible
      to import gem buffers into a control nodes, and fd2handle/handle2fd
      also don't work, so no joy with dma-bufs.
      
      The only way to do anything with a control node is by drawing stuff
      into a dumb buffer and displaying that. I suspect control nodes are an
      entirely unused thing, and a cursory check shows that there does not
      seem to be any callers of drmOpenControl nor of the other drmOpen
      functions using DRM_MODE_CONTROL.
      
      Since I don't like dead uabi, let's remove it. But since this would be
      a really big change I think it's better to start out small by simply
      not registering anything. We can garbage-collect the dead code later
      on, once we're sure it's really not used anywhere.
      Acked-by: NDave Airlie <airlied@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20161028081050.1042-1-daniel.vetter@ffwll.ch
      8a357d10
  18. 15 11月, 2016 2 次提交
  19. 11 11月, 2016 1 次提交
  20. 04 10月, 2016 1 次提交
  21. 22 9月, 2016 2 次提交
  22. 19 9月, 2016 2 次提交
    • D
      drm: cleanup drm_core_{init,exit}() · 2cc107dc
      David Herrmann 提交于
      Various cleanups to the DRM core initialization and exit handlers:
      
       - Register chrdev last: Once register_chrdev() returns, open() will
         succeed on the given chrdevs. This is usually not an issue, as no
         chardevs are registered, yet. However, nodes can be created by
         user-space via mknod(2), even though such major/minor combinations are
         unknown to the kernel. Avoid calling into drm_stub_open() in those
         cases.
         Again, drm_stub_open() would just bail out as the inode is unknown,
         but it's really non-obvious if you hack on drm_stub_open().
      
       - Unify error-paths into just one label. All the error-path helpers can
         be called even though the constructors were not called yet, or failed.
         Hence, just call all cleanups unconditionally.
      
       - Call into drm_global_release(). This is a no-op, but provides
         debugging helpers in case there're GLOBALS left on module unload. This
         function was unused until now.
      
       - Use DRM_ERROR() instead of printk(), and also print the error-code on
         failure (even if it is static!).
      
       - Don't throw away error-codes of register_chrdev()!
      
       - Don't hardcode -1 as errno. This is just plain wrong.
      
       - Order exit-handlers in the exact reverse order of initialization
         (except if the order actually matters for syncing-reasons, which is
         not the case here, though).
      
      v2:
       - Call drm_core_exit() directly from the init-error-handler. Requires to
         drop __exit annotation, though.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/20160901124837.680-7-dh.herrmann@gmail.com
      2cc107dc
    • D
      drm: drop obsolete drm_core.h · 82d5e73f
      David Herrmann 提交于
      The drm_core.h header contains a set of constants meant to be used
      throughout DRM. However, as it turns out, they're each used just once and
      don't bring any benefit. They're also grossly mis-named and lack
      name-spacing. This patch inlines them, or moves them into drm_internal.h
      as appropriate:
      
       - CORE_AUTHOR and CORE_DESC are inlined into corresponding MODULE_*()
         macros. It's just confusing having to follow 2 pointers when trying to
         find the definition of these fields. Grep'ping for MODULE_AUTHOR()
         should reveal the full information, if there's no strong reason not to.
      
       - CORE_NAME, CORE_DATE, CORE_MAJOR, CORE_MINOR, and CORE_PATCHLEVEL are
         inlined into the sysfs 'version' attribute. They're stripped
         everywhere else (which is just some printk() statements). CORE_NAME
         just doesn't make *any* sense, as we hard-code it in many places,
         anyway. The other constants are outdated and just serve
         binary-compatibility purposes. Hence, inline them in 'version' sysfs
         attribute (we might even try dropping it..).
      
       - DRM_IF_MAJOR and DRM_IF_MINOR are moved into drm_internal.h as they're
         only used by the global ioctl handlers. Furthermore, versioning
         interfaces breaks backports and as such is deprecated, anyway. We just
         keep them for historic reasons. I doubt anyone will ever modify them
         again.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/20160901124837.680-6-dh.herrmann@gmail.com
      82d5e73f
  23. 23 8月, 2016 1 次提交
  24. 19 8月, 2016 1 次提交
  25. 08 8月, 2016 1 次提交
  26. 12 7月, 2016 1 次提交
  27. 22 6月, 2016 4 次提交
  28. 19 6月, 2016 1 次提交
    • C
      drm: Protect drm_connector_register_all() under DRIVER_MODESET · bee7fb15
      Chris Wilson 提交于
      0-day kbuilder found
      
      [    1.360244] BUG: unable to handle kernel NULL pointer dereference at   (null)
      [    1.360972] IP: [<c14db9ad>] mutex_lock_nested+0x11f/0x2c3
      [    1.361512] *pde = 00000000
      [    1.361827] Oops: 0002 [#1]
      [    1.362123] Modules linked in:
      [    1.362451] CPU: 0 PID: 1 Comm: swapper Not tainted 4.7.0-rc2-00564-ge28cd4d0 #1
      [    1.363202] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Debian-1.8.2-1 04/01/2014
      [    1.364105] task: c03d0000 ti: d28da000 task.ti: d28da000
      [    1.364636] EIP: 0060:[<c14db9ad>] EFLAGS: 00210096 CPU: 0
      [    1.365215] EIP is at mutex_lock_nested+0x11f/0x2c3
      [    1.365703] EAX: 00000000 EBX: d39e8ae8 ECX: d39e8b14 EDX: c1361cf9
      [    1.366351] ESI: c03d0000 EDI: d28dbed0 EBP: d28dbeec ESP: d28dbec0
      [    1.367010]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
      [    1.367534] CR0: 80050033 CR2: 00000000 CR3: 019a9000 CR4: 00000690
      [    1.368152] Stack:
      [    1.368356]  d39e8b14 d39e8b24 c1361cf9 00200246 d39e8b14 00000000 11111111 d28dbed0
      [    1.369235]  d39e8800 d39e8ae8 00000000 d28dbf08 c1361cf9 d28dbf0c c10b25be d39e8800
      [    1.370087]  00000000 00000000 d28dbf1c c135e37d fffffff4 ffffffff 00000000 d28dbf28
      [    1.371012] Call Trace:
      [    1.371272]  [<c1361cf9>] ? drm_connector_register_all+0x1a/0x92
      [    1.371847]  [<c1361cf9>] drm_connector_register_all+0x1a/0x92
      [    1.372421]  [<c10b25be>] ? kstrdup+0x25/0x3a
      [    1.372863]  [<c135e37d>] drm_dev_register+0x59/0x99
      [    1.373358]  [<c195ea3e>] vgem_init+0x34/0x49
      [    1.373770]  [<c195ea0a>] ? mipi_dsi_bus_init+0xf/0xf
      [    1.374257]  [<c100048f>] do_one_initcall+0x7c/0xfd
      [    1.374754]  [<c104b409>] ? parse_args+0x1fd/0x314
      [    1.375259]  [<c1939c10>] ? kernel_init_freeable+0xd0/0x179
      [    1.375837]  [<c1939c2c>] kernel_init_freeable+0xec/0x179
      [    1.376371]  [<c14d66ea>] kernel_init+0x8/0xcb
      [    1.376806]  [<c14debce>] ret_from_kernel_thread+0xe/0x30
      [    1.377322]  [<c14d66e2>] ? rest_init+0x10e/0x10e
      [    1.377754] Code: 89 fa e8 71 c5 b7 ff 8b 4e 04 89 fa 89 d8 e8 8e c6 b7 ff 8d 43 2c 89 45 d4 8b 43 30 8d 4b 2c 89 45 e8 89 7b 30 89 4d e4 8b 55 dc <89> 38 8d 43 3c 89 75 ec e8 c9 dd b7 ff eb 0c 31 c0 87 03 48
      +75
      [    1.380442] EIP: [<c14db9ad>] mutex_lock_nested+0x11f/0x2c3 SS:ESP 0068:d28dbec0
      [    1.381174] CR2: 0000000000000000
      
      when loading the non-modesetting vGEM module. To prevent use of the
      uninitialised dev->mode_config from drm_dev_register() we move the
      drm_connector_register_all() under a DRIVER_MODESET guard. Longer term,
      we probably want to initialise the embedded dev->mode_config automatically
      from drm_dev_init() for all DRIVER_MODESET drivers.
      
      v2: Also protect drm_dev_unregister.
      
      Fixes: e28cd4d0 ("drm: Automatically register/unregister all connectors")
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Emil Velikov <emil.l.velikov@gmail.com>
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NEmil Velikov <emil.l.velikov@gmail.com>
      Testcase: igt/vgem_reload_basic
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/1466257601-5656-1-git-send-email-chris@chris-wilson.co.uk
      bee7fb15
  29. 17 6月, 2016 1 次提交