From patchwork Mon Oct 14 05:50:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1175991 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 ozlabs.org (Postfix) with ESMTPS id 46s72166qlz9sPh for ; Mon, 14 Oct 2019 16:50:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46s72136KNzDqbh for ; Mon, 14 Oct 2019 16:50:17 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (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 46s71r0p2yzDqXw for ; Mon, 14 Oct 2019 16:50:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au 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 ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46s71q4SHMz9s4Y; Mon, 14 Oct 2019 16:50:07 +1100 (AEDT) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:50:04 +1100 Message-Id: <20191014055004.1704-1-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Pdbg] [PATCH] libpdbg/host.c: Use reg property index of index to find chip-id 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" The host backend needs the hardware chip-id to find the correct debugfs xscom file but incorrectly derives this from the index. This means the chip path contains the actual chip-id rather than the index which should be a logcal index starting at zero as it does for all other backends. This patch updates the host backend to use reg property for the chip-id. A future patch will alter the device-trees to make this the case. Signed-off-by: Alistair Popple --- libpdbg/host.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libpdbg/host.c b/libpdbg/host.c index 061ff2a..428c18b 100644 --- a/libpdbg/host.c +++ b/libpdbg/host.c @@ -85,9 +85,10 @@ static int host_pib_probe(struct pdbg_target *target) struct pib *pib = target_to_pib(target); int fd; char *access_fn; - uint32_t index; + uint32_t chip; - index = pdbg_target_index(target); + if (pdbg_target_u32_property(target, "reg", &chip)) + return -1; /* This check should probably be done earlier */ if (access(XSCOM_BASE_PATH, F_OK) == -1) @@ -97,7 +98,7 @@ static int host_pib_probe(struct pdbg_target *target) PR_ERROR("You may need to re-run the command as root.\n"); } - if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, index) < 0) + if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip) < 0) return -1; fd = open(access_fn, O_RDWR);