From patchwork Fri Oct 14 22:52:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 9377585 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 431C26075E for ; Fri, 14 Oct 2016 22:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C4C2A799 for ; Fri, 14 Oct 2016 22:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 182292A7B4; Fri, 14 Oct 2016 22:53:08 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 6B2102A799 for ; Fri, 14 Oct 2016 22:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756171AbcJNWxG (ORCPT ); Fri, 14 Oct 2016 18:53:06 -0400 Received: from mail-it0-f50.google.com ([209.85.214.50]:38029 "EHLO mail-it0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755912AbcJNWxF (ORCPT ); Fri, 14 Oct 2016 18:53:05 -0400 Received: by mail-it0-f50.google.com with SMTP id o19so3880890ito.1 for ; Fri, 14 Oct 2016 15:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=JDk2VuZ6Ox4DXVaUtjuQgSxDlO70YUXrEYbDDiOx8Wo=; b=TgVAQhJDHuaVRLqYjWWDPCAr8Vo//kr7XvW2Rei+7IOTPAY8TyAKA3MAk+m8abI3Uu I07Nv/tUpihErdvPmjJyUG8n/ye+WIeAXM5UwKNbjruQ7rqrgA3enp+1XAbsqyOT5Q7N 5PaYceHvQBXYan/XDef+uvaxfMTF1R28/2ikw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JDk2VuZ6Ox4DXVaUtjuQgSxDlO70YUXrEYbDDiOx8Wo=; b=DhPJ9Afm/kEUWlSYVBemm7/bMX4xaE5AdJEnASJNrqwU1w5Ma7K+cUlaK024DojLJb rl5QVJQYBVa+Dxb1cBC1rs33lp1BteRZxITQ+LgV/1JZ3ovGQkrAJROGFR/TEGx+uXyH OtTxH/yHaIfAr4WbGxXeux3rioS60hCHBJRouq2XaokeO0n8vUuUQ5/XfTweWEbGI6Wd RNz+InxakDH8zf5iTGy6h7Z2C8gl+eXiq5nHwRhvqIz4kCDuLCBXKkM0gTw3Te0vqRvG cF6I4mGQY0GsVKgqkcD8+EXva/SfgFtxH9OrTh1Q2IkkMTPTylsyt1WS/gnokG99jjd8 2ZJA== X-Gm-Message-State: AA6/9Rn+HgGTG5imRoP5+w0FAP1YSbaJLzmt9IKeoOK2qedq5Df5wzjrvgE0p7dJF9S6sXqX X-Received: by 10.36.138.68 with SMTP id v65mr522074itd.0.1476485584055; Fri, 14 Oct 2016 15:53:04 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id q62sm8576156iod.35.2016.10.14.15.53.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Oct 2016 15:53:03 -0700 (PDT) From: Hoan Tran To: "Rafael J. Wysocki" , Jassi Brar , Prakash Prashanth Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lho@apm.com, Duc Dang , Hoan Tran Subject: [PATCH] mailbox: PCC: Fix lockdep warning when request PCC channel Date: Fri, 14 Oct 2016 15:52:21 -0700 Message-Id: <1476485541-7273-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes the lockdep warning below [ 7.229767] DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)) [ 7.229776] ------------[ cut here ]------------ [ 7.229787] WARNING: CPU: 1 PID: 1 at linux-next/kernel/locking/lockdep.c:2876 loc kdep_trace_alloc+0xe0/0xf0 [ 7.229790] Modules linked in: [ 7.229793] [ 7.229798] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.8.0-11756-g86c5152 #46 ... [ 7.229900] Call trace: [ 7.229903] Exception stack(0xffff8007da837890 to 0xffff8007da8379c0) [ 7.229906] 7880: ffff8007da834000 0001000000000000 [ 7.229909] 78a0: ffff8007da837a70 ffff0000081111a0 00000000600000c5 000000000000003d [ 7.229912] 78c0: 9374bc6a7f3c7832 0000000000381878 ffff000009db7ab8 000000000000002f [ 7.229915] 78e0: ffff00000811aabc ffff000008be2548 ffff8007da837990 ffff00000811adf8 [ 7.229918] 7900: ffff8007da834000 00000000024080c0 00000000000000c0 ffff000009021000 [ 7.229921] 7920: 0000000000000000 0000000000000000 ffff000008c8f7c8 ffff8007da579810 [ 7.229923] 7940: 000000000000002f ffff8007da858000 0000000000000000 0000000000000001 [ 7.229926] 7960: 0000000000000001 0000000000000000 ffff00000811a468 0000000000000002 [ 7.229929] 7980: 656c62617369645f 0000000000038187 00000000000000ee ffff8007da837850 [ 7.229932] 79a0: ffff000009db50c0 ffff000009db569d 0000000000000006 ffff000089db568f [ 7.229936] [] lockdep_trace_alloc+0xe0/0xf0 [ 7.229940] [] __kmalloc_track_caller+0x50/0x250 [ 7.229945] [] devres_alloc_node+0x28/0x60 [ 7.229949] [] devm_request_threaded_irq+0x50/0xe0 [ 7.229955] [] pcc_mbox_request_channel+0x110/0x170 [ 7.229960] [] acpi_cppc_processor_probe+0x264/0x414 [ 7.229963] [] __acpi_processor_start+0x28/0xa0 [ 7.229966] [] acpi_processor_start+0x44/0x54 [ 7.229970] [] driver_probe_device+0x1fc/0x2b0 [ 7.229974] [] __driver_attach+0xb4/0xc0 [ 7.229977] [] bus_for_each_dev+0x5c/0xa0 [ 7.229980] [] driver_attach+0x20/0x30 [ 7.229983] [] bus_add_driver+0x110/0x230 [ 7.229987] [] driver_register+0x60/0x100 [ 7.229991] [] acpi_processor_driver_init+0x2c/0xb0 [ 7.229996] [] do_one_initcall+0x38/0x130 [ 7.230000] [] kernel_init_freeable+0x210/0x2b4 [ 7.230004] [] kernel_init+0x10/0x110 [ 7.230007] [] ret_from_fork+0x10/0x50 It's because the spinlock inside pcc_mbox_request_channel() is kept too long. Adding a mutex to protect critical section of this function. Beside of that, spinlock is still used to protect the data of channel. Signed-off-by: Hoan Tran --- drivers/mailbox/pcc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 08c87fa..b6cece0 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -81,6 +81,8 @@ static int *pcc_doorbell_irq; static struct mbox_controller pcc_mbox_ctrl = {}; +static DEFINE_MUTEX(pcc_con_mutex); + /** * get_pcc_channel - Given a PCC subspace idx, get * the respective mbox_channel. @@ -243,6 +245,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, struct mbox_chan *chan; unsigned long flags; + mutex_lock(&pcc_con_mutex); /* * Each PCC Subspace is a Mailbox Channel. * The PCC Clients get their PCC Subspace ID @@ -254,6 +257,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, if (IS_ERR(chan) || chan->cl) { dev_err(dev, "Channel not found for idx: %d\n", subspace_id); + mutex_unlock(&pcc_con_mutex); return ERR_PTR(-EBUSY); } @@ -267,6 +271,8 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone) chan->txdone_method |= TXDONE_BY_ACK; + spin_unlock_irqrestore(&chan->lock, flags); + if (pcc_doorbell_irq[subspace_id] > 0) { int rc; @@ -279,7 +285,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, } } - spin_unlock_irqrestore(&chan->lock, flags); + mutex_unlock(&pcc_con_mutex); return chan; }