Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5582844img; Wed, 27 Mar 2019 11:07:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqztMwcijdfUQ8i1Oe3G3aXjIPO3pB+/66jPXonRSN+QLkSyB2iDLIvtnqUkY4ym4esnapg/ X-Received: by 2002:a17:902:5c5:: with SMTP id f63mr35109834plf.64.1553710061168; Wed, 27 Mar 2019 11:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710061; cv=none; d=google.com; s=arc-20160816; b=wAOWYsnfqUN0eRVgnlCGKCQ0Y+JxzFRPhXVxfbPg6MWv8x1PVJ9CSIOpsVk2SwqUlc a+lwmhUfv46fhTEvkILeg/gv+tm+lXwOyh9+u1kFHb63q03MB32fBBW/W1KswhISFI94 6Wu/bC8L8p0Ziji+kOjguKt1rGrvF7ZN+p61e7Po5FdQcBkqaWR+DrF4tRob0TGG/5ci h1YKb8LnlEcZwUC+30WxRiAKQkvh01j3ABEVjqwI6oOqTFffc3+SxzyL078+Yurchgr1 VCBoS62E2UU30qu021Bv49QTKvv82XfWauBruVz1naUtGMrwvlV4KII4Ofiia0WP/QAF zCuA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W1NujBqA/pbQFc8s+pv1WAfTKN1MqTYdPIKjZS+s/Os=; b=KfDRzMZHdAJL2KMpIh3Y3HDuYYCuPHGlaP5h997CP04LW9jlTkmP3WOCNPbHy0Ym+L lhEXstm5tk7WElngBZsX+mThHqpYCysvoQVEoSeeTjkgSkf43HzvsnH7V964p5o0Z355 MR7JHfUxuhYyT0wLZmCWfpequFkPgpEO0xIBMt0om0f0j1kBS9BTWu570TaLGMuCgFXZ o7OSg7jtX472cFC8LeBIXnjVOdfC61ZDnzO8zUDjJgbovfAqUY/b4osR6EOV4H4YIEdi ubidMCbq4w6lUwwyUX1F8QlnXuII0YZuCYNcV0r917RMy6bT0Wi20W5SmpTqIMwB0Tz2 V3oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0NAySJFZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si18810245pfn.77.2019.03.27.11.07.25; Wed, 27 Mar 2019 11:07:41 -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=0NAySJFZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387496AbfC0SEx (ORCPT + 99 others); Wed, 27 Mar 2019 14:04:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:45738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387485AbfC0SEw (ORCPT ); Wed, 27 Mar 2019 14:04:52 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 383192075C; Wed, 27 Mar 2019 18:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709890; bh=Co7VvKQ5U1ldm8VHFwYJ7KIwhWE9pUgdih0ei/O0xQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0NAySJFZFtdD7MrXU/6KSLkCXtSJFvLP7RpulsQraT2THk6hGXKvYhiKbOcRqRMMK y6f9F0i4j9WTP17kUEuuDhC9N+1DnbeTeLtOXAs8PbZZM/txA+8rxEQQ59QTNUVmiu BQnZGmqbefFrT8hpfUlggGgta4PJykoaBgG6uAxU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrew Lunn , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 093/262] net: dsa: mv88e6xxx: Add lockdep classes to fix false positive splat Date: Wed, 27 Mar 2019 13:59:08 -0400 Message-Id: <20190327180158.10245-93-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn [ Upstream commit f6d9758b12660484b6639364cc406da92a918c96 ] The following false positive lockdep splat has been observed. ====================================================== WARNING: possible circular locking dependency detected 4.20.0+ #302 Not tainted ------------------------------------------------------ systemd-udevd/160 is trying to acquire lock: edea6080 (&chip->reg_lock){+.+.}, at: __setup_irq+0x640/0x704 but task is already holding lock: edff0340 (&desc->request_mutex){+.+.}, at: __setup_irq+0xa0/0x704 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&desc->request_mutex){+.+.}: mutex_lock_nested+0x1c/0x24 __setup_irq+0xa0/0x704 request_threaded_irq+0xd0/0x150 mv88e6xxx_probe+0x41c/0x694 [mv88e6xxx] mdio_probe+0x2c/0x54 really_probe+0x200/0x2c4 driver_probe_device+0x5c/0x174 __driver_attach+0xd8/0xdc bus_for_each_dev+0x58/0x7c bus_add_driver+0xe4/0x1f0 driver_register+0x7c/0x110 mdio_driver_register+0x24/0x58 do_one_initcall+0x74/0x2e8 do_init_module+0x60/0x1d0 load_module+0x1968/0x1ff4 sys_finit_module+0x8c/0x98 ret_fast_syscall+0x0/0x28 0xbedf2ae8 -> #0 (&chip->reg_lock){+.+.}: __mutex_lock+0x50/0x8b8 mutex_lock_nested+0x1c/0x24 __setup_irq+0x640/0x704 request_threaded_irq+0xd0/0x150 mv88e6xxx_g2_irq_setup+0xcc/0x1b4 [mv88e6xxx] mv88e6xxx_probe+0x44c/0x694 [mv88e6xxx] mdio_probe+0x2c/0x54 really_probe+0x200/0x2c4 driver_probe_device+0x5c/0x174 __driver_attach+0xd8/0xdc bus_for_each_dev+0x58/0x7c bus_add_driver+0xe4/0x1f0 driver_register+0x7c/0x110 mdio_driver_register+0x24/0x58 do_one_initcall+0x74/0x2e8 do_init_module+0x60/0x1d0 load_module+0x1968/0x1ff4 sys_finit_module+0x8c/0x98 ret_fast_syscall+0x0/0x28 0xbedf2ae8 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&desc->request_mutex); lock(&chip->reg_lock); lock(&desc->request_mutex); lock(&chip->reg_lock); &desc->request_mutex refer to two different mutex. #1 is the GPIO for the chip interrupt. #2 is the chained interrupt between global 1 and global 2. Add lockdep classes to the GPIO interrupt to avoid this. Reported-by: Russell King Signed-off-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 4a0ec8e87c7a..6cba05a80892 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -442,12 +442,20 @@ static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) { + static struct lock_class_key lock_key; + static struct lock_class_key request_key; int err; err = mv88e6xxx_g1_irq_setup_common(chip); if (err) return err; + /* These lock classes tells lockdep that global 1 irqs are in + * a different category than their parent GPIO, so it won't + * report false recursion. + */ + irq_set_lockdep_class(chip->irq, &lock_key, &request_key); + err = request_threaded_irq(chip->irq, NULL, mv88e6xxx_g1_irq_thread_fn, IRQF_ONESHOT | IRQF_SHARED, -- 2.19.1