From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Tomasz Michalec <tmichalec@google.com>,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Sasha Levin <sashal@kernel.org>,
bleung@chromium.org, jthies@google.com, akuchynski@chromium.org,
chrome-platform@lists.linux.dev
Subject: [PATCH AUTOSEL 6.6 53/59] platform/chrome: cros_ec_typec: Defer probe on missing EC parent
Date: Sun, 3 Aug 2025 20:34:07 -0400 [thread overview]
Message-ID: <20250804003413.3622950-53-sashal@kernel.org> (raw)
In-Reply-To: <20250804003413.3622950-1-sashal@kernel.org>
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 66fdc6fa73ec..76807ceb313a 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1179,8 +1179,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
parent reply other threads:[~2025-08-04 0:36 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20250804003413.3622950-1-sashal@kernel.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250804003413.3622950-53-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=jthies@google.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=tmichalec@google.com \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox