diff mbox series

MIPS: Scan the DMI system information

Message ID 1573056341-21159-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Superseded
Headers show
Series MIPS: Scan the DMI system information | expand

Commit Message

Tiezhu Yang Nov. 6, 2019, 4:05 p.m. UTC
Enable DMI scanning on the MIPS architecture, this setups DMI identifiers
(dmi_system_id) for printing it out on task dumps and prepares DIMM entry
information (dmi_memdev_info) from the SMBIOS table. With this patch, the
driver can easily match various of mainboards.

In the SMBIOS reference specification, the table anchor string "_SM_" is
present in the address range 0xF0000 to 0xFFFFF on a 16-byte boundary,
but there exists a special case for loongson platform, when call function
dmi_early_remap, it should specify the start address to 0xFFFE000 due to
it is reserved for SMBIOS and can be normally access in the BIOS.

Co-developed-by: Yinglu Yang <yangyinglu@loongson.cn>
Signed-off-by: Yinglu Yang <yangyinglu@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/Kconfig           | 12 ++++++++++++
 arch/mips/include/asm/dmi.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/kernel/setup.c    |  2 ++
 3 files changed, 57 insertions(+)
 create mode 100644 arch/mips/include/asm/dmi.h

Comments

Jiaxun Yang Nov. 7, 2019, 12:35 a.m. UTC | #1
于 2019年11月7日 GMT+08:00 上午12:05:41, Tiezhu Yang <yangtiezhu@loongson.cn> 写到:
>Enable DMI scanning on the MIPS architecture, this setups DMI
>identifiers
>(dmi_system_id) for printing it out on task dumps and prepares DIMM
>entry
>information (dmi_memdev_info) from the SMBIOS table. With this patch,
>the
>driver can easily match various of mainboards.
>
>In the SMBIOS reference specification, the table anchor string "_SM_"
>is
>present in the address range 0xF0000 to 0xFFFFF on a 16-byte boundary,
>but there exists a special case for loongson platform, when call
>function
>dmi_early_remap, it should specify the start address to 0xFFFE000 due
>to
>it is reserved for SMBIOS and can be normally access in the BIOS.
>
>Co-developed-by: Yinglu Yang <yangyinglu@loongson.cn>
>Signed-off-by: Yinglu Yang <yangyinglu@loongson.cn>
>Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>---
> arch/mips/Kconfig           | 12 ++++++++++++
>arch/mips/include/asm/dmi.h | 43
>+++++++++++++++++++++++++++++++++++++++++++
> arch/mips/kernel/setup.c    |  2 ++
> 3 files changed, 57 insertions(+)
> create mode 100644 arch/mips/include/asm/dmi.h
>
>diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>index 7cb8947..0a67b18 100644
>--- a/arch/mips/Kconfig
>+++ b/arch/mips/Kconfig
>@@ -2757,6 +2757,18 @@ config HW_PERF_EVENTS
> 	  Enable hardware performance counter support for perf events. If
> 	  disabled, perf events will use software events only.
> 
>+# Mark as expert because too many people got it wrong.
>+# The code disables itself when not needed.
>+config DMI
>+	default y
>+	select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
>+	bool "Enable DMI scanning" if EXPERT
>+	help
>+	  Enabled scanning of DMI to identify machine quirks. Say Y
>+	  here unless you have verified that your setup is not
>+	  affected by entries in the DMI blacklist. Required by PNP
>+	  BIOS code.
>+
> config SMP
> 	bool "Multi-Processing support"
> 	depends on SYS_SUPPORTS_SMP
>diff --git a/arch/mips/include/asm/dmi.h b/arch/mips/include/asm/dmi.h
>new file mode 100644
>index 0000000..1f3da37
>--- /dev/null
>+++ b/arch/mips/include/asm/dmi.h
>@@ -0,0 +1,43 @@
>+/* SPDX-License-Identifier: GPL-2.0 */
>+#ifndef _ASM_MIPS_DMI_H
>+#define _ASM_MIPS_DMI_H
>+
>+#define dmi_early_remap		mips_early_memremap
>+#define dmi_early_unmap		mips_early_memunmap
>+#define dmi_remap(_x, _l)	mips_memremap(_x, _l, MEMREMAP_WB)
>+#define dmi_unmap(_x)		mips_memunmap(_x)
>+
>+#define dmi_alloc(l)		memblock_alloc_low(l, PAGE_SIZE)
>+
>+void __init *mips_early_memremap(resource_size_t phys_addr, unsigned
>long size)
>+{
>+#if defined(CONFIG_MACH_LOONGSON64)
>+	if (phys_addr == 0xF0000)
>+		phys_addr = 0xFFFE000;
>+
>+	return (void *)TO_CAC(phys_addr);
>+#else
>+	return NULL;
>+#endif
>+}

Hi Tiezhu,

It is really tricky to hijack dmi address here during remap.
I think we should set the dmi table address at  dmi_scan.c by a marco or something else rather than hijack it during remap.

Btw: Probably we should set DMI default y when MACH_LOONGSON64 is set?

Thanks.
Tiezhu Yang Nov. 7, 2019, 2:42 a.m. UTC | #2
On 11/07/2019 08:35 AM, Jiaxun Yang wrote:
>
> 于 2019年11月7日 GMT+08:00 上午12:05:41, Tiezhu Yang <yangtiezhu@loongson.cn> 写到:
>> Enable DMI scanning on the MIPS architecture, this setups DMI
>> identifiers
>> (dmi_system_id) for printing it out on task dumps and prepares DIMM
>> entry
>> information (dmi_memdev_info) from the SMBIOS table. With this patch,
>> the
>> driver can easily match various of mainboards.
>>
>> In the SMBIOS reference specification, the table anchor string "_SM_"
>> is
>> present in the address range 0xF0000 to 0xFFFFF on a 16-byte boundary,
>> but there exists a special case for loongson platform, when call
>> function
>> dmi_early_remap, it should specify the start address to 0xFFFE000 due
>> to
>> it is reserved for SMBIOS and can be normally access in the BIOS.
>>
>> Co-developed-by: Yinglu Yang <yangyinglu@loongson.cn>
>> Signed-off-by: Yinglu Yang <yangyinglu@loongson.cn>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>> arch/mips/Kconfig           | 12 ++++++++++++
>> arch/mips/include/asm/dmi.h | 43
>> +++++++++++++++++++++++++++++++++++++++++++
>> arch/mips/kernel/setup.c    |  2 ++
>> 3 files changed, 57 insertions(+)
>> create mode 100644 arch/mips/include/asm/dmi.h
>>
>> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>> index 7cb8947..0a67b18 100644
>> --- a/arch/mips/Kconfig
>> +++ b/arch/mips/Kconfig
>> @@ -2757,6 +2757,18 @@ config HW_PERF_EVENTS
>> 	  Enable hardware performance counter support for perf events. If
>> 	  disabled, perf events will use software events only.
>>
>> +# Mark as expert because too many people got it wrong.
>> +# The code disables itself when not needed.
>> +config DMI
>> +	default y
>> +	select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
>> +	bool "Enable DMI scanning" if EXPERT
>> +	help
>> +	  Enabled scanning of DMI to identify machine quirks. Say Y
>> +	  here unless you have verified that your setup is not
>> +	  affected by entries in the DMI blacklist. Required by PNP
>> +	  BIOS code.
>> +
>> config SMP
>> 	bool "Multi-Processing support"
>> 	depends on SYS_SUPPORTS_SMP
>> diff --git a/arch/mips/include/asm/dmi.h b/arch/mips/include/asm/dmi.h
>> new file mode 100644
>> index 0000000..1f3da37
>> --- /dev/null
>> +++ b/arch/mips/include/asm/dmi.h
>> @@ -0,0 +1,43 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _ASM_MIPS_DMI_H
>> +#define _ASM_MIPS_DMI_H
>> +
>> +#define dmi_early_remap		mips_early_memremap
>> +#define dmi_early_unmap		mips_early_memunmap
>> +#define dmi_remap(_x, _l)	mips_memremap(_x, _l, MEMREMAP_WB)
>> +#define dmi_unmap(_x)		mips_memunmap(_x)
>> +
>> +#define dmi_alloc(l)		memblock_alloc_low(l, PAGE_SIZE)
>> +
>> +void __init *mips_early_memremap(resource_size_t phys_addr, unsigned
>> long size)
>> +{
>> +#if defined(CONFIG_MACH_LOONGSON64)
>> +	if (phys_addr == 0xF0000)
>> +		phys_addr = 0xFFFE000;
>> +
>> +	return (void *)TO_CAC(phys_addr);
>> +#else
>> +	return NULL;
>> +#endif
>> +}
> Hi Tiezhu,
>
> It is really tricky to hijack dmi address here during remap.
> I think we should set the dmi table address at  dmi_scan.c by a marco or something else rather than hijack it during remap.

