[Pdbg] [PATCH 12/18] htm: Cleanup reset

Michael Neuling mikey at neuling.org
Tue Jun 19 15:25:29 AEST 2018


Simplify the code.

Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 libpdbg/htm.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index dedf0e1938..790ca4feef 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -430,6 +430,9 @@ static int configure_chtm(struct htm *htm)
 {
 	uint64_t hid0, ncu;
 
+	if (!pdbg_target_is_class(&htm->target, "chtm"))
+		return 0;
+
 	if (HTM_ERR(configure_debugfs_memtrace(htm)))
 		return -1;
 
@@ -484,6 +487,9 @@ static int configure_nhtm(struct htm *htm)
 {
 	uint64_t val;
 
+	if (!pdbg_target_is_class(&htm->target, "nhtm"))
+		return 0;
+
 	if (HTM_ERR(configure_debugfs_memtrace(htm)))
 		return -1;
 
@@ -702,21 +708,10 @@ static int do_htm_reset(struct htm *htm)
 		return -1;
 
 	if (!is_resetable(&status) || !is_configured(htm)) {
-		if (pdbg_target_is_class(&htm->target, "nhtm")) {
-			if (HTM_ERR(configure_nhtm(htm))) {
-				PR_ERROR("Couldn't setup Nest HTM during reset\n");
-				return -1;
-			}
-		} else if (pdbg_target_is_class(&htm->target, "chtm")) {
-			if (HTM_ERR(configure_chtm(htm))) {
-				PR_ERROR("Couldn't setup Core HTM during reset\n");
-				return -1;
-			}
-		} else { /* Well... */
-			PR_ERROR("Unknown HTM class! %s\n",
-				pdbg_target_class_name(&htm->target));
-		}
-
+		if (configure_nhtm(htm) < 0)
+			return -1;
+		if (configure_chtm(htm) < 0)
+			return -1;
 	}
 
 	if (HTM_ERR(configure_memory(htm)))
-- 
2.17.1



More information about the Pdbg mailing list