* [Patch v2 1/3] firmware: google: Release devices before unregistering the bus
@ 2019-11-18 8:38 patrick.rudolph
2019-11-18 8:38 ` [Patch v2 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi patrick.rudolph
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: patrick.rudolph @ 2019-11-18 8:38 UTC (permalink / raw)
To: linux-kernel
Cc: coreboot, Patrick Rudolph, Greg Kroah-Hartman, Alexios Zavras,
Allison Randal, Thomas Gleixner, Arthur Heymans
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Fix a bug where the kernel module can't be loaded after it has been
unloaded as the devices are still present and conflicting with the
to be created coreboot devices.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
drivers/firmware/google/coreboot_table.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index 8d132e4f008a..0205987a4fd4 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -163,8 +163,15 @@ static int coreboot_table_probe(struct platform_device *pdev)
return ret;
}
+static int __cb_dev_unregister(struct device *dev, void *dummy)
+{
+ device_unregister(dev);
+ return 0;
+}
+
static int coreboot_table_remove(struct platform_device *pdev)
{
+ bus_for_each_dev(&coreboot_bus_type, NULL, NULL, __cb_dev_unregister);
bus_unregister(&coreboot_bus_type);
return 0;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Patch v2 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi
2019-11-18 8:38 [Patch v2 1/3] firmware: google: Release devices before unregistering the bus patrick.rudolph
@ 2019-11-18 8:38 ` patrick.rudolph
2019-11-18 8:39 ` [Patch v2 3/3] firmware: google: Probe for a GSMI handler in firmware patrick.rudolph
2019-11-18 8:59 ` [Patch v2 1/3] firmware: google: Release devices before unregistering the bus Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: patrick.rudolph @ 2019-11-18 8:38 UTC (permalink / raw)
To: linux-kernel
Cc: coreboot, Arthur Heymans, Patrick Rudolph, Thomas Gleixner,
Alexios Zavras, Allison Randal, Greg Kroah-Hartman
From: Arthur Heymans <arthur@aheymans.xyz>
Fix a bug where the kernel module couldn't be loaded after unloading,
as the platform driver wasn't released on exit.
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
drivers/firmware/google/gsmi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index edaa4e5d84ad..974c769b75cf 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -1016,6 +1016,9 @@ static __init int gsmi_init(void)
dma_pool_destroy(gsmi_dev.dma_pool);
platform_device_unregister(gsmi_dev.pdev);
pr_info("gsmi: failed to load: %d\n", ret);
+#ifdef CONFIG_PM
+ platform_driver_unregister(&gsmi_driver_info);
+#endif
return ret;
}
@@ -1037,6 +1040,9 @@ static void __exit gsmi_exit(void)
gsmi_buf_free(gsmi_dev.name_buf);
dma_pool_destroy(gsmi_dev.dma_pool);
platform_device_unregister(gsmi_dev.pdev);
+#ifdef CONFIG_PM
+ platform_driver_unregister(&gsmi_driver_info);
+#endif
}
module_init(gsmi_init);
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Patch v2 3/3] firmware: google: Probe for a GSMI handler in firmware
2019-11-18 8:38 [Patch v2 1/3] firmware: google: Release devices before unregistering the bus patrick.rudolph
2019-11-18 8:38 ` [Patch v2 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi patrick.rudolph
@ 2019-11-18 8:39 ` patrick.rudolph
2019-11-18 8:59 ` [Patch v2 1/3] firmware: google: Release devices before unregistering the bus Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: patrick.rudolph @ 2019-11-18 8:39 UTC (permalink / raw)
To: linux-kernel
Cc: coreboot, Arthur Heymans, Patrick Rudolph, Thomas Gleixner,
Allison Randal, Alexios Zavras, Greg Kroah-Hartman
From: Arthur Heymans <arthur@aheymans.xyz>
Currently this driver is loaded if the DMI string matches coreboot
and has a proper smi_command in the ACPI FADT table, but a GSMI handler in
SMM is an optional feature in coreboot.
So probe for a SMM GSMI handler before initializing the driver.
If the smihandler leaves the calling argument in %eax in the SMM save state
untouched that generally means the is no handler for GSMI.
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
drivers/firmware/google/gsmi.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 974c769b75cf..5b2011ebbe26 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -76,6 +76,7 @@
#define GSMI_CMD_LOG_S0IX_RESUME 0x0b
#define GSMI_CMD_CLEAR_CONFIG 0x20
#define GSMI_CMD_HANDSHAKE_TYPE 0xC1
+#define GSMI_CMD_RESERVED 0xff
/* Magic entry type for kernel events */
#define GSMI_LOG_ENTRY_TYPE_KERNEL 0xDEAD
@@ -746,6 +747,7 @@ MODULE_DEVICE_TABLE(dmi, gsmi_dmi_table);
static __init int gsmi_system_valid(void)
{
u32 hash;
+ u16 cmd, result;
if (!dmi_check_system(gsmi_dmi_table))
return -ENODEV;
@@ -780,6 +782,23 @@ static __init int gsmi_system_valid(void)
return -ENODEV;
}
+ /* Test the smihandler with a bogus command. If it leaves the
+ * calling argument in %ax untouched, there is no handler for
+ * GSMI commands.
+ */
+ cmd = GSMI_CALLBACK | GSMI_CMD_RESERVED << 8;
+ asm volatile (
+ "outb %%al, %%dx\n\t"
+ : "=a" (result)
+ : "0" (cmd),
+ "d" (acpi_gbl_FADT.smi_command)
+ : "memory", "cc"
+ );
+ if (cmd == result) {
+ pr_info("gsmi: no gsmi handler in firmware\n");
+ return -ENODEV;
+ }
+
/* Found */
return 0;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch v2 1/3] firmware: google: Release devices before unregistering the bus
2019-11-18 8:38 [Patch v2 1/3] firmware: google: Release devices before unregistering the bus patrick.rudolph
2019-11-18 8:38 ` [Patch v2 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi patrick.rudolph
2019-11-18 8:39 ` [Patch v2 3/3] firmware: google: Probe for a GSMI handler in firmware patrick.rudolph
@ 2019-11-18 8:59 ` Greg Kroah-Hartman
2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-11-18 8:59 UTC (permalink / raw)
To: patrick.rudolph
Cc: linux-kernel, coreboot, Alexios Zavras, Allison Randal,
Thomas Gleixner, Arthur Heymans
On Mon, Nov 18, 2019 at 09:38:58AM +0100, patrick.rudolph@9elements.com wrote:
> From: Patrick Rudolph <patrick.rudolph@9elements.com>
>
> Fix a bug where the kernel module can't be loaded after it has been
> unloaded as the devices are still present and conflicting with the
> to be created coreboot devices.
>
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> ---
> drivers/firmware/google/coreboot_table.c | 7 +++++++
> 1 file changed, 7 insertions(+)
You forgot to document what changed from v1 of this patch and/or series
somewhere :(
Usually it just goes below the --- line on each patch.
Can you fix that up and send a v3 of this series?
thanks
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-18 8:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 8:38 [Patch v2 1/3] firmware: google: Release devices before unregistering the bus patrick.rudolph
2019-11-18 8:38 ` [Patch v2 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi patrick.rudolph
2019-11-18 8:39 ` [Patch v2 3/3] firmware: google: Probe for a GSMI handler in firmware patrick.rudolph
2019-11-18 8:59 ` [Patch v2 1/3] firmware: google: Release devices before unregistering the bus Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).