padata: update documentation
[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 28
0198ffd1
SK
29/**
30 * struct padata_priv - Embedded to the users data structure.
31 *
32 * @list: List entry, to attach to the padata lists.
33 * @pd: Pointer to the internal control structure.
34 * @cb_cpu: Callback cpu for serializatioon.
35 * @seq_nr: Sequence number of the parallelized data object.
36 * @info: Used to pass information from the parallel to the serial function.
37 * @parallel: Parallel execution function.
38 * @serial: Serial complete function.
39 */
16295bec
SK
40struct padata_priv {
41 struct list_head list;
42 struct parallel_data *pd;
43 int cb_cpu;
44 int seq_nr;
45 int info;
46 void (*parallel)(struct padata_priv *padata);
47 void (*serial)(struct padata_priv *padata);
48};
49
0198ffd1
SK
50/**
51 * struct padata_list
52 *
53 * @list: List head.
54 * @lock: List lock.
55 */
16295bec
SK
56struct padata_list {
57 struct list_head list;
58 spinlock_t lock;
59};
60
0198ffd1
SK
61/**
62 * struct padata_queue - The percpu padata queues.
63 *
64 * @parallel: List to wait for parallelization.
65 * @reorder: List to wait for reordering after parallel processing.
66 * @serial: List to wait for serialization after reordering.
67 * @pwork: work struct for parallelization.
68 * @swork: work struct for serialization.
69 * @pd: Backpointer to the internal control structure.
0198ffd1
SK
70 * @cpu_index: Index of the cpu.
71 */
16295bec
SK
72struct padata_queue {
73 struct padata_list parallel;
74 struct padata_list reorder;
75 struct padata_list serial;
76 struct work_struct pwork;
77 struct work_struct swork;
78 struct parallel_data *pd;
16295bec
SK
79 int cpu_index;
80};
81
0198ffd1
SK
82/**
83 * struct parallel_data - Internal control structure, covers everything
84 * that depends on the cpumask in use.
85 *
86 * @pinst: padata instance.
87 * @queue: percpu padata queues.
88 * @seq_nr: The sequence number that will be attached to the next object.
89 * @reorder_objects: Number of objects waiting in the reorder queues.
90 * @refcnt: Number of objects holding a reference on this parallel_data.
91 * @max_seq_nr: Maximal used sequence number.
92 * @cpumask: cpumask in use.
93 * @lock: Reorder lock.
5f1a8c1b 94 * @processed: Number of already processed objects.
0198ffd1
SK
95 * @timer: Reorder timer.
96 */
16295bec
SK
97struct parallel_data {
98 struct padata_instance *pinst;
99 struct padata_queue *queue;
100 atomic_t seq_nr;
101 atomic_t reorder_objects;
102 atomic_t refcnt;
103 unsigned int max_seq_nr;
104 cpumask_var_t cpumask;
5f1a8c1b
SK
105 spinlock_t lock ____cacheline_aligned;
106 unsigned int processed;
d46a5ac7 107 struct timer_list timer;
16295bec
SK
108};
109
0198ffd1
SK
110/**
111 * struct padata_instance - The overall control structure.
112 *
113 * @cpu_notifier: cpu hotplug notifier.
114 * @wq: The workqueue in use.
115 * @pd: The internal control structure.
116 * @cpumask: User supplied cpumask.
117 * @lock: padata instance lock.
118 * @flags: padata flags.
119 */
16295bec
SK
120struct padata_instance {
121 struct notifier_block cpu_notifier;
122 struct workqueue_struct *wq;
123 struct parallel_data *pd;
124 cpumask_var_t cpumask;
125 struct mutex lock;
126 u8 flags;
127#define PADATA_INIT 1
128#define PADATA_RESET 2
4c879170 129#define PADATA_INVALID 4
16295bec
SK
130};
131
132extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
133 struct workqueue_struct *wq);
134extern void padata_free(struct padata_instance *pinst);
135extern int padata_do_parallel(struct padata_instance *pinst,
136 struct padata_priv *padata, int cb_cpu);
137extern void padata_do_serial(struct padata_priv *padata);
138extern int padata_set_cpumask(struct padata_instance *pinst,
139 cpumask_var_t cpumask);
140extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
141extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
4c879170 142extern int padata_start(struct padata_instance *pinst);
16295bec
SK
143extern void padata_stop(struct padata_instance *pinst);
144#endif