Skip to content

[Intel-SIG] Intel 14th MTL graphics sync from 6.7 to 6.10-rc1#327

Merged
matrix-wsk merged 87 commits intodeepin-community:linux-6.6.yfrom
quanxianwang:mtl_20240719_graphics
Jul 19, 2024
Merged

[Intel-SIG] Intel 14th MTL graphics sync from 6.7 to 6.10-rc1#327
matrix-wsk merged 87 commits intodeepin-community:linux-6.6.yfrom
quanxianwang:mtl_20240719_graphics

Conversation

@quanxianwang
Copy link
Contributor

This should be the last update of MTL graphics. and this PR is to for graphics bugfix and feature enabling. and at the same time, we expected paving a good way to 15th and 16th graphics backporting.

local testing on Intel SDP MTL machine, works fine.

here are the commit lists from upstream and its kernel version:

final_deepin_graphics_commits.list
3a8ecd4,drm/i915/cx0: Add intel_cx0_get_owned_lane_mask(),2023-08-17 12:25:13,Gustavo Sousa gustavo.sousa@intel.com v6.7-rc18^221^2211
0f5c2e5,drm/i915: Simplify intel_cx0_program_phy_lane() with loop,2023-08-17 12:25:14,Gustavo Sousa gustavo.sousa@intel.com v6.7-rc1
8^221^2210
226fa3a,drm/i915/cx0: Program vswing only for owned lanes,2023-08-17 12:25:15,Gustavo Sousa gustavo.sousa@intel.com v6.7-rc18^221^2208
fd279d2,drm/i915/dp_mst: Use output_format to get the final link bpp,2023-08-18 09:42:15,Ankit Nautiyal ankit.k.nautiyal@intel.com v6.7-rc1
8^221^2201
ae3a70a,drm/i915/regs: split out intel_color_regs.h,2023-08-25 13:12:10,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^2166
7f52ca6,drm/i915/color: move CHV CGM pipe mode read to intel_color,2023-08-25 13:12:17,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2165
efe6fcb,drm/i915: move HSW+ gamma mode read to intel_color,2023-08-25 13:12:21,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^2164
cecdea1,drm/i915: move ILK+ CSC mode read to intel_color,2023-08-25 13:12:24,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2163
f56e23e,drm/i915/color: move SKL+ gamma and CSC enable read to intel_color,2023-08-25 13:12:27,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^2162
9af09df,drm/i915/color: move pre-SKL gamma and CSC enable read to intel_color,2023-08-25 13:12:31,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2161
51152ac,drm/i915/hdcp: Use intel_connector argument in intel_hdcp_shim,2023-08-29 13:51:39,Suraj Kandpal suraj.kandpal@intel.com v6.7-rc18^221^2160
c1464a8,drm/i915: add minimal i915_gem_object_frontbuffer.h,2023-08-31 18:41:34,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2144
113cddd,drm/cec: add drm_dp_cec_attach() as the non-edid version of set edid,2023-09-01 11:47:53,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^2138
7218779,drm/edid: add drm_edid_is_digital(),2023-09-01 11:47:53,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2141
82b599e,drm/edid: parse source physical address,2023-09-01 11:47:53,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^2139
e1039cd,drm/i915/display: use drm_edid_is_digital(),2023-09-01 11:47:53,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^221^2140
130849f,drm/i915/hdcp: Use intel_connector as argument for hdcp_2_2_capable,2023-09-01 13:17:44,Suraj Kandpal suraj.kandpal@intel.com v6.7-rc18^221^2143
9055e73,drm/i915/dsb: Dump the DSB command buffer when DSB fails,2023-09-07 15:43:29,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^2115
088ca02,drm/i915/dsb: Avoid corrupting the first register write,2023-09-07 15:44:16,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^2114
231b1d6,drm/i915/dsb: Don't use indexed writes when byte enables are not all set,2023-09-07 15:44:41,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^2113
30b98ec,drm/i915: Call the DDC bus i2c adapter "ddc",2023-09-15 14:47:09,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^287
e046d15,drm/i915/hdmi: Use connector->ddc everwhere,2023-09-15 14:48:49,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^281
ac6dcb6,drm/i915/hdmi: Nuke hdmi->ddc_bus,2023-09-15 14:49:10,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^280
31a6575,drm/i915/hdmi: Remove old i2c symlink,2023-09-15 14:50:04,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^279
6686c30,drm/i915: move more of the display probe to display code,2023-09-15 18:29:05,Jani Nikula jani.nikula@intel.com v6.7-rc18^221^274
f895e3d,drm/i915: Move psr unlock out from the pipe update critical section,2023-09-20 22:27:08,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^267
b4ac591,drm/i915: Optimize out redundant M/N updates,2023-09-20 22:29:43,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^262
f0f7ec7,drm/i915: Relocate is_in_vrr_range(),2023-09-20 22:30:08,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^261
6a38b36,drm/i915: Validate that the timings are within the VRR range,2023-09-20 22:30:55,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^260
8f78227,drm/i915: Disable VRR during seamless M/N changes,2023-09-20 22:31:21,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^259
0ce013a,drm/i915: Update VRR parameters in fastset,2023-09-20 22:31:39,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^258
26f03ef,drm/i915: Assert that VRR is off during vblank evasion if necessary,2023-09-20 22:32:22,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^257
16a9359,drm/i915: Implement transcoder LRR for TGL+,2023-09-20 22:32:55,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^256
8dde2e6,drm/i915: Re-order if/else ladder in intel_detect_pch(),2023-09-21 07:39:48,Lucas De Marchi lucas.demarchi@intel.com v6.7-rc1
8^221^249
65578d0,drm/i915/xe2lpd: Add fake PCH,2023-09-21 07:39:49,Gustavo Sousa gustavo.sousa@intel.com v6.7-rc18^221^248
cfeff35,drm/i915/xe2lpd: Treat cursor plane as regular plane for DDB allocation,2023-09-21 07:39:50,Stanislav Lisovskiy stanislav.lisovskiy@intel.com v6.7-rc1
8^221^247
6f35a04,drm/i915/xe2lpd: Read pin assignment from IOM,2023-09-21 08:18:06,Luca Coelho luciano.coelho@intel.com v6.7-rc18^221^240
9d404da,drm/i915/lnl: Add gmbus/ddc support,2023-09-21 08:18:06,Lucas De Marchi lucas.demarchi@intel.com v6.7-rc1
8^221^236
696c331,drm/i915/xe2lpd: Add support for HPD,2023-09-21 08:18:06,Gustavo Sousa gustavo.sousa@intel.com v6.7-rc18^221^238
fa1b97f,drm/i915/dsb: Use non-locked register access,2023-09-27 18:35:29,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^225
357832b,drm/i915/dsb: Define more DSB bits,2023-09-27 18:36:19,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^224
0c1c7a6,drm/i915/dsb: Define the contents of some intstructions bit better,2023-09-27 18:38:17,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^223
df3b919,drm/i915/dsb: Introduce intel_dsb_noop(),2023-09-27 18:38:40,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^222
e39845d,drm/i915/dsb: Introduce intel_dsb_reg_write_masked(),2023-09-27 18:38:53,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^221
5053121,drm/i915/dsb: Add support for non-posted DSB registers writes,2023-09-27 18:39:26,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^220
5ae0da3,drm/i915/dsb: Load LUTs using the DSB during vblank,2023-09-27 18:40:58,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^218
7678e08,drm/i915/dsb: Evade transcoder undelayed vblank when using DSB,2023-09-27 18:46:08,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^216
b428328,drm/i915: Introduce skl_watermark_max_latency(),2023-09-27 18:46:22,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^215
77d8285,drm/i915: Introduce intel_crtc_scanline_to_hw(),2023-09-27 18:47:08,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^221^214
f83b94d,drm/i915/dsb: Use DEwake to combat PkgC latency,2023-09-27 18:49:06,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^221^213
fa7a7a1,drm/i915: Add helper to modeset a set of pipes,2023-09-28 12:52:15,Imre Deak imre.deak@intel.com v6.7-rc18^221^27
e3b2690,drm/i915: Rename intel_modeset_all_pipes() to intel_modeset_all_pipes_late(),2023-09-28 12:52:17,Imre Deak imre.deak@intel.com v6.7-rc1
8^221^26
1050e4c,drm/i915: Factor out a helper to check/compute all the CRTC states,2023-09-28 12:52:19,Imre Deak imre.deak@intel.com v6.7-rc18^221^25
5ed8c7b,drm/i915/mocs: use to_gt() instead of direct &i915->gt,2023-10-04 18:27:33,Jani Nikula jani.nikula@intel.com v6.7-rc1
8^219^248
c788479,drm/i915: Constify the snps/c10x PLL state checkers,2023-10-07 00:12:46,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^219^229
bcdcae6,drm/i915/dsb: Allocate command buffer from local memory,2023-10-13 16:24:34,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc1
8^215^225
631b117,drm/i915/dsb: Correct DSB command buffer cache coherency settings,2023-10-13 16:25:30,Ville Syrjälä ville.syrjala@linux.intel.com v6.7-rc18^215^224
b662c19,drm/i915/display: Reset message bus after each read/write operation,2023-10-26 17:48:14,Mika Kahola mika.kahola@intel.com v6.8-rc1
21^227^2150
b0462e9,drm/i915: Move the g45 PEG band gap HPD workaround to the HPD code,2023-10-31 08:31:00,Ville Syrjälä ville.syrjala@linux.intel.com v6.8-rc121^227^2136
98ed369,drm/i915/dsb: DSB code refactoring,2023-11-16 15:56:53,Animesh Manna animesh.manna@intel.com v6.8-rc1
21^227^255
9d69533,drm/i915: move *_crtc_clock_get() to intel_dpll.c,2023-11-17 14:59:47,Jani Nikula jani.nikula@intel.com v6.8-rc121^227^253
b1f5279,drm/i915/psr: Move plane sel fetch configuration into plane source files,2023-11-27 07:36:25,Jouni Högander jouni.hogander@intel.com v6.8-rc1
21^224^231
562f338,drm/i915/dgfx: DGFX uses direct VBT pin mapping,2023-11-29 14:49:29,Clint Taylor clinton.a.taylor@intel.com v6.8-rc121^224^220
ef32c3c,drm/i915: correct the input parameter on _intel_dsb_commit(),2023-11-29 19:26:05,heminhong heminhong@kylinos.cn v6.8-rc1
21^224^222
6128bec,drm/i915: Stop accessing crtc->state from the flip done irq,2023-12-09 04:13:57,Ville Syrjälä ville.syrjala@linux.intel.com v6.8-rc121^214^220
bac2d7d,drm/i915/display: Take care of VSC select field in video dip ctl register,2023-12-22 08:15:20,Jouni Högander jouni.hogander@intel.com v6.9-rc1
26^225^295
93cbc1a,drm/i915/mtl: Add fake PCH for Meteor Lake,2024-01-03 09:17:00,Haridhar Kalvala haridhar.kalvala@intel.com v6.9-rc126^225^293
c27f010,drm/i915: Disable DSB in Xe KMD,2024-01-05 06:33:31,José Roberto de Souza jose.souza@intel.com v6.9-rc1
26^225^282
bddacdf,drm/i915: Add additional ARL PCI IDs,2024-01-18 15:24:32,Matt Roper matthew.d.roper@intel.com v6.9-rc126^225^244
84bf82f,drm/i915/xelpg: Extend driver code of Xe_LPG to Xe_LPG+,2024-01-18 15:28:40,Harish Chegondi harish.chegondi@intel.com v6.9-rc1
26^215^29
c045bc4,drm/i915: Decouple intel_crtc_vblank_evade_scanlines() from atomic commits,2024-01-22 19:02:58,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc126^225^241
bb83f34,drm/i915: Reorder drm_vblank_put() vs. need_vlv_dsi_wa,2024-01-22 19:03:11,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc1
26^225^240
637bda5,drm/i915: Introduce struct intel_vblank_evade_ctx,2024-01-22 19:03:21,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc126^225^239
b1f9bc3,drm/i915: Include need_vlv_dsi_wa in intel_vblank_evade_ctx,2024-01-22 19:03:32,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc1
26^225^238
b5ad7ce,drm/i915: Extract intel_vblank_evade(),2024-01-22 19:03:40,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc126^225^237
318ec32,drm/i915: Move the min/max scanline sanity check into intel_vblank_evade(),2024-01-22 19:04:03,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc1
26^225^236
1de6352,drm/i915: Perform vblank evasion around legacy cursor updates,2024-01-22 19:04:51,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc126^225^234
6bc41f9,Revert "drm/i915/xe2lpd: Treat cursor plane as regular plane for DDB allocation",2024-01-22 19:05:48,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc1
26^225^233
6d46d09,drm/i915/mtl: Wake GT before sending H2G message,2024-01-23 16:57:47,Vinay Belgaumkar vinay.belgaumkar@intel.com v6.9-rc126^215^27
d5c7854,drm/i915/xe2lpd: Move D2D enable/disable,2024-01-30 07:20:21,Lucas De Marchi lucas.demarchi@intel.com v6.9-rc1
26^225^228
82195d4,drm/print: move enum drm_debug_category etc. earlier in drm_print.h,2024-02-09 11:51:49,Jani Nikula jani.nikula@intel.com v6.9-rc126^223^238
dea1731,drm/i915: Move intel_vblank_evade() & co. into intel_vblank.c,2024-01-22 19:04:13,Ville Syrjälä ville.syrjala@linux.intel.com v6.9-rc1
26^225^235
d9b904d,drm/i915/display: update pll values in sync with Bspec for MTL,2024-02-14 09:27:25,Ravi Kumar Vodapalli ravi.kumar.vodapalli@intel.com v6.9-rc126^216^270
3d890f3,drm/i915/lnl: Add pkgc related register,2024-02-23 11:50:46,Suraj Kandpal suraj.kandpal@intel.com v6.9-rc1
26^216^237
810e451,drm/i915/vrr: Generate VRR "safe window" for DSB,2024-03-07 18:14:37,Ville Syrjälä ville.syrjala@linux.intel.com v6.10-rc115^226^2187
65ea19a,drm/i915/hdmi: convert *_port_to_ddc_pin() to *_encoder_to_ddc_pin(),2024-03-21 14:09:58,Jani Nikula jani.nikula@intel.com v6.10-rc1
15^226^2126
caf3d74,drm/i915/dp: Remove support for UHBR13.5,2024-04-02 10:22:42,Arun R Murthy arun.r.murthy@intel.com v6.9-rc325^2^210

