From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5958FC433F5 for ; Tue, 9 Nov 2021 12:10:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 276B661152 for ; Tue, 9 Nov 2021 12:10:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 276B661152 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=obcSSX9bSDuUEG9pfv633HiLwbCmyi4JPcK7C7GzTpY=; b=ln1AlzvDHbuKAD X2/1HkgV4ljabUi0hXCid+yN+PNouCIqhyDhYoCIcjTs4/FypdAWvHuZiLra3t6prqT2XDc5OcNzU hgONWAY6FXQ02Az1MwekT+S5eDh0pKsT+AKqLGo11oTEQUrH7lbdPsfdiEPeNBQFndZASAFUk0WRp tT0RbQl9y6WCVfmQO3xy/JQ4epN5hKeaPEc63w/ZgbyGH1w2SPCVFlZPuBPdf8m4Nf3d1JaaxV8TM VCu6eZyc6aesLJWXHa1imTynsVrbkx94VvRX7XpbRziKBA0UNQgBja8tPKCJQOuuuMwJ/PhtEBl02 D82RUzhwerm1XjqBKKZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkPwH-001vNX-2z; Tue, 09 Nov 2021 12:09:21 +0000 Received: from alexa-out.qualcomm.com ([129.46.98.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkPw8-001vLA-Le for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 12:09:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1636459753; x=1667995753; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1+MdvvHM1pA3v3NcEb9pr7yhUwI/tZNQsP5FUiK4NgE=; b=jQDVKfeMZc/TGW0+bMI/bEUW3sSPJNLI7GM/ud1aEZbW2NWFyizPEzkr N7AaXfClwZMaPL/dWd5sFqwVINM4WSkvrcSS+13y9i25wXfk1S5blRlgD dvhQe/kNQS7mhXPmK2BDm5MFr3jCEtRyCx12Egc76OH+3AmEOIWiv5+aR A=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 09 Nov 2021 04:09:09 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:09:09 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:08 -0800 Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:03 -0800 From: Sai Prakash Ranjan To: Will Deacon , , Catalin Marinas , CC: Marc Zyngier , , , , , , , , , "Sai Prakash Ranjan" Subject: [PATCHv3 0/3] tracing/rwmmio/arm64: Add support to trace register reads/writes Date: Tue, 9 Nov 2021 17:38:18 +0530 Message-ID: X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_040912_843667_C028654A X-CRM114-Status: GOOD ( 16.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Generic MMIO read/write i.e., __raw_{read,write}{b,l,w,q} accessors are typically used to read/write from/to memory mapped registers and can cause hangs or some undefined behaviour in following cases, * If the access to the register space is unclocked, for example: if there is an access to multimedia(MM) block registers without MM clocks. * If the register space is protected and not set to be accessible from non-secure world, for example: only EL3 (EL: Exception level) access is allowed and any EL2/EL1 access is forbidden. * If xPU(memory/register protection units) is controlling access to certain memory/register space for specific clients. and more... Such cases usually results in instant reboot/SErrors/NOC or interconnect hangs and tracing these register accesses can be very helpful to debug such issues during initial development stages and also in later stages. So use ftrace trace events to log such MMIO register accesses which provides rich feature set such as early enablement of trace events, filtering capability, dumping ftrace logs on console and many more. Sample output: rwmmio_read: gic_peek_irq+0xd0/0xd8 readl addr=0xffff800010040104 rwmmio_write: gic_poke_irq+0xe4/0xf0 writel addr=0xffff800010040184 val=0x40 rwmmio_read: gic_do_wait_for_rwp+0x54/0x90 readl addr=0xffff800010040000 rwmmio_write: gic_set_affinity+0x1bc/0x1e8 writeq addr=0xffff800010046130 val=0x500 In addition to this, provide dynamic debug support to filter out unwanted logs and limit trace to only specific files or directories since there can be aweful lot of register trace events and we will be interested only in specific drivers or subsystems which we will be working on. So introduce a new flag "e" to filter these event tracing to specified input. Example: Tracing register accesses for all drivers in drivers/soc/qcom/* and the trace output is given below: # dyndbg="file drivers/soc/qcom/* +e" trace_event=rwmmio or # echo "file drivers/soc/qcom/* +e" > /sys/kernel/debug/dynamic_debug/control # cat /sys/kernel/debug/tracing/trace rwmmio_read: rpmh_rsc_probe+0x35c/0x410 readl addr=0xffff80001071000c rwmmio_read: rpmh_rsc_probe+0x3d0/0x410 readl addr=0xffff800010710004 rwmmio_write: rpmh_rsc_probe+0x3b0/0x410 writel addr=0xffff800010710d00 val=0x3 rwmmio_write: write_tcs_cmd+0x6c/0x78 writel addr=0xffff800010710d30 val=0x10108 This series is a follow-up for the series [1] and a recent series [2] making use of both. [1] https://lore.kernel.org/lkml/cover.1536430404.git.saiprakash.ranjan@codeaurora.org/ [2] https://lore.kernel.org/lkml/1604631386-178312-1-git-send-email-psodagud@codeaurora.org/ Changes in v3: * Create a generic mmio header for instrumented version (Earlier suggested in [1] by Will Deacon and recently [2] by Greg to have a generic version first). * Add dynamic debug support to filter out traces which can be very useful for targeted debugging specific to subsystems or drivers. * Few modifications to the rwmmio trace event fields to include the mmio width and print addresses in hex. * Rewrote commit msg to explain some more about usecases. Prasad Sodagudi (1): tracing: Add register read and write tracing support Sai Prakash Ranjan (2): arm64/io: Add a header for mmio access instrumentation dynamic_debug: Add a flag for dynamic event tracing arch/arm64/include/asm/io.h | 25 +++----- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- include/linux/dynamic_debug.h | 1 + include/linux/mmio-instrumented.h | 95 +++++++++++++++++++++++++++++++ include/trace/events/rwmmio.h | 61 ++++++++++++++++++++ kernel/trace/Kconfig | 7 +++ kernel/trace/Makefile | 1 + kernel/trace/trace_readwrite.c | 28 +++++++++ lib/dynamic_debug.c | 1 + 9 files changed, 204 insertions(+), 17 deletions(-) create mode 100644 include/linux/mmio-instrumented.h create mode 100644 include/trace/events/rwmmio.h create mode 100644 kernel/trace/trace_readwrite.c -- 2.29.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel