[Skiboot] [PATCH] hw/npu2: Merge reset functions

Oliver O'Halloran oohall at gmail.com
Fri Mar 22 16:45:23 AEDT 2019


Seems like we should be doing the same cache purge operation in the
CRESET case, and we don't even implement FRESET.

Cc: Reza Arbab <arbab at linux.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 hw/npu2.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/hw/npu2.c b/hw/npu2.c
index 4ecc91350e82..a630536ca418 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -1200,14 +1200,14 @@ static int64_t npu2_get_power_state(struct pci_slot *slot __unused, uint8_t *val
 	return OPAL_SUCCESS;
 }
 
-static int64_t npu2_hreset(struct pci_slot *slot __unused)
+static int64_t npu2_reset(const char *reset_type)
 {
 	struct npu2 *p;
 	int i;
 	struct npu2_dev *ndev;
 
 	p = phb_to_npu2_nvlink(slot->phb);
-	NPU2INF(p, "Hreset PHB state\n");
+	NPU2INF(p, "%s PHB state\n", reset_type);
 
 	for (i = 0; i < p->total_devices; i++) {
 		ndev = &p->devices[i];
@@ -1219,28 +1219,19 @@ static int64_t npu2_hreset(struct pci_slot *slot __unused)
 	return purge_l2_l3_caches();
 }
 
+static int64_t npu2_hreset(struct pci_slot *slot __unused)
+{
+	return npu2_reset("Hreset");
+}
+
 static int64_t npu2_freset(struct pci_slot *slot __unused)
 {
-	return OPAL_SUCCESS;
+	return npu2_reset("Freset");
 }
 
 static int64_t npu2_creset(struct pci_slot *slot)
 {
-	struct npu2 *p;
-	int i;
-	struct npu2_dev *ndev;
-
-	p = phb_to_npu2_nvlink(slot->phb);
-	NPU2INF(p, "Creset PHB state\n");
-
-	for (i = 0; i < p->total_devices; i++) {
-		ndev = &p->devices[i];
-		if (ndev) {
-			NPU2DEVINF(ndev, "Resetting device\n");
-			reset_ntl(ndev);
-		}
-	}
-	return OPAL_SUCCESS;
+	return npu2_reset("Creset");
 }
 
 static struct pci_slot *npu2_slot_create(struct phb *phb)
-- 
2.20.1



More information about the Skiboot mailing list