LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Fix loading of large firmware files.
@ 2008-04-17 14:21 thomas
2008-04-17 17:07 ` [PATCH][Resend] " Thomas Hellstrom
0 siblings, 1 reply; 2+ messages in thread
From: thomas @ 2008-04-17 14:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Thomas Hellstrom
From: Thomas Hellstrom <thomas@tungstengraphics.com>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH][Resend] Fix loading of large firmware files
2008-04-17 14:21 [PATCH] Fix loading of large firmware files thomas
@ 2008-04-17 17:07 ` Thomas Hellstrom
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Hellstrom @ 2008-04-17 17:07 UTC (permalink / raw)
To: linux-kernel; +Cc: Thomas Hellstrom
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-17 16:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-17 14:21 [PATCH] Fix loading of large firmware files thomas
2008-04-17 17:07 ` [PATCH][Resend] " Thomas Hellstrom
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).