diff mbox

video: fbdev: aty: aty128fb: Replace mdelay with msleep in aty128_set_suspend

Message ID 1523324435-28719-1-git-send-email-baijiaju1990@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jia-Ju Bai April 10, 2018, 1:40 a.m. UTC
aty128_set_suspend() is never called in atomic context.

The call chains ending up at aty128_set_suspend() are:
[1] aty128_set_suspend() <- aty128_pci_suspend()
[2] aty128_set_suspend() <- aty128_do_resume() <- aty128_pci_resume()
[3] aty128_set_suspend() <- aty128_do_resume() <- aty128_early_resume()

aty128_pci_suspend() is set as ".suspend" in struct pci_driver.
aty128_pci_resume() is set as ".resume" in struct pci_driver.
aty128_early_resume() is never called.
These functions are not called in atomic context.

Despite never getting called from atomic context, aty128_set_suspend()
calls mdelay() to busily wait.
This is not necessary and can be replaced with msleep() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/video/fbdev/aty/aty128fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bartlomiej Zolnierkiewicz April 24, 2018, 3:48 p.m. UTC | #1
On Tuesday, April 10, 2018 09:40:35 AM Jia-Ju Bai wrote:
> aty128_set_suspend() is never called in atomic context.
> 
> The call chains ending up at aty128_set_suspend() are:
> [1] aty128_set_suspend() <- aty128_pci_suspend()
> [2] aty128_set_suspend() <- aty128_do_resume() <- aty128_pci_resume()
> [3] aty128_set_suspend() <- aty128_do_resume() <- aty128_early_resume()
> 
> aty128_pci_suspend() is set as ".suspend" in struct pci_driver.
> aty128_pci_resume() is set as ".resume" in struct pci_driver.
> aty128_early_resume() is never called.
> These functions are not called in atomic context.
> 
> Despite never getting called from atomic context, aty128_set_suspend()
> calls mdelay() to busily wait.
> This is not necessary and can be replaced with msleep() to
> avoid busy waiting.
> 
> This is found by a static analysis tool named DCNS written by myself.
> And I also manually check it.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Patch queued for 4.18, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
index db18474..15dfdff 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -2442,7 +2442,7 @@  static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
 		(void)aty_ld_pll(POWER_MANAGEMENT);
 		aty_st_le32(BUS_CNTL1, 0x00000010);
 		aty_st_le32(MEM_POWER_MISC, 0x0c830000);
-		mdelay(100);
+		msleep(100);
 
 		/* Switch PCI power management to D2 */
 		pci_set_power_state(pdev, PCI_D2);