Skip to contentSkip to conversation

MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys()

PATCH Applied Paul Burton 1 participant 2 messages Feb 15, 2019 – Feb 19, 2019 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys()

Commit e36863a550da ("MIPS: HIGHMEM DMA on noncoherent MIPS32 processors") introduced code which:

1) Calculates an offset within a page, by ANDing an address with ~PAGE_MASK.

2) Checks whether that offset is >= PAGE_SIZE.

This check can never evaluate true, making the code it guards unreachable. smatch spots bogus arithmetic resulting from the impossible condition, resulting in the following warning:

arch/mips/mm/dma-noncoherent.c:125
dma_sync_phys() warn: mask and shift to zero

Fix this by removing the impossible to satisfy condition & the unreachable code it guards.

---

 arch/mips/mm/dma-noncoherent.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
arch/mips/mm/dma-noncoherent.c +1 -6
index f7e0fd6b7619..b57465733e87 100644
@@ -120,13 +120,8 @@ static inline void dma_sync_phys(phys_addr_t paddr, size_t size,
 		if (PageHighMem(page)) {
 			void *addr;
 
-			if (offset + len > PAGE_SIZE) {
-				if (offset >= PAGE_SIZE) {
-					page += offset >> PAGE_SHIFT;
-					offset &= ~PAGE_MASK;
-				}
+			if (offset + len > PAGE_SIZE)
 				len = PAGE_SIZE - offset;
-			}
 
 			addr = kmap_atomic(page);
 			dma_sync_virt(addr + offset, len, dir);
Signature · 1 line
2.20.1
author Applied
#1 lore raw

Hello,

Quoted 12 lines · Paul Burton

Commit e36863a550da ("MIPS: HIGHMEM DMA on noncoherent MIPS32 processors") introduced code which:

1) Calculates an offset within a page, by ANDing an address with ~PAGE_MASK.

2) Checks whether that offset is >= PAGE_SIZE.

This check can never evaluate true, making the code it guards unreachable. smatch spots bogus arithmetic resulting from the impossible condition, resulting in the following warning:

Quoted 7 lines

arch/mips/mm/dma-noncoherent.c:125
dma_sync_phys() warn: mask and shift to zero

Fix this by removing the impossible to satisfy condition & the unreachable code it guards.

Applied to mips-next.

Thanks,
Paul

[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]