[lowrisc-dev] Re: lowRISC kernel changes rebased over stock 4.19

Gabriel L. Somlo gsomlo at gmail.com
Wed Oct 31 17:54:16 GMT 2018


Jonathan,

Thanks for all your thoughtful responses. I'll trim this down to just
one of the multiple threads for now, to keep it to the point :)

On Wed, Oct 31, 2018 at 03:12:19PM +0000, Dr Jonathan Kimmitt wrote:
> > 
> > 	- lowrisc.patch, containing all peripheral drivers (keyboard,
> > 	  video, ethernet, microSD), as well as the timer hacks I
> > 	  avoided by modifying the DT, and this:
> > =========================================================
> > diff -urN linux-4.18-patched/kernel/dma/swiotlb.c riscv-linux-riscv-linux-4.18/kernel/dma/swiotlb.c
> > --- linux-4.18-patched/kernel/dma/swiotlb.c     2018-08-12 21:41:04.000000000 +0100
> > +++ riscv-linux-riscv-linux-4.18/kernel/dma/swiotlb.c 2018-09-17 15:23:49.410795216 +0100
> > @@ -147,7 +147,7 @@
> >   }
> >   /* default to 64MB */
> > -#define IO_TLB_DEFAULT_SIZE (64UL<<20)
> > +#define IO_TLB_DEFAULT_SIZE (1UL<<20)
> >   unsigned long swiotlb_size_or_default(void)
> >   {
> >          unsigned long size;
> > =========================================================
> > 	  ... which again, I ignored without any apparent ill effects.
> > 	  Any idea why it was in there, and how bad it is that I'm trying
> > 	  to ignore it? :)
> 
> The Nexys4DDR only has 128M of ram, so if you boot without this patch you
> will get a nasty surprise
> 
> when you use a free command for the first time. What! half of memory grabbed
> for a software I/O TLB!

That would be bad, but (after some liberal use of pr_warn() throughout
kernel/dma/swiotlb.c), as it turns out, the value of IO_TLB_DEFAULT_SIZE
never comes into play for lowRISC.

The only routine referencing IO_TLB_DEFAULT_SIZE caled during lowRISC
initialization is swiotlb_init(), which uses it to set the value of
the "default_size" variable. However, that never gets used, because
the global "io_tlb_nslabs" is already set to 1 from within
setup_io_tlb_npages(), due to the CONFIG_CMDLINE="swiotlb=noforce"
entry in the lowRISC defconfig!

So, swiotlb_init() will use io_tlb_nslabs=1 and bytes=2048 regardless
of the value of IO_TLB_DEFAULT_SIZE, which is ignored.

I would have voted to make IO_TLB_DEFAULT_SIZE configurable via
Kconfig (and push *that* upstream so we can just use it :) ) but as it
turns out that's not necessary, as CONFIG_CMDLINE is enough to preempt
it!

Thanks,
--Gabriel



More information about the lowrisc-dev mailing list