From nobody Sun Oct 5 00:07:08 2025 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 302AA26B770; Mon, 11 Aug 2025 19:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941810; cv=none; b=rEgCWjvQ1RDnMVQF9YAF/n6DdhQ45ZS3zxDggDCUbIIib7+Z/yY29LoS25tb/6O8i0e1/ALx2+JPigiPKS7W594PF0Hr7d4PWp1uRI9qSwazjc1Fg9Au0VIuwzAWdVFaLZIuV+NTwlxSzUlJgv4aEpzQZT4indPRu/tyuGdfkSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941810; c=relaxed/simple; bh=PH828i8F95x+IM7qH1JCu9X3cnVIzu8pZHAK1h7NpHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TYA1Yt7OXAGr3th46Xj4kCCg4KGQK7JoF4+fdtEE6pGBb5MsA131uBRSPSZD3HGJxxvNd4mFpfn+a1E0Tv6KMEQMyWJ41qUIKQQAL//Z+1cIuDzcmc7zXwEIRFnUTa+UkbxcWCLvrv+4zTkYHnnWXQ5HO6UjzYFCluuWHMqJb4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cYgB9mik; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cYgB9mik" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3b792b0b829so4557101f8f.3; Mon, 11 Aug 2025 12:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754941807; x=1755546607; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=A86eQzX7viGNjFU7NpXeyNyVEzQ5puYbkA22fGhwrf8=; b=cYgB9mikKSRipTY9P19qrg/BqJvzq6Fe/ZJMHpV2FgADmGvCBcBKUrTd353fzFAuF3 zl2DGMCjlg/GnWAEG/F9Xu7OhlWtqDxQ6RhCgkWxtY1ZG1ODYyXPR4GafSd7zwjWmxIZ fR/uQHSizY8+IbcpPKZVgxh2CQjSiosqB3WR3y2Gk4xQfXvzYvmNHOrS78Sis7INNjoh 3628ezmt8/+4c5LZDosdAZWEeqsdCzxWwdXkp0YYA9yaIiAnrt0HGU96SjFKltb7MuU4 dY9wwnCY7ngRjm9VYJsf52lOYIJvxdwAUdTR1qTZ2eQQl/Ya+A+W33ANU7sZhfLf8UIs d+Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754941807; x=1755546607; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A86eQzX7viGNjFU7NpXeyNyVEzQ5puYbkA22fGhwrf8=; b=XK9yOxSsa6MuH79dTksmUuYMpRzWXFwm4/veHrTWima2hXoipjxFAwsJzS6C50JHXq 51c1grnCCCNZ9KqAEDWsMIA2rovqXklvZOfgi2lKTzu22G+PHI2xCStYbvHTZWnggc3n FPC5Ilnmfn9OIZgoQfV6H0oAfp37YUJsK2H7ZDdqEAArZe6GcYxkG8PEEOONWTQTT4am v4lBD9S8KE7cg9I7MdZJoYxg5hqiu58USifRtLpMC1Ue0I+Cg3InFE4aa3aYmnpFrv64 EbEyyd9NnA5ean6LTTndmRcWbTrjAhb9eNrj71qXDxgx5GnMpGGGNEd0AoY8fKg5kY0r iaFw== X-Forwarded-Encrypted: i=1; AJvYcCW998cJ6B+/av9XNCKYT8vrQMpkTaLznOtQ4l2qJIaVw2UQ0PAv42ZrM6/8WUBBkqhqGddS6NxXQI8=@vger.kernel.org, AJvYcCWWFJT8BN4fjNAm7/kdeU7xLYKreQtRJdy6Fdq8XEoNtcR/mPvOfM42SzGnn6yDdwsOVS27IHqx@vger.kernel.org, AJvYcCWYrnnWEGRuQBqGj+jkGx0y5104bSFDa+NzC4lnwzsA0QluBXGbgGV92vJ2LndcPx0uvOfYAI97BmedafEs@vger.kernel.org X-Gm-Message-State: AOJu0YxCTk6ylVclbyUlubblk08ZOVjhDuGcmL5uCos97u1x4MPcVPzE oqgg4MLpfU9llO6g2c4lzgu0evK2QgI4PEGzU2f/kRXRySiC9Duifc44tfGG3w== X-Gm-Gg: ASbGnculqBc66Sy4+IkFAi7sXaR4QshUoUdztMu+6TwxNBOVuFNGautkVqjszqPXjqa 3KFN51+CmTiEbff81xFb2Ft6vAkznHAsr7ifHyLdehFYxNRG+bEC0buSSx9o9epMLtfi035+4hk ZoSLANspaZ7K2CIuCQDfZ6TuWLGLfxSyPgb2Tg3yDqiyz1UG5AAW77aBDkPrGuGo9bnplv01dTz EmWBrRDQ/VMd98KpoTk45+axDPMDiWrUBYv/mQ/jmOBZhW6loWDA2emEOdTbFQcl+jkcB0XygFd PR2KA+tVnX3MJ30r9+zZPWcKmoSjfvPdaAO4Vrynemf9NdGirf67kHHNcUZSZ7dhgWNKWgqgnqQ L3Rce48KcQE1royyYiBfnLURsHPjeztT2r4HSXcuKN5aLRYFfWPc= X-Google-Smtp-Source: AGHT+IFvzbFGti/zNFzqyikNiwvAvCk3OD9a3dG0vzUTIRLJMIn1arvJwDoou4hVVuywAjgs4uvv6w== X-Received: by 2002:a05:6000:2287:b0:3b8:f2f1:728c with SMTP id ffacd0b85a97d-3b900b74b3dmr11151929f8f.34.1754941807310; Mon, 11 Aug 2025 12:50:07 -0700 (PDT) Received: from [192.168.0.253] (5D59A51C.catv.pool.telekom.hu. [93.89.165.28]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3b79c3b9eddsm41709246f8f.22.2025.08.11.12.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Aug 2025 12:50:06 -0700 (PDT) From: Gabor Juhos Date: Mon, 11 Aug 2025 21:49:55 +0200 Subject: [PATCH v2 1/3] i2c: add init_recovery() callback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250811-i2c-pxa-fix-i2c-communication-v2-1-ca42ea818dc9@gmail.com> References: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> In-Reply-To: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> To: Wolfram Sang , Wolfram Sang , Andi Shyti , Andy Shevchenko , Russell King , Andrew Lunn , Hanna Hawa Cc: Robert Marko , Linus Walleij , Russell King , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Imre Kaloz , Gabor Juhos , stable@vger.kernel.org X-Mailer: b4 0.14.2 Add a new init_recovery() callback to struct 'i2c_bus_recovery_info' and modify the i2c_init_recovery() function to call that if specified instead of the generic i2c_gpio_init_recovery() function. This allows controller drivers to skip calling the generic code by implementing a dummy callback function, or alternatively to run a fine tuned custom implementation. This is needed for the 'i2c-pxa' driver in order to be able to fix a long standing bug for which the fix will be implemented in a followup patch. Cc: stable@vger.kernel.org # 6.3+ Signed-off-by: Imre Kaloz Reviewed-by: Linus Walleij Signed-off-by: Gabor Juhos --- Changes in v2: - add 'Reviewed-by' tag from Linus Walleij - rebase on tip of i2c/for-current --- drivers/i2c/i2c-core-base.c | 8 +++++++- include/linux/i2c.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index ecca8c006b020379fb53293b20ab09ba25314609..e38be81dbcc17dd15947a189fd3= b89def8529d1e 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -427,12 +427,18 @@ static int i2c_init_recovery(struct i2c_adapter *adap) struct i2c_bus_recovery_info *bri =3D adap->bus_recovery_info; bool is_error_level =3D true; char *err_str; + int ret; =20 if (!bri) return 0; =20 - if (i2c_gpio_init_recovery(adap) =3D=3D -EPROBE_DEFER) + if (bri->init_recovery) { + ret =3D bri->init_recovery(adap); + if (ret) + return ret; + } else if (i2c_gpio_init_recovery(adap) =3D=3D -EPROBE_DEFER) { return -EPROBE_DEFER; + } =20 if (!bri->recover_bus) { err_str =3D "no suitable method provided"; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 20fd41b51d5c85ee1665395c07345faafd8e2fca..4cefdd4c730fc9dc4655f6581f3= dea64435d7124 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -636,6 +636,9 @@ struct i2c_timings { * for generic GPIO recovery. * @get_bus_free: Returns the bus free state as seen from the IP core in c= ase it * has a more complex internal logic than just reading SDA. Optional. + * @init_recovery: If specified, it will be called instead of the generic = GPIO + * recovery initialization code. Platform may use a dummy callback to skip + * calling the generic code, or it may use a custom implementation. * @prepare_recovery: This will be called before starting recovery. Platfo= rm may * configure padmux here for SDA/SCL line or something else they want. * @unprepare_recovery: This will be called after completing recovery. Pla= tform @@ -660,6 +663,7 @@ struct i2c_bus_recovery_info { void (*set_sda)(struct i2c_adapter *adap, int val); int (*get_bus_free)(struct i2c_adapter *adap); =20 + int (*init_recovery)(struct i2c_adapter *adap); void (*prepare_recovery)(struct i2c_adapter *adap); void (*unprepare_recovery)(struct i2c_adapter *adap); =20 --=20 2.50.1 From nobody Sun Oct 5 00:07:08 2025 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C8A22D97A1; Mon, 11 Aug 2025 19:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941813; cv=none; b=ODdHo0ZUuJqyTFPTQLueOWgnjGcXoMIax10DOJl4rMTpul6xGfeU+AK+NWvE/YR48ziOUk/mNHhNup70DiYe1hMrQkdv8QX3UHt1I8WBpy75YCEpErYqKbOAsg+5KgL3aV5f1iv/mwR0ZMTHWr1NqN5+jUOwntKF0YGisO3B/sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941813; c=relaxed/simple; bh=9jBi72UGIIPP+FPDXzQtUkKAzbd0l4XF5BUIxLpWCHQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FZLQitlq5i90SHfYmE9uUjT2/J83mlqOkny+XwKALxxoCAfXT9zWq3rYOVWk11bQHbZLyc5jRS4h1Fe7mDu3qhTmCvew2Vsa6P4w8hpu5oazuSWQQ/3+MDJHIDTZW9YE4NR3BPeZeTuS42BeX6T0uwwNsMoyKhIcOaUqrKV1FT8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FfHbmdWy; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FfHbmdWy" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3b7892609a5so2698966f8f.1; Mon, 11 Aug 2025 12:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754941810; x=1755546610; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WSipPKw7P4A06KCm7mnemasTOa9V0fPZ36VwYLVvIxg=; b=FfHbmdWy2qrGhVvwdicLBi0Pf5SG09ATQAp7OpgkGOS7m4D1HLsUiBpXsnVtgx+/NI iGQjarqK2ET3dy4gZJhBj1DGGEdWtgSspFg6CjkkPQUlLHD5JQzFyBqWDPWn7A0QmJsJ FDFd7mI16GB6UUrHWE+8NXn0rgbA9edV7O5gmmudtZ0h/jRt0WpMQKiEMfaEhMPntIIZ 8f1635PfuqK6VnANK4Urw9vwnGth1spwmgpzFNkqH3XSTSE+Ke++uRqS/kcvfycMyNn9 9bn0OorQe61NEQ8P9S2bb13AGmSOA8Lub9CU4HQ50919LMBL/PNsY8ducSrEmZlSikLI T5Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754941810; x=1755546610; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WSipPKw7P4A06KCm7mnemasTOa9V0fPZ36VwYLVvIxg=; b=FY+Yl5U8t4Wu3hUtKXcCPWC6O2vGA1EzRMTMZvGIzD6LdNnrFGG3PT5O9sBhNiQ5di /pJitNpo3ccvNRkc5+qQ57/g/l23xAeq8AtkDXZmC+cSsfu+YDYYa++GUn0R6MNBqbsY 1PY2DsyNPASLen1aqPX48NaHp4BowyZhAOeB5fd47/C1zzSJyeauEDwxPS6Lbxw61wTA jxJ6CjBe83rbjVCtBkbbEoVsVc9mooVvQxz2gW0WnwQoGrYhpnuh+G2KbPaN3dfKBYdC RvL3tJj0quYzpzV8yji0z5/NYIdlVlnIVsWuPL5CrrfmU3f8hA7Nw2QfB73B9XignF2G detQ== X-Forwarded-Encrypted: i=1; AJvYcCWazICWjEf46m8KXExMwv1kZdVEhr8Os3xfUR3nRcfMcq6eqQ9amrP3mNSo71EzOCzn8lDKwC7iEAEUNeQF@vger.kernel.org, AJvYcCXKahmbYqCPLFIVC5qHcC5EnBGzaBXvYUefTErY0grKHSrBx3El1PaCfBkJ/nKe3TyNJ9SUxl3p@vger.kernel.org, AJvYcCXr85wKUAMzMz7fvZoTb9kf2vOmBmUHHi5yq6n26Q8JlYqp6sCIyLXTepjhO0n9ArHNYAG78DZtXNk=@vger.kernel.org X-Gm-Message-State: AOJu0YwQnxEEMujxgQ6Gld3093sSfNjjpJAsM0v4UQKckY4hzkZWW+o/ /swmabOBsNIsusEy22aEJpdUexVSC/cW1eAtd5p8tBuZ8EP6HehgQavMf/9dSA== X-Gm-Gg: ASbGncuRYwiGrkraW+7AUXN1o9J8rxsALf2EcLX3U16jfLatbrWN7N9upmgnaEU7mQw pRxHXdy3o106M57IAKaRD5M5HyFBq2luaNf4ANFiyRMSa+pcA4NhKOLhOIya5KH9oeiJ/k5YtKY UjqnHq8+E2ypxl9cYdStzAtqyXoUA25huS/OmAyMxiS1N6r9M8G/w2CbtE5+De5DUBasGdPWrTi WqgLncrnIT3BakCU9DrSoCxzfKJujJiozNusOyO+6b3T0hK6Rm2jcigaqN+LjLtV56NEqJrsMWw b+Vv5i27u80SftuLMXHb42MmPNFzaBhh/xKiPiMsFg7Vhm8aXTzWPlhNpBh61PdJBwyrab5mh5R 2WEY0XvEAX1yQTW9C16hXcQPSdVu87vybv7J/bbDw8wDgl1lsgjYbBfZ4oXNxdw== X-Google-Smtp-Source: AGHT+IEMvdMt76tULvaX1DNA9rP7wy9hsoqhDHvOI8Fp0uIBsF401YmUeXKvfshA/CBg6m/VRcfecA== X-Received: by 2002:a05:6000:220f:b0:3a5:2d42:aa25 with SMTP id ffacd0b85a97d-3b91100f094mr756349f8f.50.1754941809599; Mon, 11 Aug 2025 12:50:09 -0700 (PDT) Received: from [192.168.0.253] (5D59A51C.catv.pool.telekom.hu. [93.89.165.28]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3b79c3b9eddsm41709246f8f.22.2025.08.11.12.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Aug 2025 12:50:09 -0700 (PDT) From: Gabor Juhos Date: Mon, 11 Aug 2025 21:49:56 +0200 Subject: [PATCH v2 2/3] i2c: pxa: prevent calling of the generic recovery init code Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250811-i2c-pxa-fix-i2c-communication-v2-2-ca42ea818dc9@gmail.com> References: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> In-Reply-To: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> To: Wolfram Sang , Wolfram Sang , Andi Shyti , Andy Shevchenko , Russell King , Andrew Lunn , Hanna Hawa Cc: Robert Marko , Linus Walleij , Russell King , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Imre Kaloz , Gabor Juhos , stable@vger.kernel.org X-Mailer: b4 0.14.2 The I2C communication is completely broken on the Armada 3700 platform since commit 0b01392c18b9 ("i2c: pxa: move to generic GPIO recovery"). For example, on the Methode uDPU board, probing of the two onboard temperature sensors fails ... [ 7.271713] i2c i2c-0: using pinctrl states for GPIO recovery [ 7.277503] i2c i2c-0: PXA I2C adapter [ 7.282199] i2c i2c-1: using pinctrl states for GPIO recovery [ 7.288241] i2c i2c-1: PXA I2C adapter [ 7.292947] sfp sfp-eth1: Host maximum power 3.0W [ 7.299614] sfp sfp-eth0: Host maximum power 3.0W [ 7.308178] lm75 1-0048: supply vs not found, using dummy regulator [ 32.489631] lm75 1-0048: probe with driver lm75 failed with error -121 [ 32.496833] lm75 1-0049: supply vs not found, using dummy regulator [ 82.890614] lm75 1-0049: probe with driver lm75 failed with error -121 ... and accessing the plugged-in SFP modules also does not work: [ 511.298537] sfp sfp-eth1: please wait, module slow to respond [ 536.488530] sfp sfp-eth0: please wait, module slow to respond ... [ 1065.688536] sfp sfp-eth1: failed to read EEPROM: -EREMOTEIO [ 1090.888532] sfp sfp-eth0: failed to read EEPROM: -EREMOTEIO After a discussion [1], there was an attempt to fix the problem by reverting the offending change by commit 7b211c767121 ("Revert "i2c: pxa: move to generic GPIO recovery""), but that only helped to fix the issue in the 6.1.y stable tree. The reason behind the partial succes is that there was another change in commit 20cb3fce4d60 ("i2c: Set i2c pinctrl recovery info from it's device pinctrl") in the 6.3-rc1 cycle which broke things further. The cause of the problem is the same in case of both offending commits mentioned above. Namely, the I2C core code changes the pinctrl state to GPIO while running the recovery initialization code. Although the PXA specific initialization also does this, but the key difference is that it happens before the conrtoller is getting enabled in i2c_pxa_reset(), whereas in the case of the generic initialization it happens after that. To resolve the problem, provide an empty init_recovery() callback function thus preventing the I2C core to call the generic recovery initialization code. As the result this change restores the original behaviour, which in turn makes the I2C communication to work again as it can be seen from the following log: [ 7.305277] i2c i2c-0: PXA I2C adapter [ 7.310198] i2c i2c-1: PXA I2C adapter [ 7.315012] sfp sfp-eth1: Host maximum power 3.0W [ 7.324061] lm75 1-0048: supply vs not found, using dummy regulator [ 7.331738] sfp sfp-eth0: Host maximum power 3.0W [ 7.337000] hwmon hwmon0: temp1_input not attached to any thermal zone [ 7.343593] lm75 1-0048: hwmon0: sensor 'tmp75c' [ 7.348526] lm75 1-0049: supply vs not found, using dummy regulator [ 7.356858] hwmon hwmon1: temp1_input not attached to any thermal zone [ 7.363463] lm75 1-0049: hwmon1: sensor 'tmp75c' ... [ 7.730315] sfp sfp-eth1: module Mikrotik S-RJ01 rev= 1.0 sn 61B103C55C58 dc 201022 [ 7.840318] sfp sfp-eth0: module MENTECHOPTO POS22-LDCC-KR rev= 1.0 sn MNC208U90009 dc 200828 [ 7.850083] mvneta d0030000.ethernet eth0: unsupported SFP module: no = common interface modes [ 7.990335] hwmon hwmon2: temp1_input not attached to any thermal zone [1] https://lore.kernel.org/r/20230926160255.330417-1-robert.marko@sartura.= hr Cc: stable@vger.kernel.org # 6.3+ Fixes: 20cb3fce4d60 ("i2c: Set i2c pinctrl recovery info from it's device p= inctrl") Signed-off-by: Gabor Juhos Signed-off-by: Imre Kaloz --- Changes in v2: - rebase and retest on tip of i2c/for-current --- drivers/i2c/busses/i2c-pxa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 968a8b8794dac3398a68d827c567aa5bb73ae3d7..f4cb36e22077753e21b0260df52= b8bdbb85fa308 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -1330,6 +1330,12 @@ static void i2c_pxa_unprepare_recovery(struct i2c_ad= apter *adap) i2c_pxa_enable(i2c); } =20 +static int i2c_pxa_init_recovery_cb(struct i2c_adapter *adap) +{ + /* We have initialized everything already, so nothing to do here. */ + return 0; +} + static int i2c_pxa_init_recovery(struct pxa_i2c *i2c) { struct i2c_bus_recovery_info *bri =3D &i2c->recovery; @@ -1398,6 +1404,7 @@ static int i2c_pxa_init_recovery(struct pxa_i2c *i2c) return 0; } =20 + bri->init_recovery =3D i2c_pxa_init_recovery_cb; bri->prepare_recovery =3D i2c_pxa_prepare_recovery; bri->unprepare_recovery =3D i2c_pxa_unprepare_recovery; bri->recover_bus =3D i2c_generic_scl_recovery; --=20 2.50.1 From nobody Sun Oct 5 00:07:08 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BD62D9EEA; Mon, 11 Aug 2025 19:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941815; cv=none; b=cihzMlGPayr8fHmboidv5ctt3MPq19hhrmiU30DEbF46ER17F0YIdUoobCRfI6vsLcFbtDJjeYUgqKf0rP+kyt1tlTDXzTKmGG+/0mo9f4hgkFdQlIS8WuqR3xkxVhOlfE4XWOzEx29vX6V032J4IihENOEFF+x+xXnhLQKfA6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754941815; c=relaxed/simple; bh=89jFVCcvH315+OBPK+ER309BSdX2dvJBAwSZQuHsMXA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t7ncg/SiLbpPvU15lKgxf//OlFIRxOhLSkrw9txfsPRfu/3wW5+Ztwyqr0mIIqBN1lvByw3oflOPPr9zM00NHgRiTh5JnEziyiOE+4zOLeDVSthz9KCu4cPdlMqvd47IpjqCmTeQAb3IiPhuscAeoBv9jZfkNJjENSTiJxxpH8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KtiHDyeg; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KtiHDyeg" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3b8de6f7556so2645808f8f.1; Mon, 11 Aug 2025 12:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754941811; x=1755546611; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Dq0f9hbxOiPcgOoagCVQftGeGCtA482uSOeV1n3ljhk=; b=KtiHDyeg0Avxc5/RGyN80z5Q3QvboT7EyLd/mik0xcXDazF2bfXQ6OBpeG5FZM3nxq pe90rVorQ/KiuGnPZYnbwPhdNXRwq7RyK+WClJLWGTKEIjLKUyb4vMozHaFDcPuxhT5S f1poiCrBB27wD9S/qRCFHJKFHDATG8egWCVVfhosRuXiOYKnKuezj3vdEQcLRYsbr3Ox RJ4f+eBMurs2c8RHvpmu6lI5xq6FcfEwbiG6mNB/NaL5mYGs92q/361g4i+3mYl8/b9u MqkEZ2amgAlMPnDx93jTXNRYaj1da8+dkj4CuoFkXbUe6MRNyPAEoLo0wft68xdPvbas qyeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754941811; x=1755546611; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dq0f9hbxOiPcgOoagCVQftGeGCtA482uSOeV1n3ljhk=; b=BfMkhPRl192c1P/rh/BnGMNnx8xVlQixlCT7291ObiyQEOKQ1ui/agkb9AsIqRdoTT k5aIs/1ObAmh3j7ujggAz3DmoTXaKLGwmowfcmkeHrgvZpW2YVnvlZfaM/LFYR5MoXuO q4uqY3CaPNHFJrF3J2V3m29YfTs3UlKNYiWKdVTlJXi2ZForw3lxTBiomCe9cb/RBY4t c2Rv5hnjYVeO31f6CypFjtiWn9U6TAPYOS3l7+beMXHcONyPKLC0Q23tZi+/t/oIHNvR CASYSCRP/EStT2fkJEH3o7zyoX2hnIU5OBb8LIsmfgljx8Y0M9SLIFWxqecjwzg3rZLv UIPw== X-Forwarded-Encrypted: i=1; AJvYcCU8ZU+TztRvpfAm5NcmmUolH1OLfui3z/y+eXAon47dGBOTwwfshIVG/FRcB5kfLYmb1PfYB33x@vger.kernel.org, AJvYcCW5RVaLZPuTp7AThaztMCgKa667OLGCLuHzQ70k2rvbHFjRU3ERBnMQgO7BGoVrEMbP/fz5Abp6VIxBKV4f@vger.kernel.org, AJvYcCWksFJF6ie53IJUF2ikajT92G8h+k72+snZ8XtasIXHx1EHY20Eioko/t4jB18U43YTLkrneggys/M=@vger.kernel.org X-Gm-Message-State: AOJu0YwTITeAAtK/MA3w6qfhBJoYAbinqSuwHZTBZbvpt8u0ztZfzg2R lfGAaP1nBMk0L0XX4EPbRJIZki+q3fGmbeDs54mAhZRb0JXdMz11cPPg92k2iA== X-Gm-Gg: ASbGncutz7TV6p/Y9V1JnVZ9O9bp3yONseGFvzSvxVxZ99SNNDOgdh2oP/OKIplRdZu AzDbg4dMa2vpckr1JX2/p/ZssGB5v/Rgne/yDMyNXLy6mornSLs4JVpXyANZusVIh6VSjSmDbrs bZcNCvKnqh1LV19swfdGv39YQaHDSQVaTHJD2Fuyek0YfL4oKwE6mnqBX5Tt5/w7Rm9WzcKGdEH E9T5+6Y7tsgAVq7VjhcgLxtMyXVfXHbgx8xfA+30mdSWLyW5r7yoOUZMFKQ1Xazm06U0Ykfucfd xuD4w81q85mrp50HCqDtG04OpA4L28ITKrvFxqMftepHVYxqdm9CjwVJR/tABVX89wofLzYZSKG KAUeIevHt1pCN1j2OZWiAHQVO4onALrJWKsHJFcKx3lg7NJRQjTo= X-Google-Smtp-Source: AGHT+IH+bAdPsDt9XrIorgyNOEYeyaktekbVrFIZRRBjXCSd5Yc5wHtmlxqS1JCQ8nOI7Z8NtI15og== X-Received: by 2002:a05:6000:2002:b0:3b7:9b81:73f6 with SMTP id ffacd0b85a97d-3b911042100mr751660f8f.54.1754941811015; Mon, 11 Aug 2025 12:50:11 -0700 (PDT) Received: from [192.168.0.253] (5D59A51C.catv.pool.telekom.hu. [93.89.165.28]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3b79c3b9eddsm41709246f8f.22.2025.08.11.12.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Aug 2025 12:50:10 -0700 (PDT) From: Gabor Juhos Date: Mon, 11 Aug 2025 21:49:57 +0200 Subject: [PATCH v2 3/3] i2c: pxa: handle 'Early Bus Busy' condition on Armada 3700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250811-i2c-pxa-fix-i2c-communication-v2-3-ca42ea818dc9@gmail.com> References: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> In-Reply-To: <20250811-i2c-pxa-fix-i2c-communication-v2-0-ca42ea818dc9@gmail.com> To: Wolfram Sang , Wolfram Sang , Andi Shyti , Andy Shevchenko , Russell King , Andrew Lunn , Hanna Hawa Cc: Robert Marko , Linus Walleij , Russell King , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Imre Kaloz , Gabor Juhos , stable@vger.kernel.org X-Mailer: b4 0.14.2 Under some circumstances I2C recovery fails on Armada 3700. At least on the Methode uDPU board, removing and replugging an SFP module fails often, like this: [ 36.953127] sfp sfp-eth1: module removed [ 38.468549] i2c i2c-1: i2c_pxa: timeout waiting for bus free [ 38.486960] sfp sfp-eth1: module MENTECHOPTO POS22-LDCC-KR rev= 1.0 sn MNC208U90009 dc 200828 [ 38.496867] mvneta d0040000.ethernet eth1: unsupported SFP module: no = common interface modes [ 38.521448] hwmon hwmon2: temp1_input not attached to any thermal zone [ 39.249196] sfp sfp-eth1: module removed ... [ 292.568799] sfp sfp-eth1: please wait, module slow to respond ... [ 625.208814] sfp sfp-eth1: failed to read EEPROM: -EREMOTEIO Note that the 'unsupported SFP module' messages are not relevant. The module is used only for testing the I2C recovery funcionality, because the error can be triggered easily with this specific one. Enabling debug in the i2c-pxa driver reveals the following: [ 82.034678] sfp sfp-eth1: module removed [ 90.008654] i2c i2c-1: slave_0x50 error: timeout with active message [ 90.015112] i2c i2c-1: msg_num: 2 msg_idx: 0 msg_ptr: 0 [ 90.020464] i2c i2c-1: IBMR: 00000003 IDBR: 000000a0 ICR: 000007e0 ISR= : 00000802 [ 90.027906] i2c i2c-1: log: [ 90.030787] This continues until the retries are exhausted ... [ 110.192489] i2c i2c-1: slave_0x50 error: exhausted retries [ 110.198012] i2c i2c-1: msg_num: 2 msg_idx: 0 msg_ptr: 0 [ 110.203323] i2c i2c-1: IBMR: 00000003 IDBR: 000000a0 ICR: 000007e0 ISR= : 00000802 [ 110.210810] i2c i2c-1: log: [ 110.213633] ... then the whole sequence starts again ... [ 115.368641] i2c i2c-1: slave_0x50 error: timeout with active message ... while finally the SFP core gives up: [ 671.975258] sfp sfp-eth1: failed to read EEPROM: -EREMOTEIO When we analyze the log, it can be seen that bit 1 and 11 is set in the ISR (Interface Status Register). Bit 1 indicates the ACK/NACK status, but the purpose of bit 11 is not documented in the driver code unfortunately. The 'Functional Specification' document of the Armada 3700 SoCs family however says that this bit indicates an 'Early Bus Busy' condition. The document also notes that whenever this bit is set, it is not possible to initiate a transaction on the I2C bus. The observed behaviour corresponds to this statement. Unfortunately, I2C recovery does not help as it never runs in this special case. Although the driver checks the busyness of the bus at several places, but since it does not consider the A3700 specific bit in these checks it can't determine the actual status of the bus correctly which results in the errors above. In order to fix the problem, add a new member to struct 'i2c_pxa' to store a controller specific bitmask containing the bits indicating the busy status, and use that in the code while checking the actual status of the bus. This ensures that the correct status can be determined on the Armada 3700 based devices without causing functional changes on devices based on other SoCs. With the change applied, the driver detects the busy condition, and runs the recovery process: [ 742.617312] i2c i2c-1: state:i2c_pxa_wait_bus_not_busy:449: ISR=3D0000= 0802, ICR=3D000007e0, IBMR=3D03 [ 742.626099] i2c i2c-1: i2c_pxa: timeout waiting for bus free [ 742.631933] i2c i2c-1: recovery: resetting controller, ISR=3D0x00000802 [ 742.638421] i2c i2c-1: recovery: IBMR 0x00000003 ISR 0x00000000 This clears the EBB bit in the ISR register, so it makes it possible to initiate transactions on the I2C bus again. After this patch, the SFP module used for testing can be removed and replugged numerous times without causing the error described at the beginning. Previously, the error happened after a few such attempts. The patch has been tested also with the following kernel versions: 5.10.237, 5.15.182, 6.1.138, 6.6.90, 6.12.28, 6.14.6. It improves recoverabilty on all of them. Cc: stable@vger.kernel.org # 5.8+ Fixes: 7c9ec2c52518 ("i2c: pxa: implement generic i2c bus recovery") Signed-off-by: Gabor Juhos Signed-off-by: Imre Kaloz --- Changes in v2: - rebase and retest on tip of i2c/for-current Note: the patch is included in this series for completeness however it can be applied independently from the preceding patches. On kernels 6.3+, it restores I2C functionality even in itself because it recovers the controller from the bad state described in the previous patch. --- drivers/i2c/busses/i2c-pxa.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index f4cb36e22077753e21b0260df52b8bdbb85fa308..6239200631211b2b6c9919d27fe= c63704bd19e52 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -71,6 +71,7 @@ #define ISR_GCAD (1 << 8) /* general call address detected */ #define ISR_SAD (1 << 9) /* slave address detected */ #define ISR_BED (1 << 10) /* bus error no ACK/NAK */ +#define ISR_A3700_EBB (1 << 11) /* early bus busy for armada 3700 */ =20 #define ILCR_SLV_SHIFT 0 #define ILCR_SLV_MASK (0x1FF << ILCR_SLV_SHIFT) @@ -263,6 +264,7 @@ struct pxa_i2c { bool highmode_enter; u32 fm_mask; u32 hs_mask; + u32 busy_mask; =20 struct i2c_bus_recovery_info recovery; struct pinctrl *pinctrl; @@ -429,7 +431,7 @@ static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2= c) =20 while (1) { isr =3D readl(_ISR(i2c)); - if (!(isr & (ISR_IBB | ISR_UB))) + if (!(isr & i2c->busy_mask)) return 0; =20 if (isr & ISR_SAD) @@ -466,7 +468,7 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c) * quick check of the i2c lines themselves to ensure they've * gone high... */ - if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) =3D=3D 0 && + if ((readl(_ISR(i2c)) & i2c->busy_mask) =3D=3D 0 && readl(_IBMR(i2c)) =3D=3D (IBMR_SCLS | IBMR_SDAS)) { if (i2c_debug > 0) dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); @@ -487,7 +489,7 @@ static int i2c_pxa_set_master(struct pxa_i2c *i2c) if (i2c_debug) dev_dbg(&i2c->adap.dev, "setting to bus master\n"); =20 - if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) !=3D 0) { + if ((readl(_ISR(i2c)) & i2c->busy_mask) !=3D 0) { dev_dbg(&i2c->adap.dev, "%s: unit is busy\n", __func__); if (!i2c_pxa_wait_master(i2c)) { dev_dbg(&i2c->adap.dev, "%s: error: unit busy\n", __func__); @@ -513,7 +515,7 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=3D%08x, ICR=3D%08x, IBMR=3D%02x\n= ", __func__, (long)jiffies, readl(_ISR(i2c)), readl(_ICR(i2c)), readl(_IB= MR(i2c))); =20 - if ((readl(_ISR(i2c)) & (ISR_UB|ISR_IBB)) =3D=3D 0 || + if ((readl(_ISR(i2c)) & i2c->busy_mask) =3D=3D 0 || (readl(_ISR(i2c)) & ISR_SAD) !=3D 0 || (readl(_ICR(i2c)) & ICR_SCLE) =3D=3D 0) { if (i2c_debug > 1) @@ -1171,7 +1173,7 @@ static int i2c_pxa_pio_set_master(struct pxa_i2c *i2c) /* * Wait for the bus to become free. */ - while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) + while (timeout-- && readl(_ISR(i2c)) & i2c->busy_mask) udelay(1000); =20 if (timeout < 0) { @@ -1316,7 +1318,7 @@ static void i2c_pxa_unprepare_recovery(struct i2c_ada= pter *adap) * handing control of the bus back to avoid the bus changing state. */ isr =3D readl(_ISR(i2c)); - if (isr & (ISR_UB | ISR_IBB)) { + if (isr & i2c->busy_mask) { dev_dbg(&i2c->adap.dev, "recovery: resetting controller, ISR=3D0x%08x\n", isr); i2c_pxa_do_reset(i2c); @@ -1480,6 +1482,10 @@ static int i2c_pxa_probe(struct platform_device *dev) i2c->fm_mask =3D pxa_reg_layout[i2c_type].fm; i2c->hs_mask =3D pxa_reg_layout[i2c_type].hs; =20 + i2c->busy_mask =3D ISR_UB | ISR_IBB; + if (i2c_type =3D=3D REGS_A3700) + i2c->busy_mask |=3D ISR_A3700_EBB; + if (i2c_type !=3D REGS_CE4100) i2c->reg_isar =3D i2c->reg_base + pxa_reg_layout[i2c_type].isar; =20 --=20 2.50.1