Skip to content

Commit d63ed06

Browse files
ozbenhstewartsmith
authored andcommitted
phb4: Fix PHB4 fence recovery
We had a few problems: - We used the wrong register to trigger the reset (spec bug) - We should clear the PFIR and NFIR while the reset is asserted - ... and in the right order ! - We should only apply the DD1 workaround after the reset has been lifted. - We should ensure we use ASB whenever we are fenced or doing a CRESET - Make config ops write with ASB Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent c5f23f2 commit d63ed06

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

hw/phb4.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,9 +1854,6 @@ static void phb4_read_phb_status(struct phb4 *p,
18541854
phb4_pcicfg_read32(&p->phb, 0, p->aercap + PCIECAP_AER_SRCID,
18551855
&stat->sourceId);
18561856

1857-
/* Restore config space to MMIO instead of ASB */
1858-
p->flags &= ~PHB4_CFG_USE_ASB;
1859-
18601857
/* PEC NFIR, same as P8/PHB3 */
18611858
xscom_read(p->chip_id, p->pe_stk_xscom + 0x0, &stat->nFir);
18621859
xscom_read(p->chip_id, p->pe_stk_xscom + 0x3, &stat->nFirMask);
@@ -2410,19 +2407,22 @@ static int64_t phb4_creset(struct pci_slot *slot)
24102407
xscom_write(p->chip_id, p->pe_stk_xscom + 0x2,
24112408
0x000000f000000000);
24122409

2410+
/*
2411+
* Force use of ASB for register access until the PHB has
2412+
* been fully reset.
2413+
*/
2414+
p->flags |= PHB4_CFG_USE_ASB;
2415+
24132416
/* Clear errors, following the proper sequence */
24142417
phb4_err_clear(p);
24152418

2416-
/* Clear errors in NFIR and raise ETU reset */
2417-
xscom_read(p->chip_id, p->pe_stk_xscom + 0x0, &p->nfir_cache);
2418-
xscom_read(p->chip_id, p->pci_stk_xscom + 0x0, &p->pfir_cache);
2419-
2420-
xscom_write(p->chip_id, p->pci_stk_xscom + 0x0,
2419+
/* Actual reset */
2420+
xscom_write(p->chip_id, p->pci_stk_xscom + XPEC_PCI_STK_ETU_RESET,
24212421
0x8000000000000000);
24222422

2423-
/* DD1 errata: write to PEST to force update */
2424-
phb4_ioda_sel(p, IODA3_TBL_PESTA, PHB4_RESERVED_PE_NUM(p), false);
2425-
out_be64(p->regs + PHB_IODA_DATA0, 0);
2423+
/* Clear errors in PFIR and NFIR */
2424+
xscom_read(p->chip_id, p->pci_stk_xscom + 0x0, &p->pfir_cache);
2425+
xscom_read(p->chip_id, p->pe_stk_xscom + 0x0, &p->nfir_cache);
24262426

24272427
pci_slot_set_state(slot, PHB4_SLOT_CRESET_WAIT_CQ);
24282428
slot->retries = 500;
@@ -2438,8 +2438,14 @@ static int64_t phb4_creset(struct pci_slot *slot)
24382438
xscom_write(p->chip_id, p->pci_stk_xscom + 0x1,
24392439
~p->pfir_cache);
24402440

2441-
// Clear PHB from reset
2442-
xscom_write(p->chip_id, p->pci_stk_xscom + 0x0, 0x0);
2441+
/* Clear PHB from reset */
2442+
xscom_write(p->chip_id,
2443+
p->pci_stk_xscom + XPEC_PCI_STK_ETU_RESET, 0x0);
2444+
2445+
/* DD1 errata: write to PEST to force update */
2446+
phb4_ioda_sel(p, IODA3_TBL_PESTA, PHB4_RESERVED_PE_NUM(p),
2447+
false);
2448+
phb4_write_reg(p, PHB_IODA_DATA0, 0);
24432449

24442450
pci_slot_set_state(slot, PHB4_SLOT_CRESET_REINIT);
24452451
return pci_slot_set_sm_timeout(slot, msecs_to_tb(100));
@@ -2455,6 +2461,7 @@ static int64_t phb4_creset(struct pci_slot *slot)
24552461
PHBDBG(p, "CRESET: Reinitialization\n");
24562462
p->flags &= ~PHB4_AIB_FENCED;
24572463
p->flags &= ~PHB4_CAPP_RECOVERY;
2464+
p->flags &= ~PHB4_CFG_USE_ASB;
24582465
phb4_init_hw(p, false);
24592466
pci_slot_set_state(slot, PHB4_SLOT_CRESET_FRESET);
24602467
return pci_slot_set_sm_timeout(slot, msecs_to_tb(100));

0 commit comments

Comments
 (0)