aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-29 07:56:00 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-12-15 05:54:50 -0500
commit0b892c717714334890ea179a2dc1941a223e446f (patch)
tree7fdd492b9228dc682bae6c3bc81102a1e5930dcc
parentfd77f6ba7b3ae5f02f8d4d706df6534ae9722dce (diff)
edac: move EDAC PCI definitions to drivers/edac/edac_pci.h
The edac_core.h header contain data structures and function definitions for the 3 parts of EDAC: MC, PCI and device. Let's move the PCI ones to a separate header file, as part of a header reorganization. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/edac/edac_core.h145
-rw-r--r--drivers/edac/edac_pci.c19
-rw-r--r--drivers/edac/edac_pci.h173
-rw-r--r--drivers/edac/edac_pci_sysfs.c2
-rw-r--r--include/linux/edac.h2
5 files changed, 185 insertions, 156 deletions
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 1723f3643e75..8c7cca2d6e40 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -35,8 +35,7 @@
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36#include <linux/edac.h> 36#include <linux/edac.h>
37 37
38#define EDAC_DEVICE_NAME_LEN 31 38#include "edac_pci.h"
39#define EDAC_ATTRIB_VALUE_LEN 15
40 39
41#if PAGE_SHIFT < 20 40#if PAGE_SHIFT < 20
42#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) 41#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
@@ -321,128 +320,6 @@ extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
321 320
322extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info); 321extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
323 322
324#ifdef CONFIG_PCI
325
326struct edac_pci_counter {
327 atomic_t pe_count;
328 atomic_t npe_count;
329};
330
331/*
332 * Abstract edac_pci control info structure
333 *
334 */
335struct edac_pci_ctl_info {
336 /* for global list of edac_pci_ctl_info structs */
337 struct list_head link;
338
339 int pci_idx;
340
341 struct bus_type *edac_subsys; /* pointer to subsystem */
342
343 /* the internal state of this controller instance */
344 int op_state;
345 /* work struct for this instance */
346 struct delayed_work work;
347
348 /* pointer to edac polling checking routine:
349 * If NOT NULL: points to polling check routine
350 * If NULL: Then assumes INTERRUPT operation, where
351 * MC driver will receive events
352 */
353 void (*edac_check) (struct edac_pci_ctl_info * edac_dev);
354
355 struct device *dev; /* pointer to device structure */
356
357 const char *mod_name; /* module name */
358 const char *ctl_name; /* edac controller name */
359 const char *dev_name; /* pci/platform/etc... name */
360
361 void *pvt_info; /* pointer to 'private driver' info */
362
363 unsigned long start_time; /* edac_pci load start time (jiffies) */
364
365 struct completion complete;
366
367 /* sysfs top name under 'edac' directory
368 * and instance name:
369 * cpu/cpu0/...
370 * cpu/cpu1/...
371 * cpu/cpu2/...
372 * ...
373 */
374 char name[EDAC_DEVICE_NAME_LEN + 1];
375
376 /* Event counters for the this whole EDAC Device */
377 struct edac_pci_counter counters;
378
379 /* edac sysfs device control for the 'name'
380 * device this structure controls
381 */
382 struct kobject kobj;
383};
384
385#define to_edac_pci_ctl_work(w) \
386 container_of(w, struct edac_pci_ctl_info,work)
387
388/* write all or some bits in a byte-register*/
389static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
390 u8 mask)
391{
392 if (mask != 0xff) {
393 u8 buf;
394
395 pci_read_config_byte(pdev, offset, &buf);
396 value &= mask;
397 buf &= ~mask;
398 value |= buf;
399 }
400
401 pci_write_config_byte(pdev, offset, value);
402}
403
404/* write all or some bits in a word-register*/
405static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
406 u16 value, u16 mask)
407{
408 if (mask != 0xffff) {
409 u16 buf;
410
411 pci_read_config_word(pdev, offset, &buf);
412 value &= mask;
413 buf &= ~mask;
414 value |= buf;
415 }
416
417 pci_write_config_word(pdev, offset, value);
418}
419
420/*
421 * pci_write_bits32
422 *
423 * edac local routine to do pci_write_config_dword, but adds
424 * a mask parameter. If mask is all ones, ignore the mask.
425 * Otherwise utilize the mask to isolate specified bits
426 *
427 * write all or some bits in a dword-register
428 */
429static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
430 u32 value, u32 mask)
431{
432 if (mask != 0xffffffff) {
433 u32 buf;
434
435 pci_read_config_dword(pdev, offset, &buf);
436 value &= mask;
437 buf &= ~mask;
438 value |= buf;
439 }
440
441 pci_write_config_dword(pdev, offset, value);
442}
443
444#endif /* CONFIG_PCI */
445
446struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, 323struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
447 unsigned n_layers, 324 unsigned n_layers,
448 struct edac_mc_layer *layers, 325 struct edac_mc_layer *layers,
@@ -486,26 +363,6 @@ extern int edac_device_alloc_index(void);
486extern const char *edac_layer_name[]; 363extern const char *edac_layer_name[];
487 364
488/* 365/*
489 * edac_pci APIs
490 */
491extern struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
492 const char *edac_pci_name);
493
494extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci);
495
496extern int edac_pci_alloc_index(void);
497extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx);
498extern struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev);
499
500extern struct edac_pci_ctl_info *edac_pci_create_generic_ctl(
501 struct device *dev,
502 const char *mod_name);
503
504extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci);
505extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci);
506extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
507
508/*
509 * edac misc APIs 366 * edac misc APIs
510 */ 367 */
511extern char *edac_op_state_to_string(int op_state); 368extern char *edac_op_state_to_string(int op_state);
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index 8f2f2899a7a2..02a0af4f53b3 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -9,22 +9,19 @@
9 * or implied. 9 * or implied.
10 * 10 *
11 */ 11 */
12#include <asm/page.h>
13#include <asm/uaccess.h>
14#include <linux/ctype.h>
15#include <linux/highmem.h>
16#include <linux/init.h>
12#include <linux/module.h> 17#include <linux/module.h>
13#include <linux/types.h> 18#include <linux/slab.h>
14#include <linux/smp.h> 19#include <linux/smp.h>
15#include <linux/init.h> 20#include <linux/spinlock.h>
16#include <linux/sysctl.h> 21#include <linux/sysctl.h>
17#include <linux/highmem.h>
18#include <linux/timer.h> 22#include <linux/timer.h>
19#include <linux/slab.h>
20#include <linux/spinlock.h>
21#include <linux/list.h>
22#include <linux/ctype.h>
23#include <linux/workqueue.h>
24#include <asm/uaccess.h>
25#include <asm/page.h>
26 23
27#include "edac_core.h" 24#include "edac_pci.h"
28#include "edac_module.h" 25#include "edac_module.h"
29 26
30static DEFINE_MUTEX(edac_pci_ctls_mutex); 27static DEFINE_MUTEX(edac_pci_ctls_mutex);
diff --git a/drivers/edac/edac_pci.h b/drivers/edac/edac_pci.h
new file mode 100644
index 000000000000..9da0c6fb0634
--- /dev/null
+++ b/drivers/edac/edac_pci.h
@@ -0,0 +1,173 @@
1/*
2 * Defines, structures, APIs for edac_pci and edac_pci_sysfs
3 *
4 * (C) 2007 Linux Networx (http://lnxi.com)
5 * This file may be distributed under the terms of the
6 * GNU General Public License.
7 *
8 * Written by Thayne Harbaugh
9 * Based on work by Dan Hollis <goemon at anime dot net> and others.
10 * http://www.anime.net/~goemon/linux-ecc/
11 *
12 * NMI handling support added by
13 * Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
14 *
15 * Refactored for multi-source files:
16 * Doug Thompson <norsk5@xmission.com>
17 *
18 * Please look at Documentation/driver-api/edac.rst for more info about
19 * EDAC core structs and functions.
20 */
21
22#ifndef _EDAC_PCI_H_
23#define _EDAC_PCI_H_
24
25#include <linux/completion.h>
26#include <linux/device.h>
27#include <linux/edac.h>
28#include <linux/kobject.h>
29#include <linux/list.h>
30#include <linux/pci.h>
31#include <linux/types.h>
32#include <linux/workqueue.h>
33
34#ifdef CONFIG_PCI
35
36struct edac_pci_counter {
37 atomic_t pe_count;
38 atomic_t npe_count;
39};
40
41/*
42 * Abstract edac_pci control info structure
43 *
44 */
45struct edac_pci_ctl_info {
46 /* for global list of edac_pci_ctl_info structs */
47 struct list_head link;
48
49 int pci_idx;
50
51 struct bus_type *edac_subsys; /* pointer to subsystem */
52
53 /* the internal state of this controller instance */
54 int op_state;
55 /* work struct for this instance */
56 struct delayed_work work;
57
58 /* pointer to edac polling checking routine:
59 * If NOT NULL: points to polling check routine
60 * If NULL: Then assumes INTERRUPT operation, where
61 * MC driver will receive events
62 */
63 void (*edac_check) (struct edac_pci_ctl_info * edac_dev);
64
65 struct device *dev; /* pointer to device structure */
66
67 const char *mod_name; /* module name */
68 const char *ctl_name; /* edac controller name */
69 const char *dev_name; /* pci/platform/etc... name */
70
71 void *pvt_info; /* pointer to 'private driver' info */
72
73 unsigned long start_time; /* edac_pci load start time (jiffies) */
74
75 struct completion complete;
76
77 /* sysfs top name under 'edac' directory
78 * and instance name:
79 * cpu/cpu0/...
80 * cpu/cpu1/...
81 * cpu/cpu2/...
82 * ...
83 */
84 char name[EDAC_DEVICE_NAME_LEN + 1];
85
86 /* Event counters for the this whole EDAC Device */
87 struct edac_pci_counter counters;
88
89 /* edac sysfs device control for the 'name'
90 * device this structure controls
91 */
92 struct kobject kobj;
93};
94
95#define to_edac_pci_ctl_work(w) \
96 container_of(w, struct edac_pci_ctl_info,work)
97
98/* write all or some bits in a byte-register*/
99static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
100 u8 mask)
101{
102 if (mask != 0xff) {
103 u8 buf;
104
105 pci_read_config_byte(pdev, offset, &buf);
106 value &= mask;
107 buf &= ~mask;
108 value |= buf;
109 }
110
111 pci_write_config_byte(pdev, offset, value);
112}
113
114/* write all or some bits in a word-register*/
115static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
116 u16 value, u16 mask)
117{
118 if (mask != 0xffff) {
119 u16 buf;
120
121 pci_read_config_word(pdev, offset, &buf);
122 value &= mask;
123 buf &= ~mask;
124 value |= buf;
125 }
126
127 pci_write_config_word(pdev, offset, value);
128}
129
130/*
131 * pci_write_bits32
132 *
133 * edac local routine to do pci_write_config_dword, but adds
134 * a mask parameter. If mask is all ones, ignore the mask.
135 * Otherwise utilize the mask to isolate specified bits
136 *
137 * write all or some bits in a dword-register
138 */
139static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
140 u32 value, u32 mask)
141{
142 if (mask != 0xffffffff) {
143 u32 buf;
144
145 pci_read_config_dword(pdev, offset, &buf);
146 value &= mask;
147 buf &= ~mask;
148 value |= buf;
149 }
150
151 pci_write_config_dword(pdev, offset, value);
152}
153
154#endif /* CONFIG_PCI */
155
156extern struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
157 const char *edac_pci_name);
158
159extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci);
160
161extern int edac_pci_alloc_index(void);
162extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx);
163extern struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev);
164
165extern struct edac_pci_ctl_info *edac_pci_create_generic_ctl(
166 struct device *dev,
167 const char *mod_name);
168
169extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci);
170extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci);
171extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
172
173#endif
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 6e3428ba400f..dbeb048d8efb 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -11,7 +11,7 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/ctype.h> 12#include <linux/ctype.h>
13 13
14#include "edac_core.h" 14#include "edac_pci.h"
15#include "edac_module.h" 15#include "edac_module.h"
16 16
17#define EDAC_PCI_SYMLINK "device" 17#define EDAC_PCI_SYMLINK "device"
diff --git a/include/linux/edac.h b/include/linux/edac.h
index cb56dcba68c6..0fec0f26469b 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -18,6 +18,8 @@
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <linux/debugfs.h> 19#include <linux/debugfs.h>
20 20
21#define EDAC_DEVICE_NAME_LEN 31
22
21struct device; 23struct device;
22 24
23#define EDAC_OPSTATE_INVAL -1 25#define EDAC_OPSTATE_INVAL -1