Re: [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY

2015-12-16 Thread David Rivshin (Allworx)
On Wed, 16 Dec 2015 07:39:16 +0100
Markus Brunner  wrote:

> On Monday 14 December 2015 13:04:46 David Rivshin wrote:
> > On Sat, 12 Dec 2015 16:44:19 +0100
> ...
> > > Your patch works fine on my board, which uses MII and dual_emac
> > > with a fixed_phy and a real one.
> > 
> > Thanks for checking. The only dual_emac board I have available is
> > the EVMSK, which has two real PHYs. I'm not sure of the usual
> > etiquette (and Google was  unhelpful), should I add a Tested-by on
> > the next version?
> > 
> Yes you can. Documentation/SubmittingPatches has some notes about it.

Thanks, I didn't want to throw it on without permission. Although due 
to the non-trivial change I mention below, I figured that the previous 
testing wasn't totally valid anymore anyways, so I left it off the v2 
emails.

> > > I wanted to keep changes small and didn't spend too much thinking
> > > about already broken devicetrees. Since my patch is quite new, I
> > 
> > I'm honestly not sure it's an important consideration myself. Most
> > patches I've seen in this area for this or other drivers do not take
> > such behavior into account (e.g. the phy-handle parsing that went in
> > to cpsw in 4.3).
> > I would generally feel more comfortable with such a behavior tweak
> > (minor as it is) before 4.4 is released, to avoid ping-ponging the
> > behavior. But given how far along the cycle is, I'm not sure about
> > the chances of that.
> 
> Well I don't think compatibility for flawed DTs is such a high
> priority, especially if it is that unlikely that there are some
> affected. Keep the focus on the other _real_ problems you have
> encountered and fix those like you see fit. 

Since there's been no indication from anyone that being nice to such
broken DTs is desired, I decided to drop that aspect of the patch and 
leave the current 4.4-rc1..5 behavior. This also made it much more 
reasonable to chop up the patch into smaller pieces, which I think will 
be easier to review.

> > > don't see any problems with subtle changes like that. However you
> > > should update the documentation as well.
> > 
> > Your patch already updated .../bindings/net/cpsw.txt, which this
> > patch left alone. Are you referring to some other documentation,
> > or do you think I should update the binding documentation to state
> > that phy_id takes precedence over fixed-link? I figured that such
> > devicetrees were still officially malformed, so I thought the
> > existing text was appropriate.
> 
> "Either the properties phy_id and phy-mode, or the sub-node
> fixed-link can be specified" One flaw of my patch was to ignore the
> phy-mode for a fixed link. Do not mention the precedence of the
> phy_id, because it is an undefined behavior. Your patch should change
> it to: "Either the property phy_id, or the sub-node fixed-link can be
> specified"

Thanks for pointing that out. For some reason my brain skipped over the 
"and phy-mode" part. Fixed in v2.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY

2015-12-15 Thread Markus Brunner
On Monday 14 December 2015 13:04:46 David Rivshin wrote:
> On Sat, 12 Dec 2015 16:44:19 +0100
...
> > Your patch works fine on my board, which uses MII and dual_emac with
> > a fixed_phy and a real one.
> 
> Thanks for checking. The only dual_emac board I have available is the
> EVMSK, which has two real PHYs. I'm not sure of the usual etiquette
> (and Google was  unhelpful), should I add a Tested-by on the next
> version?
> 
Yes you can. Documentation/SubmittingPatches has some notes about it.

> > > Besides fixing the bug mentioned in the commit log, there are a few
> > > 
> > > other differences to note:
> > >  * If both "phy_id" and a "fixed-link" subnode are present this
> > > 
> > > patch will use the "phy_id" property. This should preserve current
> > > behavior with existing devicetrees that might incorrectly have
> > > both. This motivates the biggest difference in code organization
> > > from 1f71e8c96fc6.
> > > 
> > >  * Some error messages have been tweaked to reflect the slightly
> > > 
> > > changed meanings of the checks.
> > 
> > I wanted to keep changes small and didn't spend too much thinking
> > about already broken devicetrees. Since my patch is quite new, I
> 
> I'm honestly not sure it's an important consideration myself. Most
> patches I've seen in this area for this or other drivers do not take
> such behavior into account (e.g. the phy-handle parsing that went in
> to cpsw in 4.3).
> I would generally feel more comfortable with such a behavior tweak
> (minor as it is) before 4.4 is released, to avoid ping-ponging the
> behavior. But given how far along the cycle is, I'm not sure about
> the chances of that.
> 

Well I don't think compatibility for flawed DTs is such a high priority, 
especially if it is that unlikely that there are some affected.
Keep the focus on the other _real_ problems you have encountered and fix those 
like you see fit. 

> > don't see any problems with subtle changes like that. However you
> > should update the documentation as well.
> 
> Your patch already updated .../bindings/net/cpsw.txt, which this
> patch left alone. Are you referring to some other documentation,
> or do you think I should update the binding documentation to state
> that phy_id takes precedence over fixed-link? I figured that such
> devicetrees were still officially malformed, so I thought the
> existing text was appropriate.

"Either the properties phy_id and phy-mode, or the sub-node fixed-link can be 
specified"
One flaw of my patch was to ignore the phy-mode for a fixed link. Do not 
mention the precedence of the phy_id, because it is an undefined behavior.
Your patch should change it to:
"Either the property phy_id, or the sub-node fixed-link can be specified"


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY

2015-12-14 Thread David Rivshin (Allworx)
On Sat, 12 Dec 2015 16:44:19 +0100
Markus Brunner  wrote:

> On Wednesday 09 December 2015 22:31:15 David Rivshin wrote:
> ...
> > This patch was originally developed in parallel with 1f71e8c96fc6 to
> > accomplish the same goal. When I replaced this patch with
> > 1f71e8c96fc6, I found that it did not work on my hardware (which
> > uses RGMII), so I am submitting this patch now as a bugfix. 
> 
> Your patch works fine on my board, which uses MII and dual_emac with
> a fixed_phy and a real one. 

Thanks for checking. The only dual_emac board I have available is the 
EVMSK, which has two real PHYs. I'm not sure of the usual etiquette 
(and Google was  unhelpful), should I add a Tested-by on the next 
version?

> > Besides fixing the bug mentioned in the commit log, there are a few
> > other differences to note:
> >  * If both "phy_id" and a "fixed-link" subnode are present this
> > patch will use the "phy_id" property. This should preserve current
> > behavior with existing devicetrees that might incorrectly have
> > both. This motivates the biggest difference in code organization
> > from 1f71e8c96fc6.
> >  * Some error messages have been tweaked to reflect the slightly
> > changed meanings of the checks.
> 
> I wanted to keep changes small and didn't spend too much thinking
> about already broken devicetrees. Since my patch is quite new, I

I'm honestly not sure it's an important consideration myself. Most
patches I've seen in this area for this or other drivers do not take 
such behavior into account (e.g. the phy-handle parsing that went in 
to cpsw in 4.3).
I would generally feel more comfortable with such a behavior tweak
(minor as it is) before 4.4 is released, to avoid ping-ponging the
behavior. But given how far along the cycle is, I'm not sure about 
the chances of that.

> don't see any problems with subtle changes like that. However you
> should update the documentation as well. 

Your patch already updated .../bindings/net/cpsw.txt, which this
patch left alone. Are you referring to some other documentation, 
or do you think I should update the binding documentation to state
that phy_id takes precedence over fixed-link? I figured that such
devicetrees were still officially malformed, so I thought the 
existing text was appropriate.

> >  * of_node_get() is called on slave_node before passing the result
> > to of_phy_find_device(). This increments the reference count, which
> > I believe is correct for this situation, but I'm not certain of
> > that.
> I think you are right. At least most other drivers calling
> of_phy_register_fixed_link(), call of_node_get afterwards. I can't
> remember where I got my "inspiration" for the patch. I made it almost
> a year ago and now 3 other guys tinker with the same feature? What a
> coincidence ;-)

