Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

edac: move EDAC device definitions to drivers/edac/edac_device.h

The edac_core.h header contain data structures and function
definitions for both EDAC MC and EDAC device.

Let's move the devices ones to a separate header file, as part
of a header reorganization.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+284 -254
+1 -237
drivers/edac/edac_core.h
··· 36 36 #include <linux/edac.h> 37 37 38 38 #include "edac_pci.h" 39 + #include "edac_device.h" 39 40 40 41 #if PAGE_SHIFT < 20 41 42 #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) ··· 96 95 97 96 #define to_mci(k) container_of(k, struct mem_ctl_info, dev) 98 97 99 - /* 100 - * The following are the structures to provide for a generic 101 - * or abstract 'edac_device'. This set of structures and the 102 - * code that implements the APIs for the same, provide for 103 - * registering EDAC type devices which are NOT standard memory. 104 - * 105 - * CPU caches (L1 and L2) 106 - * DMA engines 107 - * Core CPU switches 108 - * Fabric switch units 109 - * PCIe interface controllers 110 - * other EDAC/ECC type devices that can be monitored for 111 - * errors, etc. 112 - * 113 - * It allows for a 2 level set of hierarchy. For example: 114 - * 115 - * cache could be composed of L1, L2 and L3 levels of cache. 116 - * Each CPU core would have its own L1 cache, while sharing 117 - * L2 and maybe L3 caches. 118 - * 119 - * View them arranged, via the sysfs presentation: 120 - * /sys/devices/system/edac/.. 121 - * 122 - * mc/ <existing memory device directory> 123 - * cpu/cpu0/.. <L1 and L2 block directory> 124 - * /L1-cache/ce_count 125 - * /ue_count 126 - * /L2-cache/ce_count 127 - * /ue_count 128 - * cpu/cpu1/.. <L1 and L2 block directory> 129 - * /L1-cache/ce_count 130 - * /ue_count 131 - * /L2-cache/ce_count 132 - * /ue_count 133 - * ... 134 - * 135 - * the L1 and L2 directories would be "edac_device_block's" 136 - */ 137 - 138 - struct edac_device_counter { 139 - u32 ue_count; 140 - u32 ce_count; 141 - }; 142 - 143 - /* forward reference */ 144 - struct edac_device_ctl_info; 145 - struct edac_device_block; 146 - 147 - /* edac_dev_sysfs_attribute structure 148 - * used for driver sysfs attributes in mem_ctl_info 149 - * for extra controls and attributes: 150 - * like high level error Injection controls 151 - */ 152 - struct edac_dev_sysfs_attribute { 153 - struct attribute attr; 154 - ssize_t (*show)(struct edac_device_ctl_info *, char *); 155 - ssize_t (*store)(struct edac_device_ctl_info *, const char *, size_t); 156 - }; 157 - 158 - /* edac_dev_sysfs_block_attribute structure 159 - * 160 - * used in leaf 'block' nodes for adding controls/attributes 161 - * 162 - * each block in each instance of the containing control structure 163 - * can have an array of the following. The show and store functions 164 - * will be filled in with the show/store function in the 165 - * low level driver. 166 - * 167 - * The 'value' field will be the actual value field used for 168 - * counting 169 - */ 170 - struct edac_dev_sysfs_block_attribute { 171 - struct attribute attr; 172 - ssize_t (*show)(struct kobject *, struct attribute *, char *); 173 - ssize_t (*store)(struct kobject *, struct attribute *, 174 - const char *, size_t); 175 - struct edac_device_block *block; 176 - 177 - unsigned int value; 178 - }; 179 - 180 - /* device block control structure */ 181 - struct edac_device_block { 182 - struct edac_device_instance *instance; /* Up Pointer */ 183 - char name[EDAC_DEVICE_NAME_LEN + 1]; 184 - 185 - struct edac_device_counter counters; /* basic UE and CE counters */ 186 - 187 - int nr_attribs; /* how many attributes */ 188 - 189 - /* this block's attributes, could be NULL */ 190 - struct edac_dev_sysfs_block_attribute *block_attributes; 191 - 192 - /* edac sysfs device control */ 193 - struct kobject kobj; 194 - }; 195 - 196 - /* device instance control structure */ 197 - struct edac_device_instance { 198 - struct edac_device_ctl_info *ctl; /* Up pointer */ 199 - char name[EDAC_DEVICE_NAME_LEN + 4]; 200 - 201 - struct edac_device_counter counters; /* instance counters */ 202 - 203 - u32 nr_blocks; /* how many blocks */ 204 - struct edac_device_block *blocks; /* block array */ 205 - 206 - /* edac sysfs device control */ 207 - struct kobject kobj; 208 - }; 209 - 210 - 211 - /* 212 - * Abstract edac_device control info structure 213 - * 214 - */ 215 - struct edac_device_ctl_info { 216 - /* for global list of edac_device_ctl_info structs */ 217 - struct list_head link; 218 - 219 - struct module *owner; /* Module owner of this control struct */ 220 - 221 - int dev_idx; 222 - 223 - /* Per instance controls for this edac_device */ 224 - int log_ue; /* boolean for logging UEs */ 225 - int log_ce; /* boolean for logging CEs */ 226 - int panic_on_ue; /* boolean for panic'ing on an UE */ 227 - unsigned poll_msec; /* number of milliseconds to poll interval */ 228 - unsigned long delay; /* number of jiffies for poll_msec */ 229 - 230 - /* Additional top controller level attributes, but specified 231 - * by the low level driver. 232 - * 233 - * Set by the low level driver to provide attributes at the 234 - * controller level, same level as 'ue_count' and 'ce_count' above. 235 - * An array of structures, NULL terminated 236 - * 237 - * If attributes are desired, then set to array of attributes 238 - * If no attributes are desired, leave NULL 239 - */ 240 - struct edac_dev_sysfs_attribute *sysfs_attributes; 241 - 242 - /* pointer to main 'edac' subsys in sysfs */ 243 - struct bus_type *edac_subsys; 244 - 245 - /* the internal state of this controller instance */ 246 - int op_state; 247 - /* work struct for this instance */ 248 - struct delayed_work work; 249 - 250 - /* pointer to edac polling checking routine: 251 - * If NOT NULL: points to polling check routine 252 - * If NULL: Then assumes INTERRUPT operation, where 253 - * MC driver will receive events 254 - */ 255 - void (*edac_check) (struct edac_device_ctl_info * edac_dev); 256 - 257 - struct device *dev; /* pointer to device structure */ 258 - 259 - const char *mod_name; /* module name */ 260 - const char *ctl_name; /* edac controller name */ 261 - const char *dev_name; /* pci/platform/etc... name */ 262 - 263 - void *pvt_info; /* pointer to 'private driver' info */ 264 - 265 - unsigned long start_time; /* edac_device load start time (jiffies) */ 266 - 267 - struct completion removal_complete; 268 - 269 - /* sysfs top name under 'edac' directory 270 - * and instance name: 271 - * cpu/cpu0/... 272 - * cpu/cpu1/... 273 - * cpu/cpu2/... 274 - * ... 275 - */ 276 - char name[EDAC_DEVICE_NAME_LEN + 1]; 277 - 278 - /* Number of instances supported on this control structure 279 - * and the array of those instances 280 - */ 281 - u32 nr_instances; 282 - struct edac_device_instance *instances; 283 - 284 - /* Event counters for the this whole EDAC Device */ 285 - struct edac_device_counter counters; 286 - 287 - /* edac sysfs device control for the 'name' 288 - * device this structure controls 289 - */ 290 - struct kobject kobj; 291 - }; 292 - 293 - /* To get from the instance's wq to the beginning of the ctl structure */ 294 - #define to_edac_mem_ctl_work(w) \ 295 - container_of(w, struct mem_ctl_info, work) 296 - 297 - #define to_edac_device_ctl_work(w) \ 298 - container_of(w,struct edac_device_ctl_info,work) 299 - 300 - /* 301 - * The alloc() and free() functions for the 'edac_device' control info 302 - * structure. A MC driver will allocate one of these for each edac_device 303 - * it is going to control/register with the EDAC CORE. 304 - */ 305 - extern struct edac_device_ctl_info *edac_device_alloc_ctl_info( 306 - unsigned sizeof_private, 307 - char *edac_device_name, unsigned nr_instances, 308 - char *edac_block_name, unsigned nr_blocks, 309 - unsigned offset_value, 310 - struct edac_dev_sysfs_block_attribute *block_attributes, 311 - unsigned nr_attribs, 312 - int device_index); 313 - 314 - /* The offset value can be: 315 - * -1 indicating no offset value 316 - * 0 for zero-based block numbers 317 - * 1 for 1-based block number 318 - * other for other-based block number 319 - */ 320 - #define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1) 321 - 322 - extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info); 323 - 324 98 struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, 325 99 unsigned n_layers, 326 100 struct edac_mc_layer *layers, ··· 125 349 const int low_layer, 126 350 const char *msg, 127 351 const char *other_detail); 128 - 129 - /* 130 - * edac_device APIs 131 - */ 132 - extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev); 133 - extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev); 134 - extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev, 135 - int inst_nr, int block_nr, const char *msg); 136 - extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, 137 - int inst_nr, int block_nr, const char *msg); 138 - extern int edac_device_alloc_index(void); 139 - extern const char *edac_layer_name[]; 140 352 141 353 /* 142 354 * edac misc APIs
+12 -15
drivers/edac/edac_device.c
··· 12 12 * 19 Jan 2007 13 13 */ 14 14 15 - #include <linux/module.h> 16 - #include <linux/types.h> 17 - #include <linux/smp.h> 18 - #include <linux/init.h> 19 - #include <linux/sysctl.h> 20 - #include <linux/highmem.h> 21 - #include <linux/timer.h> 22 - #include <linux/slab.h> 23 - #include <linux/jiffies.h> 24 - #include <linux/spinlock.h> 25 - #include <linux/list.h> 26 - #include <linux/ctype.h> 27 - #include <linux/workqueue.h> 28 - #include <asm/uaccess.h> 29 15 #include <asm/page.h> 16 + #include <asm/uaccess.h> 17 + #include <linux/ctype.h> 18 + #include <linux/highmem.h> 19 + #include <linux/init.h> 20 + #include <linux/jiffies.h> 21 + #include <linux/module.h> 22 + #include <linux/slab.h> 23 + #include <linux/smp.h> 24 + #include <linux/spinlock.h> 25 + #include <linux/sysctl.h> 26 + #include <linux/timer.h> 30 27 31 - #include "edac_core.h" 28 + #include "edac_device.h" 32 29 #include "edac_module.h" 33 30 34 31 /* lock for the list: 'edac_device_list', manipulation of this list
+269
drivers/edac/edac_device.h
··· 1 + /* 2 + * Defines, structures, APIs for edac_device 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_DEVICE_H_ 23 + #define _EDAC_DEVICE_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/types.h> 31 + #include <linux/sysfs.h> 32 + #include <linux/workqueue.h> 33 + 34 + 35 + /* 36 + * The following are the structures to provide for a generic 37 + * or abstract 'edac_device'. This set of structures and the 38 + * code that implements the APIs for the same, provide for 39 + * registering EDAC type devices which are NOT standard memory. 40 + * 41 + * CPU caches (L1 and L2) 42 + * DMA engines 43 + * Core CPU switches 44 + * Fabric switch units 45 + * PCIe interface controllers 46 + * other EDAC/ECC type devices that can be monitored for 47 + * errors, etc. 48 + * 49 + * It allows for a 2 level set of hierarchy. For example: 50 + * 51 + * cache could be composed of L1, L2 and L3 levels of cache. 52 + * Each CPU core would have its own L1 cache, while sharing 53 + * L2 and maybe L3 caches. 54 + * 55 + * View them arranged, via the sysfs presentation: 56 + * /sys/devices/system/edac/.. 57 + * 58 + * mc/ <existing memory device directory> 59 + * cpu/cpu0/.. <L1 and L2 block directory> 60 + * /L1-cache/ce_count 61 + * /ue_count 62 + * /L2-cache/ce_count 63 + * /ue_count 64 + * cpu/cpu1/.. <L1 and L2 block directory> 65 + * /L1-cache/ce_count 66 + * /ue_count 67 + * /L2-cache/ce_count 68 + * /ue_count 69 + * ... 70 + * 71 + * the L1 and L2 directories would be "edac_device_block's" 72 + */ 73 + 74 + struct edac_device_counter { 75 + u32 ue_count; 76 + u32 ce_count; 77 + }; 78 + 79 + /* forward reference */ 80 + struct edac_device_ctl_info; 81 + struct edac_device_block; 82 + 83 + /* edac_dev_sysfs_attribute structure 84 + * used for driver sysfs attributes in mem_ctl_info 85 + * for extra controls and attributes: 86 + * like high level error Injection controls 87 + */ 88 + struct edac_dev_sysfs_attribute { 89 + struct attribute attr; 90 + ssize_t (*show)(struct edac_device_ctl_info *, char *); 91 + ssize_t (*store)(struct edac_device_ctl_info *, const char *, size_t); 92 + }; 93 + 94 + /* edac_dev_sysfs_block_attribute structure 95 + * 96 + * used in leaf 'block' nodes for adding controls/attributes 97 + * 98 + * each block in each instance of the containing control structure 99 + * can have an array of the following. The show and store functions 100 + * will be filled in with the show/store function in the 101 + * low level driver. 102 + * 103 + * The 'value' field will be the actual value field used for 104 + * counting 105 + */ 106 + struct edac_dev_sysfs_block_attribute { 107 + struct attribute attr; 108 + ssize_t (*show)(struct kobject *, struct attribute *, char *); 109 + ssize_t (*store)(struct kobject *, struct attribute *, 110 + const char *, size_t); 111 + struct edac_device_block *block; 112 + 113 + unsigned int value; 114 + }; 115 + 116 + /* device block control structure */ 117 + struct edac_device_block { 118 + struct edac_device_instance *instance; /* Up Pointer */ 119 + char name[EDAC_DEVICE_NAME_LEN + 1]; 120 + 121 + struct edac_device_counter counters; /* basic UE and CE counters */ 122 + 123 + int nr_attribs; /* how many attributes */ 124 + 125 + /* this block's attributes, could be NULL */ 126 + struct edac_dev_sysfs_block_attribute *block_attributes; 127 + 128 + /* edac sysfs device control */ 129 + struct kobject kobj; 130 + }; 131 + 132 + /* device instance control structure */ 133 + struct edac_device_instance { 134 + struct edac_device_ctl_info *ctl; /* Up pointer */ 135 + char name[EDAC_DEVICE_NAME_LEN + 4]; 136 + 137 + struct edac_device_counter counters; /* instance counters */ 138 + 139 + u32 nr_blocks; /* how many blocks */ 140 + struct edac_device_block *blocks; /* block array */ 141 + 142 + /* edac sysfs device control */ 143 + struct kobject kobj; 144 + }; 145 + 146 + 147 + /* 148 + * Abstract edac_device control info structure 149 + * 150 + */ 151 + struct edac_device_ctl_info { 152 + /* for global list of edac_device_ctl_info structs */ 153 + struct list_head link; 154 + 155 + struct module *owner; /* Module owner of this control struct */ 156 + 157 + int dev_idx; 158 + 159 + /* Per instance controls for this edac_device */ 160 + int log_ue; /* boolean for logging UEs */ 161 + int log_ce; /* boolean for logging CEs */ 162 + int panic_on_ue; /* boolean for panic'ing on an UE */ 163 + unsigned poll_msec; /* number of milliseconds to poll interval */ 164 + unsigned long delay; /* number of jiffies for poll_msec */ 165 + 166 + /* Additional top controller level attributes, but specified 167 + * by the low level driver. 168 + * 169 + * Set by the low level driver to provide attributes at the 170 + * controller level, same level as 'ue_count' and 'ce_count' above. 171 + * An array of structures, NULL terminated 172 + * 173 + * If attributes are desired, then set to array of attributes 174 + * If no attributes are desired, leave NULL 175 + */ 176 + struct edac_dev_sysfs_attribute *sysfs_attributes; 177 + 178 + /* pointer to main 'edac' subsys in sysfs */ 179 + struct bus_type *edac_subsys; 180 + 181 + /* the internal state of this controller instance */ 182 + int op_state; 183 + /* work struct for this instance */ 184 + struct delayed_work work; 185 + 186 + /* pointer to edac polling checking routine: 187 + * If NOT NULL: points to polling check routine 188 + * If NULL: Then assumes INTERRUPT operation, where 189 + * MC driver will receive events 190 + */ 191 + void (*edac_check) (struct edac_device_ctl_info * edac_dev); 192 + 193 + struct device *dev; /* pointer to device structure */ 194 + 195 + const char *mod_name; /* module name */ 196 + const char *ctl_name; /* edac controller name */ 197 + const char *dev_name; /* pci/platform/etc... name */ 198 + 199 + void *pvt_info; /* pointer to 'private driver' info */ 200 + 201 + unsigned long start_time; /* edac_device load start time (jiffies) */ 202 + 203 + struct completion removal_complete; 204 + 205 + /* sysfs top name under 'edac' directory 206 + * and instance name: 207 + * cpu/cpu0/... 208 + * cpu/cpu1/... 209 + * cpu/cpu2/... 210 + * ... 211 + */ 212 + char name[EDAC_DEVICE_NAME_LEN + 1]; 213 + 214 + /* Number of instances supported on this control structure 215 + * and the array of those instances 216 + */ 217 + u32 nr_instances; 218 + struct edac_device_instance *instances; 219 + 220 + /* Event counters for the this whole EDAC Device */ 221 + struct edac_device_counter counters; 222 + 223 + /* edac sysfs device control for the 'name' 224 + * device this structure controls 225 + */ 226 + struct kobject kobj; 227 + }; 228 + 229 + /* To get from the instance's wq to the beginning of the ctl structure */ 230 + #define to_edac_mem_ctl_work(w) \ 231 + container_of(w, struct mem_ctl_info, work) 232 + 233 + #define to_edac_device_ctl_work(w) \ 234 + container_of(w,struct edac_device_ctl_info,work) 235 + 236 + /* 237 + * The alloc() and free() functions for the 'edac_device' control info 238 + * structure. A MC driver will allocate one of these for each edac_device 239 + * it is going to control/register with the EDAC CORE. 240 + */ 241 + extern struct edac_device_ctl_info *edac_device_alloc_ctl_info( 242 + unsigned sizeof_private, 243 + char *edac_device_name, unsigned nr_instances, 244 + char *edac_block_name, unsigned nr_blocks, 245 + unsigned offset_value, 246 + struct edac_dev_sysfs_block_attribute *block_attributes, 247 + unsigned nr_attribs, 248 + int device_index); 249 + 250 + /* The offset value can be: 251 + * -1 indicating no offset value 252 + * 0 for zero-based block numbers 253 + * 1 for 1-based block number 254 + * other for other-based block number 255 + */ 256 + #define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1) 257 + 258 + extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info); 259 + 260 + extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev); 261 + extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev); 262 + extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev, 263 + int inst_nr, int block_nr, const char *msg); 264 + extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, 265 + int inst_nr, int block_nr, const char *msg); 266 + extern int edac_device_alloc_index(void); 267 + extern const char *edac_layer_name[]; 268 + 269 + #endif
+2 -2
drivers/edac/edac_device_sysfs.c
··· 1 1 /* 2 2 * file for managing the edac_device subsystem of devices for EDAC 3 3 * 4 - * (C) 2007 SoftwareBitMaker 4 + * (C) 2007 SoftwareBitMaker 5 5 * 6 6 * This file may be distributed under the terms of the 7 7 * GNU General Public License. ··· 15 15 #include <linux/slab.h> 16 16 #include <linux/edac.h> 17 17 18 - #include "edac_core.h" 18 + #include "edac_device.h" 19 19 #include "edac_module.h" 20 20 21 21 #define EDAC_DEVICE_SYMLINK "device"