From nobody Sat Jun 20 20:54:50 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 AC88529E0F6 for ; Fri, 10 Apr 2026 02:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775789456; cv=none; b=QXdSjqhiip6OW67WQU9qrib7mnWQl7jrGUzI90TIetO4aXmODDk4ODXVHiOB9xKCTCRYT92nr8/ChQis1lLl1E48HgmhCkmnLDhxvIH0NWey1fbZCIVq3DKsKl618b3AI2O22Nm7MhZVPhAlDn3Md11pebyCtx2MaZ3HrPigS78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775789456; c=relaxed/simple; bh=gW62Z8S9ZpS6C9UgMTqchoDnBrwS/8LylqWYZyey1xQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=hpTgMS/kW5J+d+vF2ZH03Y9YXmgJEkKW4cgial87Di5ovt8C5KqZcggar6c2NwOj8o9nE6Doa/CIBaisFrM6HWn33Zg75e4LKJ/+yYkVLwtliKsH5tPkCQezO3HP+G1Dp/Caw1xDdccn1O/Yc51SErLkkvvCZDUQzJfGo4Pf1EU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=iEAqqQym; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="iEAqqQym" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=9ApgijfyA6M/ECOQv41/b9qCMenebQIJhjVJ0g6T/qE=; b=iEAqqQymmNPuEgwrm2x9Z17laUJUuJCo/IfsHYqEDs3NX1rdaO5lP75GJqoguPF6fK6oGlv72 lEPS0Wep76wIUBRfjl/AgER9hYgNG4F3azaIshohDNwcTyFGpO0GnPtVkCPvHk4lSM9gvhctNTE zeGn/6MPN/axo0/2kx6/VOo= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4fsLjs15mrzmV6X; Fri, 10 Apr 2026 10:44:33 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id BAE0340573; Fri, 10 Apr 2026 10:50:49 +0800 (CST) Received: from kwepemq500014.china.huawei.com (7.202.195.126) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 10 Apr 2026 10:50:49 +0800 Received: from localhost.localdomain (10.50.87.63) by kwepemq500014.china.huawei.com (7.202.195.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 10 Apr 2026 10:50:49 +0800 From: Zhang Yuwei To: Greg Kroah-Hartman , Saravana Kannan , "Rafael J . Wysocki" , Rob Herring , Danilo Krummrich , Mark Brown CC: Subject: [PATCH] driver core: Use mod_delayed_work to prevent lost deferred probe work Date: Fri, 10 Apr 2026 10:44:48 +0800 Message-ID: <20260410024448.387231-1-zhangyuwei20@huawei.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemq500014.china.huawei.com (7.202.195.126) Content-Type: text/plain; charset="utf-8" The deferred_probe_timeout_work may be permanently and unexpectedly canceled when deferred_probe_extend_timeout() executes concurrently. Starting with deferred_probe_timeout_work pending, the problem can occur after the following sequence: CPU0 CPU1 deferred_probe_extend_timeout -> cancel_delayed_work() =3D> true deferred_probe_extend_timeout -> cancel_delayed_work() -> __cancel_work() -> try_grab_pending() -> schedule_delayed_work() -> queue_delayed_work_on() (Since the pending bit is grabbed, it just returns without queuing) -> set_work_pool_and_clear_pending= () (This __cancel_work() returns false and the work will never be queued again) The root cause is that the WORK_STRUCT_PENDING_BIT of the work_struct is set temporarily in __cancel_work() (via try_grab_pending()). This transient state prevents the work_struct from being successfully queued by another CPU. To fix this, replace the original non-atomic cancel and schedule mechanism with mod_delayed_work(). This ensures the modification is handled atomically and guarantees that the work is not lost. Fixes: 2b28a1a84a0e ("driver core: Extend deferred probe timeout on driver = registration") Signed-off-by: Zhang Yuwei --- Link to previous discussion Link:https://lore.kernel.org/all/40fa16cf-950b-4ca7-9935-dbce75e46eb9@huawe= i.com/ drivers/base/dd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 37c7e54e0e4c..fac019f567ae 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -327,12 +327,10 @@ void deferred_probe_extend_timeout(void) * If the work hasn't been queued yet or if the work expired, don't * start a new one. */ - if (cancel_delayed_work(&deferred_probe_timeout_work)) { - schedule_delayed_work(&deferred_probe_timeout_work, - driver_deferred_probe_timeout * HZ); + if (mod_delayed_work(system_wq, &deferred_probe_timeout_work, + driver_deferred_probe_timeout)) pr_debug("Extended deferred probe timeout by %d secs\n", driver_deferred_probe_timeout); - } } =20 /** --=20 2.43.0