From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1886ECD13CF for ; Mon, 2 Sep 2024 14:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CSQrcrRl/wp02A0vZtdvQLT9FR6csXZc/MPrC7MM8Pc=; b=c87jeQSUqnhOhyHgrTuCjux6aH w8kfCtUcjE0/6Mb5NpU88bxJRcyjwUqqdb5eUv9v9Ge9TY2S+48+wsHG1KRbBO4JP5gsjIK9DJsQI K+Cl0GQIy79pac07DQsE0Xej2/tPVQISmLwJcrzHiiL2YgTswiJslkA+V7n0/qZrlzDjgNq7P8vQd +Ahkigfu0AXj4e7o1IH+XbcpYKFKd005bM3NxwpE61UD2QomfBEm2achJrBprjxb75SwantSwMvDF NUl5b1uF6ft8WH9jYa5kGSvpJTbpx4H/+H05rId5XYD4BIDaeT6NMOweEJkL/UxXXp7Gr914mjuaN n5SZG3Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8Nj-0000000EjUi-0LqA; Mon, 02 Sep 2024 14:50:15 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8Mo-0000000EjNd-30rR for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 14:49:20 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a86859e2fc0so484296066b.3 for ; Mon, 02 Sep 2024 07:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1725288556; x=1725893356; darn=lists.infradead.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=CSQrcrRl/wp02A0vZtdvQLT9FR6csXZc/MPrC7MM8Pc=; b=VfSo0BwMEfSC0g4DigSpzzvX1wmDbZHSBiKOleOTUoilKs7Sar32I+jKa3yv+3T3k1 HfdI4/nLWO41kNg1XzJQCwDm97ILOzGV3gdFZVtm0t//Wp3kNmIWMgXZaWhH6iqRHJQw lpoS0/pWnSRIc+d5AqG9N7UzEWLjyMe0K7ZCYkzeyYwbQfe4V8g4Kwc4/5DBuUD8VEHa u+EJoTW7ipFw7glRDJhV/Q9fGjPfAMjCu0U4Bj3aY/1uxwuxHw8jDJzsOC6PqdTI99Yc ySybcOik9x6lWSheNDenJVR8dxC540Dhlpt26E2hpvs1h0U+cJX2zsWNOumWpl7Gwq6U QL5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725288556; x=1725893356; 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=CSQrcrRl/wp02A0vZtdvQLT9FR6csXZc/MPrC7MM8Pc=; b=t/uy1IBMZwHDHyju5oeR/hcSmBKDRYNBrmAZ3AdeYcPxtRvSRhhI1Ygi6qzlUNku5P 629ANCOGHJ03uJw4fsc1LbsJA2GgS/MReDuRLeqK0j/S/ii1gC5Ok70y6O3h6b+FDQ0N rpUtxBIR1HHpBodg7Ok2nsDd53VHV20A8gsrVFycZ0FFEx62JW9sRpDQ2Sty/3DB6Ha1 93KU1nfqDwOmFuFkPB/TNY3Zw1gNhHbZZirPlrgv3A+69KXkIhrPKJMNw07KzTlZJitP mo9q32Y1tZgkX6nDyohPbq4XRbFLLctPmYNxnv1nkxsCYoQFG/K0kyns0Nt2xLOut29N DQoA== X-Forwarded-Encrypted: i=1; AJvYcCVuKbrrbbH0LBwx8WY2UoRwvSOTWYCB/NIzTZovZOIwyOGfekYp721G54yS+RkiUiaWsIaDg8omeK9H8sOOEZRr@lists.infradead.org X-Gm-Message-State: AOJu0YxCXvyDZaBB5jLWHi/QMvunOMQFaWIDvJWVl33/Txcau1zFzwno lhrYDiGrlCV3G2r4S6PLn40Fn4qTgqPJxNEJR+dRcSGNgCPK5tIgu0qTLjPtUa0= X-Google-Smtp-Source: AGHT+IGIdweTIHy3ncGoNoDMZ2ce0XHLLrTLA/WGs9kWHo0EafRW0/Aqg+sXCH6Br5tMoRggnn9Gtw== X-Received: by 2002:a17:907:7da0:b0:a7a:8da1:eb00 with SMTP id a640c23a62f3a-a897f7904d4mr1009653166b.7.1725288556372; Mon, 02 Sep 2024 07:49:16 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.144]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989196c88sm566746966b.102.2024.09.02.07.49.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Sep 2024 07:49:15 -0700 (PDT) Message-ID: Date: Mon, 2 Sep 2024 17:49:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Content-Language: en-US To: Alexandre Belloni 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 , kernel test robot References: <20240830130218.3377060-1-claudiu.beznea.uj@bp.renesas.com> <20240830130218.3377060-7-claudiu.beznea.uj@bp.renesas.com> <202408302225417622f1e7@mail.local> From: claudiu beznea In-Reply-To: <202408302225417622f1e7@mail.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_074918_797650_D4EE546C X-CRM114-Status: GOOD ( 24.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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