Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932309AbbHXRhd (ORCPT ); Mon, 24 Aug 2015 13:37:33 -0400 Received: from www.linutronix.de ([62.245.132.108]:47869 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbbHXRhb (ORCPT ); Mon, 24 Aug 2015 13:37:31 -0400 Date: Mon, 24 Aug 2015 19:37:00 +0200 (CEST) From: Thomas Gleixner To: Shenwei Wang cc: "shawn.guo@linaro.org" , "jason@lakedaemon.net" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Huang Anson Subject: RE: [PATCH v8 1/2] irqchip: imx-gpcv2: IMX GPCv2 driver for wakeup sources In-Reply-To: Message-ID: References: <1438378439-11569-1-git-send-email-shenwei.wang@freescale.com> <1438378439-11569-2-git-send-email-shenwei.wang@freescale.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2469 Lines: 69 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/