aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c2
-rw-r--r--drivers/scsi/libsas/sas_ata.c2
-rw-r--r--drivers/scsi/scsi.c3
-rw-r--r--drivers/scsi/scsi_priv.h3
-rw-r--r--include/linux/async.h35
-rw-r--r--kernel/async.c35
-rw-r--r--sound/soc/soc-dapm.c2
7 files changed, 55 insertions, 27 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8b4b3829d9e7..6c74546fc3cd 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2744,7 +2744,7 @@ static void regulator_bulk_enable_async(void *data, async_cookie_t cookie)
2744int regulator_bulk_enable(int num_consumers, 2744int regulator_bulk_enable(int num_consumers,
2745 struct regulator_bulk_data *consumers) 2745 struct regulator_bulk_data *consumers)
2746{ 2746{
2747 LIST_HEAD(async_domain); 2747 ASYNC_DOMAIN_EXCLUSIVE(async_domain);
2748 int i; 2748 int i;
2749 int ret = 0; 2749 int ret = 0;
2750 2750
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index bec3bc8aab0c..a59fcdc8fd63 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -742,7 +742,7 @@ static void async_sas_ata_eh(void *data, async_cookie_t cookie)
742void sas_ata_strategy_handler(struct Scsi_Host *shost) 742void sas_ata_strategy_handler(struct Scsi_Host *shost)
743{ 743{
744 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); 744 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
745 LIST_HEAD(async); 745 ASYNC_DOMAIN_EXCLUSIVE(async);
746 int i; 746 int i;
747 747
748 /* it's ok to defer revalidation events during ata eh, these 748 /* it's ok to defer revalidation events during ata eh, these
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index bbbc9c918d4c..4cade886a50a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -54,6 +54,7 @@
54#include <linux/notifier.h> 54#include <linux/notifier.h>
55#include <linux/cpu.h> 55#include <linux/cpu.h>
56#include <linux/mutex.h> 56#include <linux/mutex.h>
57#include <linux/async.h>
57 58
58#include <scsi/scsi.h> 59#include <scsi/scsi.h>
59#include <scsi/scsi_cmnd.h> 60#include <scsi/scsi_cmnd.h>
@@ -91,7 +92,7 @@ EXPORT_SYMBOL(scsi_logging_level);
91#endif 92#endif
92 93
93/* sd, scsi core and power management need to coordinate flushing async actions */ 94/* sd, scsi core and power management need to coordinate flushing async actions */
94LIST_HEAD(scsi_sd_probe_domain); 95ASYNC_DOMAIN(scsi_sd_probe_domain);
95EXPORT_SYMBOL(scsi_sd_probe_domain); 96EXPORT_SYMBOL(scsi_sd_probe_domain);
96 97
97/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. 98/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 13d74da5dfab..8f9a0cadc296 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -2,6 +2,7 @@
2#define _SCSI_PRIV_H 2#define _SCSI_PRIV_H
3 3
4#include <linux/device.h> 4#include <linux/device.h>
5#include <linux/async.h>
5#include <scsi/scsi_device.h> 6#include <scsi/scsi_device.h>
6 7
7struct request_queue; 8struct request_queue;
@@ -163,7 +164,7 @@ static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
163static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} 164static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
164#endif /* CONFIG_PM_RUNTIME */ 165#endif /* CONFIG_PM_RUNTIME */
165 166
166extern struct list_head scsi_sd_probe_domain; 167extern struct async_domain scsi_sd_probe_domain;
167 168
168/* 169/*
169 * internal scsi timeout functions: for use by mid-layer and transport 170 * internal scsi timeout functions: for use by mid-layer and transport
diff --git a/include/linux/async.h b/include/linux/async.h
index 68a9530196f2..364e7ff16c08 100644
--- a/include/linux/async.h
+++ b/include/linux/async.h
@@ -9,19 +9,46 @@
9 * as published by the Free Software Foundation; version 2 9 * as published by the Free Software Foundation; version 2
10 * of the License. 10 * of the License.
11 */ 11 */
12#ifndef __ASYNC_H__
13#define __ASYNC_H__
12 14
13#include <linux/types.h> 15#include <linux/types.h>
14#include <linux/list.h> 16#include <linux/list.h>
15 17
16typedef u64 async_cookie_t; 18typedef u64 async_cookie_t;
17typedef void (async_func_ptr) (void *data, async_cookie_t cookie); 19typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
20struct async_domain {
21 struct list_head node;
22 struct list_head domain;
23 int count;
24 unsigned registered:1;
25};
26
27/*
28 * domain participates in global async_synchronize_full
29 */
30#define ASYNC_DOMAIN(_name) \
31 struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
32 .domain = LIST_HEAD_INIT(_name.domain), \
33 .count = 0, \
34 .registered = 1 }
35
36/*
37 * domain is free to go out of scope as soon as all pending work is
38 * complete, this domain does not participate in async_synchronize_full
39 */
40#define ASYNC_DOMAIN_EXCLUSIVE(_name) \
41 struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
42 .domain = LIST_HEAD_INIT(_name.domain), \
43 .count = 0, \
44 .registered = 0 }
18 45
19extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data); 46extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
20extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data, 47extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
21 struct list_head *list); 48 struct async_domain *domain);
22extern void async_synchronize_full(void); 49extern void async_synchronize_full(void);
23extern void async_synchronize_full_domain(struct list_head *list); 50extern void async_synchronize_full_domain(struct async_domain *domain);
24extern void async_synchronize_cookie(async_cookie_t cookie); 51extern void async_synchronize_cookie(async_cookie_t cookie);
25extern void async_synchronize_cookie_domain(async_cookie_t cookie, 52extern void async_synchronize_cookie_domain(async_cookie_t cookie,
26 struct list_head *list); 53 struct async_domain *domain);
27 54#endif
diff --git a/kernel/async.c b/kernel/async.c
index bd0c168a3bbe..ba5491dfa991 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -62,7 +62,7 @@ static async_cookie_t next_cookie = 1;
62#define MAX_WORK 32768 62#define MAX_WORK 32768
63 63
64static LIST_HEAD(async_pending); 64static LIST_HEAD(async_pending);
65static LIST_HEAD(async_running); 65static ASYNC_DOMAIN(async_running);
66static DEFINE_SPINLOCK(async_lock); 66static DEFINE_SPINLOCK(async_lock);
67 67
68struct async_entry { 68struct async_entry {
@@ -71,7 +71,7 @@ struct async_entry {
71 async_cookie_t cookie; 71 async_cookie_t cookie;
72 async_func_ptr *func; 72 async_func_ptr *func;
73 void *data; 73 void *data;
74 struct list_head *running; 74 struct async_domain *running;
75}; 75};
76 76
77static DECLARE_WAIT_QUEUE_HEAD(async_done); 77static DECLARE_WAIT_QUEUE_HEAD(async_done);
@@ -82,13 +82,12 @@ static atomic_t entry_count;
82/* 82/*
83 * MUST be called with the lock held! 83 * MUST be called with the lock held!
84 */ 84 */
85static async_cookie_t __lowest_in_progress(struct list_head *running) 85static async_cookie_t __lowest_in_progress(struct async_domain *running)
86{ 86{
87 struct async_entry *entry; 87 struct async_entry *entry;
88 88
89 if (!list_empty(running)) { 89 if (!list_empty(&running->domain)) {
90 entry = list_first_entry(running, 90 entry = list_first_entry(&running->domain, typeof(*entry), list);
91 struct async_entry, list);
92 return entry->cookie; 91 return entry->cookie;
93 } 92 }
94 93
@@ -99,7 +98,7 @@ static async_cookie_t __lowest_in_progress(struct list_head *running)
99 return next_cookie; /* "infinity" value */ 98 return next_cookie; /* "infinity" value */
100} 99}
101 100
102static async_cookie_t lowest_in_progress(struct list_head *running) 101static async_cookie_t lowest_in_progress(struct async_domain *running)
103{ 102{
104 unsigned long flags; 103 unsigned long flags;
105 async_cookie_t ret; 104 async_cookie_t ret;
@@ -119,10 +118,11 @@ static void async_run_entry_fn(struct work_struct *work)
119 container_of(work, struct async_entry, work); 118 container_of(work, struct async_entry, work);
120 unsigned long flags; 119 unsigned long flags;
121 ktime_t uninitialized_var(calltime), delta, rettime; 120 ktime_t uninitialized_var(calltime), delta, rettime;
121 struct async_domain *running = entry->running;
122 122
123 /* 1) move self to the running queue */ 123 /* 1) move self to the running queue */
124 spin_lock_irqsave(&async_lock, flags); 124 spin_lock_irqsave(&async_lock, flags);
125 list_move_tail(&entry->list, entry->running); 125 list_move_tail(&entry->list, &running->domain);
126 spin_unlock_irqrestore(&async_lock, flags); 126 spin_unlock_irqrestore(&async_lock, flags);
127 127
128 /* 2) run (and print duration) */ 128 /* 2) run (and print duration) */
@@ -156,7 +156,7 @@ static void async_run_entry_fn(struct work_struct *work)
156 wake_up(&async_done); 156 wake_up(&async_done);
157} 157}
158 158
159static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct list_head *running) 159static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct async_domain *running)
160{ 160{
161 struct async_entry *entry; 161 struct async_entry *entry;
162 unsigned long flags; 162 unsigned long flags;
@@ -223,7 +223,7 @@ EXPORT_SYMBOL_GPL(async_schedule);
223 * Note: This function may be called from atomic or non-atomic contexts. 223 * Note: This function may be called from atomic or non-atomic contexts.
224 */ 224 */
225async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data, 225async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
226 struct list_head *running) 226 struct async_domain *running)
227{ 227{
228 return __async_schedule(ptr, data, running); 228 return __async_schedule(ptr, data, running);
229} 229}
@@ -238,20 +238,20 @@ void async_synchronize_full(void)
238{ 238{
239 do { 239 do {
240 async_synchronize_cookie(next_cookie); 240 async_synchronize_cookie(next_cookie);
241 } while (!list_empty(&async_running) || !list_empty(&async_pending)); 241 } while (!list_empty(&async_running.domain) || !list_empty(&async_pending));
242} 242}
243EXPORT_SYMBOL_GPL(async_synchronize_full); 243EXPORT_SYMBOL_GPL(async_synchronize_full);
244 244
245/** 245/**
246 * async_synchronize_full_domain - synchronize all asynchronous function within a certain domain 246 * async_synchronize_full_domain - synchronize all asynchronous function within a certain domain
247 * @list: running list to synchronize on 247 * @domain: running list to synchronize on
248 * 248 *
249 * This function waits until all asynchronous function calls for the 249 * This function waits until all asynchronous function calls for the
250 * synchronization domain specified by the running list @list have been done. 250 * synchronization domain specified by the running list @domain have been done.
251 */ 251 */
252void async_synchronize_full_domain(struct list_head *list) 252void async_synchronize_full_domain(struct async_domain *domain)
253{ 253{
254 async_synchronize_cookie_domain(next_cookie, list); 254 async_synchronize_cookie_domain(next_cookie, domain);
255} 255}
256EXPORT_SYMBOL_GPL(async_synchronize_full_domain); 256EXPORT_SYMBOL_GPL(async_synchronize_full_domain);
257 257
@@ -261,11 +261,10 @@ EXPORT_SYMBOL_GPL(async_synchronize_full_domain);
261 * @running: running list to synchronize on 261 * @running: running list to synchronize on
262 * 262 *
263 * This function waits until all asynchronous function calls for the 263 * This function waits until all asynchronous function calls for the
264 * synchronization domain specified by the running list @list submitted 264 * synchronization domain specified by running list @running submitted
265 * prior to @cookie have been done. 265 * prior to @cookie have been done.
266 */ 266 */
267void async_synchronize_cookie_domain(async_cookie_t cookie, 267void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain *running)
268 struct list_head *running)
269{ 268{
270 ktime_t uninitialized_var(starttime), delta, endtime; 269 ktime_t uninitialized_var(starttime), delta, endtime;
271 270
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 89eae93445cf..fa1e31206892 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1545,7 +1545,7 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
1545 struct snd_soc_dapm_context *d; 1545 struct snd_soc_dapm_context *d;
1546 LIST_HEAD(up_list); 1546 LIST_HEAD(up_list);
1547 LIST_HEAD(down_list); 1547 LIST_HEAD(down_list);
1548 LIST_HEAD(async_domain); 1548 ASYNC_DOMAIN_EXCLUSIVE(async_domain);
1549 enum snd_soc_bias_level bias; 1549 enum snd_soc_bias_level bias;
1550 1550
1551 trace_snd_soc_dapm_start(card); 1551 trace_snd_soc_dapm_start(card);