From patchwork Thu Nov 21 19:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 1199108 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47Jq5z50tDz9sPc for ; Fri, 22 Nov 2019 06:15:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbfKUTPu (ORCPT ); Thu, 21 Nov 2019 14:15:50 -0500 Received: from inva021.nxp.com ([92.121.34.21]:59726 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbfKUTPu (ORCPT ); Thu, 21 Nov 2019 14:15:50 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 58C4D20062C; Thu, 21 Nov 2019 20:15:48 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 499FC20062B; Thu, 21 Nov 2019 20:15:48 +0100 (CET) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 13FFF203C8; Thu, 21 Nov 2019 20:15:48 +0100 (CET) From: Ioana Ciornei To: davem@davemloft.net, netdev@vger.kernel.org Cc: linux@armlinux.org.uk, andrew@lunn.ch, Ioana Ciornei Subject: [PATCH net-next 1/3] dpaa2-eth: do not hold rtnl_lock on phylink_create() or _destroy() Date: Thu, 21 Nov 2019 21:15:25 +0200 Message-Id: <1574363727-5437-2-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> References: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The rtnl_lock should not be held when calling phylink_create() or phylink_destroy() since it leads to the deadlock listed below: [ 18.656576] rtnl_lock+0x18/0x20 [ 18.659798] sfp_bus_add_upstream+0x28/0x90 [ 18.663974] phylink_create+0x2cc/0x828 [ 18.667803] dpaa2_mac_connect+0x14c/0x2a8 [ 18.671890] dpaa2_eth_connect_mac+0x94/0xd8 Fix this by moving the _lock() and _unlock() calls just outside of phylink_of_phy_connect() and phylink_disconnect_phy(). Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink") Reported-by: Russell King Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ---- drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 7ff147e89426..40290fea9e36 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -3431,12 +3431,10 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg) set_mac_addr(netdev_priv(net_dev)); update_tx_fqids(priv); - rtnl_lock(); if (priv->mac) dpaa2_eth_disconnect_mac(priv); else dpaa2_eth_connect_mac(priv); - rtnl_unlock(); } return IRQ_HANDLED; @@ -3675,9 +3673,7 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) #ifdef CONFIG_DEBUG_FS dpaa2_dbg_remove(priv); #endif - rtnl_lock(); dpaa2_eth_disconnect_mac(priv); - rtnl_unlock(); unregister_netdev(net_dev); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 84233e467ed1..0200308d1bc7 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -277,7 +277,9 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) } mac->phylink = phylink; + rtnl_lock(); err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); + rtnl_unlock(); if (err) { netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err); goto err_phylink_destroy; @@ -301,7 +303,9 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac) if (!mac->phylink) return; + rtnl_lock(); phylink_disconnect_phy(mac->phylink); + rtnl_unlock(); phylink_destroy(mac->phylink); dpmac_close(mac->mc_io, 0, mac->mc_dev->mc_handle); } From patchwork Thu Nov 21 19:15:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 1199109 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47Jq622NQVz9sPV for ; Fri, 22 Nov 2019 06:15:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfKUTPx (ORCPT ); Thu, 21 Nov 2019 14:15:53 -0500 Received: from inva021.nxp.com ([92.121.34.21]:59772 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbfKUTPx (ORCPT ); Thu, 21 Nov 2019 14:15:53 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 31F2320062F; Thu, 21 Nov 2019 20:15:51 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 25D8B200626; Thu, 21 Nov 2019 20:15:51 +0100 (CET) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id D160420413; Thu, 21 Nov 2019 20:15:50 +0100 (CET) From: Ioana Ciornei To: davem@davemloft.net, netdev@vger.kernel.org Cc: linux@armlinux.org.uk, andrew@lunn.ch, Ioana Ciornei Subject: [PATCH net-next 2/3] dpaa2-eth: add phylink_mac_ops stub callbacks Date: Thu, 21 Nov 2019 21:15:26 +0200 Message-Id: <1574363727-5437-3-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> References: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For the moment, we do not have a way to query the PCS link state or to restart aneg on it. Add stub functions for both of the callbacks since phylink can provoke an oops when an SFP module has been inserted. Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink") Reported-by: Russell King Signed-off-by: Ioana Ciornei Acked-by: Russell King --- drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 0200308d1bc7..efc587515661 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -183,11 +183,24 @@ static void dpaa2_mac_link_down(struct phylink_config *config, netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err); } +static void dpaa2_mac_an_restart(struct phylink_config *config) +{ + /* Not supported */ +} + +static void dpaa2_mac_pcs_get_state(struct phylink_config *config, + struct phylink_link_state *state) +{ + /* Not supported */ +} + static const struct phylink_mac_ops dpaa2_mac_phylink_ops = { .validate = dpaa2_mac_validate, .mac_config = dpaa2_mac_config, .mac_link_up = dpaa2_mac_link_up, .mac_link_down = dpaa2_mac_link_down, + .mac_an_restart = dpaa2_mac_an_restart, + .mac_pcs_get_state = dpaa2_mac_pcs_get_state, }; bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev, From patchwork Thu Nov 21 19:15:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 1199110 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47Jq6368XDz9sPT for ; Fri, 22 Nov 2019 06:15:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbfKUTPz (ORCPT ); Thu, 21 Nov 2019 14:15:55 -0500 Received: from inva020.nxp.com ([92.121.34.13]:43656 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbfKUTPx (ORCPT ); Thu, 21 Nov 2019 14:15:53 -0500 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 6F89B1A0654; Thu, 21 Nov 2019 20:15:52 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 63B3E1A0354; Thu, 21 Nov 2019 20:15:52 +0100 (CET) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 1DBA3203CE; Thu, 21 Nov 2019 20:15:52 +0100 (CET) From: Ioana Ciornei To: davem@davemloft.net, netdev@vger.kernel.org Cc: linux@armlinux.org.uk, andrew@lunn.ch, Ioana Ciornei Subject: [PATCH net-next 3/3] dpaa2-eth: return all supported link modes in PHY_INTERFACE_MODE_NA Date: Thu, 21 Nov 2019 21:15:27 +0200 Message-Id: <1574363727-5437-4-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> References: <1574363727-5437-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The include/linux/phylink.h states: * When @state->interface is %PHY_INTERFACE_MODE_NA, phylink expects * MAC driver to return all supported link modes. Make the necessary adjustment to meet the requirements. Signed-off-by: Ioana Ciornei Acked-by: Russell King --- drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index efc587515661..d93d71724e5a 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -95,6 +95,7 @@ static void dpaa2_mac_validate(struct phylink_config *config, phylink_set(mask, Asym_Pause); switch (state->interface) { + case PHY_INTERFACE_MODE_NA: case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_RXID: