lkml.org 
[lkml]   [2008]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][Resend] Fix loading of large firmware files
Date
Firmware loading has a memory allocation complexity of
O(size * size), which makes loads of very large firmware files
stall and fail. This patch fixes that problem by making the
allocation complexity O(size * ln(size)).
Signed-off-by: Thomas Hellstrom <thomas@tungstengraphics.com>
---
drivers/base/firmware_class.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4a1b9bf..4215cbf 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -206,7 +206,9 @@ fw_realloc_buffer(struct firmware_priv *
if (min_size <= fw_priv->alloc_size)
return 0;

- new_size = ALIGN(min_size, PAGE_SIZE);
+ new_size = 2 * new_size;
+ new_size = (min_size > new_size) ? min_size : new_size;
+ new_size = ALIGN(new_size, PAGE_SIZE);
new_data = vmalloc(new_size);
if (!new_data) {
printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__);
--
1.4.1




\
 
 \ /
  Last update: 2008-04-17 18:11    [W:0.065 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site