From patchwork Mon Sep 14 10:42:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 517350 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0BE8B14076E for ; Mon, 14 Sep 2015 20:43:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=arm.linux.org.uk header.i=@arm.linux.org.uk header.b=Xt4EBD16; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755430AbbINKnE (ORCPT ); Mon, 14 Sep 2015 06:43:04 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:47283 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755409AbbINKnA (ORCPT ); Mon, 14 Sep 2015 06:43:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date; bh=UI9eb7bXNV5e8wy3AVbsL+8PerECQffSu3YzXkxmKS0=; b=Xt4EBD161IUDnkK7GFK8JJgCZsW+KcxFAwhKxopQKRyvFaBKARgK/qOLNPZ56GHfNYqgvmgh5pGezBRjfMP5Mh8OWpf4Imj1wu1OJrRFSwG2A2PEPpPEy1JUPzlTUczm52vpWapbwDZNk9Q2Vx2dxNy9IIobFg8C6HUfDuSn0lQ=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:35052) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ZbRDt-0002lO-TR; Mon, 14 Sep 2015 11:42:58 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1ZbRDq-0004yW-RH; Mon, 14 Sep 2015 11:42:54 +0100 Date: Mon, 14 Sep 2015 11:42:54 +0100 From: Russell King - ARM Linux To: Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: DSA: phy polling Message-ID: <20150914104254.GI21084@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Andrew, I think you're the current maintainer of the Marvell DSA code, as being the most recent author of changes to it. :) I've noticed in my testing that the Marvell DSA code seems to poll the internal phy link status in mv88e6xxx_poll_link(), and set the network device carrier status according to the results. However, the internal phys are created using phylib, which also polls the phys for their link status, and controls the associated netdev carrier status. The side effect of this is that I see duplicated link status messages in the kernel log when connecting or disconnecting cables from the switch, caused by the code in mv88e6xxx_poll_link() racing with the phylib code. From what I can see, the code in mv88e6xxx_poll_link() is entirely redundant as the phylib layer will take care of any phy attached to the switch. To prove this, I have the following code in my tree, which disables the polling on a port where we have a phy attached (either an internal or external phy). The result is that the per-port network devices are still updated with the link status even though this code is disabled - thanks to the phylib polling. I'm left wondering whether the DSA specific phy polling does anything useful, or whether the entire polling code both in mv88e6xxx.c and net/dsa can be removed (mv88e6xxx.c seems to be its only user.) diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 26ec2fbfaa89..4c324eafeef2 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c @@ -400,6 +400,13 @@ void mv88e6xxx_poll_link(struct dsa_switch *ds) if (dev == NULL) continue; + /* + * Ignore ports which have a phy; phylib will take care + * of polling the link status for these. + */ + if (dsa_slave_has_phy(dev)) + continue; + link = 0; if (dev->flags & IFF_UP) { port_status = mv88e6xxx_reg_read(ds, REG_PORT(i), diff --git a/include/net/dsa.h b/include/net/dsa.h index fbca63ba8f73..b31e9da43ea7 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -176,6 +176,8 @@ static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p) return ds->phys_port_mask & (1 << p) && ds->ports[p]; } +extern bool dsa_slave_has_phy(struct net_device *); + static inline u8 dsa_upstream_port(struct dsa_switch *ds) { struct dsa_switch_tree *dst = ds->dst; diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 35c47ddd04f0..a107242816ff 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -873,6 +874,14 @@ int dsa_slave_resume(struct net_device *slave_dev) return 0; } +bool dsa_slave_has_phy(struct net_device *slave_dev) +{ + struct dsa_slave_priv *p = netdev_priv(slave_dev); + + return p->phy != NULL; +} +EXPORT_SYMBOL_GPL(dsa_slave_has_phy); + int dsa_slave_create(struct dsa_switch *ds, struct device *parent, int port, char *name) {