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 059E1C433EF for ; Mon, 18 Oct 2021 16:03:47 +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 C13EF6054E for ; Mon, 18 Oct 2021 16:03:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C13EF6054E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bh1hI2Q2WiOHf1avPx9pGWT03RpFY3Dnrf/r0uGXCek=; b=zUPxsDf+XXv5ZQ a1tNW4nTKWQDbTumJbPnWEiCQ246NZKx+O8jn839WXDVhK+ouIGFWAa5mZqA8tLjJkRrojjv/F/Eq Zf21XYOp8wBNFi1TAp5MpQHyUBBInHEYozk0/aVMrYpNE9bm/5P5YiAOiR5uV7uEHBNaqb+F2vANy um34dLc7QwZz1Xpa3QrLIFczbTLWBl/EKf7tsWlWozSSN6TAlk5PDCOrsDNRZPQlVLi7MbWV37r2P Z7REWfHDic0ehSeQamFzyXEG+4Kj56Rd7qMqPnI3nb0qEiQY0R1hml8Gezh6eCtzILtJetdB0dCqO a154E1he2p6RKYBYSlng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcV5a-00GRpa-DO; Mon, 18 Oct 2021 16:02:14 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcV5W-00GRoh-BH for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 16:02:11 +0000 Received: by mail-pj1-x1033.google.com with SMTP id pi19-20020a17090b1e5300b0019fdd3557d3so308470pjb.5 for ; Mon, 18 Oct 2021 09:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s2ngofAfTsCozTi9ujgBv7dfRkYBGqqYCREjpW1owbk=; b=AzTTda00cH6EjoSZE2TU6eqWuxaM41OMg5wWq98Q7ruZBaAs21R4APHt1M6fCZ44Mo 3fr/6ZuujTt0oA0seEC2zCfMS/Wd+UZ3EvFAV6aHxz2qHgkE0HMcWtooVtTXFvOMwSZw z11MDV5erllB8XY+DZi3RbDdmLvcS8LN/5xbD8IDuWJIznAIvSDh2owwd34ZyFTH3h+P ux/dDk3hU+9KOjLOY6BMk/R4Vm0cM0qFT0rBdiTns3FWpz5j/SGi47hXnsLO6wXrdp0i bfAQKbhtbYJLuikdC+qiR+PSTuwVS5FQvxvwt1p7d3sAJj0Vw4WjADGXTflNNgEZJxkX CLcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s2ngofAfTsCozTi9ujgBv7dfRkYBGqqYCREjpW1owbk=; b=12QvSKEjktkG03JlsFvgcyfYiCKj5YgCy30z6BbB+Ccc91E5qLdg0Z+VTnssU/SOPY XzTHX9py60HjpxWQWgWCMvyA83FBqZDWrjfAA50q1ciO2fG+eY0vLpdUnMb5xZQuPcOG Yi9+Gtece4V7AV27W3Y4TMzGK9UMBf74Orj6blO46TRIySTpa3JxdxHBrepgjERO002h rd56VzwuJoHaMq5MKlHUzAjsW85vda48qaCbDFfB89zbSkv0rJJEy0K3jSDLt7BIgcgE k0IaYaHZXUCX59W+IqrlpT83ZT7cEKh7/G5pl0b++cszJ5qqPGRl6AWoqUcPmbeXlOfZ U3Zw== X-Gm-Message-State: AOAM532B4p0eqRFQdGlFqVTFlX+I4O7tARsxAuYIFJQbHyVI2mwcPwTJ ttj/StrGxJeM/MVmcz6fkXEKHg== X-Google-Smtp-Source: ABdhPJw7ny/8h1dzHmObIk54C+X0gAjZCIP4Vvfb9Ov2mmx7TBaChFO+SiYxlakImmhe6UJHnvkm9A== X-Received: by 2002:a17:902:e5cb:b0:13f:25b7:4d50 with SMTP id u11-20020a170902e5cb00b0013f25b74d50mr27903318plf.38.1634572927197; Mon, 18 Oct 2021 09:02:07 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id f21sm3741947pfc.203.2021.10.18.09.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 09:02:04 -0700 (PDT) Date: Mon, 18 Oct 2021 10:02:02 -0600 From: Mathieu Poirier To: Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Bransilav Rankov , Anshuman Khandual , Mike Leach , Leo Yan Subject: Re: [PATCH v2] coresight: trbe: Defer the probe on offline CPUs Message-ID: <20211018160202.GE3163131@p14s> References: <20211014142238.2221248-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211014142238.2221248-1-suzuki.poulose@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211018_090210_423823_FEED0564 X-CRM114-Status: GOOD ( 26.10 ) 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, Oct 14, 2021 at 03:22:38PM +0100, Suzuki K Poulose wrote: > If a CPU is offline during the driver init, we could end up causing > a kernel crash trying to register the coresight device for the TRBE > instance. The trbe_cpudata for the TRBE instance is initialized only > when it is probed. Otherwise, we could end up dereferencing a NULL > cpudata->drvdata. > > e.g: > > [ 0.149999] coresight ete0: CPU0: ete v1.1 initialized > [ 0.149999] coresight-etm4x ete_1: ETM arch init failed > [ 0.149999] coresight-etm4x: probe of ete_1 failed with error -22 > [ 0.150085] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000050 > [ 0.150085] Mem abort info: > [ 0.150085] ESR = 0x96000005 > [ 0.150085] EC = 0x25: DABT (current EL), IL = 32 bits > [ 0.150085] SET = 0, FnV = 0 > [ 0.150085] EA = 0, S1PTW = 0 > [ 0.150085] Data abort info: > [ 0.150085] ISV = 0, ISS = 0x00000005 > [ 0.150085] CM = 0, WnR = 0 > [ 0.150085] [0000000000000050] user address but active_mm is swapper > [ 0.150085] Internal error: Oops: 96000005 [#1] PREEMPT SMP > [ 0.150085] Modules linked in: > [ 0.150085] Hardware name: FVP Base RevC (DT) > [ 0.150085] pstate: 00800009 (nzcv daif -PAN +UAO -TCO BTYPE=--) > [ 0.150155] pc : arm_trbe_register_coresight_cpu+0x74/0x144 > [ 0.150155] lr : arm_trbe_register_coresight_cpu+0x48/0x144 > ... > > [ 0.150237] Call trace: > [ 0.150237] arm_trbe_register_coresight_cpu+0x74/0x144 > [ 0.150237] arm_trbe_device_probe+0x1c0/0x2d8 > [ 0.150259] platform_drv_probe+0x94/0xbc > [ 0.150259] really_probe+0x1bc/0x4a8 > [ 0.150266] driver_probe_device+0x7c/0xb8 > [ 0.150266] device_driver_attach+0x6c/0xac > [ 0.150266] __driver_attach+0xc4/0x148 > [ 0.150266] bus_for_each_dev+0x7c/0xc8 > [ 0.150266] driver_attach+0x24/0x30 > [ 0.150266] bus_add_driver+0x100/0x1e0 > [ 0.150266] driver_register+0x78/0x110 > [ 0.150266] __platform_driver_register+0x44/0x50 > [ 0.150266] arm_trbe_init+0x28/0x84 > [ 0.150266] do_one_initcall+0x94/0x2bc > [ 0.150266] do_initcall_level+0xa4/0x158 > [ 0.150266] do_initcalls+0x54/0x94 > [ 0.150319] do_basic_setup+0x24/0x30 > [ 0.150319] kernel_init_freeable+0xe8/0x14c > [ 0.150319] kernel_init+0x14/0x18c > [ 0.150319] ret_from_fork+0x10/0x30 > [ 0.150319] Code: f94012c8 b0004ce2 9134a442 52819801 (f9402917) > [ 0.150319] ---[ end trace d23e0cfe5098535e ]--- > [ 0.150346] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b > > Fix this by skipping the step, if we are unable to probe the CPU. > > Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver") > Reported-by: Bransilav Rankov > Cc: Anshuman Khandual > Cc: Mathieu Poirier > Cc: Mike Leach > Cc: Leo Yan > Tested-by: Branislav Rankov > Signed-off-by: Suzuki K Poulose I have applied this patch. Thanks, Mathieu > --- > Changes since v1: > - Explain why we crash > - Add a WARN_ON to ensure the probe was successful. > --- > drivers/hwtracing/coresight/coresight-trbe.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c > index 5d350acef798..27225b88a2fc 100644 > --- a/drivers/hwtracing/coresight/coresight-trbe.c > +++ b/drivers/hwtracing/coresight/coresight-trbe.c > @@ -1182,6 +1182,10 @@ static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp > if (WARN_ON(trbe_csdev)) > return; > > + /* If the TRBE was not probed on the CPU, we shouldn't be here */ > + if (WARN_ON(!cpudata->drvdata)) > + return; > + > dev = &cpudata->drvdata->pdev->dev; > desc.name = devm_kasprintf(dev, GFP_KERNEL, "trbe%d", cpu); > if (!desc.name) > @@ -1286,7 +1290,9 @@ static int arm_trbe_probe_coresight(struct trbe_drvdata *drvdata) > return -ENOMEM; > > for_each_cpu(cpu, &drvdata->supported_cpus) { > - smp_call_function_single(cpu, arm_trbe_probe_cpu, drvdata, 1); > + /* If we fail to probe the CPU, let us defer it to hotplug callbacks */ > + if (smp_call_function_single(cpu, arm_trbe_probe_cpu, drvdata, 1)) > + continue; > if (cpumask_test_cpu(cpu, &drvdata->supported_cpus)) > arm_trbe_register_coresight_cpu(drvdata, cpu); > if (cpumask_test_cpu(cpu, &drvdata->supported_cpus)) > -- > 2.25.4 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel