Skip to contentSkip to conversation

drm/amd/powerplay/hwmgr: use kmemdup

PATCH In review Muhammad Falak R Wani 2 participants 4 messages May 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay/hwmgr: use kmemdup

Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c +3 -3
index c94f9fa..1471ac3 100644
@@ -5109,11 +5109,11 @@ static int fiji_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
 	struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
 
 	if (!data->soft_pp_table) {
-		data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+		data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
+					      hwmgr->soft_pp_table_size,
+					      GFP_KERNEL);
 		if (!data->soft_pp_table)
 			return -ENOMEM;
-		memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
-				hwmgr->soft_pp_table_size);
 	}
 
 	*table = (char *)&data->soft_pp_table;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 drm/amd/powerplay/hwmgr: use kmemdup

Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c +3 -3
index 93768fa..b7dad50 100644
@@ -4760,11 +4760,11 @@ static int polaris10_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
 	struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
 
 	if (!data->soft_pp_table) {
-		data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+		data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
+					      hwmgr->soft_pp_table_size,
+					      GFP_KERNEL);
 		if (!data->soft_pp_table)
 			return -ENOMEM;
-		memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
-				hwmgr->soft_pp_table_size);
 	}
 
 	*table = (char *)&data->soft_pp_table;
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/1 drm/amd/powerplay/hwmgr: use kmemdup

In reply to Muhammad Falak R Wani

Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c +3 -3
index 1faad92..df399fe 100644
@@ -6056,11 +6056,11 @@ static int tonga_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
 	struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
 
 	if (!data->soft_pp_table) {
-		data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+		data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
+					      hwmgr->soft_pp_table_size,
+					      GFP_KERNEL);
 		if (!data->soft_pp_table)
 			return -ENOMEM;
-		memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
-				hwmgr->soft_pp_table_size);
 	}
 
 	*table = (char *)&data->soft_pp_table;
Signature · 1 line
1.9.1
#3 lore raw
In reply to Muhammad Falak R Wani
Quoted 5 lines · Muhammad Falak R Wani

Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup.

Applied the hwmgr patches.

Thanks!

Alex

Quoted 26 lines
---
 drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c +3 -4
index c94f9fa..1471ac3 100644
@@ -5109,11 +5109,11 @@ static int fiji_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
        struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
 
        if (!data->soft_pp_table) {
-               data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+               data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
+                                             hwmgr->soft_pp_table_size,
+                                             GFP_KERNEL);
                if (!data->soft_pp_table)
                        return -ENOMEM;
-               memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
-                               hwmgr->soft_pp_table_size);
        }
 
        *table = (char *)&data->soft_pp_table;
--

1.9.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel