Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3232310imu; Sat, 24 Nov 2018 00:40:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/UG5z6MY2GT/awmMuPZ0re51y+ddqLQXL0xSVrkaG3b15nnFapeuYKBLojnPsr5rL6dWClW X-Received: by 2002:a17:902:6b87:: with SMTP id p7-v6mr19359017plk.282.1543048850361; Sat, 24 Nov 2018 00:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048850; cv=none; d=google.com; s=arc-20160816; b=etfZ2p+cIwj1smRmL3mKCqNcxJKZmLYTk6+4VTV42q2lyIju9DnRtJRNJt3TLzWAln OjnnUqc9k+Wg3KU8sTWHyuCfstyJ65DU3hmIOzVkLd8sjSaG1KSWjBKpH2OzriP6PwzP DV3QrWZhu9bkmM4tZw0BfD0F3qANqnB8pERn1//wwnaOCgwH57Nl671jc7X4LFIF08cy 8CA1hnVK3W0G4vW7WhKarlABw0tlo9xE6r7mGcS61rr0tZbAWhF2yHU/JtpH0W8gWidg NBd3N28ls2AkGmzsp3N1kI6hp0IpUPUKNOeQjdX3pGkV4FzWUbcwvgXxwnQRiBipSDMe ju+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+g2W/obI3cWbottSoUi5ycyOnVZOBTkOEsXK/8dB/vk=; b=yK0jDBmqgOFFWlq35rahr/A8rjxImxyXh2cUyqq/7xyStCqgXQr766QB4i9us85Yr7 aPF1Y8o3ogGBbpHJLhOQ1Ao0f6El5cxqJhnDk3i262jqm3bjMlfnugrDv1jCa5VKOB6X KUQ0AB40l8z5JYJXShDUjaCUrK4wBNMSD5UhCPJ5E1OiYWod0ds4sYPGn0pg1d4tXqRF CejGY2QiR0Xf0ACdl2Cbxk8E1kKpaBWQvytVKcdUVzasDN9lpH6cr4D/7Iguhq2wl22t Bi0C9e5M7bVuyh2SR28wYC294C7QQ83JVRFAN4xBmPCaws0bPr62e9+1egsdYJqlnOfb F+iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=23VDG7MR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w31si9768929pla.308.2018.11.24.00.40.36; Sat, 24 Nov 2018 00:40:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=23VDG7MR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504806AbeKXBwp (ORCPT + 99 others); Fri, 23 Nov 2018 20:52:45 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:47014 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504792AbeKXBwo (ORCPT ); Fri, 23 Nov 2018 20:52:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=+g2W/obI3cWbottSoUi5ycyOnVZOBTkOEsXK/8dB/vk=; b=23VDG7MRE+bBBThhLbaWS5TlCtZ0p/Pa+BhoEMUDgJcv8tO9o8slbINt/KkqpeKogaEb1XLgD+7WPaDP1dQa6IiZImfDT3aKD9EpqRYbwKHVtNHRAhnroK+SHqmAfgRaJSyuD0lPQAhcaL5KGK0OGYNqyEI1eGEsXHkjG1qOWCs=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1gQD3u-00089i-MK; Fri, 23 Nov 2018 16:08:06 +0100 Date: Fri, 23 Nov 2018 16:08:06 +0100 From: Andrew Lunn To: Quentin Schulz Cc: davem@davemloft.net, f.fainelli@gmail.com, allan.nielsen@microchip.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com Subject: Re: [PATCH net v2] net: phy: mscc: fix deadlock in vsc85xx_default_config Message-ID: <20181123150806.GB30913@lunn.ch> References: <20181123081636.18795-1-quentin.schulz@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181123081636.18795-1-quentin.schulz@bootlin.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 23, 2018 at 09:16:36AM +0100, Quentin Schulz wrote: > The vsc85xx_default_config function called in the vsc85xx_config_init > function which is used by VSC8530, VSC8531, VSC8540 and VSC8541 PHYs > mistakenly calls phy_read and phy_write in-between phy_select_page and > phy_restore_page. > > phy_select_page and phy_restore_page actually take and release the MDIO > bus lock and phy_write and phy_read take and release the lock to write > or read to a PHY register. > > Let's fix this deadlock by using phy_modify_paged which handles > correctly a read followed by a write in a non-standard page. > > Fixes: 6a0bfbbe20b0 ("net: phy: mscc: migrate to phy_select/restore_page functions") > > Signed-off-by: Quentin Schulz > --- > > v2: > - use phy_modify_paged instead of > phy_select_page -> __phy_read -> __phy_write -> phy_restore_page > > drivers/net/phy/mscc.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c > index 62269e578718..4dcf7ad06259 100644 > --- a/drivers/net/phy/mscc.c > +++ b/drivers/net/phy/mscc.c > @@ -810,17 +810,16 @@ static int vsc85xx_default_config(struct phy_device *phydev) > > phydev->mdix_ctrl = ETH_TP_MDI_AUTO; > mutex_lock(&phydev->lock); > - rc = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED_2); > + > + reg_val = RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS; > + > + rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, > + MSCC_PHY_RGMII_CNTL, RGMII_RX_CLK_DELAY_MASK, > + reg_val); > if (rc < 0) > goto out_unlock; Hi Quentin Isn't this goto now pointless. You are not jumping over anything. Andrew > > - reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL); > - reg_val &= ~(RGMII_RX_CLK_DELAY_MASK); > - reg_val |= (RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS); > - phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val); > - > out_unlock: > - rc = phy_restore_page(phydev, rc, rc > 0 ? 0 : rc); > mutex_unlock(&phydev->lock); > > return rc; > -- > 2.17.1 >