From patchwork Thu Oct 1 07:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1374879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 ozlabs.org (Postfix) with ESMTPS id 4C247K1sbKz9sVN for ; Thu, 1 Oct 2020 17:11:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=JVc3rEcY; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C247K0zfbzDqTW for ; Thu, 1 Oct 2020 17:11:57 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C24792B97zDqTk for ; Thu, 1 Oct 2020 17:11:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=JVc3rEcY; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4C2473723Jz9sVN; Thu, 1 Oct 2020 17:11:43 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1601536308; bh=SZyieNjYRLZpSX1pFxYAG2SWlq7GFw4Iq2pFmxiZvUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVc3rEcYYptbIw903v/keqeGEdavz2sJkhqFuTW4hTo+J8fuIcMSV+mO8xD9NfbHf fGUpZNFRiepJ901mh7QieCtvrGpn48mWTCUR7vdSSY+itYRevjZ8AwneVKLOHzv6Tg A3sukbIYQ8or9bL0vhocDL1Bmq+QXErxKeTh44lije21bms3jqAF8mPTsIsRPvldJi S6axVCZsITzfFht05TyZMHd02N6eUvgVcD3pGlpjMIEB1uQJ4A0/gjIIVZ1XsfO77P HjuPaL8Hv+mVZkAWwyORs9dpI822iNoHBhDG0Y7TJiRAWBnwL5hC1CfCfCQ9P3L6dn XqNDUQUsXADjw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 1 Oct 2020 17:08:07 +1000 Message-Id: <20201001070814.102735-14-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001070814.102735-1-amitay@ozlabs.org> References: <20201001070814.102735-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 13/20] libpdbg: Update sbefifo chip-ops as per changes in 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: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Joel Stanley --- libpdbg/sbefifo.c | 69 ++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index 63a37e9..1200919 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -253,9 +253,11 @@ static int sbefifo_pib_thread_op(struct pib *pib, uint32_t oper) thread_id = 0xf; /* Enforce special-wakeup for thread stop and sreset */ - if ((oper & 0xf) == SBEFIFO_INSN_OP_STOP || - (oper & 0xf) == SBEFIFO_INSN_OP_SRESET) - mode = 0x2; + if (sbefifo_proc(sctx) == SBEFIFO_PROC_P9) { + if ((oper & 0xf) == SBEFIFO_INSN_OP_STOP || + (oper & 0xf) == SBEFIFO_INSN_OP_SRESET) + mode = 0x2; + } return sbefifo_control_insn(sctx, core_id, thread_id, oper, mode); } @@ -285,6 +287,20 @@ static int sbefifo_pib_thread_sreset(struct pib *pib) return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_SRESET); } +static uint8_t sbefifo_core_id(struct sbefifo_context *sctx, struct thread *thread) +{ + struct pdbg_target *parent; + + if (sbefifo_proc(sctx) == SBEFIFO_PROC_P9) + /* P9 uses pervasive (chiplet) id as core-id */ + parent = pdbg_target_require_parent("chiplet", &thread->target); + else + /* P10 uses core id as core-id */ + parent = pdbg_target_require_parent("core", &thread->target); + + return pdbg_target_index(parent) & 0xff; +} + static int sbefifo_thread_probe(struct pdbg_target *target) { struct thread *thread = target_to_thread(target); @@ -300,21 +316,23 @@ static void sbefifo_thread_release(struct pdbg_target *target) static int sbefifo_thread_op(struct thread *thread, uint32_t oper) { - struct pdbg_target *chiplet = - pdbg_target_require_parent("chiplet", &thread->target); - struct pdbg_target *pib = pdbg_target_require_parent("pib", chiplet); + struct pdbg_target *pib = pdbg_target_require_parent("pib", &thread->target); struct sbefifo *sbefifo = pib_to_sbefifo(pib); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint8_t mode = 0; + uint8_t core_id; /* Enforce special-wakeup for thread stop and sreset */ - if ((oper & 0xf) == SBEFIFO_INSN_OP_STOP || - (oper & 0xf) == SBEFIFO_INSN_OP_SRESET) - mode = 0x2; + if (sbefifo_proc(sctx) == SBEFIFO_PROC_P9) { + if ((oper & 0xf) == SBEFIFO_INSN_OP_STOP || + (oper & 0xf) == SBEFIFO_INSN_OP_SRESET) + mode = 0x2; + } + + core_id = sbefifo_core_id(sctx, thread); - /* This chip-op requires core-id as pervasive (chiplet) id */ return sbefifo_control_insn(sctx, - pdbg_target_index(chiplet), + core_id, thread->id, oper, mode); @@ -347,20 +365,21 @@ static int sbefifo_thread_sreset(struct thread *thread) static int sbefifo_thread_getregs(struct thread *thread, struct thread_regs *regs) { - struct pdbg_target *chiplet = pdbg_target_require_parent("chiplet", &thread->target); - struct pdbg_target *pib = pdbg_target_require_parent("pib", chiplet); + struct pdbg_target *pib = pdbg_target_require_parent("pib", &thread->target); struct sbefifo *sbefifo = pib_to_sbefifo(pib); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint32_t reg_id[34]; uint64_t *value; + uint8_t core_id; int ret, i; for (i=0; i<32; i++) reg_id[i] = i; - /* This chip-op requires core-id as pervasive (chiplet) id */ + core_id = sbefifo_core_id(sctx, thread); + ret = sbefifo_register_get(sctx, - pdbg_target_index(chiplet), + core_id, thread->id, SBEFIFO_REGISTER_TYPE_GPR, reg_id, @@ -410,7 +429,7 @@ static int sbefifo_thread_getregs(struct thread *thread, struct thread_regs *reg reg_id[33] = SPR_PPR; ret = sbefifo_register_get(sctx, - pdbg_target_index(chiplet), + core_id, thread->id, SBEFIFO_REGISTER_TYPE_SPR, reg_id, @@ -461,16 +480,17 @@ static int sbefifo_thread_getregs(struct thread *thread, struct thread_regs *reg static int sbefifo_thread_get_reg(struct thread *thread, uint8_t reg_type, uint32_t reg_id, uint64_t *value) { - struct pdbg_target *chiplet = pdbg_target_require_parent("chiplet", &thread->target); - struct pdbg_target *pib = pdbg_target_require_parent("pib", chiplet); + struct pdbg_target *pib = pdbg_target_require_parent("pib", &thread->target); struct sbefifo *sbefifo = pib_to_sbefifo(pib); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint64_t *v; + uint8_t core_id; int ret; - /* This chip-op requires core-id as pervasive (chiplet) id */ + core_id = sbefifo_core_id(sctx, thread); + ret = sbefifo_register_get(sctx, - pdbg_target_index(chiplet), + core_id, thread->id, reg_type, ®_id, @@ -487,14 +507,15 @@ static int sbefifo_thread_get_reg(struct thread *thread, uint8_t reg_type, uint3 static int sbefifo_thread_put_reg(struct thread *thread, uint8_t reg_type, uint32_t reg_id, uint64_t value) { - struct pdbg_target *chiplet = pdbg_target_require_parent("chiplet", &thread->target); - struct pdbg_target *pib = pdbg_target_require_parent("pib", chiplet); + struct pdbg_target *pib = pdbg_target_require_parent("pib", &thread->target); struct sbefifo *sbefifo = pib_to_sbefifo(pib); struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + uint8_t core_id; + + core_id = sbefifo_core_id(sctx, thread); - /* This chip-op requires core-id as pervasive (chiplet) id */ return sbefifo_register_put(sctx, - pdbg_target_index(chiplet), + core_id, thread->id, reg_type, ®_id,