Re: [PATCH v1 1/1] platform/chrome: cros_ec_typec: Re-register cable on late SOP' discovery
From: Benson Leung
Date: Sat Dec 05 2026 - 01:10:33 EST
Hi Shiva,
Thanks for sending this upstream!
On Fri, Dec 04, 2026 at 09:38:48AM +0000, Shiva kumar Martalu Gachanti wrote:
> When the EC negotiates with docks that trigger repeated VCONN swaps
> (such as in DRP Try.SRC mode), SOP' cable discovery can be delayed.
> Currently, cros_ec_typec registers the cable sysfs object early with
> blank (0x0) identity VDOs and marks sop_prime_disc_done = true.
>
> Subsequent SOP' discovery notifications are then ignored, leaving the
> cable identity VDOs blank and core cable descriptor properties (active,
> pd_revision, and plug type) stale.
The overall approach makes sense and works well in my real world testing.
It would be helpful to briefly mention the user-visible impact and hardware
where this was observed (e.g., Brya/Redrix with an e-marked cable and a
Thunderbolt 4 dock, where blank cable identity prevents USB4 mode entry),
and note that re-registration is needed instead of
"typec_cable_set_identity()" so active, pd_revision, plug_type, and plug
altmodes are all updated cleanly.
> Update cros_typec_handle_status() and cros_typec_handle_sop_prime_disc()
> to re-evaluate SOP' discovery when a placeholder cable with zero
> id_header is present:
> 1. Allow cros_typec_handle_status() to re-invoke SOP' discovery if the
> registered cable still has a zero id_header.
> 2. Keep the existing placeholder cable if valid identity VDOs are still
> unavailable on a subsequent check.
> 3. Once valid SOP' identity VDOs arrive, tear down the placeholder cable
> (along with its plug and altmodes) via cros_typec_remove_cable()
> before parsing the new identity and re-registering the cable cleanly.
>
> Signed-off-by: Shiva kumar Martalu Gachanti <shivakumarmar@xxxxxxxxxxxx>
Please include a "Fixes:" tag referencing the commit that introduced
cable registration, and CC stable since this affects stable LTS kernels.
Instructions on how to format a "Fixes:" tag are here:
https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
Yours should look like this:
Fixes: 8b46a212ad11 ("platform/chrome: cros_ec_typec: Register cable")
Cc: stable@xxxxxxxxxxxxxxx
Also, it looks like this patch was generated against an older kernel
tree (probably the chromiumos kernel branch chromeos-6.6, given that's where
the Brya/Redrix board is on ChromeOS).
You missed some current maintainers. Please rebase onto
chrome-platform/for-next (or linux-next) and re-run
'scripts/get_maintainer.pl' on the patch file for v2, which gives:
Benson Leung <bleung@xxxxxxxxxxxx> (maintainer:CHROMEOS EC USB TYPE-C DRIVER)
Abhishek Pandit-Subedi <abhishekpandit@xxxxxxxxxxxx> (maintainer:CHROMEOS EC USB TYPE-C DRIVER)
Jameson Thies <jthies@xxxxxxxxxx> (maintainer:CHROMEOS EC USB TYPE-C DRIVER)
Andrei Kuchynski <akuchynski@xxxxxxxxxxxx> (maintainer:CHROMEOS EC USB TYPE-C DRIVER)
Tzung-Bi Shih <tzungbi@xxxxxxxxxx> (maintainer:CHROME HARDWARE PLATFORM SUPPORT)
Guenter Roeck <groeck@xxxxxxxxxxxx> (reviewer:CHROMEOS EC SUBDRIVERS)
chrome-platform@xxxxxxxxxxxxxxx (open list:CHROMEOS EC USB TYPE-C DRIVER)
linux-kernel@xxxxxxxxxxxxxxx (open list)
For a single patch, "git format-patch -v2 -1" will also generate
"[PATCH v2]" without "1/1".
> ---
> drivers/platform/chrome/cros_ec_typec.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index c7781aea0b88b..8cfce61965674 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -859,6 +859,22 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
> goto sop_prime_disc_exit;
> }
Watch out for the error path right above this hunk:
ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
disc, EC_PROTO2_MAX_RESPONSE_SIZE);
if (ret < 0) {
dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
goto sop_prime_disc_exit;
}
Previously, "port->cable" was always NULL on entry to this function, so
jumping to "sop_prime_disc_exit" (which calls "cros_typec_remove_cable()")
was a no-op. Now that "cros_typec_handle_sop_prime_disc()" can be called
when a placeholder "port->cable" already exists, a transient
"EC_CMD_TYPEC_DISCOVERY" error will tear down the existing placeholder
cable.
Please return "ret" directly there instead of jumping to
"sop_prime_disc_exit", so the placeholder cable stays intact and the
"PD_STATUS_EVENT_SOP_PRIME_DISC_DONE" event remains uncleared for retry.
> + /*
> + * If a placeholder cable was registered earlier with zero identity
> + * (e.g. when SOP' discovery was delayed by VCONN swaps), keep it if
> + * valid VDOs are still unavailable; otherwise tear it down before
> + * parsing the new identity so it can be re-registered cleanly.
> + */
> + if (port->cable) {
> + if (disc->identity_count == 0 || disc->discovery_vdo[0] == 0)
> + return 0;
> +
> + dev_dbg(typec->dev,
> + "Port %d: Re-registering cable with valid identity (0x%08x)\n",
> + port_num, disc->discovery_vdo[0]);
> + cros_typec_remove_cable(typec, port_num);
> + }
> +
> /* Parse the PD identity data, even if only 0s were returned. */
> cros_typec_parse_pd_identity(&port->c_identity, disc);
>
> @@ -1064,7 +1080,9 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
> }
>
> if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE &&
> - !typec->ports[port_num]->sop_prime_disc_done) {
> + (!typec->ports[port_num]->sop_prime_disc_done ||
> + (typec->ports[port_num]->cable &&
> + typec->ports[port_num]->c_identity.id_header == 0))) {
Thanks,
Benson
Attachment:
signature.asc
Description: PGP signature