Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915/dp: refactor aux_ch_name()
Date: Tue, 26 Sep 2023 12:38:22 +0300	[thread overview]
Message-ID: <87sf71l1f5.fsf@intel.com> (raw)
In-Reply-To: <fe724b7c-3a1c-278c-f2b5-aceca701ba41@intel.com>

On Tue, 26 Sep 2023, Andrzej Hajda <andrzej.hajda@intel.com> wrote:
> On 22.09.2023 12:56, Jani Nikula wrote:
>> Convert aux_ch_name() to a helper that prints a string to a caller
>> provided buffer, and use it to get more consistent aux channel
>> debugs. Now that all users of aux_ch_name() are in intel_dp_aux.c, we
>> can make it static too.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>   drivers/gpu/drm/i915/display/intel_display.h |  2 -
>>   drivers/gpu/drm/i915/display/intel_dp_aux.c  | 41 ++++++++++++--------
>>   2 files changed, 25 insertions(+), 18 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
>> index 49ac8473b988..9f252d1f03a7 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display.h
>> +++ b/drivers/gpu/drm/i915/display/intel_display.h
>> @@ -190,8 +190,6 @@ enum aux_ch {
>>   	AUX_CH_E_XELPD,
>>   };
>>   
>> -#define aux_ch_name(a) ((a) + 'A')
>> -
>>   enum phy {
>>   	PHY_NONE = -1,
>>   
>> diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux.c b/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> index b90cad7f567b..4431b6290c4c 100644
>> --- a/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> +++ b/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> @@ -14,6 +14,21 @@
>>   #include "intel_pps.h"
>>   #include "intel_tc.h"
>>   
>> +#define AUX_CH_NAME_BUFSIZE	6
>> +
>> +static const char *aux_ch_name(struct drm_i915_private *i915,
>> +			       char *buf, int size, enum aux_ch aux_ch)
>> +{
>> +	if (DISPLAY_VER(i915) >= 13 && aux_ch >= AUX_CH_D_XELPD)
>> +		snprintf(buf, size, "%c", 'A' + aux_ch - AUX_CH_D_XELPD + AUX_CH_D);
>> +	else if (DISPLAY_VER(i915) >= 12 && aux_ch >= AUX_CH_USBC1)
>> +		snprintf(buf, size, "USBC%c", '1' + aux_ch - AUX_CH_USBC1);
>> +	else
>> +		snprintf(buf, size, "%c", 'A' + aux_ch);
>> +
>> +	return buf;
>> +}
>> +
>>   u32 intel_dp_aux_pack(const u8 *src, int src_bytes)
>>   {
>>   	int i;
>> @@ -728,6 +743,7 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
>>   	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>   	struct intel_encoder *encoder = &dig_port->base;
>>   	enum aux_ch aux_ch = dig_port->aux_ch;
>> +	char buf[AUX_CH_NAME_BUFSIZE];
>>   
>>   	if (DISPLAY_VER(dev_priv) >= 14) {
>>   		intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg;
>> @@ -764,18 +780,9 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
>>   	drm_dp_aux_init(&intel_dp->aux);
>>   
>>   	/* Failure to allocate our preferred name is not critical */
>> -	if (DISPLAY_VER(dev_priv) >= 13 && aux_ch >= AUX_CH_D_XELPD)
>> -		intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
>> -					       aux_ch_name(aux_ch - AUX_CH_D_XELPD + AUX_CH_D),
>> -					       encoder->base.name);
>> -	else if (DISPLAY_VER(dev_priv) >= 12 && aux_ch >= AUX_CH_USBC1)
>> -		intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX USBC%c/%s",
>> -					       aux_ch - AUX_CH_USBC1 + '1',
>> -					       encoder->base.name);
>> -	else
>> -		intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
>> -					       aux_ch_name(aux_ch),
>> -					       encoder->base.name);
>> +	intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %s/%s",
>> +				       aux_ch_name(dev_priv, buf, sizeof(buf), aux_ch),
>> +				       encoder->base.name);
>
> With define like:
>
> #define aux_ch_name_smart(dev_priv, aux_ch) aux_ch_name(dev_priv, 
> (char[AUX_CH_NAME_BUFSIZE]){}, AUX_CH_NAME_BUFSIZE, aux_ch)
>
> you could get rid of local variable buf, and two extra arguments in 
> call. The price is gcc macro magic and maybe less visible life-time 
> constraints, no strong suggestion :)

Thanks for the suggestion. If this was more widely used, I'd consider
it, but I it's think too much magic for a simple localized thing here.

> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Thanks, pushed to drm-intel-next.

BR,
Jani.


>
> Regards
> Andrzej
>
>
>>   
>>   	intel_dp->aux.transfer = intel_dp_aux_transfer;
>>   	cpu_latency_qos_add_request(&intel_dp->pm_qos, PM_QOS_DEFAULT_VALUE);
>> @@ -819,6 +826,7 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
>>   	struct intel_encoder *other;
>>   	const char *source;
>>   	enum aux_ch aux_ch;
>> +	char buf[AUX_CH_NAME_BUFSIZE];
>>   
>>   	aux_ch = intel_bios_dp_aux_ch(encoder->devdata);
>>   	source = "VBT";
>> @@ -836,16 +844,17 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
>>   	other = get_encoder_by_aux_ch(encoder, aux_ch);
>>   	if (other) {
>>   		drm_dbg_kms(&i915->drm,
>> -			    "[ENCODER:%d:%s] AUX CH %c already claimed by [ENCODER:%d:%s]\n",
>> -			    encoder->base.base.id, encoder->base.name, aux_ch_name(aux_ch),
>> +			    "[ENCODER:%d:%s] AUX CH %s already claimed by [ENCODER:%d:%s]\n",
>> +			    encoder->base.base.id, encoder->base.name,
>> +			    aux_ch_name(i915, buf, sizeof(buf), aux_ch),
>>   			    other->base.base.id, other->base.name);
>>   		return AUX_CH_NONE;
>>   	}
>>   
>>   	drm_dbg_kms(&i915->drm,
>> -		    "[ENCODER:%d:%s] Using AUX CH %c (%s)\n",
>> +		    "[ENCODER:%d:%s] Using AUX CH %s (%s)\n",
>>   		    encoder->base.base.id, encoder->base.name,
>> -		    aux_ch_name(aux_ch), source);
>> +		    aux_ch_name(i915, buf, sizeof(buf), aux_ch), source);
>>   
>>   	return aux_ch;
>>   }
>

-- 
Jani Nikula, Intel

      reply	other threads:[~2023-09-26  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 10:56 [Intel-gfx] [PATCH] drm/i915/dp: refactor aux_ch_name() Jani Nikula
2023-09-22 23:33 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
2023-09-23  2:29 ` [Intel-gfx] [PATCH] " Gustavo Sousa
2023-09-25 11:20 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/dp: refactor aux_ch_name() (rev2) Patchwork
2023-09-25 22:05 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dp: refactor aux_ch_name() (rev3) Patchwork
2023-09-26  3:38 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-09-26  8:53 ` [Intel-gfx] [PATCH] drm/i915/dp: refactor aux_ch_name() Andrzej Hajda
2023-09-26  9:38   ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sf71l1f5.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox