All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: linux-kernel@vger.kernel.org, Stuart Yoder <stuyoder@gmail.com>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [PATCH v2] bus: fsl-mc-msi: fix MSI descriptor mutex lock for msi_first_desc()
Date: Tue, 12 Apr 2022 16:56:36 +0900	[thread overview]
Message-ID: <20220412075636.755454-1-shinichiro.kawasaki@wdc.com> (raw)

Commit e8604b1447b4 ("bus: fsl-mc-msi: Simplify MSI descriptor
handling") introduced a call to the helper function msi_first_desc(),
which needs MSI descriptor mutex lock before call. However, the required
mutex lock was not added. This resulted in lockdep assert WARNING [1].
Fix this by adding the mutex lock and unlock around the function call.

[1]

[    8.542804] WARNING: CPU: 4 PID: 119 at kernel/irq/msi.c:274 msi_first_desc+0xd0/0x10c
[    8.551428] Modules linked in:
[    8.555184] CPU: 4 PID: 119 Comm: kworker/u32:1 Not tainted 5.18.0-rc1+ #5
[    8.562755] Hardware name: SolidRun Ltd. SolidRun CEX7 Platform, BIOS EDK II Aug  9 2021
[    8.571539] Workqueue: events_unbound deferred_probe_work_func
[    8.578079] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    8.585736] pc : msi_first_desc+0xd0/0x10c
[    8.590529] lr : msi_first_desc+0xcc/0x10c
[    8.595321] sp : ffff800009856fb0
[    8.599328] x29: ffff800009856fb0 x28: ffff3018789f0000 x27: ffff3018789f0000
[    8.607175] x26: 1ffff0000130ae2a x25: 1fffe6030f13e0a4 x24: 1fffe6030f13e0a3
[    8.615020] x23: ffff301878a09024 x22: ffff301860993800 x21: ffffc539150ec000
[    8.622865] x20: 0000000000000000 x19: ffff301878a04880 x18: ffff30257b37b588
[    8.630710] x17: 0000000000000000 x16: 1fffe6030c3d89a3 x15: 1fffe6030c3d8982
[    8.638555] x14: 0000000000000004 x13: ffff301861ec4c14 x12: ffff70000130adc3
[    8.646400] x11: 1ffff0000130adc2 x10: ffff70000130adc2 x9 : ffffc53911dd0790
[    8.654245] x8 : ffff800009856e17 x7 : 0000000000000001 x6 : 0000000041b58ab3
[    8.662089] x5 : ffff70000130ada2 x4 : 1ffff0000130add2 x3 : 1fffe6030c3d8802
[    8.669933] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
[    8.677778] Call trace:
[    8.680918]  msi_first_desc+0xd0/0x10c
[    8.685364]  fsl_mc_msi_domain_alloc_irqs+0x7c/0xc0
[    8.690938]  fsl_mc_populate_irq_pool+0x80/0x3cc
[    8.696251]  dprc_scan_objects+0x370/0x560
[    8.701042]  dprc_probe+0x54/0x210
[    8.705137]  fsl_mc_driver_probe+0x60/0xc0
[    8.709934]  really_probe+0x328/0x9bc
[    8.714292]  __driver_probe_device+0x268/0x3d0
[    8.719431]  driver_probe_device+0x64/0x154
[    8.724310]  __device_attach_driver+0x194/0x250
[    8.729536]  bus_for_each_drv+0x114/0x190
[    8.734241]  __device_attach+0x198/0x34c
[    8.738859]  device_initial_probe+0x20/0x30
[    8.743738]  bus_probe_device+0x168/0x1e0
[    8.748443]  device_add+0x858/0x12a0
[    8.752713]  fsl_mc_device_add+0x4bc/0x950
[    8.757505]  fsl_mc_bus_probe+0x464/0x740
[    8.762210]  platform_probe+0xd0/0x1b0
[    8.766653]  really_probe+0x328/0x9bc
[    8.771010]  __driver_probe_device+0x268/0x3d0
[    8.776149]  driver_probe_device+0x64/0x154
[    8.781028]  __device_attach_driver+0x194/0x250
[    8.786254]  bus_for_each_drv+0x114/0x190
[    8.790958]  __device_attach+0x198/0x34c
[    8.795576]  device_initial_probe+0x20/0x30
[    8.800455]  bus_probe_device+0x168/0x1e0
[    8.805159]  deferred_probe_work_func+0x16c/0x24c
[    8.810558]  process_one_work+0x69c/0xf40
[    8.815265]  worker_thread+0x3dc/0xc50
[    8.819710]  kthread+0x2cc/0x340
[    8.823635]  ret_from_fork+0x10/0x20
[    8.827909] irq event stamp: 2082
[    8.831915] hardirqs last  enabled at (2081): [<ffffc539131f6670>] _raw_spin_unlock_irqrestore+0x120/0x144
[    8.842267] hardirqs last disabled at (2082): [<ffffc539131d5ef4>] el1_dbg+0x24/0x80
[    8.850708] softirqs last  enabled at (2002): [<ffffc53910d90a38>] __do_softirq+0x528/0x8e0
[    8.859753] softirqs last disabled at (1997): [<ffffc53910e3c3e8>] __irq_exit_rcu+0x3f8/0x680

Fixes: e8604b1447b4 ("bus: fsl-mc-msi: Simplify MSI descriptor handling")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
CC: stable@vger.kernel.org # v5.17+
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
Changes from v1:
* Added a Reviewed-by tag
* Reflected a nit comment on the list

 drivers/bus/fsl-mc/fsl-mc-msi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-msi.c b/drivers/bus/fsl-mc/fsl-mc-msi.c
index 5e0e4393ce4d..0cfe859a4ac4 100644
--- a/drivers/bus/fsl-mc/fsl-mc-msi.c
+++ b/drivers/bus/fsl-mc/fsl-mc-msi.c
@@ -224,8 +224,12 @@ int fsl_mc_msi_domain_alloc_irqs(struct device *dev,  unsigned int irq_count)
 	if (error)
 		return error;
 
+	msi_lock_descs(dev);
 	if (msi_first_desc(dev, MSI_DESC_ALL))
-		return -EINVAL;
+		error = -EINVAL;
+	msi_unlock_descs(dev);
+	if (error)
+		return error;
 
 	/*
 	 * NOTE: Calling this function will trigger the invocation of the
-- 
2.35.1


             reply	other threads:[~2022-04-12  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  7:56 Shin'ichiro Kawasaki [this message]
2022-04-27 10:38 ` [PATCH v2] bus: fsl-mc-msi: fix MSI descriptor mutex lock for msi_first_desc() Shinichiro Kawasaki
2022-04-27 17:38   ` Thomas Gleixner
2022-04-27 17:46 ` [tip: irq/urgent] bus: fsl-mc-msi: Fix " tip-bot2 for Shin'ichiro Kawasaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220412075636.755454-1-shinichiro.kawasaki@wdc.com \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=jgg@ziepe.ca \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stuyoder@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.