Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp419816rdb; Tue, 23 Jan 2024 04:02:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJxdZbiSnyJwYcx2owp4khWOJi95yUD+b3BkqhEDDStp2R5sVqP6h9/2eaITDCWsIdSiqt X-Received: by 2002:a17:903:124b:b0:1d4:fd84:bee2 with SMTP id u11-20020a170903124b00b001d4fd84bee2mr3901837plh.7.1706011320439; Tue, 23 Jan 2024 04:02:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706011320; cv=pass; d=google.com; s=arc-20160816; b=Poml8QDoB6pHKElQmOAQIVmiDHP7A5FYL5SFnmrir9aOIiWLbeqDq5wr8HY45WBbUp tjNO3JP3oJLRc9ICULLyntLVThgY/PAqyBqCX+RjlcQ0l8GrYmEFnlj/dietRAIRVu0A 8OhtDgGjN5+1nhbSPbAnxyJTgGmZjmZnHAATtAUuXRFDTrN5l27CZkFjksSf8SdEpatZ A4NkIeUolzhOsrw5Z4Frs0nDPHGaE2MEmsPl3acp3QVazesnJQR0JTpbgQplsv1KAhI7 KOeCjspz+FZs56yLOwJyoWaVMbfk/0ZK4rmFCbJzd7/nruqJxQOW2uYn72Wi9b4dcy0A i0gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=k70FL9z5OR2fcCPzPC1Tv4cFtZ4jvd++KS4IHYlFyBc=; fh=JRWpiJNnMxQ/FjtJ40KFO4dufIi0M7hfPspkshMEEx4=; b=ciGL1j0+ql7CkJqrCnx7VnWuw9fSUwMV4wRqYD1eKSCpjl7VBeEvinqWLaAzgRZO3B H4r54UUmUl4nUdX5t1/P0bN0fd2r5M0+ZHQTPFf10GMtlbFEraqsjJtNeYj3XYcqm6Zv VDGM1SsoooOaW9Jd8jcM0/IOccSsUSfc8irszdhKQvU+LfsflYkY5L3vxIEndwOiYyXC 34oAnXDdgxnAOTEofjQ6kFuHoJS0q1m+Rqqu1v0GXSzhrMIWc0QTyOZRMAPLssor9pbQ BUukykq3BF/F3T/tCU7kqSLlvQkEWUW0acMBp/laEEFGzLL85556yIEgTFl9p9bWJWkv UJCw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=N65QHdAN; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-34814-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34814-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 n10-20020a170902d2ca00b001d4dff2c4desi6450880plc.24.2024.01.23.04.02.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 04:02:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34814-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=N65QHdAN; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-34814-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34814-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 40273288DE7 for ; Tue, 23 Jan 2024 07:13:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B35DF51C56; Tue, 23 Jan 2024 07:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="N65QHdAN" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 377C551034 for ; Tue, 23 Jan 2024 07:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705994016; cv=none; b=N0drRtJKaMoIgRidzm/02BcaynPFm/pWdU36lOfUa1i7XI+zhJa3QNA3bmk7zkj25mIR711oOh8IviCbFqHe7xqSAzAsElU1M9mBX2aUIbJHy5UBQpet0ul8TnPO97SAmm/2hXVjYss6AUEMywuigujJn8B1f7aLWihFU4PcnK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705994016; c=relaxed/simple; bh=V9MrJ3xkqEmgfOldwHpgezsCJyTx9RPzrV6ws6QWYKQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=i/c1ezYksA0MPVbRlSuoZlCR0et7BiL9wlKHQjuyrddWBggy3MIj02q1ZH/a4thq011cXKPFJT5Kk0Mk0+n4rKPnztodp3s9Y5OCBZKaa5ZRGCY6KSYt5HUSIGIf/Z7FHyNmkr0+GcNq36/pQxTGlISEf11B6eoHosqyv/4GnKo= 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=N65QHdAN; arc=none smtp.client-ip=209.85.218.46 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-ej1-f46.google.com with SMTP id a640c23a62f3a-a308e6824ccso117892166b.0 for ; Mon, 22 Jan 2024 23:13:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1705994013; x=1706598813; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=k70FL9z5OR2fcCPzPC1Tv4cFtZ4jvd++KS4IHYlFyBc=; b=N65QHdANN1T5BoOmG+C880NQ81UYwT6swtOkN9PdCruWf8LQOy8eR5zTFpm4Bg/+mD iyq1H7l/s4xvWWC/Hg+eRBxvIESq0mRKJo6lrHO7XrMLxWooQGMmOpwg/O3VvEjEcqnC w1sLL5sMSpsb9/1tZzCDdp401d8ZpVQSmCGx7HQoDfXM1oy7t6fU/YEXPShmQZdc1OIr nX0ZZHtd2/375w90zoQ0BCBEXAmIW9k4E5lCG2EAvZ5wTe7SYO8YINnG3i73L7f25kTZ nXEYpV8TVgHEQqtaCoMLH9oJKVXL7uvHsRHurgTnXZVrWwj2ttqRw3ADHxo1QrS2sTjZ ED7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705994013; x=1706598813; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k70FL9z5OR2fcCPzPC1Tv4cFtZ4jvd++KS4IHYlFyBc=; b=U8LQccnmtHFXVIorQvwfFqk6bIxw20vbJ+E5TStLn+TIUw+k3xErZ1H0LjhM3eexMr MkqecIM00Bc/sqJvAgJ5iat2q0/vya2Qf/y/kdpRZTLk/K0MchXZYuQdcfnGfz0LBnp6 hRf083SfCspX7joV03MZzP0u8S0F0mIWuU4b3cBaAHfzSG8X3YmFy+LI5d25a0QtVFJd DkLNDnl+6EdjzFpzYdcvJq8yhwxoUDeT37lHVE0MZFaLFIWzJwxtd1Zdph2v9XeCCaS7 f3MxgRfT+P/qGLI7OCUQUzqi1i9ZYjIHkQ7mtBIuXU9j0mJ99Q474uZwilTV3OBOatig loYw== X-Gm-Message-State: AOJu0Yy4+Bx+wxJAawWoR3gmNJ4afbQL5rPhmUSLQ6cUpPe/V4ILiUmN 04bbQ4dJfVHg5ih8ls4fLHvYzVVoGldGm8dIBZUQRZBMmLBfmlvif3JelCL9HVY= X-Received: by 2002:a17:906:bf42:b0:a30:b616:caac with SMTP id ps2-20020a170906bf4200b00a30b616caacmr265146ejb.41.1705994013419; Mon, 22 Jan 2024 23:13:33 -0800 (PST) Received: from [192.168.50.4] ([82.78.167.135]) by smtp.gmail.com with ESMTPSA id hw15-20020a170907a0cf00b00a2ed5d9ea19sm7011693ejc.190.2024.01.22.23.13.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 23:13:33 -0800 (PST) Message-ID: <2af40ace-2779-45a0-a244-e7e9e5cc510c@tuxon.dev> Date: Tue, 23 Jan 2024 09:13:30 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Content-Language: en-US To: Guenter Roeck , wim@linux-watchdog.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de, 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, linux-clk@vger.kernel.org, Claudiu Beznea References: <20240122111115.2861835-1-claudiu.beznea.uj@bp.renesas.com> <20240122111115.2861835-8-claudiu.beznea.uj@bp.renesas.com> From: claudiu beznea In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 22.01.2024 19:39, Guenter Roeck wrote: > On 1/22/24 03:11, Claudiu wrote: >> From: Claudiu Beznea >> >> The RZ/G3S supports deep sleep states where power to most of the IP blocks >> is cut off. To ensure proper working of the watchdog when resuming from >> such states, the suspend function is stopping the watchdog and the resume >> function is starting it. There is no need to configure the watchdog >> in case the watchdog was stopped prior to starting suspend. >> >> Signed-off-by: Claudiu Beznea >> --- >>   drivers/watchdog/rzg2l_wdt.c | 26 ++++++++++++++++++++++++++ >>   1 file changed, 26 insertions(+) >> >> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c >> index 9333dc1a75ab..186796b739f7 100644 >> --- a/drivers/watchdog/rzg2l_wdt.c >> +++ b/drivers/watchdog/rzg2l_wdt.c >> @@ -279,6 +279,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) >>       priv->wdev.timeout = WDT_DEFAULT_TIMEOUT; >>         watchdog_set_drvdata(&priv->wdev, priv); >> +    dev_set_drvdata(dev, priv); >>       ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, >> &priv->wdev); >>       if (ret) >>           return ret; >> @@ -300,10 +301,35 @@ static const struct of_device_id rzg2l_wdt_ids[] = { >>   }; >>   MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids); >>   +static int rzg2l_wdt_suspend_late(struct device *dev) >> +{ >> +    struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev); >> + >> +    if (!watchdog_active(&priv->wdev)) >> +        return 0; >> + >> +    return rzg2l_wdt_stop(&priv->wdev); >> +} >> + >> +static int rzg2l_wdt_resume_early(struct device *dev) >> +{ >> +    struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev); >> + >> +    if (!watchdog_active(&priv->wdev)) >> +        return 0; >> + >> +    return rzg2l_wdt_start(&priv->wdev); >> +} >> + >> +static const struct dev_pm_ops rzg2l_wdt_pm_ops = { >> +    LATE_SYSTEM_SLEEP_PM_OPS(rzg2l_wdt_suspend_late, >> rzg2l_wdt_resume_early) >> +}; >> + >>   static struct platform_driver rzg2l_wdt_driver = { >>       .driver = { >>           .name = "rzg2l_wdt", >>           .of_match_table = rzg2l_wdt_ids, >> +        .pm = pm_ptr(&rzg2l_wdt_pm_ops), > > I think this will create a build error if CONFIG_PM=n because rzg2l_wdt_pm_ops > will be unused but is not marked with __maybe_unused. The necessity of __maybe_unused has been removed along with the introduction of LATE_SYSTEM_SLEEP_PM_OPS() and friends (and *SET_*LATE_SYSTEM_SLEEP_PM_OPS along with the other helpers were marked deprecated for that) and we can use pm_ptr() along with LATE_SYSTEM_SLEEP_PM_OPS() to avoid build errors you mentioned. FYI, I just build the driver with CONFIG_PM=n and all good. > But then the driver > won't be > operational with CONFIG_PM=n, so I really wonder if it makes sense to > include any > such conditional code instead of making the driver depend on CONFIG_PM. That's true. The driver wouldn't work if the CONFIG_PM=n but then it depends on COMPILE_TEST which is exactly for this (just to compile test it for platforms that don't support it). I see many watchdog drivers depends on COMPILE_TEST. Give this, please let me know would you like me to proceed with it. Thank you, Claudiu Beznea > > I really don't think it is desirable to suggest that the driver would work > with > CONFIG_PM=n if that isn't really true. > > Guenter > >>       }, >>       .probe = rzg2l_wdt_probe, >>   }; >