watchdog: s3c2410_wdt: fix spinlock inconsistent lock state warning
authorSungjinn Chung <sungjinn.chung@samsung.com>
Thu, 27 Nov 2014 13:18:15 +0000 (22:18 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:46 +0000 (20:27 +0900)
This patch is to fix spinlock warning.

< 4>[  204.229499] I[1:  BootAnimation: 2990] =================================
< 4>[  204.229517] I[1:  BootAnimation: 2990] [ INFO: inconsistent lock state ]
< 4>[  204.229538] I[1:  BootAnimation: 2990] 3.10.58-3388584-eng #1 Not tainted
< 4>[  204.229557] I[1:  BootAnimation: 2990] ---------------------------------
< 4>[  204.229576] I[1:  BootAnimation: 2990] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
< 4>[  204.229597] I[1:  BootAnimation: 2990] BootAnimation/2990 [HC1[1]:SC0[0]:HE0:SE1] takes:
< 4>[  204.229617] I[1:  BootAnimation: 2990]  (wdt_lock){?.+...}, at: [<ffffffc0005762c4>] s3c2410wdt_stop+0x1c/0x38
< 4>[  204.229677] I[1:  BootAnimation: 2990] {HARDIRQ-ON-W} state was registered at:
< 4>[  204.229696] I[1:  BootAnimation: 2990]   [<ffffffc0000efa04>] mark_lock+0x304/0x6e4
< 4>[  204.229725] I[1:  BootAnimation: 2990]   [<ffffffc0000f0cbc>] __lock_acquire+0x968/0x19b8
< 4>[  204.229751] I[1:  BootAnimation: 2990]   [<ffffffc0000f2454>] lock_acquire+0xf4/0x128
< 4>[  204.229775] I[1:  BootAnimation: 2990]   [<ffffffc00081dcf8>] _raw_spin_lock+0x38/0x50
< 4>[  204.229802] I[1:  BootAnimation: 2990]   [<ffffffc0005764f8>] s3c2410wdt_stop_intclear.isra.1+0x18/0x50
< 4>[  204.229827] I[1:  BootAnimation: 2990]   [<ffffffc000576830>] s3c2410wdt_probe+0x1f4/0x444

Change-Id: I5fa03e75f6ba68b6dc58a116d134b21b7d53550e
Signed-off-by: Sungjinn Chung <sungjinn.chung@samsung.com>
drivers/watchdog/s3c2410_wdt.c

index cfce2b70217ca5b35e5b7eb8add7b46819108243..ccdff8541c57c2fc32ed576edc08ccab391e1b32 100644 (file)
@@ -253,10 +253,11 @@ static int s3c2410wdt_mask_and_disable_reset(struct s3c2410_wdt *wdt, bool mask)
 static int s3c2410wdt_keepalive(struct watchdog_device *wdd)
 {
        struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
+       unsigned long flags;
 
-       spin_lock(&wdt->lock);
+       spin_lock_irqsave(&wdt->lock, flags);
        writel(wdt->count, wdt->reg_base + S3C2410_WTCNT);
-       spin_unlock(&wdt->lock);
+       spin_unlock_irqrestore(&wdt->lock, flags);
 
        return 0;
 }
@@ -273,30 +274,33 @@ static void __s3c2410wdt_stop(struct s3c2410_wdt *wdt)
 static int s3c2410wdt_stop(struct watchdog_device *wdd)
 {
        struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
+       unsigned long flags;
 
-       spin_lock(&wdt->lock);
+       spin_lock_irqsave(&wdt->lock, flags);
        __s3c2410wdt_stop(wdt);
-       spin_unlock(&wdt->lock);
+       spin_unlock_irqrestore(&wdt->lock, flags);
 
        return 0;
 }
 
 static int s3c2410wdt_stop_intclear(struct s3c2410_wdt *wdt)
 {
-       spin_lock(&wdt->lock);
+       unsigned long flags;
+
+       spin_lock_irqsave(&wdt->lock, flags);
        __s3c2410wdt_stop(wdt);
-       writel(1,  wdt->reg_base + S3C2410_WTCLRINT);
-       spin_unlock(&wdt->lock);
+       writel(1, wdt->reg_base + S3C2410_WTCLRINT);
+       spin_unlock_irqrestore(&wdt->lock, flags);
 
        return 0;
 }
 
 static int s3c2410wdt_start(struct watchdog_device *wdd)
 {
-       unsigned long wtcon;
+       unsigned long wtcon, flags;
        struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
 
-       spin_lock(&wdt->lock);
+       spin_lock_irqsave(&wdt->lock, flags);
 
        __s3c2410wdt_stop(wdt);
 
@@ -317,7 +321,7 @@ static int s3c2410wdt_start(struct watchdog_device *wdd)
        writel(wdt->count, wdt->reg_base + S3C2410_WTDAT);
        writel(wdt->count, wdt->reg_base + S3C2410_WTCNT);
        writel(wtcon, wdt->reg_base + S3C2410_WTCON);
-       spin_unlock(&wdt->lock);
+       spin_unlock_irqrestore(&wdt->lock, flags);
 
        return 0;
 }