From: Bernard Zhao <bernard@vivo.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com, Bernard Zhao <bernard@vivo.com>
Subject: [PATCH] gpu/ipu-v3:reduce protected code area in ipu idmac get/put
Date: Fri, 28 Aug 2020 19:08:07 -0700 [thread overview]
Message-ID: <20200829020807.6568-1-bernard@vivo.com> (raw)
This change will speed-up a bit these ipu_idmac_get &
ipu_idmac_put processing and there is no need to protect
kzalloc & kfree.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
drivers/gpu/ipu-v3/ipu-common.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index b3dae9ec1a38..8b3a57864c2e 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -267,29 +267,30 @@ EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees);
struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
{
struct ipuv3_channel *channel;
+ struct ipuv3_channel *entry;
dev_dbg(ipu->dev, "%s %d\n", __func__, num);
if (num > 63)
return ERR_PTR(-ENODEV);
+ channel = kzalloc(sizeof(*channel), GFP_KERNEL);
+ if (!channel)
+ return ERR_PTR(-ENOMEM);
+
+ channel->num = num;
+ channel->ipu = ipu;
+
mutex_lock(&ipu->channel_lock);
- list_for_each_entry(channel, &ipu->channels, list) {
- if (channel->num == num) {
+ list_for_each_entry(entry, &ipu->channels, list) {
+ if (entry->num == num) {
+ kfree(channel);
channel = ERR_PTR(-EBUSY);
goto out;
}
}
- channel = kzalloc(sizeof(*channel), GFP_KERNEL);
- if (!channel) {
- channel = ERR_PTR(-ENOMEM);
- goto out;
- }
-
- channel->num = num;
- channel->ipu = ipu;
list_add(&channel->list, &ipu->channels);
out:
@@ -308,9 +309,10 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
mutex_lock(&ipu->channel_lock);
list_del(&channel->list);
- kfree(channel);
mutex_unlock(&ipu->channel_lock);
+
+ kfree(channel);
}
EXPORT_SYMBOL_GPL(ipu_idmac_put);
--
2.28.0
reply other threads:[~2020-08-29 2:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200829020807.6568-1-bernard@vivo.com \
--to=bernard@vivo.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=p.zabel@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).