padata: Flush the padata queues actively
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / include / linux / padata.h
CommitLineData
16295bec
SK
1/*
2 * padata.h - header for the padata parallelization interface
3 *
4 * Copyright (C) 2008, 2009 secunet Security Networks AG
5 * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef PADATA_H
22#define PADATA_H
23
24#include <linux/workqueue.h>
25#include <linux/spinlock.h>
26#include <linux/list.h>
d46a5ac7 27#include <linux/timer.h>
16295bec
SK
28
29struct padata_priv {
30 struct list_head list;
31 struct parallel_data *pd;
32 int cb_cpu;
33 int seq_nr;
34 int info;
35 void (*parallel)(struct padata_priv *padata);
36 void (*serial)(struct padata_priv *padata);
37};
38
39struct padata_list {
40 struct list_head list;
41 spinlock_t lock;
42};
43
44struct padata_queue {
45 struct padata_list parallel;
46 struct padata_list reorder;
47 struct padata_list serial;
48 struct work_struct pwork;
49 struct work_struct swork;
50 struct parallel_data *pd;
51 atomic_t num_obj;
52 int cpu_index;
53};
54
55struct parallel_data {
56 struct padata_instance *pinst;
57 struct padata_queue *queue;
58 atomic_t seq_nr;
59 atomic_t reorder_objects;
60 atomic_t refcnt;
61 unsigned int max_seq_nr;
62 cpumask_var_t cpumask;
63 spinlock_t lock;
d46a5ac7 64 struct timer_list timer;
16295bec
SK
65};
66
67struct padata_instance {
68 struct notifier_block cpu_notifier;
69 struct workqueue_struct *wq;
70 struct parallel_data *pd;
71 cpumask_var_t cpumask;
72 struct mutex lock;
73 u8 flags;
74#define PADATA_INIT 1
75#define PADATA_RESET 2
76};
77
78extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
79 struct workqueue_struct *wq);
80extern void padata_free(struct padata_instance *pinst);
81extern int padata_do_parallel(struct padata_instance *pinst,
82 struct padata_priv *padata, int cb_cpu);
83extern void padata_do_serial(struct padata_priv *padata);
84extern int padata_set_cpumask(struct padata_instance *pinst,
85 cpumask_var_t cpumask);
86extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
87extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
88extern void padata_start(struct padata_instance *pinst);
89extern void padata_stop(struct padata_instance *pinst);
90#endif