Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fd2f3bddaeb20564f32e59f64e5063fbe0c8f4cc
Commit:     fd2f3bddaeb20564f32e59f64e5063fbe0c8f4cc
Parent:     c1a37f2c6572031203243dd083585aa4a1c138d5
Author:     Stefan Richter <[EMAIL PROTECTED]>
AuthorDate: Sun Mar 11 22:51:24 2007 +0100
Committer:  Stefan Richter <[EMAIL PROTECTED]>
CommitDate: Mon Apr 30 00:00:28 2007 +0200

    ieee1394: replace vmalloc by kmalloc in csr1212
    
    The biggest chunk ever allocated by CSR1212_MALLOC is 1024 Bytes +
    sizeof(struct csr1212_csr_rom_cache) big.  Most of the time much
    smaller data structures are allocated.  Therefore vmalloc is a waste.
    
    The one exception is csr1212_append_new_cache() which is called to
    append a chunk of CSR1212_EXTENDED_ROM_SIZE + sizeof(struct
    csr1212_csr_rom_cache) if the currently allocated ROM cache is too
    small.  CSR1212_EXTENDED_ROM_SIZE is generously defined as 256 kBytes.
    In SVN commit 1220, Steve Kinneberg lowered this to 2 kBytes in the
    config_rom_2.4 branch.  This same commit also switched CSR1212_MALLOC
    from kmalloc to vmalloc in the SVN trunk branch:
    
    > r1220 | kberg | 2004-05-31 01:51:44 +0200 (Mon, 31 May 2004) | 13 lines
    >
    > CSR1212 Extended ROM bug fixes:
    > trunk line changes:
    >   - Use vmalloc instead of kmalloc
    >   - Change delayed_reset_bus() to operate in a work_queue instead of a
    >     timer interrupt.
    >   - Fix hpsb_allocate_and_register_addrspace() to not allocate space
    >     on top of already allocated space.
    >   - Fix problems in csr1212.c filling ConfigROM images when extend
    >     ROMs are present.
    > config-rom-2.4 changes:
    >   - Changed extended rom allocation from 256K to 8K.
    (It was actually 2 kB, not 8 kB.)
    >   - Fix hpsb_allocate_and_register_addrspace() to not allocate space
    >     on top of already allocated space.
    >   - Fix problems in csr1212.c filling ConfigROM images when extend
    >     ROMs are present.
    
    I am now setting CSR1212_EXTENDED_ROM_SIZE to 2 kB minus the overhead of
    struct csr1212_csr_rom_cache.  Note, this code path is not used by the
    in-kernel drivers though.  raw1394 could trigger it, but the respective
    libraw1394 functions don't exist yet.
    
    Furthermore, userspace programs can replace the entire local ROM via
    raw1394.  If kmalloc does not fulfill their needs --- well, tough luck.
    I decree that nobody needs such huge extended ROMs.  (Extended ROMs are
    defined by IEEE 1212 clause 7.7.18.  The spec does not impose
    practically relevant restrictions on the size of extended ROM chunks.)
    
    Another potentially demanding use of CSR1212_MALLOC is if external
    FireWire devices come with Extended ROM entries.  If they are too big
    for kmalloc (or have been too big for vmalloc) we just fail to read
    their ROM.  This is quite unlikely though, to my knowledge.
    
    Signed-off-by: Stefan Richter <[EMAIL PROTECTED]>
---
 drivers/ieee1394/csr1212.c |    4 +++-
 drivers/ieee1394/csr1212.h |    6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 6c2f55b..2fd465e 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -932,7 +932,9 @@ static void csr1212_fill_cache(struct csr1212_csr_rom_cache 
*cache)
        }
 }
 
-#define CSR1212_EXTENDED_ROM_SIZE (0x10000 * sizeof(u32))
+/* This size is arbitrarily chosen.
+ * The struct overhead is subtracted for more economic allocations. */
+#define CSR1212_EXTENDED_ROM_SIZE (2048 - sizeof(struct csr1212_csr_rom_cache))
 
 int csr1212_generate_csr_image(struct csr1212_csr *csr)
 {
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index 6558275..cc23f3a 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -31,10 +31,10 @@
 #define __CSR1212_H__
 
 #include <linux/types.h>
-#include <linux/vmalloc.h>
+#include <linux/slab.h>
 
-#define CSR1212_MALLOC(size)           vmalloc((size))
-#define CSR1212_FREE(ptr)              vfree(ptr)
+#define CSR1212_MALLOC(size)   kmalloc((size), GFP_KERNEL)
+#define CSR1212_FREE(ptr)      kfree(ptr)
 
 #define CSR1212_SUCCESS (0)
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to