Message ID | 1244629493-24046-1-git-send-email-konrad@gaisler.com |
---|---|
State | Superseded |
Delegated to: | David Miller |
Headers | show |
Konrad, A couple of comments. On Wed, Jun 10, 2009 at 20:24, <konrad@gaisler.com> wrote: > From: Konrad Eisele <konrad@gaisler.com> > > sparc-leon specific SRMMU initialization and > bootup fixes. The sparc-leon caches are virtually tagged so a flush is needed on ctx > switch. > --- > arch/sparc/mm/srmmu.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 67 insertions(+), 0 deletions(-) > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > index 06c9a7d..0cf201b 100644 > --- a/arch/sparc/mm/srmmu.c > +++ b/arch/sparc/mm/srmmu.c > @@ -46,6 +46,10 @@ #include <asm/tsunami.h> > #include <asm/swift.h> > #include <asm/turbosparc.h> > > +#ifdef CONFIG_SPARC_LEON > +#include <asm/leon.h> > +#endif > + Hm, you don't need to ifdef this anymore =) > #include <asm/btfixup.h> > > enum mbus_module srmmu_modtype; > @@ -568,6 +572,11 @@ static void srmmu_switch_mm(struct mm_st > srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd); > } > > +#ifdef CONFIG_SPARC_LEON > + flush_tlb_mm(0); > + if (leon_flush_during_switch) > + leon_flush_cache_all(); > +#endif > if (is_hypersparc) > hyper_flush_whole_icache(); > Hmm... it would be nice to match the style of the statement after this, something like: if (is_leon) { flush_tlb_mm(0); if (leon_flush_during_switch) leon_flush_cache_all(); } But that would mean that the leon_flush_during_switch and leon_flush_cache_all() would have to be defined for the non-SPARC_LEON case, which isn't what you're trying to do here, however if leon_flush_cache_all() is defined as a blank function, the compiler *should* optimise all this away. Thanks,
>> enum mbus_module srmmu_modtype; >> @@ -568,6 +572,11 @@ static void srmmu_switch_mm(struct mm_st >> srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd); >> } >> >> +#ifdef CONFIG_SPARC_LEON >> + flush_tlb_mm(0); >> + if (leon_flush_during_switch) >> + leon_flush_cache_all(); >> +#endif >> if (is_hypersparc) >> hyper_flush_whole_icache(); >> > > Hmm... it would be nice to match the style of the statement after > this, something like: > > if (is_leon) { > flush_tlb_mm(0); > if (leon_flush_during_switch) > leon_flush_cache_all(); > } > > But that would mean that the leon_flush_during_switch and > leon_flush_cache_all() would have to be defined for the non-SPARC_LEON > case, which isn't what you're trying to do here, however if > leon_flush_cache_all() is defined as a blank function, the compiler > *should* optimise all this away. > I'm not shure what to do here. I wonder weather if (is_leon) { is better than a #ifdef CONFIG_SPARC_LEON it seems to me that the later is better. It seems to me that in case of the former you have to have the implicit knowledge that the compiler will optimize away the function calls (and you have to search your way through the source code to come to a conclusion that it will), and this is quite more complex and disturbing than a #ifdef. I'd think #ifdef CONFIG_SPARC_LEON is much cleaner. Moreover it is not in line with the general strategy: to make leon-specific parts be only compiled in when CONFIG_SPARC_LEON is defined. Then all leon_mm.c and leon_kernel.c should also be compiled in always and protected with is_leon() instead of only compiling it in the CONFIG_SPARC_LEON case... But, hey, he, who checkes in, decides. Maybe Dave Miller can say how it should be. -- Konrad -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Jun 11, 2009 at 17:01, Konrad Eisele<konrad@gaisler.com> wrote: >>> enum mbus_module srmmu_modtype; >>> @@ -568,6 +572,11 @@ static void srmmu_switch_mm(struct mm_st >>> srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd); >>> } >>> >>> +#ifdef CONFIG_SPARC_LEON >>> + flush_tlb_mm(0); >>> + if (leon_flush_during_switch) >>> + leon_flush_cache_all(); >>> +#endif >>> if (is_hypersparc) >>> hyper_flush_whole_icache(); >>> >> >> Hmm... it would be nice to match the style of the statement after >> this, something like: >> >> if (is_leon) { >> flush_tlb_mm(0); >> if (leon_flush_during_switch) >> leon_flush_cache_all(); >> } >> >> But that would mean that the leon_flush_during_switch and >> leon_flush_cache_all() would have to be defined for the non-SPARC_LEON >> case, which isn't what you're trying to do here, however if >> leon_flush_cache_all() is defined as a blank function, the compiler >> *should* optimise all this away. >> > > I'm not shure what to do here. I wonder weather > if (is_leon) { > is better than a > #ifdef CONFIG_SPARC_LEON > it seems to me that the later is better. > It seems to me that in case of the former you have to have the > implicit knowledge that the compiler will optimize away the > function calls (and you have to search your way through the source > code to come to a conclusion that it will), and this is quite more > complex and disturbing than a #ifdef. I'd think #ifdef CONFIG_SPARC_LEON > is much cleaner. > Moreover it is not in line with the general strategy: to make leon-specific > parts be only compiled in when CONFIG_SPARC_LEON is defined. Then all > leon_mm.c > and leon_kernel.c should also be compiled in always and protected with > is_leon() > instead of only compiling it in the CONFIG_SPARC_LEON case... > > But, hey, he, who checkes in, decides. Maybe Dave Miller can say how it > should be. I should possibly explain myself here a little. My agenda with hacking on SparcLinux is to get 32-bit Sparc fully tested and working with current kernel releases. (At the moment, I've completed phase 1, getting the hardware and am slowly working on phase 2, getting it to boot.) My methodology is to decrease the 32-bit specific parts of the code to the absolute minimum, whilst removing ifdef guards where possible to allow other methods, e.g. Kconfig, to choose which bits are compiled or not, with the end goal being that there is little difference between a 32-bit kernel and a 64-bit kernel. As I cast my eye over all these changes for SPARC LEON, I'm looking at the code in exactly the same way, asking myself the question "How can we merge this code into the existing code leaving little special-case code?" I understand your goals with this - get LEON support upstream, don't break existing systems - and I understand your methodology - making your changes disappear when SPARC_LEON is unset - but I *know* that I'll be submitting patches to do exactly what I'm talking about once I'm hacking at this again. Back to the code. As for leon_kernel.c and leon_mm.c, they shouldn't be compiled unless CONFIG_LEON is set, exactly as you have it now. As for this code, the cleanest option I see is to make leon_init() and leon_flush_cache_all() no-ops (or empty macros) when CONFIG_LEON isn't set. My rationale for this is simple: support for HyperSPARC CPUs adds some "dead" code on my MicroSPARC / SuperSPARC machines, and yet it cannot be compiled out, so why should LEON CPUs be treated any differently? As for things like new hardware or new bus types, they add little bulk, so I see no reason to cut them out when CONFIG_LEON isn't set. - and for all we know, AMBA bus may become the emerging standard for open source SPARC systems, not just LEON. Thanks for understanding =)
> As for leon_kernel.c and leon_mm.c, they shouldn't be compiled unless > CONFIG_LEON is set, exactly as you have it now. > > As for this code, the cleanest option I see is to make leon_init() and > leon_flush_cache_all() no-ops (or empty macros) when CONFIG_LEON isn't > set. My rationale for this is simple: support for HyperSPARC CPUs adds > some "dead" code on my MicroSPARC / SuperSPARC machines, and yet it > cannot be compiled out, so why should LEON CPUs be treated any > differently? > > As for things like new hardware or new bus types, they add little > bulk, so I see no reason to cut them out when CONFIG_LEON isn't set. - > and for all we know, AMBA bus may become the emerging standard for > open source SPARC systems, not just LEON. > > Thanks for understanding =) > Ok, then I'll do a is_leon approach and include the ambapp bus too, removing the ifdef. I'll wait for some more comments before I'll post yet enother round of patches, maybe next week. -- Konrad -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index 06c9a7d..0cf201b 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -46,6 +46,10 @@ #include <asm/tsunami.h> #include <asm/swift.h> #include <asm/turbosparc.h> +#ifdef CONFIG_SPARC_LEON +#include <asm/leon.h> +#endif + #include <asm/btfixup.h> enum mbus_module srmmu_modtype; @@ -568,6 +572,11 @@ static void srmmu_switch_mm(struct mm_st srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd); } +#ifdef CONFIG_SPARC_LEON + flush_tlb_mm(0); + if (leon_flush_during_switch) + leon_flush_cache_all(); +#endif if (is_hypersparc) hyper_flush_whole_icache(); @@ -1976,6 +1985,57 @@ #endif poke_srmmu = poke_viking; } +#ifdef CONFIG_SPARC_LEON + +extern void leon_flush_icache_all(void); +extern void leon_flush_dcache_all(void); +extern void leon_flush_pcache_all(struct vm_area_struct *vma, + unsigned long page); +extern void leon_flush_cache_all(void); +extern void leon_flush_tlb_all(void); +extern int leon_flush_during_switch ; +extern int leon_flush_needed(void); +extern void leon_flush_pcache_all(struct vm_area_struct *vma, + unsigned long page); + +void __init poke_leonsparc(void) +{ +} + +void __init init_leon(void) +{ + + srmmu_name = "Leon"; + + BTFIXUPSET_CALL(flush_cache_all, leon_flush_cache_all, + BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_mm, leon_flush_cache_all, + BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_page, leon_flush_pcache_all, + BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_range, leon_flush_cache_all, + BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_page_for_dma, leon_flush_dcache_all, + BTFIXUPCALL_NORM); + + BTFIXUPSET_CALL(flush_tlb_all, leon_flush_tlb_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_mm, leon_flush_tlb_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_page, leon_flush_tlb_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_range, leon_flush_tlb_all, BTFIXUPCALL_NORM); + + BTFIXUPSET_CALL(__flush_page_to_ram, leon_flush_cache_all, + BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(flush_sig_insns, leon_flush_cache_all, BTFIXUPCALL_NOP); + + poke_srmmu = poke_leonsparc; + + srmmu_cache_pagetables = 0; + + leon_flush_during_switch = leon_flush_needed(); +} + +#endif + /* Probe for the srmmu chip version. */ static void __init get_srmmu_type(void) { @@ -1991,6 +2051,13 @@ static void __init get_srmmu_type(void) psr_typ = (psr >> 28) & 0xf; psr_vers = (psr >> 24) & 0xf; +#ifdef CONFIG_SPARC_LEON + psr_typ = 0xf; /* hardcoded ids for older models/simulators */ + psr_vers = 2; + init_leon(); + return; +#endif + /* First, check for HyperSparc or Cypress. */ if(mod_typ == 1) { switch(mod_rev) {