Compare

ffbfd3f98f4393e91dffce3a46ccb7cf5329cf2f..8cb5c17be3a2fadc41075d04ce1c24c831546aaf

i2c: qcom-geni: Restore the source-clock selection policy

Currently, the source clock lookup prefers 32 MHz whenever that rate is
available, regardless of the rate configured by the platform. Before the
switch to looking up the clock index, the driver used the 32 MHz timing
table only if the current source clock rate was 32 MHz, and the 19.2 MHz
table otherwise.

On X1E80100 CRD, this results in switching the source clock from 19.2 MHz
to 32 MHz, which causes intermittent failures when probing the I2C HID
keyboard. These range from corrupted HID descriptors to failed resets
and transfer timeouts, which also affect the touchpad on the same bus.

Restore the original selection policy: use 32 MHz if already selected,
otherwise request 19.2 MHz. Look up the index for the selected rate and
keep the check that rejects higher-frequency multiples. This retains
the dynamic clock index lookup without preferring 32 MHz on platforms
that previously used 19.2 MHz. Report the requested rate if the lookup
fails.

Fixes: cb97bf3d4f91 ("i2c: qcom-geni: Fix hardcoded clock index in SE_GENI_CLK_SEL")
Assisted-by: LLM
Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
Tested-by: Hasty Heat <hastyheat@gmail.com>
Tested-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Reviewed-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20260928-b4-i2c-qcom-geni-preserve-source-clock-v1-1-9aded7552a76@oss.qualcomm.com

Abel Vesa <abel.vesa@oss.qualcomm.com> · 2026-09-28 13:58 UTC · committed by Andi Shyti

Browse files
3 files changed, +22 −22
modified drivers/gpu/drm/xe/xe_bo.c
@@ -944,8 +944,6 @@ 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.
949 947 */
950 948 static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
951 949 enum xe_madv_purgeable_state new_state)
@@ -962,8 +960,7 @@ static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
962 960 return;
963 961
964 962 xe_tt = container_of(tt, struct xe_ttm_tt, ttm);
965 - /* Pinned bos are not accounted. Only update the purgeable flag. */
966 - tt_pages = xe_bo_is_pinned(bo) ? 0 : tt->num_pages;
963 + tt_pages = tt->num_pages;
967 964
968 965 if (!xe_tt->purgeable && new_state == XE_MADV_PURGEABLE_DONTNEED) {
969 966 xe_tt->purgeable = true;
modified drivers/i2c/busses/i2c-qcom-geni.c
@@ -201,28 +201,31 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
201 201 static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
202 202 {
203 203 const struct geni_i2c_clk_fld *itr;
204 - unsigned long res_freq;
204 + unsigned long req_freq, res_freq;
205 + int ret;
205 206
206 207 /*
207 - * Frequency counter tables are calibrated for a specific source
208 - * clock frequency and are not valid for any multiple of it
209 - * (e.g. 64 MHz, 128 MHz).
210 - * Use exact=true and verify res_freq matches req_freq literally
211 - * to reject harmonics: a 64 MHz clock that divides evenly to
212 - * 32 MHz would pass exact matching but produce double the intended
213 - * I2C frequency with these counter values.
208 + * Use 32 MHz only if already selected, otherwise use 19.2 MHz.
209 + * Preferring 32 MHz merely because DFS supports it breaks I2C
210 + * transfers on X1E80100 CRD.
214 211 */
215 - if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_32MHZ,
216 - &gi2c->clk_idx, &res_freq, true) &&
217 - res_freq == GENI_SE_CLK_32MHZ) {
212 + if (clk_get_rate(gi2c->se.clk) == GENI_SE_CLK_32MHZ) {
213 + req_freq = GENI_SE_CLK_32MHZ;
218 214 itr = geni_i2c_clk_map_32mhz;
219 - } else if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ,
220 - &gi2c->clk_idx, &res_freq, true) &&
221 - res_freq == GENI_SE_CLK_19P2MHZ) {
222 - itr = geni_i2c_clk_map_19p2mhz;
223 215 } else {
224 - dev_err(gi2c->se.dev,
225 - "Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n");
216 + req_freq = GENI_SE_CLK_19P2MHZ;
217 + itr = geni_i2c_clk_map_19p2mhz;
218 + }
219 +
220 + ret = geni_se_clk_freq_match(&gi2c->se, req_freq, &gi2c->clk_idx,
221 + &res_freq, true);
222 + if (ret)
223 + return dev_err_probe(gi2c->se.dev, ret,
224 + "Failed to find SE source clock %lu Hz\n",
225 + req_freq);
226 + if (res_freq != req_freq) {
227 + dev_err(gi2c->se.dev, "Unsupported SE source clock %lu Hz\n",
228 + res_freq);
226 229 return -EINVAL;
227 230 }
228 231
modified drivers/i2c/busses/i2c-viai2c-wmt.c
@@ -116,7 +116,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
116 116 if (err)
117 117 return err;
118 118
119 - i2c->clk = of_clk_get(np, 0);
119 + i2c->clk = devm_clk_get(&pdev->dev, NULL);
120 120 if (IS_ERR(i2c->clk))
121 121 return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
122 122 "unable to request clock\n");