timer_test.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. #include <linux/init.h>
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>
  4. #include <linux/rtpm_prio.h>
  5. #include <linux/version.h>
  6. #include <linux/kernel.h>
  7. #include <linux/sched.h>
  8. #include <linux/kthread.h>
  9. #include <linux/delay.h>
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/proc_fs.h>
  13. #include <linux/string.h>
  14. #include <linux/uaccess.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/rtpm_prio.h>
  17. #include <linux/rtc.h>
  18. #include <linux/cpu.h>
  19. #include <linux/hrtimer.h>
  20. #include <linux/init.h>
  21. #include <linux/module.h>
  22. #include <linux/kernel.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/proc_fs.h>
  27. #include <linux/syscore_ops.h>
  28. #include <asm/sched_clock.h>
  29. #include <linux/version.h>
  30. #include <mach/mt_reg_base.h>
  31. #include <mach/mt_gpt.h>
  32. #include <mach/mt_timer.h>
  33. #include <mach/irqs.h>
  34. #include <mach/mt_cpuxgpt.h>
  35. #include <mach/ext_wd_drv.h>
  36. #if 0 /*this file only to do HW test*/
  37. /* extern int nr_cpu_ids; */
  38. /* int enable_clock(int id, unsigned char *name); */
  39. static int test_case;
  40. static int ts_msleep;
  41. static int msleep_times;
  42. static int ts_mdelay;
  43. static int mdelay_times;
  44. static int ts_udelay;
  45. static int udelay_times;
  46. static long ts_hrtimer_sec;
  47. static unsigned long ts_hrtimer_nsecs;
  48. static int ts_hrtimer_times;
  49. static struct hrtimer hrtimer_test;
  50. u64 hr_t1 = 0;
  51. u64 hr_t2 = 0;
  52. module_param(test_case, int, 0664);
  53. module_param(ts_msleep, int, 0664);
  54. module_param(msleep_times, int, 0664);
  55. module_param(ts_mdelay, int, 0664);
  56. module_param(mdelay_times, int, 0664);
  57. module_param(ts_udelay, int, 0664);
  58. module_param(udelay_times, int, 0664);
  59. module_param(ts_hrtimer_sec, int, 0664);
  60. module_param(ts_hrtimer_nsecs, int, 0664);
  61. module_param(ts_hrtimer_times, int, 0664);
  62. static DEFINE_SPINLOCK(wdt_test_lock0);
  63. static DEFINE_SPINLOCK(wdt_test_lock1);
  64. static struct task_struct *wk_tsk[2];/* cpu: 2 */
  65. static int data;
  66. static int hrtimer_test_case(void);
  67. static int __cpuinit
  68. cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
  69. {
  70. int hotcpu = (unsigned long)hcpu;
  71. switch (action) {
  72. case CPU_UP_PREPARE:
  73. case CPU_UP_PREPARE_FROZEN:
  74. /* watchdog_prepare_cpu(hotcpu); */
  75. break;
  76. case CPU_ONLINE:
  77. case CPU_ONLINE_FROZEN:
  78. /* */
  79. if (hotcpu < nr_cpu_ids) {
  80. kthread_bind(wk_tsk[hotcpu], hotcpu);
  81. wake_up_process(wk_tsk[hotcpu]);
  82. pr_debug("[WDK-test]cpu %d plug on ", hotcpu);
  83. }
  84. break;
  85. #ifdef CONFIG_HOTPLUG_CPU
  86. case CPU_UP_CANCELED:
  87. case CPU_UP_CANCELED_FROZEN:
  88. case CPU_DEAD:
  89. case CPU_DEAD_FROZEN:
  90. pr_debug("[WDK-test]:start Stop CPU:%d\n", hotcpu);
  91. break;
  92. #endif /* CONFIG_HOTPLUG_CPU */
  93. }
  94. /*
  95. * hardlockup and softlockup are not important enough
  96. * to block cpu bring up. Just always succeed and
  97. * rely on printk output to flag problems.
  98. */
  99. return NOTIFY_OK;
  100. }
  101. static struct notifier_block cpu_nfb __cpuinitdata = {
  102. .notifier_call = cpu_callback
  103. };
  104. static int msleep_test(int length, int times)
  105. {
  106. u64 t1 = 0;
  107. u64 t2 = 0;
  108. int i = 0;
  109. t1 = sched_clock();
  110. for (i = 0; i < times; i++)
  111. msleep(length);
  112. t2 = sched_clock();
  113. pr_debug("msleep_test, msleep(%d) test %d times\n", length, times);
  114. pr_debug("msleep_test: t1 =%lld, t2=%lld, delta=%lld\n", t1, t2, t2-t1);
  115. }
  116. static int udelay_test(int length, int times)
  117. {
  118. u64 t1 = 0;
  119. u64 t2 = 0;
  120. int i = 0;
  121. t1 = sched_clock();
  122. for (i = 0; i < times; i++)
  123. udelay(length);
  124. t2 = sched_clock();
  125. pr_debug("udelay_test, udelay_test(%d) test %d times\n", length, times);
  126. pr_debug("udelay_test :t1 =%lld, t2=%lld, delta=%lld\n", t1, t2, t2-t1);
  127. }
  128. static int mdelay_test(int length, int times)
  129. {
  130. u64 t1 = 0;
  131. u64 t2 = 0;
  132. int i = 0;
  133. t1 = sched_clock();
  134. for (i = 0; i < times; i++)
  135. mdelay(length);
  136. t2 = sched_clock();
  137. pr_debug("mdelay_test, mdelay_test(%d) test %d times\n", length, times);
  138. pr_debug("mdelay_test:t1 =%lld, t2=%lld, delta=%lld\n", t1, t2, t2-t1);
  139. }
  140. #define read_cntpct(cntpct_lo, cntpct_hi) \
  141. __asm__ __volatile__( \
  142. "MRRC p15, 0, %0, %1, c14\n" \
  143. : "=r"(cntpct_lo), "=r"(cntpct_hi) \
  144. : \
  145. : "memory"); \
  146. static int phycical_count_test(void)
  147. {
  148. unsigned int cntpct_lo1 = 0;
  149. unsigned int cntpct_hi1 = 0;
  150. unsigned int cntpct_lo2 = 0;
  151. unsigned int cntpct_hi2 = 0;
  152. pr_debug("phycical_count_test start\n");
  153. while (1) {
  154. read_cntpct(cntpct_lo1, cntpct_hi1);
  155. read_cntpct(cntpct_lo2, cntpct_hi2);
  156. if (cntpct_hi2 == cntpct_hi1) {
  157. if (cntpct_lo2 < cntpct_lo1) {
  158. if (0xffff == cntpct_lo1) {
  159. pr_debug("fwq 0 by pass bug cntpct_hi1=%u,cntpct_lo1=%u, cntpct_hi2=%u,cntpct_lo2=%u\n",
  160. cntpct_hi1, cntpct_lo1, cntpct_hi2, cntpct_lo2);
  161. continue;
  162. }
  163. pr_debug("fwq 1 cntpct_hi1=%d,cntpct_lo1=%d, cntpct_hi2=%d,cntpct_lo2=%d\n",
  164. cntpct_hi1, cntpct_lo1, cntpct_hi2, cntpct_lo2);
  165. /* break; */
  166. }
  167. }
  168. if (cntpct_hi2 < cntpct_hi1) {
  169. pr_debug("fwq 2 cntpct_hi1=%d,cntpct_lo1=%d, cntpct_hi2=%d,cntpct_lo2=%d\n",
  170. cntpct_hi1, cntpct_lo1, cntpct_hi2, cntpct_lo2);
  171. /* break; */
  172. }
  173. }
  174. pr_debug("phycical_count_test end\n");
  175. }
  176. #define GPT_IRQEN (APXGPT_BASE + 0x0000)
  177. #define GPT_IRQSTA (APXGPT_BASE + 0x0004)
  178. #define GPT_IRQACK (APXGPT_BASE + 0x0008)
  179. static int dump_gpt_reg(void)
  180. {
  181. pr_debug("IRQ STA %x\n", DRV_Reg32(GPT_IRQSTA));
  182. pr_debug("IRQ EN %x\n", DRV_Reg32(GPT_IRQEN));
  183. pr_debug("IRQ ACK %x\n", DRV_Reg32(GPT_IRQACK));
  184. pr_debug("GPT3 clk %x\n", DRV_Reg32(0xF0008034));
  185. pr_debug("GPT3 con %x\n", DRV_Reg32(0xF0008030));
  186. pr_debug("GPT3 count %x\n", DRV_Reg32(0xF0008038));
  187. pr_debug("GPT3 cmp %x\n", DRV_Reg32(0xF000803c));
  188. }
  189. static int dump_gpt1_reg(void)
  190. {
  191. pr_debug("IRQ STA %x\n", DRV_Reg32(GPT_IRQSTA));
  192. pr_debug("IRQ EN %x\n", DRV_Reg32(GPT_IRQEN));
  193. pr_debug("IRQ ACK %x\n", DRV_Reg32(GPT_IRQACK));
  194. pr_debug("GPT3 clk %x\n", DRV_Reg32(0xF0008014));
  195. pr_debug("GPT3 con %x\n", DRV_Reg32(0xF0008010));
  196. pr_debug("GPT3 count %x\n", DRV_Reg32(0xF0008018));
  197. pr_debug("GPT3 cmp %x\n", DRV_Reg32(0xF000801c));
  198. }
  199. u64 cpuxgpt_t1 = 0;
  200. u64 cpuxgpt_t2 = 0;
  201. int g_cpuxgpt0_called = 0;
  202. int g_cpuxgpt1_called = 0;
  203. int g_cpuxgpt2_called = 0;
  204. static irqreturn_t cpuxgpt_test_irq_handler(int irq, void *dev_id)
  205. {
  206. cpuxgpt_t2 = sched_clock();
  207. g_cpuxgpt0_called = 1;
  208. pr_debug("cpuxgpt irq:%d called\n", irq);
  209. pr_debug("cpuxgpt t2(%lld),t1(%lld),delta(%lld)\n", cpuxgpt_t2, cpuxgpt_t1, cpuxgpt_t2-cpuxgpt_t1);
  210. return IRQ_HANDLED;
  211. }
  212. #if 1
  213. static irqreturn_t cpuxgpt1_test_irq_handler(int irq, void *dev_id)
  214. {
  215. g_cpuxgpt1_called = 1;
  216. pr_debug("cpuxgpt1 irq called\n");
  217. return IRQ_HANDLED;
  218. }
  219. static irqreturn_t cpuxgpt2_test_irq_handler(int irq, void *dev_id)
  220. {
  221. g_cpuxgpt2_called = 1;
  222. pr_debug("cpuxgpt2 irq called\n");
  223. return IRQ_HANDLED;
  224. }
  225. static irqreturn_t cpuxgpt3_test_irq_handler(int irq, void *dev_id)
  226. {
  227. pr_debug("cpuxgpt3 irq called\n");
  228. return IRQ_HANDLED;
  229. }
  230. static irqreturn_t cpuxgpt4_test_irq_handler(int irq, void *dev_id)
  231. {
  232. pr_debug("cpuxgpt4 irq called\n");
  233. return IRQ_HANDLED;
  234. }
  235. static irqreturn_t cpuxgpt5_test_irq_handler(int irq, void *dev_id)
  236. {
  237. pr_debug("cpuxgpt5 irq called\n");
  238. return IRQ_HANDLED;
  239. }
  240. static irqreturn_t cpuxgpt6_test_irq_handler(int irq, void *dev_id)
  241. {
  242. pr_debug("cpuxgpt6 irq called\n");
  243. return IRQ_HANDLED;
  244. }
  245. static irqreturn_t cpuxgpt7_test_irq_handler(int irq, void *dev_id)
  246. {
  247. pr_debug("cpuxgpt7 irq called\n");
  248. return IRQ_HANDLED;
  249. }
  250. #endif
  251. void generic_timer_ppi_check(void)
  252. {
  253. disable_cpuxgpt();
  254. cpu_xgpt_set_init_count(0x80000000, 0xffffff00);
  255. enable_cpuxgpt();
  256. }
  257. static cpuxgpt_X_interrupt_test(int cpu)
  258. {
  259. disable_cpuxgpt();
  260. cpu_xgpt_set_init_count(0x80000000, 0xffffff00);
  261. /* cpu_xgpt_register_timer(cpu,cpuxgpt_test_irq_handler); */
  262. cpu_xgpt_register_timer(1, cpuxgpt1_test_irq_handler);
  263. cpu_xgpt_register_timer(2, cpuxgpt2_test_irq_handler);
  264. cpu_xgpt_register_timer(3, cpuxgpt3_test_irq_handler);
  265. cpu_xgpt_register_timer(4, cpuxgpt4_test_irq_handler);
  266. cpu_xgpt_register_timer(5, cpuxgpt5_test_irq_handler);
  267. cpu_xgpt_register_timer(6, cpuxgpt6_test_irq_handler);
  268. cpu_xgpt_register_timer(7, cpuxgpt7_test_irq_handler);
  269. /* */
  270. cpu_xgpt_set_cmp_HL(cpu, 0x80000001, 0x00000100);
  271. cpuxgpt_t1 = sched_clock();
  272. enable_cpuxgpt();
  273. /*wait for interrupt trigger, timeout:(0,0x80000001,0x00000100) - (0x80000000,0xffffff00)*/
  274. msleep(20);
  275. }
  276. static cpuxgpt_interrupt_test(void)
  277. {
  278. int i = 0;
  279. /* for(i = 0; i < 8; i++) */
  280. /* { */
  281. cpuxgpt_X_interrupt_test(i);
  282. /* } */
  283. /* test_case = 0; */
  284. }
  285. static void cpuxgpt_frequency_test(void)
  286. {
  287. /* long long delta1 = 0; */
  288. /* long long delta2 = 0; */
  289. /* div1 */
  290. #define TIMEOUT (13000000) /* 1s = 13M */
  291. set_cpuxgpt_clk(CLK_DIV2);
  292. disable_cpuxgpt();
  293. cpu_xgpt_set_init_count(0x00000000, 0x00000000);
  294. /* set_cpuxgpt_clk(CLK_DIV1); */
  295. cpu_xgpt_register_timer(0, cpuxgpt_test_irq_handler);
  296. cpu_xgpt_set_cmp_HL(0, 0x00000000, TIMEOUT);
  297. cpuxgpt_t1 = sched_clock();
  298. set_cpuxgpt_clk(CLK_DIV1);
  299. enable_cpuxgpt();
  300. while (0 == g_cpuxgpt0_called) {
  301. msleep(20);
  302. pr_debug("busy wait\n");
  303. }
  304. g_cpuxgpt0_called = 0;
  305. pr_debug("cpuxgpt0-div1 t2(%lld),t1(%lld),delta(%lld)\n", cpuxgpt_t2, cpuxgpt_t1, cpuxgpt_t2-cpuxgpt_t1);
  306. #if 1
  307. msleep(1000);
  308. /* div2 */
  309. disable_cpuxgpt();
  310. cpu_xgpt_set_init_count(0x00000000, 0x00000000);
  311. /* set_cpuxgpt_clk(CLK_DIV2); */
  312. cpu_xgpt_set_cmp_HL(0, 0x00000000, TIMEOUT);
  313. cpuxgpt_t1 = sched_clock();
  314. set_cpuxgpt_clk(CLK_DIV2);
  315. enable_cpuxgpt();
  316. while (0 == g_cpuxgpt0_called) {
  317. msleep(20);
  318. pr_debug("busy wait\n");
  319. }
  320. g_cpuxgpt0_called = 0;
  321. pr_debug("cpuxgpt0-div2 t2(%lld),t1(%lld),delta(%lld)\n", cpuxgpt_t2, cpuxgpt_t1, cpuxgpt_t2-cpuxgpt_t1);
  322. msleep(1000);
  323. /* div3 */
  324. disable_cpuxgpt();
  325. cpu_xgpt_set_init_count(0x00000000, 0x00000000);
  326. /* set_cpuxgpt_clk(CLK_DIV4); */
  327. cpu_xgpt_set_cmp_HL(0, 0x00000000, TIMEOUT);
  328. cpuxgpt_t1 = sched_clock();
  329. set_cpuxgpt_clk(CLK_DIV4);
  330. enable_cpuxgpt();
  331. while (0 == g_cpuxgpt0_called) {
  332. msleep(20);
  333. pr_debug("busy wait\n");
  334. }
  335. g_cpuxgpt0_called = 0;
  336. pr_debug("cpuxgpt0-div4 t2(%lld),t1(%lld),delta(%lld)\n", cpuxgpt_t2, cpuxgpt_t1, cpuxgpt_t2-cpuxgpt_t1);
  337. #endif
  338. }
  339. void cpuxgpt_halt_on_debug_test(void)
  340. {
  341. unsigned int cntpct_lo1 = 0;
  342. unsigned int cntpct_hi1 = 0;
  343. disable_cpuxgpt();
  344. cpu_xgpt_set_init_count(0x00000000, 0x00000000);
  345. set_cpuxgpt_clk(CLK_DIV1);
  346. enable_cpuxgpt();
  347. cpu_xgpt_halt_on_debug_en(1);
  348. /*
  349. read_cntpct(cntpct_lo1, cntpct_hi1);
  350. localtimer_get_phy_count();
  351. read_cntpct(cntpct_lo1, cntpct_hi1);
  352. localtimer_get_phy_count();
  353. pr_debug("11111 ca7 counter(%u,%u) == %lld\n", cntpct_hi1,cntpct_lo1,localtimer_get_phy_count() );
  354. read_cntpct(cntpct_lo1, cntpct_hi1);
  355. pr_debug("22222 ca7 counter(%u,%u) == %lld\n", cntpct_hi1,cntpct_lo1,localtimer_get_phy_count() );
  356. read_cntpct(cntpct_lo1, cntpct_hi1);
  357. pr_debug("33333 ca7 counter(%u,%u) == %lld\n", cntpct_hi1,cntpct_lo1,localtimer_get_phy_count() );
  358. read_cntpct(cntpct_lo1, cntpct_hi1);
  359. pr_debug("44444 ca7 counter(%u,%u) == %lld\n", cntpct_hi1,cntpct_lo1,localtimer_get_phy_count() );
  360. */
  361. }
  362. static void cpuxgpt_test_case_help(void)
  363. {
  364. pr_debug("1:cpuxgpt_interrupt_test\n");
  365. pr_debug("2:cpuxgpt_frequency_test\n");
  366. pr_debug("3: cpuxgpt_halt_on_debug_test\n");
  367. }
  368. void cpuxgpt_run_case(int testcase)
  369. {
  370. switch (testcase) {
  371. case 0:
  372. cpuxgpt_test_case_help();
  373. break;
  374. case 1:
  375. cpuxgpt_interrupt_test();
  376. break;
  377. case 2:
  378. cpuxgpt_frequency_test();
  379. break;
  380. case 3:
  381. cpuxgpt_halt_on_debug_test();
  382. break;
  383. case 4:
  384. generic_timer_ppi_check();
  385. break;
  386. default:
  387. pr_debug("[%s] invalid testcase\n", __func__);
  388. }
  389. test_case = 0;
  390. }
  391. static int idx;
  392. static int ktimer_thread_test(void *arg)
  393. {
  394. struct sched_param param = { .sched_priority = RTPM_PRIO_WDT};
  395. int cpu;
  396. unsigned int flags;
  397. int ret = 0;
  398. unsigned int cntpct_lo1 = 0;
  399. unsigned int cntpct_hi1 = 0;
  400. static unsigned int last_cntpct_lo1;
  401. static unsigned int last_cntpct_hi1;
  402. int i = 0;
  403. sched_setscheduler(current, SCHED_FIFO, &param);
  404. set_current_state(TASK_INTERRUPTIBLE);
  405. for (;;) {
  406. spin_lock(&wdt_test_lock0);
  407. cpu = smp_processor_id();
  408. spin_unlock(&wdt_test_lock0);
  409. pr_debug("timer test debug start, cpu:%d\n", cpu);
  410. /* phycical_count_test(); */
  411. cpuxgpt_run_case(test_case);
  412. if (ts_msleep != 0) {
  413. /* pr_debug("CPU:%d, msleep(%d) test\n", cpu,ts_msleep); */
  414. if (0 != msleep_times) {
  415. msleep_test(ts_msleep, msleep_times);
  416. else
  417. msleep_test(ts_msleep, 1);
  418. }
  419. if (ts_mdelay != 0) {
  420. /* pr_debug("CPU:%d, mdelay(%d) test\n", cpu,ts_mdelay); */
  421. if (0 != mdelay_times) {
  422. mdelay_test(ts_mdelay, mdelay_times);
  423. else
  424. mdelay_test(ts_mdelay, 1);
  425. }
  426. if (ts_udelay != 0) {
  427. /* pr_debug("CPU:%d, udelay(%d) test\n", cpu,ts_udelay); */
  428. if (0 != udelay_times)
  429. udelay_test(ts_udelay, udelay_times);
  430. else
  431. udelay_test(ts_udelay, 1);
  432. }
  433. if (ts_hrtimer_nsecs != 0 || ts_hrtimer_sec != 0)
  434. hrtimer_test_case();
  435. msleep(5*1000);/* 5s */
  436. read_cntpct(cntpct_lo1, cntpct_hi1);
  437. pr_debug("ca7 counter(%u,%u) == %lld\n", cntpct_hi1, cntpct_lo1, localtimer_get_phy_count());
  438. /* pr_debug("cpuxgpt(%d) set 100ms timer,idx=%d\n" ,idx%8,idx); */
  439. /* cpu_xgpt_set_timer(idx%8,100000000); */
  440. /* idx++; */
  441. pr_debug("timer test debug end, cpu:%d\n", cpu);
  442. #if 0
  443. pr_debug("fwq2 before set\n");
  444. dump_gpt_reg();
  445. pr_debug("set gpt3 5s oneshot\n");
  446. DRV_WriteReg32(0xF0008000, 0x7);
  447. DRV_WriteReg32(0xF0008030, 0x0);
  448. DRV_WriteReg32(0xF0008038, 0x0);
  449. DRV_WriteReg32(0xF0008034, 0x0);
  450. DRV_WriteReg32(0xF000803c, 0x1c9c380);
  451. DRV_WriteReg32(0xF0008030, 0x3);
  452. read_cntpct(cntpct_lo1, cntpct_hi1);
  453. if (cntpct_hi1 == last_cntpct_hi1 && cntpct_lo1 == last_cntpct_lo1)
  454. pr_debug("fwq local count error !!!\n");
  455. last_cntpct_hi1 = cntpct_hi1;
  456. last_cntpct_lo1 = cntpct_lo1;
  457. pr_debug("ca7 counter(%u,%u), cpu:%d\n", cntpct_hi1, cntpct_lo1);
  458. pr_debug("timer test debug end, cpu:%d\n", cpu);
  459. #endif
  460. }
  461. return 0;
  462. }
  463. static enum hrtimer_restart hrtimer_test_func(struct hrtimer *timer)
  464. {
  465. hr_t2 = sched_clock();
  466. pr_debug("[hrtimer_test_func] t1=%lld,t2 =%lld\n", hr_t1, hr_t2);
  467. pr_debug("[hrtimer_test_func] delta=%lld\n", hr_t2-hr_t1);
  468. return HRTIMER_NORESTART;
  469. }
  470. static int hrtimer_test_case(void)
  471. {
  472. int ret = 0;
  473. int value = 0;
  474. pr_debug("hrtimer_test_case:ts_hrtimer_sec=%ld, ts_hrtimer_nsecs=%ld\n", ts_hrtimer_sec, ts_hrtimer_nsecs);
  475. hr_t1 = sched_clock();
  476. hrtimer_start(&hrtimer_test, ktime_set(ts_hrtimer_sec, ts_hrtimer_nsecs), HRTIMER_MODE_REL);
  477. }
  478. static int start_kicker(void)
  479. {
  480. int i;
  481. unsigned char name[15] = {0};
  482. hrtimer_init(&hrtimer_test, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  483. hrtimer_test.function = hrtimer_test_func;
  484. for (i = 0; i < 1; i++) {
  485. sprintf(name, "timer-test%d", i);
  486. pr_debug("[Timer]:thread name: %s\n", name);
  487. wk_tsk[i] = kthread_create(ktimer_thread_test, &data, name);
  488. if (IS_ERR(wk_tsk[i])) {
  489. int ret = PTR_ERR(wk_tsk[i]);
  490. wk_tsk[i] = NULL;
  491. return ret;
  492. }
  493. kthread_bind(wk_tsk[i], i);
  494. wake_up_process(wk_tsk[i]);
  495. }
  496. return 0;
  497. }
  498. static int __init test_init(void)
  499. {
  500. /* enable_clock(12, "Vfifo"); */
  501. /* register_cpu_notifier(&cpu_nfb); */
  502. start_kicker();
  503. return 0;
  504. }
  505. static void __init test_exit(void)
  506. {
  507. }
  508. #if 0
  509. int TimerUT_proc_init(void)
  510. {
  511. struct proc_dir_entry *de = create_proc_entry(PROC_WK, 0660, 0);
  512. pr_debug("[WDK] Initialize proc\n");
  513. de->read_proc = wk_proc_cmd_read;
  514. de->write_proc = wk_proc_cmd_write;
  515. return 0;
  516. }
  517. void TimerUT_proc_exit(void)
  518. {
  519. remove_proc_entry(PROC_WK, NULL);
  520. }
  521. #endif
  522. module_init(test_init);
  523. module_exit(test_exit);
  524. #endif