Date: Mon, 9 Apr 2012 21:40:33 +0200 From: Stefan Richter Subject: firewire: ohci: omit spinlock IRQ flags where possible bus_reset_work() is only called from workqueue thread context. ohci_set_config_rom() and ohci_allocate_iso_context() perform GFP_KERNEL memory allocations, therefore they must be called with interrupts enabled. Hence these functions may disable and enable local IRQs without having to track IRQ state. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1824,7 +1824,6 @@ static void bus_reset_work(struct work_s container_of(work, struct fw_ohci, bus_reset_work); int self_id_count, generation, new_generation, i, j; u32 reg; - unsigned long flags; void *free_rom = NULL; dma_addr_t free_rom_bus = 0; bool is_new_root; @@ -1931,13 +1930,13 @@ static void bus_reset_work(struct work_s } /* FIXME: Document how the locking works. */ - spin_lock_irqsave(&ohci->lock, flags); + spin_lock_irq(&ohci->lock); ohci->generation = -1; /* prevent AT packet queueing */ context_stop(&ohci->at_request_ctx); context_stop(&ohci->at_response_ctx); - spin_unlock_irqrestore(&ohci->lock, flags); + spin_unlock_irq(&ohci->lock); /* * Per OHCI 1.2 draft, clause 7.2.3.3, hardware may leave unsent @@ -1947,7 +1946,7 @@ static void bus_reset_work(struct work_s at_context_flush(&ohci->at_request_ctx); at_context_flush(&ohci->at_response_ctx); - spin_lock_irqsave(&ohci->lock, flags); + spin_lock_irq(&ohci->lock); ohci->generation = generation; reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); @@ -1991,7 +1990,7 @@ static void bus_reset_work(struct work_s reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0); #endif - spin_unlock_irqrestore(&ohci->lock, flags); + spin_unlock_irq(&ohci->lock); if (free_rom) dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, @@ -2403,7 +2402,6 @@ static int ohci_set_config_rom(struct fw const __be32 *config_rom, size_t length) { struct fw_ohci *ohci; - unsigned long flags; __be32 *next_config_rom; dma_addr_t uninitialized_var(next_config_rom_bus); @@ -2442,7 +2440,7 @@ static int ohci_set_config_rom(struct fw if (next_config_rom == NULL) return -ENOMEM; - spin_lock_irqsave(&ohci->lock, flags); + spin_lock_irq(&ohci->lock); /* * If there is not an already pending config_rom update, @@ -2468,7 +2466,7 @@ static int ohci_set_config_rom(struct fw reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); - spin_unlock_irqrestore(&ohci->lock, flags); + spin_unlock_irq(&ohci->lock); /* If we didn't use the DMA allocation, delete it. */ if (next_config_rom != NULL) @@ -2892,10 +2890,9 @@ static struct fw_iso_context *ohci_alloc descriptor_callback_t uninitialized_var(callback); u64 *uninitialized_var(channels); u32 *uninitialized_var(mask), uninitialized_var(regs); - unsigned long flags; int index, ret = -EBUSY; - spin_lock_irqsave(&ohci->lock, flags); + spin_lock_irq(&ohci->lock); switch (type) { case FW_ISO_CONTEXT_TRANSMIT: @@ -2939,7 +2936,7 @@ static struct fw_iso_context *ohci_alloc ret = -ENOSYS; } - spin_unlock_irqrestore(&ohci->lock, flags); + spin_unlock_irq(&ohci->lock); if (index < 0) return ERR_PTR(ret); @@ -2965,7 +2962,7 @@ static struct fw_iso_context *ohci_alloc out_with_header: free_page((unsigned long)ctx->header); out: - spin_lock_irqsave(&ohci->lock, flags); + spin_lock_irq(&ohci->lock); switch (type) { case FW_ISO_CONTEXT_RECEIVE: @@ -2978,7 +2975,7 @@ static struct fw_iso_context *ohci_alloc } *mask |= 1 << index; - spin_unlock_irqrestore(&ohci->lock, flags); + spin_unlock_irq(&ohci->lock); return ERR_PTR(ret); }