netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Jose Abreu <Jose.Abreu@synopsys.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Joao Pinto <Joao.Pinto@synopsys.com>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v3 net-next 5/9] net: stmmac: Add MDIO related functions for XGMAC2
Date: Mon, 06 Aug 2018 08:25:03 -0700	[thread overview]
Message-ID: <C540FD04-8429-41E3-9C2C-C21CEAF8030D@gmail.com> (raw)
In-Reply-To: <982b8bed-e11c-2f94-4f7d-21e358ffc0c0@synopsys.com>

On August 6, 2018 12:59:54 AM PDT, Jose Abreu <Jose.Abreu@synopsys.com> wrote:
>On 03-08-2018 20:06, Florian Fainelli wrote:
>> On 08/03/2018 08:50 AM, Jose Abreu wrote:
>>> Add the MDIO related funcionalities for the new IP block XGMAC2.
>>>
>>> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
>>> Cc: David S. Miller <davem@davemloft.net>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>>> Cc: Alexandre Torgue <alexandre.torgue@st.com>
>>> Cc: Andrew Lunn <andrew@lunn.ch>
>>> ---
>>> +satic int stmmac_xgmac2_c22_format(struct stmmac_priv *priv, int
>phyaddr,
>>> +				    int phyreg, u32 *hw_addr)
>>> +{
>>> +	unsigned int mii_data = priv->hw->mii.data;
>>> +	u32 tmp;
>>> +
>>> +	/* HW does not support C22 addr >= 4 */
>>> +	if (phyaddr >= 4)
>>> +		return -ENODEV;
>> It would be nice if this could be moved at probe time so you don't
>have
>> to wait until you connect to the PHY, read its PHY OUI and find out
>it
>> has a MDIO address >= 4. Not a blocker, but something that could be
>> improved further on.
>>
>> In premise you could even scan the MDIO bus' device tree node, and
>find
>> that out ahead of time.
>
>Oh, but I use phylib ... I only provide the read/write callbacks
>so I think we should avoid duplicating the code that's already in
>the phylib ... No?

You can always extract the code that scans a MDIO bus into a helper function and make it parametrized with a callback of some kind. In that case I would be fine with you open coding the MDIO bus scan to find out if there is an address >= 4.

>
>>
>>> +	/* Wait until any existing MII operation is complete */
>>> +	if (readl_poll_timeout(priv->ioaddr + mii_data, tmp,
>>> +			       !(tmp & MII_XGMAC_BUSY), 100, 10000))
>>> +		return -EBUSY;
>>> +
>>> +	/* Set port as Clause 22 */
>>> +	tmp = readl(priv->ioaddr + XGMAC_MDIO_C22P);
>>> +	tmp |= BIT(phyaddr);
>> Since the registers are being Read/Modify/Write here, don't you need
>to
>> clear the previous address bits as well?
>>
>> You probably did not encounter any problems in your testing if you
>had
>> only one PHY on the MDIO bus, but this is not something that is
>> necessarily true, e.g: if you have an Ethernet switch, several MDIO
>bus
>> addresses are going to be responding.
>>
>> Your MDIO bus implementation must be able to support one transaction
>> with one PHY address and the next transaction with another PHY
>address ,
>> etc...
>>
>> That is something that should be easy to fix and be resubmitted as
>part
>> of v4.
>
>I'm not following you here... I only set/unset the bit for the
>corresponding phyaddr that phylib wants to read/write. Why would
>I clear the remaining addresses?

Because this is all about transactions, the HW must be in a state that it will be able to perform that transaction correctly. So here for instance if you needed to support a C45 transaction you would have to clear that bit for that particular PHY address. Since you don't appear to support those yet then yes the code appears fine though it would not hurt if you did clear all other PHY's c22 bits to make it clear what this does.

-- 
Florian

  reply	other threads:[~2018-08-06 17:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 15:50 [PATCH v3 net-next 0/9] Add support for XGMAC2 in stmmac Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 1/9] net: stmmac: Add XGMAC 2.10 HWIF entry Jose Abreu
2018-08-03 18:54   ` Florian Fainelli
2018-08-06  7:55     ` Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 2/9] net: stmmac: Add MAC related callbacks for XGMAC2 Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 3/9] net: stmmac: Add DMA " Jose Abreu
2018-08-03 18:58   ` Florian Fainelli
2018-08-06  7:56     ` Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 4/9] net: stmmac: Add descriptor " Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 5/9] net: stmmac: Add MDIO related functions " Jose Abreu
2018-08-03 16:56   ` Andrew Lunn
2018-08-03 19:06   ` Florian Fainelli
2018-08-06  7:59     ` Jose Abreu
2018-08-06 15:25       ` Florian Fainelli [this message]
2018-08-07 13:35         ` Jose Abreu
2018-08-07 15:29           ` Jose Abreu
2018-08-07 17:31           ` Florian Fainelli
2018-08-03 15:50 ` [PATCH v3 net-next 6/9] net: stmmac: Add PTP support " Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 8/9] net: stmmac: Add the bindings parsing for XGMAC2 Jose Abreu
2018-08-03 15:50 ` [PATCH v3 net-next 9/9] dt-bindings: net: stmmac: Add the bindings documentation " Jose Abreu
2018-08-07 17:36   ` Rob Herring

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=C540FD04-8429-41E3-9C2C-C21CEAF8030D@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alexandre.torgue@st.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.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).