Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gmbus: use generic poll_timeout*() instead of wait_for*()

Prefer generic poll helpers over i915 custom helpers.

The "two tier" wait_for_us() + wait_for() combination appeared without
much explanation in commit 4e6c2d58ba86 ("drm/i915: Take forcewake once
for the entire GMBUS transaction"). Try to mimic roughly the same with
the generic helpers.

wait_for_us() with 10 us or shorter timeouts ends up in
_wait_for_atomic(). Thus use poll_timeout_us_atomic() for the first try,
with the same 2 us timeout and no sleep.

For the fallback, the functional change is losing the exponentially
growing sleep of wait_for(), which used to be 10, 20, 40, ..., 640, and
1280 us. Use an arbitrary constant 500 us sleep instead. The timeout
remains at 50 ms.

Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://lore.kernel.org/r/564b397352c53a1116519fb2d53050c0426bc0dc.1756383233.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+8 -5
+8 -5
drivers/gpu/drm/i915/display/intel_gmbus.c
··· 30 30 #include <linux/export.h> 31 31 #include <linux/i2c-algo-bit.h> 32 32 #include <linux/i2c.h> 33 + #include <linux/iopoll.h> 33 34 34 35 #include <drm/display/drm_hdcp_helper.h> 35 36 36 37 #include "i915_drv.h" 37 38 #include "i915_irq.h" 38 39 #include "i915_reg.h" 39 - #include "i915_utils.h" 40 40 #include "intel_de.h" 41 41 #include "intel_display_regs.h" 42 42 #include "intel_display_types.h" ··· 415 415 intel_de_write_fw(display, GMBUS4(display), irq_en); 416 416 417 417 status |= GMBUS_SATOER; 418 - ret = wait_for_us((gmbus2 = intel_de_read_fw(display, GMBUS2(display))) & status, 419 - 2); 418 + 419 + ret = poll_timeout_us_atomic(gmbus2 = intel_de_read_fw(display, GMBUS2(display)), 420 + gmbus2 & status, 421 + 0, 2, false); 420 422 if (ret) 421 - ret = wait_for((gmbus2 = intel_de_read_fw(display, GMBUS2(display))) & status, 422 - 50); 423 + ret = poll_timeout_us(gmbus2 = intel_de_read_fw(display, GMBUS2(display)), 424 + gmbus2 & status, 425 + 500, 50 * 1000, false); 423 426 424 427 intel_de_write_fw(display, GMBUS4(display), 0); 425 428 remove_wait_queue(&display->gmbus.wait_queue, &wait);