[PATCH v2 5/6] powerpc/powernv: Handle compound PE for EEH

2014-07-16 Thread Guo Chao
From: Gavin Shan 

The patch handles compound PE for EEH backend. If one specific
PE in compound group has been frozen, we enforces to freeze
all PEs in the group. If we're enable DMA or MMIO for one PE
in compound group, DMA or MMIO of all PEs in the group will be
enabled.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/eeh-ioda.c | 125 +++---
 1 file changed, 78 insertions(+), 47 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index dd20ba8..7f6bee1 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -187,10 +187,10 @@ static int ioda_eeh_post_init(struct pci_controller *hose)
  */
 static int ioda_eeh_set_option(struct eeh_pe *pe, int option)
 {
-   s64 ret;
-   u32 pe_no;
struct pci_controller *hose = pe->phb;
struct pnv_phb *phb = hose->private_data;
+   int enable, ret = 0;
+   s64 rc;
 
/* Check on PE number */
if (pe->addr < 0 || pe->addr >= phb->ioda.total_pe) {
@@ -201,41 +201,38 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
return -EINVAL;
}
 
-   pe_no = pe->addr;
switch (option) {
case EEH_OPT_DISABLE:
-   ret = -EEXIST;
-   break;
+   return -EPERM;
case EEH_OPT_ENABLE:
-   ret = 0;
-   break;
+   return 0;
case EEH_OPT_THAW_MMIO:
-   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-   OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO);
-   if (ret) {
-   pr_warning("%s: Failed to enable MMIO for "
-  "PHB#%x-PE#%x, err=%lld\n",
-   __func__, hose->global_number, pe_no, ret);
-   return -EIO;
-   }
-
+   enable = OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO;
break;
case EEH_OPT_THAW_DMA:
-   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-   OPAL_EEH_ACTION_CLEAR_FREEZE_DMA);
-   if (ret) {
-   pr_warning("%s: Failed to enable DMA for "
-  "PHB#%x-PE#%x, err=%lld\n",
-   __func__, hose->global_number, pe_no, ret);
-   return -EIO;
-   }
-
+   enable = OPAL_EEH_ACTION_CLEAR_FREEZE_DMA;
break;
default:
-   pr_warning("%s: Invalid option %d\n", __func__, option);
+   pr_warn("%s: Invalid option %d\n",
+   __func__, option);
return -EINVAL;
}
 
+   /* If PHB supports compound PE, to handle it */
+   if (phb->unfreeze_pe) {
+   ret = phb->unfreeze_pe(phb, pe->addr, enable);
+   } else {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe->addr,
+enable);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld enable %d for PHB#%x-PE#%x\n",
+   __func__, rc, option, phb->hose->global_number,
+   pe->addr);
+   ret = -EIO;
+   }
+   }
+
return ret;
 }
 
@@ -313,16 +310,23 @@ static int ioda_eeh_get_pe_state(struct eeh_pe *pe)
return result;
}
 
-   /* Fetch state from hardware */
-   rc = opal_pci_eeh_freeze_status(phb->opal_id,
-   pe->addr,
-   &fstate,
-   &pcierr,
-   NULL);
-   if (rc != OPAL_SUCCESS) {
-   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
-   __func__, rc, phb->hose->global_number, pe->addr);
-   return EEH_STATE_NOT_SUPPORT;
+   /*
+* Fetch PE state from hardware. If the PHB
+* supports compound PE, let it handle that.
+*/
+   if (phb->get_pe_state) {
+   fstate = phb->get_pe_state(phb, pe->addr);
+   } else {
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
+   __func__, rc, phb->hose->global_number, 
pe->addr);
+   return EEH_STATE_NOT_SUPPORT;
+   }
}
 
/* Figure out state */
@@ -361,6 +365,9 @@ static int ioda_eeh_get_pe_st

[PATCH v2 6/6] powerpc/powernv: Handle compound PE in config accessors

2014-07-16 Thread Guo Chao
From: Gavin Shan 

The PCI config accessors check for PE frozen state and clear it if
EEH isn't functional. The patch handles compound PE in config accessors
if PHB supports it. For consistency, all PEs will be put into frozen
state if any one in compound group gets frozen by hardware.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/pci.c | 89 
 1 file changed, 60 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index 02f4bd9..353e35b 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -319,43 +319,52 @@ void pnv_pci_dump_phb_diag_data(struct pci_controller 
*hose,
 static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, u32 pe_no)
 {
unsigned long flags, rc;
-   int has_diag;
+   int has_diag, ret = 0;
 
spin_lock_irqsave(&phb->lock, flags);
 
+   /* Fetch PHB diag-data */
rc = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag.blob,
 PNV_PCI_DIAG_BUF_SIZE);
has_diag = (rc == OPAL_SUCCESS);
 
-   rc = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
-   if (rc) {
-   pr_warning("PCI %d: Failed to clear EEH freeze state"
-  " for PE#%d, err %ld\n",
-  phb->hose->global_number, pe_no, rc);
-
-   /* For now, let's only display the diag buffer when we fail to 
clear
-* the EEH status. We'll do more sensible things later when we 
have
-* proper EEH support. We need to make sure we don't pollute 
ourselves
-* with the normal errors generated when probing empty slots
-*/
-   if (has_diag)
-   pnv_pci_dump_phb_diag_data(phb->hose, phb->diag.blob);
-   else
-   pr_warning("PCI %d: No diag data available\n",
-  phb->hose->global_number);
+   /* If PHB supports compound PE, to handle it */
+   if (phb->unfreeze_pe) {
+   ret = phb->unfreeze_pe(phb,
+  pe_no,
+  OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
+   } else {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe_no,
+OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
+   if (rc) {
+   pr_warn("%s: Failure %ld clearing frozen "
+   "PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number,
+   pe_no);
+   ret = -EIO;
+   }
}
 
+   /*
+* For now, let's only display the diag buffer when we fail to clear
+* the EEH status. We'll do more sensible things later when we have
+* proper EEH support. We need to make sure we don't pollute ourselves
+* with the normal errors generated when probing empty slots
+*/
+   if (has_diag && ret)
+   pnv_pci_dump_phb_diag_data(phb->hose, phb->diag.blob);
+
spin_unlock_irqrestore(&phb->lock, flags);
 }
 
 static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
 struct device_node *dn)
 {
-   s64 rc;
u8  fstate;
__be16  pcierr;
-   u32 pe_no;
+   int pe_no;
+   s64 rc;
 
/*
 * Get the PE#. During the PCI probe stage, we might not
@@ -370,20 +379,42 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
pe_no = phb->ioda.reserved_pe;
}
 
-   /* Read freeze status */
-   rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no, &fstate, &pcierr,
-   NULL);
-   if (rc) {
-   pr_warning("%s: Can't read EEH status (PE#%d) for "
-  "%s, err %lld\n",
-  __func__, pe_no, dn->full_name, rc);
-   return;
+   /*
+* Fetch frozen state. If the PHB support compound PE,
+* we need handle that case.
+*/
+   if (phb->get_pe_state) {
+   fstate = phb->get_pe_state(phb, pe_no);
+   } else {
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe_no,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE#%x state\n",
+   __func__, rc, phb->hose->global_number, pe_no);
+   return;
+   }

[PATCH v2 4/6] powerpc/powernv: Handle compound PE

