Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-23 Thread Stuart Hayes


On 3/22/2018 9:58 PM, kbuild test robot wrote:
> Hi Stuart,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.16-rc6 next-20180322]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
> config: i386-randconfig-x014-201811 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 

Please disregard this one, will send a "v2" shortly.  Not sure how I managed to 
send this version...
Thanks!



Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-23 Thread Stuart Hayes


On 3/22/2018 9:58 PM, kbuild test robot wrote:
> Hi Stuart,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.16-rc6 next-20180322]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
> config: i386-randconfig-x014-201811 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 

Please disregard this one, will send a "v2" shortly.  Not sure how I managed to 
send this version...
Thanks!



Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-22 Thread kbuild test robot
Hi Stuart,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
config: i386-randconfig-x014-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/firmware/dell_rbu.c: In function 'create_packet':
>> drivers/firmware/dell_rbu.c:187:3: error: implicit declaration of function 
>> 'set_memory_uc'; did you mean 'add_memory'? 
>> [-Werror=implicit-function-declaration]
  set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
  ^
  add_memory
   drivers/firmware/dell_rbu.c: In function 'packet_empty_list':
>> drivers/firmware/dell_rbu.c:357:3: error: implicit declaration of function 
>> 'set_memory_wb'; did you mean 'add_memory'? 
>> [-Werror=implicit-function-declaration]
  set_memory_wb(newpacket->data, (1 << newpacket->ordernum));
  ^
  add_memory
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 2 include/linux/list.h:__list_add
   Cyclomatic Complexity 1 include/linux/list.h:list_add_tail
   Cyclomatic Complexity 1 include/linux/list.h:__list_del
   Cyclomatic Complexity 2 include/linux/list.h:__list_del_entry
   Cyclomatic Complexity 1 include/linux/list.h:list_del
   Cyclomatic Complexity 1 include/linux/list.h:list_empty
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:arch_local_save_flags
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 
arch/x86/include/asm/irqflags.h:arch_irqs_disabled_flags
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:virt_to_phys
   Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
   Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 
include/linux/platform_device.h:platform_device_register_resndata
   Cyclomatic Complexity 1 
include/linux/platform_device.h:platform_device_register_simple
   Cyclomatic Complexity 1 include/linux/dma-debug.h:debug_dma_free_coherent
   Cyclomatic Complexity 1 arch/x86/include/asm/dma-mapping.h:get_arch_dma_ops
   Cyclomatic Complexity 4 include/linux/dma-mapping.h:get_dma_ops
   Cyclomatic Complexity 71 include/linux/dma-mapping.h:dma_free_attrs
   Cyclomatic Complexity 1 include/linux/dma-mapping.h:dma_free_coherent
   Cyclomatic Complexity 1 drivers/firmware/dell_rbu.c:init_packet_head
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:img_update_free
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:packet_empty_list
   Cyclomatic Complexity 1 drivers/firmware/dell_rbu.c:dcdrbu_exit
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:dcdrbu_init
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:write_rbu_packet_size
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:read_rbu_packet_size
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:read_rbu_image_type
   Cyclomatic Complexity 9 drivers/firmware/dell_rbu.c:write_rbu_image_type
   Cyclomatic Complexity 71 drivers/firmware/dell_rbu.c:img_update_realloc
   Cyclomatic Complexity 75 drivers/firmware/dell_rbu.c:create_packet
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:packetize_data
   Cyclomatic Complexity 7 drivers/firmware/dell_rbu.c:callbackfn_rbu
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:read_rbu_mono_data
   Cyclomatic Complexity 4 drivers/firmware/dell_rbu.c:do_packet_read
   Cyclomatic Complexity 4 drivers/firmware/dell_rbu.c:packet_read_list
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:read_packet_data
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:read_rbu_data
   Cyclomatic Complexity 1 
drivers/firmware/dell_rbu.c:_GLOBAL__sub_I_00100_0_dell_rbu.c
   Cyclomatic Complexity 1 
drivers/firmware/dell_rbu.c:_GLOBAL__sub_D_00100_1_dell_rbu.c
   cc1: some warnings being treated as errors

vim +187 drivers/firmware/dell_rbu.c

   101  
   102  static int create_packet(void *data, size_t length)
   103  {
  

Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-22 Thread kbuild test robot
Hi Stuart,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
config: i386-randconfig-x014-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/firmware/dell_rbu.c: In function 'create_packet':
>> drivers/firmware/dell_rbu.c:187:3: error: implicit declaration of function 
>> 'set_memory_uc'; did you mean 'add_memory'? 
>> [-Werror=implicit-function-declaration]
  set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
  ^
  add_memory
   drivers/firmware/dell_rbu.c: In function 'packet_empty_list':
>> drivers/firmware/dell_rbu.c:357:3: error: implicit declaration of function 
>> 'set_memory_wb'; did you mean 'add_memory'? 
>> [-Werror=implicit-function-declaration]
  set_memory_wb(newpacket->data, (1 << newpacket->ordernum));
  ^
  add_memory
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 2 include/linux/list.h:__list_add
   Cyclomatic Complexity 1 include/linux/list.h:list_add_tail
   Cyclomatic Complexity 1 include/linux/list.h:__list_del
   Cyclomatic Complexity 2 include/linux/list.h:__list_del_entry
   Cyclomatic Complexity 1 include/linux/list.h:list_del
   Cyclomatic Complexity 1 include/linux/list.h:list_empty
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:arch_local_save_flags
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 
arch/x86/include/asm/irqflags.h:arch_irqs_disabled_flags
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:virt_to_phys
   Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
   Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 
include/linux/platform_device.h:platform_device_register_resndata
   Cyclomatic Complexity 1 
include/linux/platform_device.h:platform_device_register_simple
   Cyclomatic Complexity 1 include/linux/dma-debug.h:debug_dma_free_coherent
   Cyclomatic Complexity 1 arch/x86/include/asm/dma-mapping.h:get_arch_dma_ops
   Cyclomatic Complexity 4 include/linux/dma-mapping.h:get_dma_ops
   Cyclomatic Complexity 71 include/linux/dma-mapping.h:dma_free_attrs
   Cyclomatic Complexity 1 include/linux/dma-mapping.h:dma_free_coherent
   Cyclomatic Complexity 1 drivers/firmware/dell_rbu.c:init_packet_head
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:img_update_free
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:packet_empty_list
   Cyclomatic Complexity 1 drivers/firmware/dell_rbu.c:dcdrbu_exit
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:dcdrbu_init
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:write_rbu_packet_size
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:read_rbu_packet_size
   Cyclomatic Complexity 2 drivers/firmware/dell_rbu.c:read_rbu_image_type
   Cyclomatic Complexity 9 drivers/firmware/dell_rbu.c:write_rbu_image_type
   Cyclomatic Complexity 71 drivers/firmware/dell_rbu.c:img_update_realloc
   Cyclomatic Complexity 75 drivers/firmware/dell_rbu.c:create_packet
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:packetize_data
   Cyclomatic Complexity 7 drivers/firmware/dell_rbu.c:callbackfn_rbu
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:read_rbu_mono_data
   Cyclomatic Complexity 4 drivers/firmware/dell_rbu.c:do_packet_read
   Cyclomatic Complexity 4 drivers/firmware/dell_rbu.c:packet_read_list
   Cyclomatic Complexity 5 drivers/firmware/dell_rbu.c:read_packet_data
   Cyclomatic Complexity 3 drivers/firmware/dell_rbu.c:read_rbu_data
   Cyclomatic Complexity 1 
drivers/firmware/dell_rbu.c:_GLOBAL__sub_I_00100_0_dell_rbu.c
   Cyclomatic Complexity 1 
drivers/firmware/dell_rbu.c:_GLOBAL__sub_D_00100_1_dell_rbu.c
   cc1: some warnings being treated as errors

vim +187 drivers/firmware/dell_rbu.c

   101  
   102  static int create_packet(void *data, size_t length)
   103  {
  

Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-22 Thread kbuild test robot
Hi Stuart,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
config: i386-randconfig-a0-201811 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/firmware/dell_rbu.c: In function 'create_packet':
>> drivers/firmware/dell_rbu.c:187:3: error: implicit declaration of function 
>> 'set_memory_uc' [-Werror=implicit-function-declaration]
  set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
  ^
   drivers/firmware/dell_rbu.c: In function 'packet_empty_list':
>> drivers/firmware/dell_rbu.c:357:3: error: implicit declaration of function 
>> 'set_memory_wb' [-Werror=implicit-function-declaration]
  set_memory_wb(newpacket->data, (1 << newpacket->ordernum));
  ^
   cc1: some warnings being treated as errors

vim +/set_memory_uc +187 drivers/firmware/dell_rbu.c

   101  
   102  static int create_packet(void *data, size_t length)
   103  {
   104  struct packet_data *newpacket;
   105  int ordernum = 0;
   106  int retval = 0;
   107  unsigned int packet_array_size = 0;
   108  void **invalid_addr_packet_array = NULL;
   109  void *packet_data_temp_buf = NULL;
   110  unsigned int idx = 0;
   111  
   112  pr_debug("create_packet: entry \n");
   113  
   114  if (!rbu_data.packetsize) {
   115  pr_debug("create_packet: packetsize not specified\n");
   116  retval = -EINVAL;
   117  goto out_noalloc;
   118  }
   119  
   120  spin_unlock(_data.lock);
   121  
   122  newpacket = kzalloc(sizeof (struct packet_data), GFP_KERNEL);
   123  
   124  if (!newpacket) {
   125  printk(KERN_WARNING
   126  "dell_rbu:%s: failed to allocate new "
   127  "packet\n", __func__);
   128  retval = -ENOMEM;
   129  spin_lock(_data.lock);
   130  goto out_noalloc;
   131  }
   132  
   133  ordernum = get_order(length);
   134  
   135  /*
   136   * BIOS errata mean we cannot allocate packets below 1MB or 
they will
   137   * be overwritten by BIOS.
   138   *
   139   * array to temporarily hold packets
   140   * that are below the allocation floor
   141   *
   142   * NOTE: very simplistic because we only need the floor to be 
at 1MB
   143   *   due to BIOS errata. This shouldn't be used for higher 
floors
   144   *   or you will run out of mem trying to allocate the 
array.
   145   */
   146  packet_array_size = max(
   147  (unsigned int)(allocation_floor / 
rbu_data.packetsize),
   148  (unsigned int)1);
   149  invalid_addr_packet_array = kzalloc(packet_array_size * 
sizeof(void*),
   150  GFP_KERNEL);
   151  
   152  if (!invalid_addr_packet_array) {
   153  printk(KERN_WARNING
   154  "dell_rbu:%s: failed to allocate "
   155  "invalid_addr_packet_array \n",
   156  __func__);
   157  retval = -ENOMEM;
   158  spin_lock(_data.lock);
   159  goto out_alloc_packet;
   160  }
   161  
   162  while (!packet_data_temp_buf) {
   163  packet_data_temp_buf = (unsigned char *)
   164  __get_free_pages(GFP_KERNEL, ordernum);
   165  if (!packet_data_temp_buf) {
   166  printk(KERN_WARNING
   167  "dell_rbu:%s: failed to allocate new "
   168  "packet\n", __func__);
   169  retval = -ENOMEM;
   170  spin_lock(_data.lock);
   171  goto out_alloc_packet_array;
   172  }
   173  
   174  if ((unsigned long)virt_to_phys(packet_data_temp_buf)
   175  < allocation_floor) {
   176  pr_debug("packet 0x%lx below floor at 0x%lx.\n",
   177  (unsigned long)virt_to_phys(
   178  packet_data_temp_buf),
   179  allocation_floor);
   180  invalid_addr_packet_array[idx++] = 

Re: [PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-22 Thread kbuild test robot
Hi Stuart,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stuart-Hayes/dell_rbu-make-firmware-payload-memory-uncachable/20180323-094405
config: i386-randconfig-a0-201811 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/firmware/dell_rbu.c: In function 'create_packet':
>> drivers/firmware/dell_rbu.c:187:3: error: implicit declaration of function 
>> 'set_memory_uc' [-Werror=implicit-function-declaration]
  set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
  ^
   drivers/firmware/dell_rbu.c: In function 'packet_empty_list':
>> drivers/firmware/dell_rbu.c:357:3: error: implicit declaration of function 
>> 'set_memory_wb' [-Werror=implicit-function-declaration]
  set_memory_wb(newpacket->data, (1 << newpacket->ordernum));
  ^
   cc1: some warnings being treated as errors

vim +/set_memory_uc +187 drivers/firmware/dell_rbu.c

   101  
   102  static int create_packet(void *data, size_t length)
   103  {
   104  struct packet_data *newpacket;
   105  int ordernum = 0;
   106  int retval = 0;
   107  unsigned int packet_array_size = 0;
   108  void **invalid_addr_packet_array = NULL;
   109  void *packet_data_temp_buf = NULL;
   110  unsigned int idx = 0;
   111  
   112  pr_debug("create_packet: entry \n");
   113  
   114  if (!rbu_data.packetsize) {
   115  pr_debug("create_packet: packetsize not specified\n");
   116  retval = -EINVAL;
   117  goto out_noalloc;
   118  }
   119  
   120  spin_unlock(_data.lock);
   121  
   122  newpacket = kzalloc(sizeof (struct packet_data), GFP_KERNEL);
   123  
   124  if (!newpacket) {
   125  printk(KERN_WARNING
   126  "dell_rbu:%s: failed to allocate new "
   127  "packet\n", __func__);
   128  retval = -ENOMEM;
   129  spin_lock(_data.lock);
   130  goto out_noalloc;
   131  }
   132  
   133  ordernum = get_order(length);
   134  
   135  /*
   136   * BIOS errata mean we cannot allocate packets below 1MB or 
they will
   137   * be overwritten by BIOS.
   138   *
   139   * array to temporarily hold packets
   140   * that are below the allocation floor
   141   *
   142   * NOTE: very simplistic because we only need the floor to be 
at 1MB
   143   *   due to BIOS errata. This shouldn't be used for higher 
floors
   144   *   or you will run out of mem trying to allocate the 
array.
   145   */
   146  packet_array_size = max(
   147  (unsigned int)(allocation_floor / 
rbu_data.packetsize),
   148  (unsigned int)1);
   149  invalid_addr_packet_array = kzalloc(packet_array_size * 
sizeof(void*),
   150  GFP_KERNEL);
   151  
   152  if (!invalid_addr_packet_array) {
   153  printk(KERN_WARNING
   154  "dell_rbu:%s: failed to allocate "
   155  "invalid_addr_packet_array \n",
   156  __func__);
   157  retval = -ENOMEM;
   158  spin_lock(_data.lock);
   159  goto out_alloc_packet;
   160  }
   161  
   162  while (!packet_data_temp_buf) {
   163  packet_data_temp_buf = (unsigned char *)
   164  __get_free_pages(GFP_KERNEL, ordernum);
   165  if (!packet_data_temp_buf) {
   166  printk(KERN_WARNING
   167  "dell_rbu:%s: failed to allocate new "
   168  "packet\n", __func__);
   169  retval = -ENOMEM;
   170  spin_lock(_data.lock);
   171  goto out_alloc_packet_array;
   172  }
   173  
   174  if ((unsigned long)virt_to_phys(packet_data_temp_buf)
   175  < allocation_floor) {
   176  pr_debug("packet 0x%lx below floor at 0x%lx.\n",
   177  (unsigned long)virt_to_phys(
   178  packet_data_temp_buf),
   179  allocation_floor);
   180  invalid_addr_packet_array[idx++] = 

[PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-21 Thread Stuart Hayes
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 
---
Note that there is no maintainer for this driver, so I'd be grateful if
someone could apply this... thank you!

diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 2f452f1..6b84814 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -180,6 +180,11 @@ static int create_packet(void *data, size_t length)
invalid_addr_packet_array[idx++] = packet_data_temp_buf;
packet_data_temp_buf = NULL;
}
+   /*
+* set to uncachable or it may never get written back before
+* reboot
+*/
+   set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
}
spin_lock(_data.lock);
 
@@ -349,6 +354,7 @@ 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(newpacket->data, (1 << newpacket->ordernum));
free_pages((unsigned long) newpacket->data,
newpacket->ordernum);
kfree(newpacket);


[PATCH] dell_rbu: make firmware payload memory uncachable

2018-03-21 Thread Stuart Hayes
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 
---
Note that there is no maintainer for this driver, so I'd be grateful if
someone could apply this... thank you!

diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 2f452f1..6b84814 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -180,6 +180,11 @@ static int create_packet(void *data, size_t length)
invalid_addr_packet_array[idx++] = packet_data_temp_buf;
packet_data_temp_buf = NULL;
}
+   /*
+* set to uncachable or it may never get written back before
+* reboot
+*/
+   set_memory_uc(packet_data_temp_buf, 1 << (ordernum));
}
spin_lock(_data.lock);
 
@@ -349,6 +354,7 @@ 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(newpacket->data, (1 << newpacket->ordernum));
free_pages((unsigned long) newpacket->data,
newpacket->ordernum);
kfree(newpacket);