linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys()
@ 2019-02-15 22:03 Paul Burton
  2019-02-19 20:48 ` Paul Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Burton @ 2019-02-15 22:03 UTC (permalink / raw)
  To: linux-mips; +Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, 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:

  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.

Signed-off-by: Paul Burton <paul.burton@mips.com>
---

 arch/mips/mm/dma-noncoherent.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c
index f7e0fd6b7619..b57465733e87 100644
--- a/arch/mips/mm/dma-noncoherent.c
+++ b/arch/mips/mm/dma-noncoherent.c
@@ -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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys()
  2019-02-15 22:03 [PATCH] MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys() Paul Burton
@ 2019-02-19 20:48 ` Paul Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Burton @ 2019-02-19 20:48 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Christoph Hellwig, Marek Szyprowski, Robin Murphy,
	Paul Burton, linux-mips

Hello,

Paul Burton wrote:
> 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.
> 
> Signed-off-by: Paul Burton <paul.burton@mips.com>

Applied to mips-next.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-19 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 22:03 [PATCH] MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys() Paul Burton
2019-02-19 20:48 ` Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).