From patchwork Thu Sep 19 02:33:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164321 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygs4727Wz9sNx for ; Thu, 19 Sep 2019 12:34:00 +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.b="oq7850Ql"; 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 46Ygs454pzzF1QZ for ; Thu, 19 Sep 2019 12:34:00 +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) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46Ygrm59wjzDs09 for ; Thu, 19 Sep 2019 12:33:44 +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.b="oq7850Ql"; 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 46Ygrm0ktcz9sNf; Thu, 19 Sep 2019 12:33:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860424; bh=dfHKU4OdGkywwLzhlxI9vtymLjohxweI3oRyZnoAAzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oq7850QlJMX1Jv0/4Aik/KqdsG+F9cB9E3r/XxWghm0JSs8xyxEvo8R78SLYGkBpi h5dX1h5278repTsk36gwIN9uGP7hkz4UVrrovLsWeQKf83QrQYtqINiUIDCAkVKVKR lguwI94ef5q0rN28KrcT7vqs0xsNICT2j2se7b/3kabZQxB8YrmBsiEmK1blkYycAw DkOkkCc7KYKoGiBXyRXjkM6/az9SB+0rQlzUgjXTL+Hk222fNmTB980czsI/sjmoNf W9+2VT+r+Bha83ARcJ+R1reaiJUCToeOWNdC5dyZJ49/8UMHW0pMPme4Fig6pBpjdv nGHZAEKU5XC4g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:11 +1000 Message-Id: <20190919023333.5295-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 01/23] libpdbg: class name and name should be const 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" Each function returns a pointer to the actual name. User must not be able to modify that. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/libpdbg.c | 4 ++-- libpdbg/libpdbg.h | 4 ++-- src/main.c | 2 +- src/scom.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index 0c5a451..aade5d3 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -120,12 +120,12 @@ uint32_t pdbg_parent_index(struct pdbg_target *target, char *class) return -1; } -char *pdbg_target_class_name(struct pdbg_target *target) +const char *pdbg_target_class_name(struct pdbg_target *target) { return target->class; } -char *pdbg_target_name(struct pdbg_target *target) +const char *pdbg_target_name(struct pdbg_target *target) { return target->name; } diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index e752681..dffc346 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -113,8 +113,8 @@ uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(const struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass); -char *pdbg_target_class_name(struct pdbg_target *target); -char *pdbg_target_name(struct pdbg_target *target); +const char *pdbg_target_class_name(struct pdbg_target *target); +const char *pdbg_target_name(struct pdbg_target *target); const char *pdbg_target_dn_name(struct pdbg_target *target); void *pdbg_target_priv(struct pdbg_target *target); void pdbg_target_priv_set(struct pdbg_target *target, void *priv); diff --git a/src/main.c b/src/main.c index efdc4bb..44d1c55 100644 --- a/src/main.c +++ b/src/main.c @@ -518,7 +518,7 @@ static void print_target(struct pdbg_target *target, int level) int i; struct pdbg_target *next; enum pdbg_target_status status; - char *classname; + const char *classname; /* Does this target actually exist? */ status = pdbg_target_status(target); diff --git a/src/scom.c b/src/scom.c index 8d8e988..c747f3d 100644 --- a/src/scom.c +++ b/src/scom.c @@ -29,7 +29,7 @@ /* Check if a target has scom region */ static bool scommable(struct pdbg_target *target) { - char *classname; + const char *classname; classname = pdbg_target_class_name(target); if (!strcmp(classname, "pib") || From patchwork Thu Sep 19 02:33:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164322 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 46Ygs904QKz9sNf for ; Thu, 19 Sep 2019 12:34:05 +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.b="fxgd//1d"; 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 46Ygs84XYxzF33P for ; Thu, 19 Sep 2019 12:34:04 +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 46Ygrm5DTnzDsDy for ; Thu, 19 Sep 2019 12:33:44 +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.b="fxgd//1d"; 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 46Ygrm2CNGz9sNx; Thu, 19 Sep 2019 12:33:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860424; bh=YOjAbKQs7rXC1K0hG04oBqHKQv+UTJIyE2kbJWizA8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fxgd//1dPQzAH53JWMlViqRM2Ro5qfI0KV5bFYI+kCIVPd8AsNwlj8/gmgUB02DeC XrFAoY3C2aXO9MuUQY2N7qviGf1tNGtA11eXBa5UU0wOgVuy3EUMaOmM9zehQJ+gC4 07w66RxQGl6Hs2JAUF3zKqJJeVDgXLc8EGT1Zqvx8zUPBH402cT6oEpPwqiG0OsEt9 1rOPxZ70zDj3kfRYALWLYIpD81WtqEZdme12r82xfla8kZPsmMIlDDT2HmGQrKoBKE lI/j6CqP/BDrum3y7TpWs2hWYx3YP7J/+rVS8RsD/a1sNOfxQoAhcgDtME0arp5B3s 73gbguwQTy3lA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:12 +1000 Message-Id: <20190919023333.5295-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 02/23] libpdbg: Drop const from pdbg_target_path() argument 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: Alistair Popple --- libpdbg/device.c | 8 ++++---- libpdbg/libpdbg.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index efa9ce4..6c3b769 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -208,10 +208,10 @@ static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) return true; } -static char *dt_get_path(const struct pdbg_target *node) +static char *dt_get_path(struct pdbg_target *node) { unsigned int len = 0; - const struct pdbg_target *n; + struct pdbg_target *n; char *path, *p; /* Dealing with NULL is for test/debug purposes */ @@ -445,7 +445,7 @@ static struct pdbg_target *dt_next(const struct pdbg_target *root, return NULL; } -static const struct dt_property *dt_require_property(const struct pdbg_target *node, +static const struct dt_property *dt_require_property(struct pdbg_target *node, const char *name, int wanted_len) { const struct dt_property *p = dt_find_property(node, name); @@ -656,7 +656,7 @@ void pdbg_targets_init(void *fdt) dt_expand(pdbg_dt_root, fdt); } -char *pdbg_target_path(const struct pdbg_target *target) +char *pdbg_target_path(struct pdbg_target *target) { return dt_get_path(target); } diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index dffc346..caf8b85 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -110,7 +110,7 @@ void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); -char *pdbg_target_path(const struct pdbg_target *target); +char *pdbg_target_path(struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass); const char *pdbg_target_class_name(struct pdbg_target *target); From patchwork Thu Sep 19 02:33:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164320 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 46Ygs06yVvz9sNf for ; Thu, 19 Sep 2019 12:33:56 +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.b="dlALUH1r"; 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 46Ygs050FkzF1s8 for ; Thu, 19 Sep 2019 12:33:56 +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 46Ygrm72ZTzDsPL for ; Thu, 19 Sep 2019 12:33:44 +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.b="dlALUH1r"; 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 46Ygrm59wWz9sPG; Thu, 19 Sep 2019 12:33:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860424; bh=hei9y/HuqSlmL0o2ct2zN5xhAuFRKEGwVd4CPQa24wE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlALUH1r30QyEWNOWu0uzXaPJR90Gg72W/7XvPA57S3XeIm8KNCfsVg+Y1ewBDBCJ TXxRoQLZtL7XgsXUPY93jsfhTD40jJ+UJvlF5xIh+E+s/d4LMAsdlBzkCgw85hD35h bkKwvFxECr1unQuai27bLL57o2NxPlmCUOTD30CZbdWMxsCCpsaRpDw0CaytsmYrQM ExpzHq1XCCihcoxjcj2qXjR6xIqAQlvfJdeo9a+Jrbx2pURPQhiIcTHDVDPRjx+XvF UVBSN8Fp53q2yp/x3r3ifPkeAd9p4IJrTk7IcbCDp/epAJsOI6T0cdm/4MHTOpRywg TxtIHcgPODyPg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:13 +1000 Message-Id: <20190919023333.5295-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 03/23] libpdbg: Rename function to reflect the functionality 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: Alistair Popple --- libpdbg/device.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 6c3b769..6e2e7bb 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -173,26 +173,26 @@ static int dt_cmp_subnodes(const struct pdbg_target *a, const struct pdbg_target return strcmp(a->dn_name, b->dn_name); } -static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) +static bool dt_attach_node(struct pdbg_target *parent, struct pdbg_target *child) { struct pdbg_target *node = NULL; - assert(!root->parent); + assert(!child->parent); if (list_empty(&parent->children)) { - list_add(&parent->children, &root->list); - root->parent = parent; + list_add(&parent->children, &child->list); + child->parent = parent; return true; } dt_for_each_child(parent, node) { - int cmp = dt_cmp_subnodes(node, root); + int cmp = dt_cmp_subnodes(node, child); /* Look for duplicates */ if (cmp == 0) { prerror("DT: %s failed, duplicate %s\n", - __func__, root->dn_name); + __func__, child->dn_name); return false; } @@ -202,8 +202,8 @@ static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) break; } - list_add_before(&parent->children, &root->list, &node->list); - root->parent = parent; + list_add_before(&parent->children, &child->list, &node->list); + child->parent = parent; return true; } @@ -583,7 +583,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod * going for now, we may ultimately want to * assert */ - (void)dt_attach_root(node, child); + (void)dt_attach_node(node, child); break; case FDT_END: return -1; From patchwork Thu Sep 19 02:33:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164319 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 46Ygrw4tvXz9sNF for ; Thu, 19 Sep 2019 12:33:52 +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.b="ntceSg40"; 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 46Ygrw0DW2zF1MY for ; Thu, 19 Sep 2019 12:33:52 +1000 (AEST) 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 46Ygrn1NjNzDsQB for ; Thu, 19 Sep 2019 12:33:45 +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.b="ntceSg40"; 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 46Ygrm6c1wz9sPK; Thu, 19 Sep 2019 12:33:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860424; bh=6A1+ddw1kJ0kIz21pzKcrnBGDr3F8Ajqn+BYddherpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ntceSg40aDptFP2tLw6dx/BIF+//HPd77n37PlsXEtsMaNrKB3PTGFXeGJBk6OTtS +PTPLKJ5FAxc5y3LkiGO8AN0/uM04t/3hagKIYfM1yLzPnqY83B8kSnQMz6K0UaMjx YbveZQVa9TLhPXHMo/gg4CUJ11yYpcnWNIhNX7Ri9mlNpA4SmdPV716t6XfIkeoxD9 8/kQNhBCoGGm/6xftStKfwi78kGUKMssSi5OKB0wP/FP7fA2KhtQ1PPslqbBQBVHfu iLKYiApD/lg0dToYpE/ba+rhj62P2GZadwm5buiDr7e4CXrsT3OLPTYOOTYume0NpQ gSEaSwm/s2Dbg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:14 +1000 Message-Id: <20190919023333.5295-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 04/23] libpdbg: Add virtual node target 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" This is used to construct system device tree representation. Currently there are multiple device trees for a system (e.g. P9) based on the backend where it's used. This means one cannot refer to a hwunit by specific path which is independent of backend. System device tree is a system representation that allows to identify hwunits uniquely by device tree path. However, the backend device trees are still separate. To avoid keeping two different device trees (system device tree and backend device tree) in memory, a system device tree view is created on top of the backend device tree. This system device tree view is created using virtual nodes. A virtual nodes denotes the attachment point for a hw-unit in a system device tree view. With multiple virtual nodes a system device tree view is overlaid on top of the backend device tree. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/target.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libpdbg/target.h b/libpdbg/target.h index 2ecbf98..7e08ac3 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -50,6 +50,7 @@ struct pdbg_target { bool probed; struct list_node class_link; void *priv; + struct pdbg_target *vnode; }; struct pdbg_target *require_target_parent(struct pdbg_target *target); From patchwork Thu Sep 19 02:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164326 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygsg5j91z9sNF for ; Thu, 19 Sep 2019 12:34:31 +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.b="drfJILKr"; 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 46Ygsg2FVQzF3Nm for ; Thu, 19 Sep 2019 12:34:31 +1000 (AEST) 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 46Ygrp1KGzzF0YD for ; Thu, 19 Sep 2019 12:33:46 +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.b="drfJILKr"; 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 46Ygrn1ldSz9sPM; Thu, 19 Sep 2019 12:33:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860425; bh=9ummVBUOjIJAIyGfgfFISrv29fL/lm0qB/D/VWOXbMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drfJILKrqBI0Vx0leyyjv/VlmqOvBybpx/DZVUuMOGWnzgy9SRg3e+yUP5peRTZl+ gGkSBMHV1y+cWqMnIk/Zm0irjN8uJS+56vwJz7VaZA2LJCuWNIiixQPRVq2AAkoi0L cT/HzM2aYF6HLz3Pr0lNRV/H/vIvgirsJi6eoPJm5JVKXk0Hv8H6fChFXCghJ9gDa7 ryrcJUNZPVFz3yLgpbgGi+D86B1RhX0d64qQrj6ueuYfIM6+1AqKWpxNipqg4tB6Lf KMlAivKJRx5TBcte3usJv16PnZQzDz3B/irmDWYYwxwM6ofC5F37FXE2PqI2el2snI hvWffJzRWQaKw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:15 +1000 Message-Id: <20190919023333.5295-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 05/23] libpdbg: Support paths including virutal nodes 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" With the presence of virtual nodes, some of the nodes can be reached from the root using different paths: - using virtual nodes (which provide the system device tree view) - using the actual hwunits present in the backend (backend device tree) Both device tree paths should result in the same hardware unit. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 6e2e7bb..e4dc5c7 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -294,7 +294,10 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char if (pal && (pal != nal || strncmp(pa, na, pal))) match = false; if (match) { - root = n; + if (n->vnode) + root = n->vnode; + else + root = n; break; } } From patchwork Thu Sep 19 02:33:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164328 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygsq0CWTz9sNx for ; Thu, 19 Sep 2019 12:34:39 +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.b="u0JF15y7"; 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 46Ygsp6901zF3Pd for ; Thu, 19 Sep 2019 12:34:38 +1000 (AEST) 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 46Ygrp1J1JzF0RM for ; Thu, 19 Sep 2019 12:33:46 +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.b="u0JF15y7"; 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 46Ygrn3ZT4z9s00; Thu, 19 Sep 2019 12:33:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860425; bh=NABPxrb+magwJmszUJHfEyZaE1N4052I1or3iPHsdnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u0JF15y7nLDPsulsfk5EfywLrGkxsl9y2zCZsxHfG9oY8bghDF8N+uwmg3cRonM+O 909quOjrTAEWhmzbRfqPN2lDTiqQ/VqTfo7YqRj0vw5rPsx5aINdW8GVhnJZZDXoXd //tAfyKMdLjPxdyMIk15j9uzMx2K+DiaIvrORUxhrRzdhMhbKagS+r02tXvz4RW8PJ 1z3WXnbywixVzfQALCv5vXX1eU5lLXJFF8k6u9edoKKtbN/pvEWe6Ax8Uar+VhcNUd 2Qy4qT6aVfRlfXpZeWdwUieFnCmzvS6WYx/PtsBbWAgkyPFGVUplV3RAKUuZwFcu0i lPAKTNbpfG21g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:16 +1000 Message-Id: <20190919023333.5295-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 06/23] libpdbg: Construct unique path based on virtual nodes 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" Even though there can be two different paths to a node, libpdbg users should always see the path as defined in system device tree (view) which is the same and independent of the backend device tree. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index e4dc5c7..ce88609 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -219,6 +219,9 @@ static char *dt_get_path(struct pdbg_target *node) return strdup(""); for (n = node; n; n = n->parent) { + if (n->vnode && n->compatible) + n = n->vnode; + len += strlen(n->dn_name); if (n->parent || n == node) len++; @@ -227,6 +230,9 @@ static char *dt_get_path(struct pdbg_target *node) assert(path); p = path + len; for (n = node; n; n = n->parent) { + if (n->vnode && n->compatible) + n = n->vnode; + len = strlen(n->dn_name); p -= len; memcpy(p, n->dn_name, len); From patchwork Thu Sep 19 02:33:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164325 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YgsW4gzSz9sNf for ; Thu, 19 Sep 2019 12:34:23 +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.b="xUmYviHT"; 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 46YgsW388QzF3Gv for ; Thu, 19 Sep 2019 12:34:23 +1000 (AEST) 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 46Ygrp1HqFzF0Pv for ; Thu, 19 Sep 2019 12:33:46 +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.b="xUmYviHT"; 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 46Ygrn5hTzz9sPS; Thu, 19 Sep 2019 12:33:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860425; bh=ZzQ4Ec4oY80WWxCyscdW7gSbp6fUGeLYcMo4r3JmXOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xUmYviHTpOYdtzzummg67C67owJNKVRowXTljA6XhxIVEldfXW7vyZYrCK595t0wt E5vde9iWa8BzZXMMAtTwRDWw2oA+9Ol2sUUuTHQC6jdKbcHIaocfj3TN+SsjLFfTS3 d9o0ot6HugPqKyF95247KkJRGjqff1APPlBGeWiMSrxBmGsS1BnunsaC77JP7qVCob lM1fMTCMnFNATXfZZu03hbEtoZbodDII6nregGLgvcg67HankOmZxb35zey/m62Jqn snWR76uuj58F4FVNd7HLyxT9/TyliJwtPD1OxWAtcb/hmi4SoU8RaiHlQ7vxtNknLd X8sHibUKwVWcA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:17 +1000 Message-Id: <20190919023333.5295-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 07/23] libpdbg: Create virtual nodes based on device-tree-path property 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" To create a virtual node, "device-tree-path" property is used to denote the attachment point in the system device tree view. It's also possible to create virtual nodes from backend device tree as nodes without compatible property. All nodes without "compatible" property will be treated as virtual nodes. Signed-off-by: Amitay Isaacs --- libpdbg/device.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index ce88609..4160ea8 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -649,6 +649,75 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *out_size) return dt_get_number(p->prop, na); } +static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_target *root) +{ + struct pdbg_target *vnode, *parent, *child = NULL; + struct dt_property *prop; + const char *dtree_path; + char *parent_path, *sep; + size_t len; + + dtree_path = (const char *)pdbg_target_property(node, "device-tree-path", &len); + if (!dtree_path) + goto skip; + + vnode = dt_find_by_path(root, dtree_path); + if (vnode) { + if (vnode->vnode) + goto skip; + else + goto link_vnode; + } + + parent_path = strdup(dtree_path); + assert(parent_path); + + sep = strrchr(parent_path, '/'); + if (!sep || sep[1] == '\0') { + char *path = dt_get_path(node); + PR_ERROR("Invalid path reference \"%s\" for node %s\n", dtree_path, path); + free(path); + free(parent_path); + goto skip; + } + + *sep = '\0'; + + parent = dt_find_by_path(root, parent_path); + if (!parent) { + char *path = dt_get_path(node); + PR_ERROR("Invalid path reference \"%s\" for node %s\n", dtree_path, path); + free(path); + free(parent_path); + goto skip; + } + + vnode = dt_new_node(sep+1, NULL, 0); + assert(vnode); + + free(parent_path); + + if (!dt_attach_node(parent, vnode)) + goto skip; + + PR_DEBUG("Created virtual node %s\n", dtree_path); + +link_vnode: + node->vnode = vnode; + vnode->vnode = node; + + while ((prop = list_pop(&vnode->properties, struct dt_property, list))) + list_add_tail(&node->properties, &prop->list); + +skip: + list_for_each(&node->children, child, list) { + if (child->vnode && !child->compatible) + continue; + + pdbg_targets_init_virtual(child, root); + } +} + void pdbg_targets_init(void *fdt) { /* Root node needs to be valid when this function returns */ @@ -663,6 +732,7 @@ void pdbg_targets_init(void *fdt) } dt_expand(pdbg_dt_root, fdt); + pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); } char *pdbg_target_path(struct pdbg_target *target) From patchwork Thu Sep 19 02:33:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164324 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 46YgsP72k0z9sNf for ; Thu, 19 Sep 2019 12:34:17 +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.b="qpXaSI+1"; 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 46YgsP21TJzF35d for ; Thu, 19 Sep 2019 12:34:17 +1000 (AEST) 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 46Ygrp1n8pzF0jD for ; Thu, 19 Sep 2019 12:33:46 +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.b="qpXaSI+1"; 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 46Ygrn6zrBz9sPV; Thu, 19 Sep 2019 12:33:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860426; bh=joTteRGDWRcq5lqmBjSSAEeJMA7pBYt8xNiTiffk2xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpXaSI+1Q2qQaU36GVP06vZhE+dLBPmC4VVxyQ5JF5uPC/W2V1xCNZ2b7eqRqpb7I hpOEx2kKoy35n0q95846Q/UbmFZiMcsgNKA4iF6IwYj8jLVuLD1qXrpjmfGx7NB6Z1 4Zhpqz+X8F43dN/4BKFkNEp6Ur5dnAn7fZgo+IxhN6QrGtP2FlnktrVfbdRGriQR4+ V+Nb8EIIjynMzndlkbD1r05s9O05h6K5Qble4AzEuTDb2tY5KCCuJrUBOwT13pZW5u EjmormzzslyjBEkmCZ3EBennc4pZZOfuLKItsraH+g3gwPLvwg0892j4bCtOp8C2cX SA0Uh/1KBabpA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:18 +1000 Message-Id: <20190919023333.5295-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 08/23] libpdbg: Child traversal should not include virtual nodes 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" When traversing system device tree view (virtual = true), the children are calculated based on the system device tree view (using the virtual node attachments). When traversing backend device tree (virtual = false), the virtual nodes are ignored except if they are part of the backend device tree itself. Signed-off-by: Amitay Isaacs --- libpdbg/libpdbg.c | 52 +++++++++++++++++++++++++++++++++++++++++------ libpdbg/libpdbg.h | 6 +++--- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index aade5d3..b17853d 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -43,18 +43,58 @@ retry: } } -struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last) +static struct pdbg_target *pdbg_next_target_match(struct pdbg_target *next, bool virtual) { - if (!parent || list_empty(&parent->children)) + if (virtual) { + if (!next->vnode) + return next; + else + if (!next->compatible) + return next->vnode; + } else { + if (next->compatible) + return next; + } + + return NULL; +} + +struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last, bool virtual) +{ + struct pdbg_target *next, *child = NULL; + + if (!parent) return NULL; - if (!last) - return list_top(&parent->children, struct pdbg_target, list); + if (list_empty(&parent->children)) { + if (parent->vnode) + parent = parent->vnode; + else + return NULL; + } + + if (!last) { + list_for_each(&parent->children, child, list) + if ((next = pdbg_next_target_match(child, virtual))) + return next; + + return NULL; + } + + if (virtual && last->vnode && last->compatible) + last = last->vnode; - if (last->list.next == &parent->children.n) + if (last == list_tail(&parent->children, struct pdbg_target, list)) return NULL; - return list_entry(last->list.next, struct pdbg_target, list); + child = last; + do { + child = list_entry(child->list.next, struct pdbg_target, list); + if ((next = pdbg_next_target_match(child, virtual))) + return next; + } while (child != list_tail(&parent->children, struct pdbg_target, list)); + + return NULL; } enum pdbg_target_status pdbg_target_status(struct pdbg_target *target) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index caf8b85..df74e43 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -20,7 +20,7 @@ struct pdbg_target *__pdbg_next_compatible_node(struct pdbg_target *root, struct pdbg_target *prev, const char *compat); struct pdbg_target *__pdbg_next_target(const char *klass, struct pdbg_target *parent, struct pdbg_target *last); -struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last); +struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last, bool virtual); /* * Each target has a status associated with it. This is what each status means: @@ -71,9 +71,9 @@ enum pdbg_backend { PDBG_DEFAULT_BACKEND = 0, PDBG_BACKEND_FSI, PDBG_BACKEND_I2C target = __pdbg_next_target(class, NULL, target)) #define pdbg_for_each_child_target(parent, target) \ - for (target = __pdbg_next_child_target(parent, NULL); \ + for (target = __pdbg_next_child_target(parent, NULL, true); \ target; \ - target = __pdbg_next_child_target(parent, target)) + target = __pdbg_next_child_target(parent, target, true)) /* Return the first parent target of the given class, or NULL if the given * target does not have a parent of the given class. */ From patchwork Thu Sep 19 02:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164327 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygsm1B2hz9sNf for ; Thu, 19 Sep 2019 12:34:36 +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.b="MIA4jg7L"; 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 46Ygsl5XylzF3NP for ; Thu, 19 Sep 2019 12:34:35 +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 46Ygrp4Bt5zDsQB for ; Thu, 19 Sep 2019 12:33:46 +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.b="MIA4jg7L"; 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 46Ygrp1TNQz9sNF; Thu, 19 Sep 2019 12:33:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860426; bh=qgYTV/0SN/pU4BEytm0r/7KiVGN+Duj6BT1k/di15Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIA4jg7Lrr+hQfKuRaBxq/v5D/NZx/Hh5nlGZCo6pb1Fm9KDCgqW6bNMlgb9uqOx6 ldnNrTQ3FpWgejgO/DaXCU8fh4lwDOarZRmoZGv86kBsMNFSu2FClcHgM9ZLovmlwe YwYBgc+b+c8Ti2OCrmlngHPED+7tD6vfRSyXLxm/CZKsprYfdsPNyNxOrGe7tR4lRY 2sCPQ4axC4AU/7FdFQ6GI0J9CP9bSkufF8ApfhglI0X1GoMi+LEOHqXa4hQWShjZZY bK/voTVVj1kRLFPTa9K6ip4woZZFreIwqIme/rUCj9XmzxuJdFuP+FkMAWwmXCbrmG voYqO6Yjg7OuQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:19 +1000 Message-Id: <20190919023333.5295-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 09/23] libpdbg: Parent retrieval should skip over virtual nodes 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" Internally, parent of a device tree node should return the parent as per the backend device tree and not system device tree view. Signed-off-by: Amitay Isaacs --- libpdbg/libpdbg.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index b17853d..ae7a823 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -6,6 +6,20 @@ static pdbg_progress_tick_t progress_tick; +static struct pdbg_target *get_parent(struct pdbg_target *target) +{ + struct pdbg_target *parent; + + parent = target->parent; + if (!parent || !parent->vnode) + return parent; + + if (parent->compatible) + return parent; + + return parent->vnode; +} + struct pdbg_target *__pdbg_next_target(const char *class, struct pdbg_target *parent, struct pdbg_target *last) { struct pdbg_target *next, *tmp; @@ -33,7 +47,7 @@ retry: return next; else { /* Check if this target is a child of the given parent */ - for (tmp = next; tmp && next->parent && tmp != parent; tmp = tmp->parent) {} + for (tmp = next; tmp && get_parent(tmp) && tmp != parent; tmp = get_parent(tmp)) {} if (tmp == parent) return next; else { @@ -116,7 +130,7 @@ uint32_t pdbg_target_index(struct pdbg_target *target) { struct pdbg_target *dn; - for (dn = target; dn && dn->index == -1; dn = dn->parent); + for (dn = target; dn && dn->index == -1; dn = get_parent(dn)); if (!dn) return -1; @@ -130,9 +144,9 @@ struct pdbg_target *pdbg_target_parent(const char *class, struct pdbg_target *ta struct pdbg_target *parent; if (!class) - return target->parent; + return get_parent(target); - for (parent = target->parent; parent && parent->parent; parent = parent->parent) { + for (parent = get_parent(target); parent && get_parent(parent); parent = get_parent(parent)) { if (!strcmp(class, pdbg_target_class_name(parent))) return parent; } From patchwork Thu Sep 19 02:33:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164329 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygt06zn8z9sNf for ; Thu, 19 Sep 2019 12:34:48 +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.b="FpxXPGtx"; 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 46Ygt038spzF3lR for ; Thu, 19 Sep 2019 12:34:48 +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 46Ygrp5y80zDs09 for ; Thu, 19 Sep 2019 12:33:46 +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.b="FpxXPGtx"; 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 46Ygrp3spVz9s00; Thu, 19 Sep 2019 12:33:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860426; bh=vZa5sXJjk+XhowbgQV/fRzZWr/KNn1c9ftXAv1taR64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpxXPGtxS9NR2qKDPMY1EhuWIhFpx3TtLrv26paIJ4/FQRQO9RzZRkmrOzh0hOof/ DzPLz7s2X+dTcGzJPAKfE9rjr7zQupdTMCdTSLBVTwjWontjhtll/RTyqFQC/2kkb1 FXE94IPNj2o30iE24Z5Ue0PPpTVf6Ju0d90Vhtz7RNpBpORvvi+SDRZVOtXnQ6wQFP ta6eK49d2k/M+TlDhy8yPov6q5D3bjQKZlE1vfDBcvfeBQXApmR2Qx8ICKKzWUx6rV +Mb63wRfmedKQ0dpNZfJp98rDfB37iS8KFoTS+0dqIhr3t2qpamHM+gqsPg5CmJBBQ hVO0gwBEV7GNA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:20 +1000 Message-Id: <20190919023333.5295-11-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 10/23] libpdbg: Use pdbg api to get parent 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" This ensures that virtual nodes are handled correctly. Signed-off-by: Amitay Isaacs --- libpdbg/cfam.c | 2 +- libpdbg/target.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libpdbg/cfam.c b/libpdbg/cfam.c index 868ca76..470b167 100644 --- a/libpdbg/cfam.c +++ b/libpdbg/cfam.c @@ -313,7 +313,7 @@ static int cfam_hmfsi_write(struct fsi *fsi, uint32_t addr, uint32_t data) static int cfam_hmfsi_probe(struct pdbg_target *target) { struct fsi *fsi = target_to_fsi(target); - struct pdbg_target *fsi_parent = target->parent; + struct pdbg_target *fsi_parent = require_target_parent(target); uint32_t value, port; int rc; diff --git a/libpdbg/target.c b/libpdbg/target.c index 5808d02..d550be8 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -27,7 +27,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con *addr += pdbg_target_address(target, NULL); /* Keep walking the tree translating addresses */ - target = target->parent; + target = pdbg_target_parent(NULL, target); /* The root node doesn't have an address space so it's * an error in the device tree if we hit this. */ @@ -325,8 +325,11 @@ uint32_t sbe_ffdc_get(struct pdbg_target *target, const uint8_t **ffdc, uint32_t struct pdbg_target *require_target_parent(struct pdbg_target *target) { - assert(target->parent); - return target->parent; + struct pdbg_target *parent; + + parent = pdbg_target_parent(NULL, target); + assert(parent); + return parent; } /* Finds the given class. Returns NULL if not found. */ @@ -391,7 +394,7 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) * it's status won't have changed */ return status; - parent = target->parent; + parent = pdbg_target_parent(NULL, target); if (parent) { /* Recurse up the tree to probe and set parent target status */ pdbg_target_probe(parent); From patchwork Thu Sep 19 02:33:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164330 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 46Ygt450cTz9sNF for ; Thu, 19 Sep 2019 12:34:52 +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.b="gb3CtwKO"; 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 46Ygt443dszF3v5 for ; Thu, 19 Sep 2019 12:34:52 +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 46Ygrq0WyCzDsDy for ; Thu, 19 Sep 2019 12:33:47 +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.b="gb3CtwKO"; 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 46Ygrp5y9wz9sNf; Thu, 19 Sep 2019 12:33:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860426; bh=LWGkahpL9LbwEKmwHb8z5Vl/aWYuJf6wGUjjdjw/IJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gb3CtwKOv5c4Iber5tiBNxVtdDJro0RNrMc8V2UO/UFzkjmcrh3B8LcoKiLferqrn Nbc7XJlnpsB5oY6tWRbzVC7t/Bkaruh2JpEgOPaqLGe2Hw1gjtuP9/qjV/JSJBIJf7 0s7+NCi6FPXs+EsXhPOXfsH+pjhQJ6VH3iRUKfAOtjRdO97L61x3IcaMvu7TPLdwNd xykxtWsyspO1s4Ou6xSBFrjAwQxZ5yp/IKKw2HErZYG84u0jQ+Pg+GxsxTbujwbvPF JAV6GEmyFaIrSQLVcXxLU5xQn6lMEVkVb66o9wwEPJdfOeGbUxpFhh8kDQ68glKGQQ iZ0Nzxl9tFiyA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:21 +1000 Message-Id: <20190919023333.5295-12-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 11/23] libpdbg: Probe should traverse all nodes 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" This ensures a backend device tree traversal or a system device tree (view) traversal, always return consistent result. Signed-off-by: Amitay Isaacs --- libpdbg/target.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index d550be8..52b6f95 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -426,6 +426,11 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) } } + /* Make sure any virtual parents are also probed */ + if (target->compatible && target->vnode) { + pdbg_target_probe(target->vnode); + } + /* At this point any parents must exist and have already been probed */ if (target->probe && target->probe(target)) { /* Could not find the target */ @@ -460,12 +465,12 @@ void pdbg_target_release(struct pdbg_target *target) */ void pdbg_target_probe_all(struct pdbg_target *parent) { - struct pdbg_target *child; + struct pdbg_target *child = NULL; if (!parent) parent = pdbg_target_root(); - pdbg_for_each_child_target(parent, child) { + list_for_each(&parent->children, child, list) { pdbg_target_probe_all(child); pdbg_target_probe(child); } From patchwork Thu Sep 19 02:33:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164331 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygt75pM2z9sNF for ; Thu, 19 Sep 2019 12:34:55 +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.b="OCuqSqxr"; 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 46Ygt70vTmzF46N for ; Thu, 19 Sep 2019 12:34:55 +1000 (AEST) 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 46Ygrq211vzDsFV for ; Thu, 19 Sep 2019 12:33:47 +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.b="OCuqSqxr"; 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 46Ygrq0CVYz9sNF; Thu, 19 Sep 2019 12:33:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860427; bh=zdKTrVfiRQU9+bKLrd1NQ4H1x5mTqL8sXt0A9eKAyYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCuqSqxrs764soxN3rwkDgJA6PXTNwkmLIkqzLvgPvJ6YnXZFEyCZhfkSqpFqy2uP 2JVRNGLYK/EGNDcK9EJzbpLRKdnuRJl7XSHcbZEQTWwhZ+BKh+82Al18DU/qeR5WIl gsH1Py/0sRbvmbf9GtgbiN44sGK/8ey4SUEXNo4my+4eJPsvcW9sIfJRn1KvphVdaU a9WzLmaPsW3/8k78mD+PsoJfdRHfxNR3kL3bUeDFu9PLZrGbHZw3emYMe8xh1TykhC y/827UB1ybjAMpHFwAXro2cryVa3NxWN0CnT6nWFvPOwUsFPx8TdIixObWWSKQez6J IDyQk2auGZJkw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:22 +1000 Message-Id: <20190919023333.5295-13-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 12/23] main: Use dn_name for printing virtual nodes 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" Virtual nodes do not have a class name. When traversing system device tree view, virtual nodes need to be handled correctly. So instead of skipping the nodes if classname is not set, print dn name for virtual nodes. Signed-off-by: Amitay Isaacs --- src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 44d1c55..f7f891a 100644 --- a/src/main.c +++ b/src/main.c @@ -529,10 +529,10 @@ static void print_target(struct pdbg_target *target, int level) printf(" "); classname = pdbg_target_class_name(target); - if (!classname) - return; - - printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); + if (classname) + printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); + else + printf("%s:", pdbg_target_dn_name(target)); if (path_target_selected(target)) printf(" (*)"); printf("\n"); From patchwork Thu Sep 19 02:33:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164332 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YgtC5yx4z9s00 for ; Thu, 19 Sep 2019 12:34:59 +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.b="j3AW66Lz"; 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 46YgtB5pzxzF3wV for ; Thu, 19 Sep 2019 12:34:58 +1000 (AEST) 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 46Ygrq3jm3zDsQB for ; Thu, 19 Sep 2019 12:33:47 +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.b="j3AW66Lz"; 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 46Ygrq1jmBz9sNx; Thu, 19 Sep 2019 12:33:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860427; bh=0bIvbQgaHDfjJKawh6o+/FtmT5zKuIrzuCV4aj7aAuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j3AW66LztFVXp83cwkma9VHRyrrUFhIkIJLdlVD3GNPN/uo4Tl8BiW+m5+wWDYQn0 Jg6sH0tk094io7ehq+DMLryyvLLgYbpjCm3cCjMZvcB3u00pYQtdBKbe9d8OQShkRB 2DXdA5Ag663EKdPOyR0ussxnfowezSgHvCBTrvI3PWhYHm0s7foDzw34Zv/PeWvycp hvQsEwJNpOGKI8RQf+Umaf7t035/fqagJRrlurXoOB+NBu9773d4YNXkOutPmNZFff 09SAz0d8jbIxkAKo2p3BuQhNDFgjjL7ThJC93yRt2Lj2Zul5i+OEE4FEZ3EsTQWxmV ++8gUp4k8cvoA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:23 +1000 Message-Id: <20190919023333.5295-14-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 13/23] fake: Add virtual nodes for pib targets 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 --- fake.dts.m4 | 53 +++++----- src/tests/libpdbg_target_test.c | 10 +- tests/test_selection.sh | 98 +++++++++++++++--- tests/test_selection2.sh | 178 +++++++++++++++++++++++++++++--- 4 files changed, 279 insertions(+), 60 deletions(-) diff --git a/fake.dts.m4 b/fake.dts.m4 index 92697df..1687562 100644 --- a/fake.dts.m4 +++ b/fake.dts.m4 @@ -1,3 +1,5 @@ +define(`CONCAT', `$1$2')dnl + dnl dnl forloop([var], [start], [end], [iterator]) dnl @@ -50,18 +52,30 @@ dnl dnl dump_processor_pre([index], [addr]) dnl define(`dump_processor_pre', -` - pib@$2 { +`define(`pib_addr', eval(`$2+100'))dnl + fsi@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-fsi"; + device-tree-path = "/proc$1/fsi"; + reg = <0x0 0x0>; + index = <0x$1>; + + CONCAT(pib@,pib_addr) { #address-cells = <0x1>; #size-cells = <0x1>; compatible = "ibm,fake-pib"; - reg = <0x$2 0x0>; + device-tree-path = "/proc$1/pib"; + reg = ; index = <0x$1>;') dnl dnl dump_processor_post() dnl -define(`dump_processor_post', ` }; +define(`dump_processor_post', ` }; + + }; + ')dnl dnl @@ -73,29 +87,16 @@ forloop(`i', `0', eval(`$3-1'), `dump_core(i, eval(10000+(i+1)*10), $4)') dump_processor_post()') dnl -dnl dump_fsi_pre([index], [addr]) +dnl dump_system([num_processors], [num_cores], [num_threads]) dnl -define(`dump_fsi_pre', +define(`dump_system', +`forloop(`i', `0', eval(`$1-1'),dnl ` - fsi@$2 { - #address-cells = <0x1>; - #size-cells = <0x1>; - compatible = "ibm,fake-fsi"; - reg = <0x$2 0x0>; - index = <0x$1>;') - -dnl -dnl dump_fsi_post() -dnl -define(`dump_fsi_post', ` };') - -dnl -dnl dump_fsi([index], [addr], [num_processors], [num_cores], [num_threads]) -dnl -define(`dump_fsi', -`dump_fsi_pre(`$1', `$2') -forloop(`i', `0', eval(`$3-1'), `dump_processor(i, eval(10000+i*1000), $4, $5)') -dump_fsi_post()') + CONCAT(proc,i) { + index = < CONCAT(0x,i) >; + }; +') +forloop(`i', `0', eval(`$1-1'), `dump_processor(i, eval(20000+i*1000), $2, $3)')') divert`'dnl /dts-v1/; @@ -103,5 +104,5 @@ divert`'dnl / { #address-cells = <0x1>; #size-cells = <0x1>; -dump_fsi(0, 0, 8, 4, 2) +dump_system(8, 4, 2) }; diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index eeeeabf..b5f7fdd 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -72,7 +72,7 @@ int main(void) assert(root); count = count_class_target("fsi"); - assert(count == 1); + assert(count == 8); count = count_class_target("pib"); assert(count == 8); @@ -97,19 +97,19 @@ int main(void) assert(parent == NULL); count = count_child_target(target); - assert(count == 8); + assert(count == 0); count = count_target(target, "fsi"); assert(count == 1); count = count_target(target, "pib"); - assert(count == 8); + assert(count == 1); count = count_target(target, "core"); - assert(count == 32); + assert(count == 4); count = count_target(target, "thread"); - assert(count == 64); + assert(count == 8); name = pdbg_target_name(target); assert(!strcmp(name, "Fake FSI")); diff --git a/tests/test_selection.sh b/tests/test_selection.sh index 50db9e4..0931051 100755 --- a/tests/test_selection.sh +++ b/tests/test_selection.sh @@ -23,7 +23,8 @@ test_run pdbg -b fake probe test_result 0 < X-Patchwork-Id: 1164333 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YgtJ4xTtz9s00 for ; Thu, 19 Sep 2019 12:35:04 +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.b="ogdxQrIQ"; 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 46YgtJ41BgzF3vK for ; Thu, 19 Sep 2019 12:35:04 +1000 (AEST) 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 46Ygrq5gqZzDsFV for ; Thu, 19 Sep 2019 12:33:47 +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.b="ogdxQrIQ"; 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 46Ygrq3Mr4z9s00; Thu, 19 Sep 2019 12:33:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860427; bh=kgHubQhmOXynO1xU2flIeGhqNaaW53X2MDtUl4aHudQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ogdxQrIQEm52XeEsrkqv9JXlQ5AOqaVAQrC8CpI6z+RESFvsq8ImZBqH67kUFDduU hNppXRlO7ZCAGC/mlRP03ZRtF4SVkkT7ngLNjrL1fw/1akVbu/Ch9sz50ReULgs5ta yhSu3BPLhtqk4K09xdF8LUYstVNrOTu9wQXE90SFKX3IV4YR59iVh7o53p8A4mVB5K 6gS6HB4LpaEljGBvdgoJ/WklVrIHsCgWM97NPJqmWEjp8Sl/IpgWsK8mqOO3blZolp rm+DeFgCzwYQAYC/SoCWiDZMpqGqXGmxqcQBtKWfAAgTc7cDueCtjofOWivFgGENGG 2+7SwfVHWooBg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:24 +1000 Message-Id: <20190919023333.5295-15-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 14/23] tests: Add device tree traversal tests 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" This test checks system device tree (view) traverse and backend device tree traverse. Signed-off-by: Amitay Isaacs --- Makefile.am | 11 +- src/tests/libpdbg_dtree_test.c | 85 ++++++++++ tests/test_tree.sh | 278 +++++++++++++++++++++++++++++++++ 3 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 src/tests/libpdbg_dtree_test.c create mode 100755 tests/test_tree.sh diff --git a/Makefile.am b/Makefile.am index cec8799..accc0a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,13 +15,15 @@ libpdbg_tests = libpdbg_target_test \ libpdbg_probe_test3 bin_PROGRAMS = pdbg -check_PROGRAMS = $(libpdbg_tests) optcmd_test hexdump_test cronus_proxy +check_PROGRAMS = $(libpdbg_tests) libpdbg_dtree_test \ + optcmd_test hexdump_test cronus_proxy PDBG_TESTS = \ tests/test_selection.sh \ tests/test_selection2.sh \ tests/test_hw_bmc.sh \ - tests/test_hexdump.sh + tests/test_hexdump.sh \ + tests/test_tree.sh TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS) @@ -229,6 +231,11 @@ libpdbg_probe_test3_LDADD = $(libpdbg_test_ldadd) src/tests/libpdbg_probe_test.c: fake.dt.h +libpdbg_dtree_test_SOURCES = src/tests/libpdbg_dtree_test.c +libpdbg_dtree_test_CFLAGS = $(libpdbg_test_cflags) +libpdbg_dtree_test_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_dtree_test_LDADD = $(libpdbg_test_ldadd) + M4_V = $(M4_V_$(V)) M4_V_ = $(M4_V_$(AM_DEFAULT_VERBOSITY)) M4_V_0 = @echo " M4 " $@; diff --git a/src/tests/libpdbg_dtree_test.c b/src/tests/libpdbg_dtree_test.c new file mode 100644 index 0000000..434728a --- /dev/null +++ b/src/tests/libpdbg_dtree_test.c @@ -0,0 +1,85 @@ +/* Copyright 2019 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include + +#define for_each_child(parent, target, virtual) \ + for (target = __pdbg_next_child_target(parent, NULL, virtual); \ + target; \ + target = __pdbg_next_child_target(parent, target, virtual)) + +static void print_target(struct pdbg_target *target, bool virtual, int level) +{ + struct pdbg_target *child; + const char *name; + char *path; + int i; + + for (i=0; i\n"); + exit(1); +} + +int main(int argc, const char **argv) +{ + pdbg_targets_init(NULL); + + if (argc < 2) + usage(); + + if (strcmp(argv[1], "tree") == 0) { + struct pdbg_target *root; + + root = pdbg_target_root(); + print_target(root, true, 0); + } else if (strcmp(argv[1], "rtree") == 0) { + struct pdbg_target *root; + + root = pdbg_target_root(); + print_target(root, false, 0); + } else { + struct pdbg_target *target; + char *path; + + pdbg_for_each_class_target(argv[1], target) { + path = pdbg_target_path(target); + printf("%s%d: %s\n", argv[1], pdbg_target_index(target), path); + free(path); + } + } + + return 0; +} diff --git a/tests/test_tree.sh b/tests/test_tree.sh new file mode 100755 index 0000000..9ce0ce5 --- /dev/null +++ b/tests/test_tree.sh @@ -0,0 +1,278 @@ +#!/bin/sh + +. $(dirname "$0")/driver.sh + +test_group "tree tests" + +test_result 0 < X-Patchwork-Id: 1164334 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YgtN3SLzz9sPG for ; Thu, 19 Sep 2019 12:35:08 +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.b="hmPU2O1d"; 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 46YgtM24x9zF4F6 for ; Thu, 19 Sep 2019 12:35:07 +1000 (AEST) 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 46Ygrq74LMzF0Pv for ; Thu, 19 Sep 2019 12:33:47 +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.b="hmPU2O1d"; 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 46Ygrq5LSTz9sNF; Thu, 19 Sep 2019 12:33:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860427; bh=KdAHFX7T2eM9chy4p+e1KhDc+1pQ64ARj1ezsoTVcAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmPU2O1dpDGeTw/hzfXgLTEUnm2omPTRXWpx8b/H4rCm93IDueH2j/lshVLfKmzwd 9lCd7WFKrdyReHvvpdFxSs9+1cUao4HqDBB4cZ0+3z8+5swAd6JVT5XV8Zp4Rq6mFk KtmPwolwBBOCQf0Kf4zFNpWPlJn6NW/uhTFVf1pkw0Atu8MG9GkiH46qOpMe93Bzat mREmfUR+8Bd6Dtv5zluPuaDELlw78Kv4K2Rh76kbzkYyQV+nI42o30CKE6d2at7+vz 6BW5FWYdjpn/bldllZsxBV+DyB3lokpv+zV2Ra2DUCEFD5kHI8off61rL4CsVqdJY+ tWOmoeysEcAvA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:25 +1000 Message-Id: <20190919023333.5295-16-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 15/23] libpdbg: Pass root node to dt_expand 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" This will enable parsing more than one device tree. Signed-off-by: Amitay Isaacs --- libpdbg/device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 4160ea8..b499171 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -602,7 +602,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod return nextoffset; } -static void dt_expand(void *root, const void *fdt) +static void dt_expand(struct pdbg_target *root, const void *fdt) { PR_DEBUG("FDT: Parsing fdt @%p\n", fdt); @@ -720,9 +720,6 @@ skip: void pdbg_targets_init(void *fdt) { - /* Root node needs to be valid when this function returns */ - pdbg_dt_root = dt_new_node("", NULL, 0); - if (!fdt) fdt = pdbg_default_dtb(); @@ -731,7 +728,12 @@ void pdbg_targets_init(void *fdt) return; } + /* Root node needs to be valid when this function returns */ + pdbg_dt_root = dt_new_node("", NULL, 0); + assert(pdbg_dt_root); + dt_expand(pdbg_dt_root, fdt); + pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); } From patchwork Thu Sep 19 02:33:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164335 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 46YgtR5jLjz9sNf for ; Thu, 19 Sep 2019 12:35:11 +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.b="gAZBG02U"; 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 46YgtR3N0qzF3qf for ; Thu, 19 Sep 2019 12:35:11 +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 46Ygrr22RRzDsFV for ; Thu, 19 Sep 2019 12:33:48 +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.b="gAZBG02U"; 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 46Ygrq6mD2z9sNf; Thu, 19 Sep 2019 12:33:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860427; bh=EktAR4to1JQLPVlCq3MPv3MDbW97UHlkv7oXPxXLZ3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gAZBG02UFoOKbzF8iM72nT8V+tluk7C4Obr0EKlpI0g7dd9wF9dHR0wvjImZwc31x NTddbSrcyeJoEmqBHm0GiQwbS86dBHdzKwKso6b5qkIwhA/TU/aVsBA8hS6RZ2RAZw eDivwXAJhk5DsohsfXMPJl+7Q9bwWpxbbsFGEMf6AmtVGA+j83rCCUfVV/AI5spVxH 9Vf3Jt4S87VGigqcOogAzCuqfekpBIlh5WHAnnwQzqKjYj3XyzT3bB90ZZwyY/tVR8 1YE7XmGuLq/sqU7Ez1mHQLYMi2umZ1DvfdQeoomNO8ek3djcu/hRCQma/R8BE3uAJ5 oINBfhHqIq73w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:26 +1000 Message-Id: <20190919023333.5295-17-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 16/23] libpdbg: Drop argument from pdbg_targets_init() 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" Now that all device tree detection is built in libpdbg, there is no need to pass device tree blob to pdbg_targets_init(). Also, make it return status to indicate success or failure. Signed-off-by: Amitay Isaacs --- libpdbg/device.c | 12 +++++++----- libpdbg/libpdbg.h | 2 +- src/main.c | 3 ++- src/tests/libpdbg_dtree_test.c | 2 +- src/tests/libpdbg_probe_test.c | 6 +++--- src/tests/libpdbg_target_test.c | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index b499171..00bcf10 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -718,23 +718,25 @@ skip: } } -void pdbg_targets_init(void *fdt) +bool pdbg_targets_init(void) { - if (!fdt) - fdt = pdbg_default_dtb(); + void *fdt; + fdt = pdbg_default_dtb(); if (!fdt) { pdbg_log(PDBG_ERROR, "Could not find a system device tree\n"); - return; + return false; } /* Root node needs to be valid when this function returns */ pdbg_dt_root = dt_new_node("", NULL, 0); - assert(pdbg_dt_root); + if (!pdbg_dt_root) + return false; dt_expand(pdbg_dt_root, fdt); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); + return true; } char *pdbg_target_path(struct pdbg_target *target) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index df74e43..7603b96 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -101,7 +101,7 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *size); (index == 0 ? pdbg_target_address(target, size) : assert(0)) /* Misc. */ -void pdbg_targets_init(void *fdt); +bool pdbg_targets_init(void); void pdbg_target_probe_all(struct pdbg_target *parent); enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target); void pdbg_target_release(struct pdbg_target *target); diff --git a/src/main.c b/src/main.c index f7f891a..2ef61a3 100644 --- a/src/main.c +++ b/src/main.c @@ -580,7 +580,8 @@ int main(int argc, char *argv[]) if (backend) pdbg_set_backend(backend, device_node); - pdbg_targets_init(NULL); + if (!pdbg_targets_init()) + return 1; if (pathsel_count) { if (!path_target_parse(pathsel, pathsel_count)) diff --git a/src/tests/libpdbg_dtree_test.c b/src/tests/libpdbg_dtree_test.c index 434728a..4f1ff08 100644 --- a/src/tests/libpdbg_dtree_test.c +++ b/src/tests/libpdbg_dtree_test.c @@ -55,7 +55,7 @@ static void usage(void) int main(int argc, const char **argv) { - pdbg_targets_init(NULL); + assert(pdbg_targets_init()); if (argc < 2) usage(); diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c index 8b78b2e..02f91d1 100644 --- a/src/tests/libpdbg_probe_test.c +++ b/src/tests/libpdbg_probe_test.c @@ -74,7 +74,7 @@ static void test1(void) struct pdbg_target *root, *target; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init()); root = pdbg_target_root(); assert(root); @@ -122,7 +122,7 @@ static void test2(void) enum pdbg_target_status status; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init()); root = pdbg_target_root(); assert(root); @@ -186,7 +186,7 @@ static void test3(void) enum pdbg_target_status status; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init()); root = pdbg_target_root(); assert(root); diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index b5f7fdd..0af3ebb 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -66,7 +66,7 @@ int main(void) int count; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init()); root = pdbg_target_root(); assert(root); From patchwork Thu Sep 19 02:33:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164336 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 46YgtX18Skz9sNF for ; Thu, 19 Sep 2019 12:35:16 +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.b="FloL1652"; 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 46YgtW6smXzF46N for ; Thu, 19 Sep 2019 12:35:15 +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 46Ygrr43JdzF0RM for ; Thu, 19 Sep 2019 12:33:48 +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.b="FloL1652"; 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 46Ygrr1jlcz9s00; Thu, 19 Sep 2019 12:33:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860428; bh=u0K2YiUKgDM687p17BvhVTmElIafHpc09Fl7K4tiKt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FloL1652l0Bv5AtQxu+Uq57t3ZR/mevcLTJtb3niyLO+gMwN0Nx6OJm1enoOSmXPU MKahW2yETVyls4uUe76kYX9nyt9j6dR6009E+o5pwX1laih4uWXuz5w5yKJhLc0ljC nzbi1gjtrfdxSNywanRyRdGPMtvdnFoHLhEsqWbNRwmjOq5XpCee+AEAbnwAR+wy2e q8hweJj5fk7bJQFSqlhzXzuvxuSkK3aHDxP8Th1Uar0Gu+v+IzjdXr1BSRTGzYBa9x la5N7mCLZhkRU3XK1ZxLUTTs92HgkVIDZ1dD0JcejoCgBapOSWNwQ7HDzTDsH4A9kE VJHqPI4EmX9mw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:27 +1000 Message-Id: <20190919023333.5295-18-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 17/23] libpdbg: Make pdbg_set_backend() return boolean 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" Simplify api by using boolean status instead of int. Signed-off-by: Amitay Isaacs --- libpdbg/dtb.c | 9 +++++++-- libpdbg/libpdbg.h | 2 +- src/main.c | 3 ++- src/tests/libpdbg_probe_test.c | 6 +++--- src/tests/libpdbg_target_test.c | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 6c4beed..92a4efb 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -205,12 +205,17 @@ fail: return NULL; } -int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option) +bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option) { + if (pdbg_target_root()) { + pdbg_log(PDBG_ERROR, "pdbg_set_backend() must be called before pdbg_targets_init()\n"); + return false; + } + pdbg_backend = backend; pdbg_backend_option = backend_option; - return 0; + return true; } const char *pdbg_get_backend_option(void) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 7603b96..c719997 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -107,7 +107,7 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target); void pdbg_target_release(struct pdbg_target *target); enum pdbg_target_status pdbg_target_status(struct pdbg_target *target); void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status); -int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); +bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(struct pdbg_target *target); diff --git a/src/main.c b/src/main.c index 2ef61a3..ce0ae06 100644 --- a/src/main.c +++ b/src/main.c @@ -578,7 +578,8 @@ int main(int argc, char *argv[]) } if (backend) - pdbg_set_backend(backend, device_node); + if (!pdbg_set_backend(backend, device_node)) + return 1; if (!pdbg_targets_init()) return 1; diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c index 02f91d1..049aa4c 100644 --- a/src/tests/libpdbg_probe_test.c +++ b/src/tests/libpdbg_probe_test.c @@ -73,7 +73,7 @@ static void test1(void) { struct pdbg_target *root, *target; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init()); root = pdbg_target_root(); @@ -121,7 +121,7 @@ static void test2(void) struct pdbg_target *root, *target; enum pdbg_target_status status; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init()); root = pdbg_target_root(); @@ -185,7 +185,7 @@ static void test3(void) struct pdbg_target *root, *target; enum pdbg_target_status status; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init()); root = pdbg_target_root(); diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index 0af3ebb..e17a421 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -65,7 +65,7 @@ int main(void) const char *name; int count; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init()); root = pdbg_target_root(); From patchwork Thu Sep 19 02:33:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164337 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 46Ygtd1KMmz9sNf for ; Thu, 19 Sep 2019 12:35:21 +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.b="nea1GBbI"; 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 46Ygtc6jwWzF3qf for ; Thu, 19 Sep 2019 12:35:20 +1000 (AEST) 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 46Ygrs01g8zF0jD for ; Thu, 19 Sep 2019 12:33: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.b="nea1GBbI"; 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 46Ygrr3m7qz9sNx; Thu, 19 Sep 2019 12:33:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860428; bh=GxWMLwZLVr1Eb+QXzjz/HWixPZJrUGC3At1l1A9BQ3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nea1GBbI8qZHfbE5QJMUQL1dnk+d6/Fm/Q3jgIw3NnlZcQtsM0nfDvq7TinU33Bck OpnVzrIC0EROKyqfguiDDVxcxOp9yAAg+Vg6IcdOLQAN2qes+yKcsqrQ+XHxX1KKfP BiW015fDK6NxeOIs1oroIpcF0z7GxSe6an3jvbfOEoCvZ2cBsfm2bR418luyAIrcjY sQyHJGOSHaZ9Emao8VIwUQGRnxWXiblvArCP9/UsLtsyn2abr1hZ1+zZSIBD+GscL0 XNkDpY94ZhIl2UC417DKNV9zA6GZP/H8f/2GL04oZGJvVhlWHzzdcixptf0QgVu6mQ apTW9ekRt6Jog== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:28 +1000 Message-Id: <20190919023333.5295-19-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 18/23] libpdbg: Do not make pdbg_default_dtb public 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" Applications should never need to know the default fdt to be used. For some reason applications need to get access to the fdt blob, we can add appropriate public api. Signed-off-by: Amitay Isaacs --- libpdbg/dtb.c | 1 + libpdbg/libpdbg.h | 1 - libpdbg/target.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 92a4efb..ec2b672 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -27,6 +27,7 @@ #include #include "libpdbg.h" +#include "target.h" #include "fake.dt.h" diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index c719997..4f8e6f1 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -108,7 +108,6 @@ void pdbg_target_release(struct pdbg_target *target); enum pdbg_target_status pdbg_target_status(struct pdbg_target *target); void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status); bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); -void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); diff --git a/libpdbg/target.h b/libpdbg/target.h index 7e08ac3..78f2f49 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -62,6 +62,7 @@ bool pdbg_target_is_class(struct pdbg_target *target, const char *class); extern struct list_head empty_list; extern struct list_head target_classes; +void *pdbg_default_dtb(void); const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); From patchwork Thu Sep 19 02:33:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164338 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 46Ygth2Sckz9sNf for ; Thu, 19 Sep 2019 12:35:24 +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.b="e+CaGeI0"; 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 46Ygth0QrmzF4By for ; Thu, 19 Sep 2019 12:35:24 +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 46Ygrs2dZhzDsFV for ; Thu, 19 Sep 2019 12:33: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.b="e+CaGeI0"; 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 46Ygrr6n4Pz9sNf; Thu, 19 Sep 2019 12:33:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860429; bh=jX2WYIsEdi+J9VBPvMTHFdzi07nHw/tPwKn9hqKbPd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+CaGeI0Di/eyDy06X8MJK5ciyAc1nzoEa8wtKTqWz2sUxx44SXFMAKnTsAP1DCWe Zi8OB3ovTIib14qbJ13WNx0Zfui9sI/cJsWkI3IyA8BgZ2xruYr7yIvdVj75HFjRn6 huxmzSlKh/l2vjmR5ER2jAQlFa0v014NLgUgaSXQrwtOdTRLmMIXEPrzXz0OCMsLTp +ijGBPOhm8b8qQvkRzuKrIvmJr9wah3Xx6YSZN3Pl22a7kzYiQDw8/cwgmwj3uIHXc 7qLolrIY5zkqfWSVlaiKuK2zIWX18bp5ToasFACGaYk1Cz+l+iA5d74P6rTWgOpZGZ GrAcPHchtKNoQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:29 +1000 Message-Id: <20190919023333.5295-20-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 19/23] libpdbg: Add a structure to hold fdt pointer 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" This enables adding a separate backend device tree later. Signed-off-by: Amitay Isaacs --- libpdbg/device.c | 8 +++--- libpdbg/dtb.c | 75 ++++++++++++++++++++++++++---------------------- libpdbg/target.h | 6 +++- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 00bcf10..becd478 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -720,10 +720,10 @@ skip: bool pdbg_targets_init(void) { - void *fdt; + struct pdbg_dtb dtb; - fdt = pdbg_default_dtb(); - if (!fdt) { + pdbg_default_dtb(&dtb); + if (!dtb.system) { pdbg_log(PDBG_ERROR, "Could not find a system device tree\n"); return false; } @@ -733,7 +733,7 @@ bool pdbg_targets_init(void) if (!pdbg_dt_root) return false; - dt_expand(pdbg_dt_root, fdt); + dt_expand(pdbg_dt_root, dtb.system); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); return true; diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index ec2b672..e793cf2 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -78,20 +78,23 @@ static enum pdbg_backend default_backend(void) /* Try and determine what system type we are on by reading * /proc/cpuinfo */ -static void *ppc_target(void) +static void ppc_target(struct pdbg_dtb *dtb) { const char *pos = NULL; char line[256]; FILE *cpuinfo; - if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_host_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9")) - return &_binary_p9_host_dtb_o_start; + if (!strcmp(pdbg_backend_option, "p8")) { + dtb->system = &_binary_p8_host_dtb_o_start; + return; + } else if (!strcmp(pdbg_backend_option, "p9")) { + dtb->system = &_binary_p9_host_dtb_o_start; + return; + } cpuinfo = fopen("/proc/cpuinfo", "r"); if (!cpuinfo) - return NULL; + return; while ((pos = fgets(line, sizeof(line), cpuinfo))) if (strncmp(line, "cpu", 3) == 0) @@ -101,32 +104,31 @@ static void *ppc_target(void) if (!pos) { /* Got to EOF without a break */ pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n"); - return NULL; + return; } pos = strchr(line, ':'); if (!pos || (*(pos + 1) == '\0')) { pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n"); - return NULL; + return; } pos += 2; if (strncmp(pos, "POWER8", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n"); - return &_binary_p8_host_dtb_o_start; + dtb->system = &_binary_p8_host_dtb_o_start; } if (strncmp(pos, "POWER9", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n"); - return &_binary_p9_host_dtb_o_start; + dtb->system = &_binary_p9_host_dtb_o_start; } pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); - return NULL; } -static void *bmc_target(void) +static void bmc_target(struct pdbg_dtb *dtb) { FILE *cfam_id_file; uint32_t cfam_id = 0; @@ -138,7 +140,7 @@ static void *bmc_target(void) cfam_id_file = fopen(FSI_CFAM_ID, "r"); if (!cfam_id_file) { pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); - return NULL; + return; } rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); @@ -160,18 +162,17 @@ static void *bmc_target(void) switch(chip_id) { case CHIP_ID_P9: pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n"); - return &_binary_p9_kernel_dtb_o_start; + dtb->system = &_binary_p9_kernel_dtb_o_start; break; case CHIP_ID_P8: case CHIP_ID_P8P: pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n"); - return &_binary_p8_kernel_dtb_o_start; + dtb->system = &_binary_p8_kernel_dtb_o_start; break; default: pdbg_log(PDBG_ERROR, "Unrecognised Chip ID register 0x%08" PRIx32 "\n", chip_id); - return NULL; } } @@ -226,50 +227,56 @@ const char *pdbg_get_backend_option(void) /* Determines what platform we are running on and returns a pointer to * the fdt that is most likely to work on the system. */ -void *pdbg_default_dtb(void) +void pdbg_default_dtb(struct pdbg_dtb *dtb) { - char *dtb = getenv("PDBG_DTB"); + char *fdt = getenv("PDBG_DTB"); - if (dtb) - return mmap_dtb(dtb); + *dtb = (struct pdbg_dtb) { + .system = NULL, + }; + + if (fdt) { + dtb->system = mmap_dtb(fdt); + return; + } if (!pdbg_backend) pdbg_backend = default_backend(); switch(pdbg_backend) { case PDBG_BACKEND_HOST: - return ppc_target(); + ppc_target(dtb); break; case PDBG_BACKEND_I2C: /* I2C is only supported on POWER8 */ pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); - return &_binary_p8_i2c_dtb_o_start; + dtb->system = &_binary_p8_i2c_dtb_o_start; break; case PDBG_BACKEND_KERNEL: - return bmc_target(); + bmc_target(dtb); break; case PDBG_BACKEND_FSI: if (!pdbg_backend_option) { pdbg_log(PDBG_ERROR, "No device type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return NULL; + return; } if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_fsi_dtb_o_start; + dtb->system = &_binary_p8_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9w")) - return &_binary_p9w_fsi_dtb_o_start; + dtb->system = &_binary_p9w_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9r")) - return &_binary_p9r_fsi_dtb_o_start; + dtb->system = &_binary_p9r_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9z")) - return &_binary_p9z_fsi_dtb_o_start; + dtb->system = &_binary_p9z_fsi_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return NULL; + return; } break; @@ -278,17 +285,17 @@ void *pdbg_default_dtb(void) if (!pdbg_backend_option) { pdbg_log(PDBG_ERROR, "No device type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return NULL; + return; } if (!strncmp(pdbg_backend_option, "p8", 2)) - return &_binary_p8_cronus_dtb_o_start; + dtb->system = &_binary_p8_cronus_dtb_o_start; else if (!strncmp(pdbg_backend_option, "p9", 2)) - return &_binary_p9_cronus_dtb_o_start; + dtb->system = &_binary_p9_cronus_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return NULL; + return; } break; @@ -298,7 +305,7 @@ void *pdbg_default_dtb(void) /* Fall through */ case PDBG_BACKEND_FAKE: - return &_binary_fake_dtb_o_start; + dtb->system = &_binary_fake_dtb_o_start; break; } } diff --git a/libpdbg/target.h b/libpdbg/target.h index 78f2f49..1dfd5b3 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -53,6 +53,10 @@ struct pdbg_target { struct pdbg_target *vnode; }; +struct pdbg_dtb { + void *system; +}; + struct pdbg_target *require_target_parent(struct pdbg_target *target); struct pdbg_target_class *find_target_class(const char *name); struct pdbg_target_class *require_target_class(const char *name); @@ -62,7 +66,7 @@ bool pdbg_target_is_class(struct pdbg_target *target, const char *class); extern struct list_head empty_list; extern struct list_head target_classes; -void *pdbg_default_dtb(void); +void pdbg_default_dtb(struct pdbg_dtb *pdtb); const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); From patchwork Thu Sep 19 02:33:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164339 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygtl1g41z9sNF for ; Thu, 19 Sep 2019 12:35:27 +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.b="VF4mMXRk"; 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 46Ygtl0XkVzF4Bd for ; Thu, 19 Sep 2019 12:35:27 +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 46Ygrs4XWZzF0RM for ; Thu, 19 Sep 2019 12:33: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.b="VF4mMXRk"; 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 46Ygrs2Jc0z9sNF; Thu, 19 Sep 2019 12:33:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860429; bh=N6pttgwCRUOGfM0hO2zL0YVk7Hbwx48L/hh5vfC9qhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VF4mMXRkHD1Gx9nM2PgW6K/XmOVKaec5kzcfwQOkI9AqSShNQ2RXR6ggVFDvA3Z3X lZHDDQsXIFExujH5RDLRCelA/7lI2i/nsV1Vhwi/bcDxC/xPfbYTpNAugZttUgB3dt eFBgazSmc1HBHTxhDHS5jbzCUXXueDeHlYqwq76UcTa9MwESP+ltGitZuvTP/Y8FEm 4WbQNnjTbNLQPDwDL1/0DI5aCPpLJVMx6Yh7RkEeaL3iqgpIN/BP04n9XVRO/XwaoR i49NcDATiwNA7eeSrQiFQ612Po5B8K/ck3/hE5DRpjQrZyd5D+w1r54fajagBjeCtm dkbKIAeRR0+Ow== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:30 +1000 Message-Id: <20190919023333.5295-21-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 20/23] libpdbg: Add parsing of backend device tree 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 --- libpdbg/device.c | 3 +++ libpdbg/dtb.c | 1 + libpdbg/target.h | 1 + 3 files changed, 5 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index becd478..2e42c4e 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -733,6 +733,9 @@ bool pdbg_targets_init(void) if (!pdbg_dt_root) return false; + if (dtb.backend) + dt_expand(pdbg_dt_root, dtb.backend); + dt_expand(pdbg_dt_root, dtb.system); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index e793cf2..f548816 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -232,6 +232,7 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) char *fdt = getenv("PDBG_DTB"); *dtb = (struct pdbg_dtb) { + .backend = NULL, .system = NULL, }; diff --git a/libpdbg/target.h b/libpdbg/target.h index 1dfd5b3..2678c52 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -54,6 +54,7 @@ struct pdbg_target { }; struct pdbg_dtb { + void *backend; void *system; }; From patchwork Thu Sep 19 02:33:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164340 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Ygtp3qXRz9s00 for ; Thu, 19 Sep 2019 12:35:30 +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.b="a1tfTga3"; 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 46Ygtn5pT4zF4Bh for ; Thu, 19 Sep 2019 12:35:29 +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 46Ygrs67LVzDsFV for ; Thu, 19 Sep 2019 12:33: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.b="a1tfTga3"; 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 46Ygrs4DBvz9s00; Thu, 19 Sep 2019 12:33:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860429; bh=0iNj33Aw9YJ0HciU/X/aXFpfsUieN8k+lCzu53JvEHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1tfTga3Cb9gLJeqsdzUDELqL46OCsFbVhK0G+trBnU8edLBDOOwvHBmyXsfWfNEz JRxjrQCrJmajyX0Osl68Zzhui1i+SJCyR9ZUf8q5yq38igaUKOZ59ezwdzj9wxYMJS Io+O2PudN8uiomzC3fO3LTJSmjBEZu2BySJPhCGROZlJu2C1jLLAHO8DoY0b5gG72U J75EzIeJn/8G9t/ZGTwbhwYqqbdQxzAas+fuTq4/gAPOq2yR9gl3IkMrax1JgtDyvY rkC5GIXdUn7rtqZP9fQDrI/iKIpjULb5ZGpLoUaU2TGrPkwXmBUMJz/rNWqzg0NtaI OfPj+nlJgvZHg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:31 +1000 Message-Id: <20190919023333.5295-22-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 21/23] dts: Split P8 device trees into system and backend trees 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 --- Makefile.am | 2 +- p8-cronus.dts.m4 | 64 +++++++++++++++++------------------------------- p8-fsi.dts.m4 | 9 ++++--- p8-host.dts.m4 | 2 +- p8-i2c.dts.m4 | 8 +++--- p8-kernel.dts.m4 | 7 +++--- p8-pib.dts.m4 | 1 + p8.dts.m4 | 55 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 52 deletions(-) create mode 100644 p8.dts.m4 diff --git a/Makefile.am b/Makefile.am index accc0a4..95e69b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,7 +68,7 @@ endif DT = fake.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ - p8-host.dts p9-host.dts + p8-host.dts p9-host.dts p8.dts DT_sources = $(DT:.dts=.dtb.S) DT_headers = $(DT:.dts=.dt.h) diff --git a/p8-cronus.dts.m4 b/p8-cronus.dts.m4 index 4b62b9a..179f581 100644 --- a/p8-cronus.dts.m4 +++ b/p8-cronus.dts.m4 @@ -1,45 +1,27 @@ /dts-v1/; / { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi0: kernelfsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-fsi"; - reg = <0x0 0x0 0x0>; - - index = <0x0>; - status = "mustexist"; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x0>; - compatible = "ibm,cronus-pib"; - include(p8-pib.dts.m4)dnl - }; - - hmfsi@100000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-hmfsi"; - reg = <0x0 0x100000 0x8000>; - port = <0x1>; - index = <0x1>; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - compatible = "ibm,cronus-pib"; - index = <0x1>; - include(p8-pib.dts.m4)dnl - }; - - }; - }; + fsi0 { + compatible = "ibm,cronus-fsi"; + index = <0x0>; + device-tree-path = "/proc0/fsi"; + }; + + pib0 { + compatible = "ibm,cronus-pib"; + index = <0x0>; + device-tree-path = "/proc0/pib"; + }; + + fsi1 { + compatible = "ibm,cronus-fsi"; + index = <0x1>; + device-tree-path = "/proc1/fsi"; + }; + + pib1 { + compatible = "ibm,cronus-pib"; + index = <0x1>; + device-tree-path = "/proc1/pib"; + }; }; - diff --git a/p8-fsi.dts.m4 b/p8-fsi.dts.m4 index 406a8dc..d87d2d5 100644 --- a/p8-fsi.dts.m4 +++ b/p8-fsi.dts.m4 @@ -20,6 +20,7 @@ index = <0x0>; status = "mustexist"; + device-tree-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -27,7 +28,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x0>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; }; hmfsi@100000 { @@ -37,6 +38,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + device-tree-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -44,7 +46,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; }; @@ -56,6 +58,7 @@ reg = <0x0 0x180000 0x80000>; port = <0x2>; index = <0x2>; + device-tree-path = "/proc2/fsi"; pib@1000 { #address-cells = <0x2>; @@ -63,7 +66,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x2>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc2/pib"; }; }; }; diff --git a/p8-host.dts.m4 b/p8-host.dts.m4 index 7a2d253..822bde9 100644 --- a/p8-host.dts.m4 +++ b/p8-host.dts.m4 @@ -4,7 +4,7 @@ define(`CHIP',`pib@$1 { compatible = "ibm,host-pib"; reg = <$1>; index = <$1>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc$1/pib"; }')dnl /dts-v1/; diff --git a/p8-i2c.dts.m4 b/p8-i2c.dts.m4 index f1fcbd3..0a39d8b 100644 --- a/p8-i2c.dts.m4 +++ b/p8-i2c.dts.m4 @@ -13,7 +13,7 @@ reg = <0x50>; index = <0x0>; status = "mustexist"; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; opb@20010 { #address-cells = <0x1>; @@ -28,6 +28,7 @@ reg = <0x100000 0x80000>; port = <0x1>; index = <0x1>; + device-tree-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -35,7 +36,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; }; @@ -46,6 +47,7 @@ reg = <0x180000 0x80000>; port = <0x2>; index = <0x2>; + device-tree-path = "/proc2/fsi"; pib@1000 { #address-cells = <0x2>; @@ -53,7 +55,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x2>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc2/pib"; }; }; }; diff --git a/p8-kernel.dts.m4 b/p8-kernel.dts.m4 index 4a59b78..d352b73 100644 --- a/p8-kernel.dts.m4 +++ b/p8-kernel.dts.m4 @@ -9,9 +9,9 @@ #size-cells = <0x1>; compatible = "ibm,kernel-fsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + device-tree-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -19,7 +19,7 @@ reg = <0x0 0x1000 0x7>; index = <0x0>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; }; hmfsi@100000 { @@ -29,6 +29,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + device-tree-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -36,7 +37,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; }; diff --git a/p8-pib.dts.m4 b/p8-pib.dts.m4 index 82d11d8..044ce2b 100644 --- a/p8-pib.dts.m4 +++ b/p8-pib.dts.m4 @@ -44,6 +44,7 @@ CORE(14, 14)')dnl adu@2020000 { compatible = "ibm,power8-adu"; reg = <0x0 0x2020000 0x4>; + device_tree_path = "CONCAT(/mem,PROC_ID)"; }; nhtm@2010880 { diff --git a/p8.dts.m4 b/p8.dts.m4 new file mode 100644 index 0000000..aff477a --- /dev/null +++ b/p8.dts.m4 @@ -0,0 +1,55 @@ +define(`PROC',` +define(`PROC_ID',`$1')dnl + proc$1 { + index = <$1>; + + fsi { + index = <$1>; + }; + + pib { + #address-cells = <0x2>; + #size-cells = <0x1>; + index = <$1>; + include(p8-pib.dts.m4)dnl + }; + }; + mem$1 { + index = <$1>; + }' +)dnl + +/dts-v1/; + +/ { + PROC(0); + PROC(1); + PROC(2); + PROC(3); + PROC(4); + PROC(5); + PROC(6); + PROC(7); + PROC(9); + PROC(10); + PROC(11); + PROC(12); + PROC(13); + PROC(14); + PROC(15); + PROC(16); + PROC(17); + PROC(18); + PROC(19); + PROC(21); + PROC(22); + PROC(23); + PROC(24); + PROC(25); + PROC(26); + PROC(27); + PROC(28); + PROC(29); + PROC(30); + PROC(31); +}; From patchwork Thu Sep 19 02:33:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164341 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 46Ygtt5BVdz9sNf for ; Thu, 19 Sep 2019 12:35:34 +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.b="hVkoENlY"; 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 46Ygtt1QGZzF3vK for ; Thu, 19 Sep 2019 12:35:34 +1000 (AEST) 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 46Ygrt23pHzF0kl for ; Thu, 19 Sep 2019 12:33:50 +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.b="hVkoENlY"; 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 46Ygrs5zJhz9sNx; Thu, 19 Sep 2019 12:33:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860429; bh=Nh6FlLIqmFPtJXbwnpvU3AvrKx6DXSDIwabeuTly8ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVkoENlYF1oqj9cIkWGAN4uoltsXZzzeJgU69vXvju1i0lUwGr8jhe56abucclFUH gyoiJkdqGB9L2njZyOxJ6vr8ogDC1TWVWF+LSkwPW8UYJrI7WNx+Nlunt76LG+bpks 1atNcMl9GtaWbQuWtZw1SKx6RmYi56mcmKrr59+psrcceI6nmOn5Q5Yq5uGx4H5tVV Lddtee0yzK+IfWGbrGrE+cw85KXc9C9ZP8GFg1Ol63qChU1NGUFHsDnpWdZgk2dz7R DE7m2XE8Cx9PX/jnN7ihaSLotsdSqyDHPajzgUUpeBzBJsV3B4f3xR7MuvyYMtSVvy dk9FsQrJTq6SQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:32 +1000 Message-Id: <20190919023333.5295-23-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 22/23] dts: Split P9 device trees into system and backend trees 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 --- Makefile.am | 2 +- p9-cronus.dts.m4 | 50 ++++++++++++++++-------------------------------- p9-fsi.dtsi.m4 | 7 ++++--- p9-host.dts.m4 | 4 ++-- p9-kernel.dts.m4 | 13 ++++++++----- p9-pib.dts.m4 | 5 +++++ p9.dts.m4 | 27 ++++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 44 deletions(-) create mode 100644 p9.dts.m4 diff --git a/Makefile.am b/Makefile.am index 95e69b7..6f46abb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,7 +68,7 @@ endif DT = fake.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ - p8-host.dts p9-host.dts p8.dts + p8-host.dts p9-host.dts p8.dts p9.dts DT_sources = $(DT:.dts=.dtb.S) DT_headers = $(DT:.dts=.dt.h) diff --git a/p9-cronus.dts.m4 b/p9-cronus.dts.m4 index c560442..179f581 100644 --- a/p9-cronus.dts.m4 +++ b/p9-cronus.dts.m4 @@ -1,43 +1,27 @@ /dts-v1/; / { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi0: kernelfsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; + fsi0 { compatible = "ibm,cronus-fsi"; - reg = <0x0 0x0 0x0>; - index = <0x0>; - status = "mustexist"; + device-tree-path = "/proc0/fsi"; + }; - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x0>; - compatible = "ibm,cronus-pib"; - include(p9-pib.dts.m4)dnl - }; + pib0 { + compatible = "ibm,cronus-pib"; + index = <0x0>; + device-tree-path = "/proc0/pib"; + }; - hmfsi@100000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-fsi"; - reg = <0x0 0x100000 0x8000>; - port = <0x1>; - index = <0x1>; + fsi1 { + compatible = "ibm,cronus-fsi"; + index = <0x1>; + device-tree-path = "/proc1/fsi"; + }; - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x1>; - compatible = "ibm,cronus-pib"; - include(p9-pib.dts.m4)dnl - }; - }; + pib1 { + compatible = "ibm,cronus-pib"; + index = <0x1>; + device-tree-path = "/proc1/pib"; }; }; diff --git a/p9-fsi.dtsi.m4 b/p9-fsi.dtsi.m4 index afa7d39..a43284b 100644 --- a/p9-fsi.dtsi.m4 +++ b/p9-fsi.dtsi.m4 @@ -8,9 +8,9 @@ #size-cells = <0x1>; compatible = "ibm,bmcfsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + device-tree-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -18,7 +18,7 @@ reg = <0x0 0x1000 0x7>; index = <0x0>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; }; hmfsi@100000 { @@ -28,6 +28,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + device-tree-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -35,7 +36,7 @@ reg = <0x0 0x1000 0x7>; index = <0x1>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; }; diff --git a/p9-host.dts.m4 b/p9-host.dts.m4 index 52973ff..a48c8d3 100644 --- a/p9-host.dts.m4 +++ b/p9-host.dts.m4 @@ -11,7 +11,7 @@ compatible = "ibm,host-pib"; reg = <0x0>; index = <0x0>; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; }; pib@8 { @@ -20,6 +20,6 @@ compatible = "ibm,host-pib"; reg = <0x8>; index = <0x8>; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; }; diff --git a/p9-kernel.dts.m4 b/p9-kernel.dts.m4 index aa4bcac..b013983 100644 --- a/p9-kernel.dts.m4 +++ b/p9-kernel.dts.m4 @@ -9,9 +9,9 @@ #size-cells = <0x1>; compatible = "ibm,kernel-fsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + device-tree-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -20,7 +20,7 @@ index = <0x0>; compatible = "ibm,kernel-pib"; device-path = "/dev/scom1"; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc0/pib"; }; sbefifo@2400 { /* Bogus address */ @@ -29,8 +29,9 @@ compatible = "ibm,kernel-sbefifo"; device-path = "/dev/sbefifo1"; - sbefifo-mem@0 { + sbefifo-mem { compatible = "ibm,sbefifo-mem"; + device-tree-path = "/mem0"; }; }; @@ -41,6 +42,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + device-tree-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -49,7 +51,7 @@ index = <0x1>; compatible = "ibm,kernel-pib"; device-path = "/dev/scom2"; - include(p9-pib.dts.m4)dnl + device-tree-path = "/proc1/pib"; }; sbefifo@2400 { /* Bogus address */ @@ -58,8 +60,9 @@ compatible = "ibm,kernel-sbefifo"; device-path = "/dev/sbefifo2"; - sbefifo-mem@0 { + sbefifo-mem { compatible = "ibm,sbefifo-mem"; + device-tree-path = "/mem1"; }; }; }; diff --git a/p9-pib.dts.m4 b/p9-pib.dts.m4 index 3a99157..03d9630 100644 --- a/p9-pib.dts.m4 +++ b/p9-pib.dts.m4 @@ -35,6 +35,11 @@ index = ; reg = <0x0 HEX(CHIPLET_BASE($1)) 0xfffff>; }')dnl +adu@90000 { + compatible = "ibm-power9-adu"; + reg = <0x0 0x90000 0x50>; + device-tree-path = "CONCAT(/mem,PROC_ID)"; +}; htm@5012880 { compatible = "ibm,power9-nhtm"; diff --git a/p9.dts.m4 b/p9.dts.m4 new file mode 100644 index 0000000..dd46ace --- /dev/null +++ b/p9.dts.m4 @@ -0,0 +1,27 @@ +define(`PROC',` +define(`PROC_ID',`$1')dnl + proc$1 { + index = <$1>; + + fsi { + index = <$1>; + }; + + pib { + #address-cells = <0x2>; + #size-cells = <0x1>; + index = <$1>; + include(p9-pib.dts.m4)dnl + }; + }; + mem$1 { + index = <$1>; + }' +)dnl + +/dts-v1/; + +/ { + PROC(0); + PROC(1); +}; From patchwork Thu Sep 19 02:33:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1164342 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 46Ygtz1CXBz9sNf for ; Thu, 19 Sep 2019 12:35:39 +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.b="Y18UlMW6"; 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 46Ygty4JfVzF4Bd for ; Thu, 19 Sep 2019 12:35:38 +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 46Ygrt4XYKzF13r for ; Thu, 19 Sep 2019 12:33:50 +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.b="Y18UlMW6"; 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 46Ygrt1lkxz9sNF; Thu, 19 Sep 2019 12:33:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1568860430; bh=54THcOG33jP+f1qbVsRp2vL+FPqhZBUamWW0AIJFwRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y18UlMW6ZOiQa6q3kuEiT8XJZNsP5kriXkNtR9qo55s2xyZ05RwMFje5sfla/Rkmt qrx4p/OhGyeiA92XYefw5ZOmO9Y2FITrFBRyo8xKL4a+R4gjzloRPUw2EWWKpZ1M4Y Q/hbhFZVFfOiZwpFEg4CgGzLzgvflq99Hogedy1Mg7nGNOukpC/HvQIOUyFAStOsDl fglfl85wnooSvHHqlwOaadzo6rA+MOSXKMAGJ97Is5c9cBMr0UAS4jWT1uRlroh98M EDvBt+c0wFv8auSvbwhYi+wF+toOtAuGAKYL6GYo/4S179a0M7f1056PrgfLs0dMtw b5iu/U+Eu28cQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 19 Sep 2019 12:33:33 +1000 Message-Id: <20190919023333.5295-24-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919023333.5295-1-amitay@ozlabs.org> References: <20190919023333.5295-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 23/23] libpdbg: Separate backend and system device trees 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 --- libpdbg/dtb.c | 179 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 118 insertions(+), 61 deletions(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index f548816..b7b3c50 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -43,6 +43,9 @@ #include "p8-cronus.dt.h" #include "p9-cronus.dt.h" +#include "p8.dt.h" +#include "p9.dt.h" + #define AMI_BMC "/proc/ractrends/Helper/FwInfo" #define OPENFSI_BMC "/sys/bus/platform/devices/gpio-fsi/fsi0/" #define FSI_CFAM_ID "/sys/devices/platform/gpio-fsi/fsi0/slave@00:00/cfam_id" @@ -84,11 +87,22 @@ static void ppc_target(struct pdbg_dtb *dtb) char line[256]; FILE *cpuinfo; - if (!strcmp(pdbg_backend_option, "p8")) { - dtb->system = &_binary_p8_host_dtb_o_start; - return; - } else if (!strcmp(pdbg_backend_option, "p9")) { - dtb->system = &_binary_p9_host_dtb_o_start; + if (pdbg_backend_option) { + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9")) { + if (!dtb->backend) + dtb->backend = &_binary_p9_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); + pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n"); + } + return; } @@ -117,15 +131,19 @@ static void ppc_target(struct pdbg_dtb *dtb) if (strncmp(pos, "POWER8", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n"); - dtb->system = &_binary_p8_host_dtb_o_start; - } - - if (strncmp(pos, "POWER9", 6) == 0) { + if (!dtb->backend) + dtb->backend = &_binary_p8_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (strncmp(pos, "POWER9", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n"); - dtb->system = &_binary_p9_host_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p9_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_host_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); } - - pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); } static void bmc_target(struct pdbg_dtb *dtb) @@ -135,40 +153,55 @@ static void bmc_target(struct pdbg_dtb *dtb) uint32_t chip_id = 0; int rc; - if (!pdbg_backend_option) { - /* Try and determine the correct device type */ - cfam_id_file = fopen(FSI_CFAM_ID, "r"); - if (!cfam_id_file) { - pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); - return; + if (pdbg_backend_option) { + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9")) { + if (!dtb->backend) + dtb->backend = &_binary_p9_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); + pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n"); } - rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); - if (rc != 1) { - pdbg_log(PDBG_ERROR, "Unable to read CFAM ID: %s", strerror(errno)); - } - fclose(cfam_id_file); - chip_id = (cfam_id >> 4) & 0xff; - } else { - if (!strcmp(pdbg_backend_option, "p9")) - chip_id = CHIP_ID_P9; - else if (!strcmp(pdbg_backend_option, "p8")) - chip_id = CHIP_ID_P8; - else - pdbg_log(PDBG_WARNING, "Invalid OpenBMC system type '%s' specified\n", - pdbg_backend_option); + return; } + /* Try and determine the correct device type */ + cfam_id_file = fopen(FSI_CFAM_ID, "r"); + if (!cfam_id_file) { + pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); + return; + } + + rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); + if (rc != 1) { + pdbg_log(PDBG_ERROR, "Unable to read CFAM ID: %s", strerror(errno)); + } + fclose(cfam_id_file); + chip_id = (cfam_id >> 4) & 0xff; + switch(chip_id) { case CHIP_ID_P9: pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n"); - dtb->system = &_binary_p9_kernel_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p9_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; break; case CHIP_ID_P8: case CHIP_ID_P8P: pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n"); - dtb->system = &_binary_p8_kernel_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p8_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; break; default: @@ -229,17 +262,23 @@ const char *pdbg_get_backend_option(void) * the fdt that is most likely to work on the system. */ void pdbg_default_dtb(struct pdbg_dtb *dtb) { - char *fdt = getenv("PDBG_DTB"); + char *fdt; *dtb = (struct pdbg_dtb) { .backend = NULL, .system = NULL, }; - if (fdt) { + fdt = getenv("PDBG_BACKEND_DTB"); + if (fdt) + dtb->backend = mmap_dtb(fdt); + + fdt = getenv("PDBG_DTB"); + if (fdt) dtb->system = mmap_dtb(fdt); + + if (dtb->backend && dtb->system) return; - } if (!pdbg_backend) pdbg_backend = default_backend(); @@ -251,8 +290,12 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) case PDBG_BACKEND_I2C: /* I2C is only supported on POWER8 */ - pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); - dtb->system = &_binary_p8_i2c_dtb_o_start; + if (!dtb->backend) { + pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); + dtb->backend = &_binary_p8_i2c_dtb_o_start; + } + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; break; case PDBG_BACKEND_KERNEL: @@ -261,44 +304,58 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) case PDBG_BACKEND_FSI: if (!pdbg_backend_option) { - pdbg_log(PDBG_ERROR, "No device type specified\n"); + pdbg_log(PDBG_ERROR, "No system type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); return; } - if (!strcmp(pdbg_backend_option, "p8")) - dtb->system = &_binary_p8_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9w")) - dtb->system = &_binary_p9w_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9r")) - dtb->system = &_binary_p9r_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9z")) - dtb->system = &_binary_p9z_fsi_dtb_o_start; - else { - pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9w")) { + if (!dtb->backend) + dtb->backend = &_binary_p9w_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9r")) { + if (!dtb->backend) + dtb->backend = &_binary_p9r_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9z")) { + if (!dtb->backend) + dtb->backend = &_binary_p9z_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return; } - break; case PDBG_BACKEND_CRONUS: if (!pdbg_backend_option) { - pdbg_log(PDBG_ERROR, "No device type specified\n"); + pdbg_log(PDBG_ERROR, "No system type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); return; } - if (!strncmp(pdbg_backend_option, "p8", 2)) - dtb->system = &_binary_p8_cronus_dtb_o_start; - else if (!strncmp(pdbg_backend_option, "p9", 2)) - dtb->system = &_binary_p9_cronus_dtb_o_start; - else { - pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); + if (!strncmp(pdbg_backend_option, "p8", 2)) { + if (!dtb->backend) + dtb->backend = &_binary_p8_cronus_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strncmp(pdbg_backend_option, "p9", 2)) { + if (!dtb->backend) + dtb->backend = &_binary_p9_cronus_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return; } - break; default: