tick-broadcast.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. * linux/kernel/time/tick-broadcast.c
  3. *
  4. * This file contains functions which emulate a local clock-event
  5. * device via a broadcast event source.
  6. *
  7. * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
  8. * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
  9. * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner
  10. *
  11. * This code is licenced under the GPL version 2. For details see
  12. * kernel-base/COPYING.
  13. */
  14. #include <linux/cpu.h>
  15. #include <linux/err.h>
  16. #include <linux/hrtimer.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/percpu.h>
  19. #include <linux/profile.h>
  20. #include <linux/sched.h>
  21. #include <linux/smp.h>
  22. #include "tick-internal.h"
  23. /*
  24. * Broadcast support for broken x86 hardware, where the local apic
  25. * timer stops in C3 state.
  26. */
  27. static struct tick_device tick_broadcast_device;
  28. /* FIXME: Use cpumask_var_t. */
  29. static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS);
  30. static DECLARE_BITMAP(tmpmask, NR_CPUS);
  31. static DEFINE_RAW_SPINLOCK(tick_broadcast_lock);
  32. static int tick_broadcast_force;
  33. #ifdef CONFIG_TICK_ONESHOT
  34. static void tick_broadcast_clear_oneshot(int cpu);
  35. #else
  36. static inline void tick_broadcast_clear_oneshot(int cpu) { }
  37. #endif
  38. /*
  39. * Debugging: see timer_list.c
  40. */
  41. struct tick_device *tick_get_broadcast_device(void)
  42. {
  43. return &tick_broadcast_device;
  44. }
  45. struct cpumask *tick_get_broadcast_mask(void)
  46. {
  47. return to_cpumask(tick_broadcast_mask);
  48. }
  49. /*
  50. * Start the device in periodic mode
  51. */
  52. static void tick_broadcast_start_periodic(struct clock_event_device *bc)
  53. {
  54. if (bc)
  55. tick_setup_periodic(bc, 1);
  56. }
  57. /*
  58. * Check, if the device can be utilized as broadcast device:
  59. */
  60. int tick_check_broadcast_device(struct clock_event_device *dev)
  61. {
  62. if ((tick_broadcast_device.evtdev &&
  63. tick_broadcast_device.evtdev->rating >= dev->rating) ||
  64. (dev->features & CLOCK_EVT_FEAT_C3STOP))
  65. return 0;
  66. clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
  67. tick_broadcast_device.evtdev = dev;
  68. if (!cpumask_empty(tick_get_broadcast_mask()))
  69. tick_broadcast_start_periodic(dev);
  70. return 1;
  71. }
  72. /*
  73. * Check, if the device is the broadcast device
  74. */
  75. int tick_is_broadcast_device(struct clock_event_device *dev)
  76. {
  77. return (dev && tick_broadcast_device.evtdev == dev);
  78. }
  79. static void err_broadcast(const struct cpumask *mask)
  80. {
  81. pr_crit_once("Failed to broadcast timer tick. Some CPUs may be unresponsive.\n");
  82. }
  83. static void tick_device_setup_broadcast_func(struct clock_event_device *dev)
  84. {
  85. if (!dev->broadcast)
  86. dev->broadcast = tick_broadcast;
  87. if (!dev->broadcast) {
  88. pr_warn_once("%s depends on broadcast, but no broadcast function available\n",
  89. dev->name);
  90. dev->broadcast = err_broadcast;
  91. }
  92. }
  93. /*
  94. * Check, if the device is disfunctional and a place holder, which
  95. * needs to be handled by the broadcast device.
  96. */
  97. int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
  98. {
  99. unsigned long flags;
  100. int ret = 0;
  101. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  102. /*
  103. * Devices might be registered with both periodic and oneshot
  104. * mode disabled. This signals, that the device needs to be
  105. * operated from the broadcast device and is a placeholder for
  106. * the cpu local device.
  107. */
  108. if (!tick_device_is_functional(dev)) {
  109. dev->event_handler = tick_handle_periodic;
  110. tick_device_setup_broadcast_func(dev);
  111. cpumask_set_cpu(cpu, tick_get_broadcast_mask());
  112. tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
  113. ret = 1;
  114. } else {
  115. /*
  116. * When the new device is not affected by the stop
  117. * feature and the cpu is marked in the broadcast mask
  118. * then clear the broadcast bit.
  119. */
  120. if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
  121. int cpu = smp_processor_id();
  122. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  123. tick_broadcast_clear_oneshot(cpu);
  124. } else {
  125. tick_device_setup_broadcast_func(dev);
  126. }
  127. }
  128. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  129. return ret;
  130. }
  131. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  132. int tick_receive_broadcast(void)
  133. {
  134. struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
  135. struct clock_event_device *evt = td->evtdev;
  136. if (!evt)
  137. return -ENODEV;
  138. if (!evt->event_handler)
  139. return -EINVAL;
  140. evt->event_handler(evt);
  141. return 0;
  142. }
  143. #endif
  144. /*
  145. * Broadcast the event to the cpus, which are set in the mask (mangled).
  146. */
  147. static void tick_do_broadcast(struct cpumask *mask)
  148. {
  149. int cpu = smp_processor_id();
  150. struct tick_device *td;
  151. /*
  152. * Check, if the current cpu is in the mask
  153. */
  154. if (cpumask_test_cpu(cpu, mask)) {
  155. cpumask_clear_cpu(cpu, mask);
  156. td = &per_cpu(tick_cpu_device, cpu);
  157. td->evtdev->event_handler(td->evtdev);
  158. }
  159. if (!cpumask_empty(mask)) {
  160. /*
  161. * It might be necessary to actually check whether the devices
  162. * have different broadcast functions. For now, just use the
  163. * one of the first device. This works as long as we have this
  164. * misfeature only on x86 (lapic)
  165. */
  166. td = &per_cpu(tick_cpu_device, cpumask_first(mask));
  167. td->evtdev->broadcast(mask);
  168. }
  169. }
  170. /*
  171. * Periodic broadcast:
  172. * - invoke the broadcast handlers
  173. */
  174. static void tick_do_periodic_broadcast(void)
  175. {
  176. raw_spin_lock(&tick_broadcast_lock);
  177. cpumask_and(to_cpumask(tmpmask),
  178. cpu_online_mask, tick_get_broadcast_mask());
  179. tick_do_broadcast(to_cpumask(tmpmask));
  180. raw_spin_unlock(&tick_broadcast_lock);
  181. }
  182. /*
  183. * Event handler for periodic broadcast ticks
  184. */
  185. static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
  186. {
  187. ktime_t next;
  188. tick_do_periodic_broadcast();
  189. /*
  190. * The device is in periodic mode. No reprogramming necessary:
  191. */
  192. if (dev->mode == CLOCK_EVT_MODE_PERIODIC)
  193. return;
  194. /*
  195. * Setup the next period for devices, which do not have
  196. * periodic mode. We read dev->next_event first and add to it
  197. * when the event already expired. clockevents_program_event()
  198. * sets dev->next_event only when the event is really
  199. * programmed to the device.
  200. */
  201. for (next = dev->next_event; ;) {
  202. next = ktime_add(next, tick_period);
  203. if (!clockevents_program_event(dev, next, false))
  204. return;
  205. tick_do_periodic_broadcast();
  206. }
  207. }
  208. /*
  209. * Powerstate information: The system enters/leaves a state, where
  210. * affected devices might stop
  211. */
  212. static void tick_do_broadcast_on_off(unsigned long *reason)
  213. {
  214. struct clock_event_device *bc, *dev;
  215. struct tick_device *td;
  216. unsigned long flags;
  217. int cpu, bc_stopped;
  218. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  219. cpu = smp_processor_id();
  220. td = &per_cpu(tick_cpu_device, cpu);
  221. dev = td->evtdev;
  222. bc = tick_broadcast_device.evtdev;
  223. /*
  224. * Is the device not affected by the powerstate ?
  225. */
  226. if (!dev || !(dev->features & CLOCK_EVT_FEAT_C3STOP))
  227. goto out;
  228. if (!tick_device_is_functional(dev))
  229. goto out;
  230. bc_stopped = cpumask_empty(tick_get_broadcast_mask());
  231. switch (*reason) {
  232. case CLOCK_EVT_NOTIFY_BROADCAST_ON:
  233. case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
  234. if (!cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
  235. cpumask_set_cpu(cpu, tick_get_broadcast_mask());
  236. if (tick_broadcast_device.mode ==
  237. TICKDEV_MODE_PERIODIC)
  238. clockevents_shutdown(dev);
  239. }
  240. if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE)
  241. tick_broadcast_force = 1;
  242. break;
  243. case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
  244. if (!tick_broadcast_force &&
  245. cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
  246. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  247. if (tick_broadcast_device.mode ==
  248. TICKDEV_MODE_PERIODIC)
  249. tick_setup_periodic(dev, 0);
  250. }
  251. break;
  252. }
  253. if (cpumask_empty(tick_get_broadcast_mask())) {
  254. if (!bc_stopped)
  255. clockevents_shutdown(bc);
  256. } else if (bc_stopped) {
  257. if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
  258. tick_broadcast_start_periodic(bc);
  259. else
  260. tick_broadcast_setup_oneshot(bc);
  261. }
  262. out:
  263. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  264. }
  265. /*
  266. * Powerstate information: The system enters/leaves a state, where
  267. * affected devices might stop.
  268. */
  269. void tick_broadcast_on_off(unsigned long reason, int *oncpu)
  270. {
  271. if (!cpumask_test_cpu(*oncpu, cpu_online_mask))
  272. printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
  273. "offline CPU #%d\n", *oncpu);
  274. else
  275. tick_do_broadcast_on_off(&reason);
  276. }
  277. /*
  278. * Set the periodic handler depending on broadcast on/off
  279. */
  280. void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast)
  281. {
  282. if (!broadcast)
  283. dev->event_handler = tick_handle_periodic;
  284. else
  285. dev->event_handler = tick_handle_periodic_broadcast;
  286. }
  287. /*
  288. * Remove a CPU from broadcasting
  289. */
  290. void tick_shutdown_broadcast(unsigned int *cpup)
  291. {
  292. struct clock_event_device *bc;
  293. unsigned long flags;
  294. unsigned int cpu = *cpup;
  295. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  296. bc = tick_broadcast_device.evtdev;
  297. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  298. if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
  299. if (bc && cpumask_empty(tick_get_broadcast_mask()))
  300. clockevents_shutdown(bc);
  301. }
  302. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  303. }
  304. void tick_suspend_broadcast(void)
  305. {
  306. struct clock_event_device *bc;
  307. unsigned long flags;
  308. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  309. bc = tick_broadcast_device.evtdev;
  310. if (bc)
  311. clockevents_shutdown(bc);
  312. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  313. }
  314. int tick_resume_broadcast(void)
  315. {
  316. struct clock_event_device *bc;
  317. unsigned long flags;
  318. int broadcast = 0;
  319. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  320. bc = tick_broadcast_device.evtdev;
  321. if (bc) {
  322. clockevents_set_mode(bc, CLOCK_EVT_MODE_RESUME);
  323. switch (tick_broadcast_device.mode) {
  324. case TICKDEV_MODE_PERIODIC:
  325. if (!cpumask_empty(tick_get_broadcast_mask()))
  326. tick_broadcast_start_periodic(bc);
  327. broadcast = cpumask_test_cpu(smp_processor_id(),
  328. tick_get_broadcast_mask());
  329. break;
  330. case TICKDEV_MODE_ONESHOT:
  331. if (!cpumask_empty(tick_get_broadcast_mask()))
  332. broadcast = tick_resume_broadcast_oneshot(bc);
  333. break;
  334. }
  335. }
  336. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  337. return broadcast;
  338. }
  339. #ifdef CONFIG_TICK_ONESHOT
  340. /* FIXME: use cpumask_var_t. */
  341. static DECLARE_BITMAP(tick_broadcast_oneshot_mask, NR_CPUS);
  342. /*
  343. * Exposed for debugging: see timer_list.c
  344. */
  345. struct cpumask *tick_get_broadcast_oneshot_mask(void)
  346. {
  347. return to_cpumask(tick_broadcast_oneshot_mask);
  348. }
  349. static int tick_broadcast_set_event(ktime_t expires, int force)
  350. {
  351. struct clock_event_device *bc = tick_broadcast_device.evtdev;
  352. if (bc->mode != CLOCK_EVT_MODE_ONESHOT)
  353. clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
  354. return clockevents_program_event(bc, expires, force);
  355. }
  356. int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
  357. {
  358. clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
  359. return 0;
  360. }
  361. /*
  362. * Called from irq_enter() when idle was interrupted to reenable the
  363. * per cpu device.
  364. */
  365. void tick_check_oneshot_broadcast(int cpu)
  366. {
  367. if (cpumask_test_cpu(cpu, to_cpumask(tick_broadcast_oneshot_mask))) {
  368. struct tick_device *td = &per_cpu(tick_cpu_device, cpu);
  369. clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_ONESHOT);
  370. }
  371. }
  372. /*
  373. * Handle oneshot mode broadcasting
  374. */
  375. static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
  376. {
  377. struct tick_device *td;
  378. ktime_t now, next_event;
  379. int cpu;
  380. raw_spin_lock(&tick_broadcast_lock);
  381. again:
  382. dev->next_event.tv64 = KTIME_MAX;
  383. next_event.tv64 = KTIME_MAX;
  384. cpumask_clear(to_cpumask(tmpmask));
  385. now = ktime_get();
  386. /* Find all expired events */
  387. for_each_cpu(cpu, tick_get_broadcast_oneshot_mask()) {
  388. td = &per_cpu(tick_cpu_device, cpu);
  389. if (td->evtdev->next_event.tv64 <= now.tv64)
  390. cpumask_set_cpu(cpu, to_cpumask(tmpmask));
  391. else if (td->evtdev->next_event.tv64 < next_event.tv64)
  392. next_event.tv64 = td->evtdev->next_event.tv64;
  393. }
  394. /*
  395. * Wakeup the cpus which have an expired event.
  396. */
  397. tick_do_broadcast(to_cpumask(tmpmask));
  398. /*
  399. * Two reasons for reprogram:
  400. *
  401. * - The global event did not expire any CPU local
  402. * events. This happens in dyntick mode, as the maximum PIT
  403. * delta is quite small.
  404. *
  405. * - There are pending events on sleeping CPUs which were not
  406. * in the event mask
  407. */
  408. if (next_event.tv64 != KTIME_MAX) {
  409. /*
  410. * Rearm the broadcast device. If event expired,
  411. * repeat the above
  412. */
  413. if (tick_broadcast_set_event(next_event, 0))
  414. goto again;
  415. }
  416. raw_spin_unlock(&tick_broadcast_lock);
  417. }
  418. /*
  419. * Powerstate information: The system enters/leaves a state, where
  420. * affected devices might stop
  421. */
  422. void tick_broadcast_oneshot_control(unsigned long reason)
  423. {
  424. struct clock_event_device *bc, *dev;
  425. struct tick_device *td;
  426. unsigned long flags;
  427. int cpu;
  428. /*
  429. * Periodic mode does not care about the enter/exit of power
  430. * states
  431. */
  432. if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
  433. return;
  434. /*
  435. * We are called with preemtion disabled from the depth of the
  436. * idle code, so we can't be moved away.
  437. */
  438. cpu = smp_processor_id();
  439. td = &per_cpu(tick_cpu_device, cpu);
  440. dev = td->evtdev;
  441. if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
  442. return;
  443. bc = tick_broadcast_device.evtdev;
  444. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  445. if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
  446. if (!cpumask_test_cpu(cpu, tick_get_broadcast_oneshot_mask())) {
  447. cpumask_set_cpu(cpu, tick_get_broadcast_oneshot_mask());
  448. clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
  449. if (dev->next_event.tv64 < bc->next_event.tv64)
  450. tick_broadcast_set_event(dev->next_event, 1);
  451. }
  452. } else {
  453. if (cpumask_test_cpu(cpu, tick_get_broadcast_oneshot_mask())) {
  454. cpumask_clear_cpu(cpu,
  455. tick_get_broadcast_oneshot_mask());
  456. clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
  457. if (dev->next_event.tv64 != KTIME_MAX)
  458. tick_program_event(dev->next_event, 1);
  459. }
  460. }
  461. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  462. }
  463. /*
  464. * Reset the one shot broadcast for a cpu
  465. *
  466. * Called with tick_broadcast_lock held
  467. */
  468. static void tick_broadcast_clear_oneshot(int cpu)
  469. {
  470. cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
  471. }
  472. static void tick_broadcast_init_next_event(struct cpumask *mask,
  473. ktime_t expires)
  474. {
  475. struct tick_device *td;
  476. int cpu;
  477. for_each_cpu(cpu, mask) {
  478. td = &per_cpu(tick_cpu_device, cpu);
  479. if (td->evtdev)
  480. td->evtdev->next_event = expires;
  481. }
  482. }
  483. /**
  484. * tick_broadcast_setup_oneshot - setup the broadcast device
  485. */
  486. void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
  487. {
  488. int cpu = smp_processor_id();
  489. /* Set it up only once ! */
  490. if (bc->event_handler != tick_handle_oneshot_broadcast) {
  491. int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC;
  492. bc->event_handler = tick_handle_oneshot_broadcast;
  493. /* Take the do_timer update */
  494. tick_do_timer_cpu = cpu;
  495. /*
  496. * We must be careful here. There might be other CPUs
  497. * waiting for periodic broadcast. We need to set the
  498. * oneshot_mask bits for those and program the
  499. * broadcast device to fire.
  500. */
  501. cpumask_copy(to_cpumask(tmpmask), tick_get_broadcast_mask());
  502. cpumask_clear_cpu(cpu, to_cpumask(tmpmask));
  503. cpumask_or(tick_get_broadcast_oneshot_mask(),
  504. tick_get_broadcast_oneshot_mask(),
  505. to_cpumask(tmpmask));
  506. if (was_periodic && !cpumask_empty(to_cpumask(tmpmask))) {
  507. clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
  508. tick_broadcast_init_next_event(to_cpumask(tmpmask),
  509. tick_next_period);
  510. tick_broadcast_set_event(tick_next_period, 1);
  511. } else
  512. bc->next_event.tv64 = KTIME_MAX;
  513. } else {
  514. /*
  515. * The first cpu which switches to oneshot mode sets
  516. * the bit for all other cpus which are in the general
  517. * (periodic) broadcast mask. So the bit is set and
  518. * would prevent the first broadcast enter after this
  519. * to program the bc device.
  520. */
  521. tick_broadcast_clear_oneshot(cpu);
  522. }
  523. }
  524. /*
  525. * Select oneshot operating mode for the broadcast device
  526. */
  527. void tick_broadcast_switch_to_oneshot(void)
  528. {
  529. struct clock_event_device *bc;
  530. unsigned long flags;
  531. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  532. tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
  533. bc = tick_broadcast_device.evtdev;
  534. if (bc)
  535. tick_broadcast_setup_oneshot(bc);
  536. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  537. }
  538. /*
  539. * Remove a dead CPU from broadcasting
  540. */
  541. void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
  542. {
  543. unsigned long flags;
  544. unsigned int cpu = *cpup;
  545. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  546. /*
  547. * Clear the broadcast mask flag for the dead cpu, but do not
  548. * stop the broadcast device!
  549. */
  550. cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
  551. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  552. }
  553. /*
  554. * Check, whether the broadcast device is in one shot mode
  555. */
  556. int tick_broadcast_oneshot_active(void)
  557. {
  558. return tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT;
  559. }
  560. /*
  561. * Check whether the broadcast device supports oneshot.
  562. */
  563. bool tick_broadcast_oneshot_available(void)
  564. {
  565. struct clock_event_device *bc = tick_broadcast_device.evtdev;
  566. return bc ? bc->features & CLOCK_EVT_FEAT_ONESHOT : false;
  567. }
  568. #endif