]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0214-acpi-rt-Convert-acpi_gbl_hardware-lock-back-to-a-raw.patch
Fix memguard and related syscalls
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0214-acpi-rt-Convert-acpi_gbl_hardware-lock-back-to-a-raw.patch
1 From e7b7737c3aa52738884f25999827eac01de2604e Mon Sep 17 00:00:00 2001
2 From: Steven Rostedt <rostedt@goodmis.org>
3 Date: Wed, 13 Feb 2013 09:26:05 -0500
4 Subject: [PATCH 214/366] acpi/rt: Convert acpi_gbl_hardware lock back to a
5  raw_spinlock_t
6
7 We hit the following bug with 3.6-rt:
8
9 [    5.898990] BUG: scheduling while atomic: swapper/3/0/0x00000002
10 [    5.898991] no locks held by swapper/3/0.
11 [    5.898993] Modules linked in:
12 [    5.898996] Pid: 0, comm: swapper/3 Not tainted 3.6.11-rt28.19.el6rt.x86_64.debug #1
13 [    5.898997] Call Trace:
14 [    5.899011]  [<ffffffff810804e7>] __schedule_bug+0x67/0x90
15 [    5.899028]  [<ffffffff81577923>] __schedule+0x793/0x7a0
16 [    5.899032]  [<ffffffff810b4e40>] ? debug_rt_mutex_print_deadlock+0x50/0x200
17 [    5.899034]  [<ffffffff81577b89>] schedule+0x29/0x70
18 [    5.899036] BUG: scheduling while atomic: swapper/7/0/0x00000002
19 [    5.899037] no locks held by swapper/7/0.
20 [    5.899039]  [<ffffffff81578525>] rt_spin_lock_slowlock+0xe5/0x2f0
21 [    5.899040] Modules linked in:
22 [    5.899041]
23 [    5.899045]  [<ffffffff81579a58>] ? _raw_spin_unlock_irqrestore+0x38/0x90
24 [    5.899046] Pid: 0, comm: swapper/7 Not tainted 3.6.11-rt28.19.el6rt.x86_64.debug #1
25 [    5.899047] Call Trace:
26 [    5.899049]  [<ffffffff81578bc6>] rt_spin_lock+0x16/0x40
27 [    5.899052]  [<ffffffff810804e7>] __schedule_bug+0x67/0x90
28 [    5.899054]  [<ffffffff8157d3f0>] ? notifier_call_chain+0x80/0x80
29 [    5.899056]  [<ffffffff81577923>] __schedule+0x793/0x7a0
30 [    5.899059]  [<ffffffff812f2034>] acpi_os_acquire_lock+0x1f/0x23
31 [    5.899062]  [<ffffffff810b4e40>] ? debug_rt_mutex_print_deadlock+0x50/0x200
32 [    5.899068]  [<ffffffff8130be64>] acpi_write_bit_register+0x33/0xb0
33 [    5.899071]  [<ffffffff81577b89>] schedule+0x29/0x70
34 [    5.899072]  [<ffffffff8130be13>] ? acpi_read_bit_register+0x33/0x51
35 [    5.899074]  [<ffffffff81578525>] rt_spin_lock_slowlock+0xe5/0x2f0
36 [    5.899077]  [<ffffffff8131d1fc>] acpi_idle_enter_bm+0x8a/0x28e
37 [    5.899079]  [<ffffffff81579a58>] ? _raw_spin_unlock_irqrestore+0x38/0x90
38 [    5.899081]  [<ffffffff8107e5da>] ? this_cpu_load+0x1a/0x30
39 [    5.899083]  [<ffffffff81578bc6>] rt_spin_lock+0x16/0x40
40 [    5.899087]  [<ffffffff8144c759>] cpuidle_enter+0x19/0x20
41 [    5.899088]  [<ffffffff8157d3f0>] ? notifier_call_chain+0x80/0x80
42 [    5.899090]  [<ffffffff8144c777>] cpuidle_enter_state+0x17/0x50
43 [    5.899092]  [<ffffffff812f2034>] acpi_os_acquire_lock+0x1f/0x23
44 [    5.899094]  [<ffffffff8144d1a1>] cpuidle899101]  [<ffffffff8130be13>] ?
45
46 As the acpi code disables interrupts in acpi_idle_enter_bm, and calls
47 code that grabs the acpi lock, it causes issues as the lock is currently
48 in RT a sleeping lock.
49
50 The lock was converted from a raw to a sleeping lock due to some
51 previous issues, and tests that showed it didn't seem to matter.
52 Unfortunately, it did matter for one of our boxes.
53
54 This patch converts the lock back to a raw lock. I've run this code on a
55 few of my own machines, one being my laptop that uses the acpi quite
56 extensively. I've been able to suspend and resume without issues.
57
58 [ tglx: Made the change exclusive for acpi_gbl_hardware_lock ]
59
60 Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
61 Cc: John Kacur <jkacur@gmail.com>
62 Cc: Clark Williams <clark@redhat.com>
63 Link: http://lkml.kernel.org/r/1360765565.23152.5.camel@gandalf.local.home
64
65 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
66 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
67 ---
68  drivers/acpi/acpica/acglobal.h  |  2 +-
69  drivers/acpi/acpica/hwregs.c    |  4 ++--
70  drivers/acpi/acpica/hwxface.c   |  4 ++--
71  drivers/acpi/acpica/utmutex.c   |  4 ++--
72  include/acpi/platform/aclinux.h | 15 +++++++++++++++
73  5 files changed, 22 insertions(+), 7 deletions(-)
74
75 diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
76 index faa9760..941497f 100644
77 --- a/drivers/acpi/acpica/acglobal.h
78 +++ b/drivers/acpi/acpica/acglobal.h
79 @@ -116,7 +116,7 @@ ACPI_GLOBAL(u8, acpi_gbl_global_lock_pending);
80   * interrupt level
81   */
82  ACPI_GLOBAL(acpi_spinlock, acpi_gbl_gpe_lock); /* For GPE data structs and registers */
83 -ACPI_GLOBAL(acpi_spinlock, acpi_gbl_hardware_lock);    /* For ACPI H/W except GPE registers */
84 +ACPI_GLOBAL(acpi_raw_spinlock, acpi_gbl_hardware_lock);        /* For ACPI H/W except GPE registers */
85  ACPI_GLOBAL(acpi_spinlock, acpi_gbl_reference_count_lock);
86  
87  /* Mutex for _OSI support */
88 diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
89 index 3cf77af..dc32e72 100644
90 --- a/drivers/acpi/acpica/hwregs.c
91 +++ b/drivers/acpi/acpica/hwregs.c
92 @@ -269,14 +269,14 @@ acpi_status acpi_hw_clear_acpi_status(void)
93                           ACPI_BITMASK_ALL_FIXED_STATUS,
94                           ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address)));
95  
96 -       lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
97 +       raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags);
98  
99         /* Clear the fixed events in PM1 A/B */
100  
101         status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
102                                         ACPI_BITMASK_ALL_FIXED_STATUS);
103  
104 -       acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
105 +       raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags);
106  
107         if (ACPI_FAILURE(status)) {
108                 goto exit;
109 diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
110 index b2e50d8..ff00708 100644
111 --- a/drivers/acpi/acpica/hwxface.c
112 +++ b/drivers/acpi/acpica/hwxface.c
113 @@ -374,7 +374,7 @@ acpi_status acpi_write_bit_register(u32 register_id, u32 value)
114                 return_ACPI_STATUS(AE_BAD_PARAMETER);
115         }
116  
117 -       lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
118 +       raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags);
119  
120         /*
121          * At this point, we know that the parent register is one of the
122 @@ -435,7 +435,7 @@ acpi_status acpi_write_bit_register(u32 register_id, u32 value)
123  
124  unlock_and_exit:
125  
126 -       acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
127 +       raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags);
128         return_ACPI_STATUS(status);
129  }
130  
131 diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
132 index ce406e3..41a75eb 100644
133 --- a/drivers/acpi/acpica/utmutex.c
134 +++ b/drivers/acpi/acpica/utmutex.c
135 @@ -88,7 +88,7 @@ acpi_status acpi_ut_mutex_initialize(void)
136                 return_ACPI_STATUS (status);
137         }
138  
139 -       status = acpi_os_create_lock (&acpi_gbl_hardware_lock);
140 +       status = acpi_os_create_raw_lock (&acpi_gbl_hardware_lock);
141         if (ACPI_FAILURE (status)) {
142                 return_ACPI_STATUS (status);
143         }
144 @@ -156,7 +156,7 @@ void acpi_ut_mutex_terminate(void)
145         /* Delete the spinlocks */
146  
147         acpi_os_delete_lock(acpi_gbl_gpe_lock);
148 -       acpi_os_delete_lock(acpi_gbl_hardware_lock);
149 +       acpi_os_delete_raw_lock(acpi_gbl_hardware_lock);
150         acpi_os_delete_lock(acpi_gbl_reference_count_lock);
151  
152         /* Delete the reader/writer lock */
153 diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
154 index 323e5da..cc5fbd5 100644
155 --- a/include/acpi/platform/aclinux.h
156 +++ b/include/acpi/platform/aclinux.h
157 @@ -127,6 +127,7 @@
158  
159  #define acpi_cache_t                        struct kmem_cache
160  #define acpi_spinlock                       spinlock_t *
161 +#define acpi_raw_spinlock              raw_spinlock_t *
162  #define acpi_cpu_flags                      unsigned long
163  
164  /* Use native linux version of acpi_os_allocate_zeroed */
165 @@ -145,6 +146,20 @@
166  #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
167  #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
168  
169 +#define acpi_os_create_raw_lock(__handle)                      \
170 +({                                                             \
171 +        raw_spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock));   \
172 +                                                               \
173 +        if (lock) {                                            \
174 +               *(__handle) = lock;                             \
175 +               raw_spin_lock_init(*(__handle));                \
176 +        }                                                      \
177 +        lock ? AE_OK : AE_NO_MEMORY;                           \
178 + })
179 +
180 +#define acpi_os_delete_raw_lock(__handle)      kfree(__handle)
181 +
182 +
183  /*
184   * OSL interfaces used by debugger/disassembler
185   */
186 -- 
187 1.9.1
188