Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1769738imm; Thu, 27 Sep 2018 02:09:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ymllgsrz5zgwWqnabA8WzdMgmlylGd8PwDDGgG6qZDQn4HSJg1usbHrnAET0zGWPoYkX0 X-Received: by 2002:a62:9cd7:: with SMTP id u84-v6mr10466179pfk.90.1538039343174; Thu, 27 Sep 2018 02:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039343; cv=none; d=google.com; s=arc-20160816; b=IShyA4TpWQACfyZznZzYku1+gXTUjt63C0TLBNu4R9WSKvbsJbgBB0V4VZoLTprhhK iOh7/32D08Kb2DVemoqEW2310BILdeJ0fw3As58xprUhM2IMXKzNRnYT1r0aXBa4WFA0 9lk4AsWgHny2V4sG904JJ0GiToY8aZ9/UF+qx69RSaioHoYCNZ0OkbsDeilGhdaq/KpH t+eKQSsEkPwqKoQHF62FrCQnRWj5ysBcCEjiC/N+Cc5d5PQrJlRw8O0Pvjgp4IaoYQqL wy4f2N/AuHip9oFlu1rDNfwFXbhsdSGvZQ4rdnTkl1r6v/LBxVlbQAXiAQATHS0PQLEO YZ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=PlIuUKOP3Su7ctJEUzRA6uLZR1+MLEglDn38mqTE1OU=; b=EwxwQgWjQa130f+s9JqhTCOnKupoVzdukhe3EgSvWEy6M6pFeZ9tNDdH7/ZLvrvrCj UQExDImDtrkxzbxngk9igMJDEWeXSXc6rzZK1C4DWrOhVdTe5Sl8kV4tdX9REYvj3nkY dJfzaK8a//4UNT/ezFyUmGlvdZ3D39gMY7KASafJZXayBxBNhHYF0Pb1fWa5P2+dtBLr VDsxY7/QpCKq6ZVvBvhOPJcKFwWAi7tnUoTG7OkKbCHUjaJPObBywNRQDoaqBHSep1Sj ZXxhNHj+GNWSMHfZ/JrV/iSm6jGiobKk7CY1h7H32YPjCEHr0vUJyVXnIX8T/sei8P0E QpMA== 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 p24-v6si1509703plr.510.2018.09.27.02.08.48; Thu, 27 Sep 2018 02:09:03 -0700 (PDT) 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 S1727786AbeI0PZZ (ORCPT + 99 others); Thu, 27 Sep 2018 11:25:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbeI0PZZ (ORCPT ); Thu, 27 Sep 2018 11:25:25 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E5A6310A4; Thu, 27 Sep 2018 09:08:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King , Antoine Tenart , "David S. Miller" Subject: [PATCH 4.18 21/88] net: mvpp2: let phylink manage the carrier state Date: Thu, 27 Sep 2018 11:03:02 +0200 Message-Id: <20180927090303.089120453@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antoine Tenart [ Upstream commit 41948ccb4a856dddacfbd4d789d4fa8663fe41bb ] Net drivers using phylink shouldn't mess with the link carrier themselves and should let phylink manage it. The mvpp2 driver wasn't following this best practice as the mac_config() function made calls to change the link carrier state. This led to wrongly reported carrier link state which then triggered other issues. This patch fixes this behaviour. But the PPv2 driver relied on this misbehaviour in two cases: for fixed links and when not using phylink (ACPI mode). The later was fixed by adding an explicit call to link_up(), which when the ACPI mode will use phylink should be removed. The fixed link case was relying on the mac_config() function to set the link up, as we found an issue in phylink_start() which assumes the carrier is off. If not, the link_up() function is never called. To fix this, a call to netif_carrier_off() is added just before phylink_start() so that we do not introduce a regression in the driver. Fixes: 4bb043262878 ("net: mvpp2: phylink support") Reported-by: Russell King Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -61,6 +61,8 @@ static struct { */ static void mvpp2_mac_config(struct net_device *dev, unsigned int mode, const struct phylink_link_state *state); +static void mvpp2_mac_link_up(struct net_device *dev, unsigned int mode, + phy_interface_t interface, struct phy_device *phy); /* Queue modes */ #define MVPP2_QDIST_SINGLE_MODE 0 @@ -3142,6 +3144,7 @@ static void mvpp2_start_dev(struct mvpp2 mvpp22_mode_reconfigure(port); if (port->phylink) { + netif_carrier_off(port->dev); phylink_start(port->phylink); } else { /* Phylink isn't used as of now for ACPI, so the MAC has to be @@ -3150,9 +3153,10 @@ static void mvpp2_start_dev(struct mvpp2 */ struct phylink_link_state state = { .interface = port->phy_interface, - .link = 1, }; mvpp2_mac_config(port->dev, MLO_AN_INBAND, &state); + mvpp2_mac_link_up(port->dev, MLO_AN_INBAND, port->phy_interface, + NULL); } netif_tx_start_all_queues(port->dev); @@ -4389,10 +4393,6 @@ static void mvpp2_mac_config(struct net_ return; } - netif_tx_stop_all_queues(port->dev); - if (!port->has_phy) - netif_carrier_off(port->dev); - /* Make sure the port is disabled when reconfiguring the mode */ mvpp2_port_disable(port); @@ -4417,16 +4417,7 @@ static void mvpp2_mac_config(struct net_ if (port->priv->hw_version == MVPP21 && port->flags & MVPP2_F_LOOPBACK) mvpp2_port_loopback_set(port, state); - /* If the port already was up, make sure it's still in the same state */ - if (state->link || !port->has_phy) { - mvpp2_port_enable(port); - - mvpp2_egress_enable(port); - mvpp2_ingress_enable(port); - if (!port->has_phy) - netif_carrier_on(dev); - netif_tx_wake_all_queues(dev); - } + mvpp2_port_enable(port); } static void mvpp2_mac_link_up(struct net_device *dev, unsigned int mode,