Perhaps not a complete coincidence. I first wrote this patch a few 
months ago against 4.1. While I had always intended on submitting when 
time allowed, testing your patch gave me an extra push.

[...]

> > --- a/drivers/net/ethernet/ti/cpsw.c
> > +++ b/drivers/net/ethernet/ti/cpsw.c
> > @@ -26,6 +26,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> 
> The prototypes for of_*_fixed_link are in linux/of_mdio.h, which is
> already included.

You are correct; I forget why I had originally included that. I will 
remove it for v2.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY

2015-12-12 Thread Markus Brunner
On Wednesday 09 December 2015 22:31:15 David Rivshin wrote:
...
> This patch was originally developed in parallel with 1f71e8c96fc6 to
> accomplish the same goal. When I replaced this patch with 1f71e8c96fc6,
> I found that it did not work on my hardware (which uses RGMII), so I
> am submitting this patch now as a bugfix. 

Your patch works fine on my board, which uses MII and dual_emac with a 
fixed_phy and a real one. 

> Besides fixing the bug mentioned in the commit log, there are a few other
> differences to note:
>  * If both "phy_id" and a "fixed-link" subnode are present this patch will
>use the "phy_id" property. This should preserve current behavior with
>existing devicetrees that might incorrectly have both. This motivates
>the biggest difference in code organization from 1f71e8c96fc6.
>  * Some error messages have been tweaked to reflect the slightly changed
>meanings of the checks.

I wanted to keep changes small and didn't spend too much thinking about already 
broken devicetrees. 
Since my patch is quite new, I don't see any problems with subtle changes like 
that. However you should update the documentation as well. 

>  * of_node_get() is called on slave_node before passing the result to
>of_phy_find_device(). This increments the reference count, which I
>believe is correct for this situation, but I'm not certain of that.
I think you are right. At least most other drivers calling 
of_phy_register_fixed_link(), call of_node_get afterwards. 
I can't remember where I got my "inspiration" for the patch. I made it almost a 
year ago and now 3 other guys tinker with the same feature? What a coincidence 
;-)

>  * Uses the phy_device's 'addr' instead of 'phy_id' field when constructing
>slave_data->phy_id. Pascal Speck separately came to the same conclusion
>in another patch [1].
Clearly an improvement.
>  * [2] pointed out that the 'lenp' sanity check was wrong, and since this
>patch re-arranged that check anyways I incorporated that fix as well.
> Although the last three items could be fixed separately, it seemed like that
> would be unnecessary churn since those same lines were already touched in
> this patch. Let me know if its preferred to fix them separately.
> 
> This patch is also very similar to one Daniel Trautmann submitted [3], with
> the biggest difference being that Daniel's patch uses the new priv->phy_node
> field and of_node_get(). While this seems like a better path overall it
> does not work if more than once CPSW slave is used, due to struct cpsw_priv
> being shared with all the slaves. I am under the impression that phy_node
> should really be in struct cpsw_slave instead, but I will leave that for
> another patch.
A lot of people will need both slaves.
...
> (Side note: This is my first patch submission, and any feedback on things
> to do differently in the future would be appreciated.)

> 
>  drivers/net/ethernet/ti/cpsw.c | 65
> +- 1 file changed, 39
> insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 48b92c9..ba8d086 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -26,6 +26,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

The prototypes for of_*_fixed_link are in linux/of_mdio.h, which is already 
included.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html