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 04F2CC433FE for ; Thu, 24 Nov 2022 13:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229834AbiKXNcn (ORCPT ); Thu, 24 Nov 2022 08:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiKXNcl (ORCPT ); Thu, 24 Nov 2022 08:32:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4428D101FA for ; Thu, 24 Nov 2022 05:32:39 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F80C23A; Thu, 24 Nov 2022 05:32:45 -0800 (PST) Received: from [10.57.37.242] (unknown [10.57.37.242]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D86283F73B; Thu, 24 Nov 2022 05:32:37 -0800 (PST) Message-ID: Date: Thu, 24 Nov 2022 13:32:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] coresight: cti: Fix null pointer error on CTI init before ETM To: Mike Leach , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, leo.yan@linaro.org, acme@kernel.org References: <20221123193818.6253-1-mike.leach@linaro.org> From: Suzuki K Poulose In-Reply-To: <20221123193818.6253-1-mike.leach@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/11/2022 19:38, Mike Leach wrote: > When CTI is discovered first then the function > coresight_set_assoc_ectdev_mutex() is called to set the association > between CTI and ETM device. Recent lockdep fix passes a null pointer. > > This patch passes the correct pointer. > > Before patch: log of boot oops sequence with CTI discovered first: > > [ 12.424091] cs_system_cfg: CoreSight Configuration manager initialised > [ 12.483474] coresight cti_sys0: CTI initialized > [ 12.488109] coresight cti_sys1: CTI initialized > [ 12.503594] coresight cti_cpu0: CTI initialized > [ 12.517877] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized > [ 12.523479] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized > [ 12.529926] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized > [ 12.541808] coresight stm0: STM32 initialized > [ 12.544421] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized > [ 12.585639] coresight cti_cpu1: CTI initialized > [ 12.614028] coresight cti_cpu2: CTI initialized > [ 12.631679] CSCFG registered etm0 > [ 12.633920] coresight etm0: CPU0: etm v4.0 initialized > [ 12.656392] coresight cti_cpu3: CTI initialized > > ... > > [ 12.708383] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000348 > > ... > > [ 12.755094] Internal error: Oops: 0000000096000044 [#1] SMP > [ 12.761817] Modules linked in: coresight_etm4x(+) coresight_tmc coresight_cpu_debug coresight_replicator coresight_funnel coresight_cti coresight_tpiu coresight_stm coresight > [ 12.767210] CPU: 3 PID: 1346 Comm: systemd-udevd Not tainted 6.1.0-rc3tid-v6tid-v6-235166-gf7f7d7a2204a-dirty #498 > [ 12.782827] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) > [ 12.793154] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) > [ 12.800010] pc : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight] > [ 12.806694] lr : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight] > > ... > > [ 12.885064] Call trace: > [ 12.892352] coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight] > [ 12.894693] cti_add_assoc_to_csdev+0x144/0x1b0 [coresight_cti] > [ 12.900943] coresight_register+0x2c8/0x320 [coresight] > [ 12.906844] etm4_add_coresight_dev.isra.27+0x148/0x280 [coresight_etm4x] > [ 12.912056] etm4_probe+0x144/0x1c0 [coresight_etm4x] > [ 12.918998] etm4_probe_amba+0x40/0x78 [coresight_etm4x] > [ 12.924032] amba_probe+0x11c/0x1f0 > > After patch: similar log > > [ 12.444467] cs_system_cfg: CoreSight Configuration manager initialised > [ 12.456329] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized > [ 12.456754] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized > [ 12.469672] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized > [ 12.476098] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized > [ 12.532409] coresight stm0: STM32 initialized > [ 12.533708] coresight cti_sys0: CTI initialized > [ 12.539478] coresight cti_sys1: CTI initialized > [ 12.550106] coresight cti_cpu0: CTI initialized > [ 12.633931] coresight cti_cpu1: CTI initialized > [ 12.634664] coresight cti_cpu2: CTI initialized > [ 12.638090] coresight cti_cpu3: CTI initialized > [ 12.721136] CSCFG registered etm0 > > ... > > [ 12.762643] CSCFG registered etm1 > [ 12.762666] coresight etm1: CPU1: etm v4.0 initialized > [ 12.776258] CSCFG registered etm2 > [ 12.776282] coresight etm2: CPU2: etm v4.0 initialized > [ 12.784357] CSCFG registered etm3 > [ 12.785455] coresight etm3: CPU3: etm v4.0 initialized > > Error can also be triggered by manually starting the modules using modprobe > in the following order: > > root@linaro-developer:/home/linaro/cs-mods# modprobe coresight > root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-cti > root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-etm4x > > Tested on Dragonboard DB410c > Applies to coresight/next > It is not just the NULL pointer reference, but also the code is using wrong "device" as csdev. The patch looks good to me. I will queue this Suzuki