mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Diederik de Haas" <diederik@cknow-tech.com>
To: "Michael Wu" <michael@allwinnertech.com>,
	<myungjoo.ham@samsung.com>, <cw00.choi@samsung.com>,
	<andriy.shevchenko@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>,
	"Diederik de Haas" <diederik@cknow-tech.com>,
	"Dragan Simic" <dsimic@manjaro.org>,
	<linux-rockchip@lists.infradead.org>
Subject: Re: [PATCH v3] extcon: Fixed sysfs duplicate filename issue
Date: Sun, 21 Dec 2025 15:01:11 +0100	[thread overview]
Message-ID: <DF3Y6Z8X4GC6.11WQOENQD4EDW@cknow-tech.com> (raw)
In-Reply-To: <20251024024946.16618-1-michael@allwinnertech.com>

Hi,

On Fri Oct 24, 2025 at 4:49 AM CEST, Michael Wu wrote:
> With current extcon_dev_unregister() timing, ida_free is before
> device_unregister(), that may cause current id re-alloc to another
> device in extcon_dev_register() context but sysfs filename path not
> removal completed yet.

I periodically get errors like this:

[    7.116152] rockchip-usb2phy fe8a0000.usb2phy: error -EEXIST: failed to register extcon device
[    7.117005] rockchip-usb2phy fe8a0000.usb2phy: probe with driver rockchip-usb2phy failed with error -17

This was today on a NanoPi R5S (rk3568), but I have seen it before and
on multiple devices. They are all Rockchip based, but that's (quite)
possible because that's what I use the most (and where I pay quite a bit
of attention to dmesg).

Slightly fuller dmesg output of the above error is here:
https://paste.sr.ht/~diederik/42c6b3405386c823cd9f837d73a9a32e810361be
And via 'journalctl' I hopefully got the full dmesg output:
https://paste.sr.ht/~diederik/7a6109115b1ad85290de482db091dad3759ec159

Here are 2 similar logs, this time on PineTab2 and Quartz64-A (both rk3566)
https://paste.sr.ht/~diederik/cfe606801d3dab0267bea7049687d24c0d6e8d71

Those are all the logs I have saved, but it has happened several times
besides that. But most times I just rebooted and didn't save the log.
Today I looked a bit further, found commit 7bba9e81a6fb, searched on
lore.k.o and found this patch.

So I'm wondering whether this patch would also fix 'my' issue?
Or is this a different issue?

Most of my kernel modules are ``=m`` which is possibly a factor. And
because of that, -EPROBE_DEFER probably happens several times.
Dunno if that's relevant, but figured I'd mention it.

Cheers,
  Diederik

> The right timing shows below:
> on extcon_dev_register: ida_alloc() -> device_register()
> on extcon_dev_unregister: device_unregister() -> ida_free()
>
> stack information when an error occurs:
> sysfs: cannot create duplicate filename '/class/extcon/extcon1'
> Call trace:
>  sysfs_warn_dup+0x68/0x88
>  sysfs_do_create_link_sd+0x94/0xdc
>  sysfs_create_link+0x30/0x48
>  device_add_class_symlinks+0xb4/0x12c
>  device_add+0x1e0/0x48c
>  device_register+0x20/0x34
>  extcon_dev_register+0x3b8/0x5c4
>
> Fixes: 7bba9e81a6fb ("extcon: Use unique number for the extcon device ID")
> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Michael Wu <michael@allwinnertech.com>
> ---
> ChangeLog:
> V2 -> V3: Dropped some noisy lines in commit messages, suggested by Andy Shevchenko
> V1 -> V2: Update commit msg, suggested by Markus Elfring
> V1: https://lore.kernel.org/all/20251011053719.87055-1-michael@allwinnertech.com/
> ---
> ---
>  drivers/extcon/extcon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index e7f55c021e562..c08f642d7f5ee 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1371,10 +1371,10 @@ void extcon_dev_unregister(struct extcon_dev *edev)
>  		return;
>  	}
>  
> -	ida_free(&extcon_dev_ids, edev->id);
> -
>  	device_unregister(&edev->dev);
>  
> +	ida_free(&extcon_dev_ids, edev->id);
> +
>  	if (edev->mutually_exclusive && edev->max_supported) {
>  		for (index = 0; edev->mutually_exclusive[index];
>  				index++)


  parent reply	other threads:[~2025-12-21 14:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24  2:49 Michael Wu
2025-11-23 15:38 ` Chanwoo Choi
2025-12-21 14:01 ` Diederik de Haas [this message]
2025-12-27 15:08   ` Andy Shevchenko
2025-12-28 11:01     ` Diederik de Haas
2025-12-28 17:26       ` Andy Shevchenko
2025-12-29 23:31         ` Diederik de Haas
2025-12-30 11:26           ` Andy Shevchenko
2025-12-30 14:24             ` Diederik de Haas
2026-01-02 11:38               ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DF3Y6Z8X4GC6.11WQOENQD4EDW@cknow-tech.com \
    --to=diederik@cknow-tech.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=cw00.choi@samsung.com \
    --cc=dsimic@manjaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=michael@allwinnertech.com \
    --cc=myungjoo.ham@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®