]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: intel/ipu6: Improve DWC PHY HSFREQRANGE band selection for overlapping ranges
authorMarco Nenciarini <mnencia@kcore.it>
Wed, 1 Apr 2026 16:25:47 +0000 (18:25 +0200)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 5 May 2026 12:27:36 +0000 (15:27 +0300)
commit477620dccf3e9481ed6ae67cb5c747f25751c531
tree27c6706d8483dc570647089947e22fa159062941
parent062ba06f971c0c9f9b4cf37b3b7e8ee8a759e11c
media: intel/ipu6: Improve DWC PHY HSFREQRANGE band selection for overlapping ranges

The get_hsfreq_by_mbps() function searches the freqranges[] table
backward (from highest to lowest index). Because adjacent frequency
bands overlap, a data rate that falls in the overlap region always
lands on the higher-indexed band.

For data rates up to 1500 Mbps (index 42) every band uses
osc_freq_target 335. Starting at index 43 (1461-1640 Mbps) the
osc_freq_target drops to 208. A sensor running at 1498 Mbps sits in
the overlap between index 42 (1414-1588, osc 335) and index 43
(1461-1640, osc 208). The backward search picks index 43, programming
the lower osc_freq_target of 208 instead of the optimal 335.

This causes DDL lock instability and CSI-2 CRC errors on affected
configurations, such as the OmniVision OV08X40 sensor on Intel Arrow
Lake platforms (Dell Pro Max 16).

Rewrite get_hsfreq_by_mbps() to select the optimal band:

1. Among bands whose min/max range covers the data rate, prefer
   the one with the higher osc_freq_target.
2. If osc_freq_target is equal, prefer the band whose default_mbps
   is closest to the requested rate.

Since the frequency ranges are monotonically increasing, the loop
exits early once min exceeds the requested rate.

For 1498 Mbps this now correctly selects index 42 (osc_freq_target
335, range 1414-1588) instead of index 43 (osc_freq_target 208,
range 1461-1640).

Fixes: 1e7eeb301696 ("media: intel/ipu6: add the CSI2 DPHY implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Marco Nenciarini <mnencia@kcore.it>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.c