From patchwork Fri May 19 04:25:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 100145 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp140894qge; Thu, 18 May 2017 21:26:24 -0700 (PDT) X-Received: by 10.84.236.67 with SMTP id h3mr8838845pln.86.1495167984653; Thu, 18 May 2017 21:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495167984; cv=none; d=google.com; s=arc-20160816; b=VTGBKymoY68mvcON8xF6VS/9TjkUGgv70QUsmaoCNABkIr0HThZIDdHqM5n9INuMDn N2Ns8fAnbEFzyQ09E+FdgaMVGuK8DCyBlr6xqgLE00k1dgAZsojB57h22F/pJhRZ8iDn aHrcU7phFLkUaxvYC+8nwBpN9WApI/nFc8kNzRi+lYN9EhlZbuXyvZk5+pjPjUKnaz7s h4klXHbR7iiK0bDcPLphFPs9BEy7BNsE53rhXpUbso+epzPoiRReQsSceJJmvItoj4nW I4nzWkQXOs5nBu2zsdgoKC3/w++11d8glsbAF3mpezrD6exuuwfpP1dNc9Nbf4AP/vYq btVg== 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=xDxAdy6FQIsrPkZIlbZl71L8TET1C7KiQ/XU6wDxeR8=; b=wjdKUpHwsq5lCCtu5dOV+zzfvyi5lvsggE6mWaEIw3bzcXDucNRucmXGEqT70BlEYG 6wltuYTeAHRkkkCaUJ3xyadCIFn9uKDZe7odV1y2laFbZBD1oW0q7Qj22In9OOwfFpHz YdIKMBdIAf5E5GoJY4zlpmMJ+YgA6tksTQHh6YLhDbBhS7ZcnKWdT+4+aZ1Q0MGyw+3s ySA33xSeKEfieEKdTc0Xid6wKqMKe91UjJzoBEsQT+XlhWhSWJCQE2TF09NVZVCQpTgr XnW7AODilM/LxNL5/Xc0HAMRQ/9JvBsKT4eShEevcdJzVwrgrnwnsXya8JWtlnrDY1IY +OPA== 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 u62si6950878pgd.117.2017.05.18.21.26.24; Thu, 18 May 2017 21:26:24 -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 S1751165AbdESE0W (ORCPT + 7 others); Fri, 19 May 2017 00:26:22 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34805 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbdESE0V (ORCPT ); Fri, 19 May 2017 00:26:21 -0400 Received: by mail-pf0-f176.google.com with SMTP id 9so33730897pfj.1 for ; Thu, 18 May 2017 21:26:20 -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=PRaabClGaDHHtTnogdKBySfuwGyMf63/PS0tZ+XGkbU=; b=KEeLbDxws2al/OATJX2UsSNVEFkLk/uuXdJ8+4RNt7DmqhGFDyWJ96J+fsPNgIKWE6 NC7QQinK5gVD1D5H172iI7FR4GBpRYprnpc8tUgEBq3Cwdkfnj06Ft/SfPm/KjJNzuhS 8Tk88wSv4ztltoQC06AlTy2KGIZvVf9jAx238= 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=PRaabClGaDHHtTnogdKBySfuwGyMf63/PS0tZ+XGkbU=; b=BPWdsTFgxC/CF37ESz0fb2j/CDUTRi1mmahp9ZUdoGk1JL8LcqLQm4oXAXAlz5Joi4 9VnpbYJclkYpsdfHPBmqyUBQlwXkV1UOoSGKNcuO9SLPQYs8yvLJcK05SkUmZZP+VcFm +FImDy1GYDNIWmm8GFLl0U7U/APBlURHcqjKLR5XXuczIMrvncyYdELppyeCTR4HM4Vp zIbZ8K6V8FHczPn3tDp11Xkx6Bv+Qs3hvGMew9bgt1AJtTwjwxxvfklK3FJQAcP8yFk9 PHDZYy7Hjyt7uE0dUMxndqgt7lpUgmgANg+NBJqdVO2wjdqB4q6s5KdsKP4ACreybKmR /4SA== X-Gm-Message-State: AODbwcCO98sjUd+fwIlRjlTSuUa/oSW6mDzz4z8q97ievdXlQr3nmlom D3J3n8s7K3Wrf11a X-Received: by 10.84.233.200 with SMTP id m8mr8791473pln.118.1495167980178; Thu, 18 May 2017 21:26:20 -0700 (PDT) Received: from localhost.localdomain (li637-108.members.linode.com. [106.186.117.108]) by smtp.gmail.com with ESMTPSA id c29sm5823259pfj.101.2017.05.18.21.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 May 2017 21:26:18 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Catalin Marinas , Will Deacon , Wei Xu , Andy Gross , David Brown , Greg Kroah-Hartman , Suzuki K Poulose , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Stephen Boyd , Mike Leach Cc: Leo Yan Subject: [PATCH v10 00/10] coresight: enable debug module Date: Fri, 19 May 2017 12:25:47 +0800 Message-Id: <1495167957-14923-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. Patch 0010 is to add Coresight CPU debug nodes for Juno r0, r1 & r2. 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: coresight-cpu-debug 850000.debug: CPU[0]: coresight-cpu-debug 850000.debug: EDPRSR: 00000001 (Power:On DLK:Unlock) coresight-cpu-debug 850000.debug: EDPCSR: [] handle_IPI+0x174/0x1d8 coresight-cpu-debug 850000.debug: EDCIDSR: 00000000 coresight-cpu-debug 850000.debug: EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0) coresight-cpu-debug 852000.debug: CPU[1]: coresight-cpu-debug 852000.debug: EDPRSR: 00000001 (Power:On DLK:Unlock) coresight-cpu-debug 852000.debug: EDPCSR: [] debug_notifier_call+0x23c/0x358 coresight-cpu-debug 852000.debug: EDCIDSR: 00000000 coresight-cpu-debug 852000.debug: EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0) [...] Changes from v9: * Used dev_xyz() to replace pr_xyz() for print log. * Added DT binding patch for Juno shared by Suzuki. 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 (2): coresight: of_get_coresight_platform_data: Add missing of_node_put arm64: dts: juno: Add Coresight CPU debug nodes 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/arm/juno-base.dtsi | 54 ++ arch/arm64/boot/dts/arm/juno-r1.dts | 24 + arch/arm64/boot/dts/arm/juno-r2.dts | 24 + arch/arm64/boot/dts/arm/juno.dts | 24 + 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 | 696 +++++++++++++++++++++ drivers/hwtracing/coresight/of_coresight.c | 40 +- include/linux/coresight.h | 3 + 15 files changed, 1196 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