From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
Geert Uytterhoeven <geert@linux-m68k.org>,
Nicolas Pitre <nico@fluxnic.net>,
Catalin Marinas <catalin.marinas@arm.com>,
open list <linux-kernel@vger.kernel.org>,
linus.walleij@linaro.org, Rob Herring <robh+dt@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH 1/2] ARM: Fix off by one in checking DMA zone size
Date: Fri, 29 Apr 2022 16:15:38 +0100 [thread overview]
Message-ID: <YmwBGh5mvuNIgyRY@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220324175417.1014562-2-f.fainelli@gmail.com>
On Thu, Mar 24, 2022 at 10:54:16AM -0700, Florian Fainelli wrote:
> The maximum DMA address is PAGE_OFFSET + arm_dma_zone_size - 1, fix this
> by doing the appropriate subtraction.
The question is... is MAX_DMA_ADDRESS inclusive or exclusive. The answer
is rather indeterminant, unfortunately.
drivers/net/wan/cosa.c: if (b + len >= MAX_DMA_ADDRESS)
So, if the buffer address + buffer length is equal to MAX_DMA_ADDRESS,
then the buffer is not DMA-able. To me this looks completely wrong.
It's also completely wrong because 'b' is a "unsigned long" which
means on 32-bit, this can wrap.
drivers/parport/parport_pc.c:
unsigned long start = (unsigned long) buf;
unsigned long end = (unsigned long) buf + length - 1;
if (end < MAX_DMA_ADDRESS) {
So, "end" is the last byte of the buffer. If MAX_DMA_ADDRESS is the last
byte of the virtual address space that supports DMA, then if the two are
equal, we do not use DMA. This seems wrong to me, and points to it being
an _exclusive_ value - it's the last byte plus one.
there's a bunch of memblock allocation functions that use
__pa(MAX_DMA_ADDRESS) as the "min_addr" and if this is a minimum
address, then surely this means that it is also an exclusive value.
So, I came to the conclusion that MAX_DMA_ADDRESS is supposed to be
exclusive. In other words, where PAGE_OFFSET + sizeof(ram) if
sizeof(ram) is the size in bytes of the RAM, limited to the maximum
addressable virtual address that RAM can be mapped to.
I don't see an inclusive value being correct, at least not for the cases
I've looekd at.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-04-29 15:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 17:54 [PATCH 0/2] ARM: MAX_DMA_ADDRESS fixes Florian Fainelli
2022-03-24 17:54 ` [PATCH 1/2] ARM: Fix off by one in checking DMA zone size Florian Fainelli
2022-03-24 19:02 ` Linus Walleij
2022-04-29 15:15 ` Russell King (Oracle) [this message]
2022-04-29 15:45 ` Arnd Bergmann
2022-03-24 17:54 ` [PATCH 2/2] ARM: Clamp MAX_DMA_ADDRESS to 32-bit Florian Fainelli
2022-03-24 19:02 ` Linus Walleij
2022-03-24 20:31 ` Geert Uytterhoeven
2022-03-24 22:39 ` Florian Fainelli
2022-04-29 15:07 ` Russell King (Oracle)
2022-04-26 16:29 ` [PATCH 0/2] ARM: MAX_DMA_ADDRESS fixes Florian Fainelli
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=YmwBGh5mvuNIgyRY@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=f.fainelli@gmail.com \
--cc=geert@linux-m68k.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nico@fluxnic.net \
--cc=robh+dt@kernel.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).