From patchwork Fri May 19 05:21:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 96191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp998431vqo; Thu, 18 May 2023 22:24:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qqRJ4bHSNHnFD2cHsYtDJCu4i3wLRET8vO6+bnOzZFh5vNqr4HOmNnYt5ii9jkP+z/okj X-Received: by 2002:a05:6a21:3949:b0:104:3c82:38c0 with SMTP id ac9-20020a056a21394900b001043c8238c0mr790172pzc.41.1684473843476; Thu, 18 May 2023 22:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684473843; cv=none; d=google.com; s=arc-20160816; b=u+5J/QedPPZl0w6p6IA3mGm5RW1E5uf1bHJx1KdKIwSSZjrK/hAJ7+xjRHAPcCG0CM RsKS8fd159HUR28hiUZcWMdIhcAs8U0tZiHXmYtu9aoTk6w5LjxnT9MiUKCFbIsjdtFi RJB6QmRfDyibNI0wwE6Ae7tQJGeUxe6GjFlD0k7czjN/FuxR8lJdDfAL0GpLqCQ2Vdfq 0zHDOyOAtAJzaG/PGJuz1mJNheh/JdVRkwpGe2UBSysdVZ36s0GU/WF4RUlWDPdCe7b2 VM5cW9ybg9Xze64671i8wwyqLahgUbrjwDZZjnJyDOjK73rTof63j6QNuvzOqAZIuJz2 AqMw== 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=m+e1imscgxxfdaZ4eyi90ayYqSxq81Un1Qj+za5xbdU=; b=RdcdPb1/VWB7taGjpIz16LOoF8svucjatUwzRAp6P7eYeVO40X7q6eU4hKZV39L2sP EINqpD76F0gv9k9Aqb+PDtckUysTcDy/QFprb3bI3oMMquqzAsIVPTuqvmA9t7VoIuvj FL6sGSzvx2i9vc0ukVpz/t0HcNXfD/oeBNlWFts4ZBDXOuxobD+5+k1tB9cO3+ChuMJN JmvOSGwgiwuaihh8HbAsvcZxZpw+oxe94pFapkxwlOq4ZEJBK0vUXmgQS60txs86c5PR /DlQ1Fj78IRPzyO9DzagXE+CsbTz1KjjTxfmIDEdBwfwR6RHB8ngrb7qCMUrzmO5Jouv 4Xzg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a6566d4000000b00528b5b28439si2858717pgw.124.2023.05.18.22.23.48; Thu, 18 May 2023 22:24:03 -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 S230303AbjESFWU (ORCPT + 99 others); Fri, 19 May 2023 01:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjESFWM (ORCPT ); Fri, 19 May 2023 01:22:12 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 810C1E6B; Thu, 18 May 2023 22:22:11 -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 1174E2F4; Thu, 18 May 2023 22:22:56 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.71.125]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 956773F762; Thu, 18 May 2023 22:22:04 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, suzuki.poulose@arm.com Cc: Anshuman Khandual , Ganapatrao Kulkarni , Steve Clevenger , 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 Subject: [PATCH V3 1/6] coresight: etm4x: Allocate and device assign 'struct etmv4_drvdata' earlier Date: Fri, 19 May 2023 10:51:44 +0530 Message-Id: <20230519052149.1367814-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519052149.1367814-1-anshuman.khandual@arm.com> References: <20230519052149.1367814-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766298845115172827?= X-GMAIL-MSGID: =?utf-8?q?1766298845115172827?= 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 4c15fae534f3..7e96293c638f 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -2046,17 +2046,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; @@ -2108,6 +2105,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; @@ -2118,6 +2116,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); @@ -2127,8 +2130,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);