About Loongson platforms' directories
Hi, MIPS maintainers
Recently Loongson has released their now SystemOnChip chip called Loongson2K, and I'm going to submit patches for that chip soon. But I noticed that currently, Loongson64 code in mainline kernel is pretty in confusion. We mixed loongson2e/2f/3a/3b together in /arch/mips/loongson64, but they don't have many similarities. 2E/2F are legacy products that don't support many features such as EFI or SMBIOS, only a little code can be reused with 3 series. After discussed with another maintainer Huacai Chen, we thought we can separate 2E/2F with 3 series and make 4 directories.
/loongson-1 (Loongson 1B/1C Micro Control Units formal loongson32) /loongson-2ef (Loongson 2E/2F legacy CPU machines formal loongson64/lemote-2f fuloong-2e)
/loongson-2soc (Loongson2H/2K SoCs will be submited latter) /loongson-3 (Loongson 3A/3B CPU machines formal loongson64/loongson3)
So we can maintain code for different family chips easier. Just ask if anybody have a better idea about that.
BTW: My recent patches have been ignored for a long time. Probably because Ralf didn't appear for a long time. Just ask if these patches can get a chance to be applied. And I don't know what's the proper upstream for me, Ralf's mips-next or James's mips-next?
Signature · 1 line
Jiaxun Yang
Quoted 8 lines · Jiaxun Yang
Hi, MIPS maintainers
Recently Loongson has released their now SystemOnChip chip called Loongson2K, and I'm going to submit patches for that chip soon. But I noticed that currently, Loongson64 code in mainline kernel is pretty in confusion. We mixed loongson2e/2f/3a/3b together in /arch/mips/loongson64, but they don't have many similarities. 2E/2F are legacy products that don't support many features such as EFI or SMBIOS,
Can you expand on these. To what extent is Loongson's EFI similar to the EFI from the x86 world? Do these allow multiple new platforms to be supported more easily without much new platform code (like devicetree support would)?
Quoted 4 lines
only a little code can be reused with 3 series. After discussed with another maintainer Huacai Chen, we thought we can separate 2E/2F with 3 series and make 4 directories.
Quoted 8 lines
/loongson-1 (Loongson 1B/1C Micro Control Units formal loongson32) /loongson-2ef (Loongson 2E/2F legacy CPU machines formal loongson64/lemote-2f fuloong-2e)
/loongson-2soc (Loongson2H/2K SoCs will be submited latter) /loongson-3 (Loongson 3A/3B CPU machines formal loongson64/loongson3)So we can maintain code for different family chips easier. Just ask if anybody have a better idea about that.
I believe the general approach in the ARM camp since Linus put his foot down about the proliferation of platform code is to have it all devicetree based rather than littering the arch directories with platform devices. That way a single multiplatform kernel can boot on a variety of different platforms with the DT provided by the bootloader or appended to the kernel.
As well as cleaning up and reducing platform code it also simplifies the work for distributions since they only need a small number of kernel builds.
On that front MIPS has the "generic" platform (Paul CC'd) which is effectively a multi-platform configuration. It is possible to produce a single ITB file which contains a kernel and multiple device tree files for different platforms which the bootloader can choose from. It may be possible to also boot using legacy boot protocols too, though it depends on how it differs from the MIPS UHI spec (so a single kernel could boot on either platform), and it may require some form of DT shim to set up a DT for the kernel to use internally.
What challenges would you foresee if Loongson headed this way? (even if it was a single separate loongson platform in the kernel source). It may require some driver revamping, and the boot protocol might be an issue for it to share with the other "generic" platforms. Each new board potentially becomes easier to upstream though since the only new arch code is devicetree, and the rest is drivers in various other subsystems.
That's the way things should be heading in my opinion (and already are).
Quoted 5 lines
BTW: My recent patches have been ignored for a long time. Probably because Ralf didn't appear for a long time. Just ask if these patches can get a chance to be applied. And I don't know what's the proper upstream for me, Ralf's mips-next or James's mips-next?
Currently Ralf's mips-next, though there isn't a lot there yet and the merge window is imminent...
Cheers
James
Quoted 5 lines · On 2018年1月17日星期三 CST 下午1:25:13 James Hogan wrote:
Can you expand on these. To what extent is Loongson's EFI similar to the EFI from the x86 world? Do these allow multiple new platforms to be supported more easily without much new platform code (like devicetree support would)?
Hi James
Since I'm not familiar with loongson-3 platform, It's hard for me to expand difference between X86's EFI and Loongson's EFI. Maybe Huacai can explain that exactly. Here is a SPEC for reference (in Chinese):http://ftp.loongnix.org/ doc/05spec/%E9%BE%99%E8%8A%AFCPU%E5%BC%80%E5%8F%91%E7%B3%BB%E7%BB%9F%E5%9B%BA %E4%BB%B6%E4%B8%8E%E5%86%85%E6%A0%B8%E6%8E%A5%E5%8F%A3%E8%AF%A6%E7%BB %86%E8%A7%84%E8%8C%83V2.0.pdf . As far as I know, new platform with same chipsets can be supported by SMBIOS without any addition code in kernel. However, that feature is only avliable for Loongson-3.
Quoted 9 lines
I believe the general approach in the ARM camp since Linus put his foot down about the proliferation of platform code is to have it all devicetree based rather than littering the arch directories with platform devices. That way a single multiplatform kernel can boot on a variety of different platforms with the DT provided by the bootloader or appended to the kernel.
Quoted 3 lines
As well as cleaning up and reducing platform code it also simplifies the work for distributions since they only need a small number of kernel builds.
Yes I would like to do so. Loongson-2K have a limited support with DeviceTree (OpenFirmware) by U-Boot bootloader. Later SoC chips will also support DT as I know.
But Loongson-1 series and 2E/2F only have leagcy boot support, no EFI, no DT, even not all bootloader support machtype (in boot cmdline). That's why we want to creat different entries for these platforms.
Loongson's bootloader is pretty in mass. Loongson-3 is using both PMON2000 v3 and KunLunBIOS(A close-source EFI bootloader), Loongson-2E/2F is using PMON2000 v1 (also third-part out of tree U-boot support but not working perfectly). Loongson-1 is only using PMON2000. Newer SoCs will support both PMON2000 v3 and U-boot . PMON2000 have no DT support but I decide to submit only DT support to mainline.
Quoted 10 lines
On that front MIPS has the "generic" platform (Paul CC'd) which is effectively a multi-platform configuration. It is possible to produce a single ITB file which contains a kernel and multiple device tree files for different platforms which the bootloader can choose from. It may be possible to also boot using legacy boot protocols too, though it depends on how it differs from the MIPS UHI spec (so a single kernel could boot on either platform), and it may require some form of DT shim to set up a DT for the kernel to use internally.
Quoted 7 lines
What challenges would you foresee if Loongson headed this way? (even if it was a single separate loongson platform in the kernel source). It may require some driver revamping, and the boot protocol might be an issue for it to share with the other "generic" platforms. Each new board potentially becomes easier to upstream though since the only new arch code is devicetree, and the rest is drivers in various other subsystems.
Loongson isn't purchasing any IP core and made all the things by themself so we can't reuse most drivers already in kernel. We have to write many platform drivers such as PCI, BridgeChip, EC, addtion arch_init for chip and etc. That's why we prefer entries for Loongson platforms. Or generic may be filled with our platform drivers. Also for now loongson64 already have plenty of driver. I don't want to spend time in turn them to generic for other MIPS chips because they are not general....
Quoted 2 lines
That's the way things should be heading in my opinion (and already are).
Thanks
Signature · 2 lines
-- Jiaxun Yang
Hi Jiaxun,
Quoted 30 lines · Jiaxun Yang
Quoted 5 lines · On 2018年1月17日星期三 CST 下午1:25:13 James Hogan wrote:
Can you expand on these. To what extent is Loongson's EFI similar to the EFI from the x86 world? Do these allow multiple new platforms to be supported more easily without much new platform code (like devicetree support would)?
Hi James
Since I'm not familiar with loongson-3 platform, It's hard for me to expand difference between X86's EFI and Loongson's EFI. Maybe Huacai can explain that exactly. Here is a SPEC for reference (in Chinese):http://ftp.loongnix.org/ doc/05spec/%E9%BE%99%E8%8A%AFCPU%E5%BC%80%E5%8F%91%E7%B3%BB%E7%BB%9F%E5%9B%BA %E4%BB%B6%E4%B8%8E%E5%86%85%E6%A0%B8%E6%8E%A5%E5%8F%A3%E8%AF%A6%E7%BB %86%E8%A7%84%E8%8C%83V2.0.pdf . As far as I know, new platform with same chipsets can be supported by SMBIOS without any addition code in kernel. However, that feature is only avliable for Loongson-3.
Quoted 9 lines
I believe the general approach in the ARM camp since Linus put his foot down about the proliferation of platform code is to have it all devicetree based rather than littering the arch directories with platform devices. That way a single multiplatform kernel can boot on a variety of different platforms with the DT provided by the bootloader or appended to the kernel.
Quoted 3 lines
As well as cleaning up and reducing platform code it also simplifies the work for distributions since they only need a small number of kernel builds.
Quoted 6 lines
Yes I would like to do so. Loongson-2K have a limited support with DeviceTree (OpenFirmware) by U-Boot bootloader. Later SoC chips will also support DT as I know.
But Loongson-1 series and 2E/2F only have leagcy boot support, no EFI, no DT, even not all bootloader support machtype (in boot cmdline). That's why we want to creat different entries for these platforms.
It is possible to use DT even if boot loader does not supply it. The dtb can be append to the kernel and kernel can be configured to pick it up.
Quoted 25 lines
Loongson's bootloader is pretty in mass. Loongson-3 is using both PMON2000 v3 and KunLunBIOS(A close-source EFI bootloader), Loongson-2E/2F is using PMON2000 v1 (also third-part out of tree U-boot support but not working perfectly). Loongson-1 is only using PMON2000. Newer SoCs will support both PMON2000 v3 and U-boot . PMON2000 have no DT support but I decide to submit only DT support to mainline.
Quoted 10 lines
On that front MIPS has the "generic" platform (Paul CC'd) which is effectively a multi-platform configuration. It is possible to produce a single ITB file which contains a kernel and multiple device tree files for different platforms which the bootloader can choose from. It may be possible to also boot using legacy boot protocols too, thougtoh it depends on how it differs from the MIPS UHI spec (so a single kernel could boot on either platform), and it may require some form of DT shim to set up a DT for the kernel to use internally.
Quoted 7 lines
What challenges would you foresee if Loongson headed this way? (even if it was a single separate loongson platform in the kernel source). It may require some driver revamping, and the boot protocol might be an issue for it to share with the other "generic" platforms. Each new board potentially becomes easier to upstream though since the only new arch code is devicetree, and the rest is drivers in various other subsystems.
Quoted 7 lines
Loongson isn't purchasing any IP core and made all the things by themself so we can't reuse most drivers already in kernel. We have to write many platform drivers such as PCI, BridgeChip, EC, addtion
arch_initfor chip and etc. That's why we prefer entries for Loongson platforms. Or generic may be filled with our platform drivers. Also for now loongson64 already have plenty of driver. I don't want to spend time in turn them to generic for other MIPS chips because they are not general....
I think James is talking about having little to no platform code in arch/mips/loongson/. It is preferred to have Loongson specific drivers in driver/<hw-specific-framework> as it would help using common code the framework provides. Any change to driver will go via the respective framework maintainer (for example change to Loongson rtc driver can be submitted to the rtc maintainer) which will reduce mips maintainer burden and also increases responsiveness in getting the changes merged.
Quoted 12 lines
Quoted 2 lines
That's the way things should be heading in my opinion (and already are).
Thanks
--
--
Jiaxun Yang
Regards,
PrasannaKumar
Quoted 4 lines · On 2018年1月17日星期三 CST 下午10:04:46 PrasannaKumar Muralidharan wrote:
It is possible to use DT even if boot loader does not supply it. The dtb can be append to the kernel and kernel can be configured to pick it up.
Hi PrasannaKumar
Yes I know about that. But I think it's not necessary to introduce DT support for current Loongson platforms. Now, all machines with same SoC or CPU or MCU can share their kernel. 2E/2F differ platforms by machtype, 3 is using EFI just like DT. For loongson-mcu their is only one reference design in kernel. Introduce DT support will make whole boot progress more complex.
Loongson-2K have DT support in bootloader.
Quoted 9 lines
I think James is talking about having little to no platform code in
arch/mips/loongson/. It is preferred to have Loongson specific drivers in driver/<hw-specific-framework> as it would help using common code the framework provides. Any change to driver will go via the respective framework maintainer (for example change to Loongson rtc driver can be submitted to the rtc maintainer) which will reduce mips maintainer burden and also increases responsiveness in getting the changes merged.
Yeah, some drivers should put into their own subsystems. That's what we'll do during seprate the machs. But other drivers such as PM or PCI can only put in MIPS arch. Platform code should be reduced by DT and EFI, but for older systems (2e/2f), we still need some platform code. Since there will be no more new device for these systems, I think it's acceptable.
--
Jiaxun Yang
Quoted 10 lines · PrasannaKumar Muralidharan
Quoted 6 lines
Yes I would like to do so. Loongson-2K have a limited support with DeviceTree (OpenFirmware) by U-Boot bootloader. Later SoC chips will also support DT as I know.
But Loongson-1 series and 2E/2F only have leagcy boot support, no EFI, no DT, even not all bootloader support machtype (in boot cmdline). That's why we want to creat different entries for these platforms.It is possible to use DT even if boot loader does not supply it. The dtb can be append to the kernel and kernel can be configured to pick it up.
Problems start when such DTB disagrees with how the system has actually
been configured.
I once had to go through pains in the past when upgrading the kernel on a
Freescale board where different versions of the firmware set up resources differently and the DTS supplied with the kernel assumed the most recent one. I had to port random DTS updates to the old version to keep the old resource assignment while making the result understandable to the new kernel as the syntax evolved. And I think I may not have got everything right as e.g. I couldn't access the PATA CD-ROM the system was equipped with after the upgrade anymore (fortunately I didn't need it, so I just ignored the problem).
In case someone suggests I could have upgraded the firmware: well,
technically yes, but first that would cut the route back to the previous kernel version if the new one wasn't usable enough, and second the board was somewhere in a rack in a data centre across the pond, so no, I didn't dare bricking it.
So yes, having a DTB integrated with the kernel is certainly an option,
but a lot of care has to be taken to make it an aid rather than a burden.
FWIW,
Maciej