Skip to contentSkip to conversation

drivers/scsi/mca_53c9x.c : save_flags()/cli() removal

PATCH In review Amol Lad 5 participants 7 messages Nov 7, 2006 – Nov 8, 2006 SCSI

lore
Share & tools
lore

Amol Lad

author
#0 lore raw

PATCH 1/1 drivers/scsi/mca_53c9x.c : save_flags()/cli() removal

Replaced save_flags()/cli() with spin_lock alternatives

---
Andrew,
Please add this to -mm
---

drivers/scsi/mca_53c9x.c +4 -8
@@ -341,9 +341,7 @@ static void dma_init_read(struct NCR_ESP
 {
 	unsigned long flags;
 
-
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(esp->ehost->host_lock, flags);
 
 	mca_disable_dma(esp->dma);
 	mca_set_dma_mode(esp->dma, MCA_DMA_MODE_XFER | MCA_DMA_MODE_16 |
@@ -352,16 +350,14 @@ static void dma_init_read(struct NCR_ESP
 	mca_set_dma_count(esp->dma, length / 2); /* !!! */
 	mca_enable_dma(esp->dma);
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(esp->ehost->host_lock, flags);
 }
 
 static void dma_init_write(struct NCR_ESP *esp, __u32 addr, int length)
 {
 	unsigned long flags;
 
-
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(esp->ehost->host_lock, flags);
 
 	mca_disable_dma(esp->dma);
 	mca_set_dma_mode(esp->dma, MCA_DMA_MODE_XFER | MCA_DMA_MODE_WRITE |
@@ -370,7 +366,7 @@ static void dma_init_write(struct NCR_ES
 	mca_set_dma_count(esp->dma, length / 2); /* !!! */
 	mca_enable_dma(esp->dma);
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(esp->ehost->host_lock, flags);
 }
 
 static void dma_ints_off(struct NCR_ESP *esp)
#1 lore raw
Quoted 40 lines · On Mon, 06 Nov 2006 18:12:11 +0530 Amol Lad <[email protected]> wrote:

Replaced save_flags()/cli() with spin_lock alternatives

---
Andrew,
Please add this to -mm
---

drivers/scsi/mca_53c9x.c +3 -7
@@ -341,9 +341,7 @@ static void dma_init_read(struct NCR_ESP
 {
 	unsigned long flags;
 
-
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(esp->ehost->host_lock, flags);
 
 	mca_disable_dma(esp->dma);
 	mca_set_dma_mode(esp->dma, MCA_DMA_MODE_XFER | MCA_DMA_MODE_16 |
@@ -352,16 +350,14 @@ static void dma_init_read(struct NCR_ESP
 	mca_set_dma_count(esp->dma, length / 2); /* !!! */
 	mca_enable_dma(esp->dma);
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(esp->ehost->host_lock, flags);
 }
 
 static void dma_init_write(struct NCR_ESP *esp, __u32 addr, int length)
 {
 	unsigned long flags;
 
-
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(esp->ehost->host_lock, flags);
 
 	mca_disable_dma(esp->dma);
 	mca_set_dma_mode(esp->dma, MCA_DMA_MODE_XFER | MCA_DMA_MODE_WRITE |

drivers/scsi/mca_53c9x.c static void dma_init_write(struct NCR_ES · line 372

Quoted 8 lines
drivers/scsi/mca_53c9x.c +1 -1
@@ -370,7 +366,7 @@ static void dma_init_write(struct NCR_ES
 	mca_set_dma_count(esp->dma, length / 2); /* !!! */
 	mca_enable_dma(esp->dma);
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(esp->ehost->host_lock, flags);
 }
 
 static void dma_ints_off(struct NCR_ESP *esp)

hm. How do we find out if this works?

If it _does_ work then we can now remove the Kconfig BROKEN_ON_SMP dependency for this driver.

#2 lore raw
Quoted 1 line · Andrew Morton

hm. How do we find out if this works?

I'm not sure anyone has this type of HW anymore. It was the original SCSI chip for the old MCA based IBM PC. I can dig through my hardware bins to see if I have a card, but I don't think so.

Quoted 2 lines

If it _does_ work then we can now remove the Kconfig BROKEN_ON_SMP dependency for this driver.

Theoretically, yes ... practically I don't think there was an SMP box produced with this chip.

James

author
#3 lore raw
Quoted 7 lines · James Bottomley
Quoted 1 line · Andrew Morton

hm. How do we find out if this works?

I'm not sure anyone has this type of HW anymore. It was the original SCSI chip for the old MCA based IBM PC. I can dig through my hardware bins to see if I have a card, but I don't think so.

The only way I see is the code review.

Most of the drivers using save_flags()/cli() interfaces are not in use anymore (such as drivers/char/riscom8.c). There are two possibilities:
1. Remove such drivers from kernel
2. Fix them

This would mean we can remove cli()/sti()/save_flags() interfaces from the kernel so that any new development does not uses them accidently

Quoted 11 lines
Quoted 3 lines

If it _does_ work then we can now remove the Kconfig BROKEN_ON_SMP dependency for this driver.

Theoretically, yes ... practically I don't think there was an SMP box produced with this chip.

James

#4 lore raw
In reply to James Bottomley

Ar Mer, 2006-11-08 am 09:19 +0900, ysgrifennodd James Bottomley:

Quoted 7 lines · Andrew Morton
Quoted 2 lines

hm. How do we find out if this works?

I'm not sure anyone has this type of HW anymore. It was the original SCSI chip for the old MCA based IBM PC. I can dig through my hardware bins to see if I have a card, but I don't think so.

There was one in the pile of MCA cards I posted you I think.

#5 lore raw
In reply to Amol Lad
Quoted 1 line · Amol Lad

Replaced save_flags()/cli() with spin_lock alternatives

This patch has very little chance to work as-is because it only replaces cli with spinlocks, but not the irq handler it's locking against.

author
#6 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 1 line · Amol Lad

Replaced save_flags()/cli() with spin_lock alternatives

This patch has very little chance to work as-is because it only replaces cli with spinlocks, but not the irq handler it's locking against.

It protects against irq handler also.

drivers/scsi/NCR53C9x.c:

irqreturn_t esp_intr(int irq, void *dev_id)

{
    struct NCR_ESP *esp;
    unsigned long flags;
    int again;
    struct Scsi_Host *dev = dev_id;

    /* Handle all ESP interrupts showing at this IRQ level. */
    spin_lock_irqsave(dev->host_lock, flags);

...
...
}