From patchwork Fri Jun 23 13:03:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 9806547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2E7560329 for ; Fri, 23 Jun 2017 13:06:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1FFA285FB for ; Fri, 23 Jun 2017 13:06:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95CF828773; Fri, 23 Jun 2017 13:06:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46642285FB for ; Fri, 23 Jun 2017 13:06:13 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=2TkKq4lasLgvoFFUkm8QZcKDP+sP4ya3vfv1IFu6fxk=; b=oUf eYI2qrra6L8fCOiK2aR9MUBd9esCX0jdCEy4IP3VSRUhCVz0THNy/vwEkWVIStYRt/xyYmdWLMRBb SpPnosRRSUKrnSWiqBz9F1B+MbIAzhTxsRworyPjG5msau+/Es1A6C1Bm9teSoHg7F9Fxng8Ze+0U jCn2hbmhq+mHZHb5my8u6mr1Zk7/jdlMVM+NnmO7L8H6UG1fi8ls78CzxKM4oJldCsWmvIQoRt4Zl Gaozw94e0ODONYEe3QoTG9aLWdHzS6yt9USgdkgzoYsVhnDfXOkouSCd4VGb7oI/Kb659ALeQawQf id0KcvfQXloIhDLRpkLMNn9ufgFih3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOOHr-0008Mh-HT; Fri, 23 Jun 2017 13:06:11 +0000 Received: from regular1.263xmail.com ([211.150.99.132]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOOFx-0005CP-SE; Fri, 23 Jun 2017 13:04:16 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.83]) by regular1.263xmail.com (Postfix) with ESMTP id 23FFB93CD; Fri, 23 Jun 2017 21:03:42 +0800 (CST) X-263anti-spam: X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 65649323; Fri, 23 Jun 2017 21:03:39 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <357224104010de80d2a06233f081f12d> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 286145TM881; Fri, 23 Jun 2017 21:03:43 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Subject: [RFC PATCH] pinctrl: rockchip: add irq_shutdown Date: Fri, 23 Jun 2017 21:03:39 +0800 Message-Id: <1498223019-9123-1-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_060414_319902_3A2A180D X-CRM114-Status: UNSURE ( 5.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, heiko@sntech.de, linux-gpio@vger.kernel.org, Linus Walleij , Jeffy Chen , dianders@chromium.org, tfiga@chromium.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the rockchip pinctrl driver would try to enable/disable the gpio bank clk when enable/disable an irq. So when the irq core trying to shutdown an already disabled irq, it would result in unbalanced clk disable request: [ 35.911955] WARNING: at drivers/clk/clk.c:680 ... [ 37.272271] Call trace: [ 37.274729] [] clk_core_disable+0x28/0x194 [ 37.280395] [] clk_disable+0x34/0x48 [ 37.285544] [] rockchip_irq_disable+0x30/0x3c [ 37.291472] [] __irq_disable+0x40/0x64 [ 37.296791] [] irq_shutdown+0x68/0x8c [ 37.302023] [] __free_irq+0x110/0x218 [ 37.307254] [] free_irq+0x54/0x64 [ 37.312138] [] devm_irq_release+0x24/0x30 Add an irq_shutdown callback, and do a sanity check for irq state to prevent that. Signed-off-by: Jeffy Chen --- drivers/pinctrl/pinctrl-rockchip.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 607f52c..b0e3130 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2551,6 +2551,12 @@ static void rockchip_irq_disable(struct irq_data *d) clk_disable(bank->clk); } +static void rockchip_irq_shutdown(struct irq_data *d) +{ + if (!irqd_irq_disabled(d)) + rockchip_irq_disable(d); +} + static void rockchip_irq_bus_lock(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); @@ -2641,6 +2647,7 @@ static int rockchip_interrupts_register(struct platform_device *pdev, gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit; gc->chip_types[0].chip.irq_enable = rockchip_irq_enable; gc->chip_types[0].chip.irq_disable = rockchip_irq_disable; + gc->chip_types[0].chip.irq_shutdown = rockchip_irq_shutdown; gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; gc->chip_types[0].chip.irq_suspend = rockchip_irq_suspend; gc->chip_types[0].chip.irq_resume = rockchip_irq_resume;