diff mbox

dmaengine: zx: fix build warning

Message ID 1484040220-11517-1-git-send-email-jun.nie@linaro.org (mailing list archive)
State Accepted
Headers show

Commit Message

Jun Nie Jan. 10, 2017, 9:23 a.m. UTC
Fix build warning that related to PAGE_SIZE. The maximum DMA
length has nothing to do with PAGE_SIZE, just use a fix number
for the definition.

drivers/dma/zx_dma.c: In function 'zx_dma_prep_memcpy':
drivers/dma/zx_dma.c:523:8: warning: division by zero [-Wdiv-by-zero]
drivers/dma/zx_dma.c: In function 'zx_dma_prep_slave_sg':
drivers/dma/zx_dma.c:567:11: warning: division by zero [-Wdiv-by-zero]

Signed-off-by: Jun Nie <jun.nie@linaro.org>
---
 drivers/dma/zx_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Shawn Guo Jan. 11, 2017, 12:57 a.m. UTC | #1
On Tue, Jan 10, 2017 at 05:23:40PM +0800, Jun Nie wrote:
> Fix build warning that related to PAGE_SIZE. The maximum DMA
> length has nothing to do with PAGE_SIZE, just use a fix number
> for the definition.
> 
> drivers/dma/zx_dma.c: In function 'zx_dma_prep_memcpy':
> drivers/dma/zx_dma.c:523:8: warning: division by zero [-Wdiv-by-zero]
> drivers/dma/zx_dma.c: In function 'zx_dma_prep_slave_sg':
> drivers/dma/zx_dma.c:567:11: warning: division by zero [-Wdiv-by-zero]
> 
> Signed-off-by: Jun Nie <jun.nie@linaro.org>

HDMI audio works fine with the change, so:

Tested-by: Shawn Guo <shawn.guo@linaro.org>

But out of curiosity ...

> ---
>  drivers/dma/zx_dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
> index 42ff3e6..2bb6953 100644
> --- a/drivers/dma/zx_dma.c
> +++ b/drivers/dma/zx_dma.c
> @@ -26,7 +26,7 @@
>  
>  #define DRIVER_NAME		"zx-dma"
>  #define DMA_ALIGN		4
> -#define DMA_MAX_SIZE		(0x10000 - PAGE_SIZE)
> +#define DMA_MAX_SIZE		(0x10000 - 512)

Why do we need to minus some amount of bytes from 64KiB size for
DMA_MAX_SIZE at all?

>  #define LLI_BLOCK_SIZE		(4 * PAGE_SIZE)

Why do we need to have LLI_BLOCK_SIZE vary with PAGE_SIZE?

Shawn

>  
>  #define REG_ZX_SRC_ADDR			0x00
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jun Nie Jan. 11, 2017, 1:29 a.m. UTC | #2
On 2017年01月11日 08:57, Shawn Guo wrote:
> On Tue, Jan 10, 2017 at 05:23:40PM +0800, Jun Nie wrote:
>> Fix build warning that related to PAGE_SIZE. The maximum DMA
>> length has nothing to do with PAGE_SIZE, just use a fix number
>> for the definition.
>>
>> drivers/dma/zx_dma.c: In function 'zx_dma_prep_memcpy':
>> drivers/dma/zx_dma.c:523:8: warning: division by zero [-Wdiv-by-zero]
>> drivers/dma/zx_dma.c: In function 'zx_dma_prep_slave_sg':
>> drivers/dma/zx_dma.c:567:11: warning: division by zero [-Wdiv-by-zero]
>>
>> Signed-off-by: Jun Nie <jun.nie@linaro.org>
>
> HDMI audio works fine with the change, so:
>
> Tested-by: Shawn Guo <shawn.guo@linaro.org>
>
> But out of curiosity ...
>
>> ---
>>  drivers/dma/zx_dma.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
>> index 42ff3e6..2bb6953 100644
>> --- a/drivers/dma/zx_dma.c
>> +++ b/drivers/dma/zx_dma.c
>> @@ -26,7 +26,7 @@
>>
>>  #define DRIVER_NAME		"zx-dma"
>>  #define DMA_ALIGN		4
>> -#define DMA_MAX_SIZE		(0x10000 - PAGE_SIZE)
>> +#define DMA_MAX_SIZE		(0x10000 - 512)
>
> Why do we need to minus some amount of bytes from 64KiB size for
> DMA_MAX_SIZE at all?

For better alignment of DMA transfer size. Maximum size 0xFFFF minus 32 
or 64 shall be OK, but I prefer to 512 for better performance and safe.

>
>>  #define LLI_BLOCK_SIZE		(4 * PAGE_SIZE)
>
> Why do we need to have LLI_BLOCK_SIZE vary with PAGE_SIZE?

It is a trade off for dmam_pool size. 4 pages size does introduce 
pressure to memory management and allocation, and size is enough for 
most of DMA descriptor usage.

>
> Shawn
>
>>
>>  #define REG_ZX_SRC_ADDR			0x00
>> --
>> 1.9.1
>>

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul Jan. 25, 2017, 10:04 a.m. UTC | #3
On Tue, Jan 10, 2017 at 05:23:40PM +0800, Jun Nie wrote:
> Fix build warning that related to PAGE_SIZE. The maximum DMA
> length has nothing to do with PAGE_SIZE, just use a fix number
> for the definition.
> 
> drivers/dma/zx_dma.c: In function 'zx_dma_prep_memcpy':
> drivers/dma/zx_dma.c:523:8: warning: division by zero [-Wdiv-by-zero]
> drivers/dma/zx_dma.c: In function 'zx_dma_prep_slave_sg':
> drivers/dma/zx_dma.c:567:11: warning: division by zero [-Wdiv-by-zero]

Applied, thanks
diff mbox

Patch

diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 42ff3e6..2bb6953 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -26,7 +26,7 @@ 
 
 #define DRIVER_NAME		"zx-dma"
 #define DMA_ALIGN		4
-#define DMA_MAX_SIZE		(0x10000 - PAGE_SIZE)
+#define DMA_MAX_SIZE		(0x10000 - 512)
 #define LLI_BLOCK_SIZE		(4 * PAGE_SIZE)
 
 #define REG_ZX_SRC_ADDR			0x00