* [PATCH AUTOSEL 6.15 19/80] usb: typec: ucsi: Add poll_cci operation to cros_ec_ucsi
[not found] <20250804002747.3617039-1-sashal@kernel.org>
@ 2025-08-04 0:26 ` Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 56/80] platform/chrome: cros_ec_sensorhub: Retries when a sensor is not ready Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 74/80] platform/chrome: cros_ec_typec: Defer probe on missing EC parent Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-08-04 0:26 UTC (permalink / raw)
To: patches, stable
Cc: Jameson Thies, Benson Leung, Greg Kroah-Hartman, Sasha Levin,
abhishekpandit, ukaszb, akuchynski, chrome-platform
From: Jameson Thies <jthies@google.com>
[ Upstream commit 300386d117a98961fc1d612d1f1a61997d731b8a ]
cros_ec_ucsi fails to allocate a UCSI instance in it's probe function
because it does not define all operations checked by ucsi_create.
Update cros_ec_ucsi operations to use the same function for read_cci
and poll_cci.
Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20250711202033.2201305-1-jthies@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Now I understand the timeline:
1. The cros_ec_ucsi driver was added on 2024-12-31
2. The poll_cci requirement was added on 2025-02-17 (after the
cros_ec_ucsi driver was already in the kernel)
3. This broke the cros_ec_ucsi driver because it didn't have the
poll_cci operation defined
**Backport Status: YES**
This commit fixes a regression where the cros_ec_ucsi driver fails to
allocate a UCSI instance during probe because it lacks the poll_cci
operation that became mandatory in commit 976e7e9bdc77 ("acpi: typec:
ucsi: Introduce a ->poll_cci method").
The commit meets all criteria for stable backporting:
1. **Fixes a real bug**: The driver completely fails to probe without
this fix, preventing ChromeOS EC-based UCSI devices from working at
all. The error occurs in ucsi_create() at
drivers/usb/typec/ucsi/ucsi.c:1933 where it checks for the presence
of all required operations including poll_cci.
2. **Small and contained change**: The fix is minimal - it only adds one
line to the operations structure (`.poll_cci = cros_ucsi_read_cci,`),
reusing the existing read_cci implementation which is appropriate for
this driver.
3. **No side effects**: The change simply allows the driver to pass the
operations validation check. Using the same function for both
read_cci and poll_cci is the correct approach for drivers that don't
have the ACPI-specific sync issues that prompted the poll_cci split.
4. **Fixes a regression**: This is fixing a regression introduced by
commit 976e7e9bdc77, which itself was marked for stable. Any stable
kernel that includes 976e7e9bdc77 but not this fix will have a broken
cros_ec_ucsi driver.
5. **Clear fix relationship**: The commit message clearly identifies the
problem (ucsi_create fails due to missing operation) and the solution
is straightforward.
This should be backported to any stable kernel that includes both:
- commit f1a2241778d9 ("usb: typec: ucsi: Implement ChromeOS UCSI
driver")
- commit 976e7e9bdc77 ("acpi: typec: ucsi: Introduce a ->poll_cci
method")
drivers/usb/typec/ucsi/cros_ec_ucsi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
index 4ec1c6d22310..eed2a7d0ebc6 100644
--- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
+++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
@@ -137,6 +137,7 @@ static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci,
static const struct ucsi_operations cros_ucsi_ops = {
.read_version = cros_ucsi_read_version,
.read_cci = cros_ucsi_read_cci,
+ .poll_cci = cros_ucsi_read_cci,
.read_message_in = cros_ucsi_read_message_in,
.async_control = cros_ucsi_async_control,
.sync_control = cros_ucsi_sync_control,
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 56/80] platform/chrome: cros_ec_sensorhub: Retries when a sensor is not ready
[not found] <20250804002747.3617039-1-sashal@kernel.org>
2025-08-04 0:26 ` [PATCH AUTOSEL 6.15 19/80] usb: typec: ucsi: Add poll_cci operation to cros_ec_ucsi Sasha Levin
@ 2025-08-04 0:27 ` Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 74/80] platform/chrome: cros_ec_typec: Defer probe on missing EC parent Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-08-04 0:27 UTC (permalink / raw)
To: patches, stable
Cc: Gwendal Grignou, Gwendal Grignou, Tzung-Bi Shih, Sasha Levin,
bleung, chrome-platform
From: Gwendal Grignou <gwendal@chromium.org>
[ Upstream commit 981d7f91aeda17424b29f033249f4fa7cd2a7556 ]
When the EC/ISH starts, it can take a while for all the sensors to be up
and running or declared broken.
If the sensor stack return -EBUSY when checking for sensor information,
retry up to 50 times.
It has been observed 100ms wait time is enough to have valid sensors
ready. It can take more time in case a sensor is really broken and is
not coming up.
Signed-off-by: Gwendal Grignou <gwendal@google.com>
Link: https://lore.kernel.org/r/20250623210518.306740-1-gwendal@google.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the
following reasons:
1. **Fixes a real user-impacting bug**: The commit addresses a race
condition where the ChromeOS EC sensor hub fails to initialize
sensors properly during EC/ISH startup. Without this fix, sensors may
appear as broken or unavailable to userspace when they are actually
just slow to initialize.
2. **Small and contained fix**: The change is minimal - it only adds:
- A retry loop around `cros_ec_cmd_xfer_status()` for -EBUSY errors
- A 5-6ms delay between retries
- A maximum of 50 retries (approximately 250-300ms total timeout)
- A warning message when retries were needed
3. **Clear bug fix pattern**: The EC returning -EBUSY (EC_RES_BUSY) is
documented behavior indicating "Up but too busy. Should retry". The
original code didn't handle this case, leading to sensors being
skipped during initialization.
4. **Low regression risk**:
- The retry logic only triggers on -EBUSY errors, not affecting the
normal path
- The change is isolated to sensor initialization during probe
- Similar retry patterns exist in other parts of the cros_ec
subsystem (e.g., commit 11799564fc7e)
- The dev_warn to dev_err change is appropriate as sensor
initialization failure is an error condition
5. **Hardware-specific timing issue**: This fixes a timing-dependent
hardware initialization issue that can manifest differently across
different EC/ISH firmware versions and boot conditions, making it
important for stable operation across various Chromebook models.
6. **No architectural changes**: The commit doesn't introduce new
features or change any interfaces - it simply makes the existing
sensor initialization more robust by handling a known EC busy state.
The commit follows established patterns in the cros_ec subsystem for
handling EC_RES_BUSY responses and is a straightforward reliability
improvement that should be included in stable kernels to ensure
consistent sensor availability on ChromeOS devices.
drivers/platform/chrome/cros_ec_sensorhub.c | 23 +++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c
index 50cdae67fa32..9bad8f72680e 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub.c
@@ -8,6 +8,7 @@
#include <linux/init.h>
#include <linux/device.h>
+#include <linux/delay.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_data/cros_ec_commands.h>
@@ -18,6 +19,7 @@
#include <linux/types.h>
#define DRV_NAME "cros-ec-sensorhub"
+#define CROS_EC_CMD_INFO_RETRIES 50
static void cros_ec_sensorhub_free_sensor(void *arg)
{
@@ -53,7 +55,7 @@ static int cros_ec_sensorhub_register(struct device *dev,
int sensor_type[MOTIONSENSE_TYPE_MAX] = { 0 };
struct cros_ec_command *msg = sensorhub->msg;
struct cros_ec_dev *ec = sensorhub->ec;
- int ret, i;
+ int ret, i, retries;
char *name;
@@ -65,12 +67,25 @@ static int cros_ec_sensorhub_register(struct device *dev,
sensorhub->params->cmd = MOTIONSENSE_CMD_INFO;
sensorhub->params->info.sensor_num = i;
- ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ retries = CROS_EC_CMD_INFO_RETRIES;
+ do {
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret == -EBUSY) {
+ /* The EC is still busy initializing sensors. */
+ usleep_range(5000, 6000);
+ retries--;
+ }
+ } while (ret == -EBUSY && retries);
+
if (ret < 0) {
- dev_warn(dev, "no info for EC sensor %d : %d/%d\n",
- i, ret, msg->result);
+ dev_err(dev, "no info for EC sensor %d : %d/%d\n",
+ i, ret, msg->result);
continue;
}
+ if (retries < CROS_EC_CMD_INFO_RETRIES) {
+ dev_warn(dev, "%d retries needed to bring up sensor %d\n",
+ CROS_EC_CMD_INFO_RETRIES - retries, i);
+ }
switch (sensorhub->resp->info.type) {
case MOTIONSENSE_TYPE_ACCEL:
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 74/80] platform/chrome: cros_ec_typec: Defer probe on missing EC parent
[not found] <20250804002747.3617039-1-sashal@kernel.org>
2025-08-04 0:26 ` [PATCH AUTOSEL 6.15 19/80] usb: typec: ucsi: Add poll_cci operation to cros_ec_ucsi Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 56/80] platform/chrome: cros_ec_sensorhub: Retries when a sensor is not ready Sasha Levin
@ 2025-08-04 0:27 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-08-04 0:27 UTC (permalink / raw)
To: patches, stable
Cc: Tomasz Michalec, Abhishek Pandit-Subedi, Tzung-Bi Shih,
Sasha Levin, bleung, jthies, akuchynski, chrome-platform
From: Tomasz Michalec <tmichalec@google.com>
[ Upstream commit 8866f4e557eba43e991f99711515217a95f62d2e ]
If cros_typec_probe is called before EC device is registered,
cros_typec_probe will fail. It may happen when cros-ec-typec.ko is
loaded before EC bus layer module (e.g. cros_ec_lpcs.ko,
cros_ec_spi.ko).
Return -EPROBE_DEFER when cros_typec_probe doesn't get EC device, so
the probe function can be called again after EC device is registered.
Signed-off-by: Tomasz Michalec <tmichalec@google.com>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Link: https://lore.kernel.org/r/20250610153748.1858519-1-tmichalec@google.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the
following reasons:
1. **Fixes a real user-facing bug**: The commit addresses a module
loading race condition where `cros_ec_typec.ko` can fail to probe if
loaded before the EC bus layer modules (`cros_ec_lpcs.ko`,
`cros_ec_spi.ko`). This causes the Type-C functionality to completely
fail on affected systems.
2. **Small and contained fix**: The change is minimal - only 2 lines of
actual code changes:
- Changes `dev_err()` to `dev_warn()` (cosmetic improvement)
- Changes return value from `-ENODEV` to `-EPROBE_DEFER`
3. **Follows established kernel patterns**: The fix uses the standard
`-EPROBE_DEFER` mechanism which is the proper way to handle driver
dependencies in the Linux kernel. The driver already uses
`-EPROBE_DEFER` in another location (line 1289) for a similar EC
device check.
4. **No architectural changes**: This is a simple probe deferral fix
that doesn't introduce new features or change any existing
functionality. It merely allows the driver to retry probing later
when dependencies are satisfied.
5. **Minimal regression risk**: Returning `-EPROBE_DEFER` instead of
`-ENODEV` is a safe change that only affects the probe retry
behavior. The driver will still fail eventually if the EC device
never appears.
6. **Fixes a regression**: Looking at commit ffebd9053272
("platform/chrome: cros_ec_typec: Check for EC device"), the check
for parent EC device was added to handle older Chromebooks. However,
it inadvertently broke systems where module loading order could vary,
creating a race condition.
7. **Similar pattern in the subsystem**: Other Chrome platform drivers
already use `-EPROBE_DEFER` for similar dependency handling (as seen
in commit 13aba1e532f0).
The fix properly handles the asynchronous nature of driver loading in
modern Linux systems where module loading order is not guaranteed,
making it an important fix for system reliability.
drivers/platform/chrome/cros_ec_typec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 7678e3d05fd3..f437b594055c 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1272,8 +1272,8 @@ static int cros_typec_probe(struct platform_device *pdev)
typec->ec = dev_get_drvdata(pdev->dev.parent);
if (!typec->ec) {
- dev_err(dev, "couldn't find parent EC device\n");
- return -ENODEV;
+ dev_warn(dev, "couldn't find parent EC device\n");
+ return -EPROBE_DEFER;
}
platform_set_drvdata(pdev, typec);
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-04 0:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250804002747.3617039-1-sashal@kernel.org>
2025-08-04 0:26 ` [PATCH AUTOSEL 6.15 19/80] usb: typec: ucsi: Add poll_cci operation to cros_ec_ucsi Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 56/80] platform/chrome: cros_ec_sensorhub: Retries when a sensor is not ready Sasha Levin
2025-08-04 0:27 ` [PATCH AUTOSEL 6.15 74/80] platform/chrome: cros_ec_typec: Defer probe on missing EC parent Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).