Browse Source

disp: msm: sde: use devm_kzalloc for debug dumps

Upstream has added an "enhancement" to the DMA allocator to
reject coherent allocations less than a a full page, so allocate
device managed memory instead of artificially inflating the
buffer sizes. This has the added benefit of having this memory
automatically freed when the module is unloaded, avoiding
possible leaks.

Change-Id: I653f2cd1f06f1a352cd61e36ea8baaf7c30efd98
Signed-off-by: Steve Cohen <[email protected]>
Steve Cohen 5 năm trước cách đây
mục cha
commit
7fe084620e
2 tập tin đã thay đổi với 14 bổ sung21 xóa
  1. 7 11
      msm/sde_dbg.c
  2. 7 10
      rotator/sde_rotator_debug.c

+ 7 - 11
msm/sde_dbg.c

@@ -2949,11 +2949,9 @@ static void _sde_dump_reg(const char *dump_name, u32 reg_dump_flag,
 	end_addr = addr + len_bytes;
 
 	if (in_mem) {
-		if (dump_mem && !(*dump_mem)) {
-			phys_addr_t phys = 0;
-			*dump_mem = dma_alloc_coherent(sde_dbg_base.dev,
-					len_padded, &phys, GFP_KERNEL);
-		}
+		if (dump_mem && !(*dump_mem))
+			*dump_mem = devm_kzalloc(sde_dbg_base.dev, len_padded,
+					GFP_KERNEL);
 
 		if (dump_mem && *dump_mem) {
 			dump_addr = *dump_mem;
@@ -3189,7 +3187,6 @@ static void _sde_dbg_dump_sde_dbg_bus(struct sde_dbg_sde_debug_bus *bus)
 	u32 *dump_addr = NULL;
 	u32 status = 0;
 	struct sde_debug_bus_entry *head;
-	phys_addr_t phys = 0;
 	int list_size;
 	int i;
 	u32 offset;
@@ -3227,8 +3224,8 @@ static void _sde_dbg_dump_sde_dbg_bus(struct sde_dbg_sde_debug_bus *bus)
 
 	if (in_mem) {
 		if (!(*dump_mem))
-			*dump_mem = dma_alloc_coherent(sde_dbg_base.dev,
-				list_size, &phys, GFP_KERNEL);
+			*dump_mem = devm_kzalloc(sde_dbg_base.dev, list_size,
+					GFP_KERNEL);
 
 		if (*dump_mem) {
 			dump_addr = *dump_mem;
@@ -3338,7 +3335,6 @@ static void _sde_dbg_dump_vbif_dbg_bus(struct sde_dbg_vbif_debug_bus *bus)
 	u32 value, d0, d1;
 	unsigned long reg, reg1, reg2;
 	struct vbif_debug_bus_entry *head;
-	phys_addr_t phys = 0;
 	int i, list_size = 0;
 	void __iomem *mem_base = NULL;
 	struct vbif_debug_bus_entry *dbg_bus;
@@ -3388,8 +3384,8 @@ static void _sde_dbg_dump_vbif_dbg_bus(struct sde_dbg_vbif_debug_bus *bus)
 
 	if (in_mem) {
 		if (!(*dump_mem))
-			*dump_mem = dma_alloc_coherent(sde_dbg_base.dev,
-				list_size, &phys, GFP_KERNEL);
+			*dump_mem = devm_kzalloc(sde_dbg_base.dev, list_size,
+					GFP_KERNEL);
 
 		if (*dump_mem) {
 			dump_addr = *dump_mem;

+ 7 - 10
rotator/sde_rotator_debug.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  */
 #define pr_fmt(fmt)	"%s: " fmt, __func__
 
@@ -121,7 +121,6 @@ static void sde_rot_dump_debug_bus(u32 bus_dump_flag, u32 **dump_mem)
 	u32 *dump_addr = NULL;
 	u32 status = 0;
 	struct sde_rot_debug_bus *head;
-	phys_addr_t phys = 0;
 	int i;
 	u32 offset;
 	void __iomem *base;
@@ -137,9 +136,9 @@ static void sde_rot_dump_debug_bus(u32 bus_dump_flag, u32 **dump_mem)
 
 	if (in_mem) {
 		if (!(*dump_mem))
-			*dump_mem = dma_alloc_coherent(&mdata->pdev->dev,
+			*dump_mem = devm_kzalloc(&mdata->pdev->dev,
 				mdata->rot_dbg_bus_size * 4 * sizeof(u32),
-				&phys, GFP_KERNEL);
+				GFP_KERNEL);
 
 		if (*dump_mem) {
 			dump_addr = *dump_mem;
@@ -249,7 +248,6 @@ static void sde_rot_dump_vbif_debug_bus(u32 bus_dump_flag,
 	u32 *dump_addr = NULL;
 	u32 value;
 	struct sde_rot_vbif_debug_bus *head;
-	phys_addr_t phys = 0;
 	int i, list_size = 0;
 	void __iomem *vbif_base;
 	struct sde_rot_vbif_debug_bus *dbg_bus;
@@ -277,8 +275,8 @@ static void sde_rot_dump_vbif_debug_bus(u32 bus_dump_flag,
 
 	if (in_mem) {
 		if (!(*dump_mem))
-			*dump_mem = dma_alloc_coherent(&mdata->pdev->dev,
-				list_size, &phys, GFP_KERNEL);
+			*dump_mem = devm_kzalloc(&mdata->pdev->dev, list_size,
+					GFP_KERNEL);
 
 		if (*dump_mem) {
 			dump_addr = *dump_mem;
@@ -332,7 +330,6 @@ void sde_rot_dump_reg(const char *dump_name, u32 reg_dump_flag,
 	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
 	bool in_log, in_mem;
 	u32 *dump_addr = NULL;
-	phys_addr_t phys = 0;
 	int i;
 	void __iomem *base;
 
@@ -348,8 +345,8 @@ void sde_rot_dump_reg(const char *dump_name, u32 reg_dump_flag,
 
 	if (in_mem) {
 		if (!(*dump_mem))
-			*dump_mem = dma_alloc_coherent(&mdata->pdev->dev,
-				len * 16, &phys, GFP_KERNEL);
+			*dump_mem = devm_kzalloc(&mdata->pdev->dev, len * 16,
+					GFP_KERNEL);
 
 		if (*dump_mem) {
 			dump_addr = *dump_mem;