On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
This patch makes a couple of changes to the SMBIOS/DMI scanning
code so it can be used on other archs (such as ARM and arm64):
(a) wrap the calls to ioremap()/iounmap(), this allows the use of a
flavor of ioremap() more suitable for random unaligned access;
(b) allow the non-EFI fallback probe into hardcoded physical address
0xF0000 to be disabled.
This patch and the ones that change x86 and ia64 dmi.h *must* stay
combined, otherwise you may break bisect for other people. (If you
apply this patch, but not the other ones, you break the build on x86
and/or ia64 because dma_early_ioremap does not exist yet)
I have already sent this patch to the list: I am hoping to get it
acked by one of the x86 maintainers, so you will be able to send it to
catalin and/or russell as part of this series and they can merge it
through their respective trees.
--
Ard.
> drivers/firmware/dmi_scan.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index fa0affb..92d7ce0 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -108,7 +108,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
> {
> u8 *buf;
>
> - buf = dmi_ioremap(dmi_base, dmi_len);
> + buf = dmi_early_remap(dmi_base, dmi_len);
> if (buf == NULL)
> return -1;
>
> @@ -116,7 +116,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
>
> add_device_randomness(buf, dmi_len);
>
> - dmi_iounmap(buf, dmi_len);
> + dmi_early_unmap(buf, dmi_len);
> return 0;
> }
>
> @@ -483,18 +483,19 @@ void __init dmi_scan_machine(void)
> * needed during early boot. This also means we can
> * iounmap the space when we're done with it.
> */
> - p = dmi_ioremap(efi.smbios, 32);
> + p = dmi_early_remap(efi.smbios, 32);
> if (p == NULL)
> goto error;
> memcpy_fromio(buf, p, 32);
> - dmi_iounmap(p, 32);
> + dmi_early_unmap(p, 32);
>
> if (!dmi_present(buf)) {
> dmi_available = 1;
> goto out;
> }
> } else {
> - p = dmi_ioremap(0xF0000, 0x10000);
> +#ifdef DMI_SCAN_MACHINE_NON_EFI_FALLBACK
> + p = dmi_early_ioremap(0xF0000, 0x10000);
> if (p == NULL)
> goto error;
>
> @@ -510,12 +511,13 @@ void __init dmi_scan_machine(void)
> memcpy_fromio(buf + 16, q, 16);
> if (!dmi_present(buf)) {
> dmi_available = 1;
> - dmi_iounmap(p, 0x10000);
> + dmi_early_unmap(p, 0x10000);
> goto out;
> }
> memcpy(buf, buf + 16, 16);
> }
> - dmi_iounmap(p, 0x10000);
> + dmi_early_unmap(p, 0x10000);
> +#endif
> }
> error:
> pr_info("DMI not present or invalid.\n");
> @@ -787,13 +789,13 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
> if (!dmi_available)
> return -1;
>
> - buf = ioremap(dmi_base, dmi_len);
> + buf = dmi_remap(dmi_base, dmi_len);
> if (buf == NULL)
> return -1;
>
> dmi_table(buf, dmi_len, dmi_num, decode, private_data);
>
> - iounmap(buf);
> + dmi_unmap(buf, dmi_len);
> return 0;
> }
> EXPORT_SYMBOL_GPL(dmi_walk);
> --
> 1.7.9.5
>