From: tglx@linutronix.de (Thomas Gleixner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 1/2] irqchip: imx-gpcv2: IMX GPCv2 driver for wakeup sources
Date: Mon, 24 Aug 2015 19:37:00 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.11.1508241933150.3873@nanos> (raw)
In-Reply-To: <CY1PR0301MB084328829F8128A8FBFA6A9283620@CY1PR0301MB0843.namprd03.prod.outlook.com>
On Mon, 24 Aug 2015, Shenwei Wang wrote:
> > > +static int gpcv2_wakeup_source_save(void) {
> > > + struct gpcv2_irqchip_data *cd;
> > > + void __iomem *reg;
> > > + int i;
> > > +
> > > + cd = imx_gpcv2_instance;
> > > + if (!cd)
> > > + return 0;
> > > +
> > > + for (i = 0; i < IMR_NUM; i++) {
> > > + reg = cd->gpc_base + cd->cpu2wakeup + i * 4;
> > > + cd->enabled_irqs[i] = readl_relaxed(reg);
> >
> > You read the full state of the register and restore the full state. So why
> > enabled_irqs?
>
> There are two user scenarios:
> In CPU Idle state, the system need to be woke up by any enabled
> irqs, not just the ones that marked as wakeup sources.
> In Suspend State, they system will only be woke up by the one that
> marked as a wakeup source. Enabled_irqs are used to save the values
> before suspend, and restore them after resume.
That's what you want achieve. Still you save the full content of the
registers and restore the full content. That saves/restores the
enabled and disabled interrupts. So enabled_irqs is a misnomer as you
save the full state.
> > > + writel_relaxed(cd->wakeup_sources[i], reg);
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static void gpcv2_wakeup_source_restore(void) {
> > > + struct gpcv2_irqchip_data *cd;
> > > + void __iomem *reg;
> > > + int i;
> > > +
> > > + cd = imx_gpcv2_instance;
> > > + if (!cd)
> > > + return;
> > > +
> > > + for (i = 0; i < IMR_NUM; i++) {
> > > + reg = cd->gpc_base + cd->cpu2wakeup + i * 4;
> > > + writel_relaxed(cd->enabled_irqs[i], reg);
> > > + cd->wakeup_sources[i] = ~0;
> >
> > Why are you clearing that info on resume? Drivers will clear that via
> > set_wake() or leave it when they want to have resume functionality?
> >
> Each time system goes into the suspend state, it will call set_wake
> (ON) again to configure the wakeup sources. Clearing wakeup_sources
> here can make sure the system work as expected no matter that a
> driver calls set_wake (OFF) during resume stage.
We rather make sure that the drivers call set_wake(OFF) as they are
supposed to, because if they do not then the set_wake(ON) logic in the
core code will see the counter != 0 and not invoke the irq callback.
Thanks,
tglx
next prev parent reply other threads:[~2015-08-24 17:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 21:33 [PATCH v8 0/2] IMX GPCv2 drivers for wakeup source and suspend Shenwei Wang
2015-07-31 21:33 ` [PATCH v8 1/2] irqchip: imx-gpcv2: IMX GPCv2 driver for wakeup sources Shenwei Wang
2015-08-21 13:45 ` Shenwei Wang
2015-08-23 10:57 ` Thomas Gleixner
2015-08-24 16:09 ` Shenwei Wang
2015-08-24 17:37 ` Thomas Gleixner [this message]
2015-08-24 18:25 ` Shenwei Wang
2015-08-24 18:31 ` Thomas Gleixner
2015-07-31 21:33 ` [PATCH v8 2/2] ARM: imx: support suspend states on imx7D Shenwei Wang
2015-08-21 13:45 ` Shenwei Wang
2015-09-03 20:41 ` Shenwei Wang
2015-09-07 15:11 ` Shawn Guo
2015-09-08 15:01 ` Shenwei Wang
2015-09-18 14:15 ` Shawn Guo
2015-09-18 14:38 ` Shenwei Wang
2015-09-19 1:12 ` Shawn Guo
2015-10-01 16:31 ` Zhi Li
2015-10-08 6:37 ` Shawn Guo
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=alpine.DEB.2.11.1508241933150.3873@nanos \
--to=tglx@linutronix.de \
--cc=linux-arm-kernel@lists.infradead.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