Re: [linux-yocto] [PATCH 1/1] dma: xilinx: dpdma: alloc xilinx_dpdma_tx_desc using GFP_ATOMIC

2019-10-16 Thread Quanyang Wang


On 10/17/19 1:01 AM, Hyun Kwon wrote:

Hi Quanyang,

Thanks for the patch.

On Tue, 2019-10-15 at 22:49:41 -0700, Michal Simek wrote:

+Hyun,

On 15. 10. 19 16:56, quanyang.w...@windriver.com wrote:

From: Quanyang Wang 

The function xilinx_dpdma_chan_alloc_tx_desc can be called
from atomic context, hence use GFP_ATOMIC instead of GFP_KERNEL,
or else it will cause the calltrace as below:

BUG: sleeping function called from invalid context at mm/slab.h:418
in_atomic(): 1, irqs_disabled(): 128, pid: 416, name: alsa-sink-(null 
Preemption disabled at:
[] snd_pcm_stream_lock_irq+0x40/0x50
CPU: 2 PID: 416 Comm: alsa-sink-(null Tainted: G O 5.2.17-yocto-standard #1
Hardware name: ZynqMP ZCU102 Rev1.0 (DT) Call trace:
dump_backtrace+0x0/0x138
show_stack+0x24/0x30
dump_stack+0x94/0xbc
___might_sleep+0x14c/0x178
__might_sleep+0x58/0x90
kmem_cache_alloc_trace+0x1a4/0x300
xilinx_dpdma_chan_alloc_tx_desc.isra.0+0x24/0x40
xilinx_dpdma_prep_dma_cyclic+0xc0/0x208
snd_dmaengine_pcm_trigger+0xf8/0x198
soc_pcm_trigger+0xb4/0x128
snd_pcm_do_start+0x48/0x58
snd_pcm_action_single+0x4c/0xa0
snd_pcm_action+0x78/0x90
snd_pcm_action_lock_irq+0x3c/0x60
snd_pcm_common_ioctl+0x4ac/0x10c8
snd_pcm_ioctl+0x48/0x68
do_vfs_ioctl+0x6d4/0x968
ksys_ioctl+0x84/0xb8
__arm64_sys_ioctl+0x28/0x38
el0_svc_common.constprop.0+0x74/0x180
el0_svc_handler+0x70/0x90
el0_svc+0x8/0xc

Signed-off-by: Quanyang Wang 

Maybe the 'nonatomic' can be set to true in xilinx_dp_dai_links? But I don't
know much about the flag, ex what's required, and I don't see any problem with
this change. So,

  Reviewed-by: Hyun Kwon 


Hi Hyun,

Thank you for looking this patch over.

I test and the "nonatomic" can also eliminate the calltrace.  But I 
don't know if there is any


problem with alsa driver running in a nonatomic context.

And do you think it's better using GFP_NOWAIT instead of GFP_ATOMIC ? 
This can save some atomic memory.


Hope to get your advice.

Thanks,

Quanyang




Thanks,
-hyun


---
  drivers/dma/xilinx/xilinx_dpdma.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xilinx_dpdma.c 
b/drivers/dma/xilinx/xilinx_dpdma.c
index 1ea509e00742..89ade893f51c 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -797,7 +797,7 @@ xilinx_dpdma_chan_alloc_tx_desc(struct xilinx_dpdma_chan 
*chan)
  {
struct xilinx_dpdma_tx_desc *tx_desc;
  
-	tx_desc = kzalloc(sizeof(*tx_desc), GFP_KERNEL);

+   tx_desc = kzalloc(sizeof(*tx_desc), GFP_ATOMIC);
if (!tx_desc)
return NULL;
  


Hyun: Can you please review this?

Thanks,
Michal

--
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 1/1] clk: zynqmp: fix memory leak in zynqmp_register_clocks

2019-10-16 Thread quanyang.wang
From: Quanyang Wang 

This is detected by kmemleak running on zcu102 board:

unreferenced object 0xffc877e48180 (size 128):
comm "swapper/0", pid 1, jiffies 4294892909 (age 315.436s)
hex dump (first 32 bytes):
64 70 5f 76 69 64 65 6f 5f 72 65 66 5f 64 69 76 dp_video_ref_div
31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1...
backtrace:
[] __kmalloc_track_caller+0x200/0x380
[] kvasprintf+0x7c/0x100
[] kasprintf+0x60/0x80
[<92298b05>] zynqmp_register_clocks+0x29c/0x398
[] zynqmp_clock_probe+0x3cc/0x4c0
[<5f5986f0>] platform_drv_probe+0x58/0xa8
[] really_probe+0xd8/0x2a8
[] driver_probe_device+0x5c/0x100
[<38f91fcf>] __device_attach_driver+0x98/0xb8
[<8a3f2ac2>] bus_for_each_drv+0x74/0xd8
[<1cb2783d>] __device_attach+0xe0/0x140
[] device_initial_probe+0x24/0x30
[<6998de4b>] bus_probe_device+0x9c/0xa8
[<647ae6ff>] device_add+0x3c0/0x610
[<71c14bb8>] of_device_add+0x40/0x50
[<4bb5d132>] of_platform_device_create_pdata+0xbc/0x138

This is because that when num_nodes is larger than 1, clk_out is
allocated using kasprintf for these nodes but only the last node's
clk_out is freed.

Signed-off-by: Quanyang Wang 
---
 drivers/clk/zynqmp/clkc.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index 64355fd07f6b..536f68c98e97 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -563,7 +563,7 @@ static struct clk_hw *zynqmp_register_clk_topology(int 
clk_id, char *clk_name,
 {
int j;
u32 num_nodes, clk_dev_id;
-   char *clk_out = NULL;
+   char *clk_out[MAX_NODES];
struct clock_topology *nodes;
struct clk_hw *hw = NULL;
 
@@ -577,16 +577,16 @@ static struct clk_hw *zynqmp_register_clk_topology(int 
clk_id, char *clk_name,
 * Intermediate clock names are postfixed with type of clock.
 */
if (j != (num_nodes - 1)) {
-   clk_out = kasprintf(GFP_KERNEL, "%s%s", clk_name,
+   clk_out[j] = kasprintf(GFP_KERNEL, "%s%s", clk_name,
clk_type_postfix[nodes[j].type]);
} else {
-   clk_out = kasprintf(GFP_KERNEL, "%s", clk_name);
+   clk_out[j] = kasprintf(GFP_KERNEL, "%s", clk_name);
}
 
if (!clk_topology[nodes[j].type])
continue;
 
-   hw = (*clk_topology[nodes[j].type])(clk_out, clk_dev_id,
+   hw = (*clk_topology[nodes[j].type])(clk_out[j], clk_dev_id,
parent_names,
num_parents,
&nodes[j]);
@@ -595,9 +595,12 @@ static struct clk_hw *zynqmp_register_clk_topology(int 
clk_id, char *clk_name,
 __func__,  clk_dev_id, clk_name,
 PTR_ERR(hw));
 
-   parent_names[0] = clk_out;
+   parent_names[0] = clk_out[j];
}
-   kfree(clk_out);
+
+   for (j = 0; j < num_nodes; j++)
+   kfree(clk_out[j]);
+
return hw;
 }
 
-- 
2.17.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [kernel v5.2/standard/xlnx-soc][PATCH 0/1] fix kmemleak in zcu102

2019-10-16 Thread quanyang.wang
From: Quanyang Wang 

Hi Bruce, Michal,

This patch fixes a kmemleak in zcu102 board.

Would you please help review and merge these patches to linux-yocto
v5.2/standard/xlnx-soc branch?

Quanyang Wang (1):
  clk: zynqmp: fix memory leak in zynqmp_register_clocks

 drivers/clk/zynqmp/clkc.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

-- 
2.17.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto