Skip to contentSkip to conversation

drivers:watchdog:aspeed_wdt: using msleep instead of mdelay

PATCH In review Karim Eshapa 2 participants 4 messages Apr 16, 2017 – Apr 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers:watchdog:aspeed_wdt: using msleep instead of mdelay

that's useful for the scheduler, power management unless the driver needs to delay in atomic context look at documentation/timers/timers-howto

---
 drivers/watchdog/aspeed_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/aspeed_wdt.c +1 -1
index 1c65258..17f06d1 100644
@@ -115,7 +115,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
 
 	aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000);
 
-	mdelay(1000);
+	msleep(1000);
 
 	return 0;
 }
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 15 lines · Karim Eshapa

that's useful for the scheduler, power management unless the driver needs to delay in atomic context look at documentation/timers/timers-howto

---
 drivers/watchdog/aspeed_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/aspeed_wdt.c +0 -0
index 1c65258..17f06d1 100644

drivers/watchdog/aspeed_wdt.c static int aspeed_wdt_restart(struct watchdog_device *wdd, · line 121

Quoted 8 lines
drivers/watchdog/aspeed_wdt.c +1 -1
@@ -115,7 +115,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
 
 	aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000);
 
-	mdelay(1000);
+	msleep(1000);
 
 	return 0;
 }

Possibly, but how can you guarantee that the restart function is called with interrupts enabled ? Also, why would it be necessary or even useful for the scheduler to do anything while the system is in the process of restarting ?

Guenter

#2 lore raw
Quoted 11 lines · On Sun, 16 Apr 2017 12:53:28 -0700,Guenter Roeck wrote:
Quoted 4 lines · Karim Eshapa

that's useful for the scheduler, power management unless the driver needs to delay in atomic context look at documentation/timers/timers-howto

Possibly, but how can you guarantee that the restart function is called with interrupts enabled ? Also, why would it be necessary or even useful for the scheduler to do anything while the system is in the process of restarting ?

From signaling or interruption point of view msleep() is uninterruptible.

your process will sleep and won't be waked up until finish the time.

Quoted 1 line

From the cpu load and power point of view, mdelay() makes your code

stucked doing nothing until the delay finishes so, it's still headache to the schedular from time slot perspective.
Although it's restating but it's still a long process that takes time.

In addittion to mdelay() isn't preferable in case of large delays +10 as it uses udelay()

But the question now what about ptotecting your HW while being accessed through manipulating the registers. and what about memory reordering may be generated by the compiler or the machine itself! while accessing a sequence of registers.

Quoted 13 lines
Quoted 13 lines

---
drivers/watchdog/aspeed_wdt.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
index 1c65258..17f06d1 100644
--- a/drivers/watchdog/aspeed_wdt.c
+++ b/drivers/watchdog/aspeed_wdt.c

drivers/watchdog/aspeed_wdt.c +1 -1
@@ -115,7 +115,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd>> , aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000);
-       mdelay(1000);
+       msleep(1000);
 
Quoted 2 lines

drivers/watchdog/aspeed_wdt.c static int aspeed_wdt_restart(struct watchdog_device *wdd, · line 121

Quoted 2 lines
drivers/watchdog/aspeed_wdt.c +0 -0
        return 0;
  }

Thanks,
Karim

maintainer
#3 lore raw
Quoted 19 lines · Karim Eshapa
Quoted 9 lines · On Sun, 16 Apr 2017 12:53:28 -0700,Guenter Roeck wrote:
Quoted 4 lines · Karim Eshapa

that's useful for the scheduler, power management unless the driver needs to delay in atomic context look at documentation/timers/timers-howto

Possibly, but how can you guarantee that the restart function is called with interrupts enabled ? Also, why would it be necessary or even useful for the scheduler to do anything while the system is in the process of restarting ?

From signaling or interruption point of view msleep() is uninterruptible. your process will sleep and won't be waked up until finish the time.

From the cpu load and power point of view, mdelay() makes your code stucked doing nothing until the delay finishes so, it's still headache to the schedular from time slot perspective.
Although it's restating but it's still a long process that takes time.

Quoted 6 lines

In addittion to mdelay() isn't preferable in case of large delays +10 as it uses udelay()

But the question now what about ptotecting your HW while being accessed through manipulating the registers. and what about memory reordering may be generated by the compiler or the machine itself! while accessing a sequence of registers.

We are in the process of _resetting the system_ in this function. If the function works, it won't return from the call to mdelay(). If anything, I would argue that we don't want to use anything but mdelay() in this situation.

Sorry, I don't see the point you are trying to make.

Guenter