Re: [PATCH v2] usb: typec: tcpci: quiesce the IRQ before unregistering the TCPM port
From: Xu Yang
Date: Wed Nov 11 2026 - 22:52:46 EST
On Thu, Nov 12, 2026 at 09:56:38AM +0800, Yaohan Li wrote:
> Hi Xu,
>
> Thanks for taking another look. I'll shorten the commit message.
>
> I checked the IRQ path again. tcpci_irq() reads TCPC_ALERT and handles the status bits directly. The alert_mask field is used for the IRQ return value and the loop condition, but it doesn't filter those initial TCPM callbacks.
>
> My concern is the case where an alert is still latched, or the mask write fails during removal. Since the IRQ is shared, another device could cause _tcpci_irq() to run after synchronize_irq() has returned. Without the stopping check, that handler could still reach TCPM after the port has been unregistered.
>
> Does the TCPCI specification guarantee that TCPC_ALERT reads as zero once its mask is cleared, including for previously latched alerts? If so, I've missed that guarantee and can simplify the patch. Otherwise, I think the stopping check is still needed for that last window.
In TCPCI spec:
4.4.3 Mask Registers
The registers in this section define the masks that may be set for the ALERT registers. A
masked register will still indicate in the ALERT register, but shall not set the Alert# pin low.
So TCPC_ALERT may be not 0 if TCPC_ALERT_MASK is 0.
Your analysis is right, but I think it's another potential issue in tcpci_irq()
where masked events get handled. "status" should be ANDed with alert_mask as well.
Like below:
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 6717ac914c6a..4eb97f5a523c 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -724,6 +724,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
tcpci_read16(tcpci, TCPC_ALERT, &status);
irq_ret = status & tcpci->alert_mask;
+ status = irq_ret;
process_status:
/*
@@ -807,7 +808,8 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
tcpci_read16(tcpci, TCPC_ALERT, &status);
- if (status & tcpci->alert_mask)
+ status &= tcpci->alert_mask;
+ if (status)
goto process_status;
return IRQ_RETVAL(irq_ret);
Then you should set alert_mask to 0 and use it to mask ALERT.
/* Disable chip interrupts before unregistering port */
chip->tcpci->alert_mask = 0;
err = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, chip->tcpci->alert_mask);
Thanks,
Xu Yang
>
> Thanks,
> Yaohan