Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp171830imd; Wed, 31 Oct 2018 16:45:56 -0700 (PDT) X-Google-Smtp-Source: AJdET5dJ6lKMCpY8k2T6nR30ZSYbL+xKXT1WGrSp6MQ9MQ+xqRRduhF1irEkDNn17APxPgPr2m3S X-Received: by 2002:a63:9041:: with SMTP id a62mr4963182pge.163.1541029555917; Wed, 31 Oct 2018 16:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029555; cv=none; d=google.com; s=arc-20160816; b=c4wj8+LL0B9FVX+kjlo6LJO1upfFVFpNbNhe9N2lYLUYzb9IBvedIn9EGa+KSMLx+u W/9a9/9NsyKcYqyKlnYnU0pmnMf4/L8hdExrThK71HSH60mO4nKLy9omqo+dgUjOt8Tm ua5nEGl3JWRxAlFDSzXEIUDS3Wi2cCiRmKU/ZdUf+tt1qNJZKLGz7ajpwAl3z6it1s6e xIb+Y80uPi8dIAbQD0Tvzj5TD8oLTGV96D/j4Fqyi8wFOuZ/iXXqbF6r8hwLFb+zNZ8p DJCiefEbQYNiglrh5/8gi5FAh88F5VN+Y2I38mdGBi5semGxqn397s6pJ4oTl3rdTVPw PlEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=CM2nkmFwLI273SNxSpGLlALlQEdR8W3aH3BUuup8zVY=; b=0NB5eoywt2S+2df6yRKQhEG8XjGQr0U75eYCTq8aM/G+9hgVkruV5Hj/JBHnJw0UB1 s06IdHxVQiahtNmDWe4F5i7mMXRD5uGHp/v0qYZI1AL01ugbxY/BXsrbJNULaiH/heIJ Un9DaCw6eDfjgv1rINVwRP7fI0bi4yNbkNLp4xmZDHgQ6JU0t6MU2YcrrKgKGSPzMcGX FcC9LgEPt7gkC1r8+lItAd485zKKoA42xGBtBMQBUxrR7DVfNP0n9cLl0nVsGRNM6jY+ WDcZa6uPSEQ0QbKWgE9fKFW95Sp2+XJZU3DpGrQxPjfhhnpB1wt8cKZbd5SwbMEg9cYv eeog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DM3McP2n; 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 l63-v6si19070145plb.385.2018.10.31.16.45.41; Wed, 31 Oct 2018 16:45:55 -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=DM3McP2n; 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 S1728887AbeKAIH0 (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728840AbeKAIHY (ORCPT ); Thu, 1 Nov 2018 04:07:24 -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 411CC2064C; Wed, 31 Oct 2018 23:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027233; bh=PwOWO/HO6CdLbUGyUS1z5sBSXeT97GHfaG0HdQyfkic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DM3McP2nG5MHw4iutga+shBE3HILagBkpDbRc9TkUDcotshieksuwEVtDGKHAclNA 6/cXQVLFjimwulYagmThA1N5JkW87xK5uLwQn4cWTd5VASI2H6QN1pau4hVMmErqvI O1QOvh6BUFKEUDPpYn0aOtf+INQ7Kd1r/5OCGfS4= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Selvin Xavier , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL 4.19 101/146] RDMA/bnxt_re: Fix recursive lock warning in debug kernel Date: Wed, 31 Oct 2018 19:04:56 -0400 Message-Id: <20181031230541.28822-101-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Selvin Xavier [ Upstream commit d455f29f6d76a5f94881ca1289aaa1e90617ff5d ] Fix possible recursive lock warning. Its a false warning as the locks are part of two differnt HW Queue data structure - cmdq and creq. Debug kernel is throwing the following warning and stack trace. [ 783.914967] ============================================ [ 783.914970] WARNING: possible recursive locking detected [ 783.914973] 4.19.0-rc2+ #33 Not tainted [ 783.914976] -------------------------------------------- [ 783.914979] swapper/2/0 is trying to acquire lock: [ 783.914982] 000000002aa3949d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x232/0x350 [bnxt_re] [ 783.914999] but task is already holding lock: [ 783.915002] 00000000be73920d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x2a/0x350 [bnxt_re] [ 783.915013] other info that might help us debug this: [ 783.915016] Possible unsafe locking scenario: [ 783.915019] CPU0 [ 783.915021] ---- [ 783.915034] lock(&(&hwq->lock)->rlock); [ 783.915035] lock(&(&hwq->lock)->rlock); [ 783.915037] *** DEADLOCK *** [ 783.915038] May be due to missing lock nesting notation [ 783.915039] 1 lock held by swapper/2/0: [ 783.915040] #0: 00000000be73920d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x2a/0x350 [bnxt_re] [ 783.915044] stack backtrace: [ 783.915046] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.19.0-rc2+ #33 [ 783.915047] Hardware name: Dell Inc. PowerEdge R730/0599V5, BIOS 1.0.4 08/28/2014 [ 783.915048] Call Trace: [ 783.915049] [ 783.915054] dump_stack+0x90/0xe3 [ 783.915058] __lock_acquire+0x106c/0x1080 [ 783.915061] ? sched_clock+0x5/0x10 [ 783.915063] lock_acquire+0xbd/0x1a0 [ 783.915065] ? bnxt_qplib_service_creq+0x232/0x350 [bnxt_re] [ 783.915069] _raw_spin_lock_irqsave+0x4a/0x90 [ 783.915071] ? bnxt_qplib_service_creq+0x232/0x350 [bnxt_re] [ 783.915073] bnxt_qplib_service_creq+0x232/0x350 [bnxt_re] [ 783.915078] tasklet_action_common.isra.17+0x197/0x1b0 [ 783.915081] __do_softirq+0xcb/0x3a6 [ 783.915084] irq_exit+0xe9/0x100 [ 783.915085] do_IRQ+0x6a/0x120 [ 783.915087] common_interrupt+0xf/0xf [ 783.915088] Use nested notation for the spin_lock to avoid this warning. Signed-off-by: Selvin Xavier Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c index 2852d350ada1..6637df77d236 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c @@ -309,8 +309,17 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, rcfw->aeq_handler(rcfw, qp_event, qp); break; default: - /* Command Response */ - spin_lock_irqsave(&cmdq->lock, flags); + /* + * Command Response + * cmdq->lock needs to be acquired to synchronie + * the command send and completion reaping. This function + * is always called with creq->lock held. Using + * the nested variant of spin_lock. + * + */ + + spin_lock_irqsave_nested(&cmdq->lock, flags, + SINGLE_DEPTH_NESTING); cookie = le16_to_cpu(qp_event->cookie); mcookie = qp_event->cookie; blocked = cookie & RCFW_CMD_IS_BLOCKING; -- 2.17.1