powerpc: Fix compile errors in prom_init_check for gcc 4.5
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / padata.h
blob8d8406246eefb85c0941f136d1ce06f3d26521d2
1 /*
2 * padata.h - header for the padata parallelization interface
4 * Copyright (C) 2008, 2009 secunet Security Networks AG
5 * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com>
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.
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.
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.
21 #ifndef PADATA_H
22 #define PADATA_H
24 #include <linux/workqueue.h>
25 #include <linux/spinlock.h>
26 #include <linux/list.h>
27 #include <linux/timer.h>
29 /**
30 * struct padata_priv - Embedded to the users data structure.
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.
40 struct 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);
50 /**
51 * struct padata_list
53 * @list: List head.
54 * @lock: List lock.
56 struct padata_list {
57 struct list_head list;
58 spinlock_t lock;
61 /**
62 * struct padata_queue - The percpu padata queues.
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.
70 * @num_obj: Number of objects that are processed by this cpu.
71 * @cpu_index: Index of the cpu.
73 struct padata_queue {
74 struct padata_list parallel;
75 struct padata_list reorder;
76 struct padata_list serial;
77 struct work_struct pwork;
78 struct work_struct swork;
79 struct parallel_data *pd;
80 atomic_t num_obj;
81 int cpu_index;
84 /**
85 * struct parallel_data - Internal control structure, covers everything
86 * that depends on the cpumask in use.
88 * @pinst: padata instance.
89 * @queue: percpu padata queues.
90 * @seq_nr: The sequence number that will be attached to the next object.
91 * @reorder_objects: Number of objects waiting in the reorder queues.
92 * @refcnt: Number of objects holding a reference on this parallel_data.
93 * @max_seq_nr: Maximal used sequence number.
94 * @cpumask: cpumask in use.
95 * @lock: Reorder lock.
96 * @timer: Reorder timer.
98 struct parallel_data {
99 struct padata_instance *pinst;
100 struct padata_queue *queue;
101 atomic_t seq_nr;
102 atomic_t reorder_objects;
103 atomic_t refcnt;
104 unsigned int max_seq_nr;
105 cpumask_var_t cpumask;
106 spinlock_t lock;
107 struct timer_list timer;
111 * struct padata_instance - The overall control structure.
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.
120 struct 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
131 extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
132 struct workqueue_struct *wq);
133 extern void padata_free(struct padata_instance *pinst);
134 extern int padata_do_parallel(struct padata_instance *pinst,
135 struct padata_priv *padata, int cb_cpu);
136 extern void padata_do_serial(struct padata_priv *padata);
137 extern int padata_set_cpumask(struct padata_instance *pinst,
138 cpumask_var_t cpumask);
139 extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
140 extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
141 extern void padata_start(struct padata_instance *pinst);
142 extern void padata_stop(struct padata_instance *pinst);
143 #endif