From patchwork Fri Mar 17 03:04:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 71056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp119311wrt; Thu, 16 Mar 2023 20:16:01 -0700 (PDT) X-Google-Smtp-Source: AK7set9E6dwFdWY3TtOG+tbD2njxfblyX644RIfXQqbrQd1xtyj/GARXc7BakrWZFJOqCvkSgeTR X-Received: by 2002:a6b:651a:0:b0:71b:5cd7:fcd9 with SMTP id z26-20020a6b651a000000b0071b5cd7fcd9mr704183iob.20.1679022961715; Thu, 16 Mar 2023 20:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679022961; cv=none; d=google.com; s=arc-20160816; b=waVPGDm2hZFiSs4wrZq/D6Lzt9hXvtSbBXhPeV1k5PBsYrfJfONdVynr552JKbwwJg Mny219TkFRZ1Ml1JLfZ1+R4EFVRCiqfelrahrpx6QhX0DO+5UapO0SnI3sfTyi392EXG khhPEcz1aLIbyNV5KcGODDPDEsp6aGT2YOHm18PutP59b0q6EqMAfXLey3D82K8WuH/g dHNnwRMFPgGvpaFb4tpirGfZLuS4RSWgLrJ19k1PF2dYqVVyKTn4jK2IXMA7UFqqBNKt 6dw4pSVnK5dpH2mJ5y8bw3ac62S+x2ZfpjhlF/jza1jqQtzy8pprq5jR0Pz4y0gBa8s9 FUEA== 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=d9aZXm/V08i0dABcsMVIq0WMNn5jKRyEqjpDO22KgjeAJurtCpY1ebzIrpwSfIIDA+ Bd4tT7BbHHyRFWgwRasKhfOCEtdYro7JNZDOiO3Q98y/+cZaLJsaQUQp1X+jEpv1983i JPFgRgERaporrEQxQVYvXjijlSWac8yrc+BLFdrYxpOZgGM7mJoKSQONyKiAffLWtXDp fXoxgwyVmJ8lM9B3M3w4F5xkTZC9lFm5JqQkZcI2ZkQtCugS/wAfeTUJltWd2BAZdgYk /qpO7aGITMe5lx+OlcHVgBtAyGPKp+Tio1yxLK2EHl3HYYSd/PnKG2YNq7EblYBo1VYk 4mEA== 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 p6-20020a5ecb06000000b0074c8d0f0981si1004219iom.95.2023.03.16.20.15.42; Thu, 16 Mar 2023 20:16:01 -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 S229542AbjCQDFb (ORCPT + 99 others); Thu, 16 Mar 2023 23:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjCQDF3 (ORCPT ); Thu, 16 Mar 2023 23:05:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ECA31EC45; Thu, 16 Mar 2023 20:05:27 -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 63AFE1480; Thu, 16 Mar 2023 20:06:11 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.40.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CD4693F64C; Thu, 16 Mar 2023 20:05:21 -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 1/7] coresight: etm4x: Allocate and device assign 'struct etmv4_drvdata' earlier Date: Fri, 17 Mar 2023 08:34:55 +0530 Message-Id: <20230317030501.1811905-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317030501.1811905-1-anshuman.khandual@arm.com> References: <20230317030501.1811905-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 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?1760583181153563074?= X-GMAIL-MSGID: =?utf-8?q?1760583181153563074?= 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);