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 "tick-internal.h"
  22. /*
  23. * Broadcast support for broken x86 hardware, where the local apic
  24. * timer stops in C3 state.
  25. */
  26. static struct tick_device tick_broadcast_device;
  27. /* FIXME: Use cpumask_var_t. */
  28. static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS);
  29. static DECLARE_BITMAP(tmpmask, NR_CPUS);
  30. static DEFINE_RAW_SPINLOCK(tick_broadcast_lock);
  31. static int tick_broadcast_force;
  32. #ifdef CONFIG_TICK_ONESHOT
  33. static void tick_broadcast_clear_oneshot(int cpu);
  34. #else
  35. static inline void tick_broadcast_clear_oneshot(int cpu) { }
  36. #endif
  37. /*
  38. * Debugging: see timer_list.c
  39. */
  40. struct tick_device *tick_get_broadcast_device(void)
  41. {
  42. return &tick_broadcast_device;
  43. }
  44. struct cpumask *tick_get_broadcast_mask(void)
  45. {
  46. return to_cpumask(tick_broadcast_mask);
  47. }
  48. /*
  49. * Start the device in periodic mode
  50. */
  51. static void tick_broadcast_start_periodic(struct clock_event_device *bc)
  52. {
  53. if (bc)
  54. tick_setup_periodic(bc, 1);
  55. }
  56. /*
  57. * Check, if the device can be utilized as broadcast device:
  58. */
  59. int tick_check_broadcast_device(struct clock_event_device *dev)
  60. {
  61. struct clock_event_device *cur = tick_broadcast_device.evtdev;
  62. if ((dev->features & CLOCK_EVT_FEAT_DUMMY) ||
  63. (tick_broadcast_device.evtdev &&
  64. tick_broadcast_device.evtdev->rating >= dev->rating) ||
  65. (dev->features & CLOCK_EVT_FEAT_C3STOP))
  66. return 0;
  67. clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
  68. if (cur)
  69. cur->event_handler = clockevents_handle_noop;
  70. tick_broadcast_device.evtdev = dev;
  71. if (!cpumask_empty(tick_get_broadcast_mask()))
  72. tick_broadcast_start_periodic(dev);
  73. return 1;
  74. }
  75. /*
  76. * Check, if the device is the broadcast device
  77. */
  78. int tick_is_broadcast_device(struct clock_event_device *dev)
  79. {
  80. return (dev && tick_broadcast_device.evtdev == dev);
  81. }
  82. /*
  83. * Check, if the device is disfunctional and a place holder, which
  84. * needs to be handled by the broadcast device.
  85. */
  86. int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
  87. {
  88. unsigned long flags;
  89. int ret = 0;
  90. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  91. /*
  92. * Devices might be registered with both periodic and oneshot
  93. * mode disabled. This signals, that the device needs to be
  94. * operated from the broadcast device and is a placeholder for
  95. * the cpu local device.
  96. */
  97. if (!tick_device_is_functional(dev)) {
  98. dev->event_handler = tick_handle_periodic;
  99. cpumask_set_cpu(cpu, tick_get_broadcast_mask());
  100. tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
  101. ret = 1;
  102. } else {
  103. /*
  104. * When the new device is not affected by the stop
  105. * feature and the cpu is marked in the broadcast mask
  106. * then clear the broadcast bit.
  107. */
  108. if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
  109. int cpu = smp_processor_id();
  110. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  111. tick_broadcast_clear_oneshot(cpu);
  112. }
  113. }
  114. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  115. return ret;
  116. }
  117. /*
  118. * Broadcast the event to the cpus, which are set in the mask (mangled).
  119. */
  120. static void tick_do_broadcast(struct cpumask *mask)
  121. {
  122. int cpu = smp_processor_id();
  123. struct tick_device *td;
  124. /*
  125. * Check, if the current cpu is in the mask
  126. */
  127. if (cpumask_test_cpu(cpu, mask)) {
  128. cpumask_clear_cpu(cpu, mask);
  129. td = &per_cpu(tick_cpu_device, cpu);
  130. td->evtdev->event_handler(td->evtdev);
  131. }
  132. if (!cpumask_empty(mask)) {
  133. /*
  134. * It might be necessary to actually check whether the devices
  135. * have different broadcast functions. For now, just use the
  136. * one of the first device. This works as long as we have this
  137. * misfeature only on x86 (lapic)
  138. */
  139. td = &per_cpu(tick_cpu_device, cpumask_first(mask));
  140. td->evtdev->broadcast(mask);
  141. }
  142. }
  143. /*
  144. * Periodic broadcast:
  145. * - invoke the broadcast handlers
  146. */
  147. static void tick_do_periodic_broadcast(void)
  148. {
  149. raw_spin_lock(&tick_broadcast_lock);
  150. cpumask_and(to_cpumask(tmpmask),
  151. cpu_online_mask, tick_get_broadcast_mask());
  152. tick_do_broadcast(to_cpumask(tmpmask));
  153. raw_spin_unlock(&tick_broadcast_lock);
  154. }
  155. /*
  156. * Event handler for periodic broadcast ticks
  157. */
  158. static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
  159. {
  160. ktime_t next;
  161. tick_do_periodic_broadcast();
  162. /*
  163. * The device is in periodic mode. No reprogramming necessary:
  164. */
  165. if (dev->mode == CLOCK_EVT_MODE_PERIODIC)
  166. return;
  167. /*
  168. * Setup the next period for devices, which do not have
  169. * periodic mode. We read dev->next_event first and add to it
  170. * when the event already expired. clockevents_program_event()
  171. * sets dev->next_event only when the event is really
  172. * programmed to the device.
  173. */
  174. for (next = dev->next_event; ;) {
  175. next = ktime_add(next, tick_period);
  176. if (!clockevents_program_event(dev, next, false))
  177. return;
  178. tick_do_periodic_broadcast();
  179. }
  180. }
  181. /*
  182. * Powerstate information: The system enters/leaves a state, where
  183. * affected devices might stop
  184. */
  185. static void tick_do_broadcast_on_off(unsigned long *reason)
  186. {
  187. struct clock_event_device *bc, *dev;
  188. struct tick_device *td;
  189. unsigned long flags;
  190. int cpu, bc_stopped;
  191. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  192. cpu = smp_processor_id();
  193. td = &per_cpu(tick_cpu_device, cpu);
  194. dev = td->evtdev;
  195. bc = tick_broadcast_device.evtdev;
  196. /*
  197. * Is the device not affected by the powerstate ?
  198. */
  199. if (!dev || !(dev->features & CLOCK_EVT_FEAT_C3STOP))
  200. goto out;
  201. if (!tick_device_is_functional(dev))
  202. goto out;
  203. bc_stopped = cpumask_empty(tick_get_broadcast_mask());
  204. switch (*reason) {
  205. case CLOCK_EVT_NOTIFY_BROADCAST_ON:
  206. case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
  207. if (!cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
  208. cpumask_set_cpu(cpu, tick_get_broadcast_mask());
  209. if (tick_broadcast_device.mode ==
  210. TICKDEV_MODE_PERIODIC)
  211. clockevents_shutdown(dev);
  212. }
  213. if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE)
  214. tick_broadcast_force = 1;
  215. break;
  216. case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
  217. if (!tick_broadcast_force &&
  218. cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
  219. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  220. if (tick_broadcast_device.mode ==
  221. TICKDEV_MODE_PERIODIC)
  222. tick_setup_periodic(dev, 0);
  223. }
  224. break;
  225. }
  226. if (cpumask_empty(tick_get_broadcast_mask())) {
  227. if (!bc_stopped)
  228. clockevents_shutdown(bc);
  229. } else if (bc_stopped) {
  230. if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
  231. tick_broadcast_start_periodic(bc);
  232. else
  233. tick_broadcast_setup_oneshot(bc);
  234. }
  235. out:
  236. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  237. }
  238. /*
  239. * Powerstate information: The system enters/leaves a state, where
  240. * affected devices might stop.
  241. */
  242. void tick_broadcast_on_off(unsigned long reason, int *oncpu)
  243. {
  244. if (!cpumask_test_cpu(*oncpu, cpu_online_mask))
  245. printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
  246. "offline CPU #%d\n", *oncpu);
  247. else
  248. tick_do_broadcast_on_off(&reason);
  249. }
  250. /*
  251. * Set the periodic handler depending on broadcast on/off
  252. */
  253. void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast)
  254. {
  255. if (!broadcast)
  256. dev->event_handler = tick_handle_periodic;
  257. else
  258. dev->event_handler = tick_handle_periodic_broadcast;
  259. }
  260. /*
  261. * Remove a CPU from broadcasting
  262. */
  263. void tick_shutdown_broadcast(unsigned int *cpup)
  264. {
  265. struct clock_event_device *bc;
  266. unsigned long flags;
  267. unsigned int cpu = *cpup;
  268. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  269. bc = tick_broadcast_device.evtdev;
  270. cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
  271. if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
  272. if (bc && cpumask_empty(tick_get_broadcast_mask()))
  273. clockevents_shutdown(bc);
  274. }
  275. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  276. }
  277. void tick_suspend_broadcast(void)
  278. {
  279. struct clock_event_device *bc;
  280. unsigned long flags;
  281. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  282. bc = tick_broadcast_device.evtdev;
  283. if (bc)
  284. clockevents_shutdown(bc);
  285. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  286. }
  287. int tick_resume_broadcast(void)
  288. {
  289. struct clock_event_device *bc;
  290. unsigned long flags;
  291. int broadcast = 0;
  292. raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
  293. bc = tick_broadcast_device.evtdev;
  294. if (bc) {
  295. clockevents_set_mode(bc, CLOCK_EVT_MODE_RESUME);
  296. switch (tick_broadcast_device.mode) {
  297. case TICKDEV_MODE_PERIODIC:
  298. if (!cpumask_empty(tick_get_broadcast_mask()))
  299. tick_broadcast_start_periodic(bc);
  300. broadcast = cpumask_test_cpu(smp_processor_id(),
  301. tick_get_broadcast_mask());
  302. break;
  303. case TICKDEV_MODE_ONESHOT:
  304. if (!cpumask_empty(tick_get_broadcast_mask()))
  305. broadcast = tick_resume_broadcast_oneshot(bc);
  306. break;
  307. }
  308. }
  309. raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
  310. return broadcast;
  311. }
  312. #ifdef CONFIG_TICK_ONESHOT
  313. /* FIXME: use cpumask_var_t. */
  314. static DECLARE_BITMAP(tick_broadcast_oneshot_mask, NR_CPUS);
  315. /*
  316. * Exposed for debugging: see timer_list.c
  317. */
  318. struct cpumask *tick_get_broadcast_oneshot_mask(void)
  319. {
  320. return to_cpumask(tick_broadcast_oneshot_mask);
  321. }
  322. /*
  323. * Set broadcast interrupt affinity
  324. */
  325. static void tick_broadcast_set_affinity(struct clock_event_device *bc,
  326. const struct cpumask *cpumask)
  327. {
  328. if (!(bc->features & CLOCK_EVT_FEAT_DYNIRQ))
  329. return;
  330. if (cpumask_equal(bc->cpumask, cpumask))
  331. return;
  332. bc->cpumask = cpumask;
  333. irq_set_affinity(bc->irq, bc->cpumask);
  334. }
  335. static int tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
  336. ktime_t expires, int force)
  337. {
  338. int ret;
  339. if (bc->mode != CLOCK_EVT_MODE_ONESHOT)
  340. clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
  341. ret = clockevents_program_event(bc, expires, force);
  342. if (!ret)
  343. tick_broadcast_set_affinity(bc, cpumask_of(cpu));
  344. return ret;
  345. }
  346. int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
  347. {
  348. clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
  349. return 0;
  350. }
  351. /*
  352. * Called from irq_enter() when idle was interrupted to reenable the
  353. * per cpu device.
  354. */
  355. void tick_check_oneshot_broadcast(int cpu)
  356. {
  357. if (cpumask_test_cpu(cpu, to_cpumask(tick_broadcast_oneshot_mask))) {
  358. struct tick_device *td = &per_cpu(tick_cpu_device, cpu);
  359. /*
  360. * We might be in the middle of switching over from
  361. * periodic to oneshot. If the CPU has not yet
  362. * switched over, leave the device alone.
  363. */
  364. if (td->mode == TICKDEV_MODE_ONESHOT) {
  365. clockevents_set_mode(td->evtdev,
  366. CLOCK_EVT_MODE_ONESHOT);
  367. }
  368. }
  369. }
  370. /*
  371. * Handle oneshot mode broadcasting
  372. */
  373. static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
  374. {
  375. struct tick_device *td;
  376. ktime_t now, next_event;
  377. int cpu, next_cpu = 0;
  378. raw_spin_lock(&tick_broadcast_lock);
  379. again:
  380. dev->next_event.tv64 = KTIME_MAX;
  381. next_event.tv64 = KTIME_MAX;
  382. cpumask_clear(to_cpumask(tmpmask));
  383. now = ktime_get();
  384. /* Find all expired events */
  385. for_each_cpu(cpu, tick_get_broadcast_oneshot_mask()) {
  386. td = &per_cpu(tick_cpu_device, cpu);
  387. if (td->evtdev->next_event.tv64 <= now.tv64) {
  388. cpumask_set_cpu(cpu, to_cpumask(tmpmask));
  389. } else if (td->evtdev->next_event.tv64 < next_event.tv64) {
  390. next_event.tv64 = td->evtdev->next_event.tv64;
  391. next_cpu = cpu;
  392. }
  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(dev, next_cpu, 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(bc, cpu, 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(bc, cpu, 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