summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2026-09-16 11:29:42 +0300
committerJani Nikula <jani.nikula@intel.com>2026-09-22 16:37:41 +0300
commitb6413a8f75e642bc4e75dcb3c25c7a8b5f451d33 (patch)
treed35ee88253bf8db5d624c40db6827cbabb946e58 /drivers/gpu
parent3216d9cc254bb03c0bec1084d7bfccff2ecbcc7a (diff)
downloadlinux-next-b6413a8f75e642bc4e75dcb3c25c7a8b5f451d33.tar.gz
linux-next-b6413a8f75e642bc4e75dcb3c25c7a8b5f451d33.zip
drm/i915/psr: switch to drm_dp_dpcd_{read_byte, read_data, write_byte, write_data}()
Switch to the modern DPCD access functions that return negative error codes on errors, -EIO for incomplete access, and 0 on success. This flags incomplete reads, and clarifies error handling all over the place. Use 1-byte accessors where sensible. Rename local int r to ret for clarity and consistency. Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com> Link: https://patch.msgid.link/0a32cfdb64a37e586579a689bd8c3c4944596a31.1789547331.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/display/intel_psr.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c
index 872e253db178..f1d48b69a18f 100644
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -471,9 +471,10 @@ static u8 intel_dp_get_sink_sync_latency(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
u8 val = 8; /* assume the worst if we can't read the value */
+ int ret;
- if (drm_dp_dpcd_readb(&intel_dp->aux,
- DP_SYNCHRONIZATION_LATENCY_IN_SINK, &val) == 1)
+ ret = drm_dp_dpcd_read_byte(&intel_dp->aux, DP_SYNCHRONIZATION_LATENCY_IN_SINK, &val);
+ if (!ret)
val &= DP_MAX_RESYNC_FRAME_COUNT_MASK;
else
drm_dbg_kms(display->drm,
@@ -485,7 +486,7 @@ static void _psr_compute_su_granularity(struct intel_dp *intel_dp,
struct intel_connector *connector)
{
struct intel_display *display = to_intel_display(intel_dp);
- ssize_t r;
+ int ret;
__le16 w;
u8 y;
@@ -500,19 +501,19 @@ static void _psr_compute_su_granularity(struct intel_dp *intel_dp,
goto exit;
}
- r = drm_dp_dpcd_read(&intel_dp->aux, DP_PSR2_SU_X_GRANULARITY, &w, sizeof(w));
- if (r != sizeof(w))
+ ret = drm_dp_dpcd_read_data(&intel_dp->aux, DP_PSR2_SU_X_GRANULARITY, &w, sizeof(w));
+ if (ret < 0)
drm_dbg_kms(display->drm,
"Unable to read selective update x granularity\n");
/*
* Spec says that if the value read is 0 the default granularity should
* be used instead.
*/
- if (r != sizeof(w) || w == 0)
+ if (ret < 0 || w == 0)
w = cpu_to_le16(4);
- r = drm_dp_dpcd_read(&intel_dp->aux, DP_PSR2_SU_Y_GRANULARITY, &y, 1);
- if (r != 1) {
+ ret = drm_dp_dpcd_read_byte(&intel_dp->aux, DP_PSR2_SU_Y_GRANULARITY, &y);
+ if (ret < 0) {
drm_dbg_kms(display->drm,
"Unable to read selective update y granularity\n");
y = 4;
@@ -796,11 +797,11 @@ static void _panel_replay_enable_sink(struct intel_dp *intel_dp,
panel_replay_config[1] |=
DP_PANEL_REPLAY_SU_REGION_SCANLINE_CAPTURE;
- drm_dp_dpcd_write(&intel_dp->aux, PANEL_REPLAY_CONFIG,
- panel_replay_config, sizeof(panel_replay_config));
+ drm_dp_dpcd_write_data(&intel_dp->aux, PANEL_REPLAY_CONFIG,
+ panel_replay_config, sizeof(panel_replay_config));
panel_replay_config_3 = intel_dp_as_sdp_transmission_time();
- drm_dp_dpcd_writeb(&intel_dp->aux, PANEL_REPLAY_CONFIG3, panel_replay_config_3);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, PANEL_REPLAY_CONFIG3, panel_replay_config_3);
}
static void _psr_enable_sink(struct intel_dp *intel_dp,
@@ -827,10 +828,10 @@ static void _psr_enable_sink(struct intel_dp *intel_dp,
if (intel_dp->psr.entry_setup_frames > 0)
val |= DP_PSR_FRAME_CAPTURE;
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, val);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_PSR_EN_CFG, val);
val |= DP_PSR_ENABLE;
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, val);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_PSR_EN_CFG, val);
}
static void intel_psr_enable_sink(struct intel_dp *intel_dp,
@@ -843,7 +844,7 @@ static void intel_psr_enable_sink(struct intel_dp *intel_dp,
_psr_enable_sink(intel_dp, crtc_state);
if (intel_dp_is_edp(intel_dp))
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
}
void intel_psr_panel_replay_enable_sink(struct intel_dp *intel_dp)
@@ -854,8 +855,8 @@ void intel_psr_panel_replay_enable_sink(struct intel_dp *intel_dp)
* ensure this bit is cleared/set accordingly.
*/
if (CAN_PANEL_REPLAY(intel_dp) && panel_replay_global_enabled(intel_dp))
- drm_dp_dpcd_writeb(&intel_dp->aux, PANEL_REPLAY_CONFIG,
- DP_PANEL_REPLAY_ENABLE);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, PANEL_REPLAY_CONFIG,
+ DP_PANEL_REPLAY_ENABLE);
}
static u32 intel_psr1_get_tp_time(struct intel_dp *intel_dp)
@@ -2373,11 +2374,11 @@ static void intel_psr_disable_locked(struct intel_dp *intel_dp)
/* Disable PSR on Sink */
if (!intel_dp->psr.panel_replay_enabled) {
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, 0);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_PSR_EN_CFG, 0);
if (intel_dp->psr.sel_update_enabled)
- drm_dp_dpcd_writeb(&intel_dp->aux,
- DP_RECEIVER_ALPM_CONFIG, 0);
+ drm_dp_dpcd_write_byte(&intel_dp->aux,
+ DP_RECEIVER_ALPM_CONFIG, 0);
}
/* Wa_16025596647 */
@@ -3517,7 +3518,7 @@ static void intel_psr_handle_irq(struct intel_dp *intel_dp)
intel_psr_disable_locked(intel_dp);
psr->sink_not_reliable = true;
/* let's make sure that sink is awaken */
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
}
static void intel_psr_work(struct work_struct *work)
@@ -3796,15 +3797,15 @@ static int psr_get_status_and_error_status(struct intel_dp *intel_dp,
offset = intel_dp->psr.panel_replay_enabled ?
DP_SINK_DEVICE_PR_AND_FRAME_LOCK_STATUS : DP_PSR_STATUS;
- ret = drm_dp_dpcd_readb(aux, offset, status);
- if (ret != 1)
+ ret = drm_dp_dpcd_read_byte(aux, offset, status);
+ if (ret < 0)
return ret;
offset = intel_dp->psr.panel_replay_enabled ?
DP_PANEL_REPLAY_ERROR_STATUS : DP_PSR_ERROR_STATUS;
- ret = drm_dp_dpcd_readb(aux, offset, error_status);
- if (ret != 1)
+ ret = drm_dp_dpcd_read_byte(aux, offset, error_status);
+ if (ret < 0)
return ret;
*status = *status & DP_PSR_SINK_STATE_MASK;
@@ -3829,11 +3830,11 @@ static void psr_capability_changed_check(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
struct intel_psr *psr = &intel_dp->psr;
+ int ret;
u8 val;
- int r;
- r = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_ESI, &val);
- if (r != 1) {
+ ret = drm_dp_dpcd_read_byte(&intel_dp->aux, DP_PSR_ESI, &val);
+ if (ret < 0) {
drm_err(display->drm, "Error reading DP_PSR_ESI\n");
return;
}
@@ -3845,7 +3846,7 @@ static void psr_capability_changed_check(struct intel_dp *intel_dp)
"Sink PSR capability changed, disabling PSR\n");
/* Clearing it */
- drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_ESI, val);
+ drm_dp_dpcd_write_byte(&intel_dp->aux, DP_PSR_ESI, val);
}
}
@@ -3913,10 +3914,10 @@ void intel_psr_short_pulse(struct intel_dp *intel_dp)
"PSR_ERROR_STATUS unhandled errors %x\n",
error_status & ~errors);
/* clear status register */
- drm_dp_dpcd_writeb(&intel_dp->aux,
- panel_replay_enabled ?
- DP_PANEL_REPLAY_ERROR_STATUS : DP_PSR_ERROR_STATUS,
- error_status);
+ drm_dp_dpcd_write_byte(&intel_dp->aux,
+ panel_replay_enabled ?
+ DP_PANEL_REPLAY_ERROR_STATUS : DP_PSR_ERROR_STATUS,
+ error_status);
if (!psr->panel_replay_enabled) {
psr_alpm_check(intel_dp);