Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp61203lql; Fri, 12 Apr 2024 03:57:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGkdKnc3F6BCY4opdhWhOSbYy4ziGSY4+vLBTiVH/U97PZqmbShZHdnxhsYUA4xCNv0k2abHtr7pet97CqGxHMNCezxGCOAfy33XeB8w== X-Google-Smtp-Source: AGHT+IGV5HzPtA3tKGh7uPTc40pDjG0rWmAAhhYh2wn3nxZFJkqEKCa6MEtrucdbBAJ934uJ42TV X-Received: by 2002:a05:6870:12c3:b0:22e:bdec:8e5 with SMTP id 3-20020a05687012c300b0022ebdec08e5mr1764336oam.18.1712919443043; Fri, 12 Apr 2024 03:57:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712919443; cv=pass; d=google.com; s=arc-20160816; b=XFCiM/gafr14UY49tXnFxgyecWIShKJJ5iftjwqWsNzlz9MamvTVpcIRrxsUwktKtT NhSdspOamFjUSnRa2IkpNZZjrrkYlGdQ+bpAJAhbBe50X3fvh3caFUCdIPLHUXUHs7mb iN525oH+MBya3uLNnYhqgRAHDLOoXVqAF2Vop7AFpfLR/yYt6hdErHu/WYP0UcdetzTU IjzUOCvpJ1Xls6sOStmONqPMunS0dObkqPn+c08cPNGmLpJFeBXqiELSN4BloZxaPVmd RsMuHrLLlnjvFc90i8Ce/SSWbeemcR52JgFHp00DrdIy0bb+Ww2B4azPdTcgfwnn5MNU qAnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bfpDELhZMXS3a+UUIPdr1Q+y0EuPmA52WesKgXwm+Ms=; fh=pWJdMlQNMiDoenGYdLIBogccxfNHujSwY5gkvxZOPC0=; b=VhmO3Opgi7rTNRfa9eMzckva92Cih89BIJfZuwAE3hCxv80/EbgHOtyCpy4qMayvTn Jsi4erCKciCSgIYveeJ5KIh2A9LrIVh8v+Wh0Y8IoV9SpW/sRcrK6qJ6zOAYhFo10AFn z/uVp6vZScROJqbPDkilzdVEfSkC9YMRToZZPHyaMWpzbhdJ7s783b8Px6vbcscwn9hN Kb0bpfJmEi91ZAjl5KbM+VABu40WgE/jqX7o9KBIzrmOqG8DNqZIV8fPs61Crfg48Rc9 X2a7c4qd5wXtqOLC0kEFqPQzYtSnXSd4f3hyZJdJiD1GbbxdG/Xal8kIXG6fQPBgT/zl +Wlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=Lf0sUxq4; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-138663-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138663-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m38-20020a634c66000000b005dc892e61d3si3038041pgl.657.2024.04.12.03.57.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 03:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138663-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=Lf0sUxq4; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-138663-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138663-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A5BCA289A1C for ; Wed, 10 Apr 2024 13:51:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE08A181330; Wed, 10 Apr 2024 13:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Lf0sUxq4" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06117180A7D for ; Wed, 10 Apr 2024 13:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756485; cv=none; b=envp6JwtRpkOfw0AFKHl9c7JOZm66mYw1IOXC2SZOnyYxSpOR7kZ/e12m+LOCSqLC8kXCJjWdzlMct2PufjYDnSLL2py6hUtz/jXFbUhmdXckLiEA8FnaYIgI4gBxeIu95Ims7Z/i8PBp/o76ywIKGKhaG+PLkU0uuwm4nzQtZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756485; c=relaxed/simple; bh=CJ5Yg4Su25upi9PiRBilKHZBgxfV1yi9eo8lCkVdx7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a+ay+SeBWHRMg2zYjfYGFTQ5v8YgHYNcvAyIg33+7hAsvGjGk7l5PvHLLVtkIMCYnWM7+ujclFTSBH9LIPRlQ8HyKGnfoguhNV81Hsf+PU9kCOEsXBLyhJpfEv8UmmqhnOX4y3GNYfHDSF7Cjx1+NNTVzPnfV/7zf20YPDD9ZDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Lf0sUxq4; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4155819f710so53278055e9.2 for ; Wed, 10 Apr 2024 06:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1712756482; x=1713361282; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bfpDELhZMXS3a+UUIPdr1Q+y0EuPmA52WesKgXwm+Ms=; b=Lf0sUxq4UOs3C7KQX9/jUbg4WWL0HxKQYtHJ0eVFePeuWxpcTGK3pjOSU9ihvt0xds IDvkGrSrzp4kcU0hbrEOlf2b3FkX+F4MBaEFz/Jo1EQU5pxHJpoA5TKi54fq79ooxF5t F6EUNFUCUZY5V0j+Q6546Fv9smaI9MAbA8tMFNZUsHUrvq2Y4dmdOH1P8nRiHDXBtzXp iEOb6a4+Vz3kZ3mzEYge9GcWqJljpC1ZJBZnzWXvnYnlAKcDDHUs38vrx+39zcSPRbaF mPg2p3RfZm9XtIxYT4lbx2XOiohQ8ViDok2YHvedZWWo6M7aC25cTz3AjGKQoiTfZegC a1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712756482; x=1713361282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bfpDELhZMXS3a+UUIPdr1Q+y0EuPmA52WesKgXwm+Ms=; b=vHYDYImtj9qS3nwEnrLQa5269GCp6iRGCYfAC99dYupLmJcnjuDpdfeYVRUBC/jsCB l+6A+JwdNJQ0/FNu6uW87g3r7h0zAQcwXln/2a7Ty4TA4gotJ3btX7GZs9GEWRi9Wuqd QrsEaJcHavliOsly6qF+2JNHqst4EEd2fxL7fkYApx+ZxI9mAE3eZWW1Rxr2zEjMJ0Te kAggOWeN475RQe0yDiDBzO57Np8Di2+iNR6270MmXZNcVAFAGKWExMejeY5mOQQ1qqxG bmZ7nP+L0ggk71mz779IvjElLJpbCf5/ti7e6Gpd2pMLq5fGk+6GR1tSVVXeyqMaclnU MzGg== X-Forwarded-Encrypted: i=1; AJvYcCV6pLVIAO0/kQMT/1GdGh30cSY7pb1tOtZ8iRDdu0PUVBskUDTx9goWK+SFpFqQCFUI3TvZfv3k3ZstC3vLKVZelcdOh4fuq/eubyTH X-Gm-Message-State: AOJu0YwDYP5h4OvwWmQf83jqBOMc3JVWyNzC7b37onc16yS7bBU0eaC0 wMjuHSp3Jbh7vvUAyIiPHXe5LCHrp5piaCcGkQQSiF7Tb1Kb/S1hxbHRHkZTlvM= X-Received: by 2002:a05:600c:1914:b0:415:6d51:8e2d with SMTP id j20-20020a05600c191400b004156d518e2dmr2247721wmq.13.1712756482533; Wed, 10 Apr 2024 06:41:22 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.8]) by smtp.gmail.com with ESMTPSA id n15-20020a05600c500f00b00417c0fa4b82sm872528wmr.25.2024.04.10.06.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:41:22 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: wim@linux-watchdog.org, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, p.zabel@pengutronix.de, geert+renesas@glider.be, magnus.damm@gmail.com, biju.das.jz@bp.renesas.com Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH RESEND v8 09/10] watchdog: rzg2l_wdt: Power on the PM domain in rzg2l_wdt_restart() Date: Wed, 10 Apr 2024 16:40:43 +0300 Message-Id: <20240410134044.2138310-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410134044.2138310-1-claudiu.beznea.uj@bp.renesas.com> References: <20240410134044.2138310-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea The rzg2l_wdt_restart() is called from atomic context. Calling pm_runtime_{get_sync, resume_and_get}() or any other runtime PM resume APIs is not an option as it may lead to issues as described in commit e4cf89596c1f ("watchdog: rzg2l_wdt: Fix 'BUG: Invalid wait context'") that removed the pm_runtime_get_sync() and used directly the clk_prepare_enable() APIs. Starting with RZ/G3S the watchdog could be part of its own software controlled power domain (see the initial implementation in Link section). In case the watchdog is not used the power domain is off and accessing watchdog registers leads to aborts. To solve this the patch powers on the power domain using dev_pm_genpd_resume() API before enabling its clock. This is not sleeping or taking any other locks as the power domain will not be registered with GENPD_FLAG_IRQ_SAFE flags. Link: https://lore.kernel.org/all/20240208124300.2740313-1-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Claudiu Beznea --- Changes in v8: - none, this patch is new drivers/watchdog/rzg2l_wdt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index c8c20cfb97a3..98e5e9914a5d 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -164,6 +165,17 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); int ret; + /* + * The device may be part of a power domain that is currently + * powered off. We need to power it up before accessing registers. + * We don't undo the dev_pm_genpd_resume() as the device need to + * be up for the reboot to happen. Also, as we are in atomic context + * here there is no need to increment PM runtime usage counter + * (to make sure pm_runtime_active() doesn't return wrong code). + */ + if (!pm_runtime_active(wdev->parent)) + dev_pm_genpd_resume(wdev->parent); + clk_prepare_enable(priv->pclk); clk_prepare_enable(priv->osc_clk); -- 2.39.2