From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A069C433EF for ; Mon, 21 Feb 2022 22:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235218AbiBUWJ5 (ORCPT ); Mon, 21 Feb 2022 17:09:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbiBUWJ4 (ORCPT ); Mon, 21 Feb 2022 17:09:56 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D71DDE5A; Mon, 21 Feb 2022 14:09:32 -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-Transfer-Encoding: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=+Yh0NkVUkr1543FXohP7uVf0y3aW8/RHNzP/DPSASDs=; b=nx GaVeSCvASp+apT7hnSFsBAqEmqpn187kng60Y1gjwuOMSbUh6UveF8WeiTV+UdIpNp2wKniVwxjZl 4ZqDbqcoxuPJWSm8yq7tvNDzzzH9SypWARQPaeXHUzGl+q3lkGK9j1F+UEpa+eTJA9AOroHnFpMwE +xiYniW8+FLNSyU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nMGrx-007RMB-4J; Mon, 21 Feb 2022 23:09:21 +0100 Date: Mon, 21 Feb 2022 23:09:21 +0100 From: Andrew Lunn To: Heyi Guo Cc: "David S. Miller" , Jakub Kicinski , Joel Stanley , Benjamin Herrenschmidt , Dylan Hung , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Issue report] drivers/ftgmac100: DHCP occasionally fails during boot up or link down/up Message-ID: References: <0e456c4d-aa22-4e7f-9b2c-3059fe840cb9@linux.alibaba.com> <4964f8c3-8349-4fad-e176-8c26840d1a08@linux.alibaba.com> <1a7e74b4-8827-c14b-7371-9656a643d03c@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1a7e74b4-8827-c14b-7371-9656a643d03c@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > [   16.872475]  Possible unsafe locking scenario: > [   16.872475] > [   16.872478]        CPU0                    CPU1 > [   16.872482]        ----                    ---- > [   16.872485]   lock(&dev->lock); > [   16.872495]                                lock(rtnl_mutex); > [   16.872505] lock(&dev->lock); It looks like the whitespace got messed up here, and it should actually be: > [   16.872505] lock(&dev->lock); > [   16.872513]   lock(rtnl_mutex); So if up calls open() which first takes rtnl and then the phydev->lock. adjust link is called with phydev->lock already held and it then takes the rtnl. Deadlock. During the adjust_list callback, the phydev lock is held so the contents of phydev are consistent. What you could do is make a copy of what you need and then release phydev lock. You can then take rtnl and do the reset. Once the reset is finished, program MAC with the copy you took from phydev. Then lock phydev again, and return. Andrew