Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp72779lql; Fri, 12 Apr 2024 04:19:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfQADf1d/Q4nQ9/zDWr+RDXwSufcpCvee7Olrb04jFkHo1p9s7MhL9V9x7vQsmZvZkiBilX2rreS58PGxEBiS8gwai0RDlkp/hYDDLQA== X-Google-Smtp-Source: AGHT+IGTHSGGh7I8tiK/uj6ocMvwxeRPznNJ1IF6HE1QHQrB12uy0zbuu5C/hKIDvr59xG03vi9e X-Received: by 2002:a17:90a:e015:b0:2a2:f35f:f13c with SMTP id u21-20020a17090ae01500b002a2f35ff13cmr2039510pjy.46.1712920787374; Fri, 12 Apr 2024 04:19:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712920787; cv=pass; d=google.com; s=arc-20160816; b=HGFIXlGReVashHy007rUeYXPMf/vuFU8TwxmzRNtqPcX5xHiGMsLGruBPwngeQ63+S gZfYh/wNFoTynq+6ytDYkGQ0S7t7jBHEClUNkhEsmQ/DaeuLy/9EyEOcps1r86SLqEgh EW57gVmlxup4cKfo3yYpTLky5NrtQ/4eWzX5OlWGFajqUWVntd35XoNywrTRuKcBPlfP tRsJdgRmWbIx5Nvx3ODfuPXF4pR0bInNVHqooYmw6IXZMYFQEKrZF7i4/dlrnqu54FuF yHQWuBlOlU7+MwzygPY6JiY6U9rN6ZxgSdENiNKdzpPfPABt/iYn2rVXZ8zCGHKnSCIP 53EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=v5rDLo34QYHoVsmJR+qXt/vyD8JmocFWIjXhIAKbA2M=; fh=JnSzWAm0XI43kUqYbWtJtRFSrCzO1adpoxkUcZ9HTLQ=; b=DdHbv38vZRZrdGTvIdkPsdmeIC/a9i8rc2EiL0KbattfDUFNJcGBWVwo06+p7FY6Dd PdbeuhC6wYzv1QJ6P8w23AsWBz/CzbU03WbtegSgTSdHCuLcJpOAKFO9nuZJ3GdxNDSw votbP3b41OC/MarfNmh6Wcdvl7Hi+9z87UeHF7r0jTH8g3xKm0Auni+c6F+nKx39M52d cNXswfdRoJ9Xh3o0CPyZDNgnRJ6RLE0K/ejekm2Z+RGTtZ8oL6T+gSCvFLaY8lboWc6u x8MPocQe/lEwy9hw5hQCZJQNuxYd1XjFi8ymMRFGWDrd1WM2aERKeANxScBogDHcjdhQ jHDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mkJObC+U; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-142561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k93-20020a17090a4ce600b002a5295110besi5231194pjh.148.2024.04.12.04.19.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mkJObC+U; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-142561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 101AF284EBD for ; Fri, 12 Apr 2024 11:19:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 746CF5467B; Fri, 12 Apr 2024 11:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mkJObC+U" Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (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 21D4E53804 for ; Fri, 12 Apr 2024 11:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712920770; cv=none; b=KueHq6Fr+8EgqHJrDbjBvgmFrHwHTZ41dlt1hk8gYBj2E/CmLcV6jTtIM3z4TSit9VRxUFZQqWj+0RjsqM0BCsmwXqlvkJyBVhSOH8/b3Rz2Ny7/ZsJCnaNUEmGCB/gZv2njytnzC9H+rVakd9sDLaKyKK9ab5BeTPpCaGY7PGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712920770; c=relaxed/simple; bh=jJXQWARzxh60e8csc7f0AlY8R8u61wyoaZ5C9ACBeKc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=krIu/pHNz9uE6nw4WA4TGwKq0LbVkEfKea1rXKp2e5TTzY/UNwhsOodds/7b+DRoasSyr0ieI7uWqQ2lDHdRGJwCR7nIjH5tgSDriMrCjGYd1+hibRaBzni+9/DVuOkT7qDWmf3JcC49/un4jFij7dl5qXcYzGuyCAf1+p6K6F4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mkJObC+U; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-dcbef31a9dbso564512276.1 for ; Fri, 12 Apr 2024 04:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712920767; x=1713525567; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=v5rDLo34QYHoVsmJR+qXt/vyD8JmocFWIjXhIAKbA2M=; b=mkJObC+U8nDDJgklpIU2LoOmw05ZgepN0LI6hV8mIj+8ORTLPsMXz2BEsPNBXWYWwg bwkKqaJSOUZny7uJwMNVBWfbtQwG/bQgnmKHe5t572TgKJbqbsF0UVpQtII24Lb6qEpG y9FJsyUj4xrQxyPYOmShTpov9U3m6cJzzZASfQCHGa2o6MlI6U9E0YD+qGnHdonYTOIK fvMj0PW79tMCa3Fn/wsEH+rL3vBtI+xc0SEwbP+svld33oQzHaxkohDwQUwYBe0wB/jv VZ5pBXn4yKGdcDBXzbAlgPuk2vLLlka3ibPXdU00NO4GBYTRAWHknON4QLXgvFP9rRcc XgUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712920767; x=1713525567; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=v5rDLo34QYHoVsmJR+qXt/vyD8JmocFWIjXhIAKbA2M=; b=Zv3hCkqkdA7+Vny9tM7KxcbXtk6wm+QZGMii9af3BbdzzS0mBuB5XJ3uQ/kKo2Hc5d sAOgJpiCgJ2+GR2D0VgP5+mAQnQALgRDmf3iyf12EGlme1+FXVL8vUe6tzQl3vHXH1yz ead3e2kgzcXft7AeODeLlOiyCs77ECJMctwSO1dR1RKwL9pSayT8A14r85FefIIFe9Wx p6r4YwgzVCjJuPLXIJUaYoZ3qIbdE+KPKnqKpIlgL5vcgCPReB2EMmsWLlgeHbpvTIC0 JuvHqRYX6NPI2gQG5Q+OJjTI6lec/P0EAIdoJvmIn4aV0VOleWrh+gbnMBSHvg6Bn3qq UKiQ== X-Forwarded-Encrypted: i=1; AJvYcCV0q3Wqgz6FOb28ex64YFTJYUnGlaFoOTcYI47dK8jg3JdoVb7rTTegdcGHENRFV/0sXVgYRhuNK0u+oqC3GasUBK8UZ9b0/HnlwS7t X-Gm-Message-State: AOJu0Yx3kRyjjtg2V56VIManD7hR0iGukVIaDSw/h44TXHDzJYkKECEk uTjpGsUb1UAyARArONYXDjarSW4zfMVKRl6Ej7J6ptIRI4+0xMmfHyiWl4CZ7sIhzVlPxOIUQLz K4jhxYM7rc8/xl6aexDp33MHiz0w9IiyA/GrY8g== X-Received: by 2002:a25:2d07:0:b0:dcc:ae3:d8a0 with SMTP id t7-20020a252d07000000b00dcc0ae3d8a0mr2500615ybt.48.1712920767132; Fri, 12 Apr 2024 04:19:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240410134044.2138310-1-claudiu.beznea.uj@bp.renesas.com> <20240410134044.2138310-10-claudiu.beznea.uj@bp.renesas.com> In-Reply-To: <20240410134044.2138310-10-claudiu.beznea.uj@bp.renesas.com> From: Ulf Hansson Date: Fri, 12 Apr 2024 13:18:51 +0200 Message-ID: Subject: Re: [PATCH RESEND v8 09/10] watchdog: rzg2l_wdt: Power on the PM domain in rzg2l_wdt_restart() To: Claudiu Cc: 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, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Content-Type: text/plain; charset="UTF-8" On Wed, 10 Apr 2024 at 16:19, Claudiu wrote: > > 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. Calling clk_prepare_enable() doesn't work from an atomic context either as it may sleep on the clk prepare mutex. As I said in the other reply too, it looks like we need a different solution. I am not sure what, but I am happy to help discuss it. > > 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 Kind regards Uffe > --- > > 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 > >