All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: Madalin-Cristian Bucur <madalin.bucur@freescale.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Liberman Igal <Igal.Liberman@freescale.com>,
	Stas Sergeev <stsp@users.sourceforge.net>,
	"joakim.tjernlund@transmode.se" <joakim.tjernlund@transmode.se>,
	Shaohui Xie <Shaohui.Xie@freescale.com>
Subject: Re: [PATCH 0/2] of: fsl/fman: reuse the fixed node parsing code
Date: Wed, 12 Aug 2015 16:58:09 +0300	[thread overview]
Message-ID: <55CB50F1.7050308@list.ru> (raw)
In-Reply-To: <BL2PR03MB545929237EF33BA13089EC1E67E0@BL2PR03MB545.namprd03.prod.outlook.com>

12.08.2015 16:26, Madalin-Cristian Bucur пишет:
>>> I've tried to make the smallest changes that allow me to retrieve those
>>> without modifying existing API.
>>> Why is it important to hide the default values from the MAC driver?
>> My worry is that the fixed values are not really fixed, and
>> therefore are not always useful to access directly. It is likely
>> not a problem for your use-case, as, as you say, the AN is
>> disabled, but this is probably not the best to do in general.
> Yes, not a problem in my case.
>
>> And also you do:
>> ---
>>
>> -		err = of_phy_register_fixed_link(mac_node);
>> -		if (err)
>> +		struct phy_device *phy;
>> +
>> +		mac_dev->fixed_link = kzalloc(sizeof(*mac_dev-
>>> fixed_link),
>> +					      GFP_KERNEL);
>> +		if (of_phy_parse_fixed_link(mac_node, mac_dev-
>>> fixed_link))
>> +			goto _return_dev_set_drvdata;
>> +
>> +		phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link,
>> +					 mac_node);
>>
>> ---
>>
>> which means you really want to circumvent the current OF
>> api quite a lot, without saying why in the patch description.
> I circumvent the API because I din not want to change existing API.
> If I could get a reference to the status struct without changing any code
> or without being required to call by myself fixed_phy_register(), I
> would of done that. Given the existing code in of_phy_register_fixed_link(),
> this was my only option. I could have broken of_phy_register_fixed_link()
> in two functions:
>
> of_phy_parse_fixed_link() and of_phy_register_fixed_link(), the latter doing only
> the call to fixed_phy_register()
>
> that would allow to keep of_phy_register_fixed_link() as it is, broken in two stages:
>
> - parsing
> - registering
>
> than can be used by other drivers in order to get the status but I think it's overkill.
What I referred to as "circumventing an API" is that you do
phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link, + mac_node);
by hands, instead of letting the of_phy_register_fixed_link() doing so.

How about a smaller circumvention, like this for instance:
---
err = of_phy_register_fixed_link(mac_node);
phy = of_phy_find_device(dn);
status = fixed_phy_get_link_status(phy);    // no such func, to be coded up
---

Or even like this:
---
err = of_phy_register_fixed_link(mac_node);
phy = of_phy_find_device(dn);
set_speed_and_duplex(phy->speed, phy->duplex);    // not sure if these 
values are available that early
---

Also I meant the description should have been in the patch,
not in the e-mail. :) You only wrote _what_ the patch does
(which is of course obvious from the code itself), but not
_why_ and _what was fixed_ (what didn't work).

>> As to your problem: would it be possible to set speed & duplex
>> after you do of_phy_connect()? It returns the phy_device
>> pointer, and perhaps you can look into phydev->speed and
>> phydev->duplex at that point?
> It would be possible but un-natural as I'd have probing information only available at
> runtime.
This is un-natural only if you deal just with a fixed case.
If your driver can deal also with the non-fixed cases
(either AN or MDIO), then this looks more natural as the
non-fixed management should be done at any point of time,
and certainly _after_ of_phy_connect(). So if your driver is
universal, this look like the natural choise to me, but if it is
limited to the fixed case, then, as a simplification, you move
that to the init time.
But I am not argueing what is more natural. Maybe the
above approaches with of_phy_find_device() can be used
in init time?

>   That would just complicate matters for my particular case ans I suspect there
> will be other drivers that get into this situation.
I suspect only those that are limited to the fixed-link case.
Only then they may decide to move phy management to
init time, but IMHO this is just an optimization.

>   You are concerned about people
> abusing this API to read fixed link status when the link is not really fixed, I'm concerned
> about declaring the link as fixed-link when it's not. Maybe the naming/binding needs to be
> revised to cover the case when all is fixed but the link.
Yes, naming is the problem. fixed-link is just a bad name.
See how it is defined:
---
Some Ethernet MACs have a "fixed link", and are not connected to a
normal MDIO-managed PHY device.
---
To me this means any non-MDIO PHY connection, but
unfortunately the name "fixed-link" suggests a bit more
than advertised. :(

  reply	other threads:[~2015-08-12 13:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05 14:42 [PATCH 0/2] of: fsl/fman: reuse the fixed node parsing code Madalin Bucur
2015-08-05 14:42 ` Madalin Bucur
2015-08-05 14:42 ` [PATCH RFC 2/2] fsl_fman: use fixed_phy_status for MEMAC Madalin Bucur
2015-08-05 14:42   ` Madalin Bucur
     [not found] ` <1438785745-15517-1-git-send-email-madalin.bucur-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-08-05 14:42   ` [PATCH RFC 1/2] of: separate fixed link parsing from registration Madalin Bucur
2015-08-05 14:42     ` Madalin Bucur
2015-08-05 14:42     ` Madalin Bucur
2015-08-08 17:32   ` [PATCH 0/2] of: fsl/fman: reuse the fixed node parsing code Florian Fainelli
2015-08-08 17:32     ` Florian Fainelli
2015-08-11 16:00     ` Stas Sergeev
2015-08-11 16:33       ` Madalin-Cristian Bucur
2015-08-11 16:33         ` Madalin-Cristian Bucur
2015-08-11 16:58         ` Stas Sergeev
2015-08-12 13:26           ` Madalin-Cristian Bucur
2015-08-12 13:26             ` Madalin-Cristian Bucur
2015-08-12 13:58             ` Stas Sergeev [this message]
2015-08-12 14:43               ` Madalin-Cristian Bucur
2015-08-12 14:43                 ` Madalin-Cristian Bucur
2015-08-12 15:09                 ` Stas Sergeev
2015-08-12 15:27                   ` Madalin-Cristian Bucur
2015-08-12 15:27                     ` Madalin-Cristian Bucur
     [not found]                     ` <BL2PR03MB545A213D584384018CCB30CE67E0-AZ66ij2kwaa1tTsckATbNOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
2015-08-12 16:03                       ` Stas Sergeev
2015-08-12 16:03                         ` Stas Sergeev

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=55CB50F1.7050308@list.ru \
    --to=stsp@list.ru \
    --cc=Igal.Liberman@freescale.com \
    --cc=Shaohui.Xie@freescale.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@freescale.com \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=stsp@users.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.