mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: geert+renesas@glider.be, mturquette@baylibre.com,
	sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, magnus.damm@gmail.com,
	p.zabel@pengutronix.de, linux-renesas-soc@vger.kernel.org,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v3 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC
Date: Mon, 2 Sep 2024 17:49:14 +0300	[thread overview]
Message-ID: <a7f0a36b-3169-45f8-9169-50bb0c6c04dd@tuxon.dev> (raw)
In-Reply-To: <202408302225417622f1e7@mail.local>

Hi, Alexandre,

On 31.08.2024 01:25, Alexandre Belloni wrote:
> On 30/08/2024 16:02:12+0300, Claudiu wrote:
>> +	priv->rtc_dev->range_min = mktime64(2000, 1, 1, 0, 0, 0);
> 
> RTC_TIMESTAMP_BEGIN_2000

OK

> 
>> +	priv->rtc_dev->range_max = mktime64(2099, 12, 31, 23, 59, 59);
> 
> RTC_TIMESTAMP_END_2099

OK

> 
>> +
>> +	return devm_rtc_register_device(priv->rtc_dev);
>> +}
>> +
>> +static void rtca3_remove(struct platform_device *pdev)
>> +{
>> +	struct rtca3_priv *priv = platform_get_drvdata(pdev);
>> +
>> +	guard(spinlock_irqsave)(&priv->lock);
>> +
>> +	/* Disable alarm, periodic interrupts. */
>> +	rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0);
> 
> Why do you disable alarms on driver remove? I think you need to add a
> comment if this is because it can't system up, else this is a bad
> practice.

The RTC cannot power on the system after a power off. It can't also resume
it from a deep sleep state (when only the SoC area where the RTC resides
remains power on (there is no way to signal from RTC to the power supply
chain that an alarm happened)). It can only wake it up from s2idle mode
where all SoC components remains powered on.

Also, w/o this change the RTC remains blocked under the following scenarios
if the interrupts are not disabled in remove:

1/ Configure wake alarm and unbind the RTC driver with the following commands:
# echo +10 > /sys/class/rtc/rtc0/wakealarm
# echo /sys/bus/platform/drivers/rtc-rtca3/1004ec00.rtc > unbind
# sleep 12
# echo /sys/bus/platform/drivers/rtc-rtca3/1004ec00.rtc > bind

When rebinding the re-configuration of the RTC device times out:
[  121.854190] rtc-rtca3 1004ec00.rtc: error -ETIMEDOUT: Failed to setup
the RTC!
[  121.861511] rtc-rtca3 1004ec00.rtc: probe with driver rtc-rtca3 failed
with error -110
-sh: echo: write error: Connection timed out

2/ Configure wake alarm, unbind the RTC driver and switch to s2idle with
the following commands:
# echo s2idle > /sys/power/mem_sleep
# echo +10 > /sys/class/rtc/rtc0/wakealarm
# echo /sys/bus/platform/drivers/rtc-rtca/31004ec00.rtc > unbind
# echo mem > /sys/power/state
# #system is resumed by non RTC wakeup source (as the RTC alarm is not
working anymore in this case)
# echo /sys/bus/platform/drivers/rtc-rtca/1004ec00.rtc > bind

The system is not waked up from RTC alarm (as expected) and the rebinding
fails again:

[  172.483688] rtc-rtca3 1004ec00.rtc: error -ETIMEDOUT: Failed to setup
the RTC!
[  172.491003] rtc-rtca3 1004ec00.rtc: probe with driver rtc-rtca3 failed
with error -110
-sh: echo: write error: Connection timed out

3/ configure the RTC alarm, unbind and power off (with the following commands):
# echo +60 > /sys/class/rtc/rtc0/wakealarm
# echo /sys/bus/platform/drivers/rtc-rtca/1004ec00.rtc > unbind
# poweroff

The system is not started after 60 seconds and at the next reboot the RTC
configuration on probe is failing the same:

[    0.292068] rtc-rtca3 1004ec00.rtc: error -ETIMEDOUT: Failed to setup
the RTC!
[    0.292182] rtc-rtca3 1004ec00.rtc: probe with driver rtc-rtca3 failed
with error -110

In all scenarios the RTC is recovered only if removing/re-applying the
power to the SoC area where it resides.

These tests were done with the patches in this series and then I tried it
with the following diff on top of the patches in this series. The results
were the same:

diff --git a/drivers/rtc/rtc-renesas-rtca3.c b/drivers/rtc/rtc-renesas-rtca3.c
index 822c055b6e4d..720fdac3adc6 100644
--- a/drivers/rtc/rtc-renesas-rtca3.c
+++ b/drivers/rtc/rtc-renesas-rtca3.c
@@ -586,7 +586,7 @@ static int rtca3_initial_setup(struct clk *clk, struct
rtca3_priv *priv)
        usleep_range(sleep_us, sleep_us + 10);

        /* Disable alarm and carry interrupts. */
