* [PATCH v2 1/2] extcon: synchronize all-connector notifier removal
2026-11-15 11:47 [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Hongyan Xu
@ 2026-11-15 11:47 ` Hongyan Xu
2026-11-16 11:28 ` Ilpo Järvinen
2026-11-15 11:47 ` [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach Hongyan Xu
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Hongyan Xu @ 2026-11-15 11:47 UTC (permalink / raw)
To: Ilpo J鐩瞨vinen, Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Derek J. Clark, Mark Pearson,
Rong Zhang, platform-driver-x86, linux-kernel, stable
extcon_sync() invokes the all-connector raw notifier chain after
dropping edev->lock. Unregister unlinks a block under that lock but
does not wait for an in-flight callback, so managed consumers can
release their state while a callback still publishes work.
Use an atomic notifier chain for the all-connector notifications.
Its RCU read section and synchronized unregister provide the
required callback quiescence. Use the notifier implementation's
own writer lock and perform its grace-period wait outside edev's
spinlock. Document callback and unregister context requirements.
The current all-connector consumers defer their operations to work
items and their callbacks do not sleep. Per-ID raw chains retain
their existing behavior: some OMAP callbacks perform regulator
operations and need a separate context-compatible repair.
Found by the author's in-house static analysis tool.
Fixes: 815429b39d94 ("extcon: Add new extcon_register_notifier_all() to monitor all external connectors")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/2ef4ad43-497f-c40f-b18a-f5b75799d95d@linux.intel.com/
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
---
Discovery: found by the author's in-house static analysis tool.
Documentation/driver-api/extcon.rst | 2 +-
drivers/extcon/extcon.c | 28 +++++++++-------------------
drivers/extcon/extcon.h | 2 +-
include/linux/extcon.h | 4 ++++
4 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/Documentation/driver-api/extcon.rst b/Documentation/driver-api/extcon.rst
index d3217b9..384d743 100644
--- a/Documentation/driver-api/extcon.rst
+++ b/Documentation/driver-api/extcon.rst
@@ -70,7 +70,7 @@ The core structure representing an Extcon device::
/* Internal data */
struct device dev;
unsigned int id;
- struct raw_notifier_head nh_all;
+ struct atomic_notifier_head nh_all;
struct raw_notifier_head *nh;
struct list_head entry;
int max_supported;
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 98d85cc..b8d8c2a 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -456,10 +456,10 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id)
raw_notifier_call_chain(&edev->nh[index], state, edev);
/*
- * Call functions in a raw notifier chain for the all supported
+ * Call functions in the atomic notifier chain for all supported
* external connectors.
*/
- raw_notifier_call_chain(&edev->nh_all, state, edev);
+ atomic_notifier_call_chain(&edev->nh_all, state, edev);
spin_lock_irqsave(&edev->lock, flags);
/* This could be in interrupt handler */
@@ -967,6 +967,7 @@ EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
*
* Note that this function registers a notifier block in order to receive
* the state change of all supported external connectors from extcon device.
+ * Callbacks run under the RCU read-side critical section and must not sleep.
* And the second parameter given to the callback of nb (val) is
* the current state and the third pameter is the pointer of extcon device.
*
@@ -975,17 +976,10 @@ EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
int extcon_register_notifier_all(struct extcon_dev *edev,
struct notifier_block *nb)
{
- unsigned long flags;
- int ret;
-
if (!edev || !nb)
return -EINVAL;
- spin_lock_irqsave(&edev->lock, flags);
- ret = raw_notifier_chain_register(&edev->nh_all, nb);
- spin_unlock_irqrestore(&edev->lock, flags);
-
- return ret;
+ return atomic_notifier_chain_register(&edev->nh_all, nb);
}
EXPORT_SYMBOL_GPL(extcon_register_notifier_all);
@@ -995,21 +989,17 @@ EXPORT_SYMBOL_GPL(extcon_register_notifier_all);
* @nb: a notifier block to be registered
*
* Returns 0 if success or error number if fail.
+ *
+ * Waits for in-flight callbacks. Must be called from process context and
+ * outside a notifier callback.
*/
int extcon_unregister_notifier_all(struct extcon_dev *edev,
struct notifier_block *nb)
{
- unsigned long flags;
- int ret;
-
if (!edev || !nb)
return -EINVAL;
- spin_lock_irqsave(&edev->lock, flags);
- ret = raw_notifier_chain_unregister(&edev->nh_all, nb);
- spin_unlock_irqrestore(&edev->lock, flags);
-
- return ret;
+ return atomic_notifier_chain_unregister(&edev->nh_all, nb);
}
EXPORT_SYMBOL_GPL(extcon_unregister_notifier_all);
@@ -1300,7 +1290,7 @@ int extcon_dev_register(struct extcon_dev *edev)
for (index = 0; index < edev->max_supported; index++)
RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]);
- RAW_INIT_NOTIFIER_HEAD(&edev->nh_all);
+ ATOMIC_INIT_NOTIFIER_HEAD(&edev->nh_all);
dev_set_drvdata(&edev->dev, edev);
dev_set_name(&edev->dev, "extcon%d", edev->id);
diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h
index 9461826..5a3f0c4 100644
--- a/drivers/extcon/extcon.h
+++ b/drivers/extcon/extcon.h
@@ -48,7 +48,7 @@ struct extcon_dev {
/* Internal data. Please do not set. */
struct device dev;
unsigned int id;
- struct raw_notifier_head nh_all;
+ struct atomic_notifier_head nh_all;
struct raw_notifier_head *nh;
struct list_head entry;
int max_supported;
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index e596a0a..869bac9 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -209,6 +209,10 @@ void devm_extcon_unregister_notifier(struct device *dev,
struct extcon_dev *edev, unsigned int id,
struct notifier_block *nb);
+/*
+ * All-connector callbacks must not sleep. Unregister waits for callbacks and
+ * must be called from process context, outside a notifier callback.
+ */
int extcon_register_notifier_all(struct extcon_dev *edev,
struct notifier_block *nb);
int extcon_unregister_notifier_all(struct extcon_dev *edev,
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/2] extcon: synchronize all-connector notifier removal
2026-11-15 11:47 ` [PATCH v2 1/2] extcon: synchronize all-connector notifier removal Hongyan Xu
@ 2026-11-16 11:28 ` Ilpo Järvinen
0 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 11:28 UTC (permalink / raw)
To: Hongyan Xu
Cc: Hans de Goede, MyungJoo Ham, Chanwoo Choi, Derek J. Clark,
Mark Pearson, Rong Zhang, platform-driver-x86, LKML, stable
On Sun, 15 Nov 2026, Hongyan Xu wrote:
> extcon_sync() invokes the all-connector raw notifier chain after
> dropping edev->lock. Unregister unlinks a block under that lock but
> does not wait for an in-flight callback, so managed consumers can
> release their state while a callback still publishes work.
>
> Use an atomic notifier chain for the all-connector notifications.
> Its RCU read section and synchronized unregister provide the
> required callback quiescence. Use the notifier implementation's
> own writer lock and perform its grace-period wait outside edev's
> spinlock. Document callback and unregister context requirements.
>
> The current all-connector consumers defer their operations to work
> items and their callbacks do not sleep. Per-ID raw chains retain
> their existing behavior: some OMAP callbacks perform regulator
> operations and need a separate context-compatible repair.
>
> Found by the author's in-house static analysis tool.
I think sashiko found this too:
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260806060526.1189-1-getshell%40seu.edu.cn
> Fixes: 815429b39d94 ("extcon: Add new extcon_register_notifier_all() to monitor all external connectors")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/2ef4ad43-497f-c40f-b18a-f5b75799d95d@linux.intel.com/
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
--
i.
> ---
>
> Discovery: found by the author's in-house static analysis tool.
>
> Documentation/driver-api/extcon.rst | 2 +-
> drivers/extcon/extcon.c | 28 +++++++++-------------------
> drivers/extcon/extcon.h | 2 +-
> include/linux/extcon.h | 4 ++++
> 4 files changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/Documentation/driver-api/extcon.rst b/Documentation/driver-api/extcon.rst
> index d3217b9..384d743 100644
> --- a/Documentation/driver-api/extcon.rst
> +++ b/Documentation/driver-api/extcon.rst
> @@ -70,7 +70,7 @@ The core structure representing an Extcon device::
> /* Internal data */
> struct device dev;
> unsigned int id;
> - struct raw_notifier_head nh_all;
> + struct atomic_notifier_head nh_all;
> struct raw_notifier_head *nh;
> struct list_head entry;
> int max_supported;
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index 98d85cc..b8d8c2a 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -456,10 +456,10 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id)
> raw_notifier_call_chain(&edev->nh[index], state, edev);
>
> /*
> - * Call functions in a raw notifier chain for the all supported
> + * Call functions in the atomic notifier chain for all supported
> * external connectors.
> */
> - raw_notifier_call_chain(&edev->nh_all, state, edev);
> + atomic_notifier_call_chain(&edev->nh_all, state, edev);
>
> spin_lock_irqsave(&edev->lock, flags);
> /* This could be in interrupt handler */
> @@ -967,6 +967,7 @@ EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
> *
> * Note that this function registers a notifier block in order to receive
> * the state change of all supported external connectors from extcon device.
> + * Callbacks run under the RCU read-side critical section and must not sleep.
> * And the second parameter given to the callback of nb (val) is
> * the current state and the third pameter is the pointer of extcon device.
> *
> @@ -975,17 +976,10 @@ EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
> int extcon_register_notifier_all(struct extcon_dev *edev,
> struct notifier_block *nb)
> {
> - unsigned long flags;
> - int ret;
> -
> if (!edev || !nb)
> return -EINVAL;
>
> - spin_lock_irqsave(&edev->lock, flags);
> - ret = raw_notifier_chain_register(&edev->nh_all, nb);
> - spin_unlock_irqrestore(&edev->lock, flags);
> -
> - return ret;
> + return atomic_notifier_chain_register(&edev->nh_all, nb);
> }
> EXPORT_SYMBOL_GPL(extcon_register_notifier_all);
>
> @@ -995,21 +989,17 @@ EXPORT_SYMBOL_GPL(extcon_register_notifier_all);
> * @nb: a notifier block to be registered
> *
> * Returns 0 if success or error number if fail.
> + *
> + * Waits for in-flight callbacks. Must be called from process context and
> + * outside a notifier callback.
> */
> int extcon_unregister_notifier_all(struct extcon_dev *edev,
> struct notifier_block *nb)
> {
> - unsigned long flags;
> - int ret;
> -
> if (!edev || !nb)
> return -EINVAL;
>
> - spin_lock_irqsave(&edev->lock, flags);
> - ret = raw_notifier_chain_unregister(&edev->nh_all, nb);
> - spin_unlock_irqrestore(&edev->lock, flags);
> -
> - return ret;
> + return atomic_notifier_chain_unregister(&edev->nh_all, nb);
> }
> EXPORT_SYMBOL_GPL(extcon_unregister_notifier_all);
>
> @@ -1300,7 +1290,7 @@ int extcon_dev_register(struct extcon_dev *edev)
> for (index = 0; index < edev->max_supported; index++)
> RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]);
>
> - RAW_INIT_NOTIFIER_HEAD(&edev->nh_all);
> + ATOMIC_INIT_NOTIFIER_HEAD(&edev->nh_all);
>
> dev_set_drvdata(&edev->dev, edev);
> dev_set_name(&edev->dev, "extcon%d", edev->id);
> diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h
> index 9461826..5a3f0c4 100644
> --- a/drivers/extcon/extcon.h
> +++ b/drivers/extcon/extcon.h
> @@ -48,7 +48,7 @@ struct extcon_dev {
> /* Internal data. Please do not set. */
> struct device dev;
> unsigned int id;
> - struct raw_notifier_head nh_all;
> + struct atomic_notifier_head nh_all;
> struct raw_notifier_head *nh;
> struct list_head entry;
> int max_supported;
> diff --git a/include/linux/extcon.h b/include/linux/extcon.h
> index e596a0a..869bac9 100644
> --- a/include/linux/extcon.h
> +++ b/include/linux/extcon.h
> @@ -209,6 +209,10 @@ void devm_extcon_unregister_notifier(struct device *dev,
> struct extcon_dev *edev, unsigned int id,
> struct notifier_block *nb);
>
> +/*
> + * All-connector callbacks must not sleep. Unregister waits for callbacks and
> + * must be called from process context, outside a notifier callback.
> + */
> int extcon_register_notifier_all(struct extcon_dev *edev,
> struct notifier_block *nb);
> int extcon_unregister_notifier_all(struct extcon_dev *edev,
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach
2026-11-15 11:47 [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Hongyan Xu
2026-11-15 11:47 ` [PATCH v2 1/2] extcon: synchronize all-connector notifier removal Hongyan Xu
@ 2026-11-15 11:47 ` Hongyan Xu
2026-11-16 12:59 ` Rong Zhang
2026-11-16 12:58 ` [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Rong Zhang
2026-11-16 14:30 ` Hongyan Xu
3 siblings, 1 reply; 8+ messages in thread
From: Hongyan Xu @ 2026-11-15 11:47 UTC (permalink / raw)
To: Ilpo J鐩瞨vinen, Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Derek J. Clark, Mark Pearson,
Rong Zhang, platform-driver-x86, linux-kernel, stable
The extcon callback schedules a worker which uses managed serdev,
pinctrl and GPIO resources. Releasing those resources while the
worker remains pending or running can access invalid state.
Install managed work cancellation after the UART is opened and
before registering the managed notifier. Reverse devres order
then unregisters and waits for notifier callbacks, drains the
worker and only afterwards closes the UART and frees its pin
resources. This depends on the preceding all-connector notifier
synchronization patch; resource order alone is insufficient.
The actual lc824206xa supplier notifies from work context, and
this consumer callback only schedules work. The callback must not
outlive synchronized unregister or republish after cancellation.
Found by the author's in-house static analysis tool.
Fixes: b2ed33e8d486 ("platform/x86: Add lenovo-yoga-tab2-pro-1380-fastcharger driver")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20260806060526.1189-1-getshell@seu.edu.cn/
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
---
Discovery: found by the author's in-house static analysis tool.
.../platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
index 9e2ac80..51ff383 100644
--- a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
+++ b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
@@ -8,6 +8,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/delay.h>
+#include <linux/devm-helpers.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/extcon.h>
@@ -160,7 +161,6 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
fc->dev = dev;
fc->nb.notifier_call = yt2_1380_fc_extcon_evt;
- INIT_WORK(&fc->work, yt2_1380_fc_worker);
/*
* Do this first since it may return -EPROBE_DEFER.
@@ -209,6 +209,10 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
serdev_device_set_baudrate(serdev, 600);
serdev_device_set_flow_control(serdev, false);
+ ret = devm_work_autocancel(dev, &fc->work, yt2_1380_fc_worker);
+ if (ret)
+ return ret;
+
ret = devm_extcon_register_notifier_all(dev, fc->extcon, &fc->nb);
if (ret)
return dev_err_probe(dev, ret, "registering extcon notifier\n");
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach
2026-11-15 11:47 ` [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach Hongyan Xu
@ 2026-11-16 12:59 ` Rong Zhang
2026-11-16 13:29 ` Ilpo Järvinen
0 siblings, 1 reply; 8+ messages in thread
From: Rong Zhang @ 2026-11-16 12:59 UTC (permalink / raw)
To: Hongyan Xu, Ilpo Järvinen, Hans de Goede
Cc: Zehao Gao, Hyunjung Ko, MyungJoo Ham, Chanwoo Choi,
Derek J.Clark, Mark Pearson, platform-driver-x86, linux-kernel,
stable
Hi Hongyan,
On Sun, 2026-11-15 at 19:47 +0800, Hongyan Xu wrote:
> The extcon callback schedules a worker which uses managed serdev,
> pinctrl and GPIO resources. Releasing those resources while the
> worker remains pending or running can access invalid state.
>
> Install managed work cancellation after the UART is opened and
> before registering the managed notifier. Reverse devres order
> then unregisters and waits for notifier callbacks, drains the
> worker and only afterwards closes the UART and frees its pin
> resources. This depends on the preceding all-connector notifier
> synchronization patch; resource order alone is insufficient.
>
> The actual lc824206xa supplier notifies from work context, and
> this consumer callback only schedules work. The callback must not
> outlive synchronized unregister or republish after cancellation.
>
> Found by the author's in-house static analysis tool.
>
> Fixes: b2ed33e8d486 ("platform/x86: Add lenovo-yoga-tab2-pro-1380-fastcharger driver")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/20260806060526.1189-1-getshell@seu.edu.cn/
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
The submitter's S-o-b should be placed at last.
(+CC Zehao)
And how did Zehao contribute to the series? You didn't even CC them!
(+CC Hyunjung)
Hyunjung is also working on this. See
https://msgid.link/20261116122001.3096223-1-hj351016@gmail.com
Thanks,
Rong
> ---
>
> Discovery: found by the author's in-house static analysis tool.
>
> .../platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> index 9e2ac80..51ff383 100644
> --- a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> +++ b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> @@ -8,6 +8,7 @@
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> #include <linux/delay.h>
> +#include <linux/devm-helpers.h>
> #include <linux/err.h>
> #include <linux/errno.h>
> #include <linux/extcon.h>
> @@ -160,7 +161,6 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
>
> fc->dev = dev;
> fc->nb.notifier_call = yt2_1380_fc_extcon_evt;
> - INIT_WORK(&fc->work, yt2_1380_fc_worker);
>
> /*
> * Do this first since it may return -EPROBE_DEFER.
> @@ -209,6 +209,10 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
> serdev_device_set_baudrate(serdev, 600);
> serdev_device_set_flow_control(serdev, false);
>
> + ret = devm_work_autocancel(dev, &fc->work, yt2_1380_fc_worker);
> + if (ret)
> + return ret;
> +
> ret = devm_extcon_register_notifier_all(dev, fc->extcon, &fc->nb);
> if (ret)
> return dev_err_probe(dev, ret, "registering extcon notifier\n");
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach
2026-11-16 12:59 ` Rong Zhang
@ 2026-11-16 13:29 ` Ilpo Järvinen
0 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 13:29 UTC (permalink / raw)
To: Rong Zhang
Cc: Hongyan Xu, Hans de Goede, Zehao Gao, Hyunjung Ko, MyungJoo Ham,
Chanwoo Choi, Derek J.Clark, Mark Pearson, platform-driver-x86,
LKML, stable
On Mon, 16 Nov 2026, Rong Zhang wrote:
> Hi Hongyan,
>
> On Sun, 2026-11-15 at 19:47 +0800, Hongyan Xu wrote:
> > The extcon callback schedules a worker which uses managed serdev,
> > pinctrl and GPIO resources. Releasing those resources while the
> > worker remains pending or running can access invalid state.
> >
> > Install managed work cancellation after the UART is opened and
> > before registering the managed notifier. Reverse devres order
> > then unregisters and waits for notifier callbacks, drains the
> > worker and only afterwards closes the UART and frees its pin
> > resources. This depends on the preceding all-connector notifier
> > synchronization patch; resource order alone is insufficient.
> >
> > The actual lc824206xa supplier notifies from work context, and
> > this consumer callback only schedules work. The callback must not
> > outlive synchronized unregister or republish after cancellation.
> >
> > Found by the author's in-house static analysis tool.
> >
> > Fixes: b2ed33e8d486 ("platform/x86: Add lenovo-yoga-tab2-pro-1380-fastcharger driver")
> > Cc: stable@vger.kernel.org
> > Link: https://lore.kernel.org/all/20260806060526.1189-1-getshell@seu.edu.cn/
> > Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> > Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
>
> The submitter's S-o-b should be placed at last.
>
> (+CC Zehao)
>
> And how did Zehao contribute to the series? You didn't even CC them!
>
> (+CC Hyunjung)
>
> Hyunjung is also working on this. See
> https://msgid.link/20261116122001.3096223-1-hj351016@gmail.com
Yeah, and I'll prioritize that work over this because otherwise LLM users
could just steal other people's patches before I can process them.
The extcon part was reported by sashiko as a response to Hyunjung's patch
so I suspect this submitter's LLM got that idea from there (of course
without attributing it to sashiko).
The extcon fix might not have been submitted before AFAIK but that's not
pdx86 material anyway.
--
i.
> Thanks,
> Rong
>
> > ---
> >
> > Discovery: found by the author's in-house static analysis tool.
> >
> > .../platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> > index 9e2ac80..51ff383 100644
> > --- a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> > +++ b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> > @@ -8,6 +8,7 @@
> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> >
> > #include <linux/delay.h>
> > +#include <linux/devm-helpers.h>
> > #include <linux/err.h>
> > #include <linux/errno.h>
> > #include <linux/extcon.h>
> > @@ -160,7 +161,6 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
> >
> > fc->dev = dev;
> > fc->nb.notifier_call = yt2_1380_fc_extcon_evt;
> > - INIT_WORK(&fc->work, yt2_1380_fc_worker);
> >
> > /*
> > * Do this first since it may return -EPROBE_DEFER.
> > @@ -209,6 +209,10 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
> > serdev_device_set_baudrate(serdev, 600);
> > serdev_device_set_flow_control(serdev, false);
> >
> > + ret = devm_work_autocancel(dev, &fc->work, yt2_1380_fc_worker);
> > + if (ret)
> > + return ret;
> > +
> > ret = devm_extcon_register_notifier_all(dev, fc->extcon, &fc->nb);
> > if (ret)
> > return dev_err_probe(dev, ret, "registering extcon notifier\n");
>
--
i.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown
2026-11-15 11:47 [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Hongyan Xu
2026-11-15 11:47 ` [PATCH v2 1/2] extcon: synchronize all-connector notifier removal Hongyan Xu
2026-11-15 11:47 ` [PATCH v2 2/2] platform/x86: lenovo: cancel fastcharger work on detach Hongyan Xu
@ 2026-11-16 12:58 ` Rong Zhang
2026-11-16 14:30 ` Hongyan Xu
3 siblings, 0 replies; 8+ messages in thread
From: Rong Zhang @ 2026-11-16 12:58 UTC (permalink / raw)
To: Hongyan Xu, Ilpo Järvinen, Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Derek J.Clark, Mark Pearson,
platform-driver-x86, linux-kernel, stable
Hi Hongyan,
On Sun, 2026-11-15 at 19:47 +0800, Hongyan Xu wrote:
> The Lenovo Yoga Tab 2 fastcharger driver releases managed serdev,
> pinctrl and GPIO resources while its extcon callback can still publish
> work. Ordering the devres actions alone is not enough because the
> all-connector raw notifier does not wait for an in-flight callback.
>
> Patch 1 converts only the all-connector notifier chain to an atomic
> chain so unregister waits for callbacks and is safe from interrupt
> context. The per-ID chains stay raw because some current callbacks
> perform sleeping regulator operations. Patch 2 then installs the
> managed work cancellation before the notifier, so reverse devres order
> stops the producer before releasing the resources it uses.
>
Where's the link to v1?
>
> Hongyan Xu (2):
> extcon: synchronize all-connector notifier removal
> platform/x86: lenovo: cancel fastcharger work on detach
>
> Documentation/driver-api/extcon.rst | 2 +-
> drivers/extcon/extcon.c | 28 ++++++-------------
> drivers/extcon/extcon.h | 2 +-
> .../lenovo/yoga-tab2-pro-1380-fastcharger.c | 6 +++-
> include/linux/extcon.h | 4 +++
> 5 files changed, 20 insertions(+), 22 deletions(-)
>
> --
> 2.50.1.windows.1
Using Windows to submit this is quite weird.
You submitted a lot of patches to different subsystems at the same
minute. Did you send the email yourself, or asked an LLM agent to flood
LKML for you? Did you (or your LLM agent) test it?
Could you at least figure out how to send patches in UTF-8 correctly
before deciding to use git-send-email on Windows? By using Windows, your
configuration couldn't even encode Ilpo's last name correctly (I've fixed
it in my reply) :-/
>
> Discovery: found by the author's in-house static analysis tool.
Wasn't this just LLM generated?
Confused,
Rong
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown
2026-11-15 11:47 [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Hongyan Xu
` (2 preceding siblings ...)
2026-11-16 12:58 ` [PATCH v2 0/2] extcon: synchronize all-connector removal and fix Lenovo fastcharger teardown Rong Zhang
@ 2026-11-16 14:30 ` Hongyan Xu
3 siblings, 0 replies; 8+ messages in thread
From: Hongyan Xu @ 2026-11-16 14:30 UTC (permalink / raw)
To: Rong Zhang, Ilpo Järvinen
Cc: Zehao Gao, Hyunjung, MyungJoo Ham, Chanwoo Choi, Derek J. Clark,
Mark Pearson, platform-driver-x86, linux-kernel
Hi Rong, Ilpo,
Thanks for the review, and sorry for the mess. Let me answer the questions, and also put one thing on the record about where the extcon part came from, because the timeline matters here.
v1 link: https://msgid.link/20260806060526.1189-1-getshell@seu.edu.cn
That is the patch I posted on 2026-08-06. I should have put it in the cover letter - my mistake.
Why the extcon patch exists at all, and why it is in this series:
v1 only cancelled the work inside the lenovo driver (devm_work_autocancel). After sending it I went back over the teardown path and realized the patch itself was not correct: cancelling the work is not enough, because the all-connector raw notifier in extcon can still be running a callback after the consumer unregistered, and that callback can publish the work again. So the root cause sits in extcon's notifier handling, and that is what 1/2 fixes. That is also why 2/2 says it depends on the preceding synchronization patch.
On the origin of the idea - I understand the suspicion, so here are the dates:
My v1 is from 2026-08-06 (link above). It is also the patchset referenced by the Closes: link Ilpo posted in the 1/2 thread.
sashiko reviewed that patchset back then and raised exactly this "extcon uses raw notifiers, the synchronization is insufficient" concern. I never received that report in my mailbox; I first learned about it from Ilpo's reply on 2026-11-09:
https://lore.kernel.org/all/2ef4ad43-497f-c40f-b18a-f5b75799d95d@linux.intel.com/
That is why 1/2 carries a Link: to that message.
Hyunjung's patch is from 2026-11-16:
https://msgid.link/20261116122001.3096223-1-hj351016@gmail.com
i.e. three months later.
So this did not come from Hyunjung's patch; if anything the order is the other way round. I am not trying to win an argument - I just do not want the record to say I took someone else's work.
The attribution Ilpo suggested is right, and I will use it:
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260806060526.1189-1-getshell%40seu.edu.cn
On the other points - all fair, all my fault:
S-o-b order: fixed. Zehao Gao co-audited this series with me, so his Signed-off-by comes first and mine (the submitter) last:
Signed-off-by: Zehao Gao <gaozehao@iie.ac.cn>
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
The mangled "Jarvinen": my git-send-email setup on Windows encoded the Cc display names as GBK instead of UTF-8. Fixed now (i18n.commitEncoding=utf-8, sendemail encoding, UTF-8 console), and I checked the headers of a test message before posting. Sorry for the noise, and thanks for fixing my Cc line.
On Ilpo's point that the extcon fix is not pdx86 material - agreed. I will take 1/2 out of this series; if the extcon change is still wanted, I will repost it to the extcon list on its own with the attribution above. And since Hyunjung is already working on this, I am happy to let her series go first - if her approach covers it, mine can be dropped entirely.
Although I do not have the hardware, the change has been build-tested and manually audited. The analysis and the patch text were produced with LLM assistance, then reviewed and edited by me.
Thanks,
Hongyan
^ permalink raw reply [flat|nested] 8+ messages in thread