Hi Jiaxun,

Thanks for your review. I agree with you, let me think about it and try to
find a proper way, and then I will send a v2 patch.

>
> Btw: Probably we should set DMI default y when MACH_LOONGSON64 is set?

CONFIG_DMI is set to y by default, I think there is no need to select 
DMI when
set CONFIG_MACH_LOONGSON64.

Thanks,

Tiezhu Yang

>
> Thanks.
>
Jiaxun Yang Nov. 7, 2019, 3:42 a.m. UTC | #3
于 2019年11月7日 GMT+08:00 上午10:42:23, Tiezhu Yang <yangtiezhu@loongson.cn> 写到:
>On 11/07/2019 08:35 AM, Jiaxun Yang wrote:
>>
>> 于 2019年11月7日 GMT+08:00 上午12:05:41, Tiezhu Yang
><yangtiezhu@loongson.cn> 写到:
>>> Enable DMI scanning on the MIPS architecture, this setups DMI
>>> identifiers
>>> (dmi_system_id) for printing it out on task dumps and prepares DIMM
>>> entry
>>> information (dmi_memdev_info) from the SMBIOS table. With this
>patch,
>>> the
>>> driver can easily match various of mainboards.
>>>
>>> In the SMBIOS reference specification, the table anchor string
>"_SM_"
>>> is
>>> present in the address range 0xF0000 to 0xFFFFF on a 16-byte
>boundary,
>>> but there exists a special case for loongson platform, when call
>>> function
>>> dmi_early_remap, it should specify the start address to 0xFFFE000
>due
>>> to
>>> it is reserved for SMBIOS and can be normally access in the BIOS.
>>>
>>> Co-developed-by: Yinglu Yang <yangyinglu@loongson.cn>
>>> Signed-off-by: Yinglu Yang <yangyinglu@loongson.cn>
>>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>>> ---
>>> arch/mips/Kconfig           | 12 ++++++++++++
>>> arch/mips/include/asm/dmi.h | 43
>>> +++++++++++++++++++++++++++++++++++++++++++
>>> arch/mips/kernel/setup.c    |  2 ++
>>> 3 files changed, 57 insertions(+)
>>> create mode 100644 arch/mips/include/asm/dmi.h
>>>
>>> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>>> index 7cb8947..0a67b18 100644
>>> --- a/arch/mips/Kconfig
>>> +++ b/arch/mips/Kconfig
>>> @@ -2757,6 +2757,18 @@ config HW_PERF_EVENTS
>>> 	  Enable hardware performance counter support for perf events. If
>>> 	  disabled, perf events will use software events only.
>>>
>>> +# Mark as expert because too many people got it wrong.
>>> +# The code disables itself when not needed.
>>> +config DMI
>>> +	default y
>>> +	select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
>>> +	bool "Enable DMI scanning" if EXPERT
>>> +	help
>>> +	  Enabled scanning of DMI to identify machine quirks. Say Y
>>> +	  here unless you have verified that your setup is not
>>> +	  affected by entries in the DMI blacklist. Required by PNP
>>> +	  BIOS code.
>>> +
>>> config SMP
>>> 	bool "Multi-Processing support"
>>> 	depends on SYS_SUPPORTS_SMP
>>> diff --git a/arch/mips/include/asm/dmi.h
>b/arch/mips/include/asm/dmi.h
>>> new file mode 100644
>>> index 0000000..1f3da37
>>> --- /dev/null
>>> +++ b/arch/mips/include/asm/dmi.h
>>> @@ -0,0 +1,43 @@
>>> +/* SPDX-License-Identifier: GPL-2.0 */
>>> +#ifndef _ASM_MIPS_DMI_H
>>> +#define _ASM_MIPS_DMI_H
>>> +
>>> +#define dmi_early_remap		mips_early_memremap
>>> +#define dmi_early_unmap		mips_early_memunmap
>>> +#define dmi_remap(_x, _l)	mips_memremap(_x, _l, MEMREMAP_WB)
>>> +#define dmi_unmap(_x)		mips_memunmap(_x)
>>> +
>>> +#define dmi_alloc(l)		memblock_alloc_low(l, PAGE_SIZE)
>>> +
>>> +void __init *mips_early_memremap(resource_size_t phys_addr,
>unsigned
>>> long size)
>>> +{
>>> +#if defined(CONFIG_MACH_LOONGSON64)
>>> +	if (phys_addr == 0xF0000)
>>> +		phys_addr = 0xFFFE000;
>>> +
>>> +	return (void *)TO_CAC(phys_addr);
>>> +#else
>>> +	return NULL;
>>> +#endif
>>> +}
>> Hi Tiezhu,
>>
>> It is really tricky to hijack dmi address here during remap.
>> I think we should set the dmi table address at  dmi_scan.c by a marco
>or something else rather than hijack it during remap.
>
>Hi Jiaxun,
>
>Thanks for your review. I agree with you, let me think about it and try
>to
>find a proper way, and then I will send a v2 patch.
>
>>
>> Btw: Probably we should set DMI default y when MACH_LOONGSON64 is
>set?
>
>CONFIG_DMI is set to y by default, I think there is no need to select 
>DMI when
>set CONFIG_MACH_LOONGSON64.

