Compare
f7934340c56a84fc1b246ebf6b2e806d775f3b54..ffbfd3f98f4393e91dffce3a46ccb7cf5329cf2f
drm/xe: Don't transfer shrinker pages for pinned bos on purgeable state change
Pinned bos have their pages removed from the shrinker's shrinkable /
purgeable counts on pin, and added back on unpin according to the
bo's purgeable state at that time.
However, xe_bo_set_purgeable_shrinker() unconditionally transfers
pages between the shrinkable and purgeable counts. If the purgeable
state of a pinned bo changes, for example by userspace madvising
DONTNEED on a VMA of a bo that is also pinned as a scanout buffer,
this underflows one count and, after unpin, leaves the other one
permanently inflated.
Only update the purgeable flag for pinned bos, and leave the page
accounting to unpin.
Fixes: 536a2ead3a8f ("drm/xe/bo: Add purgeable shrinker state helpers")
Cc: Arvind Yadav <arvind.yadav@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v7.1+
Assisted-by: LLM
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20261009070053.7790-1-thomas.hellstrom@linux.intel.com
(cherry picked from commit afe6bc012034123fd838328668e609bf57e46bd3)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Thomas Hellström <thomas.hellstrom@linux.intel.com> · 2026-10-09 07:00 UTC · committed by Rodrigo Vivi
5 files changed,
+8
−5
- drivers/gpu/drm/xe/xe_bo.c
- sound/soc/codecs/cs42l52.c
- sound/soc/codecs/cs42l56.c
- sound/soc/codecs/max98371.c
- sound/soc/codecs/pcm3168a.c
modified drivers/gpu/drm/xe/xe_bo.c
| @@ -944,6 +944,8 @@ static int xe_bo_move_notify(struct xe_bo *bo, | |||
| 944 | 944 | * | |
| 945 | 945 | * Transfers pages between shrinkable and purgeable buckets when the BO | |
| 946 | 946 | * purgeable state changes. Called automatically from xe_bo_set_purgeable_state(). | |
| 947 | + | * For pinned BOs, whose pages are not accounted, only the purgeable flag is | |
| 948 | + | * updated, so that the correct bucket is used when the BO is unpinned. | |
| 947 | 949 | */ | |
| 948 | 950 | static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo, | |
| 949 | 951 | enum xe_madv_purgeable_state new_state) | |
| @@ -960,7 +962,8 @@ static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo, | |||
| 960 | 962 | return; | |
| 961 | 963 | ||
| 962 | 964 | xe_tt = container_of(tt, struct xe_ttm_tt, ttm); | |
| 963 | - | tt_pages = tt->num_pages; | |
| 965 | + | /* Pinned bos are not accounted. Only update the purgeable flag. */ | |
| 966 | + | tt_pages = xe_bo_is_pinned(bo) ? 0 : tt->num_pages; | |
| 964 | 967 | ||
| 965 | 968 | if (!xe_tt->purgeable && new_state == XE_MADV_PURGEABLE_DONTNEED) { | |
| 966 | 969 | 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/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 | ||