From patchwork Fri May 3 11:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10928257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D16DD1395 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C217A27D29 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B303A28390; Fri, 3 May 2019 11:19:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FEAE27D29 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbfECLTs (ORCPT ); Fri, 3 May 2019 07:19:48 -0400 Received: from mail-eopbgr00082.outbound.protection.outlook.com ([40.107.0.82]:40769 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727153AbfECLTs (ORCPT ); Fri, 3 May 2019 07:19:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HxMPa5mcyYpaJZoYrtdn9sDzSXY9ZtnHJbTos7wWymw=; b=hD1F31YLYYCDJW3TEP1v+xqDNH40ev163j81fWHFPLuvYeiAB8iLP7gd7GlbkF4pu/qP5P9bYmATjleRypBDoIdsdHqGgfAQcbVoA7ql62WG9wsF8UTefBOUJFRKOqi7SFECMwAw9uebPH1PUYuSc1sxkXaBVaHXxlq4Mmpcx7A= Received: from AM0PR04MB6434.eurprd04.prod.outlook.com (20.179.252.215) by AM0PR04MB5859.eurprd04.prod.outlook.com (20.178.202.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Fri, 3 May 2019 11:19:32 +0000 Received: from AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec]) by AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec%7]) with mapi id 15.20.1856.008; Fri, 3 May 2019 11:19:32 +0000 From: Leonard Crestez To: Stephen Boyd , Kieran Bingham , Jan Kiszka CC: Andrew Morton , Michael Turquette , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH 1/2] scripts/gdb: Cleanup error handling in list helpers Thread-Topic: [PATCH 1/2] scripts/gdb: Cleanup error handling in list helpers Thread-Index: AQHVAaIUVmCD1Tl5NEapbpBu30VdQQ== Date: Fri, 3 May 2019 11:19:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [89.37.124.34] x-mailer: git-send-email 2.17.1 x-clientproxiedby: VE1PR08CA0027.eurprd08.prod.outlook.com (2603:10a6:803:104::40) To AM0PR04MB6434.eurprd04.prod.outlook.com (2603:10a6:208:16c::23) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4e0a6053-7668-4592-4616-08d6cfb936b8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:AM0PR04MB5859; x-ms-traffictypediagnostic: AM0PR04MB5859: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0026334A56 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(136003)(376002)(366004)(346002)(39860400002)(396003)(189003)(199004)(478600001)(256004)(66066001)(14454004)(6436002)(386003)(11346002)(446003)(66946007)(6512007)(2616005)(110136005)(316002)(476003)(6486002)(8676002)(66476007)(66556008)(64756008)(66446008)(99286004)(53936002)(3846002)(81156014)(81166006)(54906003)(118296001)(36756003)(6116002)(68736007)(8936002)(50226002)(44832011)(73956011)(2906002)(486006)(305945005)(76176011)(52116002)(4326008)(102836004)(6506007)(25786009)(5660300002)(186003)(26005)(7736002)(86362001)(71200400001)(71190400001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5859;H:AM0PR04MB6434.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vMM7cP3o7tnaHo5j9IJXNho6qG1LlRjcUctAnah1jqj+XJ1KkRV7dEBMeXEbZQAtrL/aNg1o06J5i35NENwcEMtfcqq2VzpES8aLVMA/XH5JBBc7Xu7IXWmyvcFZcleyObrkR/0jM0URpYzqnByci6Kmin9Zep5PhoPXVj75BFU6zC0afimO/b/xh/EF54wXMaZgIknoE9bjyWYlvAamBpdEU8Opx49SMqclc3YoK6PSpvfqHOSwuXVtfFJQ/M0wWSZE//wd+zCF2zBAI4mATDskZkY+uJsyYjsY9CkY3MIAxc0Tc+KA4oB87fkYahNfw/6NB70ayQaoCoDjxJK4L1TnHD2de/shgpOSfltBjoVGsWQGAzOU5g2xPCXjay+Qtvw6lkrgWsXXPsxMocAOXEo3Aj3Utvo2ZR+CQpmm2no= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e0a6053-7668-4592-4616-08d6cfb936b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2019 11:19:31.5858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5859 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP An incorrect argument to list_for_each is an internal error in gdb scripts so a TypeError should be raised. The gdb.GdbError exception type is intended for user errors such as incorrect invocation. Drop the type assertion in list_for_each_entry because list_for_each isn't going to suddenly yield something else. Applies to both list and hlist Signed-off-by: Leonard Crestez Reviewed-by: Stephen Boyd --- scripts/gdb/linux/lists.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py index 55356b66f8ea..c487ddf09d38 100644 --- a/scripts/gdb/linux/lists.py +++ b/scripts/gdb/linux/lists.py @@ -22,45 +22,39 @@ hlist_node = utils.CachedType("struct hlist_node") def list_for_each(head): if head.type == list_head.get_type().pointer(): head = head.dereference() elif head.type != list_head.get_type(): - raise gdb.GdbError("Must be struct list_head not {}" + raise TypeError("Must be struct list_head not {}" .format(head.type)) node = head['next'].dereference() while node.address != head.address: yield node.address node = node['next'].dereference() def list_for_each_entry(head, gdbtype, member): for node in list_for_each(head): - if node.type != list_head.get_type().pointer(): - raise TypeError("Type {} found. Expected struct list_head *." - .format(node.type)) yield utils.container_of(node, gdbtype, member) def hlist_for_each(head): if head.type == hlist_head.get_type().pointer(): head = head.dereference() elif head.type != hlist_head.get_type(): - raise gdb.GdbError("Must be struct hlist_head not {}" + raise TypeError("Must be struct hlist_head not {}" .format(head.type)) node = head['first'].dereference() while node.address: yield node.address node = node['next'].dereference() def hlist_for_each_entry(head, gdbtype, member): for node in hlist_for_each(head): - if node.type != hlist_node.get_type().pointer(): - raise TypeError("Type {} found. Expected struct hlist_head *." - .format(node.type)) yield utils.container_of(node, gdbtype, member) def list_check(head): nb = 0 From patchwork Fri May 3 11:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10928259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2D9A1515 for ; Fri, 3 May 2019 11:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FAAA22A2A for ; Fri, 3 May 2019 11:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8049524BFE; Fri, 3 May 2019 11:19:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C06922A2A for ; Fri, 3 May 2019 11:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbfECLTw (ORCPT ); Fri, 3 May 2019 07:19:52 -0400 Received: from mail-eopbgr00082.outbound.protection.outlook.com ([40.107.0.82]:40769 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727682AbfECLTu (ORCPT ); Fri, 3 May 2019 07:19:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rfl+C8Pdn3tOZlH6um1JWP9IX3M26rcYnUTamup+VQs=; b=RuYhManXepJTfxwtZCC1s+duh2ujUUQb3BKf0EClc/wEUMEtbmt7sBoJWRj7X2036rlvOpIAV5Dq59i+nTHPtNFXr7RqR9pej86dIy1IxHUXEquaBwxA2TeTC+f5pQjKgqxvPkd0/PSsiGyiNazDaW3jDdkvTOFB1DeO8BXoZ7g= Received: from AM0PR04MB6434.eurprd04.prod.outlook.com (20.179.252.215) by AM0PR04MB5859.eurprd04.prod.outlook.com (20.178.202.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Fri, 3 May 2019 11:19:33 +0000 Received: from AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec]) by AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec%7]) with mapi id 15.20.1856.008; Fri, 3 May 2019 11:19:33 +0000 From: Leonard Crestez To: Stephen Boyd , Kieran Bingham , Jan Kiszka CC: Andrew Morton , Michael Turquette , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH 2/2] scripts/gdb: Print cached rate in lx-clk-summary Thread-Topic: [PATCH 2/2] scripts/gdb: Print cached rate in lx-clk-summary Thread-Index: AQHVAaIU9Nxde2bkokKBi3IR8Q3yGA== Date: Fri, 3 May 2019 11:19:32 +0000 Message-ID: <1a474318982a5f0125f2360c4161029b17f56bd1.1556881728.git.leonard.crestez@nxp.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [89.37.124.34] x-mailer: git-send-email 2.17.1 x-clientproxiedby: VE1PR08CA0027.eurprd08.prod.outlook.com (2603:10a6:803:104::40) To AM0PR04MB6434.eurprd04.prod.outlook.com (2603:10a6:208:16c::23) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c5856d9b-2cd5-4a83-3de3-08d6cfb9372d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:AM0PR04MB5859; x-ms-traffictypediagnostic: AM0PR04MB5859: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:451; x-forefront-prvs: 0026334A56 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(376002)(366004)(346002)(39860400002)(396003)(43544003)(189003)(199004)(478600001)(256004)(66066001)(14454004)(6436002)(386003)(11346002)(446003)(66946007)(6512007)(2616005)(110136005)(316002)(476003)(6486002)(8676002)(66476007)(66556008)(64756008)(66446008)(99286004)(53936002)(3846002)(81156014)(81166006)(54906003)(118296001)(36756003)(6116002)(68736007)(8936002)(50226002)(44832011)(73956011)(14444005)(2906002)(486006)(305945005)(76176011)(52116002)(4326008)(102836004)(6506007)(25786009)(5660300002)(186003)(26005)(7736002)(86362001)(71200400001)(71190400001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5859;H:AM0PR04MB6434.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Iy7DgfnWmbFL2dilMP003aDmGHw19S+1WapC9v6qY1k88iwv2rqHE4S2xjmVqfBlf3INl5fGqIPJuEbNKVFwS1DAkdhWrZ70yH9SoWXZpMOQ4qJU4Eo/MAnRF0b3XBYKRDjfJ4l7plF5xoLgrnTx8J57ie0eKra2U9g+20luSlw5tWGs4seJ8QaAHcDxPGLoayR7YQUWzRb00+rdHwkiyANCHyI7uszGI09OieiWvsQ4My9Louj4cyOksL/I+nkxSF1aMAXcjxN9auqihon9pmCyjs9mJr2P1ip4GIrPLOF62E55L+/adteuTZZBtQzT/O/5spSFYKIgFHZTgdO8eHiIotpRd113v9Ffb6jTp9udbNQjPRq+Z2JBVVjklwbHsllh8mh++qVb4eAl+L3R2CtD7DCFoY2M3XMuJy8rBHg= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5856d9b-2cd5-4a83-3de3-08d6cfb9372d X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2019 11:19:32.4503 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5859 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The clk rate is always stored in clk_core but might be out of date and require calls to update from hardware. Deal with that case by printing a (c) suffix. Signed-off-by: Leonard Crestez --- scripts/gdb/linux/clk.py | 21 ++++++++++++++------- scripts/gdb/linux/constants.py.in | 4 ++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/scripts/gdb/linux/clk.py b/scripts/gdb/linux/clk.py index 6bf71976b55d..061aecfa294e 100644 --- a/scripts/gdb/linux/clk.py +++ b/scripts/gdb/linux/clk.py @@ -3,42 +3,49 @@ # Copyright (c) NXP 2019 import gdb import sys -from linux import utils, lists +from linux import utils, lists, constants clk_core_type = utils.CachedType("struct clk_core") def clk_core_for_each_child(hlist_head): return lists.hlist_for_each_entry(hlist_head, clk_core_type.get_type().pointer(), "child_node") class LxClkSummary(gdb.Command): - """Print Linux kernel log buffer.""" + """Print clk tree summary + +Output is a subset of /sys/kernel/debug/clk/clk_summary + +No calls are made during printing, instead a (c) if printed after values which +are cached and potentially out of date""" def __init__(self): super(LxClkSummary, self).__init__("lx-clk-summary", gdb.COMMAND_DATA) def show_subtree(self, clk, level): - gdb.write("%*s%-*s %7d %8d %8d\n" % ( + gdb.write("%*s%-*s %7d %8d %8d %11lu%s\n" % ( level * 3 + 1, "", 30 - level * 3, clk['name'].string(), clk['enable_count'], clk['prepare_count'], - clk['protect_count'])) + clk['protect_count'], + clk['rate'], + '(c)' if clk['flags'] & constants.LX_CLK_GET_RATE_NOCACHE else ' ')) for child in clk_core_for_each_child(clk['children']): self.show_subtree(child, level + 1) def invoke(self, arg, from_tty): - gdb.write(" enable prepare protect\n") - gdb.write(" clock count count count\n") - gdb.write("---------------------------------------------------------\n") + gdb.write(" enable prepare protect \n") + gdb.write(" clock count count count rate \n") + gdb.write("------------------------------------------------------------------------\n") for clk in clk_core_for_each_child(gdb.parse_and_eval("clk_root_list")): self.show_subtree(clk, 0) for clk in clk_core_for_each_child(gdb.parse_and_eval("clk_orphan_list")): self.show_subtree(clk, 0) diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index 76f46f427b96..1d73083da6cb 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -10,10 +10,11 @@ * * This work is licensed under the terms of the GNU GPL version 2. * */ +#include #include #include #include #include #include @@ -36,10 +37,13 @@ /* The build system will take care of deleting everything above this marker */ import gdb +/* linux/clk-provider.h */ +LX_GDBPARSED(CLK_GET_RATE_NOCACHE) + /* linux/fs.h */ LX_VALUE(SB_RDONLY) LX_VALUE(SB_SYNCHRONOUS) LX_VALUE(SB_MANDLOCK) LX_VALUE(SB_DIRSYNC)