Skip to content

drm: Consolidate the wait timeout conversion helpers

Maíra Canal amd-gfx dri-devel intel-gfx 3 versions – Applied

Status from this message: Applied to drm-misc-next with Jani's suggestions applied to the first

Get series with b4
b4 am [email protected] change-id 20260809-drm-timeout-helpers-55473e4879d1

Versions newest first

  1. v3 Latest7 patches 19 repliesApplied
  2. v26 patches 6 repliesSuperseded
  3. v16 patches 4 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/7drm: Move drm_timeout_abs_to_jiffies() to drm_timeout.cdrivers/accel/ethosu/ethosu_drv.c drivers/accel/ivpu/ivpu_gem.c drivers/accel/rocket/rocket_gem.c +9 more+75 -434 replies
2/7drm: Add drm_timeout_rel_to_jiffies()drivers/gpu/drm/drm_timeout.c include/drm/drm_timeout.h+46 -07 replies
3/7drm/amdgpu: Use drm_timeout_abs_to_jiffies()drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c+4 -160 replies
4/7drm/v3d: Use drm_timeout_rel_to_jiffies()drivers/gpu/drm/v3d/v3d_bo.c drivers/gpu/drm/v3d/v3d_drv.h+2 -111 reply
5/7drm/i915: Use drm_timeout_rel_to_jiffies()drivers/gpu/drm/i915/gem/i915_gem_wait.c+3 -143 replies
6/7drm/vc4: Use drm_timeout_rel_to_jiffies()drivers/gpu/drm/vc4/vc4_gem.c+2 -10 replies
7/7drm: Rename drm_utils.h to drm_panel_quirks.hdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +6 more+8 -132 replies

Reviews trailers per patch

4 of 7 patches have a Reviewed-by or Acked-by.

PatchTvrtko UrsulinJani NikulaThomas ZimmermannAndi Shyti
1/7R-b R-b
2/7R-b
3/7
4/7R-b
5/7R-b A-b R-b R-b
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/7] drm: Consolidate the wait timeout conversion helpers

DRM wait ioctls express their timeout in one of two ways: as an absolute deadline in ns, or as a duration in ns. The core has a helper for the first form, drm_timeout_abs_to_jiffies(), which panfrost, lima, tegra, xe and some accel drivers use. However, there is no equivalent for the second form, so the drivers that take a duration convert it themselves.

For example, i915 has a local helper to handle the relative timeout case, and v3d carries a copy of it. This series moves that conversion into a DRM helper called drm_timeout_rel_to_jiffies(), next to the absolute variant, and converts the drivers that were open-coding either form.

This series becomes particularly relevant as the new helper will be used in the next version of the series "drm/vc4: Switch to DRM GPU scheduler" [1]. With this series, we avoid another duplication of the nsecs_to_jiffies_timeout() function (and thanks Tvrtko for the suggestion).

PATCH 1 moves drm_timeout_abs_to_jiffies() out of drm_syncobj.c and into a file of its own, so that both helpers live together. PATCH 2 adds a helper for the relative variant. Patches 3 to 6 convert amdgpu, v3d, i915 and vc4. Finally, PATCH 7 renames the drm_utils.h header to drm_panel_quirks.h to better express its meaning.

Let me know your thoughts about it.

[1] https://lore.kernel.org/dri-devel/[email protected]/T/

Best regards,
- Maíra

---
v1 -> v2: https://lore.kernel.org/r/[email protected]

- [2/6] Add comment discouraging the use of relative timeouts in uAPIs (Christian König)
- [3/6] Make it more explicit that any timeout that doesn't fit in a s64 is mapped into an infinite wait (Christian König)

v2 -> v3: https://lore.kernel.org/r/[email protected]

- [1/7] Move the function definitions to a new header file: drm_timeout.h (Thomas Zimmermann)
- [1/7] Add Tvrtko's R-b (Tvrtko Ursulin)
- [1/7, 2/7] Apply adjustments to the function's kerneldoc (Thomas Zimmermann)
- [2/7] Fixed an inadequate overflow check in drm_timeout_rel_to_jiffies(), which allowed nsecs_to_jiffies64 to wrap around on 64-bit systems. (Tvrtko Ursulin, Sashiko)
- [7/7] Rename drm_utils.h to drm_panel_quirks.h (Thomas Zimmermann)

---
Maíra Canal (7):
drm: Move drm_timeout_abs_to_jiffies() to drm_timeout.c
drm: Add drm_timeout_rel_to_jiffies() drm/amdgpu: Use drm_timeout_abs_to_jiffies() drm/v3d: Use drm_timeout_rel_to_jiffies() drm/i915: Use drm_timeout_rel_to_jiffies() drm/vc4: Use drm_timeout_rel_to_jiffies()
drm: Rename drm_utils.h to drm_panel_quirks.h

 drivers/accel/ethosu/ethosu_drv.c                  |  2 +-
 drivers/accel/ivpu/ivpu_gem.c                      |  2 +-
 drivers/accel/rocket/rocket_gem.c                  |  2 +-
 drivers/gpu/drm/Makefile                           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c            | 20 +----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  1 -
 .../amd/display/amdgpu_dm/amdgpu_dm_backlight.c    |  2 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_connector.c    |  1 -
 drivers/gpu/drm/drm_connector.c                    |  2 +-
 drivers/gpu/drm/drm_panel_backlight_quirks.c       |  2 +-
 drivers/gpu/drm/drm_panel_orientation_quirks.c     |  2 +-
 drivers/gpu/drm/drm_syncobj.c                      | 35 +-------
 drivers/gpu/drm/drm_timeout.c                      | 95 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_wait.c           | 17 +---
 drivers/gpu/drm/lima/lima_gem.c                    |  2 +-
 drivers/gpu/drm/panfrost/panfrost_drv.c            |  2 +-
 drivers/gpu/drm/panthor/panthor_drv.c              |  1 -
 drivers/gpu/drm/tegra/uapi.c                       |  2 +-
 drivers/gpu/drm/v3d/v3d_bo.c                       |  3 +-
 drivers/gpu/drm/v3d/v3d_drv.h                      | 10 ---
 drivers/gpu/drm/vc4/vc4_gem.c                      |  3 +-
 drivers/gpu/drm/xe/xe_wait_user_fence.c            |  2 +-
 drivers/video/fbdev/efifb.c                        |  2 +-
 include/drm/{drm_utils.h => drm_panel_quirks.h}    | 10 +--
 include/drm/drm_timeout.h                          | 17 ++++
 25 files changed, 140 insertions(+), 98 deletions(-)

---
base-commit: 5363e01e4ff03a204cab85292b89cf90c2d1b101
change-id: 20260809-drm-timeout-helpers-55473e4879d1