* [PATCH 0/2] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown
@ 2026-11-20 9:59 Neil Armstrong
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
0 siblings, 2 replies; 8+ messages in thread
From: Neil Armstrong @ 2026-11-20 9:59 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, Neil Armstrong
The current driver doesn't leave the port in the same
state as found when probing, and leaves the port enabled
on system shutdown.
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Neil Armstrong (2):
usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
usb: typec: qcom-pmic-typec: detach the port on shutdown
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 11 +++++++++++
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 1 +
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 11 +++++++++++
4 files changed, 24 insertions(+), 1 deletion(-)
---
base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
change-id: 20261120-topic-tcpm-qcom-fixes-c9ce1e65c570
Best regards,
--
Neil Armstrong <neil.armstrong@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
2026-11-20 9:59 [PATCH 0/2] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
@ 2026-11-20 9:59 ` Neil Armstrong
2026-11-20 10:03 ` sashiko-bot
2026-11-20 11:52 ` Bryan O'Donoghue
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
1 sibling, 2 replies; 8+ messages in thread
From: Neil Armstrong @ 2026-11-20 9:59 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, Neil Armstrong
qcom_pmic_typec_pdphy_stop() only terminates the ongoing transmission and
clears the RX frame filter, the PD PHY itself stays enabled.
Use qcom_pmic_typec_pdphy_disable() so the PD PHY is also turned off
before its supply is released, leaving it in the same state as before
qcom_pmic_typec_pdphy_start().
Assisted-by: LLM
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 435e07659d65..08cf65951796 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -545,7 +545,7 @@ static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm)
cancel_work_sync(&pmic_typec_pdphy->reset_work);
- qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
+ qcom_pmic_typec_pdphy_disable(pmic_typec_pdphy);
regulator_disable(pmic_typec_pdphy->vdd_pdphy);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown
2026-11-20 9:59 [PATCH 0/2] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
@ 2026-11-20 9:59 ` Neil Armstrong
2026-11-20 10:15 ` sashiko-bot
2026-11-20 11:55 ` Bryan O'Donoghue
1 sibling, 2 replies; 8+ messages in thread
From: Neil Armstrong @ 2026-11-20 9:59 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, Neil Armstrong
On reboot or power off the port is left as is: a source partner keeps
the negotiated contract, possibly above 5V, and a sink partner stays
powered by the OTG boost while nothing services the port anymore.
Add a shutdown callback stopping the port and the PD PHY, unregistering
the TCPM port, which turns VBUS and VCONN off, and finally disabling the
Type-C block so the partner sees a detach.
Assisted-by: LLM
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 11 +++++++++++
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 1 +
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 11 +++++++++++
3 files changed, 23 insertions(+)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
index 58d1e6aae637..8169db478b8a 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
@@ -134,6 +134,16 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
fwnode_handle_put(tcpm->tcpc.fwnode);
}
+static void qcom_pmic_typec_shutdown(struct platform_device *pdev)
+{
+ struct pmic_typec *tcpm = platform_get_drvdata(pdev);
+
+ tcpm->pdphy_stop(tcpm);
+ tcpm->port_stop(tcpm);
+ tcpm_unregister_port(tcpm->tcpm_port);
+ tcpm->port_disable(tcpm);
+}
+
static const struct pmic_typec_resources pm8150b_typec_res = {
.pdphy_res = &pm8150b_pdphy_res,
.port_res = &pm8150b_port_res,
@@ -158,6 +168,7 @@ static struct platform_driver qcom_pmic_typec_driver = {
},
.probe = qcom_pmic_typec_probe,
.remove = qcom_pmic_typec_remove,
+ .shutdown = qcom_pmic_typec_shutdown,
};
module_platform_driver(qcom_pmic_typec_driver);
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
index 3c75820c9187..0818582fe850 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
@@ -20,6 +20,7 @@ struct pmic_typec {
int (*port_start)(struct pmic_typec *tcpm,
struct tcpm_port *tcpm_port);
void (*port_stop)(struct pmic_typec *tcpm);
+ void (*port_disable)(struct pmic_typec *tcpm);
};
#define tcpc_to_tcpm(_tcpc_) container_of(_tcpc_, struct pmic_typec, tcpc)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
index b2ad31e85b5e..4dc302d732e8 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -700,6 +700,16 @@ static void qcom_pmic_typec_port_stop(struct pmic_typec *tcpm)
disable_delayed_work_sync(&pmic_typec_port->cc_debounce_dwork);
}
+static void qcom_pmic_typec_port_disable(struct pmic_typec *tcpm)
+{
+ struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
+
+ /* Present neither Rp nor Rd, so a connected partner detects a detach */
+ regmap_write(pmic_typec_port->regmap,
+ pmic_typec_port->base + TYPEC_MODE_CFG_REG,
+ TYPEC_DISABLE_CMD);
+}
+
int qcom_pmic_typec_port_probe(struct platform_device *pdev,
struct pmic_typec *tcpm,
const struct pmic_typec_port_resources *res,
@@ -779,6 +789,7 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
tcpm->port_start = qcom_pmic_typec_port_start;
tcpm->port_stop = qcom_pmic_typec_port_stop;
+ tcpm->port_disable = qcom_pmic_typec_port_disable;
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
@ 2026-11-20 10:03 ` sashiko-bot
2026-11-20 11:52 ` Bryan O'Donoghue
1 sibling, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-20 10:03 UTC (permalink / raw)
To: Neil Armstrong; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: typec: qcom-pmic-typec: missing Fixes trailer for pdphy
stop fix
--
commit b45aad2ca233d0a40118f71870955c8a4770e204
Author: Neil Armstrong <neil.armstrong@linaro.org>
> usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
>
> qcom_pmic_typec_pdphy_stop() only terminates the ongoing transmission and
> clears the RX frame filter, the PD PHY itself stays enabled.
>
> Use qcom_pmic_typec_pdphy_disable() so the PD PHY is also turned off
> before its supply is released, leaving it in the same state as before
> qcom_pmic_typec_pdphy_start().
>
> Assisted-by: LLM
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
[Severity: Low]
This fixes qcom_pmic_typec_pdphy_stop() leaving the PD PHY enabled when stopping. Should this include:
Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-topic-tcpm-qcom-fixes-v1-0-9a152f906fba@linaro.org?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
@ 2026-11-20 10:15 ` sashiko-bot
2026-11-20 10:53 ` Neil Armstrong
2026-11-20 11:55 ` Bryan O'Donoghue
1 sibling, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-11-20 10:15 UTC (permalink / raw)
To: Neil Armstrong; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: typec: qcom: NULL deref in qcom_pmic_typec_shutdown() when
VBUS is on
- [Medium] usb: typec: qcom-pmic-typec: missing port_disable() in remove
and probe unwind
--
commit 27e120f037d3faf6c51dac7774569601de458e75
Author: Neil Armstrong <neil.armstrong@linaro.org>
usb: typec: qcom-pmic-typec: detach the port on shutdown
This commit adds a platform driver shutdown callback that stops the port
and PD PHY, unregisters the TCPM port, and disables the Type-C block so
that a connected partner sees a detach on reboot or power off.
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> index 58d1e6aae637d..8169db478b8aa 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> @@ -134,6 +134,16 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
> fwnode_handle_put(tcpm->tcpc.fwnode);
> }
>
> +static void qcom_pmic_typec_shutdown(struct platform_device *pdev)
> +{
> + struct pmic_typec *tcpm = platform_get_drvdata(pdev);
> +
> + tcpm->pdphy_stop(tcpm);
> + tcpm->port_stop(tcpm);
> + tcpm_unregister_port(tcpm->tcpm_port);
[Severity: High]
Can calling tcpm_unregister_port() here cause a NULL pointer dereference
on port->wq when shutting down with an attached sink partner powered by
VBUS?
tcpm_unregister_port() destroys port->wq and sets it to NULL before
calling tcpm_reset_port() -> tcpm_init_vbus() ->
qcom_pmic_typec_port_set_vbus(). When VBUS transitions from enabled to
disabled, qcom_pmic_typec_port_set_vbus() calls tcpm_vbus_change(), which
queues work onto port->wq:
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c:qcom_pmic_typec_port_set_vbus() {
...
ret = qcom_pmic_typec_port_vbus_toggle(pmic_typec_port, on);
if (ret)
goto done;
pmic_typec_port->vbus_enabled = on;
tcpm_vbus_change(tcpm->tcpm_port);
...
}
kthread_queue_work() then dereferences NULL in &worker->lock, crashing
before tcpm->port_disable(tcpm) is reached.
> + tcpm->port_disable(tcpm);
> +}
[Severity: Medium]
Should tcpm->port_disable(tcpm) also be called in qcom_pmic_typec_remove()
and the port_unregister error path in qcom_pmic_typec_probe()?
Without it, unbinding the driver or failing probe after
tcpm_register_port() leaves TYPEC_MODE_CFG_REG presenting Rp or Rd with no
TCPM or PD PHY servicing the port, and a subsequent reboot or power off
will not invoke qcom_pmic_typec_shutdown() on the unbound device.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-topic-tcpm-qcom-fixes-v1-0-9a152f906fba@linaro.org?part=2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown
2026-11-20 10:15 ` sashiko-bot
@ 2026-11-20 10:53 ` Neil Armstrong
0 siblings, 0 replies; 8+ messages in thread
From: Neil Armstrong @ 2026-11-20 10:53 UTC (permalink / raw)
To: sashiko-reviews; +Cc: linux-usb
On 11/20/26 11:15, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [High] usb: typec: qcom: NULL deref in qcom_pmic_typec_shutdown() when
> VBUS is on
> - [Medium] usb: typec: qcom-pmic-typec: missing port_disable() in remove
> and probe unwind
> --
>
> commit 27e120f037d3faf6c51dac7774569601de458e75
> Author: Neil Armstrong <neil.armstrong@linaro.org>
>
> usb: typec: qcom-pmic-typec: detach the port on shutdown
>
> This commit adds a platform driver shutdown callback that stops the port
> and PD PHY, unregisters the TCPM port, and disables the Type-C block so
> that a connected partner sees a detach on reboot or power off.
>
>> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
>> index 58d1e6aae637d..8169db478b8aa 100644
>> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
>> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
>> @@ -134,6 +134,16 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
>> fwnode_handle_put(tcpm->tcpc.fwnode);
>> }
>>
>> +static void qcom_pmic_typec_shutdown(struct platform_device *pdev)
>> +{
>> + struct pmic_typec *tcpm = platform_get_drvdata(pdev);
>> +
>> + tcpm->pdphy_stop(tcpm);
>> + tcpm->port_stop(tcpm);
>> + tcpm_unregister_port(tcpm->tcpm_port);
>
> [Severity: High]
> Can calling tcpm_unregister_port() here cause a NULL pointer dereference
> on port->wq when shutting down with an attached sink partner powered by
> VBUS?
>
> tcpm_unregister_port() destroys port->wq and sets it to NULL before
> calling tcpm_reset_port() -> tcpm_init_vbus() ->
> qcom_pmic_typec_port_set_vbus(). When VBUS transitions from enabled to
> disabled, qcom_pmic_typec_port_set_vbus() calls tcpm_vbus_change(), which
> queues work onto port->wq:
>
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c:qcom_pmic_typec_port_set_vbus() {
> ...
> ret = qcom_pmic_typec_port_vbus_toggle(pmic_typec_port, on);
> if (ret)
> goto done;
>
> pmic_typec_port->vbus_enabled = on;
> tcpm_vbus_change(tcpm->tcpm_port);
> ...
> }
>
> kthread_queue_work() then dereferences NULL in &worker->lock, crashing
> before tcpm->port_disable(tcpm) is reached.
What's the difference with qcom_pmic_typec_remove() ? So the same regression
occurs with qcom_pmic_typec_remove() and is not related with this change.
I'll try to fix it
>
>> + tcpm->port_disable(tcpm);
>> +}
>
> [Severity: Medium]
> Should tcpm->port_disable(tcpm) also be called in qcom_pmic_typec_remove()
> and the port_unregister error path in qcom_pmic_typec_probe()?
>
> Without it, unbinding the driver or failing probe after
> tcpm_register_port() leaves TYPEC_MODE_CFG_REG presenting Rp or Rd with no
> TCPM or PD PHY servicing the port, and a subsequent reboot or power off
> will not invoke qcom_pmic_typec_shutdown() on the unbound device.
>
Ok so it should be extended by:
- check if not in TYPEC_DISABLE_CMD on probe, and force a detach is enabled before
- disable on remove and probe fail to have a coherent state
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-20 10:03 ` sashiko-bot
@ 2026-11-20 11:52 ` Bryan O'Donoghue
1 sibling, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-11-20 11:52 UTC (permalink / raw)
To: Neil Armstrong, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb
On 20/11/2026 09:59, Neil Armstrong wrote:
> qcom_pmic_typec_pdphy_stop() only terminates the ongoing transmission and
> clears the RX frame filter, the PD PHY itself stays enabled.
>
> Use qcom_pmic_typec_pdphy_disable() so the PD PHY is also turned off
> before its supply is released, leaving it in the same state as before
> qcom_pmic_typec_pdphy_start().
>
> Assisted-by: LLM
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 435e07659d65..08cf65951796 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -545,7 +545,7 @@ static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm)
>
> cancel_work_sync(&pmic_typec_pdphy->reset_work);
>
> - qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
> + qcom_pmic_typec_pdphy_disable(pmic_typec_pdphy);
>
> regulator_disable(pmic_typec_pdphy->vdd_pdphy);
> }
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
2026-11-20 10:15 ` sashiko-bot
@ 2026-11-20 11:55 ` Bryan O'Donoghue
1 sibling, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-11-20 11:55 UTC (permalink / raw)
To: Neil Armstrong, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb
On 20/11/2026 09:59, Neil Armstrong wrote:
> On reboot or power off the port is left as is: a source partner keeps
> the negotiated contract, possibly above 5V, and a sink partner stays
> powered by the OTG boost while nothing services the port anymore.
>
> Add a shutdown callback stopping the port and the PD PHY, unregistering
> the TCPM port, which turns VBUS and VCONN off, and finally disabling the
> Type-C block so the partner sees a detach.
>
> Assisted-by: LLM
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
LGTM
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-20 11:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 9:59 [PATCH 0/2] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-20 10:03 ` sashiko-bot
2026-11-20 11:52 ` Bryan O'Donoghue
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
2026-11-20 10:15 ` sashiko-bot
2026-11-20 10:53 ` Neil Armstrong
2026-11-20 11:55 ` Bryan O'Donoghue
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.