Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: <sashiko-reviews@lists.linux.dev>,
	Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: Re: [v4 2/2] drm/i915/audio: Prune ELD SADs based on HDMI audio bandwidth
Date: Fri, 28 Aug 2026 21:22:50 +0530	[thread overview]
Message-ID: <098ea99d-bd4b-46d6-82a7-032b7f9fc5c7@intel.com> (raw)
In-Reply-To: <20260813123432.23B281F00A3A@smtp.kernel.org>


On 8/13/2026 6:04 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The bandwidth check incorrectly uses the maximum pixel clock instead of the minimum pixel clock to calculate worst-case audio packet accumulation per line.
> --
>
> --- Patch [2]: [v4 2/2] drm/i915/audio: Prune ELD SADs based on HDMI audio bandwidth ---
> commit fa98484a48f1957f560711682a22233b5a6fa1f5
> Author: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
>
> drm/i915/audio: Prune ELD SADs based on HDMI audio bandwidth
>
> This commit adds a bandwidth check to determine whether a given audio
> sample rate and channel count can be carried within the hblank period
> for HDMI TMDS mode. It uses this check to prune unsupported sample rates
> from each SAD in the ELD.
>
>> diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
>> index eae76e9611055..9eb6867fa3f3a 100644
>> --- a/drivers/gpu/drm/i915/display/intel_audio.c
>> +++ b/drivers/gpu/drm/i915/display/intel_audio.c
> [ ... ]
>
>> @@ -697,6 +698,158 @@ static void ibx_audio_codec_enable(struct intel_encoder *encoder,
> [ ... ]
>
>> +static bool hdmi_audio_rate_supported(const struct intel_crtc_state *crtc_state,
>> +				      int available_tmds,
>> +				      int audio_rate, int channels)
>> +{
>> +	const struct drm_display_mode *mode = &crtc_state->hw.adjusted_mode;
>> +	int pixel_clk_max_hz;
>> +	int audio_pkt_factor;
>> +	u64 audio_pkt_rate_x4_x1000;
>> +	int audio_packets_line;
>> +	int hblank_overhead;
>> +	int required_tmds;
>> +
>> +	/*
>> +	 * Part 2: Calculate TMDS clock cycles required for Audio Bandwidth
>> +	 *
>> +	 * Step 1: pixelclk_max = nominal_pixel_rate * (1 + 0.5%)
>> +	 * crtc_clock (kHz) * 1000 * 1.005 = crtc_clock * 1005 (Hz)
>> +	 */
>> +	pixel_clk_max_hz = mode->crtc_clock * 1005;
> [ ... ]
>
>> +	/*
>> +	 * Steps 2+5-6: Audio packets per line.
>> +	 *   AudioPackets_Line = CEIL[R_AP * htotal / f_pixelclk_max]
>> +	 *
>> +	 * With audio_pkt_rate_x4_x1000 = R_AP * 4 * 1000:
>> +	 *   = CEIL[audio_pkt_rate_x4_x1000 * htotal / (4 * 1000 * pixel_clk_max_hz)]
>> +	 */
>> +	audio_packets_line = DIV64_U64_ROUND_UP(audio_pkt_rate_x4_x1000 * mode->htotal,
>> +						(u64)4 * 1000 * pixel_clk_max_hz);
> [Severity: Medium]
> To calculate the worst-case (maximum possible) required audio packets per line,
> should this logic use the minimum possible pixel clock instead of the maximum?
>
> A slower pixel clock means a video line takes longer to transmit in real time,
> causing more audio packets to accumulate in the FIFO during that line. These
> accumulated packets then require more TMDS bandwidth to transmit during the
> corresponding blanking period.
>
> By multiplying the nominal clock by 1005 (adding 0.5% tolerance) instead of
> 995 (subtracting 0.5% tolerance) and using it as a divisor here, the code
> calculates the minimum required packets instead of the maximum. This optimistic
> calculation could incorrectly allow audio configurations that will overflow
> the HDMI audio FIFO and cause audio dropouts when the pixel clock runs at
> nominal or slower speeds.
>
> Although this matches the exact naming in the 'f_pixelclk_max' comment
> (suggesting a likely typo in the underlying BSpec/HDMI hardware specification),
> is it mathematically flawed for a worst-case capability bounds check?


Mathematically the reasoning is correct, but this is exactly how it's 
defined in Bspec and the HDMI spec.

Perhaps the ceiling function and the audio clock tolerance can take care 
of the boundary case where the audio packets per line with (clock + 
0.5%) falls to 18 and the actual clock comes out to 19, though I am not 
entirely sure.

Since the patch matches the specs, I think we are covered.

Regards,

Ankit
>

  reply	other threads:[~2026-08-28 15:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 12:00 [v4 0/2] drm/i915/audio: Add HDMI TMDS audio bandwidth check Chaitanya Kumar Borah
2026-08-13 12:00 ` [v4 1/2] drm/i915/hdmi: Move audio compute config after format selection Chaitanya Kumar Borah
2026-08-13 12:00 ` [v4 2/2] drm/i915/audio: Prune ELD SADs based on HDMI audio bandwidth Chaitanya Kumar Borah
2026-08-13 12:34   ` sashiko-bot
2026-08-28 15:52     ` Nautiyal, Ankit K [this message]
2026-08-28 15:46   ` Nautiyal, Ankit K
2026-08-13 17:16 ` ✓ i915.CI.BAT: success for drm/i915/audio: Add HDMI TMDS audio bandwidth check (rev4) Patchwork
2026-08-14  0:05 ` ✓ i915.CI.Full: " Patchwork

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=098ea99d-bd4b-46d6-82a7-032b7f9fc5c7@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=chaitanya.kumar.borah@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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