Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2418423rbb; Wed, 28 Feb 2024 00:45:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0opA4CEZxUEr1bZQyj4Gu24B7hZOZZiKq0KJiDlS41cThiWv7Oitrn3Qm/yj5Jkz6MA46qW1Ds1xOABZM0IpalvSKD0csHTMztWuXSQ== X-Google-Smtp-Source: AGHT+IFJVtoJDU+j12sS42r47KebZh3JO7zRDuYiz+UeGAJ0nsRGU6P4NHqRHvaSsDpd94WBYPj1 X-Received: by 2002:a17:903:4296:b0:1dc:68b6:9243 with SMTP id ju22-20020a170903429600b001dc68b69243mr11134112plb.58.1709109958021; Wed, 28 Feb 2024 00:45:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709109958; cv=pass; d=google.com; s=arc-20160816; b=qJoEFp6Z/KsUeiHtZXqnZK3XQ1VVjEsGAfdE1jOLM2HB0/vCB2ePpvKJvitFicsa/E 7mwdjAy+9R32TWLuUWHglp4ncYta5JxeF3JhGALu2fOPR3S60G7E/GLs4xSBM45KOeS6 6Ojit+xQ+33jXrES1W6GhJXHcd4gZ2SDmxBPfYBaWnxUgra6tFCd2g4IiQpJHgOigwvp Inw4cM8V/yPjuZLcg7Meqyh8/6q/g+cLyKVRo9KgFgKW0NFNwXYfnZclj3fQgLBQi2+M fl7tWsDwI0d/syflFPDmXuyNRVgx0PoyotJduCNhYvYo1je5TfL7S3SUMCzAY/hokBnC VDJQ== 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=Q+V3L2zN30RajuobE+2SdYzeSnfcyv21XmIrKnrbFrY=; b=RI8pfiyoKL6JtQFZdVITmWashJwJ7sIMBQeGo1UOATAfCZ2NIzVSnnWF6WbcJac7n3 xyszkW4P58iMaOrb3ZGvKvqy+4sMT6xI8qDTG/oKNOroWGxATn8ZpRsSnU0YsTS+UEIP acZ8ccOimRkNTNqDFCtYvgkpavrtAgLxJbBPaXbF5GTer+jThi3wZS+rl5cQfGNo/IH6 jY7iJ7a7uvpJHCDgN9K3x7nxqZF7vNNUBIP7jiQOhp2gosdwjD6fuda8uOQ/etJs3not efMiS8KE+MxPFzyADWOIxOAHwGhDydXicQD2qAe5nyg9diUDNntXE2Xs+3AOyDGnHVQ5 TJ1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=IQcs0ODK; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-84685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84685-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o16-20020a170902779000b001dc42bd343bsi2834389pll.268.2024.02.28.00.45.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=IQcs0ODK; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-84685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84685-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5402EB27C1F for ; Wed, 28 Feb 2024 08:35:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA23338DE5; Wed, 28 Feb 2024 08:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="IQcs0ODK" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 E1098381AF for ; Wed, 28 Feb 2024 08:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709109210; cv=none; b=qLIyRQVhfcyWmeeCUAJ+lBTUInxARDo9/9YVLzhZORXHnvhIOYRH2OmBiiBG/MEmdi1un3RrajaWvbPHwDNzepkmRnhEWbBKqIc+jiiGlgkV/3aKHTFNt/Jo7L1DPXXKE1I3+JZPvQO2vtTz7lC6kAySdKSjA9yFUdMLaRgL0ac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709109210; c=relaxed/simple; bh=CJ5Yg4Su25upi9PiRBilKHZBgxfV1yi9eo8lCkVdx7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r+9E3OeF5h+ziNFxxhYcGVUkBRf2oUpljE/XTlDqHhqEz8NuGkCAlKbdRKBYIFx8ewqrt/k6Z+AkdpvYSgwmMEH0dG+4W5+v2SHX1gF/L1E+ZXDGOjjSSnu+hmg+M8qnUZ4Xpb3PPxM0vy7QhXl/pbZLd3Te96BNCP8U9fe/I0k= 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=IQcs0ODK; arc=none smtp.client-ip=209.85.208.43 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-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5648d92919dso6953440a12.1 for ; Wed, 28 Feb 2024 00:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1709109207; x=1709714007; 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=IQcs0ODKBBlEqzcRUnMR3PphfLdpm8uFtq6t6DplJCVhjYQyfNKbjPiB40fZPqwWOA aH2gMx1WBfmZGxKnhVFXzVDhIjHuAAdxDX1+xl/Z9a1dd4sM9Jibl7oWNPz2v0w3g6Mz jHH6BYUQh/tsMxeYXOzzX5RxoHDEXa9lervrxlDVMR7felSsHXMjowU3gjy2VNzDevpJ cAbD7kFHwMegwkaL4VfLF23a/c0uHyEwImKp9aAnjXl2bXJtQp8nVZNQRc7DzRV0wYua sv0S6P4gIyx94Js/x6cEs4kvRwpWFSNq3CnGaqH2I6+QcmVhSx/cMArAxM5y/1Tb+y4N 8F+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709109207; x=1709714007; 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=h8becMPp1LE6UKr0LnWz/yvFjvpfOEuOUzg1ppR+dv5SUQh0wo2B7Akw8ea2eZNrTC LEKKtPKHJpt6nQ8eY0Cfi3Mb/vJEjc0JJ+GIGmDRqOVXXhxCNdR+HIsMzXynJDQWMKXm GoVa0YE3acotcvuRDZUGdn/mPK3uMAnBZWNKtIJGtFqGntRsgDD82MeJAf0Cp8agGGv/ p//WSpPDN3TMC98oX/NmR5wngQffA1DLvSodXx4XyAy6GG4eQSXJdAdjNf1MC/zhOBaW qMXZr3A1820IIL70xp+Lk9HJ3qxaK6XlFB5i9sjLcjYZlIUyjYa65s7umpDz4b7u7A6T VBjw== X-Forwarded-Encrypted: i=1; AJvYcCU1OJrZ+JQHlHZS4X2jCEJ8CEV3LENiKDQgLLeyzm/lW3ASVrTR7dkays9Pv8qKmNLwZcXBjfLgzy/PHYfAN3/vL2wjFaMFbogJqGnU X-Gm-Message-State: AOJu0YxsmBttBg/V8UfEBatPGMRA8DiQ/A8oC0hsKCHnFSRdLHnAyXY1 cgNXl2USr+oQ+x2wXwsgXAivzxWCmeUy16Xscwulss8t5hUHNy/D0UTeqp9o93Y= X-Received: by 2002:a17:906:384f:b0:a3f:2d9c:c66b with SMTP id w15-20020a170906384f00b00a3f2d9cc66bmr8289281ejc.22.1709109207332; Wed, 28 Feb 2024 00:33:27 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.83]) by smtp.gmail.com with ESMTPSA id qh16-20020a170906ecb000b00a432777eb77sm1593987ejb.60.2024.02.28.00.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:33:26 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: wim@linux-watchdog.org, linux@roeck-us.net, robh@kernel.org, krzysztof.kozlowski+dt@linaro.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 v8 09/10] watchdog: rzg2l_wdt: Power on the PM domain in rzg2l_wdt_restart() Date: Wed, 28 Feb 2024 10:32:52 +0200 Message-Id: <20240228083253.2640997-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240228083253.2640997-1-claudiu.beznea.uj@bp.renesas.com> References: <20240228083253.2640997-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