From patchwork Fri Jun 23 20:59:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9807269 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 70D86600C5 for ; Fri, 23 Jun 2017 20:59:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 608FF2854F for ; Fri, 23 Jun 2017 20:59:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52FF428578; Fri, 23 Jun 2017 20:59:26 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C57832854F for ; Fri, 23 Jun 2017 20:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751488AbdFWU7Q (ORCPT ); Fri, 23 Jun 2017 16:59:16 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:35084 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbdFWU7P (ORCPT ); Fri, 23 Jun 2017 16:59:15 -0400 Received: by mail-pg0-f43.google.com with SMTP id 132so25643995pgb.2 for ; Fri, 23 Jun 2017 13:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LNrqwYrwq50816W9oN13fHHOJMGTLJLVVWdxo3WzF4k=; b=JYaJHjYOtcKP0Uw9OGTO8X111x53HVRyrGwC6/sbmwVfw+IB/yJAfjv1amexNC503X Maivj1FGzdPXeojTn8Y4EbQKvUyTSMP3zg6wLK+s/7DaG/clXAbmj0eUxOKwIAJpnSBp 3yofWmQ9qYpfEsPnhL2SrMKEtSabs6iT3laL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LNrqwYrwq50816W9oN13fHHOJMGTLJLVVWdxo3WzF4k=; b=WBC9gT0yIeew91iDqzRbBMb2BetmnOKSY1kRxLARkY/1nuV0oBOsdu/BE92opfJXQH 99a20fkRz/wEp3TF3oPYBw1dG093Iuc+RzJyKizEAvgGWpmL1TFsN0Bw6Mv7MmI9N9Qd TbP2DIdkDtWa+l5Es/zR8Xq+q8tKBMEhhCq/gSziGzkj3ozMkM/ZqI08nBP93rPw/FQM M7Nc6K1MEWezXEWb6etPsXiqLFpWQUZmdH2LCtuzQAYAYaRbdXfaiHHjBqc5A/s18qdu 6GxlnPxCoDD5/Fu3tchj2Lc7+6SLL6iY4RRdu9k2ectIoQNlUwbG4W+rcLA/TeI6dtzM SI5g== X-Gm-Message-State: AKS2vOwu5QVzXprXjEDxbXbV8b1P2gAvLz8nypJhSTg2vDP4lfTyza7Y yQyjoaIUDjzCCCyC X-Received: by 10.84.218.140 with SMTP id r12mr10842683pli.288.1498251554210; Fri, 23 Jun 2017 13:59:14 -0700 (PDT) Received: from google.com ([2620:0:1000:1301:c997:136d:1e31:4a36]) by smtp.gmail.com with ESMTPSA id 73sm13046035pgf.41.2017.06.23.13.59.13 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 23 Jun 2017 13:59:13 -0700 (PDT) Date: Fri, 23 Jun 2017 13:59:11 -0700 From: Brian Norris To: Heiko Stuebner , Linus Walleij , Thomas Gleixner Cc: linux-rockchip@lists.infradead.org, Julia Cartwright , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Keeping , linux-pm@vger.kernel.org, Doug Anderson Subject: [PATCH for 4.12] Revert "pinctrl: rockchip: avoid hardirq-unsafe functions in irq_chip" Message-ID: <20170623205911.GA143883@google.com> References: <20170517225634.GA11404@google.com> <20170527021900.GA119873@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170527021900.GA119873@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 88bb94216f59e10802aaf78c858a4146085faf18. It introduced a new CONFIG_DEBUG_ATOMIC_SLEEP warning in v4.12-rc1: [ 7226.716713] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238 [ 7226.716716] in_atomic(): 0, irqs_disabled(): 0, pid: 1708, name: bash [ 7226.716722] CPU: 1 PID: 1708 Comm: bash Not tainted 4.12.0-rc6+ #1213 [ 7226.716724] Hardware name: Google Kevin (DT) [ 7226.716726] Call trace: [ 7226.716738] [] dump_backtrace+0x0/0x24c [ 7226.716743] [] show_stack+0x20/0x28 [ 7226.716749] [] dump_stack+0x90/0xb0 [ 7226.716755] [] ___might_sleep+0x10c/0x124 [ 7226.716760] [] __might_sleep+0x78/0x88 [ 7226.716765] [] mutex_lock+0x2c/0x64 [ 7226.716771] [] rockchip_irq_bus_lock+0x30/0x3c [ 7226.716777] [] __irq_get_desc_lock+0x78/0x98 [ 7226.716782] [] irq_set_irq_wake+0x44/0x12c [ 7226.716787] [] dev_pm_arm_wake_irq+0x4c/0x58 [ 7226.716792] [] device_wakeup_arm_wake_irqs+0x3c/0x58 [ 7226.716796] [] dpm_suspend_noirq+0xf8/0x3a0 [ 7226.716800] [] suspend_devices_and_enter+0x1a4/0x9a8 [ 7226.716803] [] pm_suspend+0x664/0x6a4 [ 7226.716807] [] state_store+0xd4/0xf8 ... It was reported on -rc1, and it's still not fixed in -rc6, so it should just be reverted. Cc: John Keeping Cc: Heiko Stuebner Cc: Linus Walleij Signed-off-by: Brian Norris Reviewed-by: Heiko Stuebner --- + Thomas, in case he has thoughts Subject was "[4.12 REGRESSION] pinctrl: rockchip: sleeping function called from atomic context" On Fri, May 26, 2017 at 07:19:00PM -0700, Brian Norris wrote: > Any thoughts? Revert the offending patch? I can spend a little more time > next week trying to debug what's actually going on if needed. > > On Wed, May 17, 2017 at 03:56:34PM -0700, Brian Norris wrote: > > The thing is, the documentation (and apparent design) suggest that > > calling sleeping functions from ->irq_bus_lock() is perfectly valid. I'm > > not 100% following the ___might_sleep() logic, but is this complaining > > because of the RCU read locking in device_wakeup_arm_wake_irqs()? I have > > CONFIG_PREEMPT_RCU and CONFIG_PREEMPT enabled, FWIW. I've seen no reply that indicates anyone wants to fix the patch. drivers/pinctrl/pinctrl-rockchip.c | 44 ++++---------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index f141aa0430b1..9dd981ddbb17 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -143,9 +143,6 @@ struct rockchip_drv { * @gpio_chip: gpiolib chip * @grange: gpio range * @slock: spinlock for the gpio bank - * @irq_lock: bus lock for irq chip - * @new_irqs: newly configured irqs which must be muxed as GPIOs in - * irq_bus_sync_unlock() */ struct rockchip_pin_bank { void __iomem *reg_base; @@ -168,8 +165,6 @@ struct rockchip_pin_bank { struct pinctrl_gpio_range grange; raw_spinlock_t slock; u32 toggle_edge_mode; - struct mutex irq_lock; - u32 new_irqs; }; #define PIN_BANK(id, pins, label) \ @@ -2134,12 +2129,11 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) int ret; /* make sure the pin is configured as gpio input */ - ret = rockchip_verify_mux(bank, d->hwirq, RK_FUNC_GPIO); + ret = rockchip_set_mux(bank, d->hwirq, RK_FUNC_GPIO); if (ret < 0) return ret; - bank->new_irqs |= mask; - + clk_enable(bank->clk); raw_spin_lock_irqsave(&bank->slock, flags); data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); @@ -2197,6 +2191,7 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) default: irq_gc_unlock(gc); raw_spin_unlock_irqrestore(&bank->slock, flags); + clk_disable(bank->clk); return -EINVAL; } @@ -2205,6 +2200,7 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) irq_gc_unlock(gc); raw_spin_unlock_irqrestore(&bank->slock, flags); + clk_disable(bank->clk); return 0; } @@ -2248,34 +2244,6 @@ static void rockchip_irq_disable(struct irq_data *d) clk_disable(bank->clk); } -static void rockchip_irq_bus_lock(struct irq_data *d) -{ - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; - - clk_enable(bank->clk); - mutex_lock(&bank->irq_lock); -} - -static void rockchip_irq_bus_sync_unlock(struct irq_data *d) -{ - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; - - while (bank->new_irqs) { - unsigned int irq = __ffs(bank->new_irqs); - int ret; - - ret = rockchip_set_mux(bank, irq, RK_FUNC_GPIO); - WARN_ON(ret < 0); - - bank->new_irqs &= ~BIT(irq); - } - - mutex_unlock(&bank->irq_lock); - clk_disable(bank->clk); -} - static int rockchip_interrupts_register(struct platform_device *pdev, struct rockchip_pinctrl *info) { @@ -2342,9 +2310,6 @@ static int rockchip_interrupts_register(struct platform_device *pdev, gc->chip_types[0].chip.irq_suspend = rockchip_irq_suspend; gc->chip_types[0].chip.irq_resume = rockchip_irq_resume; gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; - gc->chip_types[0].chip.irq_bus_lock = rockchip_irq_bus_lock; - gc->chip_types[0].chip.irq_bus_sync_unlock = - rockchip_irq_bus_sync_unlock; gc->wake_enabled = IRQ_MSK(bank->nr_pins); irq_set_chained_handler_and_data(bank->irq, @@ -2518,7 +2483,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( int bank_pins = 0; raw_spin_lock_init(&bank->slock); - mutex_init(&bank->irq_lock); bank->drvdata = d; bank->pin_base = ctrl->nr_pins; ctrl->nr_pins += bank->nr_pins;