Re: [PATCH v3 1/2] platform/chrome: cros_ec_typec: Enforce priority-based mode selection
From: Andrei Kuchynski
Date: Thu Oct 29 2026 - 08:29:54 EST
On Thu, Oct 29, 2026 at 5:19 AM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
>
> On Wed, Oct 28, 2026 at 09:09:31AM +0000, Andrei Kuchynski wrote:
> > The driver sets mode_selection bit for each Alternate mode, thereby
> > preventing individual altmode drivers from activating their respective
> > modes.
> > Once the registration of all Alternate Modes is complete, the driver
> > verifies if USB4 mode is supported by both the port and the partner and
> > activates USB4 mode. In cases where USB4 is not supported, the driver
> > invokes typec_mode_selection_start to initiate the mode selection process
> > based on mode priorities.
> > The driver communicates the current Type-C mode to the mode selection
> > process via typec_altmode_state_update.
>
> Hi Andrei,
>
> I'm less familiar with the details of cros_ec_typec and its friend drivers.
> Could you double-check the Sashiko review [1] to see if any of the findings
> need to be addressed as they look real?
>
> [1] https://sashiko.dev/#/patchset/20261028090932.27053-1-akuchynski%40chromium.org
Hi Tzung-Bi,
Let's analyze this.
1. "If the EC does not enter TBT mode… Does this leave the port mux
configured in TBT mode and skip calling cros_typec_altmode_exit() to send
TYPEC_CONTROL_COMMAND_EXIT_MODES to the EC?"
It seems it does. Unclear if this causes actual issues, though this is
unrelated to mode_selection. The identical behavior occurs when altmode
activation gets triggered through sysfs by a user.
2. “Without calling typec_partner_set_usb_mode(), port->partner->usb_mode
is never updated to USB_MODE_USB4”
This is a good one. I will update it in v4.
3. “If cros_typec_remove_partner() has already set port->partner = NULL,
this dereferences a NULL pointer”
Also a valid point.
However, this is unrelated to mode_selection. The race condition between
cros_typec_altmode_work() and cros_typec_remove_partner() is addressed
here:
https://lore.kernel.org/all/20261018023438.3902617-1-mhun512@xxxxxxxxx/
Execution of cros_typec_altmode_work needs to be halted prior to partner
teardown.
In any case, I will test this against these considerations.
Thanks,
Andrei