linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: f.fainelli@gmail.com, mbrugger@suse.com, marc.zyngier@arm.com,
	robin.murphy@arm.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, robh+dt@kernel.org, wahrenst@gmx.net,
	m.szyprowski@samsung.com, linux-riscv@lists.infradead.org,
	phill@raspberrypi.org, Will Deacon <will@kernel.org>,
	hch@lst.de, linux-arm-kernel@lists.infradead.org,
	linux-rpi-kernel@lists.infradead.org
Subject: Re: [PATCH v5 3/4] arm64: use both ZONE_DMA and ZONE_DMA32
Date: Wed, 11 Sep 2019 15:35:27 +0100	[thread overview]
Message-ID: <20190911143527.GB43864@C02TF0J2HF1T.local> (raw)
In-Reply-To: <b0b824bebb9ef13ce746f9914de83126b0386e23.camel@suse.de>

On Wed, Sep 11, 2019 at 12:54:38PM +0200, Nicolas Saenz Julienne wrote:
> On Mon, 2019-09-09 at 11:58 +0200, Nicolas Saenz Julienne wrote:
> >  /*
> > - * Return the maximum physical address for ZONE_DMA32 (DMA_BIT_MASK(32)). It
> > - * currently assumes that for memory starting above 4G, 32-bit devices will
> > - * use a DMA offset.
> > + * Return the maximum physical address for a zone with a given address size
> > + * limit. It currently assumes that for memory starting above 4G, 32-bit
> > + * devices will use a DMA offset.
> >   */
> > -static phys_addr_t __init max_zone_dma32_phys(void)
> > +static phys_addr_t __init max_zone_phys(unsigned int zone_bits)
> >  {
> >         phys_addr_t offset = memblock_start_of_DRAM() & GENMASK_ULL(63, 32);
> > -       return min(offset + (1ULL << 32), memblock_end_of_DRAM());
> > +       return min(offset + (1ULL << zone_bits), memblock_end_of_DRAM());
> >  }
> 
> while testing other code on top of this series on odd arm64 machines I found an
> issue: when memblock_start_of_DRAM() != 0, max_zone_phys() isn't taking into
> account the offset to the beginning of memory. This doesn't matter with
> zone_bits == 32 but it does when zone_bits == 30.

I thought about this but I confused myself and the only case I had in
mind was an AMD Seattle system with RAM starting at 4GB.

What we need from this function is that the lowest naturally aligned
2^30 RAM is covered by ZONE_DMA while the rest to 2^32 are ZONE_DMA32.
This assumed that devices only capable of 30-bit (or 32-bit), have the
top address bits hardwired to be able access the bottom of the memory
(and this would be expressed in DT as the DMA offset).

I guess the fix here is to use GENMASK_ULL(63, zone_bits).

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-09-11 14:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09  9:58 [PATCH v5 0/4] Raspberry Pi 4 DMA addressing support Nicolas Saenz Julienne
2019-09-09  9:58 ` [PATCH v5 1/4] arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys() Nicolas Saenz Julienne
2019-09-09  9:58 ` [PATCH v5 2/4] arm64: rename variables used to calculate ZONE_DMA32's size Nicolas Saenz Julienne
2019-09-09  9:58 ` [PATCH v5 3/4] arm64: use both ZONE_DMA and ZONE_DMA32 Nicolas Saenz Julienne
2019-09-11 10:54   ` Nicolas Saenz Julienne
2019-09-11 14:35     ` Catalin Marinas [this message]
2019-09-11 15:00       ` Nicolas Saenz Julienne
2019-09-09  9:58 ` [PATCH v5 4/4] mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type' Nicolas Saenz Julienne
2019-09-09 19:33 ` [PATCH v5 0/4] Raspberry Pi 4 DMA addressing support Stefan Wahren
2019-09-09 19:50   ` Nicolas Saenz Julienne
2019-09-10  9:27   ` Matthias Brugger
2019-09-12 17:18     ` Matthias Brugger
2019-09-12 17:27       ` Florian Fainelli
2019-09-12 19:32       ` Stefan Wahren
2019-09-13  7:15         ` Matthias Brugger
2019-09-13  8:09         ` Matthias Brugger
2019-09-13  8:50           ` Stefan Wahren
2019-09-13  9:25             ` Matthias Brugger
2019-09-13 10:08               ` Stefan Wahren
2019-09-13 10:39                 ` Matthias Brugger
2019-09-16 19:19                   ` Stefan Wahren
2019-09-17  9:04                     ` Matthias Brugger
2019-09-17 18:03                       ` Stefan Wahren
2019-09-27 16:44                         ` Stefan Wahren

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=20190911143527.GB43864@C02TF0J2HF1T.local \
    --to=catalin.marinas@arm.com \
    --cc=f.fainelli@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=marc.zyngier@arm.com \
    --cc=mbrugger@suse.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=phill@raspberrypi.org \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=wahrenst@gmx.net \
    --cc=will@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).