From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A5E4C169C4 for ; Fri, 8 Feb 2019 10:41:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD5B620863 for ; Fri, 8 Feb 2019 10:41:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k79WBicc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD5B620863 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wOGVHvFns1tDuKCjuN3OpUbx4NrgqIHnt0cEJ7Qs/fU=; b=k79WBiccx1K1SJ fS8x+wzq5wCDwu4VH+2qzwiw3ACtNmS6CvN6kqJvfQXg49YzQFxwfILEjyk28ztr5rZkmWtcdmsK3 oujrSjtSk/HOb8TJRNtQFgjV+kXLy9H3PuBZRnE56RL/V6dsQjzRfpPXwEPmPDAdWWJadM+KbdL7o ITiz1luvENSWS1CuD8qlzGbjy8G2XR+gdV3vMT4QR1WJ6syLT4wRMRW3px1FaboxRSUKgLTkMTb9/ DK4J9+a5ZjjjR2v7auI1lIx0kLwKV+54tHwRgXYLLXk17AIzH+GYnhZPpt42gcwlE8/TTt35NDmwJ +cfnqHZ3pTZ8NW5mkSjg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs3ae-0002vI-IR; Fri, 08 Feb 2019 10:41:00 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs3aa-0002uX-EE for linux-arm-kernel@lists.infradead.org; Fri, 08 Feb 2019 10:40:58 +0000 X-Originating-IP: 90.88.22.177 Received: from localhost (aaubervilliers-681-1-80-177.w90-88.abo.wanadoo.fr [90.88.22.177]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 3AFE31C0008; Fri, 8 Feb 2019 10:40:47 +0000 (UTC) From: Thomas Petazzoni To: Linus Walleij , Bartosz Golaszewski , Michal Simek Subject: [PATCH] gpio: zynq: properly support runtime PM for GPIO used as interrupts Date: Fri, 8 Feb 2019 11:40:46 +0100 Message-Id: <20190208104046.21817-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_024056_638723_8FC3F8DF X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Zynq GPIO driver currently implements runtime PM by: - Enabling runtime PM support in ->probe() and letting the runtime PM reference counter drop to zero at the end of ->probe(). - Increasing the runtime PM reference counter in ->request() and decreasing it in ->free(). However, the latter is not sufficient: when a GPIO is used as an interrupt, ->request() and ->free() are not called. Due to this, the runtime PM counter remains to zero when the only GPIOs in use are used as interrupts, causing them to simply not work. To address this problem, this commit implement the ->irq_request_resources() and ->irq_release_resources() hooks, ensuring that the runtime PM counter is properly incremented/decremented. Since we override the default hooks, we keep the existing behavior by making sure they call gpiochip_reqres_irq() / gpiochip_relres_irq() respectively. Signed-off-by: Thomas Petazzoni --- drivers/gpio/gpio-zynq.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 3f5fcdd5a429..65c0c29ce851 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -533,6 +533,26 @@ static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) return 0; } +static int zynq_gpio_irq_reqres(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + int ret; + + ret = pm_runtime_get_sync(chip->parent); + if (ret < 0) + return ret; + + return gpiochip_reqres_irq(chip, d->hwirq); +} + +static void zynq_gpio_irq_relres(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + gpiochip_relres_irq(chip, d->hwirq); + pm_runtime_put(chip->parent); +} + /* irq chip descriptor */ static struct irq_chip zynq_gpio_level_irqchip = { .name = DRIVER_NAME, @@ -542,6 +562,8 @@ static struct irq_chip zynq_gpio_level_irqchip = { .irq_unmask = zynq_gpio_irq_unmask, .irq_set_type = zynq_gpio_set_irq_type, .irq_set_wake = zynq_gpio_set_wake, + .irq_request_resources = zynq_gpio_irq_reqres, + .irq_release_resources = zynq_gpio_irq_relres, .flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED | IRQCHIP_MASK_ON_SUSPEND, }; @@ -554,6 +576,8 @@ static struct irq_chip zynq_gpio_edge_irqchip = { .irq_unmask = zynq_gpio_irq_unmask, .irq_set_type = zynq_gpio_set_irq_type, .irq_set_wake = zynq_gpio_set_wake, + .irq_request_resources = zynq_gpio_irq_reqres, + .irq_release_resources = zynq_gpio_irq_relres, .flags = IRQCHIP_MASK_ON_SUSPEND, }; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel