Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427911 > unrolled thread

Re: [PATCH] arm64: mm: only initialize swiotlb when necessary

Started byCatalin Marinas <catalin.marinas@arm.com>
First post2016-06-21 18:10 +0200
Last post2016-06-22 19:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] arm64: mm: only initialize swiotlb when necessary Catalin Marinas <catalin.marinas@arm.com> - 2016-06-21 18:10 +0200
    Re: [PATCH] arm64: mm: only initialize swiotlb when necessary Arnd Bergmann <arnd@arndb.de> - 2016-06-21 22:20 +0200
      Re: [PATCH] arm64: mm: only initialize swiotlb when necessary Catalin Marinas <catalin.marinas@arm.com> - 2016-06-22 19:00 +0200

#1427911 — Re: [PATCH] arm64: mm: only initialize swiotlb when necessary

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-06-21 18:10 +0200
SubjectRe: [PATCH] arm64: mm: only initialize swiotlb when necessary
Message-ID<rMwps-853-11@gated-at.bofh.it>
On Wed, Jun 08, 2016 at 05:49:59PM +0200, Arnd Bergmann wrote:
> On Wednesday, June 8, 2016 1:08:29 PM CEST Catalin Marinas wrote:
> > On Wed, Jun 08, 2016 at 03:53:46PM +0800, Jisheng Zhang wrote:
> > >  static int __init arm64_dma_init(void)
> > >  {
> > > +     if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
> > > +             swiotlb = 1;
> > > +
> > >       return atomic_pool_init();
> > >  }
> > 
> > So any platform with RAM larger than 4GB would still initialise swiotlb.
> > I wouldn't say it's an issue, 64MB is not a significant loss on such
> > systems.
> > 
> > An alternative would be to defer the freeing until we are aware of all
> > possible dma masks for the populated devices (e.g. from DT), though I'm
> > not sure that's enough, drivers may try to change such masks when
> > probed.
> 
> Right, this is a hard problem, because you can in theory have odd devices
> that require a DMA mask lower than the limit of ZONE_DMA.

I'm not sure what we can do about such devices even with swiotlb. The
bounce buffer is allocated from ZONE_DMA and currently it assumes a
32-bit mask from the start of RAM, so it is not guaranteed to support a
smaller mask. We may need to come up with some DT memory node attribute
to define the minimum DMA-able memory and restrict ZONE_DMA during early
boot but I would rather wait until we hit a real issue in practice.

Anyway, I plan to merge this patch as is, we can improve the logic in
the future if we have a better idea.

-- 
Catalin

[toc] | [next] | [standalone]


#1428131

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-21 22:20 +0200
Message-ID<rMAjn-264-5@gated-at.bofh.it>
In reply to#1427911
On Tuesday, June 21, 2016 5:06:25 PM CEST Catalin Marinas wrote:
> On Wed, Jun 08, 2016 at 05:49:59PM +0200, Arnd Bergmann wrote:
> > On Wednesday, June 8, 2016 1:08:29 PM CEST Catalin Marinas wrote:
> > > On Wed, Jun 08, 2016 at 03:53:46PM +0800, Jisheng Zhang wrote:
> > > >  static int __init arm64_dma_init(void)
> > > >  {
> > > > +     if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
> > > > +             swiotlb = 1;
> > > > +
> > > >       return atomic_pool_init();
> > > >  }
> > > 
> > > So any platform with RAM larger than 4GB would still initialise swiotlb.
> > > I wouldn't say it's an issue, 64MB is not a significant loss on such
> > > systems.
> > > 
> > > An alternative would be to defer the freeing until we are aware of all
> > > possible dma masks for the populated devices (e.g. from DT), though I'm
> > > not sure that's enough, drivers may try to change such masks when
> > > probed.
> > 
> > Right, this is a hard problem, because you can in theory have odd devices
> > that require a DMA mask lower than the limit of ZONE_DMA.
> 
> I'm not sure what we can do about such devices even with swiotlb. The
> bounce buffer is allocated from ZONE_DMA and currently it assumes a
> 32-bit mask from the start of RAM, so it is not guaranteed to support a
> smaller mask. We may need to come up with some DT memory node attribute
> to define the minimum DMA-able memory and restrict ZONE_DMA during early
> boot but I would rather wait until we hit a real issue in practice.

The bounce buffer is allocated at early boot time in order to get an address
as low as possible, in the hope that it is small enough for those cases.

	Arnd

[toc] | [prev] | [next] | [standalone]


#1428978

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-06-22 19:00 +0200
Message-ID<rMTFo-5Zi-27@gated-at.bofh.it>
In reply to#1428131
On Tue, Jun 21, 2016 at 10:13:45PM +0200, Arnd Bergmann wrote:
> On Tuesday, June 21, 2016 5:06:25 PM CEST Catalin Marinas wrote:
> > On Wed, Jun 08, 2016 at 05:49:59PM +0200, Arnd Bergmann wrote:
> > > On Wednesday, June 8, 2016 1:08:29 PM CEST Catalin Marinas wrote:
> > > > On Wed, Jun 08, 2016 at 03:53:46PM +0800, Jisheng Zhang wrote:
> > > > >  static int __init arm64_dma_init(void)
> > > > >  {
> > > > > +     if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
> > > > > +             swiotlb = 1;
> > > > > +
> > > > >       return atomic_pool_init();
> > > > >  }
> > > > 
> > > > So any platform with RAM larger than 4GB would still initialise swiotlb.
> > > > I wouldn't say it's an issue, 64MB is not a significant loss on such
> > > > systems.
> > > > 
> > > > An alternative would be to defer the freeing until we are aware of all
> > > > possible dma masks for the populated devices (e.g. from DT), though I'm
> > > > not sure that's enough, drivers may try to change such masks when
> > > > probed.
> > > 
> > > Right, this is a hard problem, because you can in theory have odd devices
> > > that require a DMA mask lower than the limit of ZONE_DMA.
> > 
> > I'm not sure what we can do about such devices even with swiotlb. The
> > bounce buffer is allocated from ZONE_DMA and currently it assumes a
> > 32-bit mask from the start of RAM, so it is not guaranteed to support a
> > smaller mask. We may need to come up with some DT memory node attribute
> > to define the minimum DMA-able memory and restrict ZONE_DMA during early
> > boot but I would rather wait until we hit a real issue in practice.
> 
> The bounce buffer is allocated at early boot time in order to get an address
> as low as possible, in the hope that it is small enough for those cases.

The swiotlb allocation is triggered from mem_init() and that's well
after the memblock has been initialised. The swiotlb_init() function
uses memblock_virt_alloc_low_nopanic() which is a top-down allocator
with an upper bound of ARCH_LOW_ADDRESS_LIMIT. The latter is set by the
arm64 code to the top 32-bit of RAM (plus some offset), so it's likely
that the swiotlb bounce buffer will be placed in the upper range of the
32-bit mask.

-- 
Catalin

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web