2014-07-16 Thread Guo Chao
From: Gavin Shan 

The patch introduces 3 PHB callbacks: compound PE state retrieval,
force freezing and unfreezing compound PE. The PCI config accessors
and PowerNV EEH backend can use them in subsequent patches.

We don't export the capability of compound PE to EEH core, which
helps avoiding more complexity to EEH core.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 143 ++
 arch/powerpc/platforms/powernv/pci.h  |   3 +
 2 files changed, 146 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index cc3c59b..6d262f7 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -347,6 +347,146 @@ static void __init pnv_ioda_parse_m64_window(struct 
pnv_phb *phb)
phb->pick_m64_pe = pnv_ioda2_pick_m64_pe;
 }
 
+static void pnv_ioda_freeze_pe(struct pnv_phb *phb, int pe_no)
+{
+   struct pnv_ioda_pe *pe = &phb->ioda.pe_array[pe_no];
+   struct pnv_ioda_pe *slave;
+   s64 rc;
+
+   /* Fetch master PE */
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Freeze master PE */
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe_no,
+OPAL_EEH_ACTION_SET_FREEZE_ALL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld freezing PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number, pe_no);
+   return;
+   }
+
+   /* Freeze slave PEs */
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return;
+
+   list_for_each_entry(slave, &pe->slaves, list) {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+slave->pe_number,
+OPAL_EEH_ACTION_SET_FREEZE_ALL);
+   if (rc != OPAL_SUCCESS)
+   pr_warn("%s: Failure %lld freezing PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number,
+   slave->pe_number);
+   }
+}
+
+int pnv_ioda_unfreeze_pe(struct pnv_phb *phb, int pe_no, int opt)
+{
+   struct pnv_ioda_pe *pe, *slave;
+   s64 rc;
+
+   /* Find master PE */
+   pe = &phb->ioda.pe_array[pe_no];
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Clear frozen state for master PE */
+   rc = opal_pci_eeh_freeze_set(phb->opal_id, pe_no, opt);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld clear %d on PHB#%x-PE#%x\n",
+   __func__, rc, opt, phb->hose->global_number, pe_no);
+   return -EIO;
+   }
+
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return 0;
+
+   /* Clear frozen state for slave PEs */
+   list_for_each_entry(slave, &pe->slaves, list) {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+slave->pe_number,
+opt);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld clear %d on PHB#%x-PE#%x\n",
+   __func__, rc, opt, phb->hose->global_number,
+   slave->pe_number);
+   return -EIO;
+   }
+   }
+
+   return 0;
+}
+
+static int pnv_ioda_get_pe_state(struct pnv_phb *phb, int pe_no)
+{
+   struct pnv_ioda_pe *slave, *pe;
+   u8 fstate, state;
+   __be16 pcierr;
+   s64 rc;
+
+   /* Sanity check on PE number */
+   if (pe_no < 0 || pe_no >= phb->ioda.total_pe)
+   return OPAL_EEH_STOPPED_PERM_UNAVAIL;
+
+   /*
+* Fetch the master PE and the PE instance might be
+* not initialized yet.
+*/
+   pe = &phb->ioda.pe_array[pe_no];
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Check the master PE */
+   rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no,
+   &state, &pcierr, NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting "
+   "PHB#%x-PE#%x state\n",
+   __func__, rc,
+   phb->hose->global_number, pe_no);
+   return OPAL_EEH_STOPPED_TEMP_UNAVAIL;
+   }
+
+   /* Check the slave PE */
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return state;
+
+   list_fo

[PATCH v2 3/6] powerpc/powernv: Split ioda_eeh_get_state()

2014-07-16 Thread Guo Chao
From: Gavin Shan 

Function ioda_eeh_get_state() is used to fetch EEH state for PHB
or PE. We're going to support compound PE and the function becomes
more complicated with that. The patch splits the function into two
functions for PHB and PE cases separately to improve readability.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/eeh-ioda.c | 186 +-
 1 file changed, 105 insertions(+), 81 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index b3b4bc2..dd20ba8 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -255,130 +255,154 @@ static void ioda_eeh_phb_diag(struct pci_controller 
*hose)
pnv_pci_dump_phb_diag_data(hose, phb->diag.blob);
 }
 
-/**
- * ioda_eeh_get_state - Retrieve the state of PE
- * @pe: EEH PE
- *
- * The PE's state should be retrieved from the PEEV, PEST
- * IODA tables. Since the OPAL has exported the function
- * to do it, it'd better to use that.
- */
-static int ioda_eeh_get_state(struct eeh_pe *pe)
+static int ioda_eeh_get_phb_state(struct eeh_pe *pe)
 {
-   s64 ret = 0;
+   struct pnv_phb *phb = pe->phb->private_data;
u8 fstate;
__be16 pcierr;
-   u32 pe_no;
-   int result;
-   struct pci_controller *hose = pe->phb;
-   struct pnv_phb *phb = hose->private_data;
+   s64 rc;
+   int result = 0;
+
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x state\n",
+   __func__, rc, phb->hose->global_number);
+return EEH_STATE_NOT_SUPPORT;
+}
 
/*
-* Sanity check on PE address. The PHB PE address should
-* be zero.
+* Check PHB state. If the PHB is frozen for the
+* first time, to dump the PHB diag-data.
 */
-   if (pe->addr < 0 || pe->addr >= phb->ioda.total_pe) {
-   pr_err("%s: PE address %x out of range [0, %x] "
-  "on PHB#%x\n",
-  __func__, pe->addr, phb->ioda.total_pe,
-  hose->global_number);
-   return EEH_STATE_NOT_SUPPORT;
+   if (be16_to_cpu(pcierr) != OPAL_EEH_PHB_ERROR) {
+   result = (EEH_STATE_MMIO_ACTIVE  |
+ EEH_STATE_DMA_ACTIVE   |
+ EEH_STATE_MMIO_ENABLED |
+ EEH_STATE_DMA_ENABLED);
+   } else if (!(pe->state & EEH_PE_ISOLATED)) {
+   eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
+   ioda_eeh_phb_diag(phb->hose);
}
 
+   return result;
+}
+
+static int ioda_eeh_get_pe_state(struct eeh_pe *pe)
+{
+   struct pnv_phb *phb = pe->phb->private_data;
+   u8 fstate;
+   __be16 pcierr;
+   s64 rc;
+   int result;
+
/*
-* If we're in middle of PE reset, return normal
-* state to keep EEH core going. For PHB reset, we
-* still expect to have fenced PHB cleared with
-* PHB reset.
+* We don't clobber hardware frozen state until PE
+* reset is completed. In order to keep EEH core
+* moving forward, we have to return operational
+* state during PE reset.
 */
-   if (!(pe->type & EEH_PE_PHB) &&
-   (pe->state & EEH_PE_RESET)) {
-   result = (EEH_STATE_MMIO_ACTIVE |
- EEH_STATE_DMA_ACTIVE |
+   if (pe->state & EEH_PE_RESET) {
+   result = (EEH_STATE_MMIO_ACTIVE  |
+ EEH_STATE_DMA_ACTIVE   |
  EEH_STATE_MMIO_ENABLED |
  EEH_STATE_DMA_ENABLED);
return result;
}
 
-   /* Retrieve PE status through OPAL */
-   pe_no = pe->addr;
-   ret = opal_pci_eeh_freeze_status(phb->opal_id, pe_no,
-   &fstate, &pcierr, NULL);
-   if (ret) {
-   pr_err("%s: Failed to get EEH status on "
-  "PHB#%x-PE#%x\n, err=%lld\n",
-  __func__, hose->global_number, pe_no, ret);
+   /* Fetch state from hardware */
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
+   __func__, rc, phb->hose->global_number, pe->addr);
return EEH_STATE_NOT_SUPPORT;
}
 
-   /* Check PHB status */
-   if (pe->type & EEH_PE_PHB) {
-   resu

[PATCH v2 2/6] powerpc/powernv: Allow to freeze PE

2014-07-16 Thread Guo Chao
From: Gavin Shan 

For compound PE, all PEs should be frozen if any one in the group
becomes frozen. Unfortunately, hardware doesn't always do that
automatically with help of PELTV. So we have to flirt with
PESTA/B a bit to freeze all PEs for the case.

The patch sychronizes with firmware hearder and change the name
of opal_pci_eeh_freeze_clear() to opal_pci_eeh_freeze_set() to
reflect its usage: the API can be used to clear or set frozen
state for the specified PE.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/include/asm/opal.h| 9 +
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 6 +++---
 arch/powerpc/platforms/powernv/opal-wrappers.S | 2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c  | 4 ++--
 arch/powerpc/platforms/powernv/pci.c   | 4 ++--
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index ae885cc..edbfe1c 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -84,7 +84,7 @@ struct opal_sg_list {
 #define OPAL_PCI_EEH_FREEZE_STATUS 23
 #define OPAL_PCI_SHPC  24
 #define OPAL_CONSOLE_WRITE_BUFFER_SPACE25
-#define OPAL_PCI_EEH_FREEZE_CLEAR  26
+#define OPAL_PCI_EEH_FREEZE_SET26
 #define OPAL_PCI_PHB_MMIO_ENABLE   27
 #define OPAL_PCI_SET_PHB_MEM_WINDOW28
 #define OPAL_PCI_MAP_PE_MMIO_WINDOW29
@@ -167,7 +167,8 @@ enum OpalFreezeState {
OPAL_EEH_STOPPED_PERM_UNAVAIL = 6
 };
 
-enum OpalEehFreezeActionToken {
+enum OpalPciFreezeActionToken {
+   OPAL_EEH_ACTION_SET_FREEZE_ALL = 0,
OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO = 1,
OPAL_EEH_ACTION_CLEAR_FREEZE_DMA = 2,
OPAL_EEH_ACTION_CLEAR_FREEZE_ALL = 3
@@ -762,8 +763,8 @@ int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, 
uint64_t pe_number,
   uint8_t *freeze_state,
   __be16 *pci_error_type,
   __be64 *phb_status);
-int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
- uint64_t eeh_action_token);
+int64_t opal_pci_eeh_freeze_set(uint64_t phb_id, uint64_t pe_number,
+   uint64_t eeh_action_token);
 int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
 
 
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index f6abdb1..b3b4bc2 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -210,7 +210,7 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
ret = 0;
break;
case EEH_OPT_THAW_MMIO:
-   ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
+   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO);
if (ret) {
pr_warning("%s: Failed to enable MMIO for "
@@ -221,7 +221,7 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
 
break;
case EEH_OPT_THAW_DMA:
-   ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
+   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_DMA);
if (ret) {
pr_warning("%s: Failed to enable DMA for "
@@ -809,7 +809,7 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
hose->global_number, frozen_pe_no);
pr_info("EEH: PHB location: %s\n",
eeh_pe_loc_get(phb_pe));
-   opal_pci_eeh_freeze_clear(phb->opal_id, 
frozen_pe_no,
+   opal_pci_eeh_freeze_set(phb->opal_id, 
frozen_pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
ret = EEH_NEXT_ERR_NONE;
} else if ((*pe)->state & EEH_PE_ISOLATED ||
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 4abbff2..abf5ffa 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -85,7 +85,7 @@ OPAL_CALL(opal_set_xive,  OPAL_SET_XIVE);
 OPAL_CALL(opal_get_xive,   OPAL_GET_XIVE);
 OPAL_CALL(opal_register_exception_handler, 
OPAL_REGISTER_OPAL_EXCEPTION_HANDLER);
 OPAL_CALL(opal_pci_eeh_freeze_status,  OPAL_PCI_EEH_FREEZE_STATUS);
-OPAL_CALL(opal_pci_eeh_freeze_clear,   OPAL_PCI_EEH_FREEZE_CLEAR);
+OPAL_CALL(opal_pci_eeh_freeze_set, OPAL_PCI_EEH_FREEZE_SET);
 OPAL_CALL(opal_pci_shpc,   OPAL_PCI_SHPC);
 OPAL_C

[PATCH v2 1/6] powerpc/powernv: Enable M64 aperatus for PHB3

2014-07-16 Thread Guo Chao
This patch enables M64 aperatus for PHB3.

We already had platform hook (ppc_md.pcibios_window_alignment) to affect
the PCI resource assignment done in PCI core so that each PE's M32 resource
was built on basis of M32 segment size. Similarly, we're using that for
M64 assignment on basis of M64 segment size.

   * We're using last M64 BAR to cover M64 aperatus, and it's shared by all
 256 PEs.
   * We don't support P7IOC yet. However, some function callbacks are added
 to (struct pnv_phb) so that we can reuse them on P7IOC in future.
   * PE, corresponding to PCI bus with large M64 BAR device attached, might
 span multiple M64 segments. We introduce "compound" PE to cover the case.
 The compound PE is a list of PEs and the master PE is used as before.
 The slave PEs are just for MMIO isolation.

Signed-off-by: Guo Chao 
---
 arch/powerpc/include/asm/opal.h   |   8 +-
 arch/powerpc/platforms/powernv/pci-ioda.c | 301 +++---
 arch/powerpc/platforms/powernv/pci.h  |  20 ++
 3 files changed, 307 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 0da1dbd..ae885cc 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -340,6 +340,12 @@ enum OpalMveEnableAction {
OPAL_ENABLE_MVE = 1
 };
 
+enum OpalM64EnableAction {
+   OPAL_DISABLE_M64 = 0,
+   OPAL_ENABLE_M64_SPLIT = 1,
+   OPAL_ENABLE_M64_NON_SPLIT = 2
+};
+
 enum OpalPciResetScope {
OPAL_PHB_COMPLETE = 1, OPAL_PCI_LINK = 2, OPAL_PHB_ERROR = 3,
OPAL_PCI_HOT_RESET = 4, OPAL_PCI_FUNDAMENTAL_RESET = 5,
@@ -768,7 +774,7 @@ int64_t opal_pci_set_phb_mem_window(uint64_t phb_id, 
uint16_t window_type,
uint16_t window_num,
uint64_t starting_real_address,
uint64_t starting_pci_address,
-   uint16_t segment_size);
+   uint64_t size);
 int64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
uint16_t window_type, uint16_t window_num,
uint16_t segment_num);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 93fd815..2b659d9 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "powernv.h"
 #include "pci.h"
@@ -82,6 +83,12 @@ static inline void __raw_rm_writeq(u64 val, volatile void 
__iomem *paddr)
: : "r" (val), "r" (paddr) : "memory");
 }
 
+static inline bool pnv_pci_is_mem_pref_64(unsigned long flags)
+{
+   return ((flags & (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH)) ==
+   (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH));
+}
+
 static int pnv_ioda_alloc_pe(struct pnv_phb *phb)
 {
unsigned long pe;
@@ -106,6 +113,240 @@ static void pnv_ioda_free_pe(struct pnv_phb *phb, int pe)
clear_bit(pe, phb->ioda.pe_alloc);
 }
 
+/* The default M64 BAR is shared by all PEs */
+static int pnv_ioda2_init_m64(struct pnv_phb *phb)
+{
+   const char *desc;
+   struct resource *r;
+   s64 rc;
+
+   /* Configure the default M64 BAR */
+   rc = opal_pci_set_phb_mem_window(phb->opal_id,
+OPAL_M64_WINDOW_TYPE,
+phb->ioda.m64_bar_idx,
+phb->ioda.m64_base,
+0, /* unused */
+phb->ioda.m64_size);
+   if (rc != OPAL_SUCCESS) {
+   desc = "configuring";
+   goto fail;
+   }
+
+   /* Enable the default M64 BAR */
+   rc = opal_pci_phb_mmio_enable(phb->opal_id,
+ OPAL_M64_WINDOW_TYPE,
+ phb->ioda.m64_bar_idx,
+ OPAL_ENABLE_M64_SPLIT);
+   if (rc != OPAL_SUCCESS) {
+   desc = "enabling";
+   goto fail;
+   }
+
+   /* Mark the M64 BAR assigned */
+   set_bit(phb->ioda.m64_bar_idx, &phb->ioda.m64_bar_alloc);
+
+   /*
+* Strip off the segment used by the reserved PE, which is
+* expected to be 0 or last one of PE capabicity.
+*/
+   r = &phb->hose->mem_resources[1];
+   if (phb->ioda.reserved_pe == 0)
+   r->start += phb->ioda.m64_segsize;
+   else if (phb->ioda.reserved_pe == (phb->ioda.total_pe - 1))
+   r->end -= phb->ioda.m64_segsize;
+   else
+   pr_warn("  Cannot strip M64 segment for

[PATCH v2 0/6] powerpc/powernv: Support M64 window

2014-07-16 Thread Guo Chao
This version is rebased on top of Gavin's patches of EEH support for guest and
related fixes which are supposed to be merged in 3.17.

Changed from v1:
* Don't overwrite PE flags
* Don't return segment alignment if M64 is not supported
* Output M64 total size and segment size together with M32 and IO

Currently, all MMIO resources, including 64-bits MMIO resources are hooked
to PHB 32-bits MMIO BAR, which has limited space. If there're PCI devices
with large 64-bits MMIO BAR (could reach 1GB), we're running out of MMIO
resources (as well as PE numbers) quickly. The patchset reuses the M32
infrastructure to support M64:

   * The last M64 BAR covers all M64 aperatus and that's shared by all PEs.
   * Reuse ppc_md.pcibios_window_alignment() to affect resource assignment
 in PCI core so that we can get well segmented 64-bits window of PCI
 bridges.
   * One PCI bus might require multiple discrete M64 segment. We invent
 if we're going to unfreeze any one in the group.

Gavin Shan (5):
  powerpc/powernv: Allow to freeze PE
  powerpc/powernv: Split ioda_eeh_get_state()
  powerpc/powernv: Handle compound PE
  powerpc/powernv: Handle compound PE for EEH
  powerpc/powernv: Handle compound PE in config accessors

Guo Chao (1):
  powerpc/powernv: Enable M64 aperatus for PHB3

 arch/powerpc/include/asm/opal.h|  17 +-
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 293 +---
 arch/powerpc/platforms/powernv/opal-wrappers.S |   2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c  | 448 +++--
 arch/powerpc/platforms/powernv/pci.c   |  87 +++--
 arch/powerpc/platforms/powernv/pci.h   |  23 ++
 6 files changed, 694 insertions(+), 176 deletions(-)

-- 
1.9.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/6] powerpc/powernv: Allows to freeze PE

2014-07-10 Thread Guo Chao
From: Gavin Shan 

For compound PE, all PEs should be frozen if any one in the group
becomes frozen. Unfortunately, hardware doesn't always do that
automatically with help of PELTV. So we have to flirt with
PESTA/B a bit to freeze all PEs for the case.

The patch sychronizes with firmware hearder and change the name
of opal_pci_eeh_freeze_clear() to opal_pci_eeh_freeze_set() to
reflect its usage: the API can be used to clear or set frozen
state for the specified PE.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/include/asm/opal.h| 9 +
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 6 +++---
 arch/powerpc/platforms/powernv/opal-wrappers.S | 2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c  | 4 ++--
 arch/powerpc/platforms/powernv/pci.c   | 4 ++--
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index ae885cc..edbfe1c 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -84,7 +84,7 @@ struct opal_sg_list {
 #define OPAL_PCI_EEH_FREEZE_STATUS 23
 #define OPAL_PCI_SHPC  24
 #define OPAL_CONSOLE_WRITE_BUFFER_SPACE25
-#define OPAL_PCI_EEH_FREEZE_CLEAR  26
+#define OPAL_PCI_EEH_FREEZE_SET26
 #define OPAL_PCI_PHB_MMIO_ENABLE   27
 #define OPAL_PCI_SET_PHB_MEM_WINDOW28
 #define OPAL_PCI_MAP_PE_MMIO_WINDOW29
@@ -167,7 +167,8 @@ enum OpalFreezeState {
OPAL_EEH_STOPPED_PERM_UNAVAIL = 6
 };
 
-enum OpalEehFreezeActionToken {
+enum OpalPciFreezeActionToken {
+   OPAL_EEH_ACTION_SET_FREEZE_ALL = 0,
OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO = 1,
OPAL_EEH_ACTION_CLEAR_FREEZE_DMA = 2,
OPAL_EEH_ACTION_CLEAR_FREEZE_ALL = 3
@@ -762,8 +763,8 @@ int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, 
uint64_t pe_number,
   uint8_t *freeze_state,
   __be16 *pci_error_type,
   __be64 *phb_status);
-int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
- uint64_t eeh_action_token);
+int64_t opal_pci_eeh_freeze_set(uint64_t phb_id, uint64_t pe_number,
+   uint64_t eeh_action_token);
 int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
 
 
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index 8ad0c5b..723db8b 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -210,7 +210,7 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
ret = 0;
break;
case EEH_OPT_THAW_MMIO:
-   ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
+   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO);
if (ret) {
pr_warning("%s: Failed to enable MMIO for "
@@ -221,7 +221,7 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
 
break;
case EEH_OPT_THAW_DMA:
-   ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
+   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_DMA);
if (ret) {
pr_warning("%s: Failed to enable DMA for "
@@ -809,7 +809,7 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
hose->global_number, frozen_pe_no);
pr_info("EEH: PHB location: %s\n",
eeh_pe_loc_get(phb_pe));
-   opal_pci_eeh_freeze_clear(phb->opal_id, 
frozen_pe_no,
+   opal_pci_eeh_freeze_set(phb->opal_id, 
frozen_pe_no,
OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
ret = EEH_NEXT_ERR_NONE;
} else if ((*pe)->state & EEH_PE_ISOLATED) {
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 4abbff2..abf5ffa 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -85,7 +85,7 @@ OPAL_CALL(opal_set_xive,  OPAL_SET_XIVE);
 OPAL_CALL(opal_get_xive,   OPAL_GET_XIVE);
 OPAL_CALL(opal_register_exception_handler, 
OPAL_REGISTER_OPAL_EXCEPTION_HANDLER);
 OPAL_CALL(opal_pci_eeh_freeze_status,  OPAL_PCI_EEH_FREEZE_STATUS);
-OPAL_CALL(opal_pci_eeh_freeze_clear,   OPAL_PCI_EEH_FREEZE_CLEAR);
+OPAL_CALL(opal_pci_eeh_freeze_set, OPAL_PCI_EEH_FREEZE_SET);
 OPAL_CALL(opal_pci_shpc,   OPAL_PCI_SHPC);
 OPAL_C

[PATCH 5/6] powerpc/powernv: Handle compound PE for EEH

2014-07-10 Thread Guo Chao
From: Gavin Shan 

The patch handles compound PE for EEH backend. If one specific
PE in compound group has been frozen, we enforces to freeze
all PEs in the group. If we're enable DMA or MMIO for one PE
in compound group, DMA or MMIO of all PEs in the group will be
enabled.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/eeh-ioda.c | 125 +++---
 1 file changed, 78 insertions(+), 47 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index ac4b517..8c8b99f 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -187,10 +187,10 @@ static int ioda_eeh_post_init(struct pci_controller *hose)
  */
 static int ioda_eeh_set_option(struct eeh_pe *pe, int option)
 {
-   s64 ret;
-   u32 pe_no;
struct pci_controller *hose = pe->phb;
struct pnv_phb *phb = hose->private_data;
+   int enable, ret = 0;
+   s64 rc;
 
/* Check on PE number */
if (pe->addr < 0 || pe->addr >= phb->ioda.total_pe) {
@@ -201,41 +201,38 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
return -EINVAL;
}
 
-   pe_no = pe->addr;
switch (option) {
case EEH_OPT_DISABLE:
-   ret = -EEXIST;
-   break;
+   return -EPERM;
case EEH_OPT_ENABLE:
-   ret = 0;
-   break;
+   return 0;
case EEH_OPT_THAW_MMIO:
-   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-   OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO);
-   if (ret) {
-   pr_warning("%s: Failed to enable MMIO for "
-  "PHB#%x-PE#%x, err=%lld\n",
-   __func__, hose->global_number, pe_no, ret);
-   return -EIO;
-   }
-
+   enable = OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO;
break;
case EEH_OPT_THAW_DMA:
-   ret = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-   OPAL_EEH_ACTION_CLEAR_FREEZE_DMA);
-   if (ret) {
-   pr_warning("%s: Failed to enable DMA for "
-  "PHB#%x-PE#%x, err=%lld\n",
-   __func__, hose->global_number, pe_no, ret);
-   return -EIO;
-   }
-
+   enable = OPAL_EEH_ACTION_CLEAR_FREEZE_DMA;
break;
default:
-   pr_warning("%s: Invalid option %d\n", __func__, option);
+   pr_warn("%s: Invalid option %d\n",
+   __func__, option);
return -EINVAL;
}
 
+   /* If PHB supports compound PE, to handle it */
+   if (phb->unfreeze_pe) {
+   ret = phb->unfreeze_pe(phb, pe->addr, enable);
+   } else {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe->addr,
+enable);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld enable %d for PHB#%x-PE#%x\n",
+   __func__, rc, option, phb->hose->global_number,
+   pe->addr);
+   ret = -EIO;
+   }
+   }
+
return ret;
 }
 
@@ -313,16 +310,23 @@ static int ioda_eeh_get_pe_state(struct eeh_pe *pe)
return result;
}
 
-   /* Fetch state from hardware */
-   rc = opal_pci_eeh_freeze_status(phb->opal_id,
-   pe->addr,
-   &fstate,
-   &pcierr,
-   NULL);
-   if (rc != OPAL_SUCCESS) {
-   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
-   __func__, rc, phb->hose->global_number, pe->addr);
-   return EEH_STATE_NOT_SUPPORT;
+   /*
+* Fetch PE state from hardware. If the PHB
+* supports compound PE, let it handle that.
+*/
+   if (phb->get_pe_state) {
+   fstate = phb->get_pe_state(phb, pe->addr);
+   } else {
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
+   __func__, rc, phb->hose->global_number, 
pe->addr);
+   return EEH_STATE_NOT_SUPPORT;
+   }
}
 
/* Figure out state */
@@ -361,6 +365,9 @@ static int ioda_eeh_get_pe_st

[PATCH 4/6] powerpc/powernv: handle compound PE

2014-07-10 Thread Guo Chao
From: Gavin Shan 

The patch introduces 3 PHB callbacks: compound PE retrieval, force
freezing and unfreezing compound PE. The PCI config accessors and
EEH backend can use them in subsequent patches.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 144 ++
 arch/powerpc/platforms/powernv/pci.h  |   3 +
 2 files changed, 147 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 31a5460..69f0110 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -350,6 +350,146 @@ static void __init pnv_ioda_parse_m64_window(struct 
pnv_phb *phb)
res->start, res->end, pci_addr);
 }
 
+static void pnv_ioda_freeze_pe(struct pnv_phb *phb, int pe_no)
+{
+   struct pnv_ioda_pe *pe = &phb->ioda.pe_array[pe_no];
+   struct pnv_ioda_pe *slave;
+   s64 rc;
+
+   /* Fetch master PE */
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Freeze master PE */
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe_no,
+OPAL_EEH_ACTION_SET_FREEZE_ALL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld freezing PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number, pe_no);
+   return;
+   }
+
+   /* Freeze slave PEs */
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return;
+
+   list_for_each_entry(slave, &pe->slaves, list) {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+slave->pe_number,
+OPAL_EEH_ACTION_SET_FREEZE_ALL);
+   if (rc != OPAL_SUCCESS)
+   pr_warn("%s: Failure %lld freezing PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number,
+   slave->pe_number);
+   }
+}
+
+int pnv_ioda_unfreeze_pe(struct pnv_phb *phb, int pe_no, int opt)
+{
+   struct pnv_ioda_pe *pe, *slave;
+   s64 rc;
+
+   /* Find master PE */
+   pe = &phb->ioda.pe_array[pe_no];
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Clear frozen state for master PE */
+   rc = opal_pci_eeh_freeze_set(phb->opal_id, pe_no, opt);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld clear %d on PHB#%x-PE#%x\n",
+   __func__, rc, opt, phb->hose->global_number, pe_no);
+   return -EIO;
+   }
+
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return 0;
+
+   /* Clear frozen state for slave PEs */
+   list_for_each_entry(slave, &pe->slaves, list) {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+slave->pe_number,
+opt);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld clear %d on PHB#%x-PE#%x\n",
+   __func__, rc, opt, phb->hose->global_number,
+   slave->pe_number);
+   return -EIO;
+   }
+   }
+
+   return 0;
+}
+
+static int pnv_ioda_get_pe_state(struct pnv_phb *phb, int pe_no)
+{
+   struct pnv_ioda_pe *slave, *pe;
+   u8 fstate, state;
+   __be16 pcierr;
+   s64 rc;
+
+   /* Sanity check on PE number */
+   if (pe_no < 0 || pe_no >= phb->ioda.total_pe)
+   return OPAL_EEH_STOPPED_PERM_UNAVAIL;
+
+   /*
+* Fetch the master PE and the PE instance might be
+* not initialized yet.
+*/
+   pe = &phb->ioda.pe_array[pe_no];
+   if (pe->flags & PNV_IODA_PE_SLAVE) {
+   pe = pe->master;
+   WARN_ON(!pe || !(pe->flags & PNV_IODA_PE_MASTER));
+   pe_no = pe->pe_number;
+   }
+
+   /* Check the master PE */
+   rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no,
+   &state, &pcierr, NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting "
+   "PHB#%x-PE#%x state\n",
+   __func__, rc,
+   phb->hose->global_number, pe_no);
+   return OPAL_EEH_STOPPED_TEMP_UNAVAIL;
+   }
+
+   /* Check the slave PE */
+   if (!(pe->flags & PNV_IODA_PE_MASTER))
+   return state;
+
+   list_for_each_entry(slave, &pe->slaves, list) {
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+ 

[PATCH 3/6] powerpc/powernv: Split ioda_eeh_get_state()

2014-07-10 Thread Guo Chao
From: Gavin Shan 

Function ioda_eeh_get_state() is used to fetch EEH state for PHB
or PE. We're going to support compound PE and the function becomes
more complicated with that. The patch splits the function into two
for PHB and PE cases separately. Besides, I also clean the code up
for a bit to improve the readability.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/eeh-ioda.c | 186 +-
 1 file changed, 105 insertions(+), 81 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index 723db8b..ac4b517 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -255,130 +255,154 @@ static void ioda_eeh_phb_diag(struct pci_controller 
*hose)
pnv_pci_dump_phb_diag_data(hose, phb->diag.blob);
 }
 
