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: 7174501 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DE72DBEEC1 for ; Mon, 14 Sep 2015 10:45:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53D2820653 for ; Mon, 14 Sep 2015 10:45:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCE0820641 for ; Mon, 14 Sep 2015 10:45:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbREN-0000DG-BU; Mon, 14 Sep 2015 10:43:27 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbREK-0008DM-6A for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2015 10:43:25 +0000 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150914_034324_562041_8B29AC42 X-CRM114-Status: GOOD ( 18.98 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {