Re: [PATCH v6 5/5] powerpc/powernv/eeh: Map generic EEH error types to OPAL
From: Narayana Murty N
Date: Fri Nov 20 2026 - 02:39:47 EST
Hi Sourabh,
On 19/11/26 1:11 AM, Sourabh Jain wrote:
Hello Narayana,The intention was to decouple the generic EEH error types from the
For my understanding, could you clarify why this change is needed as part of this series?
The series is about enabling RTAS-based error injection, and PowerNV doesn't support RTAS.
How does this change fit with the earlier patches in the series?
platform-specific OPAL encodings, similar to the explicit mapping
introduced for pSeries.
However, the generic EEH error-type values remain unchanged, and
the PowerNV mapping is not a prerequisite for RTAS-based error
injection.
I'll drop this patch from the next revision and will post it as seperate patch.
Thanks,
Narayana Murty.
On 23/10/26 13:06, Narayana Murty N wrote:
eeh_pe_inject_err() is called with generic EEH error types defined in
the VFIO/EEH userspace ABI (EEH_ERR_TYPE_32, EEH_ERR_TYPE_64). The
PowerNV backend previously compared these generic values directly against
OPAL firmware constants (OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR and
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64).
This is fragile: it relies on the generic EEH ABI values being
numerically identical to OPAL-specific values, and would silently
misbehave if they ever diverged.
Add an explicit mapping in pnv_eeh_err_inject() that translates:
EEH_ERR_TYPE_32 -> OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR
EEH_ERR_TYPE_64 -> OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64
Return -ERANGE for unsupported error types, preserving the behavior
of the original code. Decouples the VFIO/EEH interface from OPAL
implementation details.
No change to existing userspace ABI or PowerNV behavior.
Signed-off-by: Narayana Murty N <nnmlinux@xxxxxxxxxxxxx>
---
arch/powerpc/platforms/powernv/eeh-powernv.c | 22 +++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/ powerpc/platforms/powernv/eeh-powernv.c
index db3370d1673c..01dae760cecb 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1167,12 +1167,24 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
{
struct pci_controller *hose = pe->phb;
struct pnv_phb *phb = hose->private_data;
+ int opal_err_type;
s64 rc;
- if (type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR &&
- type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {
- pr_warn("%s: Invalid error type %d\n",
- __func__, type);
+ /*
+ * eeh_pe_inject_err() receives generic EEH error types from the
+ * VFIO/EEH userspace ABI. The PowerNV backend must not rely on
+ * these generic values being numerically identical to OPAL firmware
+ * values. Translate to OPAL-specific types before calling firmware.
+ */
+ switch (type) {
+ case EEH_ERR_TYPE_32:
+ opal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;
+ break;
+ case EEH_ERR_TYPE_64:
+ opal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;
+ break;
+ default:
+ pr_warn("%s: Invalid error type %d\n", __func__, type);
return -ERANGE;
}
@@ -1192,7 +1204,7 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
/* Do error injection */
rc = opal_pci_err_inject(phb->opal_id, pe->addr,
- type, func, addr, mask);
+ opal_err_type, func, addr, mask);
if (rc != OPAL_SUCCESS) {
pr_warn("%s: Failure %lld injecting error "
"%d-%d to PHB#%x-PE#%x\n",