MIPS: mm: Move some checks out of 'for' loop in DMA operations
PATCH 1/1 MIPS: mm: Move some checks out of 'for' loop in DMA operations
The check cpu_needs_post_dma_flush() in mips_dma_sync_sg_for_cpu() and the check !plat_device_is_coherent() in mips_dma_sync_sg_for_device() can be moved outside the for loop.
As a side effect, this also avoids a GCC bug that caused kernel compile to fail with the error:
arch/mips/mm/dma-default.c: In function 'mips_dma_sync_sg_for_cpu':arch/mips/mm/dma-default.c:316:1: internal compiler error: in add_insn_before, at emit-rtl.c:3852
This gcc failure is seen in Code Sourcery toolchains [e.g. gcc version 4.7.2 (Sourcery CodeBench Lite 2012.09-99)] after commit "MIPS: Optimize current_cpu_type() for better code."
--- arch/mips/mm/dma-default.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/mips/mm/dma-default.c +4 -8
@@ -307,12 +307,10 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */ -for (i =0 ; i < nelems; i++, sg++) { -if (cpu_needs_post_dma_flush (dev)) +if (cpu_needs_post_dma_flush (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } } static void mips_dma_sync_sg_for_device(struct device *dev,
@@ -320,12 +318,10 @@ static void mips_dma_sync_sg_for_device(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */ -for (i =0 ; i < nelems; i++, sg++) { -if (!plat_device_is_coherent (dev)) +if (!plat_device_is_coherent (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } }int mips_dma_mapping_error (struct device *dev,dma_addr_t dma_addr)
Signature · 1 line
1.7.9.5
Quoted 42 lines · Jayachandran C
The check
cpu_needs_post_dma_flush()inmips_dma_sync_sg_for_cpu()and the check !plat_device_is_coherent() inmips_dma_sync_sg_for_device()can be moved outside the for loop.As a side effect, this also avoids a GCC bug that caused kernel compile to fail with the error:
arch/mips/mm/dma-default.c: In function 'mips_dma_sync_sg_for_cpu':arch/mips/mm/dma-default.c:316:1: internal compiler error: inadd_insn_before, at emit-rtl.c:3852This gcc failure is seen in Code Sourcery toolchains [e.g. gcc version 4.7.2 (Sourcery CodeBench Lite 2012.09-99)] after commit "MIPS: Optimize
current_cpu_type()for better code."--- arch/mips/mm/dma-default.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)arch/mips/mm/dma-default.c +2
-5@@ -307,12 +307,10 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */ -for (i =0 ; i < nelems; i++, sg++) { -if (cpu_needs_post_dma_flush (dev)) +if (cpu_needs_post_dma_flush (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } } static void mips_dma_sync_sg_for_device(struct device *dev,@@ -320,12 +318,10 @@ static void mips_dma_sync_sg_for_device(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */
arch/mips/mm/dma-default.c static void mips_dma_sync_sg_for_device(struct device *dev, · line 327
Quoted 10 lines
arch/mips/mm/dma-default.c +2
-3-for (i =0 ; i < nelems; i++, sg++) { -if (!plat_device_is_coherent (dev)) +if (!plat_device_is_coherent (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } }int mips_dma_mapping_error (struct device *dev,dma_addr_t dma_addr)
Hi,
The patch looks good to me and it fixes the gcc problem indeed (the bug is also present in gcc-4.7.3 from the 2013.05 release)
Reviewed-by/Tested-by: Markos Chandras <[email protected]>
On Wed, Sep 25, 2013 at 06:31:05PM +0530, Jayachandran C wrote:
The patch was missing the required Signed-off-by, added below.
Quoted 7 lines
The check
cpu_needs_post_dma_flush()inmips_dma_sync_sg_for_cpu()and the check !plat_device_is_coherent() inmips_dma_sync_sg_for_device()can be moved outside the for loop.As a side effect, this also avoids a GCC bug that caused kernel compile to fail with the error:
Quoted 6 lines
arch/mips/mm/dma-default.c: In function 'mips_dma_sync_sg_for_cpu':arch/mips/mm/dma-default.c:316:1: internal compiler error: inadd_insn_before, at emit-rtl.c:3852This gcc failure is seen in Code Sourcery toolchains [e.g. gcc version 4.7.2 (Sourcery CodeBench Lite 2012.09-99)] after commit "MIPS: Optimize
current_cpu_type()for better code."
Quoted 28 lines
--- arch/mips/mm/dma-default.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)arch/mips/mm/dma-default.c +2
-5@@ -307,12 +307,10 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */ -for (i =0 ; i < nelems; i++, sg++) { -if (cpu_needs_post_dma_flush (dev)) +if (cpu_needs_post_dma_flush (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } } static void mips_dma_sync_sg_for_device(struct device *dev,@@ -320,12 +318,10 @@ static void mips_dma_sync_sg_for_device(struct device *dev, {int i; -/* Make sure that gcc doesn't leave the empty loop body. */
arch/mips/mm/dma-default.c static void mips_dma_sync_sg_for_device(struct device *dev, · line 327
Quoted 10 lines
arch/mips/mm/dma-default.c +2
-3-for (i =0 ; i < nelems; i++, sg++) { -if (!plat_device_is_coherent (dev)) +if (!plat_device_is_coherent (dev)) +for (i =0 ; i < nelems; i++, sg++)__dma_sync (sg_page (sg), sg->offset, sg->length, direction); - } }int mips_dma_mapping_error (struct device *dev,dma_addr_t dma_addr)
JC.
Quoted 1 line · Jayachandran C.
The patch was missing the required Signed-off-by, added below.
Thanks, the patch is now in the tree.
(Further sifting through patches is currently being hampered by X crashing ever faster so I'm back to text console for now ...)
Ralf