Changes in 4.9.233 xfs: catch inode allocation state mismatch corruption xfs: validate cached inodes are free when allocated xfs: don't call xfs_da_shrink_inode with NULL bp net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe() crypto: ccp - Release all allocated memory if sha type is invalid media: rc: prevent memory leak in cx23888_ir_probe ath9k_htc: release allocated buffer if timed out ath9k: release allocated buffer if timed out PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge ARM: 8986/1: hw_breakpoint: Don't invoke overflow handler on uaccess watchpoints drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl() drm: hold gem reference until object is no longer accessed f2fs: check memory boundary by insane namelen f2fs: check if file namelen exceeds max value 9p/trans_fd: abort p9_read_work if req status changed 9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work x86/build/lto: Fix truncated .bss with -fdata-sections x86, vmlinux.lds: Page-align end of ..page_aligned sections fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins. rds: Prevent kernel-infoleak in rds_notify_queue_get() xfs: fix missed wakeup on l_flush_wait uapi: includes linux/types.h before exporting files install several missing uapi headers net/x25: Fix x25_neigh refcnt leak when x25 disconnect net/x25: Fix null-ptr-deref in x25_disconnect sh: Fix validation of system call number net: lan78xx: add missing endpoint sanity check net: lan78xx: fix transfer-buffer memory leak mlx4: disable device on shutdown mlxsw: core: Increase scope of RCU read-side critical section mlxsw: core: Free EMAD transactions using kfree_rcu() ibmvnic: Fix IRQ mapping disposal in error path mac80211: mesh: Free ie data when leaving mesh mac80211: mesh: Free pending skb when destroying a mpath arm64: csum: Fix handling of bad packets usb: hso: Fix debug compile warning on sparc32 qed: Disable "MFW indication via attention" SPAM every 5 minutes nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame parisc: add support for cmpxchg on u8 pointers net: ethernet: ravb: exit if re-initialization fails in tx timeout Revert "i2c: cadence: Fix the hold bit setting" xen-netfront: fix potential deadlock in xennet_remove() KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled x86/i8259: Use printk_deferred() to prevent deadlock random32: update the net random state on interrupt and activity ARM: percpu.h: fix build error random: fix circular include dependency on arm64 after addition of percpu.h random32: remove net_rand_state from the latent entropy gcc plugin random32: move the pseudo-random 32-bit definitions to prandom.h ext4: fix direct I/O read error USB: serial: qcserial: add EM7305 QDL product ID net/mlx5e: Don't support phys switch id if not in switchdev mode ALSA: seq: oss: Serialize ioctls Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt() omapfb: dss: Fix max fclk divider for omap36xx vgacon: Fix for missing check in scrollback handling mtd: properly check all write ioctls for permissions leds: wm831x-status: fix use-after-free on unbind leds: da903x: fix use-after-free on unbind leds: lm3533: fix use-after-free on unbind leds: 88pm860x: fix use-after-free on unbind net/9p: validate fds in p9_fd_open drm/nouveau/fbcon: fix module unload when fbcon init has failed for some reason cfg80211: check vendor command doit pointer before use igb: reinit_locked() should be called with rtnl_lock atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent tools lib traceevent: Fix memory leak in process_dynamic_array_len xattr: break delegations in {set,remove}xattr binder: Prevent context manager from incrementing ref 0 ipv4: Silence suspicious RCU usage warning ipv6: fix memory leaks on IPV6_ADDRFORM path vxlan: Ensure FDB dump is performed under RCU net: lan78xx: replace bogus endpoint lookup Revert "vxlan: fix tos value before xmit" usb: hso: check for return value in hso_serial_common_create() Smack: fix use-after-free in smk_write_relabel_self() tracepoint: Mark __tracepoint_string's __used gpio: fix oops resulting from calling of_get_named_gpio(NULL, ...) cgroup: add missing skcd->no_refcnt check in cgroup_sk_clone() EDAC: Fix reference count leaks arm64: dts: qcom: msm8916: Replace invalid bias-pull-none property arm64: dts: exynos: Fix silent hang after boot on Espresso m68k: mac: Don't send IOP message until channel is idle m68k: mac: Fix IOP status/control register writes platform/x86: intel-hid: Fix return value check in check_acpi_dev() platform/x86: intel-vbtn: Fix return value check in check_acpi_dev() ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() ARM: socfpga: PM: add missing put_device() call in socfpga_setup_ocram_self_refresh() drm/tilcdc: fix leak & null ref in panel_connector_get_modes Bluetooth: add a mutex lock to avoid UAF in do_enale_set fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls drm/radeon: Fix reference count leaks caused by pm_runtime_get_sync video: fbdev: neofb: fix memory leak in neo_scan_monitor() md-cluster: fix wild pointer of unlock_all_bitmaps() drm/nouveau: fix multiple instances of reference count leaks drm/debugfs: fix plain echo to connector "force" attribute mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls brcmfmac: To fix Bss Info flag definition Bug iwlegacy: Check the return value of pcie_capability_read_*() usb: gadget: net2280: fix memory leak on probe error handling paths bdc: Fix bug causing crash after multiple disconnects dyndbg: fix a BUG_ON in ddebug_describe_flags bcache: fix super block seq numbers comparision in register_cache_set() ACPICA: Do not increment operation_region reference counts for field units agp/intel: Fix a memory leak on module initialisation failure video: fbdev: sm712fb: fix an issue about iounmap for a wrong address console: newport_con: fix an issue about leak related system resources video: pxafb: Fix the function used to balance a 'dma_alloc_coherent()' call iio: improve IIO_CONCENTRATION channel type description leds: lm355x: avoid enum conversion warning media: omap3isp: Add missed v4l2_ctrl_handler_free() for preview_init_entities() scsi: cumana_2: Fix different dev_id between request_irq() and free_irq() drm/mipi: use dcs write for mipi_dsi_dcs_set_tear_scanline cxl: Fix kobject memleak drm/radeon: fix array out-of-bounds read and write issues scsi: powertec: Fix different dev_id between request_irq() and free_irq() scsi: eesox: Fix different dev_id between request_irq() and free_irq() media: firewire: Using uninitialized values in node_probe() media: exynos4-is: Add missed check for pinctrl_lookup_state() xfs: fix reflink quota reservation accounting error PCI: Fix pci_cfg_wait queue locking problem leds: core: Flush scheduled work for system suspend drm: panel: simple: Fix bpc for LG LB070WV8 panel scsi: scsi_debug: Add check for sdebug_max_queue during module init mwifiex: Prevent memory corruption handling keys powerpc/vdso: Fix vdso cpu truncation staging: rtl8192u: fix a dubious looking mask before a shift PCI/ASPM: Add missing newline in sysfs 'policy' drm/imx: tve: fix regulator_disable error path USB: serial: iuu_phoenix: fix led-activity helpers usb: dwc2: Fix error path in gadget registration scsi: mesh: Fix panic after host or bus reset Smack: fix another vsscanf out of bounds Smack: prevent underflow in smk_set_cipso() power: supply: check if calc_soc succeeded in pm860x_init_battery selftests/powerpc: Fix CPU affinity for child process selftests/powerpc: Fix online CPU selection s390/qeth: don't process empty bridge port events wl1251: fix always return 0 error net: spider_net: Fix the size used in a 'dma_free_coherent()' call fsl/fman: use 32-bit unsigned integer fsl/fman: fix dereference null return value fsl/fman: fix unreachable code fsl/fman: check dereferencing null pointer fsl/fman: fix eth hash table allocation dlm: Fix kobject memleak pinctrl-single: fix pcs_parse_pinconf() return value drivers/net/wan/lapbether: Added needed_headroom and a skb->len check net/nfc/rawsock.c: add CAP_NET_RAW check. net: Set fput_needed iff FDPUT_FPUT is set USB: serial: cp210x: re-enable auto-RTS on open USB: serial: cp210x: enable usb generic throttle/unthrottle ALSA: usb-audio: Creative USB X-Fi Pro SB1095 volume knob support ALSA: usb-audio: fix overeager device match for MacroSilicon MS2109 ALSA: usb-audio: add quirk for Pioneer DDJ-RB crypto: qat - fix double free in qat_uclo_create_batch_init_list crypto: ccp - Fix use of merged scatterlists fs/minix: check return value of sb_getblk() fs/minix: don't allow getting deleted inodes fs/minix: reject too-large maximum file size ALSA: usb-audio: work around streaming quirk for MacroSilicon MS2109 9p: Fix memory leak in v9fs_mount parisc: mask out enable and reserved bits from sba imask ARM: 8992/1: Fix unwind_frame for clang-built kernels xen/balloon: fix accounting in alloc_xenballooned_pages error path xen/balloon: make the balloon wait interruptible smb3: warn on confusing error scenario with sec=krb5 PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context() btrfs: don't allocate anonymous block device for user invisible roots btrfs: only search for left_info if there is no right_info in try_merge_free_space btrfs: fix memory leaks after failure to lookup checksums during inode logging iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() xtensa: fix xtensa_pmu_setup prototype powerpc: Fix circular dependency between percpu.h and mmu.h net: ethernet: stmmac: Disable hardware multicast filter net: stmmac: dwmac1000: provide multicast filter fallback net/compat: Add missing sock updates for SCM_RIGHTS md/raid5: Fix Force reconstruct-write io stuck in degraded raid5 bcache: allocate meta data pages as compound pages mac80211: fix misplaced while instead of if MIPS: CPU#0 is not hotpluggable ext2: fix missing percpu_counter_inc ocfs2: change slot number type s16 to u16 ftrace: Setup correct FTRACE_FL_REGS flags for module kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler watchdog: f71808e_wdt: indicate WDIOF_CARDRESET support in watchdog_info.options watchdog: f71808e_wdt: remove use of wrong watchdog_info option watchdog: f71808e_wdt: clear watchdog timeout occurred flag pseries: Fix 64 bit logical memory block panic mfd: arizona: Ensure 32k clock is put on driver unbind and error USB: serial: ftdi_sio: make process-packet buffer unsigned USB: serial: ftdi_sio: clean up receive processing gpu: ipu-v3: image-convert: Combine rotate/no-rotate irq handlers iommu/omap: Check for failure of a call to omap_iommu_dump_ctx iommu/vt-d: Enforce PASID devTLB field mask i2c: rcar: slave: only send STOP event when we have been addressed clk: clk-atlas6: fix return value check in atlas6_clk_init() pwm: bcm-iproc: handle clk_get_rate() return Input: sentelic - fix error return when fsp_reg_write fails drm/vmwgfx: Fix two list_for_each loop exit tests net: qcom/emac: add missed clk_disable_unprepare in error path of emac_clks_phase1_init nfs: Fix getxattr kernel panic and memory overflow fs/ufs: avoid potential u32 multiplication overflow mfd: dln2: Run event handler loop under spinlock ALSA: echoaudio: Fix potential Oops in snd_echo_resume() sh: landisk: Add missing initialization of sh_io_port_base khugepaged: retract_page_tables() remember to test exit mm: Avoid calling build_all_zonelists_init under hotplug context Linux 4.9.233 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ied62cb0768f5bd8e989d75e7c2ccf6f1e6f2efd4
749 lines
19 KiB
C
749 lines
19 KiB
C
/*
|
|
* (C) 2005, 2006 Linux Networx (http://lnxi.com)
|
|
* This file may be distributed under the terms of the
|
|
* GNU General Public License.
|
|
*
|
|
* Written Doug Thompson <norsk5@xmission.com>
|
|
*
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/edac.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/ctype.h>
|
|
|
|
#include "edac_core.h"
|
|
#include "edac_module.h"
|
|
|
|
#define EDAC_PCI_SYMLINK "device"
|
|
|
|
/* data variables exported via sysfs */
|
|
static int check_pci_errors; /* default NO check PCI parity */
|
|
static int edac_pci_panic_on_pe; /* default NO panic on PCI Parity */
|
|
static int edac_pci_log_pe = 1; /* log PCI parity errors */
|
|
static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
|
|
static int edac_pci_poll_msec = 1000; /* one second workq period */
|
|
|
|
static atomic_t pci_parity_count = ATOMIC_INIT(0);
|
|
static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
|
|
|
|
static struct kobject *edac_pci_top_main_kobj;
|
|
static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
|
|
|
|
/* getter functions for the data variables */
|
|
int edac_pci_get_check_errors(void)
|
|
{
|
|
return check_pci_errors;
|
|
}
|
|
|
|
static int edac_pci_get_log_pe(void)
|
|
{
|
|
return edac_pci_log_pe;
|
|
}
|
|
|
|
static int edac_pci_get_log_npe(void)
|
|
{
|
|
return edac_pci_log_npe;
|
|
}
|
|
|
|
static int edac_pci_get_panic_on_pe(void)
|
|
{
|
|
return edac_pci_panic_on_pe;
|
|
}
|
|
|
|
int edac_pci_get_poll_msec(void)
|
|
{
|
|
return edac_pci_poll_msec;
|
|
}
|
|
|
|
/**************************** EDAC PCI sysfs instance *******************/
|
|
static ssize_t instance_pe_count_show(struct edac_pci_ctl_info *pci, char *data)
|
|
{
|
|
return sprintf(data, "%u\n", atomic_read(&pci->counters.pe_count));
|
|
}
|
|
|
|
static ssize_t instance_npe_count_show(struct edac_pci_ctl_info *pci,
|
|
char *data)
|
|
{
|
|
return sprintf(data, "%u\n", atomic_read(&pci->counters.npe_count));
|
|
}
|
|
|
|
#define to_instance(k) container_of(k, struct edac_pci_ctl_info, kobj)
|
|
#define to_instance_attr(a) container_of(a, struct instance_attribute, attr)
|
|
|
|
/* DEVICE instance kobject release() function */
|
|
static void edac_pci_instance_release(struct kobject *kobj)
|
|
{
|
|
struct edac_pci_ctl_info *pci;
|
|
|
|
edac_dbg(0, "\n");
|
|
|
|
/* Form pointer to containing struct, the pci control struct */
|
|
pci = to_instance(kobj);
|
|
|
|
/* decrement reference count on top main kobj */
|
|
kobject_put(edac_pci_top_main_kobj);
|
|
|
|
kfree(pci); /* Free the control struct */
|
|
}
|
|
|
|
/* instance specific attribute structure */
|
|
struct instance_attribute {
|
|
struct attribute attr;
|
|
ssize_t(*show) (struct edac_pci_ctl_info *, char *);
|
|
ssize_t(*store) (struct edac_pci_ctl_info *, const char *, size_t);
|
|
};
|
|
|
|
/* Function to 'show' fields from the edac_pci 'instance' structure */
|
|
static ssize_t edac_pci_instance_show(struct kobject *kobj,
|
|
struct attribute *attr, char *buffer)
|
|
{
|
|
struct edac_pci_ctl_info *pci = to_instance(kobj);
|
|
struct instance_attribute *instance_attr = to_instance_attr(attr);
|
|
|
|
if (instance_attr->show)
|
|
return instance_attr->show(pci, buffer);
|
|
return -EIO;
|
|
}
|
|
|
|
/* Function to 'store' fields into the edac_pci 'instance' structure */
|
|
static ssize_t edac_pci_instance_store(struct kobject *kobj,
|
|
struct attribute *attr,
|
|
const char *buffer, size_t count)
|
|
{
|
|
struct edac_pci_ctl_info *pci = to_instance(kobj);
|
|
struct instance_attribute *instance_attr = to_instance_attr(attr);
|
|
|
|
if (instance_attr->store)
|
|
return instance_attr->store(pci, buffer, count);
|
|
return -EIO;
|
|
}
|
|
|
|
/* fs_ops table */
|
|
static const struct sysfs_ops pci_instance_ops = {
|
|
.show = edac_pci_instance_show,
|
|
.store = edac_pci_instance_store
|
|
};
|
|
|
|
#define INSTANCE_ATTR(_name, _mode, _show, _store) \
|
|
static struct instance_attribute attr_instance_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
.show = _show, \
|
|
.store = _store, \
|
|
};
|
|
|
|
INSTANCE_ATTR(pe_count, S_IRUGO, instance_pe_count_show, NULL);
|
|
INSTANCE_ATTR(npe_count, S_IRUGO, instance_npe_count_show, NULL);
|
|
|
|
/* pci instance attributes */
|
|
static struct instance_attribute *pci_instance_attr[] = {
|
|
&attr_instance_pe_count,
|
|
&attr_instance_npe_count,
|
|
NULL
|
|
};
|
|
|
|
/* the ktype for a pci instance */
|
|
static struct kobj_type ktype_pci_instance = {
|
|
.release = edac_pci_instance_release,
|
|
.sysfs_ops = &pci_instance_ops,
|
|
.default_attrs = (struct attribute **)pci_instance_attr,
|
|
};
|
|
|
|
/*
|
|
* edac_pci_create_instance_kobj
|
|
*
|
|
* construct one EDAC PCI instance's kobject for use
|
|
*/
|
|
static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
|
|
{
|
|
struct kobject *main_kobj;
|
|
int err;
|
|
|
|
edac_dbg(0, "\n");
|
|
|
|
/* First bump the ref count on the top main kobj, which will
|
|
* track the number of PCI instances we have, and thus nest
|
|
* properly on keeping the module loaded
|
|
*/
|
|
main_kobj = kobject_get(edac_pci_top_main_kobj);
|
|
if (!main_kobj) {
|
|
err = -ENODEV;
|
|
goto error_out;
|
|
}
|
|
|
|
/* And now register this new kobject under the main kobj */
|
|
err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
|
|
edac_pci_top_main_kobj, "pci%d", idx);
|
|
if (err != 0) {
|
|
edac_dbg(2, "failed to register instance pci%d\n", idx);
|
|
kobject_put(edac_pci_top_main_kobj);
|
|
goto error_out;
|
|
}
|
|
|
|
kobject_uevent(&pci->kobj, KOBJ_ADD);
|
|
edac_dbg(1, "Register instance 'pci%d' kobject\n", idx);
|
|
|
|
return 0;
|
|
|
|
/* Error unwind statck */
|
|
error_out:
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* edac_pci_unregister_sysfs_instance_kobj
|
|
*
|
|
* unregister the kobj for the EDAC PCI instance
|
|
*/
|
|
static void edac_pci_unregister_sysfs_instance_kobj(
|
|
struct edac_pci_ctl_info *pci)
|
|
{
|
|
edac_dbg(0, "\n");
|
|
|
|
/* Unregister the instance kobject and allow its release
|
|
* function release the main reference count and then
|
|
* kfree the memory
|
|
*/
|
|
kobject_put(&pci->kobj);
|
|
}
|
|
|
|
/***************************** EDAC PCI sysfs root **********************/
|
|
#define to_edacpci(k) container_of(k, struct edac_pci_ctl_info, kobj)
|
|
#define to_edacpci_attr(a) container_of(a, struct edac_pci_attr, attr)
|
|
|
|
/* simple show/store functions for attributes */
|
|
static ssize_t edac_pci_int_show(void *ptr, char *buffer)
|
|
{
|
|
int *value = ptr;
|
|
return sprintf(buffer, "%d\n", *value);
|
|
}
|
|
|
|
static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
|
|
{
|
|
int *value = ptr;
|
|
|
|
if (isdigit(*buffer))
|
|
*value = simple_strtoul(buffer, NULL, 0);
|
|
|
|
return count;
|
|
}
|
|
|
|
struct edac_pci_dev_attribute {
|
|
struct attribute attr;
|
|
void *value;
|
|
ssize_t(*show) (void *, char *);
|
|
ssize_t(*store) (void *, const char *, size_t);
|
|
};
|
|
|
|
/* Set of show/store abstract level functions for PCI Parity object */
|
|
static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
|
|
char *buffer)
|
|
{
|
|
struct edac_pci_dev_attribute *edac_pci_dev;
|
|
edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
|
|
|
|
if (edac_pci_dev->show)
|
|
return edac_pci_dev->show(edac_pci_dev->value, buffer);
|
|
return -EIO;
|
|
}
|
|
|
|
static ssize_t edac_pci_dev_store(struct kobject *kobj,
|
|
struct attribute *attr, const char *buffer,
|
|
size_t count)
|
|
{
|
|
struct edac_pci_dev_attribute *edac_pci_dev;
|
|
edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
|
|
|
|
if (edac_pci_dev->store)
|
|
return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
|
|
return -EIO;
|
|
}
|
|
|
|
static const struct sysfs_ops edac_pci_sysfs_ops = {
|
|
.show = edac_pci_dev_show,
|
|
.store = edac_pci_dev_store
|
|
};
|
|
|
|
#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \
|
|
static struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
.value = &_name, \
|
|
.show = _show, \
|
|
.store = _store, \
|
|
};
|
|
|
|
#define EDAC_PCI_STRING_ATTR(_name,_data,_mode,_show,_store) \
|
|
static struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
.value = _data, \
|
|
.show = _show, \
|
|
.store = _store, \
|
|
};
|
|
|
|
/* PCI Parity control files */
|
|
EDAC_PCI_ATTR(check_pci_errors, S_IRUGO | S_IWUSR, edac_pci_int_show,
|
|
edac_pci_int_store);
|
|
EDAC_PCI_ATTR(edac_pci_log_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
|
|
edac_pci_int_store);
|
|
EDAC_PCI_ATTR(edac_pci_log_npe, S_IRUGO | S_IWUSR, edac_pci_int_show,
|
|
edac_pci_int_store);
|
|
EDAC_PCI_ATTR(edac_pci_panic_on_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
|
|
edac_pci_int_store);
|
|
EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
|
|
EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL);
|
|
|
|
/* Base Attributes of the memory ECC object */
|
|
static struct edac_pci_dev_attribute *edac_pci_attr[] = {
|
|
&edac_pci_attr_check_pci_errors,
|
|
&edac_pci_attr_edac_pci_log_pe,
|
|
&edac_pci_attr_edac_pci_log_npe,
|
|
&edac_pci_attr_edac_pci_panic_on_pe,
|
|
&edac_pci_attr_pci_parity_count,
|
|
&edac_pci_attr_pci_nonparity_count,
|
|
NULL,
|
|
};
|
|
|
|
/*
|
|
* edac_pci_release_main_kobj
|
|
*
|
|
* This release function is called when the reference count to the
|
|
* passed kobj goes to zero.
|
|
*
|
|
* This kobj is the 'main' kobject that EDAC PCI instances
|
|
* link to, and thus provide for proper nesting counts
|
|
*/
|
|
static void edac_pci_release_main_kobj(struct kobject *kobj)
|
|
{
|
|
edac_dbg(0, "here to module_put(THIS_MODULE)\n");
|
|
|
|
kfree(kobj);
|
|
|
|
/* last reference to top EDAC PCI kobject has been removed,
|
|
* NOW release our ref count on the core module
|
|
*/
|
|
module_put(THIS_MODULE);
|
|
}
|
|
|
|
/* ktype struct for the EDAC PCI main kobj */
|
|
static struct kobj_type ktype_edac_pci_main_kobj = {
|
|
.release = edac_pci_release_main_kobj,
|
|
.sysfs_ops = &edac_pci_sysfs_ops,
|
|
.default_attrs = (struct attribute **)edac_pci_attr,
|
|
};
|
|
|
|
/**
|
|
* edac_pci_main_kobj_setup: Setup the sysfs for EDAC PCI attributes.
|
|
*/
|
|
static int edac_pci_main_kobj_setup(void)
|
|
{
|
|
int err;
|
|
struct bus_type *edac_subsys;
|
|
|
|
edac_dbg(0, "\n");
|
|
|
|
/* check and count if we have already created the main kobject */
|
|
if (atomic_inc_return(&edac_pci_sysfs_refcount) != 1)
|
|
return 0;
|
|
|
|
/* First time, so create the main kobject and its
|
|
* controls and attributes
|
|
*/
|
|
edac_subsys = edac_get_sysfs_subsys();
|
|
|
|
/* Bump the reference count on this module to ensure the
|
|
* modules isn't unloaded until we deconstruct the top
|
|
* level main kobj for EDAC PCI
|
|
*/
|
|
if (!try_module_get(THIS_MODULE)) {
|
|
edac_dbg(1, "try_module_get() failed\n");
|
|
err = -ENODEV;
|
|
goto decrement_count_fail;
|
|
}
|
|
|
|
edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
|
|
if (!edac_pci_top_main_kobj) {
|
|
edac_dbg(1, "Failed to allocate\n");
|
|
err = -ENOMEM;
|
|
goto kzalloc_fail;
|
|
}
|
|
|
|
/* Instanstiate the pci object */
|
|
err = kobject_init_and_add(edac_pci_top_main_kobj,
|
|
&ktype_edac_pci_main_kobj,
|
|
&edac_subsys->dev_root->kobj, "pci");
|
|
if (err) {
|
|
edac_dbg(1, "Failed to register '.../edac/pci'\n");
|
|
goto kobject_init_and_add_fail;
|
|
}
|
|
|
|
/* At this point, to 'release' the top level kobject
|
|
* for EDAC PCI, then edac_pci_main_kobj_teardown()
|
|
* must be used, for resources to be cleaned up properly
|
|
*/
|
|
kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD);
|
|
edac_dbg(1, "Registered '.../edac/pci' kobject\n");
|
|
|
|
return 0;
|
|
|
|
/* Error unwind statck */
|
|
kobject_init_and_add_fail:
|
|
kobject_put(edac_pci_top_main_kobj);
|
|
|
|
kzalloc_fail:
|
|
module_put(THIS_MODULE);
|
|
|
|
decrement_count_fail:
|
|
/* if are on this error exit, nothing to tear down */
|
|
atomic_dec(&edac_pci_sysfs_refcount);
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* edac_pci_main_kobj_teardown()
|
|
*
|
|
* if no longer linked (needed) remove the top level EDAC PCI
|
|
* kobject with its controls and attributes
|
|
*/
|
|
static void edac_pci_main_kobj_teardown(void)
|
|
{
|
|
edac_dbg(0, "\n");
|
|
|
|
/* Decrement the count and only if no more controller instances
|
|
* are connected perform the unregisteration of the top level
|
|
* main kobj
|
|
*/
|
|
if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
|
|
edac_dbg(0, "called kobject_put on main kobj\n");
|
|
kobject_put(edac_pci_top_main_kobj);
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
* edac_pci_create_sysfs
|
|
*
|
|
* Create the controls/attributes for the specified EDAC PCI device
|
|
*/
|
|
int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
|
|
{
|
|
int err;
|
|
struct kobject *edac_kobj = &pci->kobj;
|
|
|
|
edac_dbg(0, "idx=%d\n", pci->pci_idx);
|
|
|
|
/* create the top main EDAC PCI kobject, IF needed */
|
|
err = edac_pci_main_kobj_setup();
|
|
if (err)
|
|
return err;
|
|
|
|
/* Create this instance's kobject under the MAIN kobject */
|
|
err = edac_pci_create_instance_kobj(pci, pci->pci_idx);
|
|
if (err)
|
|
goto unregister_cleanup;
|
|
|
|
err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK);
|
|
if (err) {
|
|
edac_dbg(0, "sysfs_create_link() returned err= %d\n", err);
|
|
goto symlink_fail;
|
|
}
|
|
|
|
return 0;
|
|
|
|
/* Error unwind stack */
|
|
symlink_fail:
|
|
edac_pci_unregister_sysfs_instance_kobj(pci);
|
|
|
|
unregister_cleanup:
|
|
edac_pci_main_kobj_teardown();
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* edac_pci_remove_sysfs
|
|
*
|
|
* remove the controls and attributes for this EDAC PCI device
|
|
*/
|
|
void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci)
|
|
{
|
|
edac_dbg(0, "index=%d\n", pci->pci_idx);
|
|
|
|
/* Remove the symlink */
|
|
sysfs_remove_link(&pci->kobj, EDAC_PCI_SYMLINK);
|
|
|
|
/* remove this PCI instance's sysfs entries */
|
|
edac_pci_unregister_sysfs_instance_kobj(pci);
|
|
|
|
/* Call the main unregister function, which will determine
|
|
* if this 'pci' is the last instance.
|
|
* If it is, the main kobject will be unregistered as a result
|
|
*/
|
|
edac_dbg(0, "calling edac_pci_main_kobj_teardown()\n");
|
|
edac_pci_main_kobj_teardown();
|
|
}
|
|
|
|
/************************ PCI error handling *************************/
|
|
static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
|
|
{
|
|
int where;
|
|
u16 status;
|
|
|
|
where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
|
|
pci_read_config_word(dev, where, &status);
|
|
|
|
/* If we get back 0xFFFF then we must suspect that the card has been
|
|
* pulled but the Linux PCI layer has not yet finished cleaning up.
|
|
* We don't want to report on such devices
|
|
*/
|
|
|
|
if (status == 0xFFFF) {
|
|
u32 sanity;
|
|
|
|
pci_read_config_dword(dev, 0, &sanity);
|
|
|
|
if (sanity == 0xFFFFFFFF)
|
|
return 0;
|
|
}
|
|
|
|
status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
|
|
PCI_STATUS_PARITY;
|
|
|
|
if (status)
|
|
/* reset only the bits we are interested in */
|
|
pci_write_config_word(dev, where, status);
|
|
|
|
return status;
|
|
}
|
|
|
|
|
|
/* Clear any PCI parity errors logged by this device. */
|
|
static void edac_pci_dev_parity_clear(struct pci_dev *dev)
|
|
{
|
|
u8 header_type;
|
|
|
|
get_pci_parity_status(dev, 0);
|
|
|
|
/* read the device TYPE, looking for bridges */
|
|
pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
|
|
|
|
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
|
|
get_pci_parity_status(dev, 1);
|
|
}
|
|
|
|
/*
|
|
* PCI Parity polling
|
|
*
|
|
* Function to retrieve the current parity status
|
|
* and decode it
|
|
*
|
|
*/
|
|
static void edac_pci_dev_parity_test(struct pci_dev *dev)
|
|
{
|
|
unsigned long flags;
|
|
u16 status;
|
|
u8 header_type;
|
|
|
|
/* stop any interrupts until we can acquire the status */
|
|
local_irq_save(flags);
|
|
|
|
/* read the STATUS register on this device */
|
|
status = get_pci_parity_status(dev, 0);
|
|
|
|
/* read the device TYPE, looking for bridges */
|
|
pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
edac_dbg(4, "PCI STATUS= 0x%04x %s\n", status, dev_name(&dev->dev));
|
|
|
|
/* check the status reg for errors on boards NOT marked as broken
|
|
* if broken, we cannot trust any of the status bits
|
|
*/
|
|
if (status && !dev->broken_parity_status) {
|
|
if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI,
|
|
"Signaled System Error on %s\n",
|
|
pci_name(dev));
|
|
atomic_inc(&pci_nonparity_count);
|
|
}
|
|
|
|
if (status & (PCI_STATUS_PARITY)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI,
|
|
"Master Data Parity Error on %s\n",
|
|
pci_name(dev));
|
|
|
|
atomic_inc(&pci_parity_count);
|
|
}
|
|
|
|
if (status & (PCI_STATUS_DETECTED_PARITY)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI,
|
|
"Detected Parity Error on %s\n",
|
|
pci_name(dev));
|
|
|
|
atomic_inc(&pci_parity_count);
|
|
}
|
|
}
|
|
|
|
|
|
edac_dbg(4, "PCI HEADER TYPE= 0x%02x %s\n",
|
|
header_type, dev_name(&dev->dev));
|
|
|
|
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
|
/* On bridges, need to examine secondary status register */
|
|
status = get_pci_parity_status(dev, 1);
|
|
|
|
edac_dbg(4, "PCI SEC_STATUS= 0x%04x %s\n",
|
|
status, dev_name(&dev->dev));
|
|
|
|
/* check the secondary status reg for errors,
|
|
* on NOT broken boards
|
|
*/
|
|
if (status && !dev->broken_parity_status) {
|
|
if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
|
|
"Signaled System Error on %s\n",
|
|
pci_name(dev));
|
|
atomic_inc(&pci_nonparity_count);
|
|
}
|
|
|
|
if (status & (PCI_STATUS_PARITY)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
|
|
"Master Data Parity Error on "
|
|
"%s\n", pci_name(dev));
|
|
|
|
atomic_inc(&pci_parity_count);
|
|
}
|
|
|
|
if (status & (PCI_STATUS_DETECTED_PARITY)) {
|
|
edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
|
|
"Detected Parity Error on %s\n",
|
|
pci_name(dev));
|
|
|
|
atomic_inc(&pci_parity_count);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* reduce some complexity in definition of the iterator */
|
|
typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
|
|
|
|
/*
|
|
* pci_dev parity list iterator
|
|
*
|
|
* Scan the PCI device list looking for SERRORs, Master Parity ERRORS or
|
|
* Parity ERRORs on primary or secondary devices.
|
|
*/
|
|
static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
|
|
{
|
|
struct pci_dev *dev = NULL;
|
|
|
|
for_each_pci_dev(dev)
|
|
fn(dev);
|
|
}
|
|
|
|
/*
|
|
* edac_pci_do_parity_check
|
|
*
|
|
* performs the actual PCI parity check operation
|
|
*/
|
|
void edac_pci_do_parity_check(void)
|
|
{
|
|
int before_count;
|
|
|
|
edac_dbg(3, "\n");
|
|
|
|
/* if policy has PCI check off, leave now */
|
|
if (!check_pci_errors)
|
|
return;
|
|
|
|
before_count = atomic_read(&pci_parity_count);
|
|
|
|
/* scan all PCI devices looking for a Parity Error on devices and
|
|
* bridges.
|
|
* The iterator calls pci_get_device() which might sleep, thus
|
|
* we cannot disable interrupts in this scan.
|
|
*/
|
|
edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
|
|
|
|
/* Only if operator has selected panic on PCI Error */
|
|
if (edac_pci_get_panic_on_pe()) {
|
|
/* If the count is different 'after' from 'before' */
|
|
if (before_count != atomic_read(&pci_parity_count))
|
|
panic("EDAC: PCI Parity Error");
|
|
}
|
|
}
|
|
|
|
/*
|
|
* edac_pci_clear_parity_errors
|
|
*
|
|
* function to perform an iteration over the PCI devices
|
|
* and clearn their current status
|
|
*/
|
|
void edac_pci_clear_parity_errors(void)
|
|
{
|
|
/* Clear any PCI bus parity errors that devices initially have logged
|
|
* in their registers.
|
|
*/
|
|
edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
|
|
}
|
|
|
|
/*
|
|
* edac_pci_handle_pe
|
|
*
|
|
* Called to handle a PARITY ERROR event
|
|
*/
|
|
void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg)
|
|
{
|
|
|
|
/* global PE counter incremented by edac_pci_do_parity_check() */
|
|
atomic_inc(&pci->counters.pe_count);
|
|
|
|
if (edac_pci_get_log_pe())
|
|
edac_pci_printk(pci, KERN_WARNING,
|
|
"Parity Error ctl: %s %d: %s\n",
|
|
pci->ctl_name, pci->pci_idx, msg);
|
|
|
|
/*
|
|
* poke all PCI devices and see which one is the troublemaker
|
|
* panic() is called if set
|
|
*/
|
|
edac_pci_do_parity_check();
|
|
}
|
|
EXPORT_SYMBOL_GPL(edac_pci_handle_pe);
|
|
|
|
|
|
/*
|
|
* edac_pci_handle_npe
|
|
*
|
|
* Called to handle a NON-PARITY ERROR event
|
|
*/
|
|
void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
|
|
{
|
|
|
|
/* global NPE counter incremented by edac_pci_do_parity_check() */
|
|
atomic_inc(&pci->counters.npe_count);
|
|
|
|
if (edac_pci_get_log_npe())
|
|
edac_pci_printk(pci, KERN_WARNING,
|
|
"Non-Parity Error ctl: %s %d: %s\n",
|
|
pci->ctl_name, pci->pci_idx, msg);
|
|
|
|
/*
|
|
* poke all PCI devices and see which one is the troublemaker
|
|
* panic() is called if set
|
|
*/
|
|
edac_pci_do_parity_check();
|
|
}
|
|
EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
|
|
|
|
/*
|
|
* Define the PCI parameter to the module
|
|
*/
|
|
module_param(check_pci_errors, int, 0644);
|
|
MODULE_PARM_DESC(check_pci_errors,
|
|
"Check for PCI bus parity errors: 0=off 1=on");
|
|
module_param(edac_pci_panic_on_pe, int, 0644);
|
|
MODULE_PARM_DESC(edac_pci_panic_on_pe,
|
|
"Panic on PCI Bus Parity error: 0=off 1=on");
|