[01/17] rtc: pl031: remove misuse of IRQF_NO_SUSPEND flag

Message ID 1442850433-5903-2-git-send-email-sudeep.holla@arm.com
State New
Headers show

Commit Message

Sudeep Holla Sept. 21, 2015, 3:46 p.m.
The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
be left enabled so as to allow them to work as expected during the
suspend-resume cycle, but doesn't guarantee that it will wake the system
from a suspended state, enable_irq_wake is recommended to be used for
the wakeup.

This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/rtc/rtc-pl031.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Linus Walleij Oct. 2, 2015, 10:40 a.m. | #1
On Mon, Sep 21, 2015 at 8:46 AM, Sudeep Holla <sudeep.holla@arm.com> wrote:

> The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
> be left enabled so as to allow them to work as expected during the
> suspend-resume cycle, but doesn't guarantee that it will wake the system
> from a suspended state, enable_irq_wake is recommended to be used for
> the wakeup.
>
> This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
> introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: rtc-linux@googlegroups.com
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

Looks correct to me.
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sudeep Holla Oct. 2, 2015, 10:45 a.m. | #2
On 02/10/15 11:40, Linus Walleij wrote:
> On Mon, Sep 21, 2015 at 8:46 AM, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
>> The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
>> be left enabled so as to allow them to work as expected during the
>> suspend-resume cycle, but doesn't guarantee that it will wake the system
>> from a suspended state, enable_irq_wake is recommended to be used for
>> the wakeup.
>>
>> This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
>> introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.
>>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: Alessandro Zummo <a.zummo@towertech.it>
>> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>> Cc: rtc-linux@googlegroups.com
>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>
> Looks correct to me.
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>

Thanks, while you are at it, do you know what interrupt stv2_pl031
shares so that I can fix the TODO in the comment or the code(whichever
applicable).

Regards,
Sudeep
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Belloni Oct. 2, 2015, 1:16 p.m. | #3
On 02/10/2015 at 11:45:18 +0100, Sudeep Holla wrote :
> 
> 
> On 02/10/15 11:40, Linus Walleij wrote:
> >On Mon, Sep 21, 2015 at 8:46 AM, Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> >>The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
> >>be left enabled so as to allow them to work as expected during the
> >>suspend-resume cycle, but doesn't guarantee that it will wake the system
> >>from a suspended state, enable_irq_wake is recommended to be used for
> >>the wakeup.
> >>
> >>This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
> >>introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.
> >>
> >>Cc: Linus Walleij <linus.walleij@linaro.org>
> >>Cc: Alessandro Zummo <a.zummo@towertech.it>
> >>Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> >>Cc: rtc-linux@googlegroups.com
> >>Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> >
> >Looks correct to me.
> >Acked-by: Linus Walleij <linus.walleij@linaro.org>
> >
> 
> Thanks, while you are at it, do you know what interrupt stv2_pl031
> shares so that I can fix the TODO in the comment or the code(whichever
> applicable).
> 

So that you know, I'm planning to apply them this weekend, I couldn't
find time to do it before.
Alexandre Belloni Oct. 3, 2015, 3:20 p.m. | #4
On 21/09/2015 at 16:46:57 +0100, Sudeep Holla wrote :
> The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
> be left enabled so as to allow them to work as expected during the
> suspend-resume cycle, but doesn't guarantee that it will wake the system
> from a suspended state, enable_irq_wake is recommended to be used for
> the wakeup.
> 
> This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
> introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.
> 
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: rtc-linux@googlegroups.com
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/rtc/rtc-pl031.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
Applied, thanks.
Linus Walleij Oct. 5, 2015, 8:49 a.m. | #5
On Fri, Oct 2, 2015 at 12:45 PM, Sudeep Holla <sudeep.holla@arm.com> wrote:

>> Looks correct to me.
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>
> Thanks, while you are at it, do you know what interrupt stv2_pl031
> shares so that I can fix the TODO in the comment or the code(whichever
> applicable).

This is shared with a hardware called RTT (real-time timer) that has
no upstream driver as of now.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 41dcb7ddb906..e1687e19c59f 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -23,6 +23,7 @@ 
 #include <linux/io.h>
 #include <linux/bcd.h>
 #include <linux/delay.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/slab.h>
 
 /*
@@ -305,6 +306,8 @@  static int pl031_remove(struct amba_device *adev)
 {
 	struct pl031_local *ldata = dev_get_drvdata(&adev->dev);
 
+	dev_pm_clear_wake_irq(&adev->dev);
+	device_init_wakeup(&adev->dev, false);
 	free_irq(adev->irq[0], ldata);
 	rtc_device_unregister(ldata->rtc);
 	iounmap(ldata->base);
@@ -370,7 +373,7 @@  static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
 		}
 	}
 
-	device_init_wakeup(&adev->dev, 1);
+	device_init_wakeup(&adev->dev, true);
 	ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
 					THIS_MODULE);
 	if (IS_ERR(ldata->rtc)) {
@@ -383,7 +386,7 @@  static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
 		ret = -EIO;
 		goto out_no_irq;
 	}
-
+	dev_pm_set_wake_irq(&adev->dev, adev->irq[0]);
 	return 0;
 
 out_no_irq:
@@ -408,7 +411,6 @@  static struct pl031_vendor_data arm_pl031 = {
 		.set_alarm = pl031_set_alarm,
 		.alarm_irq_enable = pl031_alarm_irq_enable,
 	},
-	.irqflags = IRQF_NO_SUSPEND,
 };
 
 /* The First ST derivative */
@@ -422,7 +424,6 @@  static struct pl031_vendor_data stv1_pl031 = {
 	},
 	.clockwatch = true,
 	.st_weekday = true,
-	.irqflags = IRQF_NO_SUSPEND,
 };
 
 /* And the second ST derivative */
@@ -439,8 +440,10 @@  static struct pl031_vendor_data stv2_pl031 = {
 	/*
 	 * This variant shares the IRQ with another block and must not
 	 * suspend that IRQ line.
+	 * TODO check if it shares with IRQF_NO_SUSPEND user, else we can
+	 * remove IRQF_COND_SUSPEND
 	 */
-	.irqflags = IRQF_SHARED | IRQF_NO_SUSPEND,
+	.irqflags = IRQF_SHARED | IRQF_COND_SUSPEND,
 };
 
 static struct amba_id pl031_ids[] = {