Hi, Jiaxun On Thu, Aug 6, 2020 at 1:39 AM Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> wrote: > > > > 在 2020/8/5 20:10, Thomas Bogendoerfer 写道: > > On Sat, Aug 01, 2020 at 03:59:41PM +0800, Huacai Chen wrote: > >> On Wed, May 6, 2020 at 1:30 PM Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> wrote: > >>> > >>> > >>> 于 2020年5月2日 GMT+08:00 下午12:55:43, Huacai Chen <chenhc@xxxxxxxxxx> 写到: > >>>> Loongson-3's COP2 is Multi-Media coprocessor, it is disabled in kernel > >>>> mode by default. However, gslq/gssq (16-bytes load/store instructions) > >>>> overrides the instruction format of lwc2/swc2. If we wan't to use gslq/ > >>>> gssq for optimization in kernel, we should enable COP2 usage in kernel. > >>>> > >>>> Please pay attention that in this patch we only enable COP2 in kernel, > >>>> which means it will lose ST0_CU2 when a process go to user space (try > >>>> to use COP2 in user space will trigger an exception and then grab COP2, > >>>> which is similar to FPU). And as a result, we need to modify the context > >>>> switching code because the new scheduled process doesn't contain ST0_CU2 > >>>> in its THERAD_STATUS probably. > >>>> > >>>> Signed-off-by: Huacai Chen <chenhc@xxxxxxxxxx> > >>> Reviewed-by: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> > >>> > >> Does this patch have some unresolved problems, or there is something unclear? > > yes there is. Since this COP2 is a total black box to me, it would be > > really helpfull to get some docs for it or at least some information what > > it exactly does and how you want to use it in kernel code. > > FYI: > Loongson doesn't have any CU2 register. It just reused LWC2 & LDC2 opcode > to define some load & store instructions (e.g. 128bit load to two GPRs). > > I have a collection of these instructions here[1]. > > From GS464E (3A2000+), execuating these instruction won't produce COP2 > unusable > exception. But older Loongson cores (GS464) will still produce COP2 > exception, thus > we should have CU2 enabled in kernel. That would allow us use to these > instructions > to optimize kernel. > > > > > Looking closer at the patch I realized, that there is already support > > for usage of COP2 in user land, which I thought isn't the case (at least > > I understood that from one of your mails). So is there enough state > > saving to support this ? > > Actually there is no CU2 state for Loongson to save. > > > > > And finally what I stil don't like is the splittering of more > > #ifdef LOONGSON into common code. I'd prefer a more generic way > > to enable COPx for in kernel usage. Maybe a more generic config option > > or a dynamic solution like the one for user land. > Agreed. some Kconfig options or cpuinfo_mips.options can be helpful. > So make those codes depend on CONFIG_CPU_LOONGSON3_WORKAROUNDS instead of CONFIG_CPU_LOONGSON64? Huacai > Thanks. > > - Jiaxun > > [1]: https://github.com/FlyGoat/loongson-insn/ > > > > Thomas. > >