Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp354212pxb; Thu, 17 Feb 2022 05:43:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCIe36ye7RfFxgkkQ9gkFzjxapBPZJW3Uo+JWHrQxIcAFxqxMgP2tv6qyTzXyC4kzqXu8E X-Received: by 2002:a50:934b:0:b0:410:befb:cfd0 with SMTP id n11-20020a50934b000000b00410befbcfd0mr2603798eda.27.1645105387158; Thu, 17 Feb 2022 05:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645105387; cv=none; d=google.com; s=arc-20160816; b=U/wyvGdDP2KW2LT1vXU1OE+SUoRT7W7khHmnDq5yFiTB+u1cXert1d8lg5qRljd2aq LagX8/gd1yOxIHEpZ79Qp9KsCXUyCAJlKLewCQUM5wUfVVI+PJCXnfFSqNACHX/+E/Ws w6zJPPr4cepOXIwOO2HrIeXHFiwnGYZ0zFCdQ9FMVl+Rm+UQOqCfrYrHT128cCFGDGl9 2r+K7MEDp90qzxgWMfqjLQGVLYlatRjTxcui4kLWvWtWAliTFj/FNLe6lrXA0pRfeK4Y DjNH69gvvNk5gGUtfdRiP/RKGv5qEcCLevD0HXByNNmKA/4gtux3++02v3cN4l0vu993 YHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1KoWgBTUlo4nDLAUw7bf+UHEGG4Wj8YcA8JBHAxpzdA=; b=jGIGRaHvjuwRfag/NlatJGEdlOkZbAHALCDj0f6ha4XoS+dQUvoa0R8/g5r9y3pv5V 1f97W1audQSwBlvteumYYQ390A4l+xrDy9ZfQ14bG8efLdku6U86yWXFQPu7X2B3zQNj g2FkKfopWkgYm4C0SxGTqU3d+Gg54PgNH4G4WKfZaj6h+J7vfujRM9YUbYuerzKfp246 rF0EA9e30U6Z1yt1k6ylvmfsbr2BMF8PCqRZ3b66ReGSQ68PofRRiEjCCMgqd8LgNtRb i5hbjD9aBMPRaPqD2qs9iEJ84QohRDXRVVefxFxk0B7mRoNYO+dpPQ3enoLMsedoZPFA d6sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=vU16ZIZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1si1761786edd.119.2022.02.17.05.42.43; Thu, 17 Feb 2022 05:43:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=vU16ZIZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240314AbiBQMMy (ORCPT + 99 others); Thu, 17 Feb 2022 07:12:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239451AbiBQMMx (ORCPT ); Thu, 17 Feb 2022 07:12:53 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9CF1FA55; Thu, 17 Feb 2022 04:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=1KoWgBTUlo4nDLAUw7bf+UHEGG4Wj8YcA8JBHAxpzdA=; b=vU16ZIZEOKIv+Zy5HMk99Fl4NW m+Tihn9pusbecPWEJNsvCw0qXEMoe4znQwja8zPLQkV35QkKql5Jb0kW+jVXuGLDMH+Ga6LGxTVtk mOxEeJbyg3yAAZxIuCfntdxO7ZPWb/f4yYfiOiPQ9AOgimfSYYXtnE0En4rmJzjUBxJQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nKfdz-006ML2-GY; Thu, 17 Feb 2022 13:12:19 +0100 Date: Thu, 17 Feb 2022 13:12:19 +0100 From: Andrew Lunn To: Alvin =?utf-8?Q?=C5=A0ipraga?= Cc: Luiz Angelo Daros de Luca , Alvin =?utf-8?Q?=C5=A0ipraga?= , Linus Walleij , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Michael Rasmussen , =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , "open list:NETWORKING DRIVERS" , open list Subject: Re: [PATCH net-next 0/2] net: dsa: realtek: fix PHY register read corruption Message-ID: References: <20220216160500.2341255-1-alvin@pqrs.dk> <87k0dusmar.fsf@bang-olufsen.dk> <878ruasjd8.fsf@bang-olufsen.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878ruasjd8.fsf@bang-olufsen.dk> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Thank you Andrew for the clear explanation. > > Somewhat unrelated to this series, but are you able to explain to me the > difference between: > > mutex_lock(&bus->mdio_lock); > and > mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED); > > While looking at other driver examples I noticed the latter form quite a > few times too. This is to do with the debug code for checking for deadlocks, CONFIG_PROVE_LOCKING. When that feature is enables, each lock/unlock of a mutex is tracked, and a list is made of what other locks are also taken, and the order. The code can find deadlocks where one thread takes A then B, while another thread takes B and then A. It can also detect when a thread takes lock A and then tries to take lock A again. Rather than track each individual mutex, it uses classes of mutex. So bus->mdio_lock is a class of mutex. The code simply tracks that a bus->mdio_lock has been taken, not a specific bus->mdio_lock. That is generally sufficient, but not always. The mv88e6xxx switch is like many switches, accessed over MDIO. But the mv88e6xxx switch offers an MDIO bus, and there is an MDIO bus driver inside the mv88e6xxx driver. So you have nested MDIO calls. So this debug code seems the same class of mutex being taken twice, and thinks it is a deadlock. You can tell it that nested MDIO calls are actually O.K, it won't deadlock. Andrew