On Tue, 17 Jan 2017 21:58:31 +0100 Alexander Graf <ag...@suse.de> wrote:
> > > On 17/01/2017 21:45, Emmanuel Vadot wrote: > > On Tue, 17 Jan 2017 21:13:51 +0100 > > Alexander Graf <ag...@suse.de> wrote: > > > >> > >> > >> On 17/01/2017 16:50, Emmanuel Vadot wrote: > >>> From: Warner Losh <i...@freebsd.org> > >>> > >>> FreeBSD loader(8) just loaded code to some random location that may > >>> contain stale icache entries. > >>> FreeBSD Kernel needs the icache and dcache flushed. > >>> Before running either one of them, flush the icache and dcache. > >>> > >>> Signed-off-by: Emmanuel Vadot <m...@bidouilliste.com> > >> > >> Is there any downside to doing the flush always? I would prefer to not > >> conditionalize it on CONFIG_FREEBSD. > > > > I don't think there is any downside. > > > >>> --- > >>> api/api.c | 5 +++++ > >>> cmd/boot.c | 5 +++++ > >>> cmd/elf.c | 8 +++++++- > >>> 3 files changed, 17 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/api/api.c b/api/api.c > >>> index 8a1433af78..cc25deca09 100644 > >>> --- a/api/api.c > >>> +++ b/api/api.c > >>> @@ -290,6 +290,11 @@ static int API_dev_close(va_list ap) > >>> if (!err) > >>> di->state = DEV_STA_CLOSED; > >>> > >>> +#ifdef CONFIG_FREEBSD > >>> + flush_dcache_all(); > >>> + invalidate_icache_all(); > >>> +#endif > >>> + > >>> return err; > >>> } > >>> > >>> diff --git a/cmd/boot.c b/cmd/boot.c > >>> index 72f2cf362d..a1a91fbf0a 100644 > >>> --- a/cmd/boot.c > >>> +++ b/cmd/boot.c > >>> @@ -19,6 +19,11 @@ __attribute__((weak)) > >>> unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, > >>> char * const argv[]) > >>> { > >>> +#ifdef CONFIG_FREEBSD > >>> + flush_dcache_all(); > >>> + invalidate_icache_all(); > >>> +#endif > >>> + > >>> return entry (argc, argv); > >>> } > >>> > >>> diff --git a/cmd/elf.c b/cmd/elf.c > >>> index 5190cc6c0f..b2827fa042 100644 > >>> --- a/cmd/elf.c > >>> +++ b/cmd/elf.c > >>> @@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong > >>> (*entry)(int, char * const[]), > >>> { > >>> unsigned long ret; > >>> > >>> +#ifndef CONFIG_FREEBSD > >>> /* > >>> * QNX images require the data cache is disabled. > >>> * Data cache is already flushed, so just turn it off. > >>> @@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong > >>> (*entry)(int, char * const[]), > >>> int dcache = dcache_status(); > >>> if (dcache) > >>> dcache_disable(); > >> > >> Can FreeBSD boot with dcache disabled? Is there some way we can > >> determine what payload we have from the elf header? > >> > >> > >> Alex > > > > FreeBSD can boot with dcache disabled (our loader and kernel can) > > I'm not sure I get your other question, sorry. > > Your patch #ifdefs out the dcache_disable() if CONFIG_FREEBSD is set. So > if you can boot just fine with dcache disabled, you can remove this hunk > altogether FWIW. Loading the kernel from our loader is much faster with dcache enabled (1 sec instead of 5/7 sec). I guess we can always flush the cache and only disable it for QNX, I'll check if there is a CONFIG_QNX or something like that. > All the other changes in this file are mere cache flushes - and they > shouldn't hurt any u-boot api user and thus could be done unconditionally. True, I can remove the #ifdefs on CONFIG_FREEBSD here. > > Alex -- Emmanuel Vadot <m...@bidouilliste.com> <m...@freebsd.org> _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot