Update and move Dell drivers dell_rbu and dcdbas
v2 cover Update and move Dell drivers dell_rbu and dcdbas
The dell_rbu and dcdbas drivers need some changes, and should be moved to drivers/platform/x86. Additionally, dell_rbu needs a maintainer, and the listed maintainer for dcdbas is inactive and needs to be changed.
v2 changes:
- add commit messages to patches that move dcdbas and dell_rbu
- remove extra whitespace in MAINTAINERS
- add acked-by from (previous) maintainer of dcdbas
Stuart Hayes (5):
firmware: dell_rbu: Make payload memory uncachable
firmware: dcdbas: Add support for WSMT ACPI table
firmware: dell_rbu: Move dell_rbu to drivers/platform/x86
firmware: dcdbas: Move dcdbas to drivers/platform/x86
MAINTAINERS: Update maintainer for dcdbas and dell_rbu
MAINTAINERS | 11 +-
drivers/firmware/Kconfig | 28 ----
drivers/firmware/Makefile | 2 -
drivers/platform/x86/Kconfig | 28 ++++
drivers/platform/x86/Makefile | 2 +
drivers/{firmware => platform/x86}/dcdbas.c | 123 +++++++++++++++++-
drivers/{firmware => platform/x86}/dcdbas.h | 10 ++
drivers/platform/x86/dell-smbios-smm.c | 2 +-
drivers/{firmware => platform/x86}/dell_rbu.c | 8 ++
9 files changed, 175 insertions(+), 39 deletions(-)
rename drivers/{firmware => platform/x86}/dcdbas.c (82%)
rename drivers/{firmware => platform/x86}/dcdbas.h (93%)
rename drivers/{firmware => platform/x86}/dell_rbu.c (98%)Signature · 1 line
2.19.0.221.g150f307af
PATCH v2 1/5 firmware: dell_rbu: Make payload memory uncachable
The dell_rbu driver takes firmware update payloads and puts them in memory so the system BIOS can find them after a reboot. This sometimes fails (though rarely), because the memory containing the payload is in the CPU cache but never gets written back to main memory before the system is rebooted (CPU cache contents are lost on reboot).
With this patch, the payload memory will be changed to uncachable to ensure that the payload is actually in main memory before the system is rebooted.
---
This patch has been discussed previously, see history at
https://patchwork.kernel.org/patch/10512079/
drivers/firmware/dell_rbu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/firmware/dell_rbu.c +8 -0
@@ -45,6 +45,7 @@#include <linux/moduleparam.h> #include <linux/firmware.h> #include <linux/dma-mapping.h> +#include <asm/set_memory.h> MODULE_AUTHOR ("Abhay Salunke <[email protected]>" );MODULE_DESCRIPTION ("Driver for updating BIOS image on DELL systems" );
@@ -181,6 +182,11 @@ static int create_packet(void *data, size_t length) packet_data_temp_buf =NULL ; } } +/* +* set to uncachable or it may never get written back before reboot +*/ +set_memory_uc ((unsigned long )packet_data_temp_buf,1 << ordernum); +spin_lock (&rbu_data.lock); newpacket->data = packet_data_temp_buf;
@@ -349,6 +355,8 @@ static void packet_empty_list(void)* to make sure there are no stale RBU packets left in memory */ memset (newpacket->data,0 , rbu_data.packetsize); +set_memory_wb ((unsigned long )newpacket->data, +1 << newpacket->ordernum);free_pages ((unsigned long ) newpacket->data, newpacket->ordernum);kfree (newpacket);
Signature · 1 line
2.19.0
PATCH v2 2/5 firmware: dcdbas: Add support for WSMT ACPI table
In reply to Stuart HayesIf the WSMT ACPI table is present and indicates that a fixed communication buffer should be used, use the firmware-specified buffer instead of allocating a buffer in memory for communications between the dcdbas driver and firmare.
---
This patch has been discussed previously, see history at
https://lore.kernel.org/patchwork/patch/958893/
drivers/firmware/dcdbas.c | 123 ++++++++++++++++++++++++++++++++++++-- drivers/firmware/dcdbas.h | 10 ++++ 2 files changed, 127 insertions(+), 6 deletions(-)
drivers/firmware/dcdbas.c +117 -6
@@ -21,6 +21,7 @@*/ #include <linux/platform_device.h> +#include <linux/acpi.h> #include <linux/dma-mapping.h> #include <linux/errno.h> #include <linux/cpu.h>
@@ -41,7 +42,7 @@#include "dcdbas.h" #define DRIVER_NAME "dcdbas" -#define DRIVER_VERSION "5.6.0-3.2" +#define DRIVER_VERSION "5.6.0-3.3"#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver"static struct platform_device *dcdbas_pdev;
@@ -49,19 +50,23 @@ static struct platform_device *dcdbas_pdev;static u8 *smi_data_buf;static dma_addr_t smi_data_buf_handle;static unsigned long smi_data_buf_size; +static unsigned long max_smi_data_buf_size =MAX_SMI_DATA_BUF_SIZE ;static u32 smi_data_buf_phys_addr;static DEFINE_MUTEX (smi_data_lock); +static u8 *eps_buffer;static unsigned int host_control_action;static unsigned int host_control_smi_type;static unsigned int host_control_on_shutdown; +static bool wsmt_enabled; +/** * smi_data_buf_free: free SMI data buffer */ static void smi_data_buf_free (void ) { -if (!smi_data_buf) +if (!smi_data_buf || wsmt_enabled)return ; dev_dbg(&dcdbas_pdev->dev, "%s: phys: %x size: %lu\n",
@@ -86,7 +91,7 @@ static int smi_data_buf_realloc(unsigned long size)if (smi_data_buf_size >= size)return 0 ; -if (size >MAX_SMI_DATA_BUF_SIZE ) +if (size > max_smi_data_buf_size)return -EINVAL ;/* new buffer is needed */
@@ -169,7 +174,7 @@ static ssize_t smi_data_write(struct file *filp, struct kobject *kobj, {ssize_t ret; -if ((pos + count) >MAX_SMI_DATA_BUF_SIZE ) +if ((pos + count) > max_smi_data_buf_size)return -EINVAL ;mutex_lock (&smi_data_lock);
@@ -322,8 +327,20 @@ static ssize_t smi_request_store(struct device *dev, ret = count;break ;case 1 : -/* Calling Interface SMI */ - smi_cmd->ebx = (u32 )virt_to_phys (smi_cmd->command_buffer); +/* +* Calling Interface SMI +* +* Provide physical address of command buffer field within +* the struct smi_cmd to BIOS. +* +* Because the address that smi_cmd (smi_data_buf) points to +* will be from memremap() of a non-memory address if WSMT +* is present, we can't use virt_to_phys() on smi_cmd, so +* we have to use the physical address that was saved when +* the virtual address for smi_cmd was received. +*/ + smi_cmd->ebx = smi_data_buf_phys_addr + + offsetof(struct smi_cmd , command_buffer); ret =dcdbas_smi_request (smi_cmd);if (!ret) ret = count;
@@ -482,6 +499,93 @@ static void dcdbas_host_control(void) } } +/* WSMT */ + +static u8 checksum (u8 *buffer,u8 length) +{ +u8 sum =0 ; +u8 *end = buffer + length; + +while (buffer < end) + sum += *buffer++; +return sum; +} + +static inline struct smm_eps_table *check_eps_table (u8 *addr) +{ +struct smm_eps_table *eps = (struct smm_eps_table *)addr; + +if (strncmp (eps->smm_comm_buff_anchor,SMM_EPS_SIG ,4 ) !=0 ) +return NULL ; + +if (checksum (addr, eps->length) !=0 ) +return NULL ; + +return eps; +} + +static int dcdbas_check_wsmt (void ) +{ +struct acpi_table_wsmt *wsmt =NULL ; +struct smm_eps_table *eps =NULL ; +u64 remap_size; +u8 *addr; + +acpi_get_table (ACPI_SIG_WSMT ,0 , (struct acpi_table_header **)&wsmt); +if (!wsmt) +return 0 ; + +/* Check if WSMT ACPI table shows that protection is enabled */ +if (!(wsmt->protection_flags &ACPI_WSMT_FIXED_COMM_BUFFERS ) || + !(wsmt->protection_flags &ACPI_WSMT_COMM_BUFFER_NESTED_PTR_PROTECTION )) +return 0 ; + +/* Scan for EPS (entry point structure) */ +for (addr = (u8 *)__va (0xf0000 ); + addr < (u8 *)__va (0x100000 -sizeof (struct smm_eps_table )); + addr +=16 ) { + eps =check_eps_table (addr); +if (eps) +break ; + } + +if (!eps) { +dev_dbg (&dcdbas_pdev->dev,"found WSMT, but no EPS found\n" ); +return -ENODEV ; + } + +/* +* Get physical address of buffer and map to virtual address. +* Table gives size in 4K pages, regardless of actual system page size. +*/ +if (upper_32_bits (eps->smm_comm_buff_addr +8 )) { +dev_warn (&dcdbas_pdev->dev,"found WSMT, but EPS buffer address is above 4GB\n" ); +return -EINVAL ; + } +/* +* Limit remap size to MAX_SMI_DATA_BUF_SIZE + 8 (since the first 8 +* bytes are used for a semaphore, not the data buffer itself). +*/ + remap_size = eps->num_of_4k_pages *PAGE_SIZE ; +if (remap_size >MAX_SMI_DATA_BUF_SIZE +8 ) + remap_size =MAX_SMI_DATA_BUF_SIZE +8 ; + eps_buffer =memremap (eps->smm_comm_buff_addr, remap_size,MEMREMAP_WB ); +if (!eps_buffer) { +dev_warn (&dcdbas_pdev->dev,"found WSMT, but failed to map EPS buffer\n" ); +return -ENOMEM ; + } + +/* First 8 bytes is for a semaphore, not part of the smi_data_buf */ + smi_data_buf_phys_addr = eps->smm_comm_buff_addr +8 ; + smi_data_buf = eps_buffer +8 ; + smi_data_buf_size = remap_size -8 ; + max_smi_data_buf_size = smi_data_buf_size; + wsmt_enabled = true; +dev_info (&dcdbas_pdev->dev, +"WSMT found, using firmware-provided SMI buffer.\n" ); +return 1 ; +} +/** * dcdbas_reboot_notify: handle reboot notification for host control */
@@ -548,6 +652,11 @@ static int dcdbas_probe(struct platform_device *dev) dcdbas_pdev = dev; +/* Check if ACPI WSMT table specifies protected SMI buffer address */ + error =dcdbas_check_wsmt (); +if (error <0 ) +return error; +/* * BIOS SMI calls require buffer addresses be in 32-bit address space. * This is done by setting the DMA mask below.
@@ -635,6 +744,8 @@ static void __exit dcdbas_exit(void)*/ if (dcdbas_pdev)smi_data_buf_free (); +if (eps_buffer) +memunmap (eps_buffer);platform_device_unregister (dcdbas_pdev_reg);platform_driver_unregister (&dcdbas_driver); }
drivers/firmware/dcdbas.h +10 -0
@@ -53,6 +53,7 @@#define EXPIRED_TIMER (0)#define SMI_CMD_MAGIC (0x534D4931) +#define SMM_EPS_SIG "$SCB"#define DCDBAS_DEV_ATTR_RW (_name) \ DEVICE_ATTR(_name,0600,_name##_show,_name##_store);
@@ -103,5 +104,14 @@ struct apm_cmd {int dcdbas_smi_request (struct smi_cmd *smi_cmd); +struct smm_eps_table { +char smm_comm_buff_anchor[4 ]; +u8 length; +u8 checksum; +u8 version; +u64 smm_comm_buff_addr; +u64 num_of_4k_pages; +} __packed; +#endif /* _DCDBAS_H_ */
Signature · 1 line
2.19.0
PATCH v2 3/5 firmware: dell_rbu: Move dell_rbu to drivers/platform/x86
In reply to Stuart HayesMove dell_rbu to the more appropriate directory drivers/platform/x86.
---
v2 changes:
- add commit message
drivers/firmware/Kconfig | 12 ------------
drivers/firmware/Makefile | 1 -
drivers/platform/x86/Kconfig | 12 ++++++++++++
drivers/platform/x86/Makefile | 1 +
drivers/{firmware => platform/x86}/dell_rbu.c | 0
5 files changed, 13 insertions(+), 13 deletions(-)
rename drivers/{firmware => platform/x86}/dell_rbu.c (100%)drivers/firmware/Kconfig +0 -12
@@ -145,18 +145,6 @@ config EFI_PCDP See DIG64_HCDPv20_042804.pdf available from <http://www.dig64.org/specifications/> -config DELL_RBU - tristate "BIOS update support for DELL systems via sysfs" - depends on X86 - select FW_LOADER - select FW_LOADER_USER_HELPER - help - Say m if you want to have the option of updating the BIOS for your - DELL system. Note you need a Dell OpenManage or Dell Update package (DUP) - supporting application to communicate with the BIOS regarding the new - image for the image update to take effect. - See <file:Documentation/dell_rbu.txt> for more details on the driver. - config DCDBAS tristate "Dell Systems Management Base Driver" depends on X86
drivers/firmware/Makefile +0 -1
@@ -11,7 +11,6 @@ obj-$(CONFIG_DMI) += dmi_scan.o obj-$(CONFIG_DMI_SYSFS) += dmi-sysfs.o obj-$(CONFIG_EDD) += edd.o obj-$(CONFIG_EFI_PCDP) += pcdp.o -obj-$(CONFIG_DELL_RBU) += dell_rbu.o obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DMIID) += dmi-id.o obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o
drivers/platform/x86/Kconfig +12 -0
@@ -227,6 +227,18 @@ config DELL_RBTN To compile this driver as a module, choose M here: the module will be called dell-rbtn. +config DELL_RBU + tristate "BIOS update support for DELL systems via sysfs" + depends on X86 + select FW_LOADER + select FW_LOADER_USER_HELPER + help + Say m if you want to have the option of updating the BIOS for your + DELL system. Note you need a Dell OpenManage or Dell Update package (DUP) + supporting application to communicate with the BIOS regarding the new + image for the image update to take effect. + See <file:Documentation/dell_rbu.txt> for more details on the driver. + config FUJITSU_LAPTOP tristate "Fujitsu Laptop Extras"
drivers/platform/x86/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o +obj-$(CONFIG_DELL_RBU) += dell_rbu.o obj-$(CONFIG_ACER_WMI) += acer-wmi.o obj-$(CONFIG_ACER_WIRELESS) += acer-wireless.o obj-$(CONFIG_ACERHDF) += acerhdf.o
drivers/platform/x86/dell_rbu.c renamed from drivers/firmware/dell_rbu.c +0 -0
Signature · 1 line
2.19.0
PATCH v2 4/5 firmware: dcdbas: Move dcdbas to drivers/platform/x86
In reply to Stuart HayesMove dcdbas to the more appropriate directory drivers/platform/x86.
---
v2 changes:
- add commit message
drivers/firmware/Kconfig | 16 ----------------
drivers/firmware/Makefile | 1 -
drivers/platform/x86/Kconfig | 16 ++++++++++++++++
drivers/platform/x86/Makefile | 1 +
drivers/{firmware => platform/x86}/dcdbas.c | 0
drivers/{firmware => platform/x86}/dcdbas.h | 0
drivers/platform/x86/dell-smbios-smm.c | 2 +-
7 files changed, 18 insertions(+), 18 deletions(-)
rename drivers/{firmware => platform/x86}/dcdbas.c (100%)
rename drivers/{firmware => platform/x86}/dcdbas.h (100%)drivers/firmware/Kconfig +0 -16
@@ -145,22 +145,6 @@ config EFI_PCDP See DIG64_HCDPv20_042804.pdf available from <http://www.dig64.org/specifications/> -config DCDBAS - tristate "Dell Systems Management Base Driver" - depends on X86 - help - The Dell Systems Management Base Driver provides a sysfs interface - for systems management software to perform System Management - Interrupts (SMIs) and Host Control Actions (system power cycle or - power off after OS shutdown) on certain Dell systems. - - See <file:Documentation/dcdbas.txt> for more details on the driver - and the Dell systems on which Dell systems management software makes - use of this driver. - - Say Y or M here to enable the driver for use by Dell systems - management software such as Dell OpenManage. - config DMIID bool "Export DMI identification via sysfs to userspace" depends on DMI
drivers/firmware/Makefile +0 -1
@@ -11,7 +11,6 @@ obj-$(CONFIG_DMI) += dmi_scan.o obj-$(CONFIG_DMI_SYSFS) += dmi-sysfs.o obj-$(CONFIG_EDD) += edd.o obj-$(CONFIG_EFI_PCDP) += pcdp.o -obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DMIID) += dmi-id.o obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o
drivers/platform/x86/Kconfig +16 -0
@@ -105,6 +105,22 @@ config ASUS_LAPTOP If you have an ACPI-compatible ASUS laptop, say Y or M here. +config DCDBAS + tristate "Dell Systems Management Base Driver" + depends on X86 + help + The Dell Systems Management Base Driver provides a sysfs interface + for systems management software to perform System Management + Interrupts (SMIs) and Host Control Actions (system power cycle or + power off after OS shutdown) on certain Dell systems. + + See <file:Documentation/dcdbas.txt> for more details on the driver + and the Dell systems on which Dell systems management software makes + use of this driver. + + Say Y or M here to enable the driver for use by Dell systems + management software such as Dell OpenManage. + # # The DELL_SMBIOS driver depends on ACPI_WMI and/or DCDBAS if those # backends are selected. The "depends" line prevents a configuration
drivers/platform/x86/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_EEEPC_WMI) += eeepc-wmi.o obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o +obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o dell-smbios-objs := dell-smbios-base.o dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o
drivers/platform/x86/dcdbas.c renamed from drivers/firmware/dcdbas.c +0 -0
drivers/platform/x86/dcdbas.h renamed from drivers/firmware/dcdbas.h +0 -0
drivers/platform/x86/dell-smbios-smm.c +1 -1
@@ -18,7 +18,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/platform_device.h> -#include "../../firmware/dcdbas.h" +#include "dcdbas.h" #include "dell-smbios.h" static int da_command_address;
Signature · 1 line
2.19.0
PATCH v2 5/5 MAINTAINERS: Update maintainer for dcdbas and dell_rbu
In reply to Stuart HayesAssign maintainer for dell_rbu driver, and reassign maintainer of dcdbas from inactive maintainer (current maintainer is aware of this change-- see https://www.spinics.net/lists/platform-driver-x86/msg16336.html).
---
v2 changes:
- remove extra whitespace
- add acked-by from (previous) maintainer of dcdbas
MAINTAINERS | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
MAINTAINERS +9 -2
@@ -4188,6 +4188,12 @@ M: Pali Rohár <[email protected]> S: Maintained F: drivers/platform/x86/dell-rbtn.* +DELL REMOTE BIOS UPDATE DRIVER +M: Stuart Hayes <[email protected]> +L: [email protected] +S: Maintained +F: drivers/platform/x86/dell_rbu.c + DELL LAPTOP SMM DRIVER M: Pali Rohár <[email protected]> S: Maintained
@@ -4195,10 +4201,11 @@ F: drivers/hwmon/dell-smm-hwmon.c F: include/uapi/linux/i8k.h DELL SYSTEMS MANAGEMENT BASE DRIVER (dcdbas) -M: Doug Warzecha <[email protected]> +M: Stuart Hayes <[email protected]> +L: [email protected] S: Maintained F: Documentation/dcdbas.txt -F: drivers/firmware/dcdbas.* +F: drivers/platform/x86/dcdbas.* DELL WMI NOTIFICATIONS DRIVER M: Matthew Garrett <[email protected]>
Signature · 1 line
2.19.0
Quoted 5 lines · Stuart Hayes
The
dell_rbuand dcdbas drivers need some changes, and should be moved todrivers/platform/x86. Additionally,dell_rbuneeds a maintainer, and the listed maintainer for dcdbas is inactive and needs to be changed.
Pushed to my review and testing queue, thanks!
Quoted 29 lines
v2 changes:
- add commit messages to patches that move dcdbas anddell_rbu
- remove extra whitespace inMAINTAINERS
- add acked-by from (previous) maintainer of dcdbasStuart Hayes (5):
firmware:dell_rbu: Make payload memory uncachable
firmware: dcdbas: Add support for WSMT ACPI table
firmware:dell_rbu: Movedell_rbutodrivers/platform/x86
firmware: dcdbas: Move dcdbas todrivers/platform/x86
MAINTAINERS: Update maintainer for dcdbas anddell_rbuMAINTAINERS | 11 +- drivers/firmware/Kconfig | 28 ---- drivers/firmware/Makefile | 2 - drivers/platform/x86/Kconfig | 28 ++++ drivers/platform/x86/Makefile | 2 + drivers/{firmware => platform/x86}/dcdbas.c | 123 +++++++++++++++++- drivers/{firmware => platform/x86}/dcdbas.h | 10 ++ drivers/platform/x86/dell-smbios-smm.c | 2 +- drivers/{firmware => platform/x86}/dell_rbu.c | 8 ++ 9 files changed, 175 insertions(+), 39 deletions(-) rename drivers/{firmware => platform/x86}/dcdbas.c (82%) rename drivers/{firmware => platform/x86}/dcdbas.h (93%) rename drivers/{firmware => platform/x86}/dell_rbu.c (98%)--
2.19.0.221.g150f307af
Signature · 2 lines
With Best Regards, Andy Shevchenko