net: fsl_mdio: Fix busy flag polling register
PATCH v2 1/1 net: fsl_mdio: Fix busy flag polling register
NXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.
In the Linux kernel, this has already been fixed in commit 26eee0210ad7 ("net/fsl: fix a bug in xgmac_mdio").
---
Changed to use the mdio_stat register. Thanks, Ioana!
drivers/net/fm/memac_phy.c | 2 +- include/fsl_memac.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/fm/memac_phy.c +1 -1
@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs) {unsigned int timeout =MAX_NUM_RETRIES ; -while ((memac_in_32 (®s->mdio_data) &MDIO_DATA_BSY ) && timeout--) +while ((memac_in_32 (®s->mdio_stat) &MDIO_STAT_BSY ) && timeout--) ;if (!timeout) {
include/fsl_memac.h +0 -1
@@ -254,7 +254,6 @@ struct memac_mdio_controller {#define MDIO_CTL_READ (1 << 15)#define MDIO_DATA (x) (x & 0xffff) -#define MDIO_DATA_BSY (1 << 31)struct fsl_enet_mac ;
Signature · 1 line
2.34.1
Quoted 16 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Markus Koch
Sent: Tuesday, January 4, 2022 17:42
To: Ioana Ciornei <[email protected]>; [email protected]; [email protected]
Cc: Madalin Bucur (OSS) <[email protected]>; Camelia Alexandra Groza <[email protected]>; [email protected]; Markus Koch <[email protected]>
Subject: [PATCH v2] net:fsl_mdio: Fix busy flag polling registerNXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management
Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.
Quoted 4 lines
In the Linux kernel, this has already been fixed in commit
26eee0210ad7("net/fsl: fix a bug inxgmac_mdio").Signed-off-by Markus Koch <[email protected]>
I am ok with the change for the mEMAC driver but MDIO_DATA_BSY is still used by the fsl_ls_mdio driver. The MDIO driver suffers from the same issue.
Please send a v3 and either patch both drivers or don't remove the define. Also, if removing the define, please mention it explicitly in the patch description.
Thanks,
Camelia
Quoted 38 lines
---
Changed to use the
mdio_statregister. Thanks, Ioana!drivers/net/fm/memac_phy.c | 2 +- include/fsl_memac.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)drivers/net/fm/memac_phy.c +1
-1@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs) {unsigned int timeout =MAX_NUM_RETRIES ; -while ((memac_in_32 (®s->mdio_data) &MDIO_DATA_BSY ) && timeout--) +while ((memac_in_32 (®s->mdio_stat) &MDIO_STAT_BSY ) && timeout--)drivers/net/fm/memac_phy.c +0
-0;if (!timeout) {include/fsl_memac.h +0
-2@@ -254,7 +254,6 @@ struct memac_mdio_controller {#define MDIO_CTL_READ (1 << 15)#define MDIO_DATA (x) (x & 0xffff) -#define MDIO_DATA_BSY (1 << 31)struct fsl_enet_mac ; --2.34.1
Quoted 19 lines · Camelia Alexandra Groza (OSS)
Quoted 19 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Markus Koch
Sent: Tuesday, January 4, 2022 17:42
To: Ioana Ciornei <[email protected]>; [email protected]; [email protected]
Cc: Madalin Bucur (OSS) <[email protected]>; Camelia Alexandra Groza <[email protected]>; [email protected]; Markus Koch <[email protected]>
Subject: [PATCH v2] net:fsl_mdio: Fix busy flag polling registerNXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management
Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.In the Linux kernel, this has already been fixed in commit
26eee0210ad7("net/fsl: fix a bug inxgmac_mdio").
Quoted 8 lines
Quoted 1 line
Signed-off-by Markus Koch <[email protected]>I am ok with the change for the mEMAC driver but
MDIO_DATA_BSYis still used by thefsl_ls_mdiodriver. The MDIO driver suffers from the same issue.Please send a v3 and either patch both drivers or don't remove the define. Also, if removing the define, please mention it explicitly in the patch description.
I'll change the other driver as well.
There's also the fm/tgec_phy driver that uses the same construct, but it has its own define for MDIO_DATA_BSY. Should I also change that? I think it corresponds to Linux' xgmac_mdio.c which also uses the STAT_BSY register, but I don't have a datasheet to verify the register definition.
Thanks,
Markus
Quoted 42 lines
Thanks,
CameliaQuoted 38 lines
---
Changed to use the
mdio_statregister. Thanks, Ioana!drivers/net/fm/memac_phy.c | 2 +- include/fsl_memac.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)drivers/net/fm/memac_phy.c +1
-1@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs) {unsigned int timeout =MAX_NUM_RETRIES ; -while ((memac_in_32 (®s->mdio_data) &MDIO_DATA_BSY ) && timeout--) +while ((memac_in_32 (®s->mdio_stat) &MDIO_STAT_BSY ) && timeout--);
if (!timeout) {include/fsl_memac.h +0
-2@@ -254,7 +254,6 @@ struct memac_mdio_controller {#define MDIO_CTL_READ (1 << 15)#define MDIO_DATA (x) (x & 0xffff) -#define MDIO_DATA_BSY (1 << 31)struct fsl_enet_mac ; --2.34.1
Quoted 42 lines
-----Original Message-----
From: Markus Koch <[email protected]>
Sent: Friday, January 7, 2022 19:49
To: Camelia Alexandra Groza (OSS) <[email protected]>; [email protected]; [email protected]; Ioana Ciornei <[email protected]>
Cc: Madalin Bucur (OSS) <[email protected]>; u- [email protected]
Subject: Re: [PATCH v2] net:fsl_mdio: Fix busy flag polling registerQuoted 2 lines · Camelia Alexandra Groza (OSS)
Quoted 2 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of MarkusKoch
Quoted 4 lines
Quoted 4 lines
Sent: Tuesday, January 4, 2022 17:42
To: Ioana Ciornei <[email protected]>; [email protected]; [email protected]
Cc: Madalin Bucur (OSS) <[email protected]>; CameliaAlexandra
Quoted 10 lines
Quoted 10 lines
Groza <[email protected]>; [email protected]; Markus Koch <[email protected]>
Subject: [PATCH v2] net:fsl_mdio: Fix busy flag polling registerNXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management
Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.Quoted 7 lines
Quoted 4 lines
In the Linux kernel, this has already been fixed in commit
26eee0210ad7("net/fsl: fix a bug inxgmac_mdio").Signed-off-by Markus Koch <[email protected]>I am ok with the change for the mEMAC driver but
MDIO_DATA_BSYis still used by thefsl_ls_mdiodriver. The MDIO driver suffers from the sameissue.
Quoted 4 lines
Please send a v3 and either patch both drivers or don't remove the define. Also, if removing the define, please mention it explicitly in the patch description.
Quoted 7 lines
I'll change the other driver as well.
There's also the fm/tgec_phy driver that uses the same construct, but it has its own define for
MDIO_DATA_BSY. Should I also change that? I think it corresponds to Linux'xgmac_mdio.cwhich also uses theSTAT_BSYregister, but
I don't have a datasheet to verify the register definition.
The TGEC controller has BUSY bits mirroring each other in both the MDIO_DATA and MDIO_CFG_STAT registers. The tgec_phy driver doesn't need changing.
Regards,
Camelia
Quoted 45 lines
Thanks,
MarkusQuoted 42 lines
Thanks,
CameliaQuoted 38 lines
---
Changed to use the
mdio_statregister. Thanks, Ioana!drivers/net/fm/memac_phy.c | 2 +- include/fsl_memac.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)drivers/net/fm/memac_phy.c +1
-1@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs) {unsigned int timeout =MAX_NUM_RETRIES ; -while ((memac_in_32 (®s->mdio_data) &MDIO_DATA_BSY ) && timeout--) +while ((memac_in_32 (®s->mdio_stat) &MDIO_STAT_BSY ) && timeout--);
if (!timeout) {include/fsl_memac.h +0
-2@@ -254,7 +254,6 @@ struct memac_mdio_controller {#define MDIO_CTL_READ (1 << 15)#define MDIO_DATA (x) (x & 0xffff) -#define MDIO_DATA_BSY (1 << 31)struct fsl_enet_mac ; --2.34.1