From patchwork Thu Jun 20 18:31:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 11007663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4000076 for ; Thu, 20 Jun 2019 18:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA7C271CB for ; Thu, 20 Jun 2019 18:32:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23468286A2; Thu, 20 Jun 2019 18:32:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91BCB271CB for ; Thu, 20 Jun 2019 18:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=StTI4+xQd1ZEbtovM48Bvx8Vnmzd1MtYG/fZiJtFPIA=; b=QT58xEPQrJuiy+ CXKe9IqMNE54G5akveo4cW+O6UeOO4y6fIymQwPmjP2xJcBFIi+Hz9vnAIHa3B4qfYDiFKMKI6EEw l4CfksPKwaEANd9mJBZVPr2bL1hUCQWtdCtRlL9fn+QmuW/+Qo56WHGERno/HP8IO+toyyj45NeNX BjT2s/WACCCvYtnwvAy/SdOlGgtQDKprHNwU8p3vuV97LzPk0KFYwm9xXjfJ+O0Uj2B/k96m4yZsI FMPYnCo0pcqAQXtclMQxRhprX6VZxRDbbeRNeSqDsHNWiKnfW1Wj5YADT5t3k8H4j7pLuW9G/UZA6 Iln7/L8D6m/Oe36ZmWlA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1he1rO-0007CI-Kb; Thu, 20 Jun 2019 18:32:34 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1he1r7-0006yG-ER for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2019 18:32:19 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BA64960DB3; Thu, 20 Jun 2019 18:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561055536; bh=Yd54+qUf89qOF87CitVUCGaXIbQK4BoasqCeVuWeJik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bhINcgFQmSP0r2XBbgbJhmxCMJOKm7bgNjFWkaLafMNVd6wSfWmbMl91DQnFfGNoI N3vhKUF/NxNllfJUp084sUZpa4fnhrmmfk5PeMA9Lvl6WAB6ENdDVfOXyePCNPi/YC TJ6yCTWu3JPyoqUpZ0HuIYZ3/jrorchAicjoERyM= Received: from blr-ubuntu-311.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DC15D6090F; Thu, 20 Jun 2019 18:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561055532; bh=Yd54+qUf89qOF87CitVUCGaXIbQK4BoasqCeVuWeJik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VtSqWPulOzdfF6hjpLIwlv7r/EnTnL/9N7eTlHVqqbNKJ/NwsufyIV+GXDENw5pCx OCbuGP+9/yyM5ZnI5GM8m239XXJ4VtvUZfIT7o/Iaf05RwxUXUQ8mKB5lx6bJRrafH SzczKGg+8/EHLSdhhyo9OlYP8IRkKWeUXTfqhvys= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DC15D6090F Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Mathieu Poirier , Suzuki K Poulose , Leo Yan , Rob Herring , devicetree@vger.kernel.org, Alexander Shishkin , Andy Gross , David Brown , Mark Rutland Subject: [PATCHv2 1/2] coresight: Do not default to CPU0 for missing CPU phandle Date: Fri, 21 Jun 2019 00:01:51 +0530 Message-Id: <92a33fa58c77206b338220427e92dabbd1d197f7.1561054498.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190620_113217_710028_722C06A8 X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sai Prakash Ranjan , Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sibi Sankar , Vivek Gautam , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Coresight platform support assumes that a missing "cpu" phandle defaults to CPU0. This could be problematic and unnecessarily binds components to CPU0, where they may not be. Let us make the DT binding rules a bit stricter by not defaulting to CPU0 for missing "cpu" affinity information. Also in coresight etm and cpu-debug drivers, abort the probe for such cases. Signed-off-by: Sai Prakash Ranjan Reviewed-by: Suzuki K Poulose --- Documentation/devicetree/bindings/arm/coresight.txt | 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ drivers/hwtracing/coresight/coresight-platform.c | 10 +++++----- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index 8a88ddebc1a2..c4659ba9457d 100644 --- a/Documentation/devicetree/bindings/arm/coresight.txt +++ b/Documentation/devicetree/bindings/arm/coresight.txt @@ -88,7 +88,7 @@ its hardware characteristcs. registers via co-processor 14. * cpu: the cpu phandle this ETM/PTM is affined to. When omitted the - source is considered to belong to CPU0. + affinity is set to invalid. * Optional property for TMC: diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index 07a1367c733f..58bfd6319f65 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -579,6 +579,9 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id) return -ENOMEM; drvdata->cpu = coresight_get_cpu(dev); + if (drvdata->cpu < 0) + return drvdata->cpu; + if (per_cpu(debug_drvdata, drvdata->cpu)) { dev_err(dev, "CPU%d drvdata has already been initialized\n", drvdata->cpu); diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 225c2982e4fe..e2cb6873c3f2 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -816,6 +816,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) } drvdata->cpu = coresight_get_cpu(dev); + if (drvdata->cpu < 0) + return drvdata->cpu; + desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu); if (!desc.name) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 7fe266194ab5..7bcac8896fc1 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -1101,6 +1101,9 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); drvdata->cpu = coresight_get_cpu(dev); + if (drvdata->cpu < 0) + return drvdata->cpu; + desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu); if (!desc.name) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 3c5ceda8db24..8b03fa573684 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -159,16 +159,16 @@ static int of_coresight_get_cpu(struct device *dev) struct device_node *dn; if (!dev->of_node) - return 0; + return -ENODEV; + dn = of_parse_phandle(dev->of_node, "cpu", 0); - /* Affinity defaults to CPU0 */ if (!dn) - return 0; + return -ENODEV; + cpu = of_cpu_node_to_id(dn); of_node_put(dn); - /* Affinity to CPU0 if no cpu nodes are found */ - return (cpu < 0) ? 0 : cpu; + return cpu; } /* From patchwork Thu Jun 20 18:31:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 11007683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07BEB112C for ; Thu, 20 Jun 2019 18:33:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC1D7271CB for ; Thu, 20 Jun 2019 18:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E026E286A2; Thu, 20 Jun 2019 18:32:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D235271CB for ; Thu, 20 Jun 2019 18:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6j98uOamcpZ3cCrWMD5iBvV0n7RaQkiQd6Fg+SNQjPk=; b=c7Ytfk418mn8lY nao8xSashvufZ6ioPwtGlOC4m68ugWBhVc0UyG+mvahx5dTyUC/yp/gBjI5IZEnLnj/JtkzZwe9Th usvNS9etHcj6/iD8KoswKK+O21mEirHEERNIoIKgGmUX7xSO5KD1gcnlHpAPAgiCGmV7KzHNkPJQK ODvbYTaqLeCmMveFylaaEF5bRuE3xqnePrAXr/XiLZuYOmBAkBQw8oAotI4WoC3S6fSv1FLxav7gf KTugwyB351bGrs0rIF2A1JQPKHRbKgjPfpaMVYJWwbqNZveXxC381TonndTJ404ui/BLMlDxsh+Yk ki2eo091ZlK6AgMExU+A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1he1rh-0007UM-KR; Thu, 20 Jun 2019 18:32:53 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1he1rN-0007Bn-Gy for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2019 18:32:35 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 581336115B; Thu, 20 Jun 2019 18:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561055552; bh=nNFaKlesrcQPjLvKVg+8OZfxjFS3WjlQjPLTlWJcIzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/om3z0q0f8XljaE59DwHsRfdyiHLxsOAcf6iUrv1qnyTZeOsEiyUeAwY5FL4KVUz aXJHp9LoZ7lowj8Zbc/IajfLUZs8y7Iebjl3fLHwPQDa1pqrb4tBDJfhBAQdDqMiKA Y4Psk7XdS+m6BsiQNdKa2aNFuQBfa/L0d+4t/cwA= Received: from blr-ubuntu-311.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F1216090F; Thu, 20 Jun 2019 18:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561055538; bh=nNFaKlesrcQPjLvKVg+8OZfxjFS3WjlQjPLTlWJcIzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNgid0dFyvbzzgJhV0wavktTRxxIC71szOjTKcejzQq7L/jgp+/VSgpMebQuNi4lC BmxBRW4V3a3c4LHGRYlCHFsIeF/pdiomhlFxdNVKAe56yjYCLBdPQlgmuDEnqK4VeW M5Me0a5DD4tHKbeiF5KZ3deov3zECjdUzjkWlizI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F1216090F Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Mathieu Poirier , Suzuki K Poulose , Leo Yan , Rob Herring , devicetree@vger.kernel.org, Alexander Shishkin , Andy Gross , David Brown , Mark Rutland Subject: [PATCHv2 2/2] coresight: Abort probe if cpus are not available Date: Fri, 21 Jun 2019 00:01:52 +0530 Message-Id: <65050e4cb2b0433f3cb9b1ca0bf6ec49d0751086.1561054498.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190620_113233_635746_609216CF X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sai Prakash Ranjan , Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sibi Sankar , Vivek Gautam , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently coresight etm and cpu-debug will go ahead with the probe even when corresponding cpus are not available and error out later in the probe path. In such cases, it is better to abort the probe earlier. Without this, setting *nosmp* will throw below errors: [ 5.910622] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 5.914266] coresight-cpu-debug 852000.debug: CPU1 debug arch init failed [ 5.921474] coresight-cpu-debug 854000.debug: CPU2 debug arch init failed [ 5.928328] coresight-cpu-debug 856000.debug: CPU3 debug arch init failed [ 5.935330] coresight etm0: CPU0: ETM v4.0 initialized [ 5.941875] coresight-etm4x 85d000.etm: ETM arch init failed [ 5.946794] coresight-etm4x: probe of 85d000.etm failed with error -22 [ 5.952707] coresight-etm4x 85e000.etm: ETM arch init failed [ 5.958945] coresight-etm4x: probe of 85e000.etm failed with error -22 [ 5.964853] coresight-etm4x 85f000.etm: ETM arch init failed [ 5.971096] coresight-etm4x: probe of 85f000.etm failed with error -22 Signed-off-by: Sai Prakash Ranjan --- drivers/hwtracing/coresight/coresight-platform.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 8b03fa573684..3f4559596c6b 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -168,6 +168,9 @@ static int of_coresight_get_cpu(struct device *dev) cpu = of_cpu_node_to_id(dn); of_node_put(dn); + if (num_online_cpus() <= cpu) + return -ENODEV; + return cpu; }