firewire: core: reduce stack usage in bus reset tasklet
PATCH 1/1 firewire: core: reduce stack usage in bus reset tasklet
fw_compute_block_crc() used 1024 bytes of the kernel stack. This function is called
- in process context when the local node's config ROM is updated,
- in tasklet context of the bus reset handler.
Replace the stack-allocated buffer by a static buffer. Serialize buffer accesses by a static local spinlock.
Signed-off-by Stefan Richter <[email protected]>
--- drivers/firewire/core-card.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/firewire/core-card.c +9 -3
@@ -40,13 +40,19 @@int fw_compute_block_crc (u32 *block) { -__be32 be32_block[256 ]; +static DEFINE_SPINLOCK (buffer_lock); +static __be32 buffer[256 ]; +unsigned long flags;int i, length; +spin_lock_irqsave (&buffer_lock, flags); + length = (*block >>16 ) &0xff ;for (i =0 ; i < length; i++) - be32_block[i] =cpu_to_be32 (block[i +1 ]); - *block |=crc_itu_t (0 , (u8 *) be32_block, length *4 ); + buffer[i] =cpu_to_be32 (block[i +1 ]); + *block |=crc_itu_t (0 , (u8 *)buffer, length *4 ); + +spin_unlock_irqrestore (&buffer_lock, flags);return length; }
Signature · 3 lines
Stefan Richter -=====-==--= =--- ===-- http://arcgraph.de/sr/