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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 936CCC433EF for ; Wed, 27 Apr 2022 17:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbiD0RWd (ORCPT ); Wed, 27 Apr 2022 13:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbiD0RWc (ORCPT ); Wed, 27 Apr 2022 13:22:32 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0726B43EEE; Wed, 27 Apr 2022 10:19:19 -0700 (PDT) Received: from mail-yb1-f177.google.com ([209.85.219.177]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M3lHZ-1nk2AY3Yhf-000pwR; Wed, 27 Apr 2022 19:19:18 +0200 Received: by mail-yb1-f177.google.com with SMTP id y76so4637875ybe.1; Wed, 27 Apr 2022 10:19:17 -0700 (PDT) X-Gm-Message-State: AOAM531+el4QSdxw258V6dhpmKYBsthoDpzNMuJRfg2G2rqhJY7U0zPF tOAY0RJXUQchtqJqCDXOk4ygqMzOqVYwCMBmjFA= X-Google-Smtp-Source: ABdhPJxykFm2YFdeTD9c0X4acekrQD5pMu7gY+0N7BMUQZQ8AeFGwdPZwBJhORkCJQqjgz7RTTvsKHR+rJyDsdyNlv0= X-Received: by 2002:a25:75c5:0:b0:648:dccd:e1c with SMTP id q188-20020a2575c5000000b00648dccd0e1cmr2536236ybc.452.1651076102000; Wed, 27 Apr 2022 09:15:02 -0700 (PDT) MIME-Version: 1.0 References: <8cf9304d9941c25d920c4835cbc624ff5c2ac2cb.1644824638.git.quic_saipraka@quicinc.com> In-Reply-To: <8cf9304d9941c25d920c4835cbc624ff5c2ac2cb.1644824638.git.quic_saipraka@quicinc.com> From: Arnd Bergmann Date: Wed, 27 Apr 2022 18:14:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv10 5/6] lib: Add register read/write tracing support To: Sai Prakash Ranjan Cc: Will Deacon , Catalin Marinas , Arnd Bergmann , Steven Rostedt , Marc Zyngier , Trilok Soni , quic_psodagud@quicinc.com, gregkh , Linux ARM , Linux Kernel Mailing List , linux-arm-msm , Prasad Sodagudi Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:fNiZgmJlIJjWIct59kSQx8ulkmtN7VhuK0xD8FBYWGJHejqOqrI WFoOWk0Jgc7ITQkzCBP5gToDgyKqCqne6ABQKANTZkYzI1M5xyZ9RUDFVXiffCSp9+h9Zj1 UOaUe5K+szrhJSycphxyeSlW48qZTsHNffCN4KgdaxAMECjwlxLO5GZc/ro/Q3GDdbaDM5o q37ylgOliMyNA6s2ZlGGg== X-UI-Out-Filterresults: notjunk:1;V03:K0:mOXcYFdOMKM=:QmOMmZLYg82fxODCPrNcJ0 JSFAZq7c4sP4ApFc32S0zxRzq9pXxIuf1/FtJ/ltcbaIBDMqW2sWzroaY/plVcskhNUEixEsK 9qB5s94QXjaTur14KQdE1bO3mD2qeDKo6jClJxyGYNxGTGgZRMdgsBFiBI+zwdT5457qvykQG KtzY7BDW6aAKlLyZhTxHbrheYXdBUGfYjydv21D5O96VD3bqLz4g/sASmb+CqjS8QP7f24NbE Hv1yFrTMcgw1ecRKj15UGFZOHZQxypiY+JTz0eTjmJ5F2LVEprNAGpI0j6f7XbTZzs/0rDIZc JtaBpJKwXbjoxUPynlZdO1D8HdLGhlzFpXKg/Ai6goHh63fs75tSHhkx00iO6QLHsV8FyWIJj Y/CHAYNo8Lz83S2XZzf7YM2rxW+8ZegpOJDjzcFSH10BoZ46528Ga/+nJtTqfQLo7ldcGckNX EkiAXt8HLH3DvuQjpxf6W57oV1SiRQr5q+whbtup0clInB2B0Lb0W/X3soL/JQ3kX96XLWFDC yioUU8XbUrRZPYGqyx26m5PCmPSD4YwpvAJekKKBiPYSSE0T7SlWRPSzfI0xXLbEPzOEFyCnb 4LCFFDtw+SahIIwrOyxL4W0VBW4ua78M/c4791VuqB9RInnZiCuEwK3U5zteFDRt7beC+u52v V9OKFr67tL8nOBBR3QtLtojhYG3BiEMV1frW64JklzhkcMTT8a+t7LLIjgW4yJtAERwdrV1Q3 +6oKpKHEDbtMFdhfOz2ZCQrnzUSGis9snuu0tCA5hN77ikYFKyyMW0I173A0FigpnGDX/DR7J N4PKUBbPALox6FEjjz/W5hNkL2cYboQ2JFlwxUQlN8IZfcOt0Y= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, Feb 24, 2022 at 7:07 AM Sai Prakash Ranjan wrote: > > From: Prasad Sodagudi > > 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 few > 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_write: __qcom_geni_serial_console_write+0x160/0x1e0 width=32 val=0xa0d5d addr=0xfffffbfffdbff700 > rwmmio_post_write: __qcom_geni_serial_console_write+0x160/0x1e0 width=32 val=0xa0d5d addr=0xfffffbfffdbff700 > rwmmio_read: qcom_geni_serial_poll_bit+0x94/0x138 width=32 addr=0xfffffbfffdbff610 > rwmmio_post_read: qcom_geni_serial_poll_bit+0x94/0x138 width=32 val=0x0 addr=0xfffffbfffdbff610 > > Signed-off-by: Prasad Sodagudi > Co-developed-by: Sai Prakash Ranjan > Signed-off-by: Sai Prakash Ranjan I think this is ok in general. I saw that Steve had a minor comment, and I suppose you could have just resent the same patches with a fixup in order to have me pick it up into the asm-generic tree for 5.19. There is one more thing that I saw looking through this patch again: the address you print is the virtual __iomem token, but it might be more valuable to have the physical address instead, which can be looked up in the devicetree to know which register is affected. There is a small extra cost to walk the page table, and I'm not sure if we actually have an interface for it (vmalloc_to_page is almost what we want, but it returns an invalid page pointer). Any suggestions on this? Arnd 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AFD6BC433EF for ; Wed, 27 Apr 2022 17:32:25 +0000 (UTC) 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2a5kbU96yQ6Z+Z4tVe3G+oFkqsB2A6boEpOaJniycvo=; b=T268tXitok8d3x TVjM18Lavot89f4d6rkiGTT8XMVzWmo02yBFmZ0yl+lCY0xA07C39jILk/J1vWwdU93WQQPl8FLC3 bkgA7qu0o/oxetoc1a9ykXGQjoDfc1esOzWe/6fP+xCrQjfhS5xxEztk5+Y86vcN//EDDq1Q/CpSe ukhyhGMn3S145jJCQR80+QJMyvIOPR6VdQ8RV+1m37LS761K9eVZO/MyYnNxoEn30+3SAlELJhnt1 NFlQm/UZcBNWeDJKmCNoxnUORXt/il3O3H3IaPRId667DtjCfpU3Kpc16SjSR9NGJChpVZx6MkVgJ jG4fadQj01yl38JKkaEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njlVA-002gES-07; Wed, 27 Apr 2022 17:30:57 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njlIO-002bDE-KO for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 17:17:46 +0000 Received: from mail-yb1-f174.google.com ([209.85.219.174]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Mw9Lw-1o2X8J2GRA-00s32d for ; Wed, 27 Apr 2022 19:17:39 +0200 Received: by mail-yb1-f174.google.com with SMTP id j2so4684067ybu.0 for ; Wed, 27 Apr 2022 10:17:39 -0700 (PDT) X-Gm-Message-State: AOAM532EOUvGbDI8i8dbdP1xXlXUT4zpejqhWrQN2qM/jrrJgeNgLZFP jEQ1FQj1FIxp8jfL1Fv/iVIvwyUOcUf+LFmY7u4= X-Google-Smtp-Source: ABdhPJxykFm2YFdeTD9c0X4acekrQD5pMu7gY+0N7BMUQZQ8AeFGwdPZwBJhORkCJQqjgz7RTTvsKHR+rJyDsdyNlv0= X-Received: by 2002:a25:75c5:0:b0:648:dccd:e1c with SMTP id q188-20020a2575c5000000b00648dccd0e1cmr2536236ybc.452.1651076102000; Wed, 27 Apr 2022 09:15:02 -0700 (PDT) MIME-Version: 1.0 References: <8cf9304d9941c25d920c4835cbc624ff5c2ac2cb.1644824638.git.quic_saipraka@quicinc.com> In-Reply-To: <8cf9304d9941c25d920c4835cbc624ff5c2ac2cb.1644824638.git.quic_saipraka@quicinc.com> From: Arnd Bergmann Date: Wed, 27 Apr 2022 18:14:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv10 5/6] lib: Add register read/write tracing support To: Sai Prakash Ranjan Cc: Will Deacon , Catalin Marinas , Arnd Bergmann , Steven Rostedt , Marc Zyngier , Trilok Soni , quic_psodagud@quicinc.com, gregkh , Linux ARM , Linux Kernel Mailing List , linux-arm-msm , Prasad Sodagudi X-Provags-ID: V03:K1:hJAEyflA9n87hCVN7VjA+yW2GSvWUIMjipG0t87G9yqb0CsvI51 RKjvJPqpD+CNtSQ+DS+amOt40yO2E6mfkyzYF1KCyu03Nrd6cR8zqEGgazPIr76jJj/RmbW hsb8JgCcQl0AsWk6u9+cXFMKBrjmY5z0QzqEC0u9CsK2UaUjLsdlPoK5LjqBVi19E8DEMwy 3ivr5P8XUPhyDux7c5/YA== X-UI-Out-Filterresults: notjunk:1;V03:K0:rvkHgLC6YtU=:1lhuhzxVTTU1JNfAkl+vf/ 90AKj6QzWFORUdF3ZPUlwrAdOuK+zkjufGremBQNuepVHv6C2NcZcGXAN9iWZwxmWA6V9nILs EvKzWikcl8MVSS9CCaSwvsHLGLR8idrz59YYYUs6BBVQKwKB0Dfq82bXtx+XdMC4EquTIRs/w Biof1ro/r1tj1PAqRtV1Qit/OTt/PTMEt+VhLuy1tKPUFGyc+LYWfIqR/X8wCiDQCwgIkV274 xk409DYQqtvrTF1qOiSGKvpqakJuONi6E7SJWfnF8AY/qg1zn/OxNygwzs8M1/nvpkVsLNI87 idNnKveYTixWgMDJefUwwV9SFza/3HKRd0IHjFMSEM6EbsDpexSHo3ULrnNCeVuJiWG2WVUMi 81JfN049H35wu1tA42DIwgDA5e+k43pSf6qr3OLriUhKbPNz6lSW7+jlAS3uH66xqnGQpbf4R f96PjyX0F1r6pe/UK5TWwB9kBG8EWSEmwyMXgTu31x3pZjp92IcFPyYH+WWXL1dK2OYYGR7EN APuMMI0BJLOW99EBfRDoSsN2y2QjcesZtvT/IwZQM+oT+RVEvY5/s4xb0FwrGFQp2tf/e4LId tkgqeI9ByhQRHpjZCnrRKRxFbqhbaA/IorPEhrjSSTUDTdkNCfhslSOrkbELiW5J6vWpsQHoA qp/jCDBHh3lgNiqlWdC3rv73Dt0mAogbcn8fI04U+G2/sgeW6ugU/yNFLs92BkjhAwM7eyxxy zCRkU2AzazIsOKO3/JpYvM/rlz0bOQ9cNmjnMt+7XQFL2mAqvfbTlZKg32jJ5jDw8TybWguak UZuHF5uzjzVPbnWe160416jcsqTdNHk+PeoeCEy3Z9s6IPJ/xg= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_101745_011942_C20D09C5 X-CRM114-Status: GOOD ( 22.60 ) 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 On Thu, Feb 24, 2022 at 7:07 AM Sai Prakash Ranjan wrote: > > From: Prasad Sodagudi > > 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 few > 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_write: __qcom_geni_serial_console_write+0x160/0x1e0 width=32 val=0xa0d5d addr=0xfffffbfffdbff700 > rwmmio_post_write: __qcom_geni_serial_console_write+0x160/0x1e0 width=32 val=0xa0d5d addr=0xfffffbfffdbff700 > rwmmio_read: qcom_geni_serial_poll_bit+0x94/0x138 width=32 addr=0xfffffbfffdbff610 > rwmmio_post_read: qcom_geni_serial_poll_bit+0x94/0x138 width=32 val=0x0 addr=0xfffffbfffdbff610 > > Signed-off-by: Prasad Sodagudi > Co-developed-by: Sai Prakash Ranjan > Signed-off-by: Sai Prakash Ranjan I think this is ok in general. I saw that Steve had a minor comment, and I suppose you could have just resent the same patches with a fixup in order to have me pick it up into the asm-generic tree for 5.19. There is one more thing that I saw looking through this patch again: the address you print is the virtual __iomem token, but it might be more valuable to have the physical address instead, which can be looked up in the devicetree to know which register is affected. There is a small extra cost to walk the page table, and I'm not sure if we actually have an interface for it (vmalloc_to_page is almost what we want, but it returns an invalid page pointer). Any suggestions on this? Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel