spinlock.c (f682a7920baf7b721d01dd317f3b532265357cbb) spinlock.c (2ac2a7d4d9ff4e01e36f9c3d116582f6f655ab47)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Split spinlock implementation out into its own file, so it can be
4 * compiled in a FTRACE-compatible way.
5 */
6#include <linux/kernel_stat.h>
7#include <linux/spinlock.h>
8#include <linux/debugfs.h>

--- 31 unchanged lines hidden (view full) ---

40static void xen_qlock_wait(u8 *byte, u8 val)
41{
42 int irq = __this_cpu_read(lock_kicker_irq);
43
44 /* If kicker interrupts not initialized yet, just spin */
45 if (irq == -1)
46 return;
47
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Split spinlock implementation out into its own file, so it can be
4 * compiled in a FTRACE-compatible way.
5 */
6#include <linux/kernel_stat.h>
7#include <linux/spinlock.h>
8#include <linux/debugfs.h>

--- 31 unchanged lines hidden (view full) ---

40static void xen_qlock_wait(u8 *byte, u8 val)
41{
42 int irq = __this_cpu_read(lock_kicker_irq);
43
44 /* If kicker interrupts not initialized yet, just spin */
45 if (irq == -1)
46 return;
47
48 /* clear pending */
49 xen_clear_irq_pending(irq);
50 barrier();
48 /* If irq pending already clear it and return. */
49 if (xen_test_irq_pending(irq)) {
50 xen_clear_irq_pending(irq);
51 return;
52 }
51
53
52 /*
53 * We check the byte value after clearing pending IRQ to make sure
54 * that we won't miss a wakeup event because of the clearing.
55 *
56 * The sync_clear_bit() call in xen_clear_irq_pending() is atomic.
57 * So it is effectively a memory barrier for x86.
58 */
59 if (READ_ONCE(*byte) != val)
60 return;
61
62 /*
63 * If an interrupt happens here, it will leave the wakeup irq
64 * pending, which will cause xen_poll_irq() to return
65 * immediately.
66 */

--- 92 unchanged lines hidden ---
54 if (READ_ONCE(*byte) != val)
55 return;
56
57 /*
58 * If an interrupt happens here, it will leave the wakeup irq
59 * pending, which will cause xen_poll_irq() to return
60 * immediately.
61 */

--- 92 unchanged lines hidden ---