guludo and others added 30 commits July 19, 2024 14:23
commit 3a8ecd4 upstream.

There are more parts of C10/C20 programming that need to take owned
lanes into account. Define the function intel_cx0_get_owned_lane_mask()
and use it. There will be new users of that function in upcoming
changes.

BSpec: 64539
deepin-Intel-SIG: commit 3a8ecd4 drm/i915/cx0: Add intel_cx0_get_owned_lane_mask().
MTL Graphics backporting - 2024Q2

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814131331.69516-2-gustavo.sousa@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 0f5c2e5 upstream.

It is possible to generalize the "disable" value for the transmitters to
be a bit mask based on the port width and the port reversal boolean,
with a small exception for DP-alt mode with "x1" port width.

Simplify the code by using such a mask and a for-loop instead of using
switch-case statements.

v2:
  - Use (i < 2) instead of (i / 2 == 0) for PHY lane mask selection.
    (Jani)

BSpec: 64539
deepin-Intel-SIG: commit 0f5c2e5 drm/i915: Simplify intel_cx0_program_phy_lane() with loop.
MTL Graphics backporting - 2024Q2

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814131331.69516-3-gustavo.sousa@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 226fa3a upstream.

According to the BSpec, voltage swing programming should be done for
owned PHY lanes. Do not program a not-owned PHY lane.

BSpec: 74103, 74104
deepin-Intel-SIG: commit 226fa3a drm/i915/cx0: Program vswing only for owned lanes.
MTL Graphics backporting - 2024Q2

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814131331.69516-5-gustavo.sousa@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit fd279d2 upstream.

The final link bpp used to calculate the m_n values depend on the
output_format. Though the output_format is set to RGB for MST case and
the link bpp will be same as the pipe bpp, for the sake of semantics,
lets calculate the m_n values with the link bpp, instead of pipe_bpp.

deepin-Intel-SIG: commit fd279d2 drm/i915/dp_mst: Use output_format to get the final link bpp.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230817142459.89764-4-ankit.k.nautiyal@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit ae3a70a upstream.

Declutter i915_regs.h.

deepin-Intel-SIG: commit ae3a70a drm/i915/regs: split out intel_color_regs.h.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/8e76007a361bd3ca8dd8913281854886b3a1954c.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 7f52ca6 upstream.

Add color .get_config hook to read config other than LUTs and CSCs, and
start off with CHV CGM pipe mode to abstract the platform specific
register access better.

deepin-Intel-SIG: commit 7f52ca6 drm/i915/color: move CHV CGM pipe mode read to intel_color.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1444200931ae61b6360e3dcad8cbea206ad62e2f.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit efe6fcb upstream.

Abstract the platform specific register access better. The separate
hsw_read_gamma_mode() will make more sense with the following changes.

deepin-Intel-SIG: commit efe6fcb drm/i915: move HSW+ gamma mode read to intel_color.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/b7ddcc8b0fb783eb149864070821bdb695c40366.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit cecdea1 upstream.

Abstract the platform specific register access better.

deepin-Intel-SIG: commit cecdea1 drm/i915: move ILK+ CSC mode read to intel_color.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/8f34c577c663839020405e96cdb464319c2881d4.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit f56e23e upstream.

Abstract the platform specific register access better.

deepin-Intel-SIG: commit f56e23e drm/i915/color: move SKL+ gamma and CSC enable read to intel_color.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c0c37c06d1f2673c82d567c8bcbb6b0b0054b5fa.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 9af09df upstream.

Abstract the register access better. The DSPCNTR read could be moved to
either i9xx_plane.c or intel_color.c. The latter feels better, even if
the register is written in the former.

deepin-Intel-SIG: commit 9af09df drm/i915/color: move pre-SKL gamma and CSC enable read to intel_color.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/33830dba5d69027469d976f6909740ccff8c7281.1692287501.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 51152ac upstream.

Update intel_hdcp_shim funcs specifically read_2_2_message,
write_2_2_message and config_stream_type to use intel_connector
argument instead of intel_digital_port as this will help in getting
correct aux later for dp mst scenarios also already hdcp funcs
derive digital_port from connector and then many funcs again get back
the connector from dig_port which doesn't seem right.
Connector specific hdcp functions can derive dig_port on need basis.

deepin-Intel-SIG: commit 51152ac drm/i915/hdcp: Use intel_connector argument in intel_hdcp_shim.
MTL Graphics backporting - 2024Q2

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230828063401.600414-2-suraj.kandpal@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit c1464a8 upstream.

Split out frontbuffer related declarations and static inlines from
gem/i915_gem_object.h into new gem/i915_gem_object_frontbuffer.h.

The main goal is to reduce header interdependencies. With
gem/i915_gem_object.h including display/intel_frontbuffer.h,
modification of the latter causes a whopping 300+ objects to be rebuilt,
while many of the source files actually needing it aren't explicitly
including it at all.

After the change, only 21 objects depend on display/intel_frontbuffer.h,
directly or indirectly.

deepin-Intel-SIG: commit c1464a8 drm/i915: add minimal i915_gem_object_frontbuffer.h.
MTL Graphics backporting - 2024Q2

Cc: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230830085127.2416842-1-jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 113cddd upstream.

Connectors have source physical address available in display
info. There's no need to parse the EDID again for this. Add
drm_dp_cec_attach() to do this.

Seems like the set_edid/unset_edid naming is a bit specific now that
there's no need to pass the EDID at all, so aim for attach/detach going
forward.

v2: Fix the embarrashing build failures

deepin-Intel-SIG: commit 113cddd drm/cec: add drm_dp_cec_attach() as the non-edid version of set edid.
MTL Graphics backporting - 2024Q2

Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230825130120.1250089-1-jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 7218779 upstream.

Checking edid->input & DRM_EDID_INPUT_DIGITAL is common enough to
deserve a helper that also lets us abstract the raw EDID a bit better.

deepin-Intel-SIG: commit 7218779 drm/edid: add drm_edid_is_digital().
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/4bdb407bf189fd922be022eb2f9564692377c81d.1692884619.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 82b599e upstream.

CEC needs the source physical address. Parsing it is trivial with the
existing EDID CEA DB infrastructure.

Default to CEC_PHYS_ADDR_INVALID (0xffff) instead of 0 to cater for
easier CEC usage.

deepin-Intel-SIG: commit 82b599e drm/edid: parse source physical address.
MTL Graphics backporting - 2024Q2

Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/8c6b6403932536b6849e0b44e1ee6e7ebdbe4a69.1692884619.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit e1039cd upstream.

Reduce the use of struct edid and drm_edid_raw().

deepin-Intel-SIG: commit e1039cd drm/i915/display: use drm_edid_is_digital().
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/dbc0269d34f3140aff410eefae8a2711c59299b3.1692884619.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 130849f upstream.

Use intel_connector as argument instead of intel_digital_port in
hdcp_2_2_capable function and dig_port can be later derived from
connector. This will help with getting the correct hdcp version of
particular monitor in a MST setup.

deepin-Intel-SIG: commit 130849f drm/i915/hdcp: Use intel_connector as argument for hdcp_2_2_capable.
MTL Graphics backporting - 2024Q2

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230830073437.666263-2-suraj.kandpal@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 9055e73 upstream.

Dump the full DSB command buffers and head/tail pointers if the
the DSB hasn't completed its job in time.

deepin-Intel-SIG: commit 9055e73 drm/i915/dsb: Dump the DSB command buffer when DSB fails.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230606191504.18099-4-ville.syrjala@linux.intel.com
Reviewed-by: Animesh Manna <animesh.manna@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 088ca02 upstream.

i915_gem_object_create_internal() does not hand out zeroed
memory. Thus we may confuse whatever stale garbage is in
there as a previous register write and mistakenly handle the
first actual register write as an indexed write. This can
end up corrupting the instruction sufficiently well to lose
the entire register write.

Make sure we've actually emitted a previous instruction before
attemting indexed register write merging.

deepin-Intel-SIG: commit 088ca02 drm/i915/dsb: Avoid corrupting the first register write.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230606191504.18099-7-ville.syrjala@linux.intel.com
Reviewed-by: Animesh Manna <animesh.manna@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 231b1d6 upstream.

The indexed write instruction doesn't support byte-enables, so
if the non-indexed write used those we must not convert it to
an indexed write.

deepin-Intel-SIG: commit 231b1d6 drm/i915/dsb: Don't use indexed writes when byte enables are not all set.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230606191504.18099-8-ville.syrjala@linux.intel.com
Reviewed-by: Animesh Manna <animesh.manna@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 30b98ec upstream.

Rename the various names we've used for the DDC bus
i2c adapter ("i2c", "adapter", etc.) to just "ddc".
This differentiates it from the various other i2c
busses we might have (DSI panel stuff, DVO control bus, etc.).

v2: Don't add a bogus drm_get_edid() call (Jani)

deepin-Intel-SIG: commit 30b98ec drm/i915: Call the DDC bus i2c adapter "ddc".
MTL Graphics backporting - 2024Q2

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230831104300.29688-1-ville.syrjala@linux.intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit e046d15 upstream.

We already populate connector->ddc for HDMI ports, but
so far we've not taken full advantage of it. Do that by
eliminating a bunch of intel_gmbus_get_adapter() lookups.

deepin-Intel-SIG: commit e046d15 drm/i915/hdmi: Use connector->ddc everwhere.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230829113920.13713-10-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit ac6dcb6 upstream.

Remove the mostly redundant hdmi->ddc_bus. The only thing that needs
it anymore is get_encoder_by_ddc_bus(), but that can be replaced with
a slight detour through attached_connector+intel_gmbus_get_adapter().

deepin-Intel-SIG: commit ac6dcb6 drm/i915/hdmi: Nuke hdmi->ddc_bus.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230829113920.13713-11-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 31a6575 upstream.

Remove the i915 specific i2c-N symlink from HDMI connectors.
This was added to sort of mirror the DP connectors that alreayd
had their aux ch based i2c adapter sitting beneath them in the
sysfs hierarchy. But now that we have the standard "ddc" symlink
approach provided by the core let's switch to that fully.
I don't think anything beyond igt depends on this.

deepin-Intel-SIG: commit 31a6575 drm/i915/hdmi: Remove old i2c symlink.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230829113920.13713-12-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 6686c30 upstream.

Initializing i915->display.info.__device_info and DISPLAY_RUNTIME_INFO()
really belongs in display code. Move them there.

deepin-Intel-SIG: commit 6686c30 drm/i915: move more of the display probe to display code.
MTL Graphics backporting - 2024Q2

Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230912120537.2158209-1-jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit f895e3d upstream.

Do the PSR unlock after the vblank evade critcal section is
fully over, not before.

deepin-Intel-SIG: commit f895e3d drm/i915: Move psr unlock out from the pipe update critical section.
MTL Graphics backporting - 2024Q2

Cc: Manasi Navare <navaremanasi@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901130440.2085-2-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit b4ac591 upstream.

Don't perform a seamless M/N update if the values aren't actually
changing. This avoids doing extra shenanigans during vblank evasion
needlessly.

deepin-Intel-SIG: commit b4ac591 drm/i915: Optimize out redundant M/N updates.
MTL Graphics backporting - 2024Q2

Cc: Manasi Navare <navaremanasi@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901130440.2085-7-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit f0f7ec7 upstream.

Move is_in_vrr_range() into intel_vrr.c in anticipation of
more users, and rename it accordingly.

deepin-Intel-SIG: commit f0f7ec7 drm/i915: Relocate is_in_vrr_range().
MTL Graphics backporting - 2024Q2

Cc: Manasi Navare <navaremanasi@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901130440.2085-8-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 6a38b36 upstream.

Let's assume there are some crazy displays where the high
end of the VRR range ends up being lower than the refresh
rate as determined by the actual timings. In that case
when we toggle VRR on/off we would step outside the VRR
range when toggling VRR on/off. Let's just make sure that
never happens by not using VRR in such cases. If the user
really wants VRR they should then select the timings to
land within the VRR range.

deepin-Intel-SIG: commit 6a38b36 drm/i915: Validate that the timings are within the VRR range.
MTL Graphics backporting - 2024Q2

Cc: Manasi Navare <navaremanasi@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901130440.2085-9-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 8f78227 upstream.

Make life less confusing by making sure VRR is disabled whenever
we do any drastic changes to the display timings, such as seamless
M/N changes.

deepin-Intel-SIG: commit 8f78227 drm/i915: Disable VRR during seamless M/N changes.
MTL Graphics backporting - 2024Q2

Cc: Manasi Navare <navaremanasi@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901130440.2085-10-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
hogander and others added 26 commits July 19, 2024 14:24
commit b1f5279 upstream.

Currently selective fetch configuration for planes is implemented in psr
code. More suitable place for this code is where everything else is
configured for planes -> move it into skl_universal_plane.c and
intel_cursor.c. This also allows us to drop hooks for cursor handling.

v3: Checkpatch warnings fixed
v2: Removed setting sel_fetch_area->y1/y2 as -1

deepin-Intel-SIG: commit b1f5279 drm/i915/psr: Move plane sel fetch configuration into plane source files.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231120082606.3156488-2-jouni.hogander@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 562f338 upstream.

DDC pin mapping for DGFX cards uses direct VBT pin mapping

deepin-Intel-SIG: commit 562f338 drm/i915/dgfx: DGFX uses direct VBT pin mapping.
MTL Graphics backporting - 2024Q2

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Clint Taylor <clinton.a.taylor@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231128190329.1335562-1-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit ef32c3c upstream.

Current, the dewake_scanline variable is defined as unsigned int,
an unsigned int variable that is always greater than or equal to 0.
when _intel_dsb_commit function is called by intel_dsb_commit function,
the dewake_scanline variable may have an int value.
So the dewake_scanline variable is necessary to defined as an int.

Fixes: f83b94d ("drm/i915/dsb: Use DEwake to combat PkgC latency")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310052201.AnVbpgPr-lkp@intel.com/
deepin-Intel-SIG: commit ef32c3c drm/i915: correct the input parameter on _intel_dsb_commit().
MTL Graphics backporting - 2024Q2

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: heminhong <heminhong@kylinos.cn>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231114024341.14524-1-heminhong@kylinos.cn
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 6128bec upstream.

Assuming crtc->state is pointing at the correct thing for the
async flip commit is nonsense. If we had already queued up multiple
commits this would point at the very lates crtc state even if the
older commits hadn't even happened yet.

Instead properly stage/arm the event like we do for async flips.
Since we don't need to arm multiple of these at the same time we
don't need a list like the normal vblank even processing uses.

deepin-Intel-SIG: commit 6128bec drm/i915: Stop accessing crtc->state from the flip done irq.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230928152450.30109-1-ville.syrjala@linux.intel.com
Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
…ster

commit bac2d7d upstream.

We need to configure VSC Select field in video dip ctl if we want to have
e.g. colorimetry date in our VSC SDP.

deepin-Intel-SIG: commit bac2d7d drm/i915/display: Take care of VSC select field in video dip ctl register.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Tested-by: Shawn Lee <shawn.c.lee@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231220103609.1384523-8-jouni.hogander@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 93cbc1a upstream.

Correct the implementation trying to detect MTL PCH with
the MTL fake PCH id.

On MTL, both the North Display (NDE) and South Display (SDE) functionality
reside on the same die (the SoC die in this case), unlike many past
platforms where the SDE was on a separate PCH die. The code is (badly)
structured today in a way that assumes the SDE is always on the PCH for
modern platforms, so on platforms where we don't actually need to identify
the PCH to figure out how the SDE behaves (i.e., all DG1/2 GPUs as well as
MTL and LNL),we've been assigning a "fake PCH" as a quickhack that allows
us to avoid restructuring a bunch of the code.we've been assigning a
"fake PCH" as a quick hack that allows us to avoid restructuring a bunch
of the code.

Removed unused macros of LNL amd MTL as well.

v2: Reorder PCH_MTL conditional check (Matt Roper)
    Reverting to PCH_MTL for PICA interrupt(Matt Roper)

deepin-Intel-SIG: commit 93cbc1a drm/i915/mtl: Add fake PCH for Meteor Lake.
MTL Graphics backporting - 2024Q2

Signed-off-by: Haridhar Kalvala <haridhar.kalvala@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231219185233.1469675-1-haridhar.kalvala@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit c27f010 upstream.

Often getting DSB overflows when starting Xorg or Wayland compositors
when running Xe KMD.
Issue was reported but nothing was done, so disabling DSB as whole
until properly fixed in Xe KMD.

v2:
- move check to HAS_DSB(Jani)

v3:
- use IS_ENABLED(I915) check in intel_dsb_prepare()

Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/989
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1031
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1072
deepin-Intel-SIG: commit c27f010 drm/i915: Disable DSB in Xe KMD.
MTL Graphics backporting - 2024Q2

Cc: Animesh Manna <animesh.manna@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240104162411.56085-1-jose.souza@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit bddacdf upstream.

Our existing MTL driver handling is also sufficient to handle ARL, so
these IDs are simply added to the MTL ID list.

Bspec: 55420
deepin-Intel-SIG: commit bddacdf drm/i915: Add additional ARL PCI IDs.
MTL Graphics backporting - 2024Q2

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Haridhar Kalvala <haridhar.kalvala@intel.com>
Reviewed-by: Matt Atwood <matthew.s.atwood@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240108122738.14399-2-haridhar.kalvala@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 84bf82f upstream.

Xe_LPG+ (IP version 12.74) should take the same general code
paths as Xe_LPG (versions 12.70 and 12.71).

Xe_LPG+'s workaround list will be handled by the next patch.

deepin-Intel-SIG: commit 84bf82f drm/i915/xelpg: Extend driver code of Xe_LPG to Xe_LPG+.
MTL Graphics backporting - 2024Q2

Signed-off-by: Harish Chegondi <harish.chegondi@intel.com>
Signed-off-by: Haridhar Kalvala <haridhar.kalvala@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240108122738.14399-3-haridhar.kalvala@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
…mmits

commit c045bc4 upstream.

We'll be needing to do vblank evasion around legacy cursor updates,
which don't have the intel_atomic_state around. So let's remove
this dependency on a full commit and pass the crtc state in by hand.

deepin-Intel-SIG: commit c045bc4 drm/i915: Decouple intel_crtc_vblank_evade_scanlines() from atomic commits.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-2-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit bb83f34 upstream.

Drop the vblank reference only after we've done the hideous
need_vlv_dsi_wa stuff. This will make it easier to reuse the
the vblank evasion machinery elsewhere.

Keeping the vblank reference for a bit longer is not a
problem. In fact we might want to not drop it at all until
intel_pipe_update_end(), but we'll leave that idea for later.

deepin-Intel-SIG: commit bb83f34 drm/i915: Reorder drm_vblank_put() vs. need_vlv_dsi_wa.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-3-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 637bda5 upstream.

Collect the information needed for vblank evasions into
a structure that we can pass around more easily.

And let's rename intel_crtc_vblank_evade_scanlines() to just
intel_vblank_evade_init() so that better describes the intended
usage of initializing the context.

deepin-Intel-SIG: commit 637bda5 drm/i915: Introduce struct intel_vblank_evade_ctx.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-4-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit b1f9bc3 upstream.

Pull the need_vlv_dsi_wa details into intel_vblank_evade_init()
so that caller doesn't have to care about it.

deepin-Intel-SIG: commit b1f9bc3 drm/i915: Include need_vlv_dsi_wa in intel_vblank_evade_ctx.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-5-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit b5ad7ce upstream.

Pull the core vblank evasion loop into its own function,
so that we can reuse it elsewhere later.

deepin-Intel-SIG: commit b5ad7ce drm/i915: Extract intel_vblank_evade().
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-6-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
…ade()

commit 318ec32 upstream.

There isn't really any reason to make the caller suffer through
checking the vblank evasion min/max scanlines. If we somehow
ended up with bogus values (which really shouldn't happen)
then just skip the actual vblank evasion loop but otherwise
plow ahead as normal.

The only "real" change is that we now get+put a vblank reference
even if the min/max values are bogus, previously we skipped
directly to the end.

deepin-Intel-SIG: commit 318ec32 drm/i915: Move the min/max scanline sanity check into intel_vblank_evade().
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-7-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 1de6352 upstream.

Our legacy cursor updates are actually mailbox updates.
Ie. the hardware latches things once per frame on start of
vblank, but we issue an number of updates per frame,
withough any attempt to synchronize against the vblank
in software. So in theory only the last update issued
during the frame will latch, and the previous ones are
discarded.

However this can lead to problems with maintaining the
ggtt/iommu mappings as we have no idea which updates
will actually latch.

The problem is exacerbated by the hardware's annoying disarming
behaviour; any non-arming register write will disarm an already
armed update, only to be rearmed later by the arming register
(CURBASE in case of cursors). If a disarming write happens
just before the start of vblank, and the arming write happens
after start of vblank we have effectively prevented the hardware
from latching anything. And if we manage to straddle multiple
sequential vblank starts in this manner we effectively prevent
the hardware from latching any new registers for an arbitrary
amount of time. This provides more time for the (potentially
still in use by the hardware) gtt/iommu mappings to be torn
down.

A partial solution, of course, is to use vblank evasion to
avoid the register writes from spreading on both sides of
the start of vblank.

I've previously highlighted this problem as a general issue
affecting mailbox updates. I even added some notes to the
{i9xx,skl}_crtc_planes_update_arm() to remind us that the noarm
and arm phases both need to pulled into the vblank evasion
critical section if we actually decided to implement mailbox
updates in general. But as I never impelemented the noarm+arm
split for cursors we don't have to worry about that for the
moment.

We've been lucky enough so far that this hasn't really caused
problems. One thing that does help is that Xorg generally
sticks to the same cursor BO. But igt seems pretty good at
hitting this on MTL now, so apparently we have to start
thinking about this.

v2: Wait for PSR exit to avoid the vblank evasion timeout (1ms)
    tripping due to PSR exit latency (~5ms typically)

deepin-Intel-SIG: commit 1de6352 drm/i915: Perform vblank evasion around legacy cursor updates.
MTL Graphics backporting - 2024Q2

Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240116204927.23499-1-ville.syrjala@linux.intel.com
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
…allocation"

commit 6bc41f9 upstream.

This reverts commit cfeff35.

A core design consideration with legacy cursor updates is that the
cursor must not touch any other plane, even if we were to force it
to take the slow path. That is the real reason why the cursor uses
a fixed ddb allocation, not because bspec says so.

Treating cursors as any other plane during ddb allocation
violates that, which means we can now pull other planes into
fully unsynced legacy cursor mailbox commits. That is
definitely not something we've ever considered when designing
the rest of the code. The noarm+arm register write split in
particular makes that dangerous as previous updates can get
disarmed pretty much at any random time, and not necessarily
in an order that is actually safe (eg. against ddb overlaps).

So if we were to do this then:
- someone needs to expend the appropriate amount of brain
  cells thinking through all the tricky details
- we should do it for all skl+ platforms since all
  of those have double buffered wm/ddb registers. The current
  arbitrary mtl+ cutoff doesn't really make sense

For the moment just go back to the original behaviour where
the cursor's ddb alloation does not change outside of
modeset/fastset. As of now anything else isn't safe.

deepin-Intel-SIG: commit 6bc41f9 Revert "drm/i915/xe2lpd: Treat cursor plane as regular plane for DDB allocation".
MTL Graphics backporting - 2024Q2

Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-10-ville.syrjala@linux.intel.com
Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 6d46d09 upstream.

Instead of waiting until the interrupt reaches GuC, we can grab a
forcewake while triggering the H2G interrupt. GEN11_GUC_HOST_INTERRUPT
is inside sgunit and is not affected by forcewakes. However, there
could be some delays when platform is entering/exiting some higher
level platform sleep states and a H2G is triggered. A forcewake
ensures those sleep states have been fully exited and further
processing occurs as expected. The hysteresis timers for C6 and
higher sleep states will ensure there is no unwanted race between the
wake and processing of the interrupts by GuC.

This will have an official WA soon so adding a FIXME in the comments.

v2: Make the new ranges watertight to address BAT failures and update
commit message (Matt R).

deepin-Intel-SIG: commit 6d46d09 drm/i915/mtl: Wake GT before sending H2G message.
MTL Graphics backporting - 2024Q2

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240119193513.221730-1-vinay.belgaumkar@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit d5c7854 upstream.

Bits to enable/disable and check state for D2D moved from
XELPDP_PORT_BUF_CTL1 to DDI_BUF_CTL (now named DDI_CTL_DE in the spec).
Make the functions mtl_ddi_disable_d2d() and mtl_ddi_enable_d2d generic
to work with multiple reg location and bitfield layout.

v2: Set/Clear XE2LPD_DDI_BUF_D2D_LINK_ENABLE in saved_port_bits when
    enabling/disabling D2D so DDI_BUF_CTL is correctly programmed in
    other places without overriding these bits (Clint)
v3: Leave saved_port_bits alone as those bits are not meant to be
    modified outside of the port initialization. Rather propagate the
    additional bit in DDI_BUF_CTL to be set when that register is
    written again after D2D is enabled.

deepin-Intel-SIG: commit d5c7854 drm/i915/xe2lpd: Move D2D enable/disable.
MTL Graphics backporting - 2024Q2

Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240126224638.4132016-2-lucas.demarchi@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 82195d4 upstream.

Avoid forward declarations in subsequent changes, but separate this
movement to an independent change.

deepin-Intel-SIG: commit 82195d4 drm/print: move enum drm_debug_category etc. earlier in drm_print.h.
MTL Graphics backporting - 2024Q2

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Luca Coelho <luciano.coelho@intel.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/9d105014e3c90af13a874745d768212347f68283.1705410327.git.jani.nikula@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit dea1731 upstream.

intel_vblank.c seems like the appropriate place for the core
vblank evasion code. Move it there.

deepin-Intel-SIG: commit dea1731 drm/i915: Move intel_vblank_evade() & co. into intel_vblank.c.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231213102519.13500-8-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit d9b904d upstream.

DP/eDP and HDMI C20 PHY PLL values were updated for MTL platform

deepin-Intel-SIG: commit d9b904d drm/i915/display: update pll values in sync with Bspec for MTL.
MTL Graphics backporting - 2024Q2

Signed-off-by: Ravi Kumar Vodapalli <ravi.kumar.vodapalli@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240214070930.1028456-1-ravi.kumar.vodapalli@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 3d890f3 upstream.

Add the register that needs to read and written onto for
deep pkgc programming.

deepin-Intel-SIG: commit 3d890f3 drm/i915/lnl: Add pkgc related register.
MTL Graphics backporting - 2024Q2

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Signed-off-by: Animesh Manna <animesh.manna@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240201085158.1000285-2-suraj.kandpal@intel.com
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 810e451 upstream.

Looks like TRANS_CHICKEN bit 31 means something totally different
depending on the platform:
TGL: generate VRR "safe window" for DSB
ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR

So far we've only set this on ADL/DG2, but when using DSB+VRR
we also need to set it on TGL.

And a quick test on MTL says it doesn't need this bit for either
of those purposes, even though it's still documented as valid
in bspec.

deepin-Intel-SIG: commit 810e451 drm/i915/vrr: Generate VRR "safe window" for DSB.
MTL Graphics backporting - 2024Q2

Cc: stable@vger.kernel.org
Fixes: 34d8311 ("drm/i915/dsb: Re-instate DSB for LUT updates")
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/9927
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240306040806.21697-2-ville.syrjala@linux.intel.com
Reviewed-by: Animesh Manna <animesh.manna@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit 65ea19a upstream.

Pass encoder to the _port_to_ddc_pin() functions, and rename to
_encoder_to_ddc_pin(). The encoder will be more helpful than just port
in the subsequent changes.

deepin-Intel-SIG: commit 65ea19a drm/i915/hdmi: convert *_port_to_ddc_pin() to *_encoder_to_ddc_pin().
MTL Graphics backporting - 2024Q2

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c94debf36816157de1105a186b061fd90dab574a.1710949619.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
commit caf3d74 upstream.

UHBR13.5 is not supported in MTL and also the DP2.1 spec says UHBR13.5
is optional. Hence removing UHBR135 from the supported link rates.

v2: Reframed the commit message and added link to the issue.

deepin-Intel-SIG: commit caf3d74 drm/i915/dp: Remove support for UHBR13.5.
MTL Graphics backporting - 2024Q2

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Fixes: 62618c7 ("drm/i915/mtl: C20 PLL programming")
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Animesh Manna <animesh.manna@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240228144350.3184930-1-arun.r.murthy@intel.com
(cherry picked from commit ddf8a8b)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
[ Quanxian Wang: amend commit log ]
Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
@deepin-ci-robot
Copy link

deepin pr auto review

i915: Fix broken PCI IDs for Tiger Lake and Ryzen 7 4700G

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@311788 91177308-0d34-0410-b5e6-96231b3b80d8

@matrix-wsk matrix-wsk merged commit 0969b9a into deepin-community:linux-6.6.y Jul 19, 2024
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Jul 11, 2025
…keeping

[ Upstream commit e2d2115 ]

Yi Lai reported an issue ([1]) where the following warning appears
in kernel dmesg:
  [   60.643604] verifier backtracking bug
  [   60.643635] WARNING: CPU: 10 PID: 2315 at kernel/bpf/verifier.c:4302 __mark_chain_precision+0x3a6c/0x3e10
  [   60.648428] Modules linked in: bpf_testmod(OE)
  [   60.650471] CPU: 10 UID: 0 PID: 2315 Comm: test_progs Tainted: G           OE       6.15.0-rc4-gef11287f8289-dirty deepin-community#327 PREEMPT(full)
  [   60.654385] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
  [   60.656682] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
  [   60.660475] RIP: 0010:__mark_chain_precision+0x3a6c/0x3e10
  [   60.662814] Code: 5a 30 84 89 ea e8 c4 d9 01 00 80 3d 3e 7d d8 04 00 0f 85 60 fa ff ff c6 05 31 7d d8 04
                       01 48 c7 c7 00 58 30 84 e8 c4 06 a5 ff <0f> 0b e9 46 fa ff ff 48 ...
  [   60.668720] RSP: 0018:ffff888116cc7298 EFLAGS: 00010246
  [   60.671075] RAX: 54d70e82dfd31900 RBX: ffff888115b65e20 RCX: 0000000000000000
  [   60.673659] RDX: 0000000000000001 RSI: 0000000000000004 RDI: 00000000ffffffff
  [   60.676241] RBP: 0000000000000400 R08: ffff8881f6f23bd3 R09: 1ffff1103ede477a
  [   60.678787] R10: dffffc0000000000 R11: ffffed103ede477b R12: ffff888115b60ae8
  [   60.681420] R13: 1ffff11022b6cbc4 R14: 00000000fffffff2 R15: 0000000000000001
  [   60.684030] FS:  00007fc2aedd80c0(0000) GS:ffff88826fa8a000(0000) knlGS:0000000000000000
  [   60.686837] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  [   60.689027] CR2: 000056325369e000 CR3: 000000011088b002 CR4: 0000000000370ef0
  [   60.691623] Call Trace:
  [   60.692821]  <TASK>
  [   60.693960]  ? __pfx_verbose+0x10/0x10
  [   60.695656]  ? __pfx_disasm_kfunc_name+0x10/0x10
  [   60.697495]  check_cond_jmp_op+0x16f7/0x39b0
  [   60.699237]  do_check+0x58fa/0xab10
  ...

Further analysis shows the warning is at line 4302 as below:

  4294                 /* static subprog call instruction, which
  4295                  * means that we are exiting current subprog,
  4296                  * so only r1-r5 could be still requested as
  4297                  * precise, r0 and r6-r10 or any stack slot in
  4298                  * the current frame should be zero by now
  4299                  */
  4300                 if (bt_reg_mask(bt) & ~BPF_REGMASK_ARGS) {
  4301                         verbose(env, "BUG regs %x\n", bt_reg_mask(bt));
  4302                         WARN_ONCE(1, "verifier backtracking bug");
  4303                         return -EFAULT;
  4304                 }

With the below test (also in the next patch):
  __used __naked static void __bpf_jmp_r10(void)
  {
	asm volatile (
	"r2 = 2314885393468386424 ll;"
	"goto +0;"
	"if r2 <= r10 goto +3;"
	"if r1 >= -1835016 goto +0;"
	"if r2 <= 8 goto +0;"
	"if r3 <= 0 goto +0;"
	"exit;"
	::: __clobber_all);
  }

  SEC("?raw_tp")
  __naked void bpf_jmp_r10(void)
  {
	asm volatile (
	"r3 = 0 ll;"
	"call __bpf_jmp_r10;"
	"r0 = 0;"
	"exit;"
	::: __clobber_all);
  }

The following is the verifier failure log:
  0: (18) r3 = 0x0                      ; R3_w=0
  2: (85) call pc+2
  caller:
   R10=fp0
  callee:
   frame1: R1=ctx() R3_w=0 R10=fp0
  5: frame1: R1=ctx() R3_w=0 R10=fp0
  ; asm volatile ("                                 \ @ verifier_precision.c:184
  5: (18) r2 = 0x20202000256c6c78       ; frame1: R2_w=0x20202000256c6c78
  7: (05) goto pc+0
  8: (bd) if r2 <= r10 goto pc+3        ; frame1: R2_w=0x20202000256c6c78 R10=fp0
  9: (35) if r1 >= 0xffe3fff8 goto pc+0         ; frame1: R1=ctx()
  10: (b5) if r2 <= 0x8 goto pc+0
  mark_precise: frame1: last_idx 10 first_idx 0 subseq_idx -1
  mark_precise: frame1: regs=r2 stack= before 9: (35) if r1 >= 0xffe3fff8 goto pc+0
  mark_precise: frame1: regs=r2 stack= before 8: (bd) if r2 <= r10 goto pc+3
  mark_precise: frame1: regs=r2,r10 stack= before 7: (05) goto pc+0
  mark_precise: frame1: regs=r2,r10 stack= before 5: (18) r2 = 0x20202000256c6c78
  mark_precise: frame1: regs=r10 stack= before 2: (85) call pc+2
  BUG regs 400

The main failure reason is due to r10 in precision backtracking bookkeeping.
Actually r10 is always precise and there is no need to add it for the precision
backtracking bookkeeping.

One way to fix the issue is to prevent bt_set_reg() if any src/dst reg is
r10. Andrii suggested to go with push_insn_history() approach to avoid
explicitly checking r10 in backtrack_insn().

This patch added push_insn_history() support for cond_jmp like 'rX <op> rY'
operations. In check_cond_jmp_op(), if any of rX or rY is a stack pointer,
push_insn_history() will record such information, and later backtrack_insn()
will do bt_set_reg() properly for those register(s).

  [1] https://lore.kernel.org/bpf/Z%2F8q3xzpU59CIYQE@ly-workstation/

Reported by: Yi Lai <yi1.lai@linux.intel.com>

Fixes: 407958a ("bpf: encapsulate precision backtracking bookkeeping")
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250524041335.4046126-1-yonghong.song@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 4265682c29c92f52c0da6fad5a79b5801462c8de)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.