On Thu, Jun 26, 2025 at 01:23:12PM +0300, Jani Nikula wrote: > On Thu, 26 Jun 2025, Imre Deak <[email protected]> wrote: > > On Thu, Jun 26, 2025 at 12:12:11PM +0300, Jani Nikula wrote: > >> On Thu, 26 Jun 2025, Imre Deak <[email protected]> wrote: > >> > From: Imre Deak <[email protected]> > >> > > >> > An AUX access failure during HPD IRQ handling should be handled by > >> > falling back to a full connector detection, ensure that if the failure > >> > happens while reading/acking a device service IRQ. > >> > > >> > Signed-off-by: Imre Deak <[email protected]> > >> > --- > >> > drivers/gpu/drm/i915/display/intel_dp.c | 21 +++++++++++++++------ > >> > 1 file changed, 15 insertions(+), 6 deletions(-) > >> > > >> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c > >> > b/drivers/gpu/drm/i915/display/intel_dp.c > >> > index 7793a72983abd..7eb208d2c321b 100644 > >> > --- a/drivers/gpu/drm/i915/display/intel_dp.c > >> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > >> > @@ -5393,16 +5393,20 @@ void intel_dp_check_link_state(struct intel_dp > >> > *intel_dp) > >> > intel_encoder_link_check_queue_work(encoder, 0); > >> > } > >> > > >> > -static void intel_dp_check_device_service_irq(struct intel_dp *intel_dp) > >> > +static bool intel_dp_check_device_service_irq(struct intel_dp *intel_dp) > >> > >> I don't think "check" is very intuitive in function names. Check > >> something, but then what? Is it like an assert or does it do something > >> active or what? > >> > >> What does a boolean return from a check function mean? > >> > >> It's not obvious to the reader at all. > > > > I agree, but in this patch I didn't want to change the function name. > > Arguably adding a return value changes the meaning already... > > > > >> > >> > { > >> > struct intel_display *display = to_intel_display(intel_dp); > >> > u8 val; > >> > > >> > if (drm_dp_dpcd_readb(&intel_dp->aux, > >> > - DP_DEVICE_SERVICE_IRQ_VECTOR, &val) != 1 > >> > || !val) > >> > - return; > >> > + DP_DEVICE_SERVICE_IRQ_VECTOR, &val) != 1) > >> > + return true; > >> > >> Looks like true means the check failed... while usually true for boolean > >> functions means success. > > > > The function returns true as before if a full connector detection is needed. > > But it didn't return anything before! And that meaning is not conveyed > to the reader in *any* reasonable way!
This function is the counterpart of intel_dp_check_link_service_irq() both functions having the same purpose, reading and handling HPD IRQs. The latter one's return value is true if a reprobe is needed and this patch doesn't change that, it keeps the two functions behave the same way. > The absolute minimum is to add a comment (mind you, kernel-doc is > overkill) stating what the return value means. The function name will change in a follow-up patch and I think that doesn't require a comment on the return value. > >> > >> > > >> > - drm_dp_dpcd_writeb(&intel_dp->aux, > >> > DP_DEVICE_SERVICE_IRQ_VECTOR, val); > >> > + if (!val) > >> > + return false; > >> > + > >> > + if (drm_dp_dpcd_writeb(&intel_dp->aux, > >> > DP_DEVICE_SERVICE_IRQ_VECTOR, val) != 1) > >> > + return true; > >> > > >> > if (val & DP_AUTOMATED_TEST_REQUEST) > >> > intel_dp_test_request(intel_dp); > >> > >> Whoa, it's not a *check* function at all?! It actually *handles* the > >> service irqs. > >> > >> Can we rephrase the function name? > > > > I want to keep the function name in this patch. In the following patches > > I will separate this part and rename it to > > intel_dp_get_and_ack_device_service_irq(). > > Right, saw that now. But even for that function name the meaning of the > return value is ambiguous. All the get/ack IRQ functions in intel_dp.c return true for success. > > BR, > Jani. > > > > > > >> int intel_dp_handle_device_service_irq() and int returns maybe? > >> BR, > >> Jani. > >> > >> > @@ -5412,6 +5416,8 @@ static void > >> > intel_dp_check_device_service_irq(struct intel_dp *intel_dp) > >> > > >> > if (val & DP_SINK_SPECIFIC_IRQ) > >> > drm_dbg_kms(display->drm, "Sink specific irq > >> > unhandled\n"); > >> > + > >> > + return false; > >> > } > >> > > >> > static bool intel_dp_check_link_service_irq(struct intel_dp *intel_dp) > >> > @@ -5476,8 +5482,11 @@ intel_dp_short_pulse(struct intel_dp *intel_dp) > >> > /* No need to proceed if we are going to do full detect > >> > */ > >> > return false; > >> > > >> > - intel_dp_check_device_service_irq(intel_dp); > >> > - reprobe_needed = intel_dp_check_link_service_irq(intel_dp); > >> > + if (intel_dp_check_device_service_irq(intel_dp)) > >> > + reprobe_needed = true; > >> > + > >> > + if (intel_dp_check_link_service_irq(intel_dp)) > >> > + reprobe_needed = true; > >> > > >> > /* Handle CEC interrupts, if any */ > >> > drm_dp_cec_irq(&intel_dp->aux); > >> > >> -- > >> Jani Nikula, Intel > > -- > Jani Nikula, Intel
