1. 27 May, 2020 1 commit
    • Ville Syrjälä's avatar
      drm: Nuke mode->vrefresh · 0425662f
      Ville Syrjälä authored
      Get rid of mode->vrefresh and just calculate it on demand. Saves
      a bit of space and avoids the cached value getting out of sync
      with reality.
      
      Mostly done with cocci, with the following manual fixups:
      - Remove the now empty loop in drm_helper_probe_single_connector_modes()
      - Fix __MODE() macro in ch7006_mode.c
      - Fix DRM_MODE_ARG() macro in drm_modes.h
      - Remove leftover comment from samsung_s6d16d0_mode
      - Drop the TODO
      
      @@
      @@
      struct drm_display_mode {
      	...
      -	int vrefresh;
      	...
      };
      
      @@
      identifier N;
      expression E;
      @@
      struct drm_display_mode N = {
      -	.vrefresh = E
      };
      
      @@
      identifier N;
      expression E;
      @@
      struct drm_display_mode N[...] = {
      ...,
      {
      -	.vrefresh = E
      }
      ,...
      };
      
      @@
      expression E;
      @@
      {
      	DRM_MODE(...),
      -	.vrefresh = E,
      }
      
      @@
      identifier M, R;
      @@
      int drm_mode_vrefresh(const struct drm_display_mode *M)
      {
        ...
      - if (M->vrefresh > 0)
      - 	R = M->vrefresh;
      - else
        if (...) {
        ...
        }
        ...
      }
      
      @@
      struct drm_display_mode *p;
      expression E;
      @@
      (
      - p->vrefresh = E;
      |
      - p->vrefresh
      + drm_mode_vrefresh(p)
      )
      
      @@
      struct drm_display_mode s;
      expression E;
      @@
      (
      - s.vrefresh = E;
      |
      - s.vrefresh
      + drm_mode_vrefresh(&s)
      )
      
      @@
      expression E;
      @@
      - drm_mode_vrefresh(E) ? drm_mode_vrefresh(E) : drm_mode_vrefresh(E)
      + drm_mode_vrefresh(E)
      
      @find_substruct@
      identifier X;
      identifier S;
      @@
      struct X {
      ...
      	struct drm_display_mode S;
      ...
      };
      
      @@
      identifier find_substruct.S;
      expression E;
      identifier I;
      @@
      {
      .S = {
      -	.vrefresh = E
      }
      }
      
      @@
      identifier find_substruct.S;
      identifier find_substruct.X;
      expression E;
      identifier I;
      @@
      struct X I[...] = {
      ...,
      .S = {
      -	.vrefresh = E
      }
      ,...
      };
      
      v2: Drop TODO
      v3: Rebase
      v4: Rebase
      
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Neil Armstrong <narmstrong@baylibre.com>
      Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
      Cc: Jonas Karlman <jonas@kwiboo.se>
      Cc: Jernej Skrabec <jernej.skrabec@siol.net>
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Joonyoung Shim <jy0922.shim@samsung.com>
      Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: CK Hu <ck.hu@mediatek.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Jerry Han <hanxu5@huaqin.corp-partner.google.com>
      Cc: Icenowy Zheng <icenowy@aosc.io>
      Cc: Jagan Teki <jagan@amarulasolutions.com>
      Cc: Stefan Mavrodiev <stefan@olimex.com>
      Cc: Robert Chiras <robert.chiras@nxp.com>
      Cc: "Guido Günther" <agx@sigxcpu.org>
      Cc: Purism Kernel Team <kernel@puri.sm>
      Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
      Cc: Vincent Abriou <vincent.abriou@st.com>
      Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Cc: linux-amlogic@lists.infradead.org
      Cc: nouveau@lists.freedesktop.org
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200428171940.19552-4-ville.syrjala@linux.intel.com
      0425662f
  2. 26 May, 2020 4 commits
  3. 25 May, 2020 2 commits
  4. 23 May, 2020 1 commit
  5. 20 May, 2020 3 commits
    • Daniel Vetter's avatar
      drm/writeback: don't set fence->ops to default · 38d6fd40
      Daniel Vetter authored
      It's the default.
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200511091142.208787-1-daniel.vetter@ffwll.ch
      38d6fd40
    • Chris Wilson's avatar
      drm: Restore the NULL check for drm_gem_object_put() · 0e799e84
      Chris Wilson authored
      Some users want to pass NULL to drm_gem_object_put(), but those using
      __drm_gem_object_put() did not. Compromise, have both and let the
      compiler sort it out.
      
      drm_gem_fb_destroy() calls drm_gem_object_put() with NULL obj causing:
      [   11.584209] BUG: kernel NULL pointer dereference, address: 0000000000000000
      [   11.584213] #PF: supervisor write access in kernel mode
      [   11.584215] #PF: error_code(0x0002) - not-present page
      [   11.584216] PGD 0 P4D 0
      [   11.584220] Oops: 0002 [#1] SMP NOPTI
      [   11.584223] CPU: 7 PID: 1571 Comm: gnome-shell Tainted: G            E     5.7.0-rc1-1-default+ #27
      [   11.584225] Hardware name: Micro-Star International Co., Ltd. MS-7A31/X370 XPOWER GAMING TITANIUM (MS-7A31), BIOS 1.MR 12/03/2019
      [   11.584237] RIP: 0010:drm_gem_fb_destroy+0x28/0x70 [drm_kms_helper]
      <snip>
      [   11.584256] Call Trace:
      [   11.584279]  drm_mode_rmfb+0x189/0x1c0 [drm]
      [   11.584299]  ? drm_mode_rmfb+0x1c0/0x1c0 [drm]
      [   11.584314]  drm_ioctl_kernel+0xaa/0xf0 [drm]
      [   11.584329]  drm_ioctl+0x1ff/0x3b0 [drm]
      [   11.584347]  ? drm_mode_rmfb+0x1c0/0x1c0 [drm]
      [   11.584421]  amdgpu_drm_ioctl+0x49/0x80 [amdgpu]
      [   11.584427]  ksys_ioctl+0x87/0xc0
      [   11.584430]  __x64_sys_ioctl+0x16/0x20
      [   11.584434]  do_syscall_64+0x5f/0x240
      [   11.584438]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [   11.584440] RIP: 0033:0x7f0ef80f7227
      Reported-by: default avatarNirmoy Das <nirmoy.das@amd.com>
      Fixes: b5d25074 ("drm/gem: fold drm_gem_object_put_unlocked and __drm_gem_object_put()")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Nirmoy Das <nirmoy.das@amd.com>
      Cc: Emil Velikov <emil.velikov@collabora.com>
      Cc: Christian König <christian.koenig@amd.com>.
      Acked-by: default avatarNirmoy Das <nirmoy.das@amd.com>
      Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200520142347.29060-1-chris@chris-wilson.co.uk
      0e799e84
    • Daniel Vetter's avatar
      dma-fence: add might_sleep annotation to _wait() · ef825550
      Daniel Vetter authored
      Do it uncontionally, there's a separate peek function with
      dma_fence_is_signalled() which can be called from atomic context.
      
      v2: Consensus calls for an unconditional might_sleep (Chris,
      Christian)
      
      Full audit:
      - dma-fence.h: Uses MAX_SCHEDULE_TIMOUT, good chance this sleeps
      - dma-resv.c: Timeout always at least 1
      - st-dma-fence.c: Save to sleep in testcases
      - amdgpu_cs.c: Both callers are for variants of the wait ioctl
      - amdgpu_device.c: Two callers in vram recover code, both right next
        to mutex_lock.
      - amdgpu_vm.c: Use in the vm_wait ioctl, next to _reserve/unreserve
      - remaining functions in amdgpu: All for test_ib implementations for
        various engines, caller for that looks all safe (debugfs, driver
        load, reset)
      - etnaviv: another wait ioctl
      - habanalabs: another wait ioctl
      - nouveau_fence.c: hardcoded 15*HZ ... glorious
      - nouveau_gem.c: hardcoded 2*HZ ... so not even super consistent, but
        this one does have a WARN_ON :-/ At least this one is only a
        fallback path for when kmalloc fails. Maybe this should be put onto
        some worker list instead, instead of a work per unamp ...
      - i915/selftests: Hardecoded HZ / 4 or HZ / 8
      - i915/gt/selftests: Going up the callchain looks safe looking at
        nearby callers
      - i915/gt/intel_gt_requests.c. Wrapped in a mutex_lock
      - i915/gem_i915_gem_wait.c: The i915-version which is called instead
        for i915 fences already has a might_sleep() annotation, so all good
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Lucas Stach <l.stach@pengutronix.de>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: "VMware Graphics" <linux-graphics-maintainer@vmware.com>
      Cc: Oded Gabbay <oded.gabbay@gmail.com>
      Cc: linux-media@vger.kernel.org
      Cc: linaro-mm-sig@lists.linaro.org
      Cc: linux-rdma@vger.kernel.org
      Cc: amd-gfx@lists.freedesktop.org
      Cc: intel-gfx@lists.freedesktop.org
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Christian König <christian.koenig@amd.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200519132756.682888-1-daniel.vetter@ffwll.ch
      ef825550
  6. 19 May, 2020 29 commits