Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1737607 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2017-09-22 18:30 +0200 |
| Last post | 2017-09-22 19:00 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH net-next 1/4] net: dsa: move up phy enabling in core Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-09-22 18:30 +0200
Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core Andrew Lunn <andrew@lunn.ch> - 2017-09-22 18:40 +0200
Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core Florian Fainelli <f.fainelli@gmail.com> - 2017-09-22 19:00 +0200
Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core Florian Fainelli <f.fainelli@gmail.com> - 2017-09-22 19:00 +0200
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2017-09-22 18:30 +0200 |
| Subject | [PATCH net-next 1/4] net: dsa: move up phy enabling in core |
| Message-ID | <usyZY-8kh-1@gated-at.bofh.it> |
bcm_sf2 is currently the only driver using the phy argument passed to
.port_enable. It resets the state machine if the phy has been hard
reset. This check is generic and can be moved to DSA core.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/bcm_sf2.c | 16 +---------------
net/dsa/slave.c | 15 +++++++++++++--
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 898d5642b516..ad96b9725a2c 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -184,22 +184,8 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port));
/* Re-enable the GPHY and re-apply workarounds */
- if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
+ if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1)
bcm_sf2_gphy_enable_set(ds, true);
- if (phy) {
- /* if phy_stop() has been called before, phy
- * will be in halted state, and phy_start()
- * will call resume.
- *
- * the resume path does not configure back
- * autoneg settings, and since we hard reset
- * the phy manually here, we need to reset the
- * state machine also.
- */
- phy->state = PHY_READY;
- phy_init_hw(phy);
- }
- }
/* Enable MoCA port interrupts to get notified */
if (port == priv->moca_port)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 02ace7d462c4..606812160fd5 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -72,6 +72,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
static int dsa_slave_open(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
+ struct phy_device *phy = p->phy;
struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds;
struct net_device *master = dsa_master_netdev(p);
@@ -106,8 +107,18 @@ static int dsa_slave_open(struct net_device *dev)
dsa_port_set_state_now(p->dp, stp_state);
- if (p->phy)
- phy_start(p->phy);
+ if (phy) {
+ /* If phy_stop() has been called before, phy will be in
+ * halted state, and phy_start() will call resume.
+ *
+ * The resume path does not configure back autoneg
+ * settings, and since the internal phy may have been
+ * hard reset, we need to reset the state machine also.
+ */
+ phy->state = PHY_READY;
+ phy_init_hw(phy);
+ phy_start(phy);
+ }
return 0;
--
2.14.1
[toc] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2017-09-22 18:40 +0200 |
| Message-ID | <usz9F-8nF-41@gated-at.bofh.it> |
| In reply to | #1737607 |
On Fri, Sep 22, 2017 at 12:17:50PM -0400, Vivien Didelot wrote:
> bcm_sf2 is currently the only driver using the phy argument passed to
> .port_enable. It resets the state machine if the phy has been hard
> reset. This check is generic and can be moved to DSA core.
>
> dsa_port_set_state_now(p->dp, stp_state);
>
> - if (p->phy)
> - phy_start(p->phy);
> + if (phy) {
> + /* If phy_stop() has been called before, phy will be in
> + * halted state, and phy_start() will call resume.
> + *
> + * The resume path does not configure back autoneg
> + * settings, and since the internal phy may have been
> + * hard reset, we need to reset the state machine also.
> + */
> + phy->state = PHY_READY;
> + phy_init_hw(phy);
> + phy_start(phy);
> + }
Hi Vivien
If this is generic, why is it needed at all here? Shouldn't this
actually by in phylib?
Florian ?
Andrew
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-09-22 19:00 +0200 |
| Message-ID | <uszt0-8us-17@gated-at.bofh.it> |
| In reply to | #1737641 |
On 09/22/2017 09:32 AM, Andrew Lunn wrote:
> On Fri, Sep 22, 2017 at 12:17:50PM -0400, Vivien Didelot wrote:
>> bcm_sf2 is currently the only driver using the phy argument passed to
>> .port_enable. It resets the state machine if the phy has been hard
>> reset. This check is generic and can be moved to DSA core.
>>
>> dsa_port_set_state_now(p->dp, stp_state);
>>
>> - if (p->phy)
>> - phy_start(p->phy);
>> + if (phy) {
>> + /* If phy_stop() has been called before, phy will be in
>> + * halted state, and phy_start() will call resume.
>> + *
>> + * The resume path does not configure back autoneg
>> + * settings, and since the internal phy may have been
>> + * hard reset, we need to reset the state machine also.
>> + */
>> + phy->state = PHY_READY;
>> + phy_init_hw(phy);
>> + phy_start(phy);
>> + }
>
> Hi Vivien
>
> If this is generic, why is it needed at all here? Shouldn't this
> actually by in phylib?
This does not belong in the core logic within net/dsa/slave.c. The
reason why this is necessary here is because we are doing a HW-based
reset of the PHY, as the comment explains this is specific to how the HW
works. There may be a cleaner solution to this problem, but in any case,
I don't think other drivers should inherit that logic.
--
Florian
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-09-22 19:00 +0200 |
| Message-ID | <uszt0-8us-1@gated-at.bofh.it> |
| In reply to | #1737607 |
On 09/22/2017 09:17 AM, Vivien Didelot wrote:
> bcm_sf2 is currently the only driver using the phy argument passed to
> .port_enable. It resets the state machine if the phy has been hard
> reset. This check is generic and can be moved to DSA core.
This is completely specific to bcm_sf2 because it does call
bcm_sf2_gphy_enable_set() which performs a HW reset of the PHY, you
can't move this to the generic portion of net/dsa/slave.c. NACK.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
> drivers/net/dsa/bcm_sf2.c | 16 +---------------
> net/dsa/slave.c | 15 +++++++++++++--
> 2 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 898d5642b516..ad96b9725a2c 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -184,22 +184,8 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
> core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port));
>
> /* Re-enable the GPHY and re-apply workarounds */
> - if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
> + if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1)
> bcm_sf2_gphy_enable_set(ds, true);
> - if (phy) {
> - /* if phy_stop() has been called before, phy
> - * will be in halted state, and phy_start()
> - * will call resume.
> - *
> - * the resume path does not configure back
> - * autoneg settings, and since we hard reset
> - * the phy manually here, we need to reset the
> - * state machine also.
> - */
> - phy->state = PHY_READY;
> - phy_init_hw(phy);
> - }
> - }
>
> /* Enable MoCA port interrupts to get notified */
> if (port == priv->moca_port)
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 02ace7d462c4..606812160fd5 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -72,6 +72,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
> static int dsa_slave_open(struct net_device *dev)
> {
> struct dsa_slave_priv *p = netdev_priv(dev);
> + struct phy_device *phy = p->phy;
> struct dsa_port *dp = p->dp;
> struct dsa_switch *ds = dp->ds;
> struct net_device *master = dsa_master_netdev(p);
> @@ -106,8 +107,18 @@ static int dsa_slave_open(struct net_device *dev)
>
> dsa_port_set_state_now(p->dp, stp_state);
>
> - if (p->phy)
> - phy_start(p->phy);
> + if (phy) {
> + /* If phy_stop() has been called before, phy will be in
> + * halted state, and phy_start() will call resume.
> + *
> + * The resume path does not configure back autoneg
> + * settings, and since the internal phy may have been
> + * hard reset, we need to reset the state machine also.
> + */
> + phy->state = PHY_READY;
> + phy_init_hw(phy);
> + phy_start(phy);
> + }
>
> return 0;
>
>
--
Florian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web