From patchwork Wed Oct 24 17:10:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1639871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 206203FCF7 for ; Wed, 24 Oct 2012 17:12:43 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TR4Tj-00044s-L6; Wed, 24 Oct 2012 17:10:51 +0000 Received: from mail-da0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TR4Te-00044e-3Q for linux-arm-kernel@lists.infradead.org; Wed, 24 Oct 2012 17:10:48 +0000 Received: by mail-da0-f49.google.com with SMTP id q27so315717daj.36 for ; Wed, 24 Oct 2012 10:10:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=n00mdIrFnivvvMss/mBFYc0KZwrPmEoBKW47amXzWkM=; b=ZtIlT2t0BxhOJ11T/sw4BJ1iXxCgOy2QL0H1y8/0p5RvxF8B6ksudr20ljaKiTmfYB GrPwjrSmwrxrr5qGWF+YFKcejemLxPuRPfzjq1qdgNOiGlWpwCsiSB849rphTT32agIK NXbzKc4b5Qxovzp2UkxEmy9cgeDDix36sfNZTxzrV+VeNRQr8R072xxg+sarDuHSqZbE WajVF6g/a0p/dJTk69kAcUv8n1Gw5FGwCbLVAOTnTb2ZCD+rWOVVSR4kCQHAkq7P+HCF rMBQC2SKWnpIvupFnm1S9hsagJxNfJFbfSLMgtp12AALSI+JVbUzvyUe6yCzVWxHjRXW SI7g== Received: by 10.68.223.135 with SMTP id qu7mr51746040pbc.143.1351098644050; Wed, 24 Oct 2012 10:10:44 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id jx4sm1866488pbc.27.2012.10.24.10.10.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Oct 2012 10:10:43 -0700 (PDT) From: Kevin Hilman To: Linus Walleij , Felipe Balbi , linux-omap@vger.kernel.org Subject: [PATCH v2] gpio/omap: fix off-mode bug: clear debounce clock enable mask on free/reset Date: Wed, 24 Oct 2012 10:10:41 -0700 Message-Id: <1351098641-23917-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.8.0 X-Gm-Message-State: ALoCoQk3QkakzrcqN0i2kpKCyyh5TIoSC1FeyjZMszv2BExe3HfC9HGNtxtfZTvqerRgeyoQAEFs X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Paul Walmsley , Igor Grinberg , linux-arm-kernel@lists.infradead.org, Grazvydas Ignotas X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Kevin Hilman When a GPIO bank is freed or shutdown, ensure that the banks dbck_enable_mask is cleared also. Otherwise, context restore on subsequent off-mode transition will restore previous value from the shadow copies (bank->context.debounce*) leading to mismatch state between driver state and hardware state. This was discovered when board code was doing gpio_request_one() gpio_set_debounce() gpio_free() which was leaving the GPIO debounce settings in a confused state. If that GPIO bank is subsequently used with off-mode enabled, bogus state would be restored, leaving GPIO debounce enabled which then prevented the CORE powerdomain from transitioning. To fix, ensure that bank->dbck_enable_mask is cleared when the bank is freed/shutdown so debounce state doesn't persist. Special thanks to Grazvydas Ignotas for pointing out a bug in an earlier version that would've disabled debounce on any runtime PM transition. Reported-by: Paul Walmsley Cc: Igor Grinberg Cc: Grazvydas Ignotas Signed-off-by: Kevin Hilman --- v2: only clear mask in free/shutdown, not in runtime PM paths, clarified changelog Applies on v3.7-rc2. drivers/gpio/gpio-omap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 94cbc84..113b167 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -539,6 +539,7 @@ static void _reset_gpio(struct gpio_bank *bank, int gpio) _set_gpio_irqenable(bank, gpio, 0); _clear_gpio_irqstatus(bank, gpio); _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE); + bank->dbck_enable_mask = 0; } /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */