]>
Commit | Line | Data |
---|---|---|
9547e94c SL |
1 | From 474e88c98233b5698d11ca6e76839b1576681d38 Mon Sep 17 00:00:00 2001 |
2 | From: Mathieu Poirier <mathieu.poirier@linaro.org> | |
3 | Date: Tue, 2 Feb 2016 14:13:56 -0700 | |
4 | Subject: coresight: fixing lockdep error | |
5 | ||
6 | [ Upstream commit a9ddc71f5840c2711e530f2e055b278f79948b29 ] | |
7 | ||
8 | On some platform the following lockdep error occurs when doing simple | |
9 | manipulations: | |
10 | ||
11 | [ 23.197021] | |
12 | [ 23.198608] ====================================================== | |
13 | [ 23.205078] [ INFO: possible circular locking dependency detected ] | |
14 | [ 23.211639] 4.4.0-rc8-00025-gbbf360b #172 Not tainted | |
15 | [ 23.216918] ------------------------------------------------------- | |
16 | [ 23.223480] sh/858 is trying to acquire lock: | |
17 | [ 23.228057] (coresight_mutex){+.+.+.}, at: [<c0415d40>] coresight_enable+0x1c/0x1b4 | |
18 | [ 23.236206] | |
19 | [ 23.236206] but task is already holding lock: | |
20 | [ 23.242309] (s_active#52){++++.+}, at: [<c01d4b40>] kernfs_fop_write+0x5c/0x1c0 | |
21 | [ 23.250122] | |
22 | [ 23.250122] which lock already depends on the new lock. | |
23 | [ 23.250122] | |
24 | [ 23.258697] | |
25 | [ 23.258697] the existing dependency chain (in reverse order) is: | |
26 | [ 23.266510] | |
27 | -> #1 (s_active#52){++++.+}: | |
28 | [ 23.270843] [<c01d30ec>] __kernfs_remove+0x294/0x35c | |
29 | [ 23.276672] [<c01d3e44>] kernfs_remove_by_name_ns+0x44/0x8c | |
30 | [ 23.283172] [<c01d6318>] remove_files+0x3c/0x84 | |
31 | [ 23.288543] [<c01d66b4>] sysfs_remove_group+0x48/0x9c | |
32 | [ 23.294494] [<c01d6734>] sysfs_remove_groups+0x2c/0x3c | |
33 | [ 23.300506] [<c030b658>] device_remove_attrs+0x5c/0x74 | |
34 | [ 23.306549] [<c030c290>] device_del+0x110/0x218 | |
35 | [ 23.311950] [<c030c3c4>] device_unregister+0x2c/0x6c | |
36 | [ 23.317779] [<c04156d8>] coresight_unregister+0x30/0x40 | |
37 | [ 23.323883] [<c041a290>] etm_probe+0x228/0x2e8 | |
38 | [ 23.329193] [<c02bc760>] amba_probe+0xe4/0x160 | |
39 | [ 23.334503] [<c0310540>] driver_probe_device+0x23c/0x480 | |
40 | [ 23.340728] [<c0310820>] __driver_attach+0x9c/0xa0 | |
41 | [ 23.346374] [<c030e400>] bus_for_each_dev+0x70/0xa4 | |
42 | [ 23.352142] [<c030fcf4>] driver_attach+0x24/0x28 | |
43 | [ 23.357604] [<c030f86c>] bus_add_driver+0x1e0/0x278 | |
44 | [ 23.363372] [<c0310d48>] driver_register+0x80/0x100 | |
45 | [ 23.369110] [<c02bc508>] amba_driver_register+0x58/0x5c | |
46 | [ 23.375244] [<c0749514>] etm_driver_init+0x18/0x1c | |
47 | [ 23.380889] [<c0009918>] do_one_initcall+0xc4/0x20c | |
48 | [ 23.386657] [<c0715e7c>] kernel_init_freeable+0x160/0x208 | |
49 | [ 23.392974] [<c052d7fc>] kernel_init+0x18/0xf0 | |
50 | [ 23.398254] [<c0010850>] ret_from_fork+0x14/0x24 | |
51 | [ 23.403747] | |
52 | -> #0 (coresight_mutex){+.+.+.}: | |
53 | [ 23.408447] [<c008ed60>] lock_acquire+0xe4/0x210 | |
54 | [ 23.413909] [<c0530a30>] mutex_lock_nested+0x74/0x450 | |
55 | [ 23.419860] [<c0415d40>] coresight_enable+0x1c/0x1b4 | |
56 | [ 23.425689] [<c0416030>] enable_source_store+0x58/0x68 | |
57 | [ 23.431732] [<c030b358>] dev_attr_store+0x20/0x2c | |
58 | [ 23.437286] [<c01d55e8>] sysfs_kf_write+0x50/0x54 | |
59 | [ 23.442871] [<c01d4ba8>] kernfs_fop_write+0xc4/0x1c0 | |
60 | [ 23.448699] [<c015b60c>] __vfs_write+0x34/0xe4 | |
61 | [ 23.454040] [<c015bf38>] vfs_write+0x98/0x174 | |
62 | [ 23.459228] [<c015c7a8>] SyS_write+0x4c/0xa8 | |
63 | [ 23.464355] [<c00107c0>] ret_fast_syscall+0x0/0x1c | |
64 | [ 23.470031] | |
65 | [ 23.470031] other info that might help us debug this: | |
66 | [ 23.470031] | |
67 | [ 23.478393] Possible unsafe locking scenario: | |
68 | [ 23.478393] | |
69 | [ 23.484619] CPU0 CPU1 | |
70 | [ 23.489349] ---- ---- | |
71 | [ 23.494079] lock(s_active#52); | |
72 | [ 23.497497] lock(coresight_mutex); | |
73 | [ 23.503906] lock(s_active#52); | |
74 | [ 23.509918] lock(coresight_mutex); | |
75 | [ 23.513702] | |
76 | [ 23.513702] *** DEADLOCK *** | |
77 | [ 23.513702] | |
78 | [ 23.519897] 3 locks held by sh/858: | |
79 | [ 23.523529] #0: (sb_writers#7){.+.+.+}, at: [<c015ec38>] __sb_start_write+0xa8/0xd4 | |
80 | [ 23.531799] #1: (&of->mutex){+.+...}, at: [<c01d4b38>] kernfs_fop_write+0x54/0x1c0 | |
81 | [ 23.539916] #2: (s_active#52){++++.+}, at: [<c01d4b40>] kernfs_fop_write+0x5c/0x1c0 | |
82 | [ 23.548156] | |
83 | [ 23.548156] stack backtrace: | |
84 | [ 23.552734] CPU: 0 PID: 858 Comm: sh Not tainted 4.4.0-rc8-00025-gbbf360b #172 | |
85 | [ 23.560302] Hardware name: Generic OMAP4 (Flattened Device Tree) | |
86 | [ 23.566589] Backtrace: | |
87 | [ 23.569152] [<c00154d4>] (dump_backtrace) from [<c00156d0>] (show_stack+0x18/0x1c) | |
88 | [ 23.577087] r7:ed4b8570 r6:c0936400 r5:c07ae71c r4:00000000 | |
89 | [ 23.583038] [<c00156b8>] (show_stack) from [<c027e69c>] (dump_stack+0x98/0xc0) | |
90 | [ 23.590606] [<c027e604>] (dump_stack) from [<c008a750>] (print_circular_bug+0x21c/0x33c) | |
91 | [ 23.599090] r5:c0939d60 r4:c0936400 | |
92 | [ 23.602874] [<c008a534>] (print_circular_bug) from [<c008e370>] (__lock_acquire+0x1c98/0x1d88) | |
93 | [ 23.611877] r10:00000003 r9:c0fd7a5c r8:ed4b8550 r7:ed4b8570 r6:ed4b8000 r5:c0ff69e4 | |
94 | [ 23.620117] r4:c0936400 r3:ed4b8550 | |
95 | [ 23.623901] [<c008c6d8>] (__lock_acquire) from [<c008ed60>] (lock_acquire+0xe4/0x210) | |
96 | [ 23.632080] r10:00000000 r9:00000000 r8:60000013 r7:c07cb7b4 r6:00000001 r5:00000000 | |
97 | [ 23.640350] r4:00000000 | |
98 | [ 23.643005] [<c008ec7c>] (lock_acquire) from [<c0530a30>] (mutex_lock_nested+0x74/0x450) | |
99 | [ 23.651458] r10:ecc0bf80 r9:edbe7dcc r8:ed4b8000 r7:c0fd7a5c r6:c0415d40 r5:00000000 | |
100 | [ 23.659729] r4:c07cb780 | |
101 | [ 23.662384] [<c05309bc>] (mutex_lock_nested) from [<c0415d40>] (coresight_enable+0x1c/0x1b4) | |
102 | [ 23.671234] r10:ecc0bf80 r9:edbe7dcc r8:ed733c00 r7:00000000 r6:ed733c00 r5:00000002 | |
103 | [ 23.679473] r4:ed762140 | |
104 | [ 23.682128] [<c0415d24>] (coresight_enable) from [<c0416030>] (enable_source_store+0x58/0x68) | |
105 | [ 23.691070] r7:00000000 r6:ed733c00 r5:00000002 r4:ed762160 | |
106 | [ 23.697052] [<c0415fd8>] (enable_source_store) from [<c030b358>] (dev_attr_store+0x20/0x2c) | |
107 | [ 23.705780] r5:edbe7dc0 r4:c0415fd8 | |
108 | [ 23.709533] [<c030b338>] (dev_attr_store) from [<c01d55e8>] (sysfs_kf_write+0x50/0x54) | |
109 | [ 23.717834] r5:edbe7dc0 r4:c030b338 | |
110 | [ 23.721618] [<c01d5598>] (sysfs_kf_write) from [<c01d4ba8>] (kernfs_fop_write+0xc4/0x1c0) | |
111 | [ 23.730163] r7:00000000 r6:00000000 r5:00000002 r4:edbe7dc0 | |
112 | [ 23.736145] [<c01d4ae4>] (kernfs_fop_write) from [<c015b60c>] (__vfs_write+0x34/0xe4) | |
113 | [ 23.744323] r10:00000000 r9:ecc0a000 r8:c0010964 r7:ecc0bf80 r6:00000002 r5:c01d4ae4 | |
114 | [ 23.752593] r4:ee385a40 | |
115 | [ 23.755249] [<c015b5d8>] (__vfs_write) from [<c015bf38>] (vfs_write+0x98/0x174) | |
116 | [ 23.762908] r9:ecc0a000 r8:c0010964 r7:ecc0bf80 r6:000ab0d8 r5:00000002 r4:ee385a40 | |
117 | [ 23.771057] [<c015bea0>] (vfs_write) from [<c015c7a8>] (SyS_write+0x4c/0xa8) | |
118 | [ 23.778442] r8:c0010964 r7:00000002 r6:000ab0d8 r5:ee385a40 r4:ee385a40 | |
119 | [ 23.785522] [<c015c75c>] (SyS_write) from [<c00107c0>] (ret_fast_syscall+0x0/0x1c) | |
120 | [ 23.793457] r7:00000004 r6:00000001 r5:000ab0d8 r4:00000002 | |
121 | [ 23.799652] coresight-etb10 54162000.etb: ETB enabled | |
122 | [ 23.805084] coresight-funnel 54164000.funnel: FUNNEL inport 0 enabled | |
123 | [ 23.811859] coresight-replicator 44000000.ocp:replicator: REPLICATOR enabled | |
124 | [ 23.819335] coresight-funnel 54158000.funnel: FUNNEL inport 0 enabled | |
125 | [ 23.826110] coresight-etm3x 5414c000.ptm: ETM tracing enabled | |
126 | ||
127 | The locking in coresight_unregister() is not required as the only customers of | |
128 | the function are drivers themselves when an initialisation failure has been | |
129 | encoutered. | |
130 | ||
131 | Reported-by: Rabin Vincent <rabin@rab.in> | |
132 | Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> | |
133 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
134 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
135 | --- | |
136 | drivers/hwtracing/coresight/coresight.c | 4 ---- | |
137 | 1 file changed, 4 deletions(-) | |
138 | ||
139 | diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c | |
140 | index 902ee6efd09c..84fc60318f79 100644 | |
141 | --- a/drivers/hwtracing/coresight/coresight.c | |
142 | +++ b/drivers/hwtracing/coresight/coresight.c | |
143 | @@ -716,12 +716,8 @@ EXPORT_SYMBOL_GPL(coresight_register); | |
144 | ||
145 | void coresight_unregister(struct coresight_device *csdev) | |
146 | { | |
147 | - mutex_lock(&coresight_mutex); | |
148 | - | |
149 | kfree(csdev->conns); | |
150 | device_unregister(&csdev->dev); | |
151 | - | |
152 | - mutex_unlock(&coresight_mutex); | |
153 | } | |
154 | EXPORT_SYMBOL_GPL(coresight_unregister); | |
155 | ||
156 | -- | |
157 | 2.19.1 | |
158 |