All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year()
@ 2018-03-20 18:07 Andy Shevchenko
  2018-03-20 18:07 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-03-20 18:07 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, Rafael J . Wysocki, linux-acpi,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, Jean Delvare,
	Lukas Wunner
  Cc: Andy Shevchenko

Introduce a new helper to extract a year from DMI BIOS date since there
are most existing users do and newcomers would utilize as well.

This is a fix up series on top what had been applied already.

Since v3:
- address more comments from Jean
- add tags
- reverse the order of the patches in the series
- due to above add a Fixes tag to both of them

Since v2:
- resend as fix up series
- address comments from Bjorn, Jean, Lukas, Rafael

Since v1:
- move the helper to be regular function (Bjorn, Rafael)
- fix a potential regression introduced in pci_acpi_crs_quirks() (Jean)
- adjust subject lines and commit message bodies (Bjorn)
- add tags (Bjorn, Jean)

Andy Shevchenko (2):
  firmware: dmi_scan: Uninline dmi_get_bios_year() helper
  x86/PCI: Fix a potential regression when use dmi_get_bios_year()

 arch/x86/pci/acpi.c         |  4 +++-
 drivers/firmware/dmi_scan.c | 20 ++++++++++++++++++++
 include/linux/dmi.h         | 11 ++---------
 3 files changed, 25 insertions(+), 10 deletions(-)

-- 
2.16.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper
  2018-03-20 18:07 [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
@ 2018-03-20 18:07 ` Andy Shevchenko
  2018-03-27  9:33   ` Ingo Molnar
  2018-03-20 18:08 ` [PATCH v4 2/2] x86/PCI: Fix a potential regression when use dmi_get_bios_year() Andy Shevchenko
  2018-03-26 17:14 ` [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2018-03-20 18:07 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, Rafael J . Wysocki, linux-acpi,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, Jean Delvare,
	Lukas Wunner
  Cc: Andy Shevchenko

Uninline dmi_get_bios_year() which, in particular, allows us
to optimize it in the future.

While doing this, convert the function to return an error code
when BIOS date is not present or not parsable, or CONFIG_DMI=n.

Additionally, during the move, add a bit of documentation.

Fixes: 492a1abd61e4 ("dmi: Introduce the dmi_get_bios_year() helper function")
Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/firmware/dmi_scan.c | 20 ++++++++++++++++++++
 include/linux/dmi.h         | 11 ++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index ae4f1b181c23..bfb6ce6abc83 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -1040,6 +1040,26 @@ bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
 }
 EXPORT_SYMBOL(dmi_get_date);
 
+/**
+ *	dmi_get_bios_year - get a year out of DMI_BIOS_DATE field
+ *
+ *	Returns year on success, -ENXIO if DMI is not selected,
+ *	or a different negative error code if DMI field is not present
+ *	or not parsable.
+ */
+int dmi_get_bios_year(void)
+{
+	bool exists;
+	int year;
+
+	exists = dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
+	if (!exists)
+		return -ENODATA;
+
+	return year ? year : -ERANGE;
+}
+EXPORT_SYMBOL(dmi_get_bios_year);
+
 /**
  *	dmi_walk - Walk the DMI table and get called back for every record
  *	@decode: Callback function
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index b5b8c26b04fb..c46fdb36700b 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -106,6 +106,7 @@ extern void dmi_scan_machine(void);
 extern void dmi_memdev_walk(void);
 extern void dmi_set_dump_stack_arch_desc(void);
 extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
+extern int dmi_get_bios_year(void);
 extern int dmi_name_in_vendors(const char *str);
 extern int dmi_name_in_serial(const char *str);
 extern int dmi_available;
@@ -134,6 +135,7 @@ static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
 		*dayp = 0;
 	return false;
 }
+static inline int dmi_get_bios_year(void) { return -ENXIO; }
 static inline int dmi_name_in_vendors(const char *s) { return 0; }
 static inline int dmi_name_in_serial(const char *s) { return 0; }
 #define dmi_available 0
@@ -149,13 +151,4 @@ static inline const struct dmi_system_id *
 
 #endif
 
-static inline int dmi_get_bios_year(void)
-{
-	int year;
-
-	dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
-
-	return year;
-}
-
 #endif	/* __DMI_H__ */
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] x86/PCI: Fix a potential regression when use dmi_get_bios_year()
  2018-03-20 18:07 [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
  2018-03-20 18:07 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Andy Shevchenko
@ 2018-03-20 18:08 ` Andy Shevchenko
  2018-03-26 17:14 ` [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-03-20 18:08 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, Rafael J . Wysocki, linux-acpi,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, Jean Delvare,
	Lukas Wunner
  Cc: Andy Shevchenko

dmi_get_bios_year() may return 0 when it is incapable to parse
the BIOS date string. Previously this has been checked in
pci_acpi_crs_quirks().

Update the code to restore old behaviour.

Fixes: 69c42d493db4 ("x86/pci: Simplify code by using the new dmi_get_bios_year() helper")
Reported-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/pci/acpi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 00e60de30328..5559dcaddd5e 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -140,7 +140,9 @@ static const struct dmi_system_id pci_crs_quirks[] __initconst = {
 
 void __init pci_acpi_crs_quirks(void)
 {
-	if ((dmi_get_bios_year() < 2008) && (iomem_resource.end <= 0xffffffff))
+	int year = dmi_get_bios_year();
+
+	if (year >= 0 && year < 2008 && iomem_resource.end <= 0xffffffff)
 		pci_use_crs = false;
 
 	dmi_check_system(pci_crs_quirks);
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year()
  2018-03-20 18:07 [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
  2018-03-20 18:07 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Andy Shevchenko
  2018-03-20 18:08 ` [PATCH v4 2/2] x86/PCI: Fix a potential regression when use dmi_get_bios_year() Andy Shevchenko
@ 2018-03-26 17:14 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-03-26 17:14 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, Rafael J . Wysocki, linux-acpi,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, Jean Delvare,
	Lukas Wunner

On Tue, 2018-03-20 at 20:07 +0200, Andy Shevchenko wrote:
> Introduce a new helper to extract a year from DMI BIOS date since
> there
> are most existing users do and newcomers would utilize as well.
> 
> This is a fix up series on top what had been applied already.
> 

Ingo, this is a fix up series like should be as you and Rafael pointed
out.

Can we get it into next release, so, we will have no regression in
between?

> Since v3:
> - address more comments from Jean
> - add tags
> - reverse the order of the patches in the series
> - due to above add a Fixes tag to both of them
> 
> Since v2:
> - resend as fix up series
> - address comments from Bjorn, Jean, Lukas, Rafael
> 
> Since v1:
> - move the helper to be regular function (Bjorn, Rafael)
> - fix a potential regression introduced in pci_acpi_crs_quirks()
> (Jean)
> - adjust subject lines and commit message bodies (Bjorn)
> - add tags (Bjorn, Jean)
> 
> Andy Shevchenko (2):
>   firmware: dmi_scan: Uninline dmi_get_bios_year() helper
>   x86/PCI: Fix a potential regression when use dmi_get_bios_year()
> 
>  arch/x86/pci/acpi.c         |  4 +++-
>  drivers/firmware/dmi_scan.c | 20 ++++++++++++++++++++
>  include/linux/dmi.h         | 11 ++---------
>  3 files changed, 25 insertions(+), 10 deletions(-)
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper
  2018-03-20 18:07 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Andy Shevchenko
@ 2018-03-27  9:33   ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2018-03-27  9:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bjorn Helgaas, linux-pci, Rafael J . Wysocki, linux-acpi,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, Jean Delvare,
	Lukas Wunner


* Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Uninline dmi_get_bios_year() which, in particular, allows us
> to optimize it in the future.
> 
> While doing this, convert the function to return an error code
> when BIOS date is not present or not parsable, or CONFIG_DMI=n.
> 
> Additionally, during the move, add a bit of documentation.
> 
> Fixes: 492a1abd61e4 ("dmi: Introduce the dmi_get_bios_year() helper function")
> Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
> Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/firmware/dmi_scan.c | 20 ++++++++++++++++++++
>  include/linux/dmi.h         | 11 ++---------
>  2 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index ae4f1b181c23..bfb6ce6abc83 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -1040,6 +1040,26 @@ bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
>  }
>  EXPORT_SYMBOL(dmi_get_date);
>  
> +/**
> + *	dmi_get_bios_year - get a year out of DMI_BIOS_DATE field
> + *
> + *	Returns year on success, -ENXIO if DMI is not selected,
> + *	or a different negative error code if DMI field is not present
> + *	or not parsable.

s/parsable/parseable

I have fixed this in the version I've applied - which I'll push out if it passes 
testing.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-27  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20 18:07 [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko
2018-03-20 18:07 ` [PATCH v4 1/2] firmware: dmi_scan: Uninline dmi_get_bios_year() helper Andy Shevchenko
2018-03-27  9:33   ` Ingo Molnar
2018-03-20 18:08 ` [PATCH v4 2/2] x86/PCI: Fix a potential regression when use dmi_get_bios_year() Andy Shevchenko
2018-03-26 17:14 ` [PATCH v4 0/2] x86, dmi: Uninline dmi_get_bios_year() Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.