From patchwork Fri Nov 10 10:07:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 13452285 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E33BEC4167B for ; Fri, 10 Nov 2023 10:08:12 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q4ibDiTQVxaN2w2FtS7fDUDjt2gDsXCYaD4TTb18Dg8=; b=QZsgtvdZl7RP/L SIJES8cWil7WWFvvk7LMObojF0XfoHAHV/GP+ZsqnVzm2mTiJfPlgTk1WT4GE8LUQpbgGe7XTq7fL p6m+SJ0lswuWKFH/1/s8oQZx3erBonEkyVKoFGgE6xG67nH+XW7rCFVgyegZCUXeOUOJ74KIKbIvC 0yApBI7melULIEvP0Wx89SniVQOSGk8ImCdCjpdS070y014yMSy2Q2hhOipgedAcKDekwPuRTkurV CBUKhIDey8ssIA2p6tmv4KHIyC8MHJgtN+uxlDVt9Glmb1pNxsrPu1WkAcpuCvb1bvXiBGJG2IH8N u88IfbTzivU+88PKMGGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r1OQS-008G9Z-15; Fri, 10 Nov 2023 10:07:44 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r1OQN-008G85-1M for linux-arm-kernel@lists.infradead.org; Fri, 10 Nov 2023 10:07:40 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3AAA7Y5d015876; Fri, 10 Nov 2023 04:07:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1699610854; bh=TBhNcMdYIYfOE3nmWstbO+Hog8z7g7tkR/0hU9Urw7A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=K4l61i8VdLOOk330swBJx8cC4Q5o++pyUe2BlospnkYgintcGzttYR8g6d3bnhe91 o5fiYberLk/9Iu+2Cb1C98oFbtKasXbwkZC2DD171dU0GgINueyIPbR+DKDuYrMvtx uAO34wvUIpA6hIcnxTGCdVD6yZJqMrk8SeFcrtQo= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3AAA7Yqj095147 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Nov 2023 04:07:34 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 10 Nov 2023 04:07:34 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 10 Nov 2023 04:07:34 -0600 Received: from uda0132425.dhcp.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3AAA7S4q051776; Fri, 10 Nov 2023 04:07:32 -0600 From: Vignesh Raghavendra To: Wim Van Sebroeck , Guenter Roeck CC: Tero Kristo , , , Vignesh Raghavendra , , , Subject: [PATCH 1/2] watchdog: rti_wdt: Use managed APIs to handle runtime PM Date: Fri, 10 Nov 2023 15:37:25 +0530 Message-ID: <20231110100726.2930218-2-vigneshr@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231110100726.2930218-1-vigneshr@ti.com> References: <20231110100726.2930218-1-vigneshr@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231110_020739_539462_5C924AE7 X-CRM114-Status: GOOD ( 13.47 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to devm_pm_runtime_enable() to simplify error handling in driver probe. Signed-off-by: Vignesh Raghavendra --- drivers/watchdog/rti_wdt.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 8e1be7ba0103..163bdeb6929a 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -236,12 +236,8 @@ static int rti_wdt_probe(struct platform_device *pdev) if (wdt->freq < 32768) wdt->freq = wdt->freq * 9 / 10; - pm_runtime_enable(dev); - ret = pm_runtime_resume_and_get(dev); - if (ret < 0) { - pm_runtime_disable(&pdev->dev); - return dev_err_probe(dev, ret, "runtime pm failed\n"); - } + devm_pm_runtime_enable(dev); + pm_runtime_get_noresume(dev); platform_set_drvdata(pdev, wdt); @@ -260,7 +256,7 @@ static int rti_wdt_probe(struct platform_device *pdev) wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) { ret = PTR_ERR(wdt->base); - goto err_iomap; + return ret; } if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) { @@ -286,7 +282,7 @@ static int rti_wdt_probe(struct platform_device *pdev) ret = rti_wdt_setup_hw_hb(wdd, wsize); if (ret) { dev_err(dev, "bad window size.\n"); - goto err_iomap; + return ret; } last_ping = heartbeat_ms - time_left_ms; @@ -301,7 +297,7 @@ static int rti_wdt_probe(struct platform_device *pdev) ret = of_address_to_resource(node, 0, &res); if (ret) { dev_err(dev, "No memory address assigned to the region.\n"); - goto err_iomap; + return ret; } /* @@ -312,15 +308,13 @@ static int rti_wdt_probe(struct platform_device *pdev) reserved_mem_size = resource_size(&res); if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) { dev_err(dev, "The size of reserved memory is too small.\n"); - ret = -EINVAL; - goto err_iomap; + return -EINVAL; } vaddr = memremap(paddr, reserved_mem_size, MEMREMAP_WB); if (!vaddr) { dev_err(dev, "Failed to map memory-region.\n"); - ret = -ENOMEM; - goto err_iomap; + return -ENOMEM; } if (vaddr[0] == PON_REASON_SOF_NUM && @@ -337,19 +331,13 @@ static int rti_wdt_probe(struct platform_device *pdev) ret = watchdog_register_device(wdd); if (ret) { dev_err(dev, "cannot register watchdog device\n"); - goto err_iomap; + return ret; } if (last_ping) watchdog_set_last_hw_keepalive(wdd, last_ping); return 0; - -err_iomap: - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - - return ret; } static void rti_wdt_remove(struct platform_device *pdev) @@ -357,8 +345,6 @@ static void rti_wdt_remove(struct platform_device *pdev) struct rti_wdt_device *wdt = platform_get_drvdata(pdev); watchdog_unregister_device(&wdt->wdd); - pm_runtime_put(&pdev->dev); - pm_runtime_disable(&pdev->dev); } static const struct of_device_id rti_wdt_of_match[] = { From patchwork Fri Nov 10 10:07:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 13452286 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 02D97C4167D for ; Fri, 10 Nov 2023 10:08:14 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0gVcNT4iF6H2Ld6OYpYdvHBi9tdCbx4ars5wLKSZZSM=; b=jgEBlE36YA1pxq Gvyblh4/n2+baaNQgoGdigyfFbMYl9SXcTOEPz5xOx8rI6kiGlfbQdVXEJTrhNRvgK+dcLIrDJDRp ZxixD9CgEnpAWGuv0E4dWUMwctKDfg9XOJVD24t+Tf/cQq3LO/Iy2TbQIgVfXXEhLPukbSFiNBBik H4d+Apc7Uc/x0HMkwd1Tf5yYr7z9RXUpx+vEOnrUlCeNuTElgk6S3NRYuFJ6zUsfVanCpg/nJ+2Bk 3FhArMKjx+8+2Dll5G8r8iju+XroD/YEMAUaNW7CdfC1k93dtvsnINdq/hvsOJalc3GJSfUpRPibP tWeaI/ZECbgYLg07bBxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r1OQS-008G9n-2p; Fri, 10 Nov 2023 10:07:44 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r1OQO-008G8b-1b for linux-arm-kernel@lists.infradead.org; Fri, 10 Nov 2023 10:07:41 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3AAA7bnJ112103; Fri, 10 Nov 2023 04:07:37 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1699610857; bh=mxg1FHFd1rRvOC36n+OHwsPn0OmqfcxRKRDGDy9uAcI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DT+hVshrjO7vdhNxIT15tWkNSdAqW0Duo9P8wf7DC4oVXlFVeWvxcg8bGpUOZEbTG Zjb+W7zqtG5NM5WAKE4iqXMkjL1jFW9y1buOnsrufpsoAd28YDouVEfTyZNRcnczXZ njvC/676o5TyQUiT7WVWDcqXMVL50ybbZvjty4BI= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3AAA7bKu003760 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Nov 2023 04:07:37 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 10 Nov 2023 04:07:37 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 10 Nov 2023 04:07:37 -0600 Received: from uda0132425.dhcp.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3AAA7S4r051776; Fri, 10 Nov 2023 04:07:35 -0600 From: Vignesh Raghavendra To: Wim Van Sebroeck , Guenter Roeck CC: Tero Kristo , , , Vignesh Raghavendra , , , Subject: [PATCH 2/2] watchdog: rti_wdt: Drop RPM watchdog when unused Date: Fri, 10 Nov 2023 15:37:26 +0530 Message-ID: <20231110100726.2930218-3-vigneshr@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231110100726.2930218-1-vigneshr@ti.com> References: <20231110100726.2930218-1-vigneshr@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231110_020740_612302_B4D70FF9 X-CRM114-Status: GOOD ( 11.97 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Do a RPM put if watchdog is not already started during probe and re enable it in watchdog start. On K3 SoCs, watchdogs and their corresponding CPUs are under same PD, so if the reference count of unused watchdogs aren't dropped, it will lead to CPU hotplug failures as Device Management firmware won't allow to turn off the PD due to dangling reference count. Fixes: 2d63908bdbfb ("watchdog: Add K3 RTI watchdog support") Signed-off-by: Vignesh Raghavendra --- drivers/watchdog/rti_wdt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 163bdeb6929a..87f2c333a41d 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -78,6 +78,9 @@ static int rti_wdt_start(struct watchdog_device *wdd) u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + if (pm_runtime_suspended(wdd->parent)) + pm_runtime_get_sync(wdd->parent); + /* set timeout period */ timer_margin = (u64)wdd->timeout * wdt->freq; timer_margin >>= WDT_PRELOAD_SHIFT; @@ -337,6 +340,9 @@ static int rti_wdt_probe(struct platform_device *pdev) if (last_ping) watchdog_set_last_hw_keepalive(wdd, last_ping); + if (!watchdog_hw_running(wdd)) + pm_runtime_put_sync(&pdev->dev); + return 0; } @@ -345,6 +351,9 @@ static void rti_wdt_remove(struct platform_device *pdev) struct rti_wdt_device *wdt = platform_get_drvdata(pdev); watchdog_unregister_device(&wdt->wdd); + + if (!pm_runtime_suspended(&pdev->dev)) + pm_runtime_put_sync(&pdev->dev); } static const struct of_device_id rti_wdt_of_match[] = {