linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: bugzilla-daemon@bugzilla.kernel.org
To: linuxppc-dev@lists.ozlabs.org
Subject: [Bug 205201] Booting halts if Dawicontrol DC-2976 UW SCSI board installed, unless RAM size limited to 3500M
Date: Wed, 06 Nov 2019 19:36:15 +0000	[thread overview]
Message-ID: <bug-205201-206035-9IdykV1CIH@https.bugzilla.kernel.org/> (raw)
In-Reply-To: <bug-205201-206035@https.bugzilla.kernel.org/>

https://bugzilla.kernel.org/show_bug.cgi?id=205201

--- Comment #6 from Christian Zigotzky (chzigotzky@xenosoft.de) ---
FYI because of the issue with some PCI cards (SCSI, TV cards etc):

Christoph Hellwig wrote:
Can you send me the .config and a dmesg?  And in the meantime try the patch
below?

From 4d659b7311bd4141fdd3eeeb80fa2d7602ea01d4 Mon Sep 17 00:00:00 2001
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Date: Fri, 18 Oct 2019 13:00:43 +0200
Subject: dma-direct: check for overflows on 32 bit DMA addresses

As seen on the new Raspberry Pi 4 and sta2x11's DMA implementation it is
possible for a device configured with 32 bit DMA addresses and a partial
DMA mapping located at the end of the address space to overflow. It
happens when a higher physical address, not DMAable, is translated to
it's DMA counterpart.

For example the Raspberry Pi 4, configurable up to 4 GB of memory, has
an interconnect capable of addressing the lower 1 GB of physical memory
with a DMA offset of 0xc0000000. It transpires that, any attempt to
translate physical addresses higher than the first GB will result in an
overflow which dma_capable() can't detect as it only checks for
addresses bigger then the maximum allowed DMA address.

Fix this by verifying in dma_capable() if the DMA address range provided
is at any point lower than the minimum possible DMA address on the bus.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
include/linux/dma-direct.h | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index adf993a3bd58..6ad9e9ea7564 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -3,6 +3,7 @@
#define _LINUX_DMA_DIRECT_H 1

#include <linux/dma-mapping.h>
+#include <linux/memblock.h> /* for min_low_pfn */
#include <linux/mem_encrypt.h>

#ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
@@ -27,6 +28,13 @@ static inline bool dma_capable(struct device *dev,
dma_addr_t addr, size_t size)
   if (!dev->dma_mask)
       return false;

+#ifndef CONFIG_ARCH_DMA_ADDR_T_64BIT
+    /* Check if DMA address overflowed */
+    if (min(addr, addr + size - 1) <
+        __phys_to_dma(dev, (phys_addr_t)(min_low_pfn << PAGE_SHIFT)))
+        return false;
+#endif
+
   return addr + size - 1 <=
       min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
}

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

  parent reply	other threads:[~2019-11-06 19:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 14:36 [Bug 205201] New: Booting halts if Dawicontrol DC-2976 UW SCSI board installed, unless RAM size limited to 3500M bugzilla-daemon
2019-10-16 21:48 ` [Bug 205201] " bugzilla-daemon
2019-10-29 23:45 ` bugzilla-daemon
2019-11-05 10:58 ` bugzilla-daemon
2019-11-05 14:33 ` bugzilla-daemon
2019-11-05 14:47 ` bugzilla-daemon
2019-11-06 19:36 ` bugzilla-daemon [this message]
2019-11-07  8:46 ` bugzilla-daemon
2019-11-07  9:11 ` bugzilla-daemon
2019-11-07  9:13 ` bugzilla-daemon
2019-11-07  9:18 ` bugzilla-daemon
2019-11-10  7:11 ` bugzilla-daemon
2019-11-11  7:38 ` bugzilla-daemon
2019-11-11 12:19 ` bugzilla-daemon
2019-11-13 11:01 ` bugzilla-daemon
2019-11-16  6:48 ` bugzilla-daemon
2019-11-23 11:28 ` bugzilla-daemon
2020-01-10 10:15 ` bugzilla-daemon
2020-01-10 10:16 ` bugzilla-daemon
2020-01-13 12:28 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-205201-206035-9IdykV1CIH@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@bugzilla.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).