Sorry, I meant only default to y when MACH_LOONGSON64 is set or even depends on MACH_LOONGSON64. As Loongson is the only known MIPS platform that supports DMI. Default y unconditionally may lead to regression on other MIPS platforms.

>
>Thanks,
>
>Tiezhu Yang
>
>>
>> Thanks.
>>
diff mbox series

Patch

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7cb8947..0a67b18 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2757,6 +2757,18 @@  config HW_PERF_EVENTS
 	  Enable hardware performance counter support for perf events. If
 	  disabled, perf events will use software events only.
 
+# Mark as expert because too many people got it wrong.
+# The code disables itself when not needed.
+config DMI
+	default y
+	select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
+	bool "Enable DMI scanning" if EXPERT
+	help
+	  Enabled scanning of DMI to identify machine quirks. Say Y
+	  here unless you have verified that your setup is not
+	  affected by entries in the DMI blacklist. Required by PNP
+	  BIOS code.
+
 config SMP
 	bool "Multi-Processing support"
 	depends on SYS_SUPPORTS_SMP
diff --git a/arch/mips/include/asm/dmi.h b/arch/mips/include/asm/dmi.h
new file mode 100644
index 0000000..1f3da37
--- /dev/null
+++ b/arch/mips/include/asm/dmi.h
@@ -0,0 +1,43 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_MIPS_DMI_H
+#define _ASM_MIPS_DMI_H
+
+#define dmi_early_remap		mips_early_memremap
+#define dmi_early_unmap		mips_early_memunmap
+#define dmi_remap(_x, _l)	mips_memremap(_x, _l, MEMREMAP_WB)
+#define dmi_unmap(_x)		mips_memunmap(_x)
+
+#define dmi_alloc(l)		memblock_alloc_low(l, PAGE_SIZE)
+
+void __init *mips_early_memremap(resource_size_t phys_addr, unsigned long size)
+{
+#if defined(CONFIG_MACH_LOONGSON64)
+	if (phys_addr == 0xF0000)
+		phys_addr = 0xFFFE000;
+
+	return (void *)TO_CAC(phys_addr);
+#else
+	return NULL;
+#endif
+}
+
+void __init mips_early_memunmap(void *addr, unsigned long size)
+{
+
+}
+
+void *mips_memremap(resource_size_t offset, size_t size, unsigned long flags)
+{
+#if defined(CONFIG_MACH_LOONGSON64)
+	return (void *)TO_CAC(offset);
+#else
+	return NULL;
+#endif
+}
+
+void mips_memunmap(void *addr)
+{
+
+}
+
+#endif /* _ASM_MIPS_DMI_H */
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c3d4212..da7d312 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -28,6 +28,7 @@ 
 #include <linux/decompress/generic.h>
 #include <linux/of_fdt.h>
 #include <linux/of_reserved_mem.h>
+#include <linux/dmi.h>
 
 #include <asm/addrspace.h>
 #include <asm/bootinfo.h>
@@ -802,6 +803,7 @@  void __init setup_arch(char **cmdline_p)
 #endif
 
 	arch_mem_init(cmdline_p);
+	dmi_setup();
 
 	resource_init();
 	plat_smp_setup();