From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9436E4418CD for ; Tue, 20 Jan 2026 18:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768934170; cv=none; b=QfKpP3wAfTe6YWnQKR4mOpGQJx+sW4Aq3YlOW3et3tWJW6my9OGXIDLaQe8gJLEoHIbcbGiscH7MmwrL0yFOMAncSJAoxfcWu3ATZUIIMsffPMqIe7YI1h/p7jVEgGA4Se9BZfHQ5zvNIDEqomc3e8I0Cl3Zs2l+2FAi0F5X/n0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768934170; c=relaxed/simple; bh=5WEiL+pMeM0RxtZ/c0/L7oc/p1NckqG8nhfT92FgRuM=; h=Mime-Version:Content-Type:Date:Message-Id:From:Subject:Cc:To: References:In-Reply-To; b=Fy5vQP7ULS3+5rWfyWSR8FL+BHGX5EuLHO6IdZlbY2t2LlafmJ/xx9XWqyiK3ofRuCD4xAVeuf6SW6Lh63nLWBaJ6W+WgBrcbwj6zITbMQKYDFjZqpjY2rEH4mQjx+KvpEeRAR0awI3PCUkGRQkG6RFLl6fMfqEAYez2fS4gs3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ue7OfQ1f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ue7OfQ1f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36088C16AAE; Tue, 20 Jan 2026 18:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768934169; bh=5WEiL+pMeM0RxtZ/c0/L7oc/p1NckqG8nhfT92FgRuM=; h=Date:From:Subject:Cc:To:References:In-Reply-To:From; b=ue7OfQ1fxYFwy062/o34cf2jMOkgOP9Jp/riNCond8V3/HZDq6eaHtzAflloSu6pV v+cxBU1vyPzPhKCsd6RfpfjVOhkVyKHmqCNolY0J9VYZDlFv4VFy6v6qbcJQpy23Z7 bpQs0NmG1CDI3HFt6pvPt7nuFwkhAYDH5qxnRh3h1Pn3L3ud5ROxgKTO7LUogv4o0e PKrAMvZFgum2LkHDntXE/iijUbVpbN47VdMvD4ToFA0XdDogK4I02b7Dav0pwe23un cK1LbO89sdBtVcPRCmy/xgjbVQJFXXJnRk6hwynv+dDfOS/TkDx41J1RJtV/RmnxLu x0Bb9VKBKKrRA== 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 Content-Type: text/plain; charset=UTF-8 Date: Tue, 20 Jan 2026 19:36:05 +0100 Message-Id: From: "Danilo Krummrich" Subject: Re: [PATCH v5] driver core: enforce device_lock for driver_match_device() Cc: "Gui-Dong Han" , , , , , "Qiu-ji Chen" , , "Marek Szyprowski" To: "Mark Brown" References: <20260113162843.12712-1-hanguidong02@gmail.com> <7ae38e31-ef31-43ad-9106-7c76ea0e8596@sirena.org.uk> <4ec6cf46-990e-489c-836e-49124034b67f@sirena.org.uk> In-Reply-To: <4ec6cf46-990e-489c-836e-49124034b67f@sirena.org.uk> On Tue Jan 20, 2026 at 6:38 PM CET, Mark Brown wrote: > On Tue, Jan 20, 2026 at 04:03:03PM +0100, Danilo Krummrich wrote: > >> I don't have a machine to reproduce it, but for debugging it would proba= bly help >> to not actually take the lock in __driver_attach(), but only acquire / r= elease >> the corresponding lockdep map. If my suspicion is correct, we should see= a >> lockdep splat pointing out the issue. > > I tried lockdep but didn't see anything different. Instrumenting with > printk() tells me it's deadlocking trying to attach arm-smmu on Juno > (that's a v1 SMMU on this platform), I'll try to poke further but it'll > likely be tomorrow at the earliest. Maybe the following diff faking the lock for lockdep helps, as it should ke= ep things running, i.e. with this we have the exact same semantics as if we'd revert the patch (except for the lockdep check of course). diff --git a/drivers/base/base.h b/drivers/base/base.h index 677320881af1..4741412d7e46 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -190,8 +190,13 @@ static inline int driver_match_device(const struct dev= ice_driver *drv, static inline int driver_match_device_locked(const struct device_driver *d= rv, struct device *dev) { - guard(device)(dev); - return driver_match_device(drv, dev); + int ret; + + mutex_acquire(&dev->mutex.dep_map, 0, 0, _THIS_IP_); + ret =3D driver_match_device(drv, dev); + mutex_release(&dev->mutex.dep_map, _THIS_IP_); + + return ret; } static inline void dev_sync_state(struct device *dev)