lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <AN*ApwBwDVasgemZb6*hx4qM.1.1600686717774.Hmail.bernard@vivo.com>
Date:   Mon, 21 Sep 2020 19:11:57 +0800 (GMT+08:00)
From:   Bernard <bernard@...o.com>
To:     Philipp Zabel <p.zabel@...gutronix.de>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Cc:     opensource.kernel@...o.com, Bernard Zhao <bernard@...o.com>
Subject: [Re-send][PATCH] gpu/ipu-v3:reduce protected code area in ipu idmac get/put

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@...o.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



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