Commit 1dd7def0 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

Staging: meilhaus: convert nested spin_lock_irqsave to spin_lock

If spin_lock_irqsave is called twice in a row with the same second
argument, the interrupt state at the point of the second call overwrites
the value saved by the first call.  Indeed, the second call does not need
to save the interrupt state, so it is changed to a simple spin_lock.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression lock1,lock2;
expression flags;
@@

*spin_lock_irqsave(lock1,flags)
... when != flags
*spin_lock_irqsave(lock2,flags)
// </smpl>
Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
Cc: David Kiliani <mail@davidkiliani.de>
Cc: Meilhaus Support <support@meilhaus.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c60adf37
...@@ -760,7 +760,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice, ...@@ -760,7 +760,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice,
// Mark that StreamConfig is removed. // Mark that StreamConfig is removed.
instance->chan_list_len = 0; instance->chan_list_len = 0;
spin_lock_irqsave(instance->ctrl_reg_lock, cpu_flags); spin_lock(instance->ctrl_reg_lock);
/// @note Imprtant: Preserve EXT IRQ settings. /// @note Imprtant: Preserve EXT IRQ settings.
tmp = inl(instance->ctrl_reg); tmp = inl(instance->ctrl_reg);
// Clear FIFOs and dissable interrupts // Clear FIFOs and dissable interrupts
...@@ -824,7 +824,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice, ...@@ -824,7 +824,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice,
instance->ctrl_reg - instance->reg_base, instance->ctrl_reg - instance->reg_base,
instance->single_config[channel].ctrl | tmp); instance->single_config[channel].ctrl | tmp);
spin_unlock_irqrestore(instance->ctrl_reg_lock, cpu_flags); spin_unlock(instance->ctrl_reg_lock);
if (!(instance->single_config[channel].ctrl & ME4600_AI_CTRL_BIT_EX_TRIG)) { // Software start if (!(instance->single_config[channel].ctrl & ME4600_AI_CTRL_BIT_EX_TRIG)) { // Software start
inl(instance->start_reg); inl(instance->start_reg);
...@@ -877,7 +877,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice, ...@@ -877,7 +877,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice,
} }
// Restore settings. // Restore settings.
spin_lock_irqsave(instance->ctrl_reg_lock, cpu_flags); spin_lock(instance->ctrl_reg_lock);
tmp = inl(instance->ctrl_reg); tmp = inl(instance->ctrl_reg);
// Clear FIFOs and dissable interrupts. // Clear FIFOs and dissable interrupts.
tmp &= tmp &=
...@@ -889,7 +889,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice, ...@@ -889,7 +889,7 @@ static int me4600_ai_io_single_read(me_subdevice_t *subdevice,
outl(tmp, instance->ctrl_reg); outl(tmp, instance->ctrl_reg);
PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base, PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base,
instance->ctrl_reg - instance->reg_base, tmp); instance->ctrl_reg - instance->reg_base, tmp);
spin_unlock_irqrestore(instance->ctrl_reg_lock, cpu_flags); spin_unlock(instance->ctrl_reg_lock);
spin_unlock_irqrestore(&instance->subdevice_lock, cpu_flags); spin_unlock_irqrestore(&instance->subdevice_lock, cpu_flags);
...@@ -1268,7 +1268,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice, ...@@ -1268,7 +1268,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice,
} }
instance->status = ai_status_none; instance->status = ai_status_none;
spin_lock_irqsave(instance->ctrl_reg_lock, cpu_flags); spin_lock(instance->ctrl_reg_lock);
// Stop all actions. Block all interrupts. Clear (disable) FIFOs. // Stop all actions. Block all interrupts. Clear (disable) FIFOs.
ctrl = ctrl =
ME4600_AI_CTRL_BIT_LE_IRQ_RESET | ME4600_AI_CTRL_BIT_HF_IRQ_RESET | ME4600_AI_CTRL_BIT_LE_IRQ_RESET | ME4600_AI_CTRL_BIT_HF_IRQ_RESET |
...@@ -1290,7 +1290,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice, ...@@ -1290,7 +1290,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice,
outl(tmp | ctrl, instance->ctrl_reg); outl(tmp | ctrl, instance->ctrl_reg);
PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base, PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base,
instance->ctrl_reg - instance->reg_base, tmp | ctrl); instance->ctrl_reg - instance->reg_base, tmp | ctrl);
spin_unlock_irqrestore(instance->ctrl_reg_lock, cpu_flags); spin_unlock(instance->ctrl_reg_lock);
// Write the channel list // Write the channel list
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
...@@ -1529,7 +1529,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice, ...@@ -1529,7 +1529,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice,
ctrl |= (ME4600_AI_CTRL_BIT_HF_IRQ | ME4600_AI_CTRL_BIT_SC_IRQ | ME4600_AI_CTRL_BIT_LE_IRQ); //The last IRQ source (ME4600_AI_CTRL_BIT_LE_IRQ) is unused! ctrl |= (ME4600_AI_CTRL_BIT_HF_IRQ | ME4600_AI_CTRL_BIT_SC_IRQ | ME4600_AI_CTRL_BIT_LE_IRQ); //The last IRQ source (ME4600_AI_CTRL_BIT_LE_IRQ) is unused!
//Everything is good. Finalize //Everything is good. Finalize
spin_lock_irqsave(instance->ctrl_reg_lock, cpu_flags); spin_lock(instance->ctrl_reg_lock);
tmp = inl(instance->ctrl_reg); tmp = inl(instance->ctrl_reg);
//Preserve EXT IRQ and OFFSET settings. Clean other bits. //Preserve EXT IRQ and OFFSET settings. Clean other bits.
...@@ -1541,7 +1541,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice, ...@@ -1541,7 +1541,7 @@ static int me4600_ai_io_stream_config(me_subdevice_t *subdevice,
outl(ctrl | tmp, instance->ctrl_reg); outl(ctrl | tmp, instance->ctrl_reg);
PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base, PDEBUG_REG("ctrl_reg outl(0x%lX+0x%lX)=0x%x\n", instance->reg_base,
instance->ctrl_reg - instance->reg_base, ctrl | tmp); instance->ctrl_reg - instance->reg_base, ctrl | tmp);
spin_unlock_irqrestore(instance->ctrl_reg_lock, cpu_flags); spin_unlock(instance->ctrl_reg_lock);
//Set the global parameters end exit. //Set the global parameters end exit.
instance->chan_list_len = count; instance->chan_list_len = count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment