Re: [PATCH] EDAC/altera: Fix Port B error injection in altr_edac_a10_device_trig
From: Yazen Ghannam
Date: Wed Nov 25 2026 - 16:26:42 EST
On Mon, Nov 16, 2026 at 07:16:41AM -0600, Dinh Nguyen wrote:
> From: Niravkumar L Rabara <niravkumarlaxmidas.rabara@xxxxxxxxxx>
>
> The INTTEST register on SoCFPGA only supports 16-bit writes; a 32-bit
> write triggers an SError to the CPU. altr_edac_a10_device_trig() was
> already using writew() correctly, but Port B test bits (TSERRB at
> BIT(16), TDERRB at BIT(24)) live in the upper half of the 32-bit
> register. Writing them to the base address silently truncates the
> value to zero, so no test interrupt is ever asserted.
>
> Write only the 16-bit half that holds the trigger bits, and leave the
> zero half untouched.
>
> Fixes: e5ef4cd2a47f ("EDAC/altera: Use correct write width with the INTTEST register")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Niravkumar L Rabara <niravkumarlaxmidas.rabara@xxxxxxxxxx>
> Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
> ---
> drivers/edac/altera_edac.c | 16 +++++++++++++---
> drivers/edac/altera_edac.h | 3 +++
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
> index bb95dab847b3c..37ce2a87443e2 100644
> --- a/drivers/edac/altera_edac.c
> +++ b/drivers/edac/altera_edac.c
> @@ -1741,16 +1741,26 @@ altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,
> const struct edac_device_prv_data *priv = drvdata->data;
> void __iomem *set_addr = (drvdata->base + priv->set_err_ofst);
> unsigned long flags;
> + u32 mask;
> + u16 half;
> u8 trig_type;
When adding or modifying variable declarations, consider ordering the
lines from longest to shortest.
>
> if (!user_buf || get_user(trig_type, user_buf))
> return -EFAULT;
>
> - local_irq_save(flags);
> if (trig_type == ALTR_UE_TRIGGER_CHAR)
> - writew(priv->ue_set_mask, set_addr);
> + mask = priv->ue_set_mask;
> else
> - writew(priv->ce_set_mask, set_addr);
> + mask = priv->ce_set_mask;
> +
> + local_irq_save(flags);
> + half = lower_16_bits(mask);
> + if (half)
> + writew(half, set_addr);
> +
> + half = upper_16_bits(mask);
> + if (half)
> + writew(half, set_addr + ALTR_A10_ECC_INTTEST_PORTB_OFST);
>
> /* Ensure the interrupt test bits are set */
> wmb();
> diff --git a/drivers/edac/altera_edac.h b/drivers/edac/altera_edac.h
> index 9387056fd65e3..fe6d0289f5c35 100644
> --- a/drivers/edac/altera_edac.h
> +++ b/drivers/edac/altera_edac.h
> @@ -244,6 +244,9 @@ struct altr_sdram_mc_data {
> #define ALTR_A10_ECC_TSERRB BIT(16)
> #define ALTR_A10_ECC_TDERRB BIT(24)
>
> +/* Byte offset of bits[31:16] of INTTEST for a 16-bit write */
> +#define ALTR_A10_ECC_INTTEST_PORTB_OFST 2
> +
> /* ECC Manager Defines */
> #define A10_SYSMGR_ECC_INTMASK_SET_OFST 0x94
> #define A10_SYSMGR_ECC_INTMASK_CLR_OFST 0x98
> --
Overall, looks good to me.
Reviewed-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
Thanks,
Yazen