From patchwork Tue May 9 02:49:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 98858 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1616578qge; Mon, 8 May 2017 19:50:27 -0700 (PDT) X-Received: by 10.98.87.203 with SMTP id i72mr35923001pfj.151.1494298227332; Mon, 08 May 2017 19:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494298227; cv=none; d=google.com; s=arc-20160816; b=hlSrxeh6aiE1yKumbs09oH7m32aj7Uhc4rba5Hv3/XleseRtFrHTK0azOvuXdHrq9Q LoXcCBkGLpUCnKzRuJ/OJkYYwaaHT7S/NIIt3y0vStp9A5QEFkSZfVZT3CFQiu7bY5h9 9ZZ8d/KmWhJpIz7e5k8jeJFizkMBdw9SYf4sn3TLzLaGg5iT/sStT2cx/hqLjVg8hrIf hGk4iB7HWXYe0LL2bDE16nh4yNI+BYJnTfyZAH9SeS+Xn6QGehd5Q3El53/I4SGAaFxC BDWAW99oKBAPDk2HOdH7ynBt6jGebHK2Yn+u/ZPwugcGsADbPUqp3Hx5fYJFdX7Uqo17 XqvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hEEmTrW9XUdFVHnG2CSt/swHc3cgwxhVZORtc700Hr0=; b=N6LFpFIwmsF7S5fzoYfN7tbtj4vK1qwtStWPYkqmc2dX6y6jSk/DVprERXXCpwbYQ/ 6kgB6PncNTZQunq42jB3OJbJDAbzBkBDk6MjGG4cQm22/oFmurvIFtbl8DxrtBfYfuk2 tgsaNQqAtamlqym7/g5/s/OTQirRzfjJDGb6XTupTLQsM6WY0EXxnjwNfFyrkkSVpq2r 1plryl6VOZ9Iz6WxQtuErfQhJv1g+a9SMAs3xu8G4v4KU1DcXfYdQJXV5sWp0zBiNgFd gE53xFxR2JffYU8nXqM6UIuC0ts3DIY/sgCm5S63YWEiPeQ7gXpHzxnZV/cRBnd8Zcc3 1D7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si15640893plm.45.2017.05.08.19.50.27; Mon, 08 May 2017 19:50:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753083AbdEICu0 (ORCPT + 7 others); Mon, 8 May 2017 22:50:26 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:34271 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586AbdEICuY (ORCPT ); Mon, 8 May 2017 22:50:24 -0400 Received: by mail-pg0-f49.google.com with SMTP id u28so32683004pgn.1 for ; Mon, 08 May 2017 19:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=jYQiAKLMpHkpiVjP2KVgSB6XoxnvKQdviw0zP+ufTyU=; b=jyd+oauf9FRvqmXWQNBt6bcKcaUETW54PTL+52pQTI4GE80U0sjzQocsk03ueYGs+J f9PpvFYwEFVHeGEX2ssODKw0NvfSWAK+HFuqKqNjAOP1mfovitU06gbUOyzKw/WMe1eu fL5wYNt658Tcsfzu3L5J+KYOx25HAdHRUebjA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jYQiAKLMpHkpiVjP2KVgSB6XoxnvKQdviw0zP+ufTyU=; b=N6ZsHBK2if7B0A3YXAc4QOhG9/uc7AxCjccE0XNylQo4IPhA1nOs08QiFik02PBiNL OvPikred3SrF/6kdDOEal87PlNnbV/4K+msEXpClYqJkEtVndHe6cwq9MVqqXHLdAnjb DOwXpCXR2PU/FOxFYGw5OvQz6h4hPOiPt9WNDdKb00ZfkI7XAWqT/7iNmaoSrMkathmV 2QIpSta1CFQ/a3P4azdh8OP1q2Mm+cBc76kfqty4gRycye4EzntnNxlk40vHlAcLsbLP yJ+2Gui8A79rYXb1/7m1iWyjkVOyUDuEMsmeJsIVeTpkEGU1FEo5kKv9oAXVUdmxcrVZ q3HA== X-Gm-Message-State: AN3rC/4FLdpIJBIh1FUf6eh+MuJWQRpbZ+CoLNAP5Ckp3Vxcu/APh4ql eK2JVxIBs/FN1sdR X-Received: by 10.84.172.1 with SMTP id m1mr87490263plb.84.1494298223267; Mon, 08 May 2017 19:50:23 -0700 (PDT) Received: from localhost.localdomain (li1627-128.members.linode.com. [172.104.47.128]) by smtp.gmail.com with ESMTPSA id 20sm35326370pfq.42.2017.05.08.19.50.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 19:50:21 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Greg Kroah-Hartman , Suzuki K Poulose , Stephen Boyd , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Mike Leach , Sudeep Holla Cc: Leo Yan Subject: [PATCH v9 0/9] coresight: enable debug module Date: Tue, 9 May 2017 10:49:53 +0800 Message-Id: <1494298202-6739-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org ARMv8 architecture reference manual (ARM DDI 0487A.k) Chapter H7 "The Sample-based Profiling Extension" has description for sampling registers, we can utilize these registers to check program counter value with combined CPU exception level, secure state, etc. So this is helpful for CPU lockup bugs, e.g. if one CPU has run into infinite loop with IRQ disabled; the 'hang' CPU cannot switch context and handle any interrupt, so it cannot handle SMP call for stack dump, etc. This patch series is to enable coresight debug module with sample-based registers and register call back notifier for PCSR register dumping when panic happens, so we can see below dumping info for panic; and this patch series has considered the conditions for access permission for debug registers self, so this can avoid access debug registers when CPU power domain is off; the driver also try to figure out the CPU is in secure or non-secure state. Patch 0001 is to document the dt binding; patch 0002 adds one detailed document to describe the Coresight debug module implementation, the clock and power domain impaction on the driver, some examples for usage. Patch 0003 is to document boot parameters used in kernel command line. Patch 0004 is to add file entries for MAINTAINERS. Patch 0005 is used to fix the func of_get_coresight_platform_data() doesn't properly drop the reference to the CPU node pointer; and patch 0006 is refactor to add new function of_coresight_get_cpu(). Patch 0007 is the driver for CPU debug module. Patch 0008 in this series are to enable debug unit on 96boards Hikey, Patch 0009 is to enable debug on 96boards DB410c. Have verified on both two boards. We can enable debugging with two methods, adding parameters into kernel command line for build-in module: coresight_cpu_debug.enable=1 Or we can wait the system has booted up to use debugfs nodes to enable debugging: # echo 1 > /sys/kernel/debug/coresight_cpu_debug/enable As result we can get below log after input command: echo c > /proc/sysrq-trigger: ARM external debug module: CPU[0]: EDPRSR: 0000000b (Power:On DLK:Unlock) EDPCSR: [] handle_IPI+0xe4/0x150 EDCIDSR: 00000000 EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0) CPU[1]: EDPRSR: 0000000b (Power:On DLK:Unlock) EDPCSR: [] debug_notifier_call+0x108/0x288 EDCIDSR: 00000000 EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0) [...] Changes from v8: * According to Mathieu suggestions to split the doc into two patches, one is for kernel parameter and another is for driver documentation. * Add file entries to MAINTAINERS. * According to Mathieu suggestions, refined functions debug_enable_func()/debug_disable_func(). Changes from v7: * Fix operator priority bug. * Minor sequence adjustment for function debug_func_exit(). Changes from v6: * According to Suzuki and Mathieu suggestions, refined debug module driver to install panic notifier when insmod module; refined function debug_force_cpu_powered_up() for CPU power state checking; some minor fixing for output log, adding comments for memory barrier, code alignment. Changes from v5: * According to Suzuki and Mathieu suggestions, refined debug module driver to drop unused structure members, refactored initialization code to distinguish hardware implementation features, refactored flow for forcing CPU powered up, supported pm_runtime operations. * Added one new doc file: Documentation/trace/coresight-cpu-debug.txt, which is used to describe detailed info for implementation, clock and power domain impaction on debug module, and exmaples for common usage. * Removed "idle constraints" from debug driver. Changes from v4: * This version is mainly credit to ARM colleagues many contribution ideas for better quality (Thanks a lot Suzuki, Mike and Sudeep!). * According to Suzuki suggestion, refined debug module driver to avoid memory leak for drvdata struct, handle PCSAMPLE_MODE=1, use flag drvdata.pc_has_offset to indicate if PCSR has offset, minor fixes. * According to Mathieu suggestion, refined dt binding description. * Changed driver to support module mode; * According to Mike suggestion and very appreciate the pseudo code, added support to force CPU powered up with register EDPRCR; * According to discussions, added command line and debugfs nodes to support enabling debugging for boot time, or later can dynamically enable/disable debugging by debugfs. * According to Rob Herring suggestion, one minor fixes in DT binding. * According to Stephen Boyd suggestion, add const quality to structure device_node. And used use of_cpu_device_node_get() to replace of_get_cpu_node() in patch 0003. Changes from v3: * Added Suzuki K Poulose's patch to fix issue for the func of_get_coresight_platform_data() doesn't properly drop the reference to the CPU node pointer. * According to Suzuki suggestion, added code to handl the corner case for ARMv8 CPU with aarch32 mode. * According to Suzuki suggestion, changed compatible string to "arm,coresight-cpu-debug". * According to Mathieu suggestion, added "power-domains" as optional properties. Changes from v2: * According to Mathieu Poirier suggestion, applied some minor fixes. * Added two extra patches for enabling debug module on Hikey. Changes from v1: * According to Mike Leach suggestion, removed the binding for debug module clocks which have been directly provided by CPU clocks. * According to Mathieu Poirier suggestion, added function of_coresight_get_cpu() and some minor refactors for debug module driver. Changes from RFC: * According to Mike Leach suggestion, added check for EDPRSR to avoid lockup; added supporting EDVIDSR and EDCIDSR registers. * According to Mark Rutland and Mathieu Poirier suggestion, rewrote the documentation for DT binding. * According to Mark and Mathieu suggestion, refined debug driver. Leo Yan (8): coresight: bindings for CPU debug module doc: Add documentation for Coresight CPU debug doc: Add coresight_cpu_debug.enable to kernel-parameters.txt MAINTAINERS: update file entries for Coresight subsystem coresight: refactor with function of_coresight_get_cpu coresight: add support for CPU debug module arm64: dts: hi6220: register debug module arm64: dts: qcom: msm8916: Add debug unit Suzuki K Poulose (1): coresight: of_get_coresight_platform_data: Add missing of_node_put Documentation/admin-guide/kernel-parameters.txt | 7 + .../bindings/arm/coresight-cpu-debug.txt | 49 ++ Documentation/trace/coresight-cpu-debug.txt | 174 ++++++ MAINTAINERS | 2 + arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 64 ++ arch/arm64/boot/dts/qcom/msm8916.dtsi | 32 + drivers/hwtracing/coresight/Kconfig | 14 + drivers/hwtracing/coresight/Makefile | 1 + drivers/hwtracing/coresight/coresight-cpu-debug.c | 693 +++++++++++++++++++++ drivers/hwtracing/coresight/of_coresight.c | 40 +- include/linux/coresight.h | 3 + 11 files changed, 1067 insertions(+), 12 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt create mode 100644 Documentation/trace/coresight-cpu-debug.txt create mode 100644 drivers/hwtracing/coresight/coresight-cpu-debug.c -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose