@@ -53,6 +53,37 @@ struct vexpress_syscfg_func {
};
+static int vexpress_syscfg_delay_schedule(unsigned int us)
+{
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(usecs_to_jiffies(us));
+ if (signal_pending(current))
+ return -EINTR;
+
+ return 0;
+}
+
+static int vexpress_syscfg_delay_loop(unsigned int us)
+{
+ udelay(us);
+
+ return 0;
+}
+
+static int (*vexpress_syscfg_delay)(unsigned int us) =
+ vexpress_syscfg_delay_schedule;
+
+static void vexpress_syscfg_shutdown(void)
+{
+ /* Can't relay on the scheduler when the system is going down */
+ vexpress_syscfg_delay = vexpress_syscfg_delay_loop;
+}
+
+static struct syscore_ops vexpress_syscfg_syscore_ops = {
+ .shutdown = vexpress_syscfg_shutdown,
+};
+
+
static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func,
int index, bool write, u32 *data)
{
@@ -87,10 +118,9 @@ static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func,
tries = 100;
timeout = 100;
do {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(usecs_to_jiffies(timeout));
- if (signal_pending(current))
- return -EINTR;
+ int err = vexpress_syscfg_delay(timeout);
+ if (err)
+ return err;
status = readl(syscfg->base + SYS_CFGSTAT);
if (status & SYS_CFGSTAT_ERR)
@@ -299,6 +329,8 @@ int vexpress_syscfg_probe(struct platform_device *pdev)
if (!pdev->dev.of_node)
vexpress_syscfg_bridge = bridge;
+ register_syscore_ops(&vexpress_syscfg_syscore_ops);
+
return 0;
}
It is normally preferable to yield the task waiting for syscfg operations (that can take up to dozens of milliseconds), but when the system is shutting down it may not be possible. This patch adds a udelay-based version of the code to be used in such circumstances. Cc: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Pawel Moll <pawel.moll@arm.com> --- drivers/misc/vexpress-syscfg.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-)