From patchwork Wed Dec 13 14:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 13491058 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 4815EC4332F for ; Wed, 13 Dec 2023 14:01:56 +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: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:In-Reply-To:References: List-Owner; bh=fDIdSjBlQ1SyjuecJga4BeqmM+ISFZgmftpNCaFSiVc=; b=QIm+Ya7QCofY6k ODZw6wLCeJBFoDg5jOE8U4qD9bGcJJqjWc3AdOHQeWgp73itepMLoXoKK5gFojmQ/UYGAP9Cnp8PD 898XFknV9JHc9tpu9vLwNK7s2OnLrfPcdA5r6QMaVxkxOIqIMpKbRZI8YXX3tWQEqKCfQak+nhzIm o7zdjdNd0kExGaLIEJytKkI3/BxPJ2Ie/E1pOcE7eNFvxrJxY5F0r/ok9fkvyvAwKrqh4eg50KXya to+QqBmLCfDiIqoJYy/vo2hse5f0a0wsmLNmzSmLG83+tXSQaqhWt17ZZBYqCU/zrX5sq2SB1RCIs 1swWKWO0tmPsGqIqdN7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDPnf-00Evy9-06; Wed, 13 Dec 2023 14:01:23 +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 1rDPnc-00Evwu-14 for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2023 14:01:21 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BDE1IuP028512; Wed, 13 Dec 2023 08:01:18 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702476078; bh=IV6ikSPAmmlnSTHeM2+mRbfELz8qQ4FfHSx+eC/mlUY=; h=From:To:CC:Subject:Date; b=PwE8pVzJjyJcbHyHaYGXhmnl9I4NXVj0bMxdcSvf3SRMv9kea1UaeNu9GrnX+0qsI eJN9sfaQhIQsiVUl+b68pIvQ/Thx573uswizppIYRvuFSVDDHu1cS/eOrAyEN7G+bX fhsGHp6jU3bhBS5sfO4Rs2o+F/32YquXVXRr39N4= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BDE1Ibe015489 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Dec 2023 08:01:18 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 13 Dec 2023 08:01:18 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE110.ent.ti.com (10.64.6.31) 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; Wed, 13 Dec 2023 08:01:18 -0600 Received: from uda0132425.dhcp.ti.com (uda0132425.dhcp.ti.com [172.24.227.94]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BDE1FwW047173; Wed, 13 Dec 2023 08:01:16 -0600 From: Vignesh Raghavendra To: Wim Van Sebroeck , Guenter Roeck CC: Manorit Chawdhry , , , Vignesh Raghavendra , Subject: [PATCH v3] watchdog: rti_wdt: Drop runtime pm reference count when watchdog is unused Date: Wed, 13 Dec 2023 19:31:10 +0530 Message-ID: <20231213140110.938129-1-vigneshr@ti.com> X-Mailer: git-send-email 2.43.0 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-20231213_060120_451002_BCC61A94 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 Call runtime_pm_put*() if watchdog is not already started during probe and re enable it in watchdog start as required. On K3 SoCs, watchdogs and their corresponding CPUs are under same power-domain, 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 power-domain due to dangling reference count. Fixes: 2d63908bdbfb ("watchdog: Add K3 RTI watchdog support") Signed-off-by: Vignesh Raghavendra Reviewed-by: Guenter Roeck Tested-by: Manorit Chawdhry --- v3: Reword commit message to expand non std acronyms Collect Reviewed-by and Tested-by tags No code change v2: https://lore.kernel.org/r/20231122041642.2015936-1-vigneshr@ti.com v2: * Drop 1/2 (will be posted along with runtime_pm callbacks) * Use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() which takes care of err handling v1: https://lore.kernel.org/r/20231110100726.2930218-1-vigneshr@ti.com drivers/watchdog/rti_wdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 8e1be7ba0103..9215793a1c81 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -77,6 +77,11 @@ static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + int ret; + + ret = pm_runtime_resume_and_get(wdd->parent); + if (ret) + return ret; /* set timeout period */ timer_margin = (u64)wdd->timeout * wdt->freq; @@ -343,6 +348,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; err_iomap: @@ -357,7 +365,10 @@ 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); + + if (!pm_runtime_suspended(&pdev->dev)) + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); }