From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Russell King <rmk+kernel@armlinux.org.uk>,
Florian Fainelli <f.fainelli@gmail.com>,
privat@egil-hjelmeland.no, andrew@lunn.ch,
vivien.didelot@savoirfairelinux.com, davem@davemloft.net,
sean.wang@mediatek.com, Woojung.Huh@microchip.com,
john@phrozen.org, cphealy@gmail.com
Subject: [PATCH net-next v2 3/9] net: phy: phylink: Poll link GPIOs
Date: Thu, 10 May 2018 13:17:31 -0700 [thread overview]
Message-ID: <20180510201737.13887-4-f.fainelli@gmail.com> (raw)
In-Reply-To: <20180510201737.13887-1-f.fainelli@gmail.com>
From: Russell King <rmk+kernel@armlinux.org.uk>
When using a fixed link with a link GPIO, we need to poll that GPIO to
determine link state changes. This is consistent with what fixed_phy.c does.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 6392b5248cf5..581ce93ecaf9 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -19,6 +19,7 @@
#include <linux/phylink.h>
#include <linux/rtnetlink.h>
#include <linux/spinlock.h>
+#include <linux/timer.h>
#include <linux/workqueue.h>
#include "sfp.h"
@@ -54,6 +55,7 @@ struct phylink {
/* The link configuration settings */
struct phylink_link_state link_config;
struct gpio_desc *link_gpio;
+ struct timer_list link_poll;
void (*get_fixed_state)(struct net_device *dev,
struct phylink_link_state *s);
@@ -500,6 +502,15 @@ static void phylink_run_resolve(struct phylink *pl)
queue_work(system_power_efficient_wq, &pl->resolve);
}
+static void phylink_fixed_poll(struct timer_list *t)
+{
+ struct phylink *pl = container_of(t, struct phylink, link_poll);
+
+ mod_timer(t, jiffies + HZ);
+
+ phylink_run_resolve(pl);
+}
+
static const struct sfp_upstream_ops sfp_phylink_ops;
static int phylink_register_sfp(struct phylink *pl,
@@ -572,6 +583,7 @@ struct phylink *phylink_create(struct net_device *ndev,
pl->link_config.an_enabled = true;
pl->ops = ops;
__set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
+ timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(pl->link_config.advertising, pl->supported);
@@ -905,6 +917,8 @@ void phylink_start(struct phylink *pl)
clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
phylink_run_resolve(pl);
+ if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
+ mod_timer(&pl->link_poll, jiffies + HZ);
if (pl->sfp_bus)
sfp_upstream_start(pl->sfp_bus);
if (pl->phydev)
@@ -929,6 +943,8 @@ void phylink_stop(struct phylink *pl)
phy_stop(pl->phydev);
if (pl->sfp_bus)
sfp_upstream_stop(pl->sfp_bus);
+ if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
+ del_timer_sync(&pl->link_poll);
set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
queue_work(system_power_efficient_wq, &pl->resolve);
--
2.14.1
next prev parent reply other threads:[~2018-05-10 20:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 20:17 [PATCH net-next v2 0/9] net: dsa: Plug in PHYLINK support Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 1/9] net: phy: phylink: Use gpiod_get_value_cansleep() Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 2/9] net: phy: phylink: Release link GPIO Florian Fainelli
2018-05-10 20:17 ` Florian Fainelli [this message]
2018-05-10 20:29 ` [PATCH net-next v2 3/9] net: phy: phylink: Poll link GPIOs Russell King - ARM Linux
2018-05-10 20:32 ` Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 4/9] net: dsa: Add PHYLINK switch operations Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 5/9] net: dsa: bcm_sf2: Implement phylink_mac_ops Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 6/9] net: dsa: Eliminate dsa_slave_get_link() Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 7/9] net: dsa: mv88e6xxx: add PHYLINK support Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 8/9] net: dsa: Plug in " Florian Fainelli
2018-05-10 20:17 ` [PATCH net-next v2 9/9] net: dsa: bcm_sf2: Get rid of PHYLIB functions Florian Fainelli
2018-05-11 16:23 ` [PATCH net-next v2 0/9] net: dsa: Plug in PHYLINK support David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180510201737.13887-4-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=cphealy@gmail.com \
--cc=davem@davemloft.net \
--cc=john@phrozen.org \
--cc=netdev@vger.kernel.org \
--cc=privat@egil-hjelmeland.no \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).