-/**
- * ioda_eeh_get_state - Retrieve the state of PE
- * @pe: EEH PE
- *
- * The PE's state should be retrieved from the PEEV, PEST
- * IODA tables. Since the OPAL has exported the function
- * to do it, it'd better to use that.
- */
-static int ioda_eeh_get_state(struct eeh_pe *pe)
+static int ioda_eeh_get_phb_state(struct eeh_pe *pe)
 {
-   s64 ret = 0;
+   struct pnv_phb *phb = pe->phb->private_data;
u8 fstate;
__be16 pcierr;
-   u32 pe_no;
-   int result;
-   struct pci_controller *hose = pe->phb;
-   struct pnv_phb *phb = hose->private_data;
+   s64 rc;
+   int result = 0;
+
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x state\n",
+   __func__, rc, phb->hose->global_number);
+return EEH_STATE_NOT_SUPPORT;
+}
 
/*
-* Sanity check on PE address. The PHB PE address should
-* be zero.
+* Check PHB state. If the PHB is frozen for the
+* first time, to dump the PHB diag-data.
 */
-   if (pe->addr < 0 || pe->addr >= phb->ioda.total_pe) {
-   pr_err("%s: PE address %x out of range [0, %x] "
-  "on PHB#%x\n",
-  __func__, pe->addr, phb->ioda.total_pe,
-  hose->global_number);
-   return EEH_STATE_NOT_SUPPORT;
+   if (be16_to_cpu(pcierr) != OPAL_EEH_PHB_ERROR) {
+   result = (EEH_STATE_MMIO_ACTIVE  |
+ EEH_STATE_DMA_ACTIVE   |
+ EEH_STATE_MMIO_ENABLED |
+ EEH_STATE_DMA_ENABLED);
+   } else if (!(pe->state & EEH_PE_ISOLATED)) {
+   eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
+   ioda_eeh_phb_diag(phb->hose);
}
 
+   return result;
+}
+
+static int ioda_eeh_get_pe_state(struct eeh_pe *pe)
+{
+   struct pnv_phb *phb = pe->phb->private_data;
+   u8 fstate;
+   __be16 pcierr;
+   s64 rc;
+   int result;
+
/*
-* If we're in middle of PE reset, return normal
-* state to keep EEH core going. For PHB reset, we
-* still expect to have fenced PHB cleared with
-* PHB reset.
+* We don't clobber hardware frozen state until PE
+* reset is completed. In order to keep EEH core
+* moving forward, we have to return operational
+* state during PE reset.
 */
-   if (!(pe->type & EEH_PE_PHB) &&
-   (pe->state & EEH_PE_RESET)) {
-   result = (EEH_STATE_MMIO_ACTIVE |
- EEH_STATE_DMA_ACTIVE |
+   if (pe->state & EEH_PE_RESET) {
+   result = (EEH_STATE_MMIO_ACTIVE  |
+ EEH_STATE_DMA_ACTIVE   |
  EEH_STATE_MMIO_ENABLED |
  EEH_STATE_DMA_ENABLED);
return result;
}
 
-   /* Retrieve PE status through OPAL */
-   pe_no = pe->addr;
-   ret = opal_pci_eeh_freeze_status(phb->opal_id, pe_no,
-   &fstate, &pcierr, NULL);
-   if (ret) {
-   pr_err("%s: Failed to get EEH status on "
-  "PHB#%x-PE#%x\n, err=%lld\n",
-  __func__, hose->global_number, pe_no, ret);
+   /* Fetch state from hardware */
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe->addr,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
+   __func__, rc, phb->hose->global_number, pe->addr);
return EEH_STATE_NOT_SUPPORT;
}
 
-   /* Check PHB status */
-   if (pe->ty

[PATCH 6/6] powerpc/powernv: Handle compound PE in config accessors

2014-07-10 Thread Guo Chao
From: Gavin Shan 

The PCI config accessors check for PE frozen state and clear it if
EEH is disabled. The patch handles compound PE in config accessors
if PHB supports it. For consistency, all PEs will be put into frozen
state if any one in compound group gets frozen by hardware.

Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/pci.c | 89 
 1 file changed, 60 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index 02f4bd9..353e35b 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -319,43 +319,52 @@ void pnv_pci_dump_phb_diag_data(struct pci_controller 
*hose,
 static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, u32 pe_no)
 {
unsigned long flags, rc;
-   int has_diag;
+   int has_diag, ret = 0;
 
spin_lock_irqsave(&phb->lock, flags);
 
+   /* Fetch PHB diag-data */
rc = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag.blob,
 PNV_PCI_DIAG_BUF_SIZE);
has_diag = (rc == OPAL_SUCCESS);
 
-   rc = opal_pci_eeh_freeze_set(phb->opal_id, pe_no,
-OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
-   if (rc) {
-   pr_warning("PCI %d: Failed to clear EEH freeze state"
-  " for PE#%d, err %ld\n",
-  phb->hose->global_number, pe_no, rc);
-
-   /* For now, let's only display the diag buffer when we fail to 
clear
-* the EEH status. We'll do more sensible things later when we 
have
-* proper EEH support. We need to make sure we don't pollute 
ourselves
-* with the normal errors generated when probing empty slots
-*/
-   if (has_diag)
-   pnv_pci_dump_phb_diag_data(phb->hose, phb->diag.blob);
-   else
-   pr_warning("PCI %d: No diag data available\n",
-  phb->hose->global_number);
+   /* If PHB supports compound PE, to handle it */
+   if (phb->unfreeze_pe) {
+   ret = phb->unfreeze_pe(phb,
+  pe_no,
+  OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
+   } else {
+   rc = opal_pci_eeh_freeze_set(phb->opal_id,
+pe_no,
+OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
+   if (rc) {
+   pr_warn("%s: Failure %ld clearing frozen "
+   "PHB#%x-PE#%x\n",
+   __func__, rc, phb->hose->global_number,
+   pe_no);
+   ret = -EIO;
+   }
}
 
+   /*
+* For now, let's only display the diag buffer when we fail to clear
+* the EEH status. We'll do more sensible things later when we have
+* proper EEH support. We need to make sure we don't pollute ourselves
+* with the normal errors generated when probing empty slots
+*/
+   if (has_diag && ret)
+   pnv_pci_dump_phb_diag_data(phb->hose, phb->diag.blob);
+
spin_unlock_irqrestore(&phb->lock, flags);
 }
 
 static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
 struct device_node *dn)
 {
-   s64 rc;
u8  fstate;
__be16  pcierr;
-   u32 pe_no;
+   int pe_no;
+   s64 rc;
 
/*
 * Get the PE#. During the PCI probe stage, we might not
@@ -370,20 +379,42 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
pe_no = phb->ioda.reserved_pe;
}
 
-   /* Read freeze status */
-   rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no, &fstate, &pcierr,
-   NULL);
-   if (rc) {
-   pr_warning("%s: Can't read EEH status (PE#%d) for "
-  "%s, err %lld\n",
-  __func__, pe_no, dn->full_name, rc);
-   return;
+   /*
+* Fetch frozen state. If the PHB support compound PE,
+* we need handle that case.
+*/
+   if (phb->get_pe_state) {
+   fstate = phb->get_pe_state(phb, pe_no);
+   } else {
+   rc = opal_pci_eeh_freeze_status(phb->opal_id,
+   pe_no,
+   &fstate,
+   &pcierr,
+   NULL);
+   if (rc) {
+   pr_warn("%s: Failure %lld getting PHB#%x-PE#%x state\n",
+   __func__, rc, phb->hose->global_number, pe_no);
+   return;
+   }
}

[PATCH 1/6] powerpc/powernv: Enable M64 aperatus for PHB3

2014-07-10 Thread Guo Chao
This patch enable M64 aperatus for PHB3.

We already had platform hook (ppc_md.pcibios_window_alignment) to affect
the PCI resource assignment done in PCI core so that each PE's M32 resource
was built on basis of M32 segment size. Similarly, we're using that for
M64 assignment on basis of M64 segment size.

   * We're using last M64 BAR to cover M64 aperatus, and it's shared by all
 256 PEs.
   * We don't support P7IOC yet. However, some function callbacks are added
 to (struct pnv_phb) so that we can reuse them on P7IOC in future.
   * PE, corresponding to PCI bus with large M64 BAR device attached, might
 span multiple M64 segments. We introduce "compound" PE to cover the case.
 The compound PE is a list of PEs and the master PE is used as before.
 The slave PEs are just for MMIO isolation.

Signed-off-by: Guo Chao 
---
 arch/powerpc/include/asm/opal.h   |   8 +-
 arch/powerpc/platforms/powernv/pci-ioda.c | 284 --
 arch/powerpc/platforms/powernv/pci.h  |  20 +++
 3 files changed, 297 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 0da1dbd..ae885cc 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -340,6 +340,12 @@ enum OpalMveEnableAction {
OPAL_ENABLE_MVE = 1
 };
 
+enum OpalM64EnableAction {
+   OPAL_DISABLE_M64 = 0,
+   OPAL_ENABLE_M64_SPLIT = 1,
+   OPAL_ENABLE_M64_NON_SPLIT = 2
+};
+
 enum OpalPciResetScope {
OPAL_PHB_COMPLETE = 1, OPAL_PCI_LINK = 2, OPAL_PHB_ERROR = 3,
OPAL_PCI_HOT_RESET = 4, OPAL_PCI_FUNDAMENTAL_RESET = 5,
@@ -768,7 +774,7 @@ int64_t opal_pci_set_phb_mem_window(uint64_t phb_id, 
uint16_t window_type,
uint16_t window_num,
uint64_t starting_real_address,
uint64_t starting_pci_address,
-   uint16_t segment_size);
+   uint64_t size);
 int64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
uint16_t window_type, uint16_t window_num,
uint16_t segment_num);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index de19ede..851e615 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "powernv.h"
 #include "pci.h"
@@ -82,6 +83,12 @@ static inline void __raw_rm_writeq(u64 val, volatile void 
__iomem *paddr)
: : "r" (val), "r" (paddr) : "memory");
 }
 
+static inline bool pnv_pci_is_mem_pref_64(unsigned long flags)
+{
+   return ((flags & (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH)) ==
+   (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH));
+}
+
 static int pnv_ioda_alloc_pe(struct pnv_phb *phb)
 {
unsigned long pe;
@@ -106,6 +113,243 @@ static void pnv_ioda_free_pe(struct pnv_phb *phb, int pe)
clear_bit(pe, phb->ioda.pe_alloc);
 }
 
+/* The default M64 BAR is shared by all PEs */
+static int pnv_ioda2_init_m64(struct pnv_phb *phb)
+{
+   const char *desc;
+   struct resource *r;
+   s64 rc;
+
+   /* Configure the default M64 BAR */
+   rc = opal_pci_set_phb_mem_window(phb->opal_id,
+OPAL_M64_WINDOW_TYPE,
+phb->ioda.m64_bar_idx,
+phb->ioda.m64_base,
+0, /* unused */
+phb->ioda.m64_size);
+   if (rc != OPAL_SUCCESS) {
+   desc = "configuring";
+   goto fail;
+   }
+
+   /* Enable the default M64 BAR */
+   rc = opal_pci_phb_mmio_enable(phb->opal_id,
+ OPAL_M64_WINDOW_TYPE,
+ phb->ioda.m64_bar_idx,
+ OPAL_ENABLE_M64_SPLIT);
+   if (rc != OPAL_SUCCESS) {
+   desc = "enabling";
+   goto fail;
+   }
+
+   /* Mark the M64 BAR assigned */
+   set_bit(phb->ioda.m64_bar_idx, &phb->ioda.m64_bar_alloc);
+
+   /*
+* Strip off the segment used by the reserved PE, which is
+* expected to be 0 or last one of PE capabicity.
+*/
+   r = &phb->hose->mem_resources[1];
+   if (phb->ioda.reserved_pe == 0)
+   r->start += phb->ioda.m64_segsize;
+   else if (phb->ioda.reserved_pe == (phb->ioda.total_pe - 1))
+   r->end -= phb->ioda.m64_segsize;
+   else
+   pr_warn("  Cannot strip M64 segment for

[PATCH 0/6] powerpc/powernv: Support M64 window

2014-07-10 Thread Guo Chao
Currently, all MMIO resources, including 64-bits MMIO resources are hooked
to PHB 32-bits MMIO BAR, which has limited space. If there're PCI devices
with large 64-bits MMIO BAR (could reach 1GB), we're running out of MMIO
resources (as well as PE numbers) quickly. The patchset reuses the M32
infrastructure to support M64:

   * The last M64 BAR covers all M64 aperatus and that's shared by all PEs.
   * Reuse ppc_md.pcibios_window_alignment() to affect resource assignment
 in PCI core so that we can get well segmented 64-bits window of PCI
 bridges.
   * One PCI bus might require multiple discrete M64 segment. We invent
 if we're going to unfreeze any one in the group.

The patchset requires corresponding changes from firmware. And we don't
support M64 for P7 yet. That's something to do in future.

Gavin Shan (5):
  powerpc/powernv: Allows to freeze PE
  powerpc/powernv: Split ioda_eeh_get_state()
  powerpc/powernv: handle compound PE
  powerpc/powernv: Handle compound PE for EEH
  powerpc/powernv: Handle compound PE in config accessors

Guo Chao (1):
  powerpc/powernv: Enable M64 aperatus for PHB3

 arch/powerpc/include/asm/opal.h|  17 +-
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 293 ++---
 arch/powerpc/platforms/powernv/opal-wrappers.S |   2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c  | 432 -
 arch/powerpc/platforms/powernv/pci.c   |  87 +++--
 arch/powerpc/platforms/powernv/pci.h   |  23 ++
 6 files changed, 685 insertions(+), 169 deletions(-)

-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/powernv: fix endianness problems in EEH

2014-06-09 Thread Guo Chao
EEH information fetched from OPAL need fix before using in LE environment.
To be included in sparse's endian check, declare them as __beXX and
access them by accessors.

Cc: Gavin Shan 

Signed-off-by: Guo Chao 
---
 arch/powerpc/include/asm/opal.h   | 102 +++---
 arch/powerpc/platforms/powernv/eeh-ioda.c |  36 ++-
 arch/powerpc/platforms/powernv/pci.c  |  81 +++-
 3 files changed, 120 insertions(+), 99 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 4ccd1d4..a4c0acc 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -599,9 +599,9 @@ enum {
 };
 
 struct OpalIoPhbErrorCommon {
-   uint32_t version;
-   uint32_t ioType;
-   uint32_t len;
+   __be32 version;
+   __be32 ioType;
+   __be32 len;
 };
 
 struct OpalIoP7IOCPhbErrorData {
@@ -671,64 +671,64 @@ enum {
 struct OpalIoPhb3ErrorData {
struct OpalIoPhbErrorCommon common;
 
-   uint32_t brdgCtl;
+   __be32 brdgCtl;
 
/* PHB3 UTL regs */
-   uint32_t portStatusReg;
-   uint32_t rootCmplxStatus;
-   uint32_t busAgentStatus;
+   __be32 portStatusReg;
+   __be32 rootCmplxStatus;
+   __be32 busAgentStatus;
 
/* PHB3 cfg regs */
-   uint32_t deviceStatus;
-   uint32_t slotStatus;
-   uint32_t linkStatus;
-   uint32_t devCmdStatus;
-   uint32_t devSecStatus;
+   __be32 deviceStatus;
+   __be32 slotStatus;
+   __be32 linkStatus;
+   __be32 devCmdStatus;
+   __be32 devSecStatus;
 
/* cfg AER regs */
-   uint32_t rootErrorStatus;
-   uint32_t uncorrErrorStatus;
-   uint32_t corrErrorStatus;
-   uint32_t tlpHdr1;
-   uint32_t tlpHdr2;
-   uint32_t tlpHdr3;
-   uint32_t tlpHdr4;
-   uint32_t sourceId;
+   __be32 rootErrorStatus;
+   __be32 uncorrErrorStatus;
+   __be32 corrErrorStatus;
+   __be32 tlpHdr1;
+   __be32 tlpHdr2;
+   __be32 tlpHdr3;
+   __be32 tlpHdr4;
+   __be32 sourceId;
 
-   uint32_t rsv3;
+   __be32 rsv3;
 
/* Record data about the call to allocate a buffer */
-   uint64_t errorClass;
-   uint64_t correlator;
+   __be64 errorClass;
+   __be64 correlator;
 
-   uint64_t nFir;  /* 000 */
-   uint64_t nFirMask;  /* 003 */
-   uint64_t nFirWOF;   /* 008 */
+   __be64 nFir;/* 000 */
+   __be64 nFirMask;/* 003 */
+   __be64 nFirWOF; /* 008 */
 
/* PHB3 MMIO Error Regs */
-   uint64_t phbPlssr;  /* 120 */
-   uint64_t phbCsr;/* 110 */
-   uint64_t lemFir;/* C00 */
-   uint64_t lemErrorMask;  /* C18 */
-   uint64_t lemWOF;/* C40 */
-   uint64_t phbErrorStatus;/* C80 */
-   uint64_t phbFirstErrorStatus;   /* C88 */
-   uint64_t phbErrorLog0;  /* CC0 */
-   uint64_t phbErrorLog1;  /* CC8 */
-   uint64_t mmioErrorStatus;   /* D00 */
-   uint64_t mmioFirstErrorStatus;  /* D08 */
-   uint64_t mmioErrorLog0; /* D40 */
-   uint64_t mmioErrorLog1; /* D48 */
-   uint64_t dma0ErrorStatus;   /* D80 */
-   uint64_t dma0FirstErrorStatus;  /* D88 */
-   uint64_t dma0ErrorLog0; /* DC0 */
-   uint64_t dma0ErrorLog1; /* DC8 */
-   uint64_t dma1ErrorStatus;   /* E00 */
-   uint64_t dma1FirstErrorStatus;  /* E08 */
-   uint64_t dma1ErrorLog0; /* E40 */
-   uint64_t dma1ErrorLog1; /* E48 */
-   uint64_t pestA[OPAL_PHB3_NUM_PEST_REGS];
-   uint64_t pestB[OPAL_PHB3_NUM_PEST_REGS];
+   __be64 phbPlssr;/* 120 */
+   __be64 phbCsr;  /* 110 */
+   __be64 lemFir;  /* C00 */
+   __be64 lemErrorMask;/* C18 */
+   __be64 lemWOF;  /* C40 */
+   __be64 phbErrorStatus;  /* C80 */
+   __be64 phbFirstErrorStatus; /* C88 */
+   __be64 phbErrorLog0;/* CC0 */
+   __be64 phbErrorLog1;/* CC8 */
+   __be64 mmioErrorStatus; /* D00 */
+   __be64 mmioFirstErrorStatus;/* D08 */
+   __be64 mmioErrorLog0;   /* D40 */
+   __be64 mmioErrorLog1;   /* D48 */
+   __be64 dma0ErrorStatus; /* D80 */
+   __be64 dma0FirstErrorStatus;/* D88 */
+   __be64 dma0ErrorLog0;   /* DC0 */
+   __be64 dma0ErrorLog1;   /* DC8 */
+   __be64 dma1ErrorStatus; /* E00 */
+   __be64 dma1FirstErrorStatus;/* E08 */
+   __be64 dma1ErrorLog0;   /* E40 */
+   __be64 dma1ErrorLog1;   /* E48 */
+   __be64 pestA[OPAL_PHB3_NUM_PEST_REGS];
+   __be64 pestB[OPAL_PHB3_NUM_PEST_REGS];
 };
 
 typedef struct oppanel_line {
@@ -851,8 +851,8 @@ int64_t opal_pci_mask_pe_error(uint64_t phb_id, uin