1. 14 Apr, 2022 8 commits
  2. 13 Apr, 2022 6 commits
  3. 12 Apr, 2022 4 commits
    • Changcheng Deng's avatar
    • Matthew Auld's avatar
      drm/ttm: stop passing NULL fence in ttm_bo_move_sync_cleanup · c6346218
      Matthew Auld authored
      If we hit the sync case, like when skipping clearing for kernel internal
      objects, or when falling back to cpu clearing, like in i915, we end up
      trying to add a NULL fence, but with some recent changes in this area
      this now just results in NULL deref in dma_resv_add_fence:
      
      <1>[    5.466383] BUG: kernel NULL pointer dereference, address: 0000000000000008
      <1>[    5.466384] #PF: supervisor read access in kernel mode
      <1>[    5.466385] #PF: error_code(0x0000) - not-present page
      <6>[    5.466386] PGD 0 P4D 0
      <4>[    5.466387] Oops: 0000 [#1] PREEMPT SMP NOPTI
      <4>[    5.466389] CPU: 5 PID: 267 Comm: modprobe Not tainted 5.18.0-rc2-CI-CI_DRM_11481+ #1
      <4>[    5.466391] RIP: 0010:dma_resv_add_fence+0x63/0x260
      <4>[    5.466395] Code: 38 85 c0 0f 84 df 01 00 00 0f 88 e8 01 00 00 83 c0 01 0f 88 df 01 00 00 8b 05 35 89 10 01 49 8d 5e 68 85 c0 0f 85 45 01 00 00 <48> 8b 45 08 48 3d c0 a5 0a 82 0f 84 5c 01 00 00 48 3d 60 a5 0a 82
      <4>[    5.466396] RSP: 0018:ffffc90000e974f8 EFLAGS: 00010202
      <4>[    5.466397] RAX: 0000000000000001 RBX: ffff888123e88b28 RCX: 00000000ffffffff
      <4>[    5.466398] RDX: 0000000000000001 RSI: ffffffff822e4f50 RDI: ffffffff8233f087
      <4>[    5.466399] RBP: 0000000000000000 R08: ffff8881313dbc80 R09: 0000000000000001
      <4>[    5.466399] R10: 0000000000000001 R11: 00000000da354294 R12: 0000000000000000
      <4>[    5.466400] R13: ffff88810927dc58 R14: ffff888123e88ac0 R15: ffff88810a88d600
      <4>[    5.466401] FS:  00007f5fa1193540(0000) GS:ffff88845d880000(0000) knlGS:0000000000000000
      <4>[    5.466402] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      <4>[    5.466402] CR2: 0000000000000008 CR3: 0000000106dd6003 CR4: 00000000003706e0
      <4>[    5.466403] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      <4>[    5.466404] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      <4>[    5.466404] Call Trace:
      <4>[    5.466405]  <TASK>
      <4>[    5.466406]  ttm_bo_move_accel_cleanup+0x62/0x270 [ttm]
      <4>[    5.466411]  ? i915_rsgt_from_buddy_resource+0x185/0x1e0 [i915]
      <4>[    5.466529]  i915_ttm_move+0xfd/0x430 [i915]
      <4>[    5.466833]  ? dma_resv_reserve_fences+0x4e/0x320
      <4>[    5.466836]  ? ttm_bo_add_move_fence.constprop.20+0xf7/0x140 [ttm]
      <4>[    5.466841]  ttm_bo_handle_move_mem+0xa1/0x140 [ttm]
      <4>[    5.466845]  ttm_bo_validate+0xee/0x160 [ttm]
      <4>[    5.466849]  __i915_ttm_get_pages+0x4f/0x210 [i915]
      <4>[    5.466976]  i915_ttm_get_pages+0xad/0x140 [i915]
      <4>[    5.467094]  ____i915_gem_object_get_pages+0x32/0xf0 [i915]
      <4>[    5.467210]  __i915_gem_object_get_pages+0x89/0xa0 [i915]
      <4>[    5.467323]  i915_vma_get_pages+0x114/0x1d0 [i915]
      <4>[    5.467446]  i915_vma_pin_ww+0xd3/0xa90 [i915]
      <4>[    5.467570]  i915_vma_pin.constprop.10+0x119/0x1b0 [i915]
      <4>[    5.467700]  ? __mutex_unlock_slowpath+0x3e/0x2b0
      <4>[    5.467704]  intel_alloc_initial_plane_obj.isra.6+0x1a9/0x390 [i915]
      <4>[    5.467833]  intel_crtc_initial_plane_config+0x83/0x340 [i915]
      
      In the ttm_bo_move_sync_cleanup() case it seems we only really care
      about calling ttm_bo_wait_free_node(), so let's instead just call that
      directly.
      Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Cc: Nirmoy Das <nirmoy.das@linux.intel.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220411085603.58156-1-matthew.auld@intel.com
      c6346218
    • Ville Syrjälä's avatar
      drm: Use drm_mode_copy() · a3342f4d
      Ville Syrjälä authored
      struct drm_display_mode embeds a list head, so overwriting
      the full struct with another one will corrupt the list
      (if the destination mode is on a list). Use drm_mode_copy()
      instead which explicitly preserves the list head of
      the destination mode.
      
      Even if we know the destination mode is not on any list
      using drm_mode_copy() seems decent as it sets a good
      example. Bad examples of not using it might eventually
      get copied into code where preserving the list head
      actually matters.
      
      Obviously one case not covered here is when the mode
      itself is embedded in a larger structure and the whole
      structure is copied. But if we are careful when copying
      into modes embedded in structures I think we can be a
      little more reassured that bogus list heads haven't been
      propagated in.
      
      @is_mode_copy@
      @@
      drm_mode_copy(...)
      {
      ...
      }
      
      @depends on !is_mode_copy@
      struct drm_display_mode *mode;
      expression E, S;
      @@
      (
      - *mode = E
      + drm_mode_copy(mode, &E)
      |
      - memcpy(mode, E, S)
      + drm_mode_copy(mode, E)
      )
      
      @depends on !is_mode_copy@
      struct drm_display_mode mode;
      expression E;
      @@
      (
      - mode = E
      + drm_mode_copy(&mode, &E)
      |
      - memcpy(&mode, E, S)
      + drm_mode_copy(&mode, E)
      )
      
      @@
      struct drm_display_mode *mode;
      @@
      - &*mode
      + mode
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220218100403.7028-23-ville.syrjala@linux.intel.comReviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      a3342f4d
    • Ville Syrjälä's avatar
      drm: Use drm_mode_init() for on-stack modes · 563c4a75
      Ville Syrjälä authored
      Initialize on-stack modes with drm_mode_init() to guarantee
      no stack garbage in the list head, or that we aren't copying
      over another mode's list head.
      
      Based on the following cocci script, with manual fixups:
      @decl@
      identifier M;
      expression E;
      @@
      - struct drm_display_mode M = E;
      + struct drm_display_mode M;
      
      @@
      identifier decl.M;
      expression decl.E;
      statement S, S1;
      @@
      struct drm_display_mode M;
      ... when != S
      + drm_mode_init(&M, &E);
      +
      S1
      
      @@
      expression decl.E;
      @@
      - &*E
      + E
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220218100403.7028-22-ville.syrjala@linux.intel.comReviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      563c4a75
  4. 11 Apr, 2022 9 commits
  5. 08 Apr, 2022 9 commits
  6. 07 Apr, 2022 4 commits
    • Daniel Vetter's avatar
      fbcon: Maintain a private array of fb_info · efc3acbc
      Daniel Vetter authored
      Accessing the one in fbmem.c without taking the right locks is a bad
      idea. Instead maintain our own private copy, which is fully protected
      by console_lock() (like everything else in fbcon.c). That copy is
      serialized through fbcon_fb_registered/unregistered() calls.
      
      Also this means we do not need to hold a full fb_info reference, which
      is nice because doing so would mean a refcount loop between the
      console and the fb_info. But it's also not nice since it means
      console_lock() must be held absolutely everywhere. Well strictly
      speaking we could still try to do some refcounting games again by
      calling get_fb_info before we drop the console_lock. But things will
      get tricky.
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Claudio Suarez <cssk@net-c.es>
      Cc: Du Cheng <ducheng2@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-18-daniel.vetter@ffwll.ch
      efc3acbc
    • Daniel Vetter's avatar
      fbcon: untangle fbcon_exit · c75300b5
      Daniel Vetter authored
      There's a bunch of confusions going on here:
      - The deferred fbcon setup notifier should only be cleaned up from
        fb_console_exit(), to be symmetric with fb_console_init()
      - We also need to make sure we don't race with the work, which means
        temporarily dropping the console lock (or we can deadlock)
      - That also means no point in clearing deferred_takeover, we are
        unloading everything anyway.
      - Finally rename fbcon_exit to fbcon_release_all and move it, since
        that's what's it doing when being called from consw->con_deinit
        through fbcon_deinit.
      
      To answer a question from Sam just quoting my own reply:
      
      > We loose the call to fbcon_release_all() here [in fb_console_exit()].
      > We have part of the old fbcon_exit() above, but miss the release parts.
      
      Ah yes that's the entire point of this change. The release_all in the
      fbcon exit path was only needed when fbcon was a separate module
      indepedent from core fb.ko. Which means it was possible to unload fbcon
      while having fbdev drivers registered.
      
      But since we've merged them that has become impossible, so by the time the
      fb.ko module can be unloaded, there's guaranteed to be no fbdev drivers
      left. And hence removing them is pointless.
      
      v2: Explain the why better (Sam)
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Claudio Suarez <cssk@net-c.es>
      Cc: Du Cheng <ducheng2@gmail.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-17-daniel.vetter@ffwll.ch
      c75300b5
    • Daniel Vetter's avatar
      fbcon: Move more code into fbcon_release · 3647d6d3
      Daniel Vetter authored
      con2fb_release_oldinfo() has a bunch more kfree() calls than
      fbcon_exit(), but since kfree() on NULL is harmless doing that in both
      places should be ok. This is also a bit more symmetric now again with
      fbcon_open also allocating the fbcon_ops structure.
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Du Cheng <ducheng2@gmail.com>
      Cc: Claudio Suarez <cssk@net-c.es>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-16-daniel.vetter@ffwll.ch
      3647d6d3
    • Daniel Vetter's avatar
      fbcon: Move console_lock for register/unlink/unregister · 6e7da3af
      Daniel Vetter authored
      Ideally console_lock becomes an implementation detail of fbcon.c and
      doesn't show up anywhere in fbmem.c. We're still pretty far from that,
      but at least the register/unregister code is there now.
      
      With this the do_fb_ioctl() handler is the only code in fbmem.c still
      calling console_lock().
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Du Cheng <ducheng2@gmail.com>
      Cc: Claudio Suarez <cssk@net-c.es>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Zheyu Ma <zheyuma97@gmail.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-15-daniel.vetter@ffwll.ch
      6e7da3af