Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2034640imm; Thu, 24 May 2018 04:53:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrxRSJaBZ2DdP3S1esbqemP1Epmqp86NRm515M8Og3wM1iPhurJUD0SICoT19lyYfgfhpvi X-Received: by 2002:a62:ca98:: with SMTP id y24-v6mr6891721pfk.187.1527162815559; Thu, 24 May 2018 04:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162815; cv=none; d=google.com; s=arc-20160816; b=QseGiXDgw8bvcfn2ZNFpOQKKsM4QAKxZBDeuRvrXEp1I3Ahwkga6fu2juTjo8lWEH2 dFt48HHgA0Dy+Iu3gkhCT7X4QGbLw2oopihmQDYCWIEY6FQWjm8c/Rw0e3lO05B5Dk1U /TCA8eE6qXVo+si9/FMkTP6nmF4/pGGdN88DVKvI13mlqhrcDrEa81O8LRwbSAXPMJYT ediOYg2/YFso9BVOmslGmF0aIzuoJ8YDafPky2mYBs1oL8EB7GQN50M7Ym6hA2Afn3+p SsbGXrgfpxSrNiOo9gPZL/1/JSXqScTUoZEQM4vhpC57krql8WyM3tsf/HYAN6HzSlvR dumQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=eV/f8VF54vt8tNUkaTwHKgw0jxFJaUNbuaELQsvyxuE=; b=X3Pfc/W3cVUVVb+H6eA0D8+9c9770iKYKQNvqMFEu1T6nRRB03iPum6fT/Lswsw2Be u2ec4ZjdQE7o4XdVszGkIpHNJUYP5Ejgkq2Ig+a+xw55kgkHIFHTjmscHqdNCE+2d4tY Unh4RMw6hGdZjsveJbzhvD+x9CA+Yg8esdZkM3hRMzaO0mo9k95j2bOrUa6pydcJPTfE FvcO0l/lNZ0RD/bbrccbUzkNdoKy8RoZI0Asx0a9XXC+HnGlWcgPadk0Dg8mO9iKHCQ2 FiSJ30qDndpsad/8r324SmI1PhAL7TCvTGGdtVrkT+VBSrSnC3Q8kWcno+S2NNJ/kB5o kP5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L9K6WFNp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11-v6si4270753pgs.32.2018.05.24.04.53.20; Thu, 24 May 2018 04:53:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L9K6WFNp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969377AbeEXLwk (ORCPT + 99 others); Thu, 24 May 2018 07:52:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:57854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966510AbeEXJqc (ORCPT ); Thu, 24 May 2018 05:46:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE261208BA; Thu, 24 May 2018 09:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155191; bh=/XQE9WCv/NFmVH6JA0nw2AcbRDu4kbqzpQTinmatGTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9K6WFNpgVMPEGEUzKjsNQxBjbOTzm91m+vU+wMwPsuo51RmHo4QRdGxphGLPtQvr 93WkTjpc2PYlRZXVxzArTQACU0K4XwKLYgskAcwm/ZrcdjA62/ctgRtUJGlV4WwESg lDvBoDLFUjE+uIuxFXKMrCV1u+CUeWjhgcnSOSC0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Linus Walleij , Fabrizio Castro , Biju Das Subject: [PATCH 4.4 89/92] gpio: rcar: Add Runtime PM handling for interrupts Date: Thu, 24 May 2018 11:39:06 +0200 Message-Id: <20180524093207.768255027@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geert Uytterhoeven commit b26a719bdba9aa926ceaadecc66e07623d2b8a53 upstream. The R-Car GPIO driver handles Runtime PM for requested GPIOs only. When using a GPIO purely as an interrupt source, no Runtime PM handling is done, and the GPIO module's clock may not be enabled. To fix this: - Add .irq_request_resources() and .irq_release_resources() callbacks to handle Runtime PM when an interrupt is requested, - Add irq_bus_lock() and sync_unlock() callbacks to handle Runtime PM when e.g. disabling/enabling an interrupt, or configuring the interrupt type. Fixes: d5c3d84657db57bd "net: phy: Avoid polling PHY with PHY_IGNORE_INTERRUPTS" Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Walleij [fabrizio: cherry-pick to v4.4.y. Use container_of instead of gpiochip_get_data.] Signed-off-by: Fabrizio Castro Reviewed-by: Biju Das Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-rcar.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -200,6 +200,48 @@ static int gpio_rcar_irq_set_wake(struct return 0; } +static void gpio_rcar_irq_bus_lock(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, + gpio_chip); + + pm_runtime_get_sync(&p->pdev->dev); +} + +static void gpio_rcar_irq_bus_sync_unlock(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, + gpio_chip); + + pm_runtime_put(&p->pdev->dev); +} + + +static int gpio_rcar_irq_request_resources(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, + gpio_chip); + int error; + + error = pm_runtime_get_sync(&p->pdev->dev); + if (error < 0) + return error; + + return 0; +} + +static void gpio_rcar_irq_release_resources(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, + gpio_chip); + + pm_runtime_put(&p->pdev->dev); +} + static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) { struct gpio_rcar_priv *p = dev_id; @@ -460,6 +502,10 @@ static int gpio_rcar_probe(struct platfo irq_chip->irq_unmask = gpio_rcar_irq_enable; irq_chip->irq_set_type = gpio_rcar_irq_set_type; irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; + irq_chip->irq_bus_lock = gpio_rcar_irq_bus_lock; + irq_chip->irq_bus_sync_unlock = gpio_rcar_irq_bus_sync_unlock; + irq_chip->irq_request_resources = gpio_rcar_irq_request_resources; + irq_chip->irq_release_resources = gpio_rcar_irq_release_resources; irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; ret = gpiochip_add(gpio_chip);