Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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