Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2401027imu; Fri, 23 Nov 2018 08:39:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/WyDALWwrtM5sBxzkCE2rlWLBa5p/p1CzMDqwaCxqJEO84h9KH+khElkhgBbR7dqc0X+9se X-Received: by 2002:a62:4e83:: with SMTP id c125mr14851151pfb.101.1542991154252; Fri, 23 Nov 2018 08:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542991154; cv=none; d=google.com; s=arc-20160816; b=02PUftsCGDWbACFKLT2jba9+P7W+JUpJZaAktX+YrvR6K3A4a//lbf+FrrVDFQV1lT 1orqIwJBP5j3gAtCRfLkUkudn6NtDBUR/oZ0pVCgf5DxdNQFnfaiJxlgOPLltEAQz7mz 0G+GJNgieaCdrxDha6Dc7HM4SgiGg6OGR0M70Gu9Jc5tDns4V4hzYShChkuKFV9EpPI2 pniZzXJ3rsBU/rCbIk6hl0D8FnAslzRNUbHOwUiZQsSJ3Ff1C0xMi4ZKSsvJxXA0fi32 ybX5cBgMAXlVaJMBT0aEalhkKFaMXNzC6PaxJ7XHuMcW+MJvpIaAER731bkDhAk9mK0e 8yBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=RabmvaY7q3BTR0hbs4xHPdXftZ+33yfRmKwiOETw5FE=; b=SmvO3i3z9qBSs2K59y4S9QupYJuo9acSzxlbvyYRxY+Jcei5FKZVEXLZt/MW70cOES 2tsbq+/10qGJwpSSMLcUDyE40xRaLDnSwFmdnD10yCTIA9frCG+3njrKikiPN7GzVS9B m6FOu2p0MaNHcwScxAgnJN76j5alx9NuZ5SVmRY43NZfUf4Wk5OfzHqqr6IT1LxsXZjj 4TsvIqQQu/Dk3Z65PXdBCd6BiHIKLSDV77sEbPq3F7pyCWIoNPZv0+OZEGQP3lIMGrpX yf/e8qhT+qs353EbZy+6B3t5nMcmZvsDPjvZIysB1XNsQJdWdTRQssXVc+souU23ILbR 3gSA== ARC-Authentication-Results: i=1; mx.google.com; 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 i66-v6si58178366pfc.173.2018.11.23.08.38.56; Fri, 23 Nov 2018 08:39:14 -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; 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 S2395223AbeKVXxd (ORCPT + 99 others); Thu, 22 Nov 2018 18:53:33 -0500 Received: from mail.bootlin.com ([62.4.15.54]:55537 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391278AbeKVXxc (ORCPT ); Thu, 22 Nov 2018 18:53:32 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 02B5220DBE; Thu, 22 Nov 2018 14:14:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id B608B20741; Thu, 22 Nov 2018 14:14:03 +0100 (CET) From: Quentin Schulz To: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com Cc: allan.nielsen@microchip.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com, Quentin Schulz Subject: [PATCH net] net: phy: mscc: fix deadlock in vsc85xx_default_config Date: Thu, 22 Nov 2018 14:12:32 +0100 Message-Id: <20181122131232.32032-1-quentin.schulz@bootlin.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 so __phy_write and __phy_read (which assume that you already have the MDIO bus lock unlike phy_write and phy_read) should be used for any call in between the two said functions. Let's fix this deadlock. Fixes: 6a0bfbbe20b0 ("net: phy: mscc: migrate to phy_select/restore_page functions") Signed-off-by: Quentin Schulz --- drivers/net/phy/mscc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index 62269e578718..6856fe4d1a60 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -814,10 +814,10 @@ static int vsc85xx_default_config(struct phy_device *phydev) if (rc < 0) goto out_unlock; - reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL); + 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); + __phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val); out_unlock: rc = phy_restore_page(phydev, rc, rc > 0 ? 0 : rc); -- 2.17.1