All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset
@ 2018-04-11  2:21 Jia-Ju Bai
  2018-04-11 15:50 ` kbuild test robot
  2018-04-11 15:52 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-11  2:21 UTC (permalink / raw)
  To: bh74.an, ks.giri, vipul.pandya; +Cc: netdev, linux-kernel, Jia-Ju Bai

sxgbe_sw_reset() is never called in atomic context.

sxgbe_sw_reset() is only called by sxgbe_drv_probe(), which is 
only called by sxgbe_platform_probe().
sxgbe_platform_probe() is set as ".probe" in struct platform_driver.
This function is not called in atomic context.

Despite never getting called from atomic context, sxgbe_sw_reset()
calls mdelay() to busily wait.
This is not necessary and can be replaced with usleep_range() 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/net/ethernet/samsung/sxgbe/sxgbe_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 89831ad..99cd586 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -2038,7 +2038,7 @@ static int sxgbe_sw_reset(void __iomem *addr)
 		if (!(readl(addr + SXGBE_DMA_MODE_REG) &
 		      SXGBE_DMA_SOFT_RESET))
 			break;
-		mdelay(10);
+		usleep(10000, 11000);
 	}
 
 	if (retry_count < 0)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset
  2018-04-11  2:21 [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset Jia-Ju Bai
@ 2018-04-11 15:50 ` kbuild test robot
  2018-04-11 15:52 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-04-11 15:50 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: kbuild-all, bh74.an, ks.giri, vipul.pandya, netdev, linux-kernel,
	Jia-Ju Bai

[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

Hi Jia-Ju,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.16 next-20180411]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jia-Ju-Bai/net-samsung-sxgbe-Replace-mdelay-with-usleep_range-in-sxgbe_sw_reset/20180411-225900
config: i386-randconfig-x019-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c: In function 'sxgbe_sw_reset':
>> drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c:2039:3: error: implicit declaration of function 'usleep'; did you mean 'ssleep'? [-Werror=implicit-function-declaration]
      usleep(10000, 11000);
      ^~~~~~
      ssleep
   cc1: some warnings being treated as errors

vim +2039 drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c

  2029	
  2030	static int sxgbe_sw_reset(void __iomem *addr)
  2031	{
  2032		int retry_count = 10;
  2033	
  2034		writel(SXGBE_DMA_SOFT_RESET, addr + SXGBE_DMA_MODE_REG);
  2035		while (retry_count--) {
  2036			if (!(readl(addr + SXGBE_DMA_MODE_REG) &
  2037			      SXGBE_DMA_SOFT_RESET))
  2038				break;
> 2039			usleep(10000, 11000);
  2040		}
  2041	
  2042		if (retry_count < 0)
  2043			return -EBUSY;
  2044	
  2045		return 0;
  2046	}
  2047	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32699 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset
  2018-04-11  2:21 [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset Jia-Ju Bai
  2018-04-11 15:50 ` kbuild test robot
@ 2018-04-11 15:52 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-04-11 15:52 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: kbuild-all, bh74.an, ks.giri, vipul.pandya, netdev, linux-kernel,
	Jia-Ju Bai

[-- Attachment #1: Type: text/plain, Size: 1639 bytes --]

Hi Jia-Ju,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.16 next-20180411]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jia-Ju-Bai/net-samsung-sxgbe-Replace-mdelay-with-usleep_range-in-sxgbe_sw_reset/20180411-225900
config: i386-randconfig-s1-201814 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c: In function 'sxgbe_sw_reset':
>> drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c:2039:3: error: implicit declaration of function 'usleep' [-Werror=implicit-function-declaration]
      usleep(10000, 11000);
      ^~~~~~
   cc1: some warnings being treated as errors

vim +/usleep +2039 drivers/net//ethernet/samsung/sxgbe/sxgbe_main.c

  2029	
  2030	static int sxgbe_sw_reset(void __iomem *addr)
  2031	{
  2032		int retry_count = 10;
  2033	
  2034		writel(SXGBE_DMA_SOFT_RESET, addr + SXGBE_DMA_MODE_REG);
  2035		while (retry_count--) {
  2036			if (!(readl(addr + SXGBE_DMA_MODE_REG) &
  2037			      SXGBE_DMA_SOFT_RESET))
  2038				break;
> 2039			usleep(10000, 11000);
  2040		}
  2041	
  2042		if (retry_count < 0)
  2043			return -EBUSY;
  2044	
  2045		return 0;
  2046	}
  2047	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24019 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-11 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11  2:21 [PATCH] net: samsung: sxgbe: Replace mdelay with usleep_range in sxgbe_sw_reset Jia-Ju Bai
2018-04-11 15:50 ` kbuild test robot
2018-04-11 15:52 ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.