From patchwork Thu Nov 25 00:41:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Niethe X-Patchwork-Id: 1559482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=l3B+Gwjf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hzzbc0Xskz9sVc for ; Thu, 25 Nov 2021 11:42:04 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Hzzbb6yzKz2yn9 for ; Thu, 25 Nov 2021 11:42:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=l3B+Gwjf; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::52b; helo=mail-pg1-x52b.google.com; envelope-from=jniethe5@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=l3B+Gwjf; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HzzbX1Bztz2ypV for ; Thu, 25 Nov 2021 11:42:00 +1100 (AEDT) Received: by mail-pg1-x52b.google.com with SMTP id t4so3590646pgn.9 for ; Wed, 24 Nov 2021 16:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T9Fb4FHPMdQPctB451X/wVobORZnhnek7nAuZz4gAtc=; b=l3B+GwjfW913h2x7LKgXkPwwaKG6Z4zXaVD6DDuPHOF3twoV0k9d8Blp/EHAEf76hH As63ZZYurdoGr6q1bXF3pcEyOkTdF+pWgiOCcRwwAiyaBtsyw2uUJ/BgDEetzF1jrNyT WSpPq3FCePQ82qA0stF2lKhKrBsouF8U2uAgwtkcK9L2HDP9W7Uw8Q5mb98qXcB7cXec CE42wiEkobHpluOZDPLLh6ZEAwv0cV+xuXjMcH1fpYYq0I5o3wHlF1Go+BusU/Clrorf ShNSsw9wVjERHP/Rb12ICTcZirT13VXGEuNxFlcF6cCwZal2pP9A5n0l7e/DnkAFFNPn lzFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T9Fb4FHPMdQPctB451X/wVobORZnhnek7nAuZz4gAtc=; b=4AvYUsPPus8KU3iCxM1nz6spcPDVw96QsXuVNg9wnQLuLOofhmALiu+2BYU7gC8FyR Vgpoyoe7/SMqrhuwrITjkjLdcZQTZXpX3wXUzzXGm9qtQ5iU0swgT+60gxWQEWgdpevw T8Elvj/p0WzkbGeW8P7Jl5AtSTw+rsNJazY9DQhWc4AUlE+16dvLhYwyKGf7odnCDMzx KxcvIVL4kYZeLJFLdZkZQN6pF/Aot+KCGt2jN2YKYrey3v2JFiOREON+x2wqsbYgP6ED UWzxD83I9U3jnPBwMKbJUBsyt/HQ+XMUulDkJ/CwdBQSOma3yAMZ8Hqdpk9It8CiJEka ObYA== X-Gm-Message-State: AOAM530g+4ipbGB7/lF9QHPfrJ/QHHjLU6LTzfbUEg+KLIjBFH/3Puj+ rP2xOIHTzFCqfONxRjn1uUorXfw08yk= X-Google-Smtp-Source: ABdhPJxWXODVfVNWc/vMAMacWAmX1NP+yTH8+dQ+IvuPHjLB85oPfI9AMTTYpGFCGhhOElQJx2WWhQ== X-Received: by 2002:a05:6a00:2290:b0:49f:c63a:2a5f with SMTP id f16-20020a056a00229000b0049fc63a2a5fmr10592385pfe.69.1637800917577; Wed, 24 Nov 2021 16:41:57 -0800 (PST) Received: from tee480.ibm.com (159-196-117-139.9fc475.syd.nbn.aussiebb.net. [159.196.117.139]) by smtp.gmail.com with ESMTPSA id fw21sm5490326pjb.25.2021.11.24.16.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 16:41:57 -0800 (PST) From: Jordan Niethe To: pdbg@lists.ozlabs.org Date: Thu, 25 Nov 2021 11:41:34 +1100 Message-Id: <20211125004138.120917-6-jniethe5@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125004138.120917-1-jniethe5@gmail.com> References: <20211125004138.120917-1-jniethe5@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 5/9] libpdbg: Prepare to add chtm for p10 X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Break some p8 specific functionality into helper functions to make things cleaner when adding support for chtm on p10. Signed-off-by: Jordan Niethe --- v2: add .configure, .deconfigure, function pointers --- libpdbg/htm.c | 52 +++++++++++++++++++++++++++++++----------------- libpdbg/hwunit.h | 3 +++ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 419ac287e760..f4a0c28a20a7 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -586,8 +586,7 @@ static int configure_debugfs_memtrace(struct htm *htm) static int configure_chtm(struct htm *htm, bool wrap) { - uint64_t hid0, ncu, val; - struct pdbg_target *core; + uint64_t val; if (!pdbg_target_is_class(&htm->target, "chtm")) return 0; @@ -600,6 +599,17 @@ static int configure_chtm(struct htm *htm, bool wrap) HTM_MODE_ENABLE | val))) return -1; + if (htm->configure && htm->configure(htm) < 0) + return -1; + + return 0; +} + +static int do_configure_chtm_p8(struct htm *htm) +{ + uint64_t hid0, ncu; + struct pdbg_target *core; + core = pdbg_target_require_parent("core", &htm->target); if (HTM_ERR(pib_read(core, HID0_REGISTER, &hid0))) return -1; @@ -618,12 +628,27 @@ static int configure_chtm(struct htm *htm, bool wrap) static int deconfigure_chtm(struct htm *htm) { - uint64_t hid0, ncu; - struct pdbg_target *core; if (!pdbg_target_is_class(&htm->target, "chtm")) return 0; + if (htm->deconfigure && htm->deconfigure(htm) < 0) + return -1; + + if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,0))) + return -1; + +// FIXME this needs kernel work to happen +// if (HTM_ERR(deconfigure_debugfs_memtrace(htm))) +// return -1; + return 0; +} + +static int do_deconfigure_chtm_p8(struct htm *htm) +{ + struct pdbg_target *core; + uint64_t ncu, hid0; + core = pdbg_target_require_parent("core", &htm->target); if (HTM_ERR(pib_read(core, NCU_MODE_REGISTER, &ncu))) return -1; @@ -637,12 +662,6 @@ static int deconfigure_chtm(struct htm *htm) if (HTM_ERR(pib_write(core, HID0_REGISTER, hid0))) return -1; - if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,0))) - return -1; - -// FIXME this needs kernel work to happen -// if (HTM_ERR(deconfigure_debugfs_memtrace(htm))) -// return -1; return 0; } @@ -929,7 +948,7 @@ static int do_htm_reset(struct htm *htm, bool wrap) /* Stolen from p8chip.c */ #define RAS_MODE_REG 0x1 #define MR_THREAD_IN_DEBUG PPC_BIT(43) -static int htm_toggle_debug_bit(struct htm *htm) +static int do_post_configure_chtm_p8(struct htm *htm) { struct pdbg_target *target; struct pdbg_target *core; @@ -941,12 +960,6 @@ static int htm_toggle_debug_bit(struct htm *htm) if (!core) return 0; /* nhtm case */ - /* FIXME: this is a hack for P8 */ - if (!pdbg_target_compatible(core, "ibm,power8-core")) { - PR_ERROR("HTM is POWER8 only currently\n"); - return -1; - } - pdbg_for_each_target("thread", core, target) { if (pdbg_target_index(target) == 0) { /* Need to set this bit to ensure HTM starts */ @@ -980,7 +993,7 @@ static int __do_htm_start(struct htm *htm, bool wrap) if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_START))) return -1; - if (htm_toggle_debug_bit(htm)) + if (htm->post_configure && htm->post_configure(htm)) return -1; /* @@ -1378,6 +1391,9 @@ static struct htm p8_chtm = { .record = do_htm_record, .status = do_htm_status, .dump = do_htm_dump, + .configure = do_configure_chtm_p8, + .deconfigure = do_deconfigure_chtm_p8, + .post_configure = do_post_configure_chtm_p8, }; DECLARE_HW_UNIT(p8_chtm); diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index de15a870c20f..b8504b187d15 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -58,6 +58,9 @@ struct htm { int (*status)(struct htm *); int (*dump)(struct htm *, char *); int (*record)(struct htm *, char *); + int (*configure)(struct htm *); + int (*deconfigure)(struct htm *); + int (*post_configure)(struct htm *); }; #define target_to_htm(x) container_of(x, struct htm, target)