rtc-pm8xxx: Clear Alarm register on resume
Subsystems (2)
PATCH 1/1 rtc-pm8xxx: Clear Alarm register on resume
Currently, alarm register is not cleared on resume leading to reboot during power off charging mode.
--- drivers/rtc/rtc-pm8xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/rtc/rtc-pm8xxx.c +12 -1
@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, 2019, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2010-2011, 2019-2020, The Linux Foundation. All rights reserved. */ #include <linux/of.h> #include <linux/module.h>
@@ -301,6 +301,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;unsigned int ctrl_reg; +u8 value[NUM_8_BIT_RTC_REGS ] = {0 };spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags);
@@ -319,6 +320,16 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) goto rtc_rw_fail; } +/* Clear Alarm register */ +if (!enable) { + rc =regmap_bulk_write (rtc_dd->regmap, regs->alarm_rw, value, +sizeof (value)); +if (rc) { +dev_err (dev,"Write to RTC ALARM register failed\n" ); + goto rtc_rw_fail; + } + } + rtc_rw_fail:spin_unlock_irqrestore (&rtc_dd->ctrl_reg_lock, irq_flags);return rc;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Alexandre Belloni
maintainerHi,
Quoted 4 lines · Mohit Aggarwal
Currently, alarm register is not cleared on resume leading to reboot during power off charging mode.
Change-Id: Ie2e6bbab8aa46e4e9b9cc984181ffab557cbbdae
No Change-Id upstream please.
Quoted 25 lines
Signed-off-by Mohit Aggarwal <[email protected]>--- drivers/rtc/rtc-pm8xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/rtc/rtc-pm8xxx.c +2
-1@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, 2019, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2010-2011, 2019-2020, The Linux Foundation. All rights reserved. */ #include <linux/of.h> #include <linux/module.h> @@ -301,6 +301,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;unsigned int ctrl_reg; +u8 value[NUM_8_BIT_RTC_REGS ] = {0 };spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags);
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 326
Quoted 7 lines
drivers/rtc/rtc-pm8xxx.c +4
-0@@ -319,6 +320,16 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) goto rtc_rw_fail; } +/* Clear Alarm register */ +if (!enable) { + rc =regmap_bulk_write (rtc_dd->regmap, regs->alarm_rw, value, +sizeof (value));
This is not properly aligned.
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 328
Quoted 2 lines
drivers/rtc/rtc-pm8xxx.c +2
-0+if (rc) { +dev_err (dev,"Write to RTC ALARM register failed\n" );
Is that error message necessary? What would be the user action after seeing that in the logs? Will the logs actually be seen?
Quoted 4 lines
drivers/rtc/rtc-pm8xxx.c +4
-0+ goto rtc_rw_fail; + } + } +
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi,
Comments inline.
Thanks & Regards,
Mohit
-----Original Message-----
From: Alexandre Belloni <[email protected]>
Sent: Monday, March 16, 2020 3:59 PM
To: Mohit Aggarwal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] rtc-pm8xxx: Clear Alarm register on resume
Hi,
Quoted 4 lines · Mohit Aggarwal
Currently, alarm register is not cleared on resume leading to reboot during power off charging mode.
Change-Id: Ie2e6bbab8aa46e4e9b9cc984181ffab557cbbdae
No Change-Id upstream please.
[Mohit]: Will fix in next patch.
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device
Quoted 19 lines
Signed-off-by Mohit Aggarwal <[email protected]>--- drivers/rtc/rtc-pm8xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/rtc/rtc-pm8xxx.c index renamed from drivers/rtc/rtc-pm8xxx.c +0
-0bbe013f..96e7985 100644
drivers/rtc/rtc-pm8xxx.c +0
-1@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, 2019, The Linux Foundation. All rights reserved. */
drivers/rtc/rtc-pm8xxx.c +2
-0+/* Copyright (c) 2010-2011, 2019-2020, The Linux Foundation. All +rights reserved. */ #include <linux/of.h> #include <linux/module.h> @@ -301,6 +301,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device
*dev, unsigned int enable)
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device
Quoted 8 lines
drivers/rtc/rtc-pm8xxx.c +1
-0struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;unsigned int ctrl_reg; +u8 value[NUM_8_BIT_RTC_REGS ] = {0 };spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags);@@ -319,6 +320,16 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device
*dev, unsigned int enable)
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
Quoted 6 lines
drivers/rtc/rtc-pm8xxx.c +3
-0goto rtc_rw_fail; } +/* Clear Alarm register */ +if (!enable) { + rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw,
value,
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 326
Quoted 1 line
drivers/rtc/rtc-pm8xxx.c +1
-0+ sizeof(value));
This is not properly aligned.
[Mohit]: I don't see any alignment issue at my end. I can see proper tabs are present.
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device · line 328
Quoted 2 lines
drivers/rtc/rtc-pm8xxx.c +2
-0+if (rc) { + dev_err(dev, "Write to RTC ALARM register
failed\n");
Is that error message necessary? What would be the user action after seeing that in the logs? Will the logs actually be seen?
[Mohit]: In case issue in question reproduces even after this change then for debugging purposes user can look out for this error log in kernel logs which can help to triage the issue.
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 332
Quoted 4 lines
drivers/rtc/rtc-pm8xxx.c +4
-0+ goto rtc_rw_fail; + } + } +
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Alexandre Belloni
maintainerQuoted 63 lines · On 17/03/2020 10:20:36+0530, [email protected] wrote:
Hi,
Comments inline.
Thanks & Regards,
Mohit-----Original Message-----
From: Alexandre Belloni <[email protected]>
Sent: Monday, March 16, 2020 3:59 PM
To: Mohit Aggarwal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] rtc-pm8xxx: Clear Alarm register on resumeHi,
Quoted 4 lines · Mohit Aggarwal
Currently, alarm register is not cleared on resume leading to reboot during power off charging mode.
Change-Id: Ie2e6bbab8aa46e4e9b9cc984181ffab557cbbdae
No Change-Id upstream please.
[Mohit]: Will fix in next patch.drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device
Quoted 19 lines
Signed-off-by Mohit Aggarwal <[email protected]>--- drivers/rtc/rtc-pm8xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/rtc/rtc-pm8xxx.c index renamed from drivers/rtc/rtc-pm8xxx.c +0
-0bbe013f..96e7985 100644
drivers/rtc/rtc-pm8xxx.c +0
-1@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, 2019, The Linux Foundation. All rights reserved. */
drivers/rtc/rtc-pm8xxx.c +2
-0+/* Copyright (c) 2010-2011, 2019-2020, The Linux Foundation. All +rights reserved. */ #include <linux/of.h> #include <linux/module.h> @@ -301,6 +301,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device*dev, unsigned int enable)
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device
Quoted 8 lines
drivers/rtc/rtc-pm8xxx.c +1
-0struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;unsigned int ctrl_reg; +u8 value[NUM_8_BIT_RTC_REGS ] = {0 };spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags);@@ -319,6 +320,16 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device*dev, unsigned int enable)
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
Quoted 6 lines
drivers/rtc/rtc-pm8xxx.c +3
-0goto rtc_rw_fail; } +/* Clear Alarm register */ +if (!enable) { + rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw,value,
Quoted 6 lines
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 326
Quoted 1 line
drivers/rtc/rtc-pm8xxx.c +1
-0+ sizeof(value));This is not properly aligned.
[Mohit]: I don't see any alignment issue at my end. I can see proper tabs are present.
The alignment should match the opening parenthesis.
Quoted 10 lines
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device · line 328
Quoted 2 lines
drivers/rtc/rtc-pm8xxx.c +2
-0+if (rc) { + dev_err(dev, "Write to RTC ALARM registerfailed\n");
Is that error message necessary? What would be the user action after seeing that in the logs? Will the logs actually be seen?
[Mohit]: In case issue in question reproduces even after this change then for debugging purposes user can look out for this error log in kernel logs which can help to triage the issue.
Who in the field on the final product will see this error message? For debugging purposes, regmap already provides plenty of tracing facilities.
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Comments inline.
-----Original Message-----
From: Alexandre Belloni <[email protected]>
Sent: Tuesday, March 17, 2020 5:25 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] rtc-pm8xxx: Clear Alarm register on resume
Quoted 66 lines · On 17/03/2020 10:20:36+0530, [email protected] wrote:
Hi,
Comments inline.
Thanks & Regards,
Mohit-----Original Message-----
From: Alexandre Belloni <[email protected]>
Sent: Monday, March 16, 2020 3:59 PM
To: Mohit Aggarwal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] rtc-pm8xxx: Clear Alarm register on resumeHi,
Quoted 4 lines · Mohit Aggarwal
Currently, alarm register is not cleared on resume leading to reboot during power off charging mode.
Change-Id: Ie2e6bbab8aa46e4e9b9cc984181ffab557cbbdae
No Change-Id upstream please.
[Mohit]: Will fix in next patch.Quoted 20 lines
Signed-off-by Mohit Aggarwal <[email protected]>--- drivers/rtc/rtc-pm8xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/rtc/rtc-pm8xxx.c +0
-0index
bbe013f..96e7985 100644drivers/rtc/rtc-pm8xxx.c +0
-1@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, 2019, The Linux Foundation. All rights reserved. */
drivers/rtc/rtc-pm8xxx.c +2
-0+/* Copyright (c) 2010-2011, 2019-2020, The Linux Foundation. All +rights reserved. */ #include <linux/of.h> #include <linux/module.h> @@ -301,6 +301,7 @@ static int pm8xxx_rtc_alarm_irq_enable(structQuoted 1 line
device
*dev, unsigned int enable)
Quoted 9 lines
drivers/rtc/rtc-pm8xxx.c +1
-0struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;unsigned int ctrl_reg; +u8 value[NUM_8_BIT_RTC_REGS ] = {0 };spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags);@@ -319,6 +320,16 @@ static int pm8xxx_rtc_alarm_irq_enable(structdevice
*dev, unsigned int enable)
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
Quoted 6 lines
drivers/rtc/rtc-pm8xxx.c +3
-0goto rtc_rw_fail; } +/* Clear Alarm register */ +if (!enable) { + rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw,value,
Quoted 6 lines
drivers/rtc/rtc-pm8xxx.c static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) · line 326
Quoted 1 line
drivers/rtc/rtc-pm8xxx.c +1
-0+ sizeof(value));This is not properly aligned.
[Mohit]: I don't see any alignment issue at my end. I can see proper tabs are present.
The alignment should match the opening parenthesis. [Mohit]: Thanks for clarification. Uploaded new patch.
Quoted 10 lines
drivers/rtc/rtc-pm8xxx.c
Quoted 2 lines
drivers/rtc/rtc-pm8xxx.c +2
-0+if (rc) { + dev_err(dev, "Write to RTC ALARM registerfailed\n");
Is that error message necessary? What would be the user action after seeing that in the logs? Will the logs actually be seen? [Mohit]: In case issue in question reproduces even after this change then for debugging purposes user can look out for this error log in kernel logs which can help to triage the issue.
Who in the field on the final product will see this error message? For debugging purposes, regmap already provides plenty of tracing facilities. [Mohit]: This is mostly for debugging issues reported during internal tests using kernel logs. Also added the debug error log to remain in-line with other error logs in file.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com