-       mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE;
+       mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE;
        ret = rtca3_alarm_irq_set_helper(priv, mask, 0);
        if (ret)
                return ret;
@@ -784,7 +784,7 @@ static void rtca3_remove(struct platform_device *pdev)
        guard(spinlock_irqsave)(&priv->lock);

        /* Disable alarm, periodic interrupts. */
-       rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0);
+       //rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0);
 }

Thank you,
Claudiu Beznea


  reply	other threads:[~2024-09-02 14:49 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 13:02 [PATCH v3 00/12] Add RTC support for the " Claudiu
2024-08-30 13:02 ` [PATCH v3 01/12] dt-bindings: clock: renesas,r9a08g045-vbattb: Document VBATTB Claudiu
2024-08-30 17:46   ` Rob Herring
2024-08-30 22:06     ` Alexandre Belloni
2024-09-02 14:55       ` claudiu beznea
2024-09-03  6:58   ` Biju Das
2024-09-03  7:23     ` Geert Uytterhoeven
2024-09-03  7:25       ` Biju Das
2024-09-03  7:29         ` Biju Das
2024-09-03  7:28     ` claudiu beznea
2024-09-03  7:36       ` Biju Das
2024-09-03  7:40         ` Geert Uytterhoeven
2024-09-03  7:44         ` claudiu beznea
2024-09-03  7:51           ` Biju Das
2024-10-10  9:58   ` Geert Uytterhoeven
2024-10-10 10:08   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 02/12] dt-bindings: clock: r9a08g045-vbattb: Add clock IDs for the VBATTB controller Claudiu
2024-08-30 17:47   ` Rob Herring
2024-10-10  9:55   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 03/12] clk: linux/clk-provider.h: Add devm_clk_hw_register_gate_parent_hw() Claudiu
2024-10-10 10:00   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 04/12] clk: renesas: clk-vbattb: Add VBATTB clock driver Claudiu
2024-10-10 10:06   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 05/12] dt-bindings: rtc: renesas,rzg3s-rtc: Document the Renesas RTCA-3 IP Claudiu
2024-08-30 15:44   ` Rob Herring (Arm)
2024-10-10  9:29   ` Geert Uytterhoeven
2024-10-10  9:52     ` claudiu beznea
2024-10-10 15:31       ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Claudiu
2024-08-30 22:25   ` Alexandre Belloni
2024-09-02 14:49     ` claudiu beznea [this message]
2024-09-02 20:28       ` Alexandre Belloni
2024-09-03  7:29         ` claudiu beznea
2024-09-03 16:09       ` claudiu beznea
2024-09-03 17:36         ` Alexandre Belloni
2024-10-17 10:45   ` Wolfram Sang
2024-10-17 10:51     ` Geert Uytterhoeven
2024-10-17 11:04       ` Wolfram Sang
2024-08-30 13:02 ` [PATCH v3 07/12] arm64: dts: renesas: r9a08g045: Add VBATTB node Claudiu
2024-09-03 19:48   ` Stephen Boyd
2024-09-04 12:17     ` claudiu beznea
2024-09-05 18:09       ` Stephen Boyd
2024-09-06  7:28         ` Geert Uytterhoeven
2024-09-06 23:01           ` Stephen Boyd
2024-09-09 12:11             ` Geert Uytterhoeven
2024-09-09 21:18               ` Stephen Boyd
2024-09-10  8:02                 ` Geert Uytterhoeven
2024-10-10 15:17   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 08/12] arm64: dts: renesas: r9a08g045: Add RTC node Claudiu
2024-10-10 15:22   ` Geert Uytterhoeven
2024-10-11 10:28     ` claudiu beznea
2024-10-16 22:03       ` Alexandre Belloni
2024-10-17  7:57         ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 09/12] arm64: dts: renesas: rzg3s-smarc-som: Enable VBATTB Claudiu
2024-10-10 15:28   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 10/12] arm64: dts: renesas: rzg3s-smarc-som: Enable RTC Claudiu
2024-10-10 15:28   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 11/12] arm64: defconfig: Enable VBATTB clock Claudiu
2024-10-10 15:29   ` Geert Uytterhoeven
2024-08-30 13:02 ` [PATCH v3 12/12] arm64: defconfig: Enable Renesas RTCA-3 flag Claudiu
2024-10-10 15:30   ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7f0a36b-3169-45f8-9169-50bb0c6c04dd@tuxon.dev \
    --to=claudiu.beznea@tuxon.dev \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=magnus.damm@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®