* [PATCH] firmware: dmi: handle missing DMI data gracefully
@ 2017-10-12 19:59 Ard Biesheuvel
2017-10-17 7:27 ` Jean Delvare
0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2017-10-12 19:59 UTC (permalink / raw)
To: linux-kernel, jdelvare; +Cc: Ard Biesheuvel
Currently, when booting a kernel with DMI support on a platform that has
no DMI tables, the following output is emitted into the kernel log:
[ 0.128818] DMI not present or invalid.
...
[ 1.306659] dmi: Firmware registration failed.
...
[ 2.908681] dmi-sysfs: dmi entry is absent.
The first one is a pr_info(), but the subsequent ones are pr_err()s that
complain about a condition that is not really an error to begin with.
So let's clean this up, and give up silently if dma_available is not set.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/firmware/dmi-sysfs.c | 3 +++
drivers/firmware/dmi_scan.c | 6 ++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index d5de6ee8466d..3a264cbbb5a6 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -651,6 +651,9 @@ static int __init dmi_sysfs_init(void)
int error;
int val;
+ if (!dmi_available)
+ return 0;
+
if (!dmi_kobj) {
pr_err("dmi-sysfs: dmi entry is absent.\n");
error = -ENODATA;
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 783041964439..17a7425063c2 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -715,10 +715,8 @@ static int __init dmi_init(void)
u8 *dmi_table;
int ret = -ENOMEM;
- if (!dmi_available) {
- ret = -ENODATA;
- goto err;
- }
+ if (!dmi_available)
+ return 0;
/*
* Set up dmi directory at /sys/firmware/dmi. This entry should stay
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: dmi: handle missing DMI data gracefully
2017-10-12 19:59 [PATCH] firmware: dmi: handle missing DMI data gracefully Ard Biesheuvel
@ 2017-10-17 7:27 ` Jean Delvare
2017-10-17 8:18 ` Ard Biesheuvel
0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2017-10-17 7:27 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: linux-kernel
Hi Ard,
On Thu, 12 Oct 2017 20:59:37 +0100, Ard Biesheuvel wrote:
> Currently, when booting a kernel with DMI support on a platform that has
> no DMI tables, the following output is emitted into the kernel log:
>
> [ 0.128818] DMI not present or invalid.
> ...
> [ 1.306659] dmi: Firmware registration failed.
> ...
> [ 2.908681] dmi-sysfs: dmi entry is absent.
>
> The first one is a pr_info(), but the subsequent ones are pr_err()s that
> complain about a condition that is not really an error to begin with.
>
> So let's clean this up, and give up silently if dma_available is not set.
On the principle I agree, but you'll have to come up with an
implementation that links successfully:
ERROR: "dmi_available" [drivers/firmware/dmi-sysfs.ko] undefined!
scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1216: recipe for target 'modules' failed
make: *** [modules] Error 2
The reason is that dmi_available is not exported. The obvious solution
is to export it. Or maybe just turn the error message into a debug
message and assume the only reason it may reasonably happen is because
dmi isn't available in the first place. If dmi_kobj is missing for any
other reason then there's a much more important problem to solve anyway.
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> drivers/firmware/dmi-sysfs.c | 3 +++
> drivers/firmware/dmi_scan.c | 6 ++----
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
> index d5de6ee8466d..3a264cbbb5a6 100644
> --- a/drivers/firmware/dmi-sysfs.c
> +++ b/drivers/firmware/dmi-sysfs.c
> @@ -651,6 +651,9 @@ static int __init dmi_sysfs_init(void)
> int error;
> int val;
>
> + if (!dmi_available)
> + return 0;
> +
> if (!dmi_kobj) {
> pr_err("dmi-sysfs: dmi entry is absent.\n");
> error = -ENODATA;
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index 783041964439..17a7425063c2 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -715,10 +715,8 @@ static int __init dmi_init(void)
> u8 *dmi_table;
> int ret = -ENOMEM;
>
> - if (!dmi_available) {
> - ret = -ENODATA;
> - goto err;
> - }
> + if (!dmi_available)
> + return 0;
>
> /*
> * Set up dmi directory at /sys/firmware/dmi. This entry should stay
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: dmi: handle missing DMI data gracefully
2017-10-17 7:27 ` Jean Delvare
@ 2017-10-17 8:18 ` Ard Biesheuvel
0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2017-10-17 8:18 UTC (permalink / raw)
To: Jean Delvare; +Cc: linux-kernel@vger.kernel.org
On 17 October 2017 at 08:27, Jean Delvare <jdelvare@suse.de> wrote:
> Hi Ard,
>
> On Thu, 12 Oct 2017 20:59:37 +0100, Ard Biesheuvel wrote:
>> Currently, when booting a kernel with DMI support on a platform that has
>> no DMI tables, the following output is emitted into the kernel log:
>>
>> [ 0.128818] DMI not present or invalid.
>> ...
>> [ 1.306659] dmi: Firmware registration failed.
>> ...
>> [ 2.908681] dmi-sysfs: dmi entry is absent.
>>
>> The first one is a pr_info(), but the subsequent ones are pr_err()s that
>> complain about a condition that is not really an error to begin with.
>>
>> So let's clean this up, and give up silently if dma_available is not set.
>
> On the principle I agree, but you'll have to come up with an
> implementation that links successfully:
>
> ERROR: "dmi_available" [drivers/firmware/dmi-sysfs.ko] undefined!
> scripts/Makefile.modpost:91: recipe for target '__modpost' failed
> make[1]: *** [__modpost] Error 1
> Makefile:1216: recipe for target 'modules' failed
> make: *** [modules] Error 2
>
Oops. Thanks for spotting that.
> The reason is that dmi_available is not exported. The obvious solution
> is to export it. Or maybe just turn the error message into a debug
> message and assume the only reason it may reasonably happen is because
> dmi isn't available in the first place. If dmi_kobj is missing for any
> other reason then there's a much more important problem to solve anyway.
>
Indeed. dmi_kobj is the first thing that gets created in dmi_init(),
and if that fails you will get a pr_err() anyway.
I will respin.
Thanks,
Ard.
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> drivers/firmware/dmi-sysfs.c | 3 +++
>> drivers/firmware/dmi_scan.c | 6 ++----
>> 2 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
>> index d5de6ee8466d..3a264cbbb5a6 100644
>> --- a/drivers/firmware/dmi-sysfs.c
>> +++ b/drivers/firmware/dmi-sysfs.c
>> @@ -651,6 +651,9 @@ static int __init dmi_sysfs_init(void)
>> int error;
>> int val;
>>
>> + if (!dmi_available)
>> + return 0;
>> +
>> if (!dmi_kobj) {
>> pr_err("dmi-sysfs: dmi entry is absent.\n");
>> error = -ENODATA;
>> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
>> index 783041964439..17a7425063c2 100644
>> --- a/drivers/firmware/dmi_scan.c
>> +++ b/drivers/firmware/dmi_scan.c
>> @@ -715,10 +715,8 @@ static int __init dmi_init(void)
>> u8 *dmi_table;
>> int ret = -ENOMEM;
>>
>> - if (!dmi_available) {
>> - ret = -ENODATA;
>> - goto err;
>> - }
>> + if (!dmi_available)
>> + return 0;
>>
>> /*
>> * Set up dmi directory at /sys/firmware/dmi. This entry should stay
>
> --
> Jean Delvare
> SUSE L3 Support
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-17 8:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12 19:59 [PATCH] firmware: dmi: handle missing DMI data gracefully Ard Biesheuvel
2017-10-17 7:27 ` Jean Delvare
2017-10-17 8:18 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox