Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1593261ybv; Thu, 20 Feb 2020 23:56:09 -0800 (PST) X-Google-Smtp-Source: APXvYqxmuyxN0+xXuU51pfEj6qYLjNPY7S2viWKC5M/QLvzg4b4slYgQXf+E8YFPoVajhqhphIIe X-Received: by 2002:aca:2207:: with SMTP id b7mr964996oic.109.1582271769762; Thu, 20 Feb 2020 23:56:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271769; cv=none; d=google.com; s=arc-20160816; b=ei17NefP2q9oS43YxSly9NaQ/yC+9Y5uvE1O49TJsUAftbhq1wOYcfP6c3frFD1Qhp U+SfWeiqZFUGRvB2rWKdZK1r05UZZTIvdmXgMgWT6LFW7C2et07BzSCVTfNNKvi0//Es JZrPWBxV6lbzBJKIz1dNAB1hO8W0zfUOowMK2tP1G33rVeLs2FXUbyJT/bUjaR3tuttM 22hVYUvRpVAg4psCVOY6VCz45FXPsb/dcaXbuGpHheOfurJ75+0a8kWxceidR+xcQxto 3R6JPY4RDJrkjcSDaTtQ/G0c35QteFeMExhk3zikkb5/yZsV9QnV0Ndrg+fTRFgC+FMv CP9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zxOAlPU/UPZeKnZKd7l1kxW/eLtY90rhs0XCQXu9cfM=; b=BgnQjfZp3d2QfNGNUFiLZTj/75AJQAddYq+MyZ6ChJp1wIJCHf8fV5SxvzzoIx1vJr oQiwh4vcQD9pWdt6hl0kTl9Kl3QAXtQLe0SNHqNoFR3Blv57ksD7C73+4NQrgot7j75O uC0B9jCGkUANSWQQO31/8r10mMPmtrYF/1PpGhsKBLiMiFb3ImWvUIN/S5aTAhHahnF2 Rg/U06zgxqoaOckxi6+biv5iqc+M1S1K5kBJJxfH/9iGIof/r2oiTkifLITBd8/cFCIv 5O59IomJHKj0q2vTyA+8xOkoOi/LNa29VCLw0k4BHYWI2p0DCgJDKIFikN319Gtc3vb/ vepQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kFACAePU; 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 l5si1191821otn.35.2020.02.20.23.55.57; Thu, 20 Feb 2020 23:56:09 -0800 (PST) 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=kFACAePU; 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 S1730278AbgBUHy5 (ORCPT + 99 others); Fri, 21 Feb 2020 02:54:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:53544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728481AbgBUHyx (ORCPT ); Fri, 21 Feb 2020 02:54:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 32B9320801; Fri, 21 Feb 2020 07:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271691; bh=DvXZmOsU9KBX6JwijiEl/HVjG43XLWa66DURpCTRJys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kFACAePUN9NbYhC/Glg/7trel/B8qpS+RxOTaXVoLD/MrOy0jlCXq3plP92XiimrY j7trFdyTABaGWPEVjcZcMhF0mGhRpMdwzY3MitdoeEffk5n6Ms3mgBOhHmFFmVkCVT 7Z7zGpf3I1ft2UhEsdIVr1/HXo56fUn8I/qtIgSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Brian Masney , Lina Iyer , Marc Zyngier , Maulik Shah , Stephen Boyd , Linus Walleij , Sasha Levin Subject: [PATCH 5.5 262/399] gpiolib: Set lockdep class for hierarchical irq domains Date: Fri, 21 Feb 2020 08:39:47 +0100 Message-Id: <20200221072427.864803918@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Boyd [ Upstream commit c34f6dc8c9e6bbe9fba1d53acd6d9a3889599da3 ] I see the following lockdep splat in the qcom pinctrl driver when attempting to suspend the device. ============================================ WARNING: possible recursive locking detected 5.4.2 #2 Tainted: G S -------------------------------------------- cat/6536 is trying to acquire lock: ffffff814787ccc0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94 but task is already holding lock: ffffff81436740c0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&irq_desc_lock_class); lock(&irq_desc_lock_class); *** DEADLOCK *** May be due to missing lock nesting notation 7 locks held by cat/6536: #0: ffffff8140e0c420 (sb_writers#7){.+.+}, at: vfs_write+0xc8/0x19c #1: ffffff8121eec480 (&of->mutex){+.+.}, at: kernfs_fop_write+0x128/0x1f4 #2: ffffff8147cad668 (kn->count#263){.+.+}, at: kernfs_fop_write+0x130/0x1f4 #3: ffffffd011446000 (system_transition_mutex){+.+.}, at: pm_suspend+0x108/0x354 #4: ffffff814302b970 (&dev->mutex){....}, at: __device_suspend+0x16c/0x420 #5: ffffff81436740c0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94 #6: ffffff81479b8c10 (&pctrl->lock){....}, at: msm_gpio_irq_set_wake+0x48/0x7c stack backtrace: CPU: 4 PID: 6536 Comm: cat Tainted: G S 5.4.2 #2 Call trace: dump_backtrace+0x0/0x174 show_stack+0x20/0x2c dump_stack+0xdc/0x144 __lock_acquire+0x52c/0x2268 lock_acquire+0x1dc/0x220 _raw_spin_lock_irqsave+0x64/0x80 __irq_get_desc_lock+0x64/0x94 irq_set_irq_wake+0x40/0x144 msm_gpio_irq_set_wake+0x5c/0x7c set_irq_wake_real+0x40/0x5c irq_set_irq_wake+0x70/0x144 cros_ec_rtc_suspend+0x38/0x4c platform_pm_suspend+0x34/0x60 dpm_run_callback+0x64/0xcc __device_suspend+0x314/0x420 dpm_suspend+0xf8/0x298 dpm_suspend_start+0x84/0xb4 suspend_devices_and_enter+0xbc/0x628 pm_suspend+0x214/0x354 state_store+0xb0/0x108 kobj_attr_store+0x14/0x24 sysfs_kf_write+0x4c/0x64 kernfs_fop_write+0x158/0x1f4 __vfs_write+0x54/0x18c vfs_write+0xdc/0x19c ksys_write+0x7c/0xe4 __arm64_sys_write+0x20/0x2c el0_svc_common+0xa8/0x160 el0_svc_compat_handler+0x2c/0x38 el0_svc_compat+0x8/0x10 This is because the msm_gpio_irq_set_wake() function calls irq_set_irq_wake() as a backup in case the irq comes in during the path to idle. Given that we're calling irqchip functions from within an irqchip we need to set the lockdep class to be different for this child controller vs. the default one that the parent irqchip gets. This used to be done before this driver was converted to hierarchical irq domains in commit e35a6ae0eb3a ("pinctrl/msm: Setup GPIO chip in hierarchy") via the gpiochip_irq_map() function. With hierarchical irq domains this function has been replaced by gpiochip_hierarchy_irq_domain_alloc(). Therefore, set the lockdep class like was done previously in the irq domain path so we can avoid this lockdep warning. Fixes: fdd61a013a24 ("gpio: Add support for hierarchical IRQ domains") Cc: Thierry Reding Cc: Brian Masney Cc: Lina Iyer Cc: Marc Zyngier Cc: Maulik Shah Signed-off-by: Stephen Boyd Link: https://lore.kernel.org/r/20200114231103.85641-1-swboyd@chromium.org Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bcfbfded9ba3f..175c6363cf611 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2053,6 +2053,7 @@ static int gpiochip_hierarchy_irq_domain_alloc(struct irq_domain *d, parent_type); chip_info(gc, "alloc_irqs_parent for %d parent hwirq %d\n", irq, parent_hwirq); + irq_set_lockdep_class(irq, gc->irq.lock_key, gc->irq.request_key); ret = irq_domain_alloc_irqs_parent(d, irq, 1, &parent_fwspec); if (ret) chip_err(gc, -- 2.20.1