* [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro
@ 2025-09-24 15:22 Furong Xu
2025-09-25 9:42 ` Simon Horman
2025-09-27 0:26 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Furong Xu @ 2025-09-24 15:22 UTC (permalink / raw)
To: netdev, linux-stm32, linux-arm-kernel, linux-kernel
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, xfr, Furong Xu
Drop the open-coded register polling routines.
Use readl_poll_timeout_atomic() in atomic state.
Compile tested only.
No functional change intended.
Signed-off-by: Furong Xu <0x1207@gmail.com>
---
.../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 28 ++++---------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index e2840fa241f2..9e445ad1aa77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -135,7 +135,6 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
static int config_addend(void __iomem *ioaddr, u32 addend)
{
u32 value;
- int limit;
writel(addend, ioaddr + PTP_TAR);
/* issue command to update the addend value */
@@ -144,23 +143,15 @@ static int config_addend(void __iomem *ioaddr, u32 addend)
writel(value, ioaddr + PTP_TCR);
/* wait for present addend update to complete */
- limit = 10;
- while (limit--) {
- if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSADDREG))
- break;
- mdelay(10);
- }
- if (limit < 0)
- return -EBUSY;
-
- return 0;
+ return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
+ !(value & PTP_TCR_TSADDREG),
+ 10, 100000);
}
static int adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
int add_sub, int gmac4)
{
u32 value;
- int limit;
if (add_sub) {
/* If the new sec value needs to be subtracted with
@@ -187,16 +178,9 @@ static int adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
writel(value, ioaddr + PTP_TCR);
/* wait for present system time adjust/update to complete */
- limit = 10;
- while (limit--) {
- if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSUPDT))
- break;
- mdelay(10);
- }
- if (limit < 0)
- return -EBUSY;
-
- return 0;
+ return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
+ !(value & PTP_TCR_TSUPDT),
+ 10, 100000);
}
static void get_systime(void __iomem *ioaddr, u64 *systime)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro
2025-09-24 15:22 [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro Furong Xu
@ 2025-09-25 9:42 ` Simon Horman
2025-09-27 0:26 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-09-25 9:42 UTC (permalink / raw)
To: Furong Xu
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Maxime Coquelin, Alexandre Torgue, xfr
On Wed, Sep 24, 2025 at 11:22:17PM +0800, Furong Xu wrote:
> Drop the open-coded register polling routines.
> Use readl_poll_timeout_atomic() in atomic state.
>
> Compile tested only.
> No functional change intended.
>
> Signed-off-by: Furong Xu <0x1207@gmail.com>
I agree this is correct. Or at least, it looks correct to me.
But, FWIIW, I do have some hesitation about untested code of this nature
being accepted so close to the merge window.
Reviewed-by: Simon Horman <horms@kernel.org>
...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro
2025-09-24 15:22 [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro Furong Xu
2025-09-25 9:42 ` Simon Horman
@ 2025-09-27 0:26 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-09-27 0:26 UTC (permalink / raw)
To: Furong Xu
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
David S. Miller, Eric Dumazet, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, xfr
On Wed, 24 Sep 2025 23:22:17 +0800 Furong Xu wrote:
> writel(addend, ioaddr + PTP_TAR);
> /* issue command to update the addend value */
> @@ -144,23 +143,15 @@ static int config_addend(void __iomem *ioaddr, u32 addend)
> writel(value, ioaddr + PTP_TCR);
>
> /* wait for present addend update to complete */
> - limit = 10;
> - while (limit--) {
> - if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSADDREG))
> - break;
> - mdelay(10);
> - }
> - if (limit < 0)
> - return -EBUSY;
> -
> - return 0;
> + return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
> + !(value & PTP_TCR_TSADDREG),
Why the strange alignment ? I think you can start the continuation line
under the opening bracket and still easily fit in 80 chars?
> + 10, 100000);
You say in the commit message "no functional changes intended"
but you changed the frequency of polling from 10msec to 10usec.
Seems like a reasonable change, but the commit message is lying.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-27 0:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 15:22 [PATCH net-next] net: stmmac: Convert open-coded register polling to helper macro Furong Xu
2025-09-25 9:42 ` Simon Horman
2025-09-27 0:26 ` Jakub Kicinski
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).