/** * struct ecc_error_info - ECC error log information * @addr: Fault generated at this address * @fault_lo: Generated fault data (lower 32-bit) * @fault_hi: Generated fault data (upper 32-bit)
*/ struct ecc_error_info {
u32 addr;
u32 fault_lo;
u32 fault_hi;
};
/** * struct ecc_status - ECC status information to report * @ce_cnt: Correctable error count * @ue_cnt: Uncorrectable error count * @ceinfo: Correctable error log information * @ueinfo: Uncorrectable error log information
*/ struct ecc_status {
u32 ce_cnt;
u32 ue_cnt; struct ecc_error_info ceinfo; struct ecc_error_info ueinfo;
};
/** * struct edac_priv - OCM private instance data * @baseaddr: Base address of the OCM * @message: Buffer for framing the event specific info * @stat: ECC status information * @ce_cnt: Correctable Error count * @ue_cnt: Uncorrectable Error count * @debugfs_dir: Directory entry for debugfs * @ce_bitpos: Bit position for Correctable Error * @ue_bitpos: Array to store UnCorrectable Error bit positions * @fault_injection_cnt: Fault Injection Counter value
*/ struct edac_priv { void __iomem *baseaddr; char message[ZYNQMP_OCM_EDAC_MSG_SIZE]; struct ecc_status stat;
u32 ce_cnt;
u32 ue_cnt; #ifdef CONFIG_EDAC_DEBUG struct dentry *debugfs_dir;
u8 ce_bitpos;
u8 ue_bitpos[OCM_NUM_UE_BITPOS];
u32 fault_injection_cnt; #endif
};
/** * get_error_info - Get the current ECC error info * @base: Pointer to the base address of the OCM * @p: Pointer to the OCM ECC status structure * @mask: Status register mask value * * Determines there is any ECC error or not *
*/ staticvoid get_error_info(void __iomem *base, struct ecc_status *p, int mask)
{ if (mask & OCM_CEINTR_MASK) {
p->ce_cnt++;
p->ceinfo.fault_lo = readl(base + CE_FFD0_OFST);
p->ceinfo.fault_hi = readl(base + CE_FFD1_OFST);
p->ceinfo.addr = (OCM_BASEVAL | readl(base + CE_FFA_OFST));
writel(ECC_CTRL_CLR_CE_ERR, base + OCM_ISR_OFST);
} elseif (mask & OCM_UEINTR_MASK) {
p->ue_cnt++;
p->ueinfo.fault_lo = readl(base + UE_FFD0_OFST);
p->ueinfo.fault_hi = readl(base + UE_FFD1_OFST);
p->ueinfo.addr = (OCM_BASEVAL | readl(base + UE_FFA_OFST));
writel(ECC_CTRL_CLR_UE_ERR, base + OCM_ISR_OFST);
}
}
/** * handle_error - Handle error types CE and UE * @dci: Pointer to the EDAC device instance * @p: Pointer to the OCM ECC status structure * * Handles correctable and uncorrectable errors.
*/ staticvoid handle_error(struct edac_device_ctl_info *dci, struct ecc_status *p)
{ struct edac_priv *priv = dci->pvt_info; struct ecc_error_info *pinf;
/** * get_eccstate - Return the ECC status * @base: Pointer to the OCM base address * * Get the ECC enable/disable status * * Return: ECC status 0/1.
*/ staticbool get_eccstate(void __iomem *base)
{ return readl(base + ECC_CTRL_OFST) & OCM_ECC_ENABLE_MASK;
}
#ifdef CONFIG_EDAC_DEBUG /** * write_fault_count - write fault injection count * @priv: Pointer to the EDAC private struct * * Update the fault injection count register, once the counter reaches * zero, it injects errors
*/ staticvoid write_fault_count(struct edac_priv *priv)
{
u32 ficount = priv->fault_injection_cnt;
if (ficount & ~OCM_FICOUNT_MASK) {
ficount &= OCM_FICOUNT_MASK;
edac_printk(KERN_INFO, EDAC_DEVICE, "Fault injection count value truncated to %d\n", ficount);
}
writel(ficount, priv->baseaddr + OCM_FIC_OFST);
}
/* * To get the Correctable Error injected, the following steps are needed: * - Setup the optional Fault Injection Count: * echo <fault_count val> > /sys/kernel/debug/edac/ocm/inject_fault_count * - Write the Correctable Error bit position value: * echo <bit_pos val> > /sys/kernel/debug/edac/ocm/inject_ce_bitpos
*/ static ssize_t inject_ce_write(struct file *file, constchar __user *data,
size_t count, loff_t *ppos)
{ struct edac_device_ctl_info *edac_dev = file->private_data; struct edac_priv *priv = edac_dev->pvt_info; int ret;
if (!data) return -EFAULT;
ret = kstrtou8_from_user(data, count, 0, &priv->ce_bitpos); if (ret) return ret;
if (priv->ce_bitpos > UE_MAX_BITPOS_UPPER) return -EINVAL;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.