Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2372611rwl; Sun, 26 Mar 2023 22:07:23 -0700 (PDT) X-Google-Smtp-Source: AKy350b0P8F0TmQNDcJvF2z0Cepkiz9fb5dQ3GdSXFmkE09kgwFF99F5OBjPevWUjIXSfpYfnGT2 X-Received: by 2002:a17:902:f54b:b0:19c:ff5d:1fd2 with SMTP id h11-20020a170902f54b00b0019cff5d1fd2mr10524936plf.8.1679893643493; Sun, 26 Mar 2023 22:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679893643; cv=none; d=google.com; s=arc-20160816; b=h+Oxh3yVBqjWZxXE2srt9DpFQ+3xTtlNcxg9HvZcYn41O3gD+itf88+Im8+DDXSYSe GZr5U4cnWk7mSBpu+CNDCM8cs/3BYnwZfBg/T8MooT3Mkmbcf+6+SSR0AdtPMYYVi1D4 pAix8Z/MTVQsMZ5uvNvUmcqrqNny3BbbmuN4Eg5EEfEGcdZ08HeGfK/57al501hBl+Ih vkK8VZ1xXHxbN8J3hCHNCJa8JAyNLEYHtKoKp1R7PPjtECbCw9ieRdKNHySOG5Mug/8b IhGu6RacgjqWhLFDHTfm1rh/zKMueIYsfuztLdb/ftZXT19UGmu2SuciTCCVKAxTkQ2n Ngjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YNl48d59wlnYE63Gu5q16OOd0QVJNAHILkVXxCt2bhc=; b=thIny203DVGb5OnRM+eI9E9bUyJB4Q/4ezS17PHjdPJJT6abrkWFIWoorWtgcVSmoh cvOJJcJjul/r/07Xf/Gf2HoDu1OAjVGXgM2k1nySlRhgkFuKodovz3BgvPI4dcmGmx6/ 2AA1DRIWcWFqv3YjxUlG+O1PwmLXnYFmQW7zTEnaHMXWlwXSrn8H1EXzHO6pFm//US3J rPlj+0sD+RhwfhgwvzLRL7XnB4asmxihlHr+n1Ymsm8tfgFW2a56rUaHtyWcbwPZgKPT /dAROSFy5IPKGcuQeOdAiw1/L/1w1P+o6om+FBwSRcxmg/DHAiU7xF+4AIWe47MnD63/ m5Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170902cacd00b0019ced5a540csi24253555pld.370.2023.03.26.22.07.12; Sun, 26 Mar 2023 22:07:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbjC0FGH (ORCPT + 99 others); Mon, 27 Mar 2023 01:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbjC0FGB (ORCPT ); Mon, 27 Mar 2023 01:06:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C4DE4EC8; Sun, 26 Mar 2023 22:06:00 -0700 (PDT) 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 0DAB2C14; Sun, 26 Mar 2023 22:06:44 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.42.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6E51B3F73F; Sun, 26 Mar 2023 22:05:53 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, suzuki.poulose@arm.com Cc: scclevenger@os.amperecomputing.com, Anshuman Khandual , Rob Herring , Frank Rowand , Russell King , Greg Kroah-Hartman , "Rafael J. Wysocki" , Len Brown , Sudeep Holla , Lorenzo Pieralisi , Mathieu Poirier , Mike Leach , Leo Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 1/5] coresight: etm4x: Allocate and device assign 'struct etmv4_drvdata' earlier Date: Mon, 27 Mar 2023 10:35:33 +0530 Message-Id: <20230327050537.30861-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230327050537.30861-1-anshuman.khandual@arm.com> References: <20230327050537.30861-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allocate and device assign 'struct etmv4_drvdata' earlier during the driver probe, ensuring that it can be retrieved in power management based runtime callbacks if required. This will also help in dropping iomem base address argument from the function etm4_probe() later. Cc: Mathieu Poirier Cc: Suzuki K Poulose Cc: Mike Leach Cc: Leo Yan Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- .../coresight/coresight-etm4x-core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 1ea8f173cca0..10119c223fbe 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -2050,17 +2050,14 @@ static int etm4_add_coresight_dev(struct etm4_init_arg *init_arg) static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) { - struct etmv4_drvdata *drvdata; + struct etmv4_drvdata *drvdata = dev_get_drvdata(dev); struct csdev_access access = { 0 }; struct etm4_init_arg init_arg = { 0 }; struct etm4_init_arg *delayed; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) + if (WARN_ON(!drvdata)) return -ENOMEM; - dev_set_drvdata(dev, drvdata); - if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE) pm_save_enable = coresight_loses_context_with_cpu(dev) ? PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER; @@ -2112,6 +2109,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) { + struct etmv4_drvdata *drvdata; void __iomem *base; struct device *dev = &adev->dev; struct resource *res = &adev->res; @@ -2122,6 +2120,11 @@ static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) if (IS_ERR(base)) return PTR_ERR(base); + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + dev_set_drvdata(dev, drvdata); ret = etm4_probe(dev, base, id->id); if (!ret) pm_runtime_put(&adev->dev); @@ -2131,8 +2134,14 @@ static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) static int etm4_probe_platform_dev(struct platform_device *pdev) { + struct etmv4_drvdata *drvdata; int ret; + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + dev_set_drvdata(&pdev->dev, drvdata); pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); -- 2.25.1