Compare

4db45fc1da3d62d0fa6e8f1e457ae92e8741ed07..448e76cbdc6652ccd3ba337b7a6e1f028859f2ed

drm/xe: skip eviction of a BO with no resource

xe_evict_flags() switches on tbo->resource->mem_type to choose an
eviction placement. An xe BO can reach eviction with no ttm.resource,
e.g. an imported dma-buf BO whose resource was freed during teardown
while its attachment is still live: the exporter then invalidates it via
xe_dma_buf_move_notify() -> xe_bo_evict(), and the switch dereferences a
NULL resource and faults.

A BO with no resource has nothing placed or mapped, so there is nothing
to evict. Return an empty placement (num_placement = 0), mirroring the
handling already used for non-xe scatter-gather BOs just above;
ttm_bo_validate() then takes the pipeline-gutting path and returns 0.

Without the fix the xe_dma_buf@xe_test_dmabuf_move_notify_no_resource
dynamic live selftest will fail with below stack.

BUG: kernel NULL pointer dereference, address: 0000000000000010
RIP: 0010:xe_evict_flags+0xf4/0x140 [xe]
Call Trace:
 <TASK>
 xe_bo_evict+0x40/0xa0 [xe]
 ? ttm_bo_pipeline_gutting+0x71/0x180 [ttm]
 xe_test_dmabuf_move_notify_no_resource+0x182/0x440 [xe]
 xe_dma_buf_kunit+0x387/0x580 [xe]

v2: Add Fixes tag and failure info in commit text (Matt Brost)

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Assisted-by: GitHub-Copilot:claude-opus-4.8
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patch.msgid.link/20261012215014.1495677-5-niranjana.vishwanathapura@intel.com
(cherry picked from commit dbcfaac6331f1fcb0c2fe3ad3e9adb1e5d43ec0c)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> · 2026-10-12 21:50 UTC · committed by Rodrigo Vivi

Browse files
7 files changed, +18 −9
modified drivers/gpu/drm/xe/xe_bo.c
@@ -330,6 +330,12 @@ static void xe_evict_flags(struct ttm_buffer_object *tbo,
330 330 return;
331 331 }
332 332
333 + /* No resource: nothing is placed/mapped, so there is nothing to evict. */
334 + if (!tbo->resource) {
335 + placement->num_placement = 0;
336 + return;
337 + }
338 +
333 339 bo = ttm_to_xe_bo(tbo);
334 340 if (bo->flags & XE_BO_FLAG_CPU_ADDR_MIRROR) {
335 341 *placement = sys_placement;
@@ -944,6 +950,8 @@ static int xe_bo_move_notify(struct xe_bo *bo,
944 950 *
945 951 * Transfers pages between shrinkable and purgeable buckets when the BO
946 952 * purgeable state changes. Called automatically from xe_bo_set_purgeable_state().
953 + * For pinned BOs, whose pages are not accounted, only the purgeable flag is
954 + * updated, so that the correct bucket is used when the BO is unpinned.
947 955 */
948 956 static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
949 957 enum xe_madv_purgeable_state new_state)
@@ -960,7 +968,8 @@ static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
960 968 return;
961 969
962 970 xe_tt = container_of(tt, struct xe_ttm_tt, ttm);
963 - tt_pages = tt->num_pages;
971 + /* Pinned bos are not accounted. Only update the purgeable flag. */
972 + tt_pages = xe_bo_is_pinned(bo) ? 0 : tt->num_pages;
964 973
965 974 if (!xe_tt->purgeable && new_state == XE_MADV_PURGEABLE_DONTNEED) {
966 975 xe_tt->purgeable = true;
modified sound/soc/codecs/cs42l52.c
@@ -290,7 +290,7 @@ static const char * const cs42l52_ng_type_text[] = {
290 290 };
291 291
292 292 static SOC_ENUM_SINGLE_DECL(ng_type_enum,
293 - CS42L52_NOISE_GATE_CTL, 7,
293 + CS42L52_NOISE_GATE_CTL, 6,
294 294 cs42l52_ng_type_text);
295 295
296 296 static const char * const left_swap_text[] = {
modified sound/soc/codecs/cs42l56.c
@@ -481,7 +481,7 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = {
481 481 0, 0x3f, 0, 0),
482 482 SOC_SINGLE_TLV("Limiter MAX", CS42L56_LIM_THRESHOLD_CTL,
483 483 5, 0x07, 1, alc_tlv),
484 - SOC_SINGLE_TLV("Limiter Cushion", CS42L56_LIM_THRESHOLD_CTL,
484 + SOC_SINGLE_TLV("Limiter Cushion", CS42L56_ALC_THRESHOLD,
485 485 2, 0x07, 1, alc_tlv),
486 486
487 487 SOC_SINGLE("NG Switch", CS42L56_NOISE_GATE_CTL, 6, 1, 1),
modified sound/soc/codecs/max98371.c
@@ -166,7 +166,7 @@ static const struct snd_kcontrol_new max98371_snd_controls[] = {
166 166 0, (1<<MAX98371_DHT_MAX_WIDTH)-1, 0,
167 167 max98371_dht_max_gain),
168 168 SOC_SINGLE_TLV("Speaker DHT Min Volume", MAX98371_DHT_GAIN,
169 - 4, (1<<MAX98371_DHT_GAIN_WIDTH)-1, 0,
169 + 0, (1<<MAX98371_DHT_GAIN_WIDTH)-1, 0,
170 170 max98371_dht_min_gain),
171 171 SOC_SINGLE_TLV("Speaker DHT Rotation Volume", MAX98371_DHT_GAIN,
172 172 0, (1<<MAX98371_DHT_ROT_WIDTH)-1, 0,
modified sound/soc/codecs/nau8822.c
@@ -383,9 +383,9 @@ static const struct snd_kcontrol_new nau8822_snd_controls[] = {
383 383 NAU8822_REG_RIGHT_ADC_BOOST_CONTROL, 0, 7, 0, boost_tlv),
384 384
385 385 SOC_SINGLE("DAC 128x Oversampling Switch",
386 - NAU8822_REG_DAC_CONTROL, 3, 1, 0),
386 + NAU8822_REG_DAC_CONTROL, 5, 1, 0),
387 387 SOC_SINGLE("ADC 128x Oversampling Switch",
388 - NAU8822_REG_ADC_CONTROL, 3, 1, 0),
388 + NAU8822_REG_ADC_CONTROL, 5, 1, 0),
389 389 };
390 390
391 391 /* LMAIN and RMAIN Mixer */
modified sound/soc/codecs/pcm3168a.c
@@ -103,7 +103,7 @@ static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_func, PCM3168A_DAC_ATT_DEMP_ZF,
103 103 static const char *const pcm3168a_pol[] = { "Active High", "Active Low" };
104 104
105 105 static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_pol, PCM3168A_DAC_ATT_DEMP_ZF,
106 - PCM3168A_DAC_ZREV_SHIFT, pcm3168a_pol);
106 + PCM3168A_DAC_ATSPDA_SHIFT, pcm3168a_pol);
107 107
108 108 static const char *const pcm3168a_con[] = { "Differential", "Single-Ended" };
109 109
modified sound/soc/codecs/wm8978.c
@@ -255,9 +255,9 @@ static const struct snd_kcontrol_new wm8978_snd_controls[] = {
255 255
256 256 /* DAC / ADC oversampling */
257 257 SOC_SINGLE("DAC 128x Oversampling Switch", WM8978_DAC_CONTROL,
258 - 3, 1, 0),
258 + 5, 1, 0),
259 259 SOC_SINGLE("ADC 128x Oversampling Switch", WM8978_ADC_CONTROL,
260 - 3, 1, 0),
260 + 5, 1, 0),
261 261 };
262 262
263 263 /* Mixer #1: Output (OUT1, OUT2) Mixer: mix AUX, Input mixer output and DAC */