Microsecond Sleep in Linux kernel

独自空忆成欢 提交于 2019-12-08 06:33:38

问题


udelay(), mdelay(), usleep_range() all are giving run time errors:

symbol lookup error: undefined symbol: __const_udelay

I'm trying with ns3-DCE-linux, hence I'm able to see the error but in Linux Kernel, I get a kernel panic.

From here udelay() is defined as a macro.

#define udelay(n)                                                \
 ({                                                              \
         if (__builtin_constant_p(n)) {                          \
                 if ((n) / 20000 >= 1)                           \
                          __bad_udelay();                        \
                 else                                            \
                         __const_udelay((n) * 0x10c7ul);         \
         } else {                                                \
                 __udelay(n);                                    \
         }                                                       \
 })

From here mdelay() is defined as a macro which uses udelay().

#ifndef mdelay
#define mdelay(n) (\
        (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
        ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
#endif

usleep_range() also uses udelay() after a long tracking.

I can clearly see definition of __const_udelay() here.

inline void __const_udelay(unsigned long xloops)
 {
         int d0;

         xloops *= 4;
         asm("mull %%edx"
                 :"=d" (xloops), "=&a" (d0)
                 :"1" (xloops), ""
                 (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));

         __delay(++xloops);
 }
 EXPORT_SYMBOL(__const_udelay);

and included as extern here.

extern void __const_udelay(unsigned long xloops);

The only thing working is msleep().

Is there anyway I can give a few microsecond sleep in kernel? (delay or sleep. But sleep is preferable.)

What is the reason of above error? Is this hardware dependent? How to solve the error?

来源:https://stackoverflow.com/questions/32264257/microsecond-sleep-in-linux-kernel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!