From: "Dāvis Mosāns" <davispuh@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Vinod Koul" <vkoul@kernel.org>,
dmaengine@vger.kernel.org, "Dāvis Mosāns" <davispuh@gmail.com>
Subject: [PATCH] dmaengine: fix locking for dma_channel_rebalance
Date: Tue, 22 Feb 2022 03:58:49 +0200 [thread overview]
Message-ID: <20220222015849.14727-1-davispuh@gmail.com> (raw)
dma_channel_rebalance comment says:
> Must be called under dma_list_mutex
We have few places where it wasn't done and could cause crashes.
So invoke it only when it's under mutex.
---
drivers/dma/dmaengine.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 2cfa8458b51be..5198bdf7ee804 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1098,7 +1098,10 @@ int dma_async_device_channel_register(struct dma_device *device,
if (rc < 0)
return rc;
+ mutex_lock(&dma_list_mutex);
dma_channel_rebalance();
+ mutex_unlock(&dma_list_mutex);
+
return 0;
}
EXPORT_SYMBOL_GPL(dma_async_device_channel_register);
@@ -1124,7 +1127,9 @@ void dma_async_device_channel_unregister(struct dma_device *device,
struct dma_chan *chan)
{
__dma_async_device_channel_unregister(device, chan);
+ mutex_lock(&dma_list_mutex);
dma_channel_rebalance();
+ mutex_unlock(&dma_list_mutex);
}
EXPORT_SYMBOL_GPL(dma_async_device_channel_unregister);
--
2.35.1
next reply other threads:[~2022-02-22 1:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 1:58 Dāvis Mosāns [this message]
2022-02-22 2:18 ` [PATCH] dmaengine: fix locking for dma_channel_rebalance Dāvis Mosāns
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=20220222015849.14727-1-davispuh@gmail.com \
--to=davispuh@gmail.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox