Description
On a Laptop 13 Pro (AMD Ryzen AI 300 Series), EC lilac-4.0.2-fdbf549, board_set_active_charge_port() regularly logs cypd_cfet_vbus_control:N fail:5 when a charger is plugged, unplugged or renegotiates. The code and the EC console point at a race: the write runs in the system work queue and polls for the PD controller's response, while the higher-priority CYPD task is woken by the same interrupt, reads the response, ignores it and clears the interrupt.
Two kinds of failure (EC console, HC lines removed; event set 0x0400000000000000 is EC_HOST_EVENT_UCSI, which the CYPD task sets in check_ucsi_event_from_host() when it completes a UCSI command of the host, so it shows the CYPD task exchanging data with the controllers meanwhile):
A timeout, the waiter never sees the interrupt line asserted within 100 ms:
[377977.177600 CYPD_RESPONSE_PORT_CONNECT 3]
[377977.182200 board_set_active_charge_port port 3, prev:-1]
[377977.208100 event set 0x0400000000000000]
[377977.234100 event set 0x0400000000000000]
[377977.261400 event set 0x0400000000000000]
[377977.283000 CCG_RESPONSE_ACCEPT_MSG_RX 3]
[377977.288600 event set 0x0400000000000000]
[377977.297200 cypd_wait_for_ack timeout on interrupt]
[377977.301000 cypd_write_reg8_wait_ack timeout on interrupt]
[377977.302600 cypd_cfet_vbus_control:0 fail:5]
A response code of 0, the waiter saw the port's bit in the interrupt status, but the response register was already cleared when it read it. Only the EC clears it, so another context did so in between:
[378014.573300 board_set_active_charge_port port 3, prev:3]
[378014.574100 event set 0x0400000000000000]
[378014.595300 cypd_write_reg8_wait_ack C:1 0x2032 response 0x0]
[378014.597900 event set 0x0400000000000000]
[378014.606400 cypd_cfet_vbus_control:3 fail:5]
Numbers from four EC console captures over two days (90 W dock, 45 W and 100 W chargers): 39 calls of board_set_active_charge_port() made 95 writes of CCG_PORT_VBUS_FET_CONTROL, and 28 of them failed (ports 0/1/2/3: 11/5/3/9): 23 with response 0x0, 5 with a 100 ms timeout. No write to any other register failed. In particular, the CCG_POWER_STAT writes which the CYPD task itself makes to both controllers 100 ms after each switch (update_power_state_deferred() sets CCG_EVT_UPDATE_PWRSTAT) never logged a failure, although they go to the same controllers at nearly the same time.
Effects:
- Each timeout holds the system work queue for 100 ms, so every hook and deferred function waits behind it (five times in these captures, at most one per switch).
- The EC cannot tell a raced response from a real failure, so
fail:5is logged for writes which the controller presumably performed (charging worked in all these cases, and later calls write the FET control again). - I did not see an effect on how fast AC is detected:
PORT_CONNECTtoAC onvaried from 131 to 621 ms in these captures independent of the failures, depending mostly on whetherAC oncame before or after the 20 V contract.
Activity