linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] dell_rbu: make firmware payload memory uncachable
@ 2018-04-06 13:12 Stuart Hayes
  2018-04-06 13:23 ` Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stuart Hayes @ 2018-04-06 13:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Takashi Iwai

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.

Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
---
v2 Added include, removed extra parentheses
v3 Corrected formatting and include line
v4 Moved set_memory_uc() outside the while loop so that the memory is
   definitely allocated before it is set to uncachable

This driver has no maintainer.


diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 2f452f1f7c8a..53f27a6e2d76 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -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 <abhay_salunke@dell.com>");
 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);

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

* Re: [PATCH v4] dell_rbu: make firmware payload memory uncachable
  2018-04-06 13:12 [PATCH v4] dell_rbu: make firmware payload memory uncachable Stuart Hayes
@ 2018-04-06 13:23 ` Takashi Iwai
  2018-04-10 13:50 ` Sasha Levin
  2018-07-06 16:18 ` [PATCH resend " Stuart Hayes
  2 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-04-06 13:23 UTC (permalink / raw)
  To: Stuart Hayes; +Cc: linux-kernel, Andrew Morton

On Fri, 06 Apr 2018 15:12:21 +0200,
Stuart Hayes wrote:
> 
> 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.
> 
> Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>

Looks good to me.

Reviewed-by: Takashi Iwai <tiwai@suse.de>

Andrew, could you pick this one?  The driver seems to have no
maintainer.


thanks,

Takashi

> ---
> v2 Added include, removed extra parentheses
> v3 Corrected formatting and include line
> v4 Moved set_memory_uc() outside the while loop so that the memory is
>    definitely allocated before it is set to uncachable
> 
> This driver has no maintainer.
> 
> 
> diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
> index 2f452f1f7c8a..53f27a6e2d76 100644
> --- a/drivers/firmware/dell_rbu.c
> +++ b/drivers/firmware/dell_rbu.c
> @@ -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 <abhay_salunke@dell.com>");
>  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);
> 

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

* Re: [PATCH v4] dell_rbu: make firmware payload memory uncachable
  2018-04-06 13:12 [PATCH v4] dell_rbu: make firmware payload memory uncachable Stuart Hayes
  2018-04-06 13:23 ` Takashi Iwai
@ 2018-04-10 13:50 ` Sasha Levin
  2018-07-06 16:18 ` [PATCH resend " Stuart Hayes
  2 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2018-04-10 13:50 UTC (permalink / raw)
  To: Sasha Levin, Stuart Hayes, linux-kernel; +Cc: Takashi Iwai, stable

Hi,

[This is an automated email]

This commit has been processed by the -stable helper bot and determined
to be a high probability candidate for -stable trees. (score: 19.9792)

The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33, v4.9.93, v4.4.127.

v4.16.1: Build OK!
v4.15.16: Build OK!
v4.14.33: Build OK!
v4.9.93: Build failed! Errors:
    set_memory.h: No such file or directory

v4.4.127: Build failed! Errors:
    set_memory.h: No such file or directory


Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks,
Sasha

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

* [PATCH resend v4] dell_rbu: make firmware payload memory uncachable
  2018-04-06 13:12 [PATCH v4] dell_rbu: make firmware payload memory uncachable Stuart Hayes
  2018-04-06 13:23 ` Takashi Iwai
  2018-04-10 13:50 ` Sasha Levin
@ 2018-07-06 16:18 ` Stuart Hayes
  2018-07-06 16:28   ` Mario.Limonciello
  2 siblings, 1 reply; 6+ messages in thread
From: Stuart Hayes @ 2018-07-06 16:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Takashi Iwai, Andy Shevchenko, dvhart, Platform Driver

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.

Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v2 Added include, removed extra parentheses
v3 Corrected formatting and include line
v4 Moved set_memory_uc() outside the while loop so that the memory is
   definitely allocated before it is set to uncachable

This driver has no maintainer.


diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 2f452f1f7c8a..53f27a6e2d76 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -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 <abhay_salunke@dell.com>");
 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);

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

* RE: [PATCH resend v4] dell_rbu: make firmware payload memory uncachable
  2018-07-06 16:18 ` [PATCH resend " Stuart Hayes
@ 2018-07-06 16:28   ` Mario.Limonciello
  2018-07-13 14:26     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Mario.Limonciello @ 2018-07-06 16:28 UTC (permalink / raw)
  To: stuart.w.hayes, linux-kernel, Stuart.Hayes
  Cc: tiwai, andy.shevchenko, dvhart, platform-driver-x86



> -----Original Message-----
> From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> owner@vger.kernel.org] On Behalf Of Stuart Hayes
> Sent: Friday, July 6, 2018 11:19 AM
> To: linux-kernel@vger.kernel.org
> Cc: Takashi Iwai; Andy Shevchenko; dvhart@infradead.org; Platform Driver
> Subject: [PATCH resend v4] dell_rbu: make firmware 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.
> 
> Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
> Reviewed-by: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>

> ---
> v2 Added include, removed extra parentheses
> v3 Corrected formatting and include line
> v4 Moved set_memory_uc() outside the while loop so that the memory is
>    definitely allocated before it is set to uncachable
> 
> This driver has no maintainer.

Stuart,

Outside of this patch, I think it would make sense to send some follow up patch
series that do the following:

1) Let you take over as maintainer (Update MAINTAINERS)
2) Move this driver to platform-x86
3) Update dell_rbu.txt with the correct URLs and mention that it's only for enterprise
hardware.    Client hardware has instead opted to support UEFI capsules for updates
from Linux.

Since it's really a platform feature and specific to only Dell enterprise hardware
I think it makes sense to move over to an area with subsystem maintainers that
can help to review patches as needed.

> 
> 
> diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
> index 2f452f1f7c8a..53f27a6e2d76 100644
> --- a/drivers/firmware/dell_rbu.c
> +++ b/drivers/firmware/dell_rbu.c
> @@ -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 <abhay_salunke@dell.com>");
>  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);

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

* Re: [PATCH resend v4] dell_rbu: make firmware payload memory uncachable
  2018-07-06 16:28   ` Mario.Limonciello
@ 2018-07-13 14:26     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-07-13 14:26 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Stuart Hayes, Linux Kernel Mailing List, Stuart.Hayes,
	Takashi Iwai, Darren Hart, Platform Driver

On Fri, Jul 6, 2018 at 7:28 PM,  <Mario.Limonciello@dell.com> wrote:

> Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>

Pushed to my review and testing queue, thanks!

>> This driver has no maintainer.
>
> Stuart,
>
> Outside of this patch, I think it would make sense to send some follow up patch
> series that do the following:
>
> 1) Let you take over as maintainer (Update MAINTAINERS)

> 2) Move this driver to platform-x86

Darren, what do you think about this step?

If we would go this way, first move, then take maintainership to reduce a churn.

> 3) Update dell_rbu.txt with the correct URLs and mention that it's only for enterprise
> hardware.    Client hardware has instead opted to support UEFI capsules for updates
> from Linux.
>
> Since it's really a platform feature and specific to only Dell enterprise hardware
> I think it makes sense to move over to an area with subsystem maintainers that
> can help to review patches as needed.

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2018-07-13 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-06 13:12 [PATCH v4] dell_rbu: make firmware payload memory uncachable Stuart Hayes
2018-04-06 13:23 ` Takashi Iwai
2018-04-10 13:50 ` Sasha Levin
2018-07-06 16:18 ` [PATCH resend " Stuart Hayes
2018-07-06 16:28   ` Mario.Limonciello
2018-07-13 14:26     ` Andy Shevchenko

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).