Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
On 2016/3/8 6:59, Andrew Morton wrote: > On Mon, 7 Mar 2016 18:43:47 +0800 "Leizhen (ThunderTown)" > wrote: > >> Suppose: >> CONFIG_SPARSEMEM is opened. >> CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. >> >> Then virt_to_page or phys_to_page will be called.

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
On 2016/3/8 6:59, Andrew Morton wrote: > On Mon, 7 Mar 2016 18:43:47 +0800 "Leizhen (ThunderTown)" > wrote: > >> Suppose: >> CONFIG_SPARSEMEM is opened. >> CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. >> >> Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, >>

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Andrew Morton
On Mon, 7 Mar 2016 18:43:47 +0800 "Leizhen (ThunderTown)" wrote: > Suppose: > CONFIG_SPARSEMEM is opened. > CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. > > Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, > __sec =

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Andrew Morton
On Mon, 7 Mar 2016 18:43:47 +0800 "Leizhen (ThunderTown)" wrote: > Suppose: > CONFIG_SPARSEMEM is opened. > CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. > > Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, > __sec = __pfn_to_section(__pfn) is NULL. > So access

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
On 2016/3/7 19:41, One Thousand Gnomes wrote: > On Mon, 7 Mar 2016 17:21:25 +0800 > Zhen Lei wrote: > >> Do this to keep consistent with kfree, which tolerate ptr is NULL. >> >> Signed-off-by: Zhen Lei > > This is inlined code so you

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
On 2016/3/7 19:41, One Thousand Gnomes wrote: > On Mon, 7 Mar 2016 17:21:25 +0800 > Zhen Lei wrote: > >> Do this to keep consistent with kfree, which tolerate ptr is NULL. >> >> Signed-off-by: Zhen Lei > > This is inlined code so you are adding extra logic to every single > instance of a

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread One Thousand Gnomes
On Mon, 7 Mar 2016 17:21:25 +0800 Zhen Lei wrote: > Do this to keep consistent with kfree, which tolerate ptr is NULL. > > Signed-off-by: Zhen Lei This is inlined code so you are adding extra logic to every single instance of a call to

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread One Thousand Gnomes
On Mon, 7 Mar 2016 17:21:25 +0800 Zhen Lei wrote: > Do this to keep consistent with kfree, which tolerate ptr is NULL. > > Signed-off-by: Zhen Lei This is inlined code so you are adding extra logic to every single instance of a call to the function. What is it's total effect on kernel size ?

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
Suppose: CONFIG_SPARSEMEM is opened. CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, __sec = __pfn_to_section(__pfn) is NULL. So access section->section_mem_map will trigger exception. - #define

Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Leizhen (ThunderTown)
Suppose: CONFIG_SPARSEMEM is opened. CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, __sec = __pfn_to_section(__pfn) is NULL. So access section->section_mem_map will trigger exception. - #define

[PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Zhen Lei
Do this to keep consistent with kfree, which tolerate ptr is NULL. Signed-off-by: Zhen Lei --- include/linux/dma-mapping.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index

[PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL

2016-03-07 Thread Zhen Lei
Do this to keep consistent with kfree, which tolerate ptr is NULL. Signed-off-by: Zhen Lei --- include/linux/dma-mapping.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 75857cd..fdd4294 100644 ---