From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 316ED78F2F for ; Sun, 21 Dec 2025 14:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766325683; cv=none; b=WBzL2HPdL6Qy+Y8V5aU0M6CgXw8aUE80sN1JtBTX2JLPDzTHVERqyA0egQhzRubZHPN+mxzQ3dUDSkH2G1SZF5XT3meEUlzmhv952ci1jv9yzbmNcJu4qOjYOeGp6STiYr8p7Mq9hOfdD36y/epllCYrelu1OOPOmiKwoo7DKNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766325683; c=relaxed/simple; bh=MAsiiZN/vAY26qoKsKYygT0NMnNXvYX3xrXzBcP2G0E=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=nyd0ztifvVHFQoKHPy9M+6qL+SM1Z73kX99FbQTa4np/Om3iMB0e11Az01yXsIfi8K71LMJ200cwVz94SlkXHM3UVQ1Nl20HSweTFq8SWt3jX0nL5cSqcbKRP/tVKPzbRMmH+iraqZ5KDOOXi2kj80U0voP0uyzMMyAgtzE4+xQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cknow-tech.com; spf=pass smtp.mailfrom=cknow-tech.com; dkim=pass (2048-bit key) header.d=cknow-tech.com header.i=@cknow-tech.com header.b=SLxOPTJD; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cknow-tech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cknow-tech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cknow-tech.com header.i=@cknow-tech.com header.b="SLxOPTJD" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cknow-tech.com; s=key1; t=1766325674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EnCgnR5pTlWvp05mToIOM/ovHvN7nLfvjB4hRz8Cv1Y=; b=SLxOPTJDtC3c7LfUo1AcgFHLJLpMjXLQUptfsVcW3HBlJ8+y4fc+eT6XmfmhYY0isrrbFq TZJpV51QsD0kcBTYEZ+mCEuZ/v29jbNztc58CTfkjNFtnP/AQzzHavAWOAfmFr7KUVTgA3 pqQ9LTzPRRHEYbWnGMxIptUcY2WL2O63t1yVwQ22Ktwj+KmBmZNULHQwyTidYOu27knilY Yce+cFruuDCSRY80ep48abU+ZZEuceb82GkdH6Q9PcyR0TnxRAUfMnp6vag4dy/ytmlR2K mD2AWES6l1QFDLJig7/mFibHMdBgWJvxi2EmPx8ITaafHM05p5K8NqxN/xyISA== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 21 Dec 2025 15:01:11 +0100 Message-Id: Cc: , "Diederik de Haas" , "Dragan Simic" , Subject: Re: [PATCH v3] extcon: Fixed sysfs duplicate filename issue X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Diederik de Haas" To: "Michael Wu" , , , References: <20251024024946.16618-1-michael@allwinnertech.com> In-Reply-To: <20251024024946.16618-1-michael@allwinnertech.com> X-Migadu-Flow: FLOW_OUT 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 rockchi= p-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 ``=3Dm`` 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 > Reviewed-by: Andy Shevchenko > Signed-off-by: Michael Wu > --- > 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@allwinnert= ech.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 *ede= v) > return; > } > =20 > - ida_free(&extcon_dev_ids, edev->id); > - > device_unregister(&edev->dev); > =20 > + ida_free(&extcon_dev_ids, edev->id); > + > if (edev->mutually_exclusive && edev->max_supported) { > for (index =3D 0; edev->mutually_exclusive[index]; > index++)