* [PATCH] EDAC/altera: Fix Port B error injection in altr_edac_a10_device_trig
@ 2026-11-16 13:16 Dinh Nguyen
2026-11-25 21:26 ` Yazen Ghannam
0 siblings, 1 reply; 2+ messages in thread
From: Dinh Nguyen @ 2026-11-16 13:16 UTC (permalink / raw)
To: bp, tony.luck
Cc: dinguyen, rounakdas2025, linux-edac, linux-kernel,
Niravkumar L Rabara, stable
From: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
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@vger.kernel.org
Signed-off-by: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
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;
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
--
2.42.0.411.g813d9a9188
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] EDAC/altera: Fix Port B error injection in altr_edac_a10_device_trig
2026-11-16 13:16 [PATCH] EDAC/altera: Fix Port B error injection in altr_edac_a10_device_trig Dinh Nguyen
@ 2026-11-25 21:26 ` Yazen Ghannam
0 siblings, 0 replies; 2+ messages in thread
From: Yazen Ghannam @ 2026-11-25 21:26 UTC (permalink / raw)
To: Dinh Nguyen
Cc: bp, tony.luck, rounakdas2025, linux-edac, linux-kernel,
Niravkumar L Rabara, stable
On Mon, Nov 16, 2026 at 07:16:41AM -0600, Dinh Nguyen wrote:
> From: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
>
> 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@vger.kernel.org
> Signed-off-by: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
> ---
> 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@amd.com>
Thanks,
Yazen
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 21:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 13:16 [PATCH] EDAC/altera: Fix Port B error injection in altr_edac_a10_device_trig Dinh Nguyen
2026-11-25 21:26 ` Yazen Ghannam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®