mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	<linux-kernel@vger.kernel.org>,
	Vignesh Raghavendra <vigneshr@ti.com>
Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl()
Date: Tue, 2 Nov 2021 21:12:29 +0200	[thread overview]
Message-ID: <828e2d69-be15-fe69-48d8-9cfc29c4e76e@ti.com> (raw)
In-Reply-To: <e18f17bd-9e77-d3ef-cc1e-30adccb7cdd5@ti.com>



On 02/11/2021 20:37, Grygorii Strashko wrote:
> Hi Russell, Andrew,
> 
> Thanks a lot for you comments.
> 
> On 02/11/2021 19:41, Russell King (Oracle) wrote:
>> On Tue, Nov 02, 2021 at 07:19:46PM +0200, Grygorii Strashko wrote:
>>> It would require MDIO bus lock, which is not a solution,
>>> or some sort of batch processing, like for mmd:
>>>   w reg1 val1
>>>   w reg2 val2
>>>   w reg1 val3
>>>   r reg2
>>>
>>> What Kernel interface do you have in mind?
>>
>> That is roughly what I was thinking, but Andrew has basically said no
>> to it.
>>
>>> Sry, but I have to note that demand for this become terribly high, min two pings in months
>>
>> Feel free to continue demanding it, but it seems that at least two of
>> the phylib maintainers are in agreement that providing generic
>> emulation of C45 accesses in kernel space is just not going to happen.
>>
> 
> not ready to give up.
> 
> One more idea how about mdiobus_get_phy(), so we can search for PHY and
> if present try to use proper API phy_read/phy_write_mmd?
> 
> 

smth like below
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a3bfb156c83d..8ebe59b5647d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -285,6 +285,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
         u16 val = mii_data->val_in;
         bool change_autoneg = false;
         int prtad, devad;
+       struct phy_device *phydev_rq = phydev;
  
         switch (cmd) {
         case SIOCGMIIPHY:
@@ -300,8 +301,18 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
                         prtad = mii_data->phy_id;
                         devad = mii_data->reg_num;
                 }
-               mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad,
-                                                devad);
+
+               if (prtad != phydev->mdio.addr)
+                       phydev_rq = mdiobus_get_phy(phydev->mdio.bus, prtad);
+
+               if (!phydev_rq) {
+                       mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad, devad);
+               } else if (mdio_phy_id_is_c45(mii_data->phy_id) && !phydev->is_c45) {
+                       mii_data->val_out = phy_read_mmd(phydev_rq, mdio_phy_id_devad(mii_data->phy_id), mii_data->reg_num);
+               } else {
+                       mii_data->val_out = phy_read(phydev_rq, mii_data->reg_num);
+               }
+
                 return 0;
  
         case SIOCSMIIREG:

-- 
Best regards,
grygorii

  reply	other threads:[~2021-11-02 19:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 18:28 Grygorii Strashko
2021-11-01 19:33 ` Andrew Lunn
2021-11-01 19:54   ` Russell King (Oracle)
2021-11-02  0:49     ` Andrew Lunn
2021-11-02 12:39       ` Russell King (Oracle)
2021-11-02 17:13         ` Andrew Lunn
2021-11-02 19:46           ` Sean Anderson
2021-11-02 23:38             ` Russell King (Oracle)
2021-11-04 15:05               ` Sean Anderson
2021-11-02 17:19         ` Grygorii Strashko
2021-11-02 17:41           ` Russell King (Oracle)
2021-11-02 18:37             ` Grygorii Strashko
2021-11-02 19:12               ` Grygorii Strashko [this message]
2021-11-02 21:46                 ` Andrew Lunn
2021-11-02 22:22                   ` Grygorii Strashko
2021-11-03  0:27                     ` Andrew Lunn
2021-11-03 18:42                       ` Grygorii Strashko
2021-11-03 19:36                         ` Andrew Lunn
2021-11-04 11:17                           ` Tobias Waldekranz
2021-11-04 12:35                             ` Russell King (Oracle)
2021-11-04 12:40                               ` Russell King (Oracle)
2021-11-04 13:13                                 ` Tobias Waldekranz
2021-11-04 13:06                               ` Tobias Waldekranz

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=828e2d69-be15-fe69-48d8-9cfc29c4e76e@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vigneshr@ti.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

all inboxes | Powered by JetHome®