Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5332799rdb; Wed, 13 Dec 2023 06:02:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjwwChiLvE8iGz4MFQbHZ6IXhppn9r7nlGC2GI5259yNC7jnld30oISGz76GG8akZu00ID X-Received: by 2002:a05:6808:211f:b0:3b9:e13b:6428 with SMTP id r31-20020a056808211f00b003b9e13b6428mr10863134oiw.4.1702476136162; Wed, 13 Dec 2023 06:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702476136; cv=none; d=google.com; s=arc-20160816; b=toojTNpiyJnXmH1aX9n25nowak7sjxrje5mBJwtt6y1SccGaAsWbjxChC1VuKY1dhj xrqo3R/bXP8ueoVQyZJbPujSzgC/2XDugH4HGNMPZj0pf63JHlcRWIcnKalTvdwn+K8P EzGWnqCgnS4WBGUl/neF0s6eDuRx0fP6aI1vwiieBp82kYnOynk7i8GK5DA/0MFaOA4w iPhYlzrSfySm0+RAvTW8Jijdm2MiiTONAHfbrh4pWptffKZQIPcQGx3dhphTDduiQ6mt xl0tVCNakRPh1h59QfV0LAyH68ok3t9mMORbdQQxbMHEvUU82X3Un/J45SvCY6O26J4Z rnAQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=IV6ikSPAmmlnSTHeM2+mRbfELz8qQ4FfHSx+eC/mlUY=; fh=rRUNZkuY4KZktQrIrDNS1Gd/6C8fsQOo12Ze00QgKh4=; b=bgFALtU5Zj1+nLK++8J+XDIj7a7+W6d4PNX7JMOy43Ps++7VKYTcmw39PRYEzQB3c2 9ESCXkE4UIFx5zj4uHNEhPnyXmZGVx3Ko/r+HAqikV+23xgUj2fEWcxkfBCFTpw7dk5p +kpYmnhRWpKKGuummSLtLmaT2RNJOLf9ZzTGUPSCbJ3QiQVLlW23LKAhV67VDXOV4MwG y+rnjOESlKIUKG50vkU8KiEbedfJ3CDmyG60Nea7N+/xMXDPjPYzQOqcRbCygPEIG7dv JUwfp/zvoa+uRLDHv6+r74LrDQbdEHVQ71vkUZ+q0ytTFzvRha9I0UJD1WpJQwh9bvN0 feuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PwE8pVzJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p11-20020a05680811cb00b003ba17113705si1452232oiv.285.2023.12.13.06.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:02:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PwE8pVzJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id AC07F8038B5B; Wed, 13 Dec 2023 06:01:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379288AbjLMOBn (ORCPT + 99 others); Wed, 13 Dec 2023 09:01:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235430AbjLMOB1 (ORCPT ); Wed, 13 Dec 2023 09:01:27 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8507010CB; Wed, 13 Dec 2023 06:01:33 -0800 (PST) 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:01:55 -0800 (PST) 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); } -- 2.43.0