[patch 15/28] PCI Error Recovery: Symbios SCSI base support

2007-05-10 Thread akpm
From: Linas Vepstas <[EMAIL PROTECTED]>

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the Symbios SCSI device
driver.  The patch has been tested, and appears to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: Matthew Wilcox <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sym53c8xx_2/sym_glue.c |  136 ++
 drivers/scsi/sym53c8xx_2/sym_glue.h |4 
 drivers/scsi/sym53c8xx_2/sym_hipd.c |6 +
 3 files changed, 146 insertions(+)

diff -puN 
drivers/scsi/sym53c8xx_2/sym_glue.c~pci-error-recovery-symbios-scsi-base-support
 drivers/scsi/sym53c8xx_2/sym_glue.c
--- 
a/drivers/scsi/sym53c8xx_2/sym_glue.c~pci-error-recovery-symbios-scsi-base-support
+++ a/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -657,6 +657,10 @@ static irqreturn_t sym53c8xx_intr(int ir
unsigned long flags;
struct sym_hcb *np = (struct sym_hcb *)dev_id;
 
+   /* Avoid spinloop trying to handle interrupts on frozen device */
+   if (pci_channel_offline(np->s.device))
+   return IRQ_HANDLED;
+
if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("[");
 
spin_lock_irqsave(np->s.host->host_lock, flags);
@@ -726,6 +730,20 @@ static int sym_eh_handler(int op, char *
 
dev_warn(&cmd->device->sdev_gendev, "%s operation started.\n", opname);
 
+   /* We may be in an error condition because the PCI bus
+* went down. In this case, we need to wait until the
+* PCI bus is reset, the card is reset, and only then
+* proceed with the scsi error recovery.  There's no
+* point in hurrying; take a leisurely wait.
+*/
+#define WAIT_FOR_PCI_RECOVERY  35
+   if (pci_channel_offline(np->s.device)) {
+   int finished_reset = wait_for_completion_timeout(
+   &np->s.io_reset_wait, WAIT_FOR_PCI_RECOVERY*HZ);
+   if (!finished_reset)
+   return SCSI_FAILED;
+   }
+
spin_lock_irq(host->host_lock);
/* This one is queued in some place -> to wait for completion */
FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
@@ -1510,6 +1528,7 @@ static struct Scsi_Host * __devinit sym_
np->maxoffs = dev->chip.offset_max;
np->maxburst= dev->chip.burst_max;
np->myaddr  = dev->host_id;
+   init_completion(&np->s.io_reset_wait);
 
/*
 *  Edit its name.
@@ -1948,6 +1967,116 @@ static void __devexit sym2_remove(struct
attach_count--;
 }
 
+/**
+ * sym2_io_error_detected() -- called when PCI error is detected
+ * @pdev: pointer to PCI device
+ * @state: current state of the PCI slot
+ */
+static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev,
+ enum pci_channel_state state)
+{
+   struct sym_hcb *np = pci_get_drvdata(pdev);
+
+   /* If slot is permanently frozen, turn everything off */
+   if (state == pci_channel_io_perm_failure) {
+   sym2_remove(pdev);
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+
+   init_completion(&np->s.io_reset_wait);
+   disable_irq(pdev->irq);
+   pci_disable_device(pdev);
+
+   /* Request a slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * sym2_reset_workarounds -- hardware-specific work-arounds
+ *
+ * This routine is similar to sym_set_workarounds(), except
+ * that, at this point, we already know that the device was
+ * succesfully intialized at least once before, and so most
+ * of the steps taken there are un-needed here.
+ */
+static void sym2_reset_workarounds(struct pci_dev *pdev)
+{
+   u_char revision;
+   u_short status_reg;
+   struct sym_chip *chip;
+
+   pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
+   chip = sym_lookup_chip_table(pdev->device, revision);
+
+   /* Work around for errant bit in 895A, in a fashion
+* similar to what is done in sym_set_workarounds().
+*/
+   pci_read_config_word(pdev, PCI_STATUS, &status_reg);
+   if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) {
+   status_reg = PCI_STATUS_66MHZ;
+   pci_write_config_word(pdev, PCI_STATUS, status_reg);
+   pci_read_config_word(pdev, PCI_STATUS, &status_reg);
+   }
+}
+
+/**
+ * sym2_io_slot_reset() -- called when the pci bus has been reset.
+ * @pdev: pointer to PCI device
+ *
+ * Restart the card from scratch.
+ */
+static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev)
+{
+   struct sym_hcb *np = pci_get_drvdata(pdev);
+
+   printk(KERN_INFO "%s: recovering from a PCI slot reset\n",
+ sym_name(np));
+
+   if (pci_enable_device(pdev)) {
+   printk(KERN_ERR "%s: Unable to enable afer PCI reset\n",
+   sym_name(np));
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+

[patch 16/28] PCI Error Recovery: Symbios SCSI First Failure

2007-05-10 Thread akpm
From: Linas Vepstas <[EMAIL PROTECTED]>

Implement the so-called "first failure data capture" (FFDC) for the symbios
PCI error recovery.  After a PCI error event is reported, the driver
requests that MMIO be enabled.  Once enabled, it then reads and dumps
assorted status registers, and concludes by requesting the usual reset
sequence.

(includes a whitespace fix for bad indentation).

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: Matthew Wilcox <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sym53c8xx_2/sym_glue.c |   15 +++
 drivers/scsi/sym53c8xx_2/sym_glue.h |1 +
 drivers/scsi/sym53c8xx_2/sym_hipd.c |   18 ++
 3 files changed, 30 insertions(+), 4 deletions(-)

diff -puN 
drivers/scsi/sym53c8xx_2/sym_glue.c~pci-error-recovery-symbios-scsi-first-failure
 drivers/scsi/sym53c8xx_2/sym_glue.c
--- 
a/drivers/scsi/sym53c8xx_2/sym_glue.c~pci-error-recovery-symbios-scsi-first-failure
+++ a/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -1987,6 +1987,20 @@ static pci_ers_result_t sym2_io_error_de
disable_irq(pdev->irq);
pci_disable_device(pdev);
 
+   /* Request that MMIO be enabled, so register dump can be taken. */
+   return PCI_ERS_RESULT_CAN_RECOVER;
+}
+
+/**
+ * sym2_io_slot_dump -- Enable MMIO and dump debug registers
+ * @pdev: pointer to PCI device
+ */
+static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev)
+{
+   struct sym_hcb *np = pci_get_drvdata(pdev);
+
+   sym_dump_registers(np);
+
/* Request a slot reset. */
return PCI_ERS_RESULT_NEED_RESET;
 }
@@ -2241,6 +2255,7 @@ MODULE_DEVICE_TABLE(pci, sym2_id_table);
 
 static struct pci_error_handlers sym2_err_handler = {
.error_detected = sym2_io_error_detected,
+   .mmio_enabled = sym2_io_slot_dump,
.slot_reset = sym2_io_slot_reset,
.resume = sym2_io_resume,
 };
diff -puN 
drivers/scsi/sym53c8xx_2/sym_glue.h~pci-error-recovery-symbios-scsi-first-failure
 drivers/scsi/sym53c8xx_2/sym_glue.h
--- 
a/drivers/scsi/sym53c8xx_2/sym_glue.h~pci-error-recovery-symbios-scsi-first-failure
+++ a/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -270,5 +270,6 @@ void sym_xpt_async_bus_reset(struct sym_
 void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target);
 int  sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, 
struct sym_ccb *cp);
 void sym_log_bus_error(struct sym_hcb *np);
+void sym_dump_registers(struct sym_hcb *np);
 
 #endif /* SYM_GLUE_H */
diff -puN 
drivers/scsi/sym53c8xx_2/sym_hipd.c~pci-error-recovery-symbios-scsi-first-failure
 drivers/scsi/sym53c8xx_2/sym_hipd.c
--- 
a/drivers/scsi/sym53c8xx_2/sym_hipd.c~pci-error-recovery-symbios-scsi-first-failure
+++ a/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -1180,10 +1180,10 @@ static void sym_log_hard_error(struct sy
scr_to_cpu((int) *(u32 *)(script_base + script_ofs)));
}
 
-printf ("%s: regdump:", sym_name(np));
-for (i=0; i<24;i++)
-printf (" %02x", (unsigned)INB_OFF(np, i));
-printf (".\n");
+   printf("%s: regdump:", sym_name(np));
+   for (i = 0; i < 24; i++)
+   printf(" %02x", (unsigned)INB_OFF(np, i));
+   printf(".\n");
 
/*
 *  PCI BUS error.
@@ -1192,6 +1192,16 @@ static void sym_log_hard_error(struct sy
sym_log_bus_error(np);
 }
 
+void sym_dump_registers(struct sym_hcb *np)
+{
+   u_short sist;
+   u_char dstat;
+
+   sist = INW(np, nc_sist);
+   dstat = INB(np, nc_dstat);
+   sym_log_hard_error(np, sist, dstat);
+}
+
 static struct sym_chip sym_dev_table[] = {
  {PCI_DEVICE_ID_NCR_53C810, 0x0f, "810", 4, 8, 4, 64,
  FE_ERL}
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 24/28] fix for bugzilla 8426: massive slowdown on SCSI CD/DVD drive connected to mptspi driver

2007-05-10 Thread akpm
From: Doug Chapman <[EMAIL PROTECTED]>

Patch for: http://bugzilla.kernel.org/show_bug.cgi?id=8426

A recent code cleanup that moved code from mptscsih to mptspi inadvertently
change the order some code was called.  This caused a massive slowdown (of
150x to 300x) on the CD/DVD drive on the high-end HP Integrity servers.

Signed-off-by: Doug Chapman <[EMAIL PROTECTED]>
Cc: "Moore, Eric Dean" <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/message/fusion/mptspi.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff -puN 
drivers/message/fusion/mptspi.c~fix-for-bugzilla-8426-massive-slowdown-on-scsi-cd-dvd-drive-connected-to-mptspi-driver
 drivers/message/fusion/mptspi.c
--- 
a/drivers/message/fusion/mptspi.c~fix-for-bugzilla-8426-massive-slowdown-on-scsi-cd-dvd-drive-connected-to-mptspi-driver
+++ a/drivers/message/fusion/mptspi.c
@@ -727,13 +727,15 @@ static int mptspi_slave_configure(struct
struct _MPT_SCSI_HOST *hd =
(struct _MPT_SCSI_HOST *)sdev->host->hostdata;
VirtTarget *vtarget = scsi_target(sdev)->hostdata;
-   int ret = mptscsih_slave_configure(sdev);
+   int ret;
+
+   mptspi_initTarget(hd, vtarget, sdev);
+
+   ret = mptscsih_slave_configure(sdev);
 
if (ret)
return ret;
 
-   mptspi_initTarget(hd, vtarget, sdev);
-
ddvprintk((MYIOC_s_INFO_FMT "id=%d min_period=0x%02x"
" max_offset=0x%02x max_width=%d\n", hd->ioc->name,
sdev->id, spi_min_period(scsi_target(sdev)),
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 23/28] drivers/scsi/aic7xxx_old.c: remove redundant GFP_ATOMIC from kmalloc

2007-05-10 Thread akpm
From: Satyam Sharma <[EMAIL PROTECTED]>

drivers/scsi/aic7xxx_old.c:aic7xxx_slave_alloc() unnecessarily passes
GFP_ATOMIC (along with GFP_KERNEL) to kmalloc() from a context that is not
atomic. Remove the pointless GFP_ATOMIC.

Signed-off-by: Satyam Sharma <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/aic7xxx_old.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
drivers/scsi/aic7xxx_old.c~drivers-scsi-aic7xxx_oldc-remove-redundant-gfp_atomic-from-kmalloc
 drivers/scsi/aic7xxx_old.c
--- 
a/drivers/scsi/aic7xxx_old.c~drivers-scsi-aic7xxx_oldc-remove-redundant-gfp_atomic-from-kmalloc
+++ a/drivers/scsi/aic7xxx_old.c
@@ -6581,7 +6581,7 @@ aic7xxx_slave_alloc(struct scsi_device *
   struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr->host->hostdata;
   struct aic_dev_data *aic_dev;
 
-  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC | GFP_KERNEL);
+  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_KERNEL);
   if(!aic_dev)
 return 1;
   /*
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 20/28] drivers/scsi/ips.c: remove kernel 2.4 code

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/ips.c |  145 +--
 drivers/scsi/ips.h |   44 -
 2 files changed, 20 insertions(+), 169 deletions(-)

diff -puN drivers/scsi/ips.c~drivers-scsi-ipsc-remove-kernel-24-code 
drivers/scsi/ips.c
--- a/drivers/scsi/ips.c~drivers-scsi-ipsc-remove-kernel-24-code
+++ a/drivers/scsi/ips.c
@@ -211,19 +211,6 @@ module_param(ips, charp, 0);
 #warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
 #endif
 
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
-#include 
-#include "sd.h"
-#define IPS_LOCK_SAVE(lock,flags) spin_lock_irqsave(&io_request_lock,flags)
-#define IPS_UNLOCK_RESTORE(lock,flags) 
spin_unlock_irqrestore(&io_request_lock,flags)
-#ifndef __devexit_p
-#define __devexit_p(x) x
-#endif
-#else
-#define IPS_LOCK_SAVE(lock,flags) do{spin_lock(lock);(void)flags;}while(0)
-#define IPS_UNLOCK_RESTORE(lock,flags) 
do{spin_unlock(lock);(void)flags;}while(0)
-#endif
-
 #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || 
\
  DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
  PCI_DMA_BIDIRECTIONAL : \
@@ -381,24 +368,13 @@ static struct scsi_host_template ips_dri
.eh_abort_handler   = ips_eh_abort,
.eh_host_reset_handler  = ips_eh_reset,
.proc_name  = "ips",
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
.proc_info  = ips_proc_info,
.slave_configure= ips_slave_configure,
-#else
-   .proc_info  = ips_proc24_info,
-   .select_queue_depths= ips_select_queue_depth,
-#endif
.bios_param = ips_biosparam,
.this_id= -1,
.sg_tablesize   = IPS_MAX_SG,
.cmd_per_lun= 3,
.use_clustering = ENABLE_CLUSTERING,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-   .use_new_eh_code= 1,
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)  &&  LINUX_VERSION_CODE < 
KERNEL_VERSION(2,5,0)
-.highmem_io  = 1,   
-#endif
 };
 
 
@@ -731,7 +707,7 @@ ips_release(struct Scsi_Host *sh)
/* free IRQ */
free_irq(ha->irq, ha);
 
-   IPS_REMOVE_HOST(sh);
+   scsi_remove_host(sh);
scsi_host_put(sh);
 
ips_released_controllers++;
@@ -813,7 +789,6 @@ int ips_eh_abort(struct scsi_cmnd *SC)
ips_ha_t *ha;
ips_copp_wait_item_t *item;
int ret;
-   unsigned long cpu_flags;
struct Scsi_Host *host;
 
METHOD_TRACE("ips_eh_abort", 1);
@@ -830,7 +805,7 @@ int ips_eh_abort(struct scsi_cmnd *SC)
if (!ha->active)
return (FAILED);
 
-   IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+   spin_lock(host->host_lock);
 
/* See if the command is on the copp queue */
item = ha->copp_waitlist.head;
@@ -851,7 +826,7 @@ int ips_eh_abort(struct scsi_cmnd *SC)
ret = (FAILED);
}
 
-   IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+   spin_unlock(host->host_lock);
return ret;
 }
 
@@ -1176,18 +1151,10 @@ static int ips_queue(struct scsi_cmnd *S
 /*   Set bios geometry for the controller   */
 /*  */
 //
-static int
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-ips_biosparam(Disk * disk, kdev_t dev, int geom[])
-{
-   ips_ha_t *ha = (ips_ha_t *) disk->device->host->hostdata;
-   unsigned long capacity = disk->capacity;
-#else
-ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
- sector_t capacity, int geom[])
+static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+sector_t capacity, int geom[])
 {
ips_ha_t *ha = (ips_ha_t *) sdev->host->hostdata;
-#endif
int heads;
int sectors;
int cylinders;
@@ -1225,70 +1192,6 @@ ips_biosparam(struct scsi_device *sdev, 
return (0);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-
-/* ips_proc24_info is a wrapper around ips_proc_info *
- * for compatibility with the 2.4 scsi parameters*/
-static int
-ips_proc24_info(char *buffer, char **start, off_t offset, int length,
- int hostno, int func)
-{
-   int i;
-
-   for (i = 0; i < ips_next_controller; i++) {
-   if (ips_sh[i] && ips_sh[i]->host_no == hostno) {
-   return ips_proc_info(ips_sh[i], buffer, start,
-offset, length, func);
-   }
-   }
-   return -EINVAL; 
-}
-
-/**

[patch 22/28] drivers/message/i2o/device.c: remove redundant GFP_ATOMIC from kmalloc

2007-05-10 Thread akpm
From: Satyam Sharma <[EMAIL PROTECTED]>

drivers/message/i2o/device.c:i2o_parm_field_get() unnecessarily passes
GFP_ATOMIC (along with GFP_KERNEL) to kmalloc() from a context that is not
atomic. Remove the pointless GFP_ATOMIC.

Signed-off-by: Satyam Sharma <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/message/i2o/device.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
drivers/message/i2o/device.c~drivers-message-i2o-devicec-remove-redundant-gfp_atomic-from-kmalloc
 drivers/message/i2o/device.c
--- 
a/drivers/message/i2o/device.c~drivers-message-i2o-devicec-remove-redundant-gfp_atomic-from-kmalloc
+++ a/drivers/message/i2o/device.c
@@ -485,7 +485,7 @@ int i2o_parm_field_get(struct i2o_device
u8 *resblk; /* 8 bytes for header */
int rc;
 
-   resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC);
+   resblk = kmalloc(buflen + 8, GFP_KERNEL);
if (!resblk)
return -ENOMEM;
 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 21/28] drivers/scsi/nsp32.c: remove kernel 2.4 code

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Acked-by: GOTO Masanori <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/nsp32.c |  109 -
 1 file changed, 13 insertions(+), 96 deletions(-)

diff -puN drivers/scsi/nsp32.c~drivers-scsi-nsp32c-remove-kernel-24-code 
drivers/scsi/nsp32.c
--- a/drivers/scsi/nsp32.c~drivers-scsi-nsp32c-remove-kernel-24-code
+++ a/drivers/scsi/nsp32.c
@@ -49,10 +49,6 @@
 #include 
 #include 
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
-# include 
-#endif
-
 #include "nsp32.h"
 
 
@@ -199,17 +195,9 @@ static int  __initinit_nsp32  (void)
 static void __exitexit_nsp32  (void);
 
 /* struct struct scsi_host_template */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
 static int nsp32_proc_info   (struct Scsi_Host *, char *, char **, 
off_t, int, int);
-#else
-static int nsp32_proc_info   (char *, char **, off_t, int, int, int);
-#endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
 static int nsp32_detect  (struct pci_dev *pdev);
-#else
-static int nsp32_detect  (struct scsi_host_template *);
-#endif
 static int nsp32_queuecommand(struct scsi_cmnd *,
void (*done)(struct scsi_cmnd *));
 static const char *nsp32_info(struct Scsi_Host *);
@@ -296,15 +284,7 @@ static struct scsi_host_template nsp32_t
.eh_abort_handler   = nsp32_eh_abort,
.eh_bus_reset_handler   = nsp32_eh_bus_reset,
.eh_host_reset_handler  = nsp32_eh_host_reset,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74))
-   .detect = nsp32_detect,
-   .release= nsp32_release,
-#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,2))
-   .use_new_eh_code= 1,
-#else
 /* .highmem_io = 1, */
-#endif
 };
 
 #include "nsp32_io.h"
@@ -1210,13 +1190,9 @@ static irqreturn_t do_nsp32_isr(int irq,
unsigned long flags;
int ret;
int handled = 0;
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
struct Scsi_Host *host = data->Host;
+
spin_lock_irqsave(host->host_lock, flags);
-#else
-   spin_lock_irqsave(&io_request_lock, flags);
-#endif
 
/*
 * IRQ check, then enable IRQ mask
@@ -1480,11 +1456,7 @@ static irqreturn_t do_nsp32_isr(int irq,
nsp32_write2(base, IRQ_CONTROL, 0);
 
  out2:
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
spin_unlock_irqrestore(host->host_lock, flags);
-#else
-   spin_unlock_irqrestore(&io_request_lock, flags);
-#endif
 
nsp32_dbg(NSP32_DEBUG_INTR, "exit");
 
@@ -1499,28 +1471,15 @@ static irqreturn_t do_nsp32_isr(int irq,
nsp32_dbg(NSP32_DEBUG_PROC, "buffer=0x%p pos=0x%p 
length=%d %d\n", buffer, pos, length,  length - (pos - buffer));\
} \
} while(0)
-static int nsp32_proc_info(
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 
-   struct Scsi_Host *host,
-#endif
-   char *buffer,
-   char**start,
-   off_t offset,
-   int   length,
-#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 
-   int   hostno,
-#endif
-   int   inout)
+
+static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start,
+  off_t offset, int length, int inout)
 {
char *pos = buffer;
int   thislength;
unsigned long flags;
nsp32_hw_data*data;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 
int   hostno;
-#else
-   struct Scsi_Host *host;
-#endif
unsigned int  base;
unsigned char mode_reg;
int   id, speed;
@@ -1531,15 +1490,7 @@ static int nsp32_proc_info(
return -EINVAL;
}
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 
hostno = host->host_no;
-#else
-   /* search this HBA host */
-   host = scsi_host_hn_get(hostno);
-   if (host == NULL) {
-   return -ESRCH;
-   }
-#endif
data = (nsp32_hw_data *)host->hostdata;
base = host->io_port;
 
@@ -2674,17 +2625,7 @@ static void nsp32_sack_negate(nsp32_hw_d
  * 0x900-0xbff: (map same 0x800-0x8ff I/O port image repeatedly)
  * 0xc00-0xfff: CardBus status registers
  */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
-#define DETECT_OK 0
-#define DETECT_NG 1
-#define PCIDEVpdev
 static int nsp32_detect(struct pci_dev *pdev)
-#else
-#define DETECT_OK 1
-#define DETECT_NG 0
-#define PCIDEV(data->Pci)
-static int nsp32_detect(struct scsi_host_template *sht)
-#endif
 {
struct Scsi_Host *host; /* registered host structure */
struct resource  *res;
@@ -2697,11 +2638,7 @@ static int nsp32_detect(struct scsi_host
/*

[patch 11/28] Use unchecked_isa_dma in sd_revalidate_disk()

2007-05-10 Thread akpm
From: Bernhard Walle <[EMAIL PROTECTED]>

In sd_revalidate_disk(), the SCSI Disk driver needs a few bytes DMA memory,
allocated by kmalloc() and __GFP_DMA.  This patch uses __GFP_DMA only if
the corresponding host structure has unchecked_isa_dma set.

Signed-off-by: Bernhard Walle <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Acked-by: Jens Axboe <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff -puN drivers/scsi/sd.c~use-unchecked_isa_dma-in-sd_revalidate_disk 
drivers/scsi/sd.c
--- a/drivers/scsi/sd.c~use-unchecked_isa_dma-in-sd_revalidate_disk
+++ a/drivers/scsi/sd.c
@@ -1515,7 +1515,8 @@ static int sd_revalidate_disk(struct gen
if (!scsi_device_online(sdp))
goto out;
 
-   buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA);
+   buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL |
+   (sdp->host->unchecked_isa_dma ? __GFP_DMA : 0));
if (!buffer) {
sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory "
  "allocation failure.\n");
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 19/28] drivers/scsi/pcmcia/nsp_cs.c: remove kernel 2.4 code

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/pcmcia/nsp_cs.c |  159 +
 drivers/scsi/pcmcia/nsp_cs.h |8 -
 2 files changed, 5 insertions(+), 162 deletions(-)

diff -puN 
drivers/scsi/pcmcia/nsp_cs.c~drivers-scsi-pcmcia-nsp_csc-remove-kernel-24-code 
drivers/scsi/pcmcia/nsp_cs.c
--- 
a/drivers/scsi/pcmcia/nsp_cs.c~drivers-scsi-pcmcia-nsp_csc-remove-kernel-24-code
+++ a/drivers/scsi/pcmcia/nsp_cs.c
@@ -25,8 +25,6 @@
 
 ***/
 
-/* $Id: nsp_cs.c,v 1.23 2003/08/18 11:09:19 elca Exp $ */
-
 #include 
 #include 
 #include 
@@ -59,7 +57,7 @@
 #include "nsp_cs.h"
 
 MODULE_AUTHOR("YOKOTA Hiroshi <[EMAIL PROTECTED]>");
-MODULE_DESCRIPTION("WorkBit NinjaSCSI-3 / NinjaSCSI-32Bi(16bit) PCMCIA SCSI 
host adapter module $Revision: 1.23 $");
+MODULE_DESCRIPTION("WorkBit NinjaSCSI-3 / NinjaSCSI-32Bi(16bit) PCMCIA SCSI 
host adapter module");
 MODULE_SUPPORTED_DEVICE("sd,sr,sg,st");
 #ifdef MODULE_LICENSE
 MODULE_LICENSE("GPL");
@@ -83,10 +81,6 @@ static struct scsi_host_template nsp_dri
.proc_name   = "nsp_cs",
.proc_info   = nsp_proc_info,
.name= "WorkBit NinjaSCSI-3/32Bi(16bit)",
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-   .detect  = nsp_detect_old,
-   .release = nsp_release_old,
-#endif
.info= nsp_info,
.queuecommand= nsp_queuecommand,
 /* .eh_abort_handler= nsp_eh_abort,*/
@@ -97,9 +91,6 @@ static struct scsi_host_template nsp_dri
.sg_tablesize= SG_ALL,
.cmd_per_lun = 1,
.use_clustering  = DISABLE_CLUSTERING,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,2))
-   .use_new_eh_code = 1,
-#endif
 };
 
 static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
@@ -1313,11 +1304,7 @@ static struct Scsi_Host *nsp_detect(stru
nsp_hw_data *data_b = &nsp_data_base, *data;
 
nsp_dbg(NSP_DEBUG_INIT, "this_id=%d", sht->this_id);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
host = scsi_host_alloc(&nsp_driver_template, sizeof(nsp_hw_data));
-#else
-   host = scsi_register(sht, sizeof(nsp_hw_data));
-#endif
if (host == NULL) {
nsp_dbg(NSP_DEBUG_INIT, "host failed");
return NULL;
@@ -1354,37 +1341,6 @@ static struct Scsi_Host *nsp_detect(stru
return host; /* detect done. */
 }
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-static int nsp_detect_old(struct scsi_host_template *sht)
-{
-   if (nsp_detect(sht) == NULL) {
-   return 0;
-   } else {
-   //MOD_INC_USE_COUNT;
-   return 1;
-   }
-}
-
-
-static int nsp_release_old(struct Scsi_Host *shpnt)
-{
-   //nsp_hw_data *data = (nsp_hw_data *)shpnt->hostdata;
-
-   /* PCMCIA Card Service dose same things below. */
-   /* So we do nothing.   */
-   //if (shpnt->irq) {
-   //  free_irq(shpnt->irq, data->ScsiInfo);
-   //}
-   //if (shpnt->io_port) {
-   //  release_region(shpnt->io_port, shpnt->n_io_port);
-   //}
-
-   //MOD_DEC_USE_COUNT;
-
-   return 0;
-}
-#endif
-
 /**/
 /* return info string*/
 /**/
@@ -1403,19 +1359,9 @@ static const char *nsp_info(struct Scsi_
nsp_dbg(NSP_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d 
%d\n", buffer, pos, length,  length - (pos - buffer));\
} \
} while(0)
-static int
-nsp_proc_info(
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
-   struct Scsi_Host *host,
-#endif
-   char  *buffer,
-   char **start,
-   off_t  offset,
-   intlength,
-#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
-   inthostno,
-#endif
-   intinout)
+
+static int nsp_proc_info(struct Scsi_Host *host, char *buffer, char **start,
+off_t offset, int length, int inout)
 {
int id;
char *pos = buffer;
@@ -1423,24 +1369,13 @@ nsp_proc_info(
int speed;
unsigned long flags;
nsp_hw_data *data;
-#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
-   struct Scsi_Host *host;
-#else
int hostno;
-#endif
+
if (inout) {
return -EINVAL;
}
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
hostno = host->host_no;
-#else
-   /* search this HBA host */
-   host = scsi_host_hn_get(hostno);
-   if (host == NULL) {
-   return -ESRCH;
-   }
-#endif
data = (nsp_hw_data *)host->hostdata;
 
 
@@ -1676,10 +1611,6 @@ static int nsp_cs_co

[patch 26/28] scsi: fix ambiguous gdthtable definition

2007-05-10 Thread akpm
From: David Rientjes <[EMAIL PROTECTED]>

Labeling a variable as __attribute_used__ is ambiguous: it means
__attribute__((unused)) for gcc <3.4 and __attribute__((used)) for gcc >=3.4. 
There is no such thing as labeling a variable as __attribute__((used)).  We
assume that we're simply suppressing a warning here if gdthtable[] is declared
but unreferenced.

Cc: Achim Leubner <[EMAIL PROTECTED]>
Signed-off-by: David Rientjes <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/gdth.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/gdth.c~scsi-fix-ambiguous-gdthtable-definition 
drivers/scsi/gdth.c
--- a/drivers/scsi/gdth.c~scsi-fix-ambiguous-gdthtable-definition
+++ a/drivers/scsi/gdth.c
@@ -876,7 +876,7 @@ static int __init gdth_search_pci(gdth_p
 /* Vortex only makes RAID controllers.
  * We do not really want to specify all 550 ids here, so wildcard match.
  */
-static struct pci_device_id gdthtable[] __attribute_used__ = {
+static struct pci_device_id gdthtable[] __maybe_unused = {
 {PCI_VENDOR_ID_VORTEX,PCI_ANY_ID,PCI_ANY_ID, PCI_ANY_ID},
 {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC,PCI_ANY_ID,PCI_ANY_ID}, 
 
{PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC_XSCALE,PCI_ANY_ID,PCI_ANY_ID}, 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 18/28] scsi/lpfc/lpfc_init.c: remove unused variable

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/lpfc/lpfc_init.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
drivers/scsi/lpfc/lpfc_init.c~scsi-lpfc-lpfc_initc-remove-unused-variable 
drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c~scsi-lpfc-lpfc_initc-remove-unused-variable
+++ a/drivers/scsi/lpfc/lpfc_init.c
@@ -1512,7 +1512,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev,
struct lpfc_sli  *psli;
struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL;
unsigned long bar0map_len, bar2map_len;
-   int error = -ENODEV, retval;
+   int error = -ENODEV;
int i;
uint16_t iotag;
 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 27/28] Use menuconfig objects II - SCSI

2007-05-10 Thread akpm
From: Jan Engelhardt <[EMAIL PROTECTED]>

Make a "menuconfig" out of the Kconfig objects "menu, ..., endmenu",
so that the user can disable all the options in that menu at once
instead of having to disable each option separately.

Signed-off-by: Jan Engelhardt <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/Kconfig|8 ++--
 drivers/scsi/pcmcia/Kconfig |8 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff -puN drivers/scsi/Kconfig~use-menuconfig-objects-ii-scsi 
drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig~use-menuconfig-objects-ii-scsi
+++ a/drivers/scsi/Kconfig
@@ -285,8 +285,12 @@ source "drivers/scsi/libsas/Kconfig"
 
 endmenu
 
-menu "SCSI low-level drivers"
+menuconfig SCSI_LOWLEVEL
+   bool "SCSI low-level drivers"
depends on SCSI!=n
+   default y
+
+if SCSI_LOWLEVEL
 
 config ISCSI_TCP
tristate "iSCSI Initiator over TCP/IP"
@@ -1795,7 +1799,7 @@ config SCSI_SRP
  To compile this driver as a module, choose M here: the
  module will be called libsrp.
 
-endmenu
+endif # SCSI_LOWLEVEL
 
 source "drivers/scsi/pcmcia/Kconfig"
 
diff -puN drivers/scsi/pcmcia/Kconfig~use-menuconfig-objects-ii-scsi 
drivers/scsi/pcmcia/Kconfig
--- a/drivers/scsi/pcmcia/Kconfig~use-menuconfig-objects-ii-scsi
+++ a/drivers/scsi/pcmcia/Kconfig
@@ -2,8 +2,12 @@
 # PCMCIA SCSI adapter configuration
 #
 
-menu "PCMCIA SCSI adapter support"
+menuconfig SCSI_LOWLEVEL_PCMCIA
+   bool "PCMCIA SCSI adapter support"
depends on SCSI!=n && PCMCIA!=n
+   default y
+
+if SCSI_LOWLEVEL_PCMCIA
 
 config PCMCIA_AHA152X
tristate "Adaptec AHA152X PCMCIA support"
@@ -77,4 +81,4 @@ config PCMCIA_SYM53C500
  To compile this driver as a module, choose M here: the
  module will be called sym53c500_cs.
 
-endmenu
+endif # SCSI_LOWLEVEL_PCMCIA
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 12/28] fdomain.c: get rid of unused stuff

2007-05-10 Thread akpm
From: Parag Warudkar <[EMAIL PROTECTED]>

fdomain.c uses the below stuff only if PCMCIA is not defined.  This causes
unused variables to be defined when PCMCIA is not defined.  Wrap variables
and functions around #ifndef PCMCIA appropriately to avoid this.

4 less compiler warnings.

Signed-off-by: Parag Warudkar <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/fdomain.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff -puN drivers/scsi/fdomain.c~fdomainc-get-rid-of-unused-stuff 
drivers/scsi/fdomain.c
--- a/drivers/scsi/fdomain.c~fdomainc-get-rid-of-unused-stuff
+++ a/drivers/scsi/fdomain.c
@@ -410,6 +410,7 @@ static irqreturn_t   do_fdomain_16x0
 static char * fdomain = NULL;
 module_param(fdomain, charp, 0);
 
+#ifndef PCMCIA
 static unsigned long addresses[] = {
0xc8000,
0xca000,
@@ -502,6 +503,7 @@ static struct signature {
 };
 
 #define SIGNATURE_COUNT ARRAY_SIZE(signatures)
+#endif /* ifndef PCMCIA */
 
 static void print_banner( struct Scsi_Host *shpnt )
 {
@@ -646,7 +648,7 @@ static int fdomain_test_loopback( void )
Sometimes it is possible to use the computer's BIOS setup screen to
configure a PCI system so that one of these IRQs will be used by the
Future Domain card. */
-
+#ifndef PCMCIA
 static int fdomain_get_irq( int base )
 {
int options = inb(base + Configuration1);
@@ -664,6 +666,7 @@ static int fdomain_get_irq( int base )
return 0;
return ints[(options & 0x0e) >> 1];
 }
+#endif
 
 static int fdomain_isa_detect( int *irq, int *iobase )
 {
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 17/28] SCSI: use irq_handler_t where appropriate

2007-05-10 Thread akpm
From: Jeff Garzik <[EMAIL PROTECTED]>

Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/aacraid/aacraid.h |2 +-
 drivers/scsi/qla2xxx/qla_isr.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -puN 
drivers/scsi/aacraid/aacraid.h~scsi-use-irq_handler_t-where-appropriate 
drivers/scsi/aacraid/aacraid.h
--- a/drivers/scsi/aacraid/aacraid.h~scsi-use-irq_handler_t-where-appropriate
+++ a/drivers/scsi/aacraid/aacraid.h
@@ -464,7 +464,7 @@ struct adapter_ops
int  (*adapter_restart)(struct aac_dev *dev, int bled);
/* Transport operations */
int  (*adapter_ioremap)(struct aac_dev * dev, u32 size);
-   irqreturn_t (*adapter_intr)(int irq, void *dev_id);
+   irq_handler_t adapter_intr;
/* Packet operations */
int  (*adapter_deliver)(struct fib * fib);
int  (*adapter_bounds)(struct aac_dev * dev, struct scsi_cmnd * cmd, 
u64 lba);
diff -puN 
drivers/scsi/qla2xxx/qla_isr.c~scsi-use-irq_handler_t-where-appropriate 
drivers/scsi/qla2xxx/qla_isr.c
--- a/drivers/scsi/qla2xxx/qla_isr.c~scsi-use-irq_handler_t-where-appropriate
+++ a/drivers/scsi/qla2xxx/qla_isr.c
@@ -1633,7 +1633,7 @@ struct qla_init_msix_entry {
uint16_t entry;
uint16_t index;
const char *name;
-   irqreturn_t (*handler)(int, void *);
+   irq_handler_t handler;
 };
 
 static struct qla_init_msix_entry imsix_entries[QLA_MSIX_ENTRIES] = {
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 28/28] Update Maintainer email-id for MegaRAID SCSI drivers

2007-05-10 Thread akpm
From: Sumant Patro <[EMAIL PROTECTED]>

Update Maintainer email-id for MegaRAID SCSI drivers.

Signed-off-by: Sumant Patro <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 MAINTAINERS |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN MAINTAINERS~update-maintainer-email-id-for-megaraid-scsi-drivers 
MAINTAINERS
--- a/MAINTAINERS~update-maintainer-email-id-for-megaraid-scsi-drivers
+++ a/MAINTAINERS
@@ -2335,7 +2335,7 @@ S:Maintained
 
 MEGARAID SCSI DRIVERS
 P: Neela Syam Kolli
-M: [EMAIL PROTECTED]
+M: [EMAIL PROTECTED]
 S: linux-scsi@vger.kernel.org
 W: http://megaraid.lsilogic.com
 S: Maintained
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 25/28] Fix old SCSI adapter crashes with CD-ROM (take 2)

2007-05-10 Thread akpm
From: Alan Cox <[EMAIL PROTECTED]>

The CD-ROM layer doesn't bounce requests for old ISA controllers (and nor
should it).  However they get injected into the SCSI layer via sr_ioctl
which also doesn't bounce them and SCSI then passes the buffer along to a
device with unchecked_isa_dma set which either panics or truncates the
buffer to 24bits.

According to Jens the right long term fix is for the CD layer to route the
requests differently but in the mean time this has been tested by a victim
and verified to sort the problem out.  For the other 99.9% of users it's a
no-op and doesn't bounce data.

(akpm: placeholder fix.  Apparently the metaphorical Mike is working on a real
fix).

Signed-off-by: Alan Cox <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sr_ioctl.c |   25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff -puN 
drivers/scsi/sr_ioctl.c~fix-old-scsi-adapter-crashes-with-cd-rom-take-2 
drivers/scsi/sr_ioctl.c
--- a/drivers/scsi/sr_ioctl.c~fix-old-scsi-adapter-crashes-with-cd-rom-take-2
+++ a/drivers/scsi/sr_ioctl.c
@@ -187,6 +187,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct pack
struct scsi_sense_hdr sshdr;
int result, err = 0, retries = 0;
struct request_sense *sense = cgc->sense;
+   void *zebedee = cgc->buffer;
 
SDev = cd->device;
 
@@ -198,6 +199,21 @@ int sr_do_ioctl(Scsi_CD *cd, struct pack
}
}
 
+   if (cgc->buflen && cd->device->host->unchecked_isa_dma) {
+   switch(cgc->data_direction) {
+   case DMA_NONE:
+   break;
+   case DMA_FROM_DEVICE:
+   case DMA_TO_DEVICE:
+   zebedee = kmalloc(cgc->buflen, 
GFP_KERNEL|GFP_DMA);
+   if (zebedee ==NULL) {
+   err = -ENOMEM;
+   goto out;
+   }
+   }
+   if (cgc->data_direction == DMA_TO_DEVICE)
+   memcpy(zebedee, cgc->buffer, cgc->buflen);
+   }
   retry:
if (!scsi_block_when_processing_errors(SDev)) {
err = -ENODEV;
@@ -206,11 +222,16 @@ int sr_do_ioctl(Scsi_CD *cd, struct pack
 
memset(sense, 0, sizeof(*sense));
result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
- cgc->buffer, cgc->buflen, (char *)sense,
+ zebedee, cgc->buflen, (char *)sense,
  cgc->timeout, IOCTL_RETRIES, 0);
 
scsi_normalize_sense((char *)sense, sizeof(*sense), &sshdr);
 
+   if (zebedee != cgc->buffer) {
+   if (cgc->data_direction == DMA_FROM_DEVICE)
+   memcpy(cgc->buffer, zebedee, cgc->buflen);
+   }
+
/* Minimal error checking.  Ignore cases we know about, and report the 
rest. */
if (driver_byte(result) != 0) {
switch (sshdr.sense_key) {
@@ -266,6 +287,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct pack
 
/* Wake up a process waiting for device */
   out:
+   if (zebedee != cgc->buffer)
+   kfree(zebedee); /* Time for bed */
if (!cgc->sense)
kfree(sense);
cgc->stat = err;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 05/28] sym53c8xx_2 claims cpqarray device

2007-05-10 Thread akpm
From: Chip Coldwell <[EMAIL PROTECTED]>

Apropos this thread

http://marc.theaimsgroup.com/?l=linux-scsi&m=115591706804045&w=2

which led to this patch

http://www.kernel.org/git/?p=linux/kernel/git/jejb/scsi-rc-fixes-2.6.git;a=commit;h=b2b3c121076961333977f485f0d54c22121df920

do we not also need the following patch, nine lines lower in the same file?

Signed-off-by: Chip Coldwell <[EMAIL PROTECTED]>
Cc: Matthew Wilcox <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sym53c8xx_2/sym_glue.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
drivers/scsi/sym53c8xx_2/sym_glue.c~sym53c8xx_2-claims-cpqarray-device 
drivers/scsi/sym53c8xx_2/sym_glue.c
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c~sym53c8xx_2-claims-cpqarray-device
+++ a/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2094,7 +2094,7 @@ static struct pci_device_id sym2_id_tabl
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C875,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C1510,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, /* new */
+ PCI_ANY_ID, PCI_ANY_ID,  PCI_CLASS_STORAGE_SCSI<<8,  0x00, 0UL }, 
/* new */
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C895A,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C875A,
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 10/28] Fix |/|| confusion in fusion driver

2007-05-10 Thread akpm
From: Dirk Mueller <[EMAIL PROTECTED]>

This patch corrects a |/|| confusion in mptscsih_copy_sense_data.  Using ||
means that the data that ends up being written is (almost always) 1,
instead of being bit-wise or'ed.

Cc: Eric Moore <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/message/fusion/mptscsih.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN drivers/message/fusion/mptscsih.c~fix--confusion-in-fusion-driver 
drivers/message/fusion/mptscsih.c
--- a/drivers/message/fusion/mptscsih.c~fix--confusion-in-fusion-driver
+++ a/drivers/message/fusion/mptscsih.c
@@ -2463,9 +2463,9 @@ mptscsih_copy_sense_data(struct scsi_cmn
ioc->events[idx].event = 
MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE;
ioc->events[idx].eventContext = 
ioc->eventContext;
 
-   ioc->events[idx].data[0] = (pReq->LUN[1] << 24) 
||
-   (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA 
<< 16) ||
-   (sc->device->channel << 8) || 
sc->device->id;
+   ioc->events[idx].data[0] = (pReq->LUN[1] << 24) 
|
+   (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA 
<< 16) |
+   (sc->device->channel << 8) | 
sc->device->id;
 
ioc->events[idx].data[1] = (sense_data[13] << 
8) || sense_data[12];
 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 08/28] make seagate_st0x_detect() static

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

seagate_st0x_detect() can become static.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/seagate.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/seagate.c~make-seagate_st0x_detect-static 
drivers/scsi/seagate.c
--- a/drivers/scsi/seagate.c~make-seagate_st0x_detect-static
+++ a/drivers/scsi/seagate.c
@@ -420,7 +420,7 @@ static inline void borken_wait (void)
 #define ULOOP( i ) for (clock = i*8;;)
 #define TIMEOUT (!(clock--))
 
-int __init seagate_st0x_detect (struct scsi_host_template * tpnt)
+static int __init seagate_st0x_detect (struct scsi_host_template * tpnt)
 {
struct Scsi_Host *instance;
int i, j;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 09/28] SCSI: Fix obvious typo "spin_lock_irqrestore()" in gdth.c

2007-05-10 Thread akpm
From: "Robert P. J. Day" <[EMAIL PROTECTED]>

Fix misspelled "spin_lock_irqrestore" to read "spin_unlock_irqrestore"
instead.

Presumably, GDTH_RTC doesn't get used a lot.

Signed-off-by: Robert P. J. Day <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/gdth.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
drivers/scsi/gdth.c~scsi-fix-obvious-typo-spin_lock_irqrestore-in-gdthc 
drivers/scsi/gdth.c
--- a/drivers/scsi/gdth.c~scsi-fix-obvious-typo-spin_lock_irqrestore-in-gdthc
+++ a/drivers/scsi/gdth.c
@@ -1955,7 +1955,7 @@ static int __init gdth_search_drives(int
 for (j = 0; j < 12; ++j) 
 rtc[j] = CMOS_READ(j);
 } while (rtc[0] != CMOS_READ(0));
-spin_lock_irqrestore(&rtc_lock, flags);
+spin_unlock_irqrestore(&rtc_lock, flags);
 TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32 *)&rtc[0],
 *(ulong32 *)&rtc[4], *(ulong32 *)&rtc[8]));
 /* 3. send to controller firmware */
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 04/28] drivers/scsi/NCR5380.c: Replacing yield() with a better alternative

2007-05-10 Thread akpm
From: Amol Lad <[EMAIL PROTECTED]>

Replaced yield() with cond_resched()

Signed-off-by: Amol Lad <[EMAIL PROTECTED]>
Acked-by: Alan Cox <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/NCR5380.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/NCR5380.c~drivers-scsi-ncr5380c-replacing-yield-with-a 
drivers/scsi/NCR5380.c
--- a/drivers/scsi/NCR5380.c~drivers-scsi-ncr5380c-replacing-yield-with-a
+++ a/drivers/scsi/NCR5380.c
@@ -347,7 +347,7 @@ static int NCR5380_poll_politely(struct 
if((r & bit) == val)
return 0;
if(!in_interrupt())
-   yield();
+   cond_resched();
else
cpu_relax();
}
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 07/28] scsi: cover up bugs^W^W^WFix up compiler warnings in megaraid driver

2007-05-10 Thread akpm
From: Martin Bligh <[EMAIL PROTECTED]>

Fix up compiler warnings in megaraid driver

[EMAIL PROTECTED]: build fix]
Signed-off-by: Martin J. Bligh <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/megaraid.c |   22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff -puN 
drivers/scsi/megaraid.c~scsi-cover-up-bugs-fix-up-compiler-warnings-in-megaraid-driver
 drivers/scsi/megaraid.c
--- 
a/drivers/scsi/megaraid.c~scsi-cover-up-bugs-fix-up-compiler-warnings-in-megaraid-driver
+++ a/drivers/scsi/megaraid.c
@@ -73,10 +73,14 @@ static unsigned short int max_mbox_busy_
 module_param(max_mbox_busy_wait, ushort, 0);
 MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds 
if busy (default=MBOX_BUSY_WAIT=10)");
 
-#define RDINDOOR(adapter)  readl((adapter)->mmio_base + 0x20)
-#define RDOUTDOOR(adapter) readl((adapter)->mmio_base + 0x2C)
-#define WRINDOOR(adapter,value) writel(value, (adapter)->mmio_base + 
0x20)
-#define WROUTDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x2C)
+#define RDINDOOR(adapter)  readl((volatile void __iomem *) \
+   (adapter)->base + 0x20)
+#define RDOUTDOOR(adapter) readl((volatile void __iomem *) \
+   (adapter)->base + 0x2C)
+#define WRINDOOR(adapter,value)writel(value, (volatile void 
__iomem *)\
+   (adapter)->base + 0x20)
+#define WROUTDOOR(adapter,value)   writel(value, (volatile void __iomem *)\
+   (adapter)->base + 0x2C)
 
 /*
  * Global variables
@@ -3571,7 +3575,7 @@ megadev_ioctl(struct inode *inode, struc
/*
 * The user passthru structure
 */
-   upthru = (mega_passthru __user *)MBOX(uioc)->xferaddr;
+   upthru = (mega_passthru __user *)(unsigned 
long)MBOX(uioc)->xferaddr;
 
/*
 * Copy in the user passthru here.
@@ -3623,7 +3627,7 @@ megadev_ioctl(struct inode *inode, struc
/*
 * Get the user data
 */
-   if( copy_from_user(data, (char __user 
*)uxferaddr,
+   if( copy_from_user(data, (char __user 
*)(unsigned long) uxferaddr,
pthru->dataxferlen) ) {
rval = (-EFAULT);
goto freemem_and_return;
@@ -3649,7 +3653,7 @@ megadev_ioctl(struct inode *inode, struc
 * Is data going up-stream
 */
if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) {
-   if( copy_to_user((char __user *)uxferaddr, data,
+   if( copy_to_user((char __user *)(unsigned long) 
uxferaddr, data,
pthru->dataxferlen) ) {
rval = (-EFAULT);
}
@@ -3702,7 +3706,7 @@ freemem_and_return:
/*
 * Get the user data
 */
-   if( copy_from_user(data, (char __user 
*)uxferaddr,
+   if( copy_from_user(data, (char __user 
*)(unsigned long) uxferaddr,
uioc.xferlen) ) {
 
pci_free_consistent(pdev,
@@ -3742,7 +3746,7 @@ freemem_and_return:
 * Is data going up-stream
 */
if( uioc.xferlen && (uioc.flags & UIOC_RD) ) {
-   if( copy_to_user((char __user *)uxferaddr, data,
+   if( copy_to_user((char __user *)(unsigned long) 
uxferaddr, data,
uioc.xferlen) ) {
 
rval = (-EFAULT);
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 14/28] scsi: fix CONFIG_SCSI_WAIT_SCAN=m

2007-05-10 Thread akpm
From: Hugh Dickins <[EMAIL PROTECTED]>

CONFIG_MODULES=y
CONFIG_SCSI=y
CONFIG_SCSI_SCAN_ASYNC=y
CONFIG_SCSI_WAIT_SCAN=m

2.6.21-rc5-mm2 VFS panics unable to find my root on /dev/sda2, but boots
okay if I change drivers/scsi/Kconfig to "default y" instead of "default m"
for SCSI_WAIT_SCAN.

Make sure there's a late_initcall to scsi_complete_async_scans when it's
built in, so a monolithic SCSI_SCAN_ASYNC kernel can rely on the scans
being completed before trying to mount root, even if they're slow.

[EMAIL PROTECTED]: build fixes]
Signed-off-by: Hugh Dickins <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
---
James sayeth "This isn't the right fix ...  this has to be invoked last in the
call sequence ...  I can't see another way of doing this except yet another
file added as a final component to the link."
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/scsi_scan.c |9 +
 1 file changed, 9 insertions(+)

diff -puN drivers/scsi/scsi_scan.c~scsi-fix-config_scsi_wait_scan=m 
drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c~scsi-fix-config_scsi_wait_scan=m
+++ a/drivers/scsi/scsi_scan.c
@@ -184,6 +184,15 @@ int scsi_complete_async_scans(void)
 /* Only exported for the benefit of scsi_wait_scan */
 EXPORT_SYMBOL_GPL(scsi_complete_async_scans);
 
+#ifndef MODULE
+/*
+ * For async scanning we need to wait for all the scans to complete before
+ * trying to mount the root fs.  Otherwise non-modular drivers may not be ready
+ * yet.
+ */
+late_initcall(scsi_complete_async_scans);
+#endif
+
 /**
  * scsi_unlock_floptical - unlock device via a special MODE SENSE command
  * @sdev:  scsi device to send command to
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 06/28] drivers/scsi/wd33c93.c: cleanups

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

- #include  for getting the prototypes of {dis,en}able_irq()

- make the needlessly global wd33c93_setup() static

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/wd33c93.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN drivers/scsi/wd33c93.c~drivers-scsi-wd33c93c-cleanups 
drivers/scsi/wd33c93.c
--- a/drivers/scsi/wd33c93.c~drivers-scsi-wd33c93c-cleanups
+++ a/drivers/scsi/wd33c93.c
@@ -89,6 +89,8 @@
 #include 
 #include 
 
+#include 
+
 #include "wd33c93.h"
 
 #define optimum_sx_per(hostdata) (hostdata)->sx_table[1].period_ns
@@ -1762,7 +1764,7 @@ static char setup_buffer[SETUP_BUFFER_SI
 static char setup_used[MAX_SETUP_ARGS];
 static int done_setup = 0;
 
-int
+static int
 wd33c93_setup(char *str)
 {
int i;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 03/28] scsi: remove unnecessary check in drivers/scsi/sg.c

2007-05-10 Thread akpm
From: Eric Sesterhenn <[EMAIL PROTECTED]>

coverity spotted this (cid #758).  All callers dereference sfp, so we dont
need this check.  In addition to this, we dereference it earlier in the
function.

Signed-off-by: Eric Sesterhenn <[EMAIL PROTECTED]>
Cc: Douglas Gilbert <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/sg.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/sg.c~remove-unnecessary-check-in-drivers-scsi-sgc 
drivers/scsi/sg.c
--- a/drivers/scsi/sg.c~remove-unnecessary-check-in-drivers-scsi-sgc
+++ a/drivers/scsi/sg.c
@@ -1842,7 +1842,7 @@ sg_build_indirect(Sg_scatter_hold * schp
int blk_size = buff_size;
struct page *p = NULL;
 
-   if ((blk_size < 0) || (!sfp))
+   if (blk_size < 0)
return -EFAULT;
if (0 == blk_size)
++blk_size; /* don't know why */
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 02/28] drivers/scsi/advansys.c: cleanups

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

- remove the unneeded advansys.h
- remove the unused advansys_setup()
- make needlessly global functions static

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/advansys.c |  101 +++---
 drivers/scsi/advansys.h |   36 -
 2 files changed, 8 insertions(+), 129 deletions(-)

diff -puN drivers/scsi/advansys.c~drivers-scsi-advansysc-cleanups 
drivers/scsi/advansys.c
--- a/drivers/scsi/advansys.c~drivers-scsi-advansysc-cleanups
+++ a/drivers/scsi/advansys.c
@@ -798,7 +798,6 @@
 #include 
 #include 
 #include 
-#include "advansys.h"
 #ifdef CONFIG_PCI
 #include 
 #endif /* CONFIG_PCI */
@@ -2014,7 +2013,7 @@ STATIC int   AscSgListToQueue(int);
 STATIC void  AscEnableIsaDma(uchar);
 #endif /* CONFIG_ISA */
 STATIC ASC_DCNT  AscGetMaxDmaCount(ushort);
-
+static const char *advansys_info(struct Scsi_Host *shp);
 
 /*
  * --- Adv Library Constants and Macros
@@ -3970,10 +3969,6 @@ STATIC ushort asc_bus[ASC_NUM_BUS] __ini
 ASC_IS_PCI,
 };
 
-/*
- * Used with the LILO 'advansys' option to eliminate or
- * limit I/O port probing at boot time, cf. advansys_setup().
- */
 STATIC int asc_iopflag = ASC_FALSE;
 STATIC int asc_ioport[ASC_NUM_IOPORT_PROBE] = { 0, 0, 0, 0 };
 
@@ -4055,10 +4050,6 @@ STATIC void asc_prt_hex(char *f,
 #endif /* ADVANSYS_DEBUG */
 
 
-/*
- * --- Linux 'struct scsi_host_template' and advansys_setup() Functions
- */
-
 #ifdef CONFIG_PROC_FS
 /*
  * advansys_proc_info() - /proc/scsi/advansys/[0-(ASC_NUM_BOARD_SUPPORTED-1)]
@@ -4080,7 +4071,7 @@ STATIC void asc_prt_hex(char *f,
  * if 'prtbuf' is too small it will not be overwritten. Instead the
  * user just won't get all the available statistics.
  */
-int
+static int
 advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
off_t offset, int length, int inout)
 {
@@ -4296,7 +4287,7 @@ advansys_proc_info(struct Scsi_Host *sho
  * it must not call SCSI mid-level functions including scsi_malloc()
  * and scsi_free().
  */
-int __init
+static int __init
 advansys_detect(struct scsi_host_template *tpnt)
 {
 static int  detect_called = ASC_FALSE;
@@ -5428,7 +5419,7 @@ advansys_detect(struct scsi_host_templat
  *
  * Release resources allocated for a single AdvanSys adapter.
  */
-int
+static int
 advansys_release(struct Scsi_Host *shp)
 {
 asc_board_t*boardp;
@@ -5475,7 +5466,7 @@ advansys_release(struct Scsi_Host *shp)
  * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  * otherwise the static 'info' array will be overrun.
  */
-const char *
+static const char *
 advansys_info(struct Scsi_Host *shp)
 {
 static char info[ASC_INFO_SIZE];
@@ -5568,7 +5559,7 @@ advansys_info(struct Scsi_Host *shp)
  * This function always returns 0. Command return status is saved
  * in the 'scp' result field.
  */
-int
+static int
 advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
 {
 struct Scsi_Host*shp;
@@ -5656,7 +5647,7 @@ advansys_queuecommand(struct scsi_cmnd *
  * sleeping is allowed and no locking other than for host structures is
  * required. Returns SUCCESS or FAILED.
  */
-int
+static int
 advansys_reset(struct scsi_cmnd *scp)
 {
 struct Scsi_Host *shp;
@@ -5841,7 +5832,7 @@ advansys_reset(struct scsi_cmnd *scp)
  * ip[1]: sectors
  * ip[2]: cylinders
  */
-int
+static int
 advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
sector_t capacity, int ip[])
 {
@@ -5875,82 +5866,6 @@ advansys_biosparam(struct scsi_device *s
 }
 
 /*
- * advansys_setup()
- *
- * This function is called from init/main.c at boot time.
- * It it passed LILO parameters that can be set from the
- * LILO command line or in /etc/lilo.conf.
- *
- * It is used by the AdvanSys driver to either disable I/O
- * port scanning or to limit scanning to 1 - 4 I/O ports.
- * Regardless of the option setting EISA and PCI boards
- * will still be searched for and detected. This option
- * only affects searching for ISA and VL boards.
- *
- * If ADVANSYS_DEBUG is defined the driver debug level may
- * be set using the 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port.
- *
- * Examples:
- * 1. Eliminate I/O port scanning:
- * boot: linux advansys=
- *   or
- * boot: linux advansys=0x0
- * 2. Limit I/O port scanning to one I/O port:
- *boot: linux advansys=0x110
- * 3. Limit I/O port scanning to four I/O ports:
- *boot: linux advansys=0x110,0x210,0x230,0x330
- * 4. If ADVANSYS_DEBUG, limit I/O port scanning to four I/O ports and
- *set the driver debug level to 2.
- *boot: linux advansys=0x110,0x210,0x230,0x330,0xdeb2
- *
- * ints[0] - number of arguments
- * ints[1] - first argument
- * ints[2] - second argument
- * ...
- */
-void __init
-advansys_setup(char *str, int *ints)
-{
-inti;
-
-if (asc_iopflag == ASC_TRUE) {
- 

[patch 01/28] drivers/scsi/: small cleanups

2007-05-10 Thread akpm
From: Adrian Bunk <[EMAIL PROTECTED]>

This patch contains the following cleanups:
- make needlessly global functions static
- every file should #include the headers containing the prototypes for
  it's global functions

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Cc: James Bottomley <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/scsi/scsi_sysctl.c   |1 +
 drivers/scsi/scsi_sysfs.c|3 ++-
 drivers/scsi/scsi_transport_fc.c |2 +-
 drivers/scsi/sr.c|2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff -puN drivers/scsi/scsi_sysctl.c~drivers-scsi-small-cleanups 
drivers/scsi/scsi_sysctl.c
--- a/drivers/scsi/scsi_sysctl.c~drivers-scsi-small-cleanups
+++ a/drivers/scsi/scsi_sysctl.c
@@ -9,6 +9,7 @@
 #include 
 
 #include "scsi_logging.h"
+#include "scsi_priv.h"
 
 
 static ctl_table scsi_table[] = {
diff -puN drivers/scsi/scsi_sysfs.c~drivers-scsi-small-cleanups 
drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c~drivers-scsi-small-cleanups
+++ a/drivers/scsi/scsi_sysfs.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "scsi_priv.h"
 #include "scsi_logging.h"
@@ -822,7 +823,7 @@ void scsi_remove_device(struct scsi_devi
 }
 EXPORT_SYMBOL(scsi_remove_device);
 
-void __scsi_remove_target(struct scsi_target *starget)
+static void __scsi_remove_target(struct scsi_target *starget)
 {
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
unsigned long flags;
diff -puN drivers/scsi/scsi_transport_fc.c~drivers-scsi-small-cleanups 
drivers/scsi/scsi_transport_fc.c
--- a/drivers/scsi/scsi_transport_fc.c~drivers-scsi-small-cleanups
+++ a/drivers/scsi/scsi_transport_fc.c
@@ -1803,7 +1803,7 @@ fc_rport_final_delete(struct work_struct
  * Notes:
  * This routine assumes no locks are held on entry.
  **/
-struct fc_rport *
+static struct fc_rport *
 fc_rport_create(struct Scsi_Host *shost, int channel,
struct fc_rport_identifiers  *ids)
 {
diff -puN drivers/scsi/sr.c~drivers-scsi-small-cleanups drivers/scsi/sr.c
--- a/drivers/scsi/sr.c~drivers-scsi-small-cleanups
+++ a/drivers/scsi/sr.c
@@ -175,7 +175,7 @@ static void scsi_cd_put(struct scsi_cd *
  * an inode for that to work, and we do not always have one.
  */
 
-int sr_media_change(struct cdrom_device_info *cdi, int slot)
+static int sr_media_change(struct cdrom_device_info *cdi, int slot)
 {
struct scsi_cd *cd = cdi->handle;
int retval;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean

2007-05-10 Thread Richard Knutsson
Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested with all(yes|mod|no)config on x86(|_64) & sparc(|64)
  got some warnings on some builds, none related to this patch
Diffed against Linus' git-tree.

 aic7xxx_old.c  |  326 ++---
 aic7xxx_old/aic7xxx_proc.c |2
 2 files changed, 161 insertions(+), 167 deletions(-)


diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index a988d5a..afa5ded 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -255,12 +255,6 @@
 #define ALL_LUNS -1
 #define MAX_TARGETS  16
 #define MAX_LUNS 8
-#ifndef TRUE
-#  define TRUE 1
-#endif
-#ifndef FALSE
-#  define FALSE 0
-#endif
 
 #if defined(__powerpc__) || defined(__i386__) || defined(__x86_64__)
 #  define MMAPIO
@@ -1382,7 +1376,7 @@ aic7xxx_setup(char *s)
 char *tok, *tok_end, *tok_end2;
 char tok_list[] = { '.', ',', '{', '}', '\0' };
 int i, instance = -1, device = -1;
-unsigned char done = FALSE;
+bool done = false;
 
 base = p;
 tok = base + n + 1;  /* Forward us just past the ':' */
@@ -1410,14 +1404,14 @@ aic7xxx_setup(char *s)
 case ',':
 case '.':
   if (instance == -1)
-done = TRUE;
+done = true;
   else if (device >= 0)
 device++;
   else if (instance >= 0)
 instance++;
   if ( (device >= MAX_TARGETS) || 
(instance >= ARRAY_SIZE(aic7xxx_tag_info)) )
-done = TRUE;
+done = true;
   tok++;
   if (!done)
   {
@@ -1425,10 +1419,10 @@ aic7xxx_setup(char *s)
   }
   break;
 case '\0':
-  done = TRUE;
+  done = true;
   break;
 default:
-  done = TRUE;
+  done = true;
   tok_end = strchr(tok, '\0');
   for(i=0; tok_list[i]; i++)
   {
@@ -1436,7 +1430,7 @@ aic7xxx_setup(char *s)
 if ( (tok_end2) && (tok_end2 < tok_end) )
 {
   tok_end = tok_end2;
-  done = FALSE;
+  done = false;
 }
   }
   if ( (instance >= 0) && (device >= 0) &&
@@ -1512,7 +1506,7 @@ pause_sequencer(struct aic7xxx_host *p)
  *   warrant an easy way to do it.
  *-F*/
 static void
-unpause_sequencer(struct aic7xxx_host *p, int unpause_always)
+unpause_sequencer(struct aic7xxx_host *p, bool unpause_always)
 {
   if (unpause_always ||
   ( !(aic_inb(p, INTSTAT) & (SCSIINT | SEQINT | BRKADRINT)) &&
@@ -1771,7 +1765,7 @@ aic7xxx_loadseq(struct aic7xxx_host *p)
   aic_outb(p, 0, SEQADDR0);
   aic_outb(p, 0, SEQADDR1);
   aic_outb(p, FASTMODE | FAILDIS, SEQCTL);
-  unpause_sequencer(p, TRUE);
+  unpause_sequencer(p, true);
   mdelay(1);
   pause_sequencer(p);
   aic_outb(p, FASTMODE, SEQCTL);
@@ -1820,7 +1814,7 @@ aic7xxx_print_sequencer(struct aic7xxx_host *p, int 
downloaded)
   aic_outb(p, 0, SEQADDR0);
   aic_outb(p, 0, SEQADDR1);
   aic_outb(p, FASTMODE | FAILDIS, SEQCTL);
-  unpause_sequencer(p, TRUE);
+  unpause_sequencer(p, true);
   mdelay(1);
   pause_sequencer(p);
   aic_outb(p, FASTMODE, SEQCTL);
@@ -1868,7 +1862,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned 
int *period,
   unsigned int maxsync, unsigned char *options)
 {
   struct aic7xxx_syncrate *syncrate;
-  int done = FALSE;
+  bool done = false;
 
   switch(*options)
   {
@@ -1924,7 +1918,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned 
int *period,
 case MSG_EXT_PPR_OPTION_DT_UNITS:
   if(!(syncrate->sxfr_ultra2 & AHC_SYNCRATE_CRC))
   {
-done = TRUE;
+done = true;
 /*
  * oops, we went too low for the CRC/DualEdge signalling, so
  * clear the options byte
@@ -1938,7 +1932,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned 
int *period,
   }
   else
   {
-done = TRUE;
+done = true;
 if(syncrate == &aic7xxx_syncrates[maxsync])
 {
   *period = syncrate->period;
@@ -1948,7 +1942,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned 
int *period,
 default:
   if(!(syncrate->sxfr_ultra2 & AHC_SYNCRATE_CRC))
   {
-done = TRUE;
+done = true;
 if(syncrate == &aic7xxx_syncrates[maxsync])
 {
   *period = syncrate->period;
@@ -2375,22 +2369,22 @@ scbq_insert_tail(volatile scb_queue_type *queue, struct 
aic7xxx_scb *scb)
  * 

Re: 2.6.21 broke arm scsi on qemu -M volatilepb

2007-05-10 Thread Randy Dunlap
[adding linux-scsi]

On Thu, 10 May 2007 23:59:10 -0400 Rob Landley wrote:

> Booting a 2.6.20 kernel under qemu works fine and gets me to a shell prompt, 
> but booting a 2.6.21.1 kernel cycles endlessly on scsi, going:
> 
> Loading iSCSI transport class v2.0-724.
> PCI: enabling device :00:0c.0 (0140 -> 0143)
> sym0: <895a> rev 0x0 at pci :00:0c.0 irq 0
> sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
> sym0: SCSI BUS has been reset.
> scsi0 : sym-2.2.3
> scsi 0:0:0:0: ABORT operation started.
> scsi 0:0:0:0: ABORT operation timed-out.
> scsi 0:0:0:0: DEVICE RESET operation started.
> scsi 0:0:0:0: DEVICE RESET operation timed-out.
> scsi 0:0:0:0: BUS RESET operation started.
> scsi 0:0:0:0: BUS RESET operation timed-out.
> scsi 0:0:0:0: HOST RESET operation started.
> sym0: SCSI BUS has been reset.
> ...
> And so on.
> 
> If you're interested in reproducing this, download the most recent 
> http://landley.net/hg/firmware snapshot (links up top), run "./build.sh 
> armv4l", and when that's done "cd build" and "./run-armv4l.sh".
> 
> Is this a known issue?  A quick google for "arm scsi 2.6.21" didn't turn up 
> anything relevant...
> 
> Rob


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


hdparm 7.3 supports SAT

2007-05-10 Thread Douglas Gilbert
Mark Lord's hdparm version 7.3 supports the SCSI to ATA
Translation (SAT) pass-through. So if SAT is supported,
this allows hdparm to access ATA (e.g. SATA disks) and
ATAPI (e.g. cd/dvd drives) devices behind SCSI transports.

Note that the SAT layer may be in the kernel (e.g. libata),
in a HBA's firmware (MPT Fusion SAS HBAs) or external.
Also one of those "SCSI transports" might be SATA.

See http://sourceforge.net/projects/hdparm/


Both sdparm and two utilities in sg3_utils used some
tortured syntax to pipe through ATA IDENTIFY (PACKET)
DEVICE responses to 'hdparm --Istdin' prior to hdparm 7.x .
That, in most cases, should no longer be needed.

Doug Gilbert
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] stex: minor cleanup and version update

2007-05-10 Thread Jeff Garzik

Ed Lin wrote:

@@ -1196,7 +1206,7 @@ stex_probe(struct pci_dev *pdev, const s
goto out_scsi_host_put;
}
 
-	hba->mmio_base = ioremap(pci_resource_start(pdev, 0),

+   hba->mmio_base = ioremap_nocache(pci_resource_start(pdev, 0),
pci_resource_len(pdev, 0));
if ( !hba->mmio_base) {



I would suggest using pci_iomap(), which would accomplish the same thing 
in a slightly more clean manner.


Jeff


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] stex: fix reset recovery for console device

2007-05-10 Thread Jeff Garzik

Ed Lin wrote:

After reset completed, the scsi error handler sends out TEST_UNIT_READY
to the device. For 'normal' devices the command will be handled by firmware.
However, because the RAID console only interfaces to scsi mid layer, the
firmware will not process the command for it. This will make the console to
be offlined right after reset. Add the handling in driver to fix this problem.

Signed-off-by: Ed Lin <[EMAIL PROTECTED]>
---
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 81dd3b7..47c2ef9 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -612,6 +612,13 @@ stex_queuecommand(struct scsi_cmnd *cmd,
return 0;
}
break;
+   case TEST_UNIT_READY:
+   if (id == host->max_id - 1) {
+   cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+   done(cmd);
+   return 0;
+   }
+   break;


Long term, it seems like a more obvious separation between the RAID 
console and the firmware-handled devices would be useful, rather than 
repeating the "if (id == host->max_id - 1)" for each command in question.



-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] stex: fix id mapping issue

2007-05-10 Thread Jeff Garzik

Ed Lin wrote:

The correct internal mapping of stex controllers should be:
id:0~15, lun:0~7 (st_shasta)
id:0, lun:0~127 (st_yosemite)
id:0~127, lun:0 (st_vsc and st_vsc1)

This patch reports the internal mapping to scsi mid layer,  eliminating
the translation between scsi mid layer and firmware. To achieve this
goal, we also need to:
-- fail the REPORT_LUNS command for st_shasta because the
   firmware is known to not report all actual luns
-- add an entry in scsi_devindo.c to force sequential lun scan
   (for st_shasta controllers)
-- fail the REPORT_LUNS command for console device
-- remove special handling of REPORT_LUNS command for
   st_yosemite, as there is no translation mapping now

Signed-off-by: Ed Lin <[EMAIL PROTECTED]>


ACK patches 1-4, but some suggestions will follow


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] stex: fix id mapping issue

2007-05-10 Thread James Bottomley
On Wed, 2007-05-09 at 20:50 -0800, Ed Lin wrote:
> The correct internal mapping of stex controllers should be:
> id:0~15, lun:0~7 (st_shasta)
> id:0, lun:0~127 (st_yosemite)
> id:0~127, lun:0 (st_vsc and st_vsc1)
> 
> This patch reports the internal mapping to scsi mid layer,  eliminating
> the translation between scsi mid layer and firmware. To achieve this
> goal, we also need to:
> -- fail the REPORT_LUNS command for st_shasta because the
>firmware is known to not report all actual luns
> -- add an entry in scsi_devindo.c to force sequential lun scan
>(for st_shasta controllers)
> -- fail the REPORT_LUNS command for console device
> -- remove special handling of REPORT_LUNS command for
>st_yosemite, as there is no translation mapping now
> 
> Signed-off-by: Ed Lin <[EMAIL PROTECTED]>

This looks great, thanks for doing it.  I think it can be slid nicely
into -rc1.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] scsi: megaraid_sas - intercepts cmd timeout andthrottle io

2007-05-10 Thread Patro, Sumant
Sorry I had missed those comments.

Will address those and resubmit.

Regards,

Sumant 

-Original Message-
From: James Bottomley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 10, 2007 12:24 PM
To: Patro, Sumant
Cc: [EMAIL PROTECTED]; linux-scsi@vger.kernel.org; Kolli, Neela; Yang, Bo
Subject: Re: [PATCH] scsi: megaraid_sas - intercepts cmd timeout
andthrottle io

On Thu, 2007-05-10 at 07:01 -0700, Sumant Patro wrote:
> eh_timed_out call back (megasas_reset_timer) is used to throttle io to

> the adapter when it is called the first time for a scmd.
> The MEGASAS_FW_BUSY flag is set and can_queue reduced to 16. The 
> can_queue is restored from completion routine in following two 
> conditions : 5 seconds has elapsed and the # of outstanding cmds in FW
is < 17.
> Also removed reserved fields from struct megasas_instance.

And the rest of the comments?

This is the cut out of all the ones I made, I think:

> > +static enum
> > +scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) {
> > + struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
> > + struct megasas_instance *instance;
> > + unsigned long flags;
> > +
> > + if (cmd) {
> 
> I don't believe we can ever get a command timeout with no command, can

> we?
> 
> > + if (time_after(jiffies, scmd->jiffies_at_alloc + 170 *
> HZ))
> > + return EH_NOT_HANDLED;
> 
> This 170s is a bit arbitrary ... surely you want it to be related to a

> multiple of scmd->timeout_per_command?


> > + if (!(instance->flag & MEGASAS_FW_BUSY)) {
> > + /* FW is busy, throttle IO */
> > + spin_lock_irqsave(&instance->throttle_io_lock,
> flags);
> > +
> > + instance->host->can_queue = 16;
> 
> can_queue is protected by the host lock ... I think you need to dump 
> the throttle_io_lock and simply use the host lock for all of this.


> > - if (cmd->scmd) {
> > + if (cmd->scmd)
> >   cmd->scmd->SCp.ptr = (char *)0;
> 
> That's NULL, ordinarily ...

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH]: Update Maintainer email-id for MegaRAID SCSI drivers

2007-05-10 Thread Sumant Patro

Update Maintainer email-id for MegaRAID SCSI drivers.

Signed-off-by: Sumant Patro <[EMAIL PROTECTED]>
---

diff -uprN orig/MAINTAINERS new/MAINTAINERS
--- orig/MAINTAINERS2007-05-10 07:13:22.0 -0700
+++ new/MAINTAINERS 2007-05-10 07:12:58.0 -0700
@@ -2268,7 +2268,7 @@ S:Maintained
 
 MEGARAID SCSI DRIVERS
 P: Neela Syam Kolli
-M: [EMAIL PROTECTED]
+M: [EMAIL PROTECTED]
 S: linux-scsi@vger.kernel.org
 W: http://megaraid.lsilogic.com
 S: Maintained


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: megaraid_sas - intercepts cmd timeout and throttle io

2007-05-10 Thread James Bottomley
On Thu, 2007-05-10 at 07:01 -0700, Sumant Patro wrote:
> eh_timed_out call back (megasas_reset_timer) is used to throttle io to the 
> adapter
> when it is called the first time for a scmd.
> The MEGASAS_FW_BUSY flag is set and can_queue reduced to 16. The can_queue is 
> restored
> from completion routine in following two conditions : 5 seconds has elapsed 
> and the # of
> outstanding cmds in FW is < 17.
> Also removed reserved fields from struct megasas_instance.

And the rest of the comments?

This is the cut out of all the ones I made, I think:

> > +static enum
> > +scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
> > +{
> > + struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
> > + struct megasas_instance *instance;
> > + unsigned long flags;
> > +
> > + if (cmd) {
> 
> I don't believe we can ever get a command timeout with no command, can
> we?
> 
> > + if (time_after(jiffies, scmd->jiffies_at_alloc + 170 *
> HZ))
> > + return EH_NOT_HANDLED;
> 
> This 170s is a bit arbitrary ... surely you want it to be related to a
> multiple of scmd->timeout_per_command?


> > + if (!(instance->flag & MEGASAS_FW_BUSY)) {
> > + /* FW is busy, throttle IO */
> > + spin_lock_irqsave(&instance->throttle_io_lock,
> flags);
> > +
> > + instance->host->can_queue = 16;
> 
> can_queue is protected by the host lock ... I think you need to dump
> the
> throttle_io_lock and simply use the host lock for all of this.


> > - if (cmd->scmd) {
> > + if (cmd->scmd)
> >   cmd->scmd->SCp.ptr = (char *)0;
> 
> That's NULL, ordinarily ...

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: megaraid_sas - intercepts cmd timeout and throttle io

2007-05-10 Thread Sumant Patro
eh_timed_out call back (megasas_reset_timer) is used to throttle io to the 
adapter
when it is called the first time for a scmd.
The MEGASAS_FW_BUSY flag is set and can_queue reduced to 16. The can_queue is 
restored
from completion routine in following two conditions : 5 seconds has elapsed and 
the # of
outstanding cmds in FW is < 17.
Also removed reserved fields from struct megasas_instance.

Signed-off-by: Sumant Patro <[EMAIL PROTECTED]>
---
 drivers/scsi/megaraid/megaraid_sas.c |   65 +++--
 drivers/scsi/megaraid/megaraid_sas.h |   13 +++--
 2 files changed, 69 insertions(+), 9 deletions(-)

Re-submitting after removing the reserved fields from megasas_instance.

On Thu, 2007-04-26 at 11:52 -0600, Patro, Sumant wrote:
> The rsvd[3] is reserved for future use. If you have objection to
> the definition I will take it out in a future patch submission.

But this is a structure that's internal to the driver isn't it?  It's
not shared with the card, so there's no need to pad it or reserve
elements ... you can add anything you need at the point you need it.

James

diff -uprN orig/drivers/scsi/megaraid/megaraid_sas.c 
new/drivers/scsi/megaraid/megaraid_sas.c
--- orig/drivers/scsi/megaraid/megaraid_sas.c   2007-05-09 05:32:21.0 
-0700
+++ new/drivers/scsi/megaraid/megaraid_sas.c2007-05-10 06:11:44.0 
-0700
@@ -10,7 +10,7 @@
  *2 of the License, or (at your option) any later version.
  *
  * FILE: megaraid_sas.c
- * Version : v00.00.03.10-rc1
+ * Version : v00.00.03.10-rc4
  *
  * Authors:
  * (email-id : [EMAIL PROTECTED])
@@ -886,6 +886,7 @@ megasas_queue_command(struct scsi_cmnd *
goto out_return_cmd;
 
cmd->scmd = scmd;
+   scmd->SCp.ptr = (char *)cmd;
 
/*
 * Issue the command to the FW
@@ -981,8 +982,8 @@ static int megasas_generic_reset(struct 
 
instance = (struct megasas_instance *)scmd->device->host->hostdata;
 
-   scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x\n",
-  scmd->serial_number, scmd->cmnd[0]);
+   scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x 
retries=%x\n",
+scmd->serial_number, scmd->cmnd[0], scmd->retries);
 
if (instance->hw_crit_error) {
printk(KERN_ERR "megasas: cannot recover from previous reset "
@@ -1000,6 +1001,40 @@ static int megasas_generic_reset(struct 
 }
 
 /**
+ * megasas_reset_timer - quiesce the adapter if required
+ * @scmd:  scsi cmnd
+ *
+ * Sets the FW busy flag and reduces the host->can_queue if the
+ * cmd has not been completed within the timeout period.
+ */
+static enum
+scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
+{
+   struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
+   struct megasas_instance *instance;
+   unsigned long flags;
+
+   if (cmd) {
+   if (time_after(jiffies, scmd->jiffies_at_alloc + 170 * HZ))
+   return EH_NOT_HANDLED;
+
+   instance = cmd->instance;
+   if (!(instance->flag & MEGASAS_FW_BUSY)) {
+   /* FW is busy, throttle IO */
+   spin_lock_irqsave(&instance->throttle_io_lock, flags);
+
+   instance->host->can_queue = 16;
+   instance->last_time = jiffies;
+   instance->flag |= MEGASAS_FW_BUSY;
+
+   spin_unlock_irqrestore(&instance->throttle_io_lock, 
flags);
+   }
+   return EH_RESET_TIMER;
+   }
+   return EH_HANDLED;
+}
+
+/**
  * megasas_reset_device -  Device reset handler entry point
  */
 static int megasas_reset_device(struct scsi_cmnd *scmd)
@@ -1112,6 +1147,7 @@ static struct scsi_host_template megasas
.eh_device_reset_handler = megasas_reset_device,
.eh_bus_reset_handler = megasas_reset_bus_host,
.eh_host_reset_handler = megasas_reset_bus_host,
+   .eh_timed_out = megasas_reset_timer,
.bios_param = megasas_bios_param,
.use_clustering = ENABLE_CLUSTERING,
 };
@@ -1215,9 +1251,8 @@ megasas_complete_cmd(struct megasas_inst
int exception = 0;
struct megasas_header *hdr = &cmd->frame->hdr;
 
-   if (cmd->scmd) {
+   if (cmd->scmd)
cmd->scmd->SCp.ptr = (char *)0;
-   }
 
switch (hdr->cmd) {
 
@@ -1806,6 +1841,7 @@ static void megasas_complete_cmd_dpc(uns
u32 context;
struct megasas_cmd *cmd;
struct megasas_instance *instance = (struct megasas_instance 
*)instance_addr;
+   unsigned long flags;
 
/* If we have already declared adapter dead, donot complete cmds */
if (instance->hw_crit_error)
@@ -1828,6 +1864,22 @@ static void megasas_complete_cmd_dpc(uns
}
 
*instance->consumer = producer;
+
+   /*
+* Check if we can restore can_queue
+*/
+   if (instance->flag & MEGASAS

RE: SG_IO with >4k buffer size to iscsi sg device causes "Bad page" panic

2007-05-10 Thread Qi, Yanling


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
> Behalf Of Herbert Xu
> Sent: Wednesday, May 09, 2007 6:39 PM
> To: Qi, Yanling
> Cc: [EMAIL PROTECTED]; linux-scsi@vger.kernel.org; open-
> [EMAIL PROTECTED]; [EMAIL PROTECTED]; Qi,
> Yanling; [EMAIL PROTECTED]; [EMAIL PROTECTED];
> [EMAIL PROTECTED]
> Subject: Re: SG_IO with >4k buffer size to iscsi sg device causes "Bad
> page" panic
> 
> 
> Qi, Yanling <[EMAIL PROTECTED]> wrote:
> > @@ -2571,6 +2572,13 @@ sg_page_malloc(int rqSz, int lowDma, int
> >resp = (char *) __get_free_pages(page_mask, order);
> > /* try half */
> >resSz = a_size;
> >}
> > +   tmppage = virt_to_page(resp);
> > +   for( m = PAGE_SIZE; m < resSz; m += PAGE_SIZE )
> > +   {
> > +   tmppage++;
> > +   SetPageReserved(tmppage);
> > +   }
> > +
> 
[Qi, Yanling]
If I do a get_page() at sg_page_malloc() time and then do a put_page()
at sg_page_free() time, I worry about a race condition that the page
gets re-used before calling free_pages().

Thanks,
Yanling
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] aic94xx: add PCI ID 9005:0416

2007-05-10 Thread Pim Zandbergen
I just received the retail version of an Adaptec 58300 PCI-X SAS adapter
with PCI ID 9005:0416.

Here's the lspci -vvn output:

03:08.0 Class 0107: 9005:0416 (rev 09)
Subsystem: 9005:0416
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- 
Stepping- SERR+ FastB2B-
Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- SERR- http://vger.kernel.org/majordomo-info.html


Re: [patch 1/7] libata: check for AN support

2007-05-10 Thread Kristen Carlson Accardi
Check to see if an ATAPI device supports Asynchronous Notification.
If so, enable it.

Signed-off-by: Kristen Carlson Accardi <[EMAIL PROTECTED]>
---
Andrew, I cleaned up the function header to properly comply with kernel
doc requirements.  Other than that, this patch is the same.  

Index: 2.6-mm/drivers/ata/libata-core.c
===
--- 2.6-mm.orig/drivers/ata/libata-core.c
+++ 2.6-mm/drivers/ata/libata-core.c
@@ -70,6 +70,7 @@ const unsigned long sata_deb_timing_long
 static unsigned int ata_dev_init_params(struct ata_device *dev,
u16 heads, u16 sectors);
 static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
+static unsigned int ata_dev_set_AN(struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_device *dev);
 
 unsigned int ata_print_id = 1;
@@ -1983,6 +1984,22 @@ int ata_dev_configure(struct ata_device 
}
dev->cdb_len = (unsigned int) rc;
 
+   /*
+* check to see if this ATAPI device supports
+* Asynchronous Notification
+*/
+   if ((ap->flags & ATA_FLAG_AN) && ata_id_has_AN(id)) {
+   int err;
+   /* issue SET feature command to turn this on */
+   err = ata_dev_set_AN(dev);
+   if (err)
+   ata_dev_printk(dev, KERN_ERR,
+   "unable to set AN, err %x\n",
+   err);
+   else
+   dev->flags |= ATA_DFLAG_AN;
+   }
+
if (ata_id_cdb_intr(dev->id)) {
dev->flags |= ATA_DFLAG_CDB_INTR;
cdb_intr_string = ", CDB intr";
@@ -3910,6 +3927,41 @@ static unsigned int ata_dev_set_xfermode
 }
 
 /**
+ * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES
+ * @dev: Device to which command will be sent
+ *
+ * Issue SET FEATURES - SATA FEATURES command to device @dev
+ * on port @ap with sector count set to indicate Asynchronous
+ * Notification feature
+ *
+ * LOCKING:
+ * PCI/etc. bus probe sem.
+ *
+ * RETURNS:
+ * 0 on success, AC_ERR_* mask otherwise.
+ */
+static unsigned int ata_dev_set_AN(struct ata_device *dev)
+{
+   struct ata_taskfile tf;
+   unsigned int err_mask;
+
+   /* set up set-features taskfile */
+   DPRINTK("set features - SATA features\n");
+
+   ata_tf_init(dev, &tf);
+   tf.command = ATA_CMD_SET_FEATURES;
+   tf.feature = SETFEATURES_SATA_ENABLE;
+   tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+   tf.protocol = ATA_PROT_NODATA;
+   tf.nsect = SATA_AN;
+
+   err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
+
+   DPRINTK("EXIT, err_mask=%x\n", err_mask);
+   return err_mask;
+}
+
+/**
  * ata_dev_init_params - Issue INIT DEV PARAMS command
  * @dev: Device to which command will be sent
  * @heads: Number of heads (taskfile parameter)
Index: 2.6-mm/include/linux/ata.h
===
--- 2.6-mm.orig/include/linux/ata.h
+++ 2.6-mm/include/linux/ata.h
@@ -204,6 +204,12 @@ enum {
 
SETFEATURES_SPINUP  = 0x07, /* Spin-up drive */
 
+   SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
+   SETFEATURES_SATA_DISABLE = 0x90, /* Disable use of SATA feature */
+
+   /* SETFEATURE Sector counts for SATA features */
+   SATA_AN = 0x05,  /* Asynchronous Notification */
+
/* ATAPI stuff */
ATAPI_PKT_DMA   = (1 << 0),
ATAPI_DMADIR= (1 << 2), /* ATAPI data dir:
@@ -309,6 +315,9 @@ struct ata_taskfile {
 #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1)
 #define ata_id_removeable(id)  ((id)[0] & (1 << 7))
 #define ata_id_has_dword_io(id)((id)[50] & (1 << 0))
+#define ata_id_has_AN(id)  \
+   ( (((id)[76] != 0x) && ((id)[76] != 0x)) && \
+ ((id)[78] & (1 << 5)) )
 #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
 #define ata_id_has_iordy(id) ((id)[49] & (1 << 9))
 #define ata_id_u32(id,n)   \
Index: 2.6-mm/include/linux/libata.h
===
--- 2.6-mm.orig/include/linux/libata.h
+++ 2.6-mm/include/linux/libata.h
@@ -136,6 +136,7 @@ enum {
ATA_DFLAG_CDB_INTR  = (1 << 2), /* device asserts INTRQ when ready 
for CDB */
ATA_DFLAG_NCQ   = (1 << 3), /* device supports NCQ */
ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */
+   ATA_DFLAG_AN= (1 << 5), /* device supports Async 
notification */
ATA_DFLAG_CFG_MASK  = (1 << 8) - 1,
 
ATA_DFLAG_PIO   = (1 << 8), /* device limited to PIO mode */
@@ -174,6 +175,7 @@ e

Re: [PATCH v2] add bidi support for block pc requests

2007-05-10 Thread Boaz Harrosh
Douglas Gilbert wrote:
> Boaz Harrosh wrote:
>> FUJITA Tomonori wrote:
>>> From: FUJITA Tomonori <[EMAIL PROTECTED]>
>>> Subject: Re: [PATCH v2] add bidi support for block pc requests
>>> Date: Thu, 10 May 2007 15:53:22 +0900
>>>
 From: Boaz Harrosh <[EMAIL PROTECTED]>
 Subject: Re: [PATCH v2] add bidi support for block pc requests
 Date: Wed, 09 May 2007 19:54:32 +0300

> James Bottomley wrote:
>> Actually, the first order of business is to use accessors on the command
>> pointers in the drivers to free them from the internal layout of the
>> structure (and where it is allocated).
>>
> Thanks! I totally second that. Let me look into my old patches and come
> up with all the needed accessors. I hope 3-5 will be enough.
> I will send some suggestions tomorrow.
>> No, that's why you do the accessors.  Convert all of the common drivers
>> to accessors on the current structure, then throw the switch to convert
>> to the new structure (whatever form is finally settled on).  Then any
>> unconverted drivers break and people fix the ones they care about.
> Last time I was able to compile 97% of drivers and convert by 
> search-and-replace
> the rest. Not a huge deal.
 We need to remove the non-use-sg code in the drivers and convert
 them. So it's a bit more complicated than search-and-replace.
>>> Here's a patch to convert ibmvscsi to use helper functions (though it
>>> needs more testings).
>>>
>>> ---
>>> ---
>>> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
>>> index d6948d0..799f204 100644
>>> --- a/include/scsi/scsi_cmnd.h
>>> +++ b/include/scsi/scsi_cmnd.h
>>> @@ -138,4 +138,17 @@ extern void scsi_kunmap_atomic_sg(void *
>>>  extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
>>>  extern void scsi_free_sgtable(struct scatterlist *, int);
>>>  
>>> +extern int scsi_dma_map(struct device *dev, struct scsi_cmnd *cmd);
>>> +extern void scsi_dma_unmap(struct device *dev, struct scsi_cmnd *cmd);
>>> +
>>> +/* moved to scatterlist.h after chaining sg */
>>> +#define sg_next(sg) ((sg) + 1)
>>> +
>>> +#define scsi_for_each_sg(cmd, nseg, i) 
>>> \
>>> +   for (i = 0, sg = (cmd)->request_buffer; i < nseg;   \
>>> +   sg = sg_next(sg), i++)  \
>>> +
>> Better we do like Jens's patch
>> +#define for_each_sg(sglist, sg, nr, __i)\
>> +for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
>>
>> I think that we should wait for Jens pending patchset and do this work on top
>> of his, then use his sg macros directly. This way the cleaners can also be
>> watchfully for any drivers that might brake with big IO sent to them.
>>
>>> +#define scsi_sg_count(cmd) ((cmd)->use_sg)
>>> +#define scsi_bufferlen(cmd) ((cmd)->request_bufflen)
>>> +
>>>  #endif /* _SCSI_SCSI_CMND_H */
>> Above helpers look good. However I am missing 2 of them:
>>
>> 1.
>> +#define scsi_sgl(cmd) ((struct scatterlist*)(cmd)->request_buffer)
>>
>> This is for drivers like iSCSI that do not do any dma mapping, as dma
>> is done at the lower level in the NICs. And lots of other places that just
>> transfer the sglist around.
>>
>> 2.
>> +#define scsi_resid(cmd) ((cmd)->resid)
> 
> I have defined resid in the past as a signed (32 bit)
> integer following the CAM spec. The cases are:
>- resid=0 : initiator's DMA engine got (or sent?) the
>number of bytes it expected
>- resid>0 : dxfer_len-resid bytes received, less than
>expected
>- resid<0 : more bytes received (or could have been)
>than indicated by dxfer_len
> 
> Some definitions of resid make it unsigned which rules out
> the less common resid<0 case. Can this case happen? Does it
> happen in practice? Naturally no more than dxfer_len should
> be placed in the scatter gather list.
> 
> SPI and SAS do not convey dxfer_len (or data direction) to
> a target in their transport frames. This means that the
> relevant field in the cdb (e.g. transfer length) dictates
> how much data a target sends back to an initiator in the
> case of a read like operation. So that opens up the
> possibility that dxfer_len and the cdb disagree.
> 
> FCP does convey dxfer_len and data_direction to a target.
> So a FCP target can detect a mismatch between this and the
> cdb and send resid information (either under or over) in its
> response frame back to the initiator. Alternatively it
> can treat the "over" case as an error (fcp3r04.pdf section
> 9.4.2).
> iSCSI and SRP?
> 
> The resid<0 case may become more common if a driver or
> application does not properly take account of protection
> information being sent together with the requested
> data.
> 
> So should we keep resid signed?
> 
> Doug Gilbert
You are probably right just that I was afraid of this: req->data_len = sc->resid
and I saw in iSCSI :

iscsi_scsi_cmd_rsp()
...

if (

Re: [patch 1/7] libata: check for AN support

2007-05-10 Thread Randy Dunlap
On Wed, 9 May 2007 22:09:52 -0700 Andrew Morton wrote:

> On Wed, 9 May 2007 16:38:09 -0700 Kristen Carlson Accardi <[EMAIL PROTECTED]> 
> wrote:
> 
> >  /**
> > + * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES
> > + *   with sector count set to indicate
> > + *   Asynchronous Notification feature
> 
> I think kenreldoc requires that all this be on a single line?

Correct.

> > + * @dev: Device to which command will be sent
> > + *
> > + * Issue SET FEATURES - SATA FEATURES command to device @dev
> > + * on port @ap.
> > + *
> > + * LOCKING:
> > + * PCI/etc. bus probe sem.
> > + *
> > + * RETURNS:
> > + * 0 on success, AC_ERR_* mask otherwise.
> > + */
> 
> ooh, locking and return value documentation.  Often missed, and nice.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] add bidi support for block pc requests

2007-05-10 Thread Douglas Gilbert
Boaz Harrosh wrote:
> FUJITA Tomonori wrote:
>> From: FUJITA Tomonori <[EMAIL PROTECTED]>
>> Subject: Re: [PATCH v2] add bidi support for block pc requests
>> Date: Thu, 10 May 2007 15:53:22 +0900
>>
>>> From: Boaz Harrosh <[EMAIL PROTECTED]>
>>> Subject: Re: [PATCH v2] add bidi support for block pc requests
>>> Date: Wed, 09 May 2007 19:54:32 +0300
>>>
 James Bottomley wrote:
> Actually, the first order of business is to use accessors on the command
> pointers in the drivers to free them from the internal layout of the
> structure (and where it is allocated).
>
 Thanks! I totally second that. Let me look into my old patches and come
 up with all the needed accessors. I hope 3-5 will be enough.
 I will send some suggestions tomorrow.
> No, that's why you do the accessors.  Convert all of the common drivers
> to accessors on the current structure, then throw the switch to convert
> to the new structure (whatever form is finally settled on).  Then any
> unconverted drivers break and people fix the ones they care about.
 Last time I was able to compile 97% of drivers and convert by 
 search-and-replace
 the rest. Not a huge deal.
>>> We need to remove the non-use-sg code in the drivers and convert
>>> them. So it's a bit more complicated than search-and-replace.
>> Here's a patch to convert ibmvscsi to use helper functions (though it
>> needs more testings).
>>
>> ---
>> ---
>> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
>> index d6948d0..799f204 100644
>> --- a/include/scsi/scsi_cmnd.h
>> +++ b/include/scsi/scsi_cmnd.h
>> @@ -138,4 +138,17 @@ extern void scsi_kunmap_atomic_sg(void *
>>  extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
>>  extern void scsi_free_sgtable(struct scatterlist *, int);
>>  
>> +extern int scsi_dma_map(struct device *dev, struct scsi_cmnd *cmd);
>> +extern void scsi_dma_unmap(struct device *dev, struct scsi_cmnd *cmd);
>> +
>> +/* moved to scatterlist.h after chaining sg */
>> +#define sg_next(sg) ((sg) + 1)
>> +
>> +#define scsi_for_each_sg(cmd, nseg, i)  
>> \
>> +for (i = 0, sg = (cmd)->request_buffer; i < nseg;   \
>> +sg = sg_next(sg), i++)  \
>> +
> 
> Better we do like Jens's patch
> +#define for_each_sg(sglist, sg, nr, __i) \
> + for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
> 
> I think that we should wait for Jens pending patchset and do this work on top
> of his, then use his sg macros directly. This way the cleaners can also be
> watchfully for any drivers that might brake with big IO sent to them.
> 
>> +#define scsi_sg_count(cmd) ((cmd)->use_sg)
>> +#define scsi_bufferlen(cmd) ((cmd)->request_bufflen)
>> +
>>  #endif /* _SCSI_SCSI_CMND_H */
> 
> Above helpers look good. However I am missing 2 of them:
> 
> 1.
> +#define scsi_sgl(cmd) ((struct scatterlist*)(cmd)->request_buffer)
> 
> This is for drivers like iSCSI that do not do any dma mapping, as dma
> is done at the lower level in the NICs. And lots of other places that just
> transfer the sglist around.
> 
> 2.
> +#define scsi_resid(cmd) ((cmd)->resid)

I have defined resid in the past as a signed (32 bit)
integer following the CAM spec. The cases are:
   - resid=0 : initiator's DMA engine got (or sent?) the
   number of bytes it expected
   - resid>0 : dxfer_len-resid bytes received, less than
   expected
   - resid<0 : more bytes received (or could have been)
   than indicated by dxfer_len

Some definitions of resid make it unsigned which rules out
the less common resid<0 case. Can this case happen? Does it
happen in practice? Naturally no more than dxfer_len should
be placed in the scatter gather list.

SPI and SAS do not convey dxfer_len (or data direction) to
a target in their transport frames. This means that the
relevant field in the cdb (e.g. transfer length) dictates
how much data a target sends back to an initiator in the
case of a read like operation. So that opens up the
possibility that dxfer_len and the cdb disagree.

FCP does convey dxfer_len and data_direction to a target.
So a FCP target can detect a mismatch between this and the
cdb and send resid information (either under or over) in its
response frame back to the initiator. Alternatively it
can treat the "over" case as an error (fcp3r04.pdf section
9.4.2).
iSCSI and SRP?

The resid<0 case may become more common if a driver or
application does not properly take account of protection
information being sent together with the requested
data.

So should we keep resid signed?

Doug Gilbert
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: use_sg != 0 assumption (was Re: [PATCH 5/9] Drop single buffer request support.)

2007-05-10 Thread Kristian Høgsberg

Stefan Richter wrote:

Kristian Høgsberg wrote:

The SCSI layer only passes sg requests down, so drop the
use_sg == 0, request_bufflen != 0 case.

Signed-off-by: Kristian Hoegsberg <[EMAIL PROTECTED]>
---
 drivers/firewire/fw-sbp2.c |   43 +--
 1 files changed, 1 insertions(+), 42 deletions(-)


[...]


@@ -1063,21 +1035,8 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, 
scsi_done_fn_t done)
orb->request.misc |=
COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
 
-	if (cmd->use_sg) {

-   if (sbp2_command_orb_map_scatterlist(orb) < 0)
-   goto fail_map_payload;
-   } else if (cmd->request_bufflen > SBP2_MAX_SG_ELEMENT_LENGTH) {
-   /*
-* FIXME: Need to split this into a sg list... but
-* could we get the scsi or blk layer to do that by
-* reporting our max supported block size?
-*/
-   fw_error("command > 64k\n");
+   if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
goto fail_map_payload;
-   } else if (cmd->request_bufflen > 0) {
-   if (sbp2_command_orb_map_buffer(orb) < 0)
-   goto fail_map_payload;
-   }
 
 	fw_memcpy_to_be32(&orb->request, &orb->request, sizeof orb->request);
 


Would a BUG_ON(cmd->use_sg == 0); be in order?


That's a good idea, though it needs to be

  BUG_ON(cmd->usg_sg == 0 && cmd->request_bufflen > 0);

since commands with no payload have use_sg == 0 and request_bufflen == 0.

Kristian


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] fix for BZ 8426 - massive slowdown on SCSI CD/DVD drive connected to mptspi driver

2007-05-10 Thread Doug Chapman
Eric,

Any feedback on this?  From looking at the code I am pretty sure I have
only restored things to the order where they were before the cleanup
patch but you obviously know the code better than I possibly could.

As this is a regression I would like to get this resolved before long.

thanks,

- Doug

On Mon, 2007-05-07 at 15:59 -0400, Doug Chapman wrote:
> Patch for: http://bugzilla.kernel.org/show_bug.cgi?id=8426
> 
> A recent code cleanup that moved code from mptscsih to mptspi
> inadvertently change the order some code was called.  This caused
> a massive slowdown (of 150x to 300x) on the CD/DVD drive on the
> high-end HP Integrity servers.
> 
> Signed-off-by: Doug Chapman <[EMAIL PROTECTED]>
> 
> 
> 
> 
> diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
> index 85f21b5..2eb5741 100644
> --- a/drivers/message/fusion/mptspi.c
> +++ b/drivers/message/fusion/mptspi.c
> @@ -726,13 +726,15 @@ static int mptspi_slave_configure(struct scsi_device 
> *sdev)
>   struct _MPT_SCSI_HOST *hd =
>   (struct _MPT_SCSI_HOST *)sdev->host->hostdata;
>   VirtTarget *vtarget = scsi_target(sdev)->hostdata;
> - int ret = mptscsih_slave_configure(sdev);
> + int ret;
> +
> + mptspi_initTarget(hd, vtarget, sdev);
> +
> + ret = mptscsih_slave_configure(sdev);
>  
>   if (ret)
>   return ret;
>  
> - mptspi_initTarget(hd, vtarget, sdev);
> -
>   ddvprintk((MYIOC_s_INFO_FMT "id=%d min_period=0x%02x"
>   " max_offset=0x%02x max_width=%d\n", hd->ioc->name,
>   sdev->id, spi_min_period(scsi_target(sdev)),
> 
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDIO_DRIVE_CMD and hdparm

2007-05-10 Thread Mark Lord

Geert Uytterhoeven wrote:

Hi,

`hdparm -t' uses HDIO_DRIVE_CMD(null) to flush the disk's buffer.


More correctly, that command is supposed to act like an I/O queue "barrier"
operation, not returning from the syscall until everything queued in front
of it has been issued/completed.

I believe that only the original IDE driver actually implements it, though.
And hdparm-7.4 (not released yet) will no longer complain about ENOTTY.

Note that current versions of hdparm use SG_IO/ATA_16 (SAT) for nearly 
everything
now, only falling back to the older ioctl's for drivers which reject the SAT 
attempt.

I'd love to find a USB drive enclosure that supports SAT.
Anyone know of one?

And does the USB storage layer actually pass the ATA_16 packets to the device?

Cheers
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDIO_DRIVE_CMD and hdparm

2007-05-10 Thread Mark Lord

Alan Cox wrote:

  - SCSI doesn't handle HDIO_DRIVE_CMD(null), and returns EINVAL
=> fine for hdparm
  - If a block device doesn't support the ioctl, blkdev_driver_ioctl() returns
ENOTTY
=> hdparm error message


Those are both correct
-ENOTTY I don't know this ioctl
-EINVAL I know this ioctl, usage wrong


Exactly.
I'll have hdparm-7.4 not complain on ENOTTY as well.

-ml
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: use_sg != 0 assumption (was Re: [PATCH 5/9] Drop single buffer request support.)

2007-05-10 Thread Stefan Richter
Christoph Hellwig wrote:
> On Thu, May 10, 2007 at 12:38:31PM +0200, Stefan Richter wrote:
>> Would a BUG_ON(cmd->use_sg == 0); be in order?
> 
> I don't think we should put this into every driver.  If you want to
> be sure this doesn't happen anymore put it just in front of the queuecommand
> call.

Thanks for the pointer.  I'm just noticing that Jens Axboe has a patch
which puts BUG_ON(!cmd->use_sg); into scsi_lib.c's sg table allocation
path.  (The "Chaining sg lists for bio IO commands v3" patchset from a
few hours ago, part 11/13 "SCSI: support for allocating large
scatterlists".)
-- 
Stefan Richter
-=-=-=== -=-= -=-=-
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] add bidi support for block pc requests

2007-05-10 Thread FUJITA Tomonori
From: Boaz Harrosh <[EMAIL PROTECTED]>
Subject: Re: [PATCH v2] add bidi support for block pc requests
Date: Thu, 10 May 2007 15:37:48 +0300

> > +/* moved to scatterlist.h after chaining sg */
> > +#define sg_next(sg) ((sg) + 1)
> > +
> > +#define scsi_for_each_sg(cmd, nseg, i) 
> > \
> > +   for (i = 0, sg = (cmd)->request_buffer; i < nseg;   \
> > +   sg = sg_next(sg), i++)  \
> > +
> 
> Better we do like Jens's patch
> +#define for_each_sg(sglist, sg, nr, __i) \
> + for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
> 
> I think that we should wait for Jens pending patchset and do this work on top
> of his, then use his sg macros directly. This way the cleaners can also be
> watchfully for any drivers that might brake with big IO sent to them.

Yeah, we can use sg list's macro something like:

#define scsi_for_each_sg(cmd, sg, nseg, __i)\
for_each_sg((cmd)->request_buffer, sg, nseg, __i)   

Seems that Jens converted lots of LLDs to use for_each_sg. If
for_each_sg goes first, we can just replase for_each_sg (but after
all, we need to touch LLDs to remove the non-use-sg path). On the
other hand, if we go first, there is no conversion for for_each_sg in
LLDs.

Jens, do you want the sg list stuff done before our cleanups?
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDIO_DRIVE_CMD and hdparm

2007-05-10 Thread Alan Cox
>   - SCSI doesn't handle HDIO_DRIVE_CMD(null), and returns EINVAL
> => fine for hdparm
>   - If a block device doesn't support the ioctl, blkdev_driver_ioctl() returns
> ENOTTY
> => hdparm error message

Those are both correct
-ENOTTY I don't know this ioctl
-EINVAL I know this ioctl, usage wrong
0   Hey it worked

ENOIOCTLCMD Internal (not user exposed)
for fallthrough

ENOSYS  CD-ROM being weird.

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDIO_DRIVE_CMD and hdparm

2007-05-10 Thread Christoph Hellwig
On Thu, May 10, 2007 at 02:12:59PM +0200, Geert Uytterhoeven wrote:
>   Hi,
> 
> `hdparm -t' uses HDIO_DRIVE_CMD(null) to flush the disk's buffer.
> When using it on my own block device (the new PS3 disk storage driver), hdparm
> gives the following error message:
> 
> | HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl 
> for device
> 
> When using it on an ATA or SCSI device, no such error message is printed.
> 
> According to the hdparm sources, hdparm expects the HDIO_DRIVE_CMD(null) ioctl
> to either succeed, or to fail with errno EINVAL.
> 
> Apparently handling of ioctls is different for the different device types:
>   - ATA/SATA handle HDIO_DRIVE_CMD(null) (and a few other variants)
> => fine for hdparm
>   - SCSI doesn't handle HDIO_DRIVE_CMD(null), and returns EINVAL
> => fine for hdparm
>   - If a block device doesn't support the ioctl, blkdev_driver_ioctl() returns
> ENOTTY
> => hdparm error message
> 
> Which one is correct?
>   - blkdev_ioctl()/blkdev_driver_ioctl() return -ENOTTY
>   - scsi_cmd_ioctl() returns -ENOTTY
>   - scsi_ioctl() returns -EINVAL
>   - cdrom_ioctl() returns -ENOSYS to mean not handled, continue
>   - some block layer routines return -ENOIOCTLCMD to mean not handled, 
> continue

ENOTTY is the traditional unix errno value for this ioctl is not implemented.
ENOIOCTLCMD is a new fashioned code meaning about the same.  In the block
layer the latter should be used as generic code should handlde this.

> 
> My questions:
>   1. Does any of these have to be fixed?
>   2. Shall I add a dummy HDIO_DRIVE_CMD(null) handler to my block device to
>  return -EINVAL?
>   3. Shall I just ignore the hdparm error message?

I suspect you can just ignore this.  Even better send a patch to the hdparm
maintainer to deal with ENOTTY aswell.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] add bidi support for block pc requests

2007-05-10 Thread Boaz Harrosh
FUJITA Tomonori wrote:
> From: FUJITA Tomonori <[EMAIL PROTECTED]>
> Subject: Re: [PATCH v2] add bidi support for block pc requests
> Date: Thu, 10 May 2007 15:53:22 +0900
> 
>> From: Boaz Harrosh <[EMAIL PROTECTED]>
>> Subject: Re: [PATCH v2] add bidi support for block pc requests
>> Date: Wed, 09 May 2007 19:54:32 +0300
>>
>>> James Bottomley wrote:
 Actually, the first order of business is to use accessors on the command
 pointers in the drivers to free them from the internal layout of the
 structure (and where it is allocated).

>>> Thanks! I totally second that. Let me look into my old patches and come
>>> up with all the needed accessors. I hope 3-5 will be enough.
>>> I will send some suggestions tomorrow.
 No, that's why you do the accessors.  Convert all of the common drivers
 to accessors on the current structure, then throw the switch to convert
 to the new structure (whatever form is finally settled on).  Then any
 unconverted drivers break and people fix the ones they care about.
>>> Last time I was able to compile 97% of drivers and convert by 
>>> search-and-replace
>>> the rest. Not a huge deal.
>> We need to remove the non-use-sg code in the drivers and convert
>> them. So it's a bit more complicated than search-and-replace.
> 
> Here's a patch to convert ibmvscsi to use helper functions (though it
> needs more testings).
> 
> ---
> ---
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index d6948d0..799f204 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -138,4 +138,17 @@ extern void scsi_kunmap_atomic_sg(void *
>  extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
>  extern void scsi_free_sgtable(struct scatterlist *, int);
>  
> +extern int scsi_dma_map(struct device *dev, struct scsi_cmnd *cmd);
> +extern void scsi_dma_unmap(struct device *dev, struct scsi_cmnd *cmd);
> +
> +/* moved to scatterlist.h after chaining sg */
> +#define sg_next(sg) ((sg) + 1)
> +
> +#define scsi_for_each_sg(cmd, nseg, i)   
> \
> + for (i = 0, sg = (cmd)->request_buffer; i < nseg;   \
> + sg = sg_next(sg), i++)  \
> +

Better we do like Jens's patch
+#define for_each_sg(sglist, sg, nr, __i)   \
+   for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))

I think that we should wait for Jens pending patchset and do this work on top
of his, then use his sg macros directly. This way the cleaners can also be
watchfully for any drivers that might brake with big IO sent to them.

> +#define scsi_sg_count(cmd) ((cmd)->use_sg)
> +#define scsi_bufferlen(cmd) ((cmd)->request_bufflen)
> +
>  #endif /* _SCSI_SCSI_CMND_H */

Above helpers look good. However I am missing 2 of them:

1.
+#define scsi_sgl(cmd) ((struct scatterlist*)(cmd)->request_buffer)

This is for drivers like iSCSI that do not do any dma mapping, as dma
is done at the lower level in the NICs. And lots of other places that just
transfer the sglist around.

2.
+#define scsi_resid(cmd) ((cmd)->resid)

Boaz


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


HDIO_DRIVE_CMD and hdparm

2007-05-10 Thread Geert Uytterhoeven
Hi,

`hdparm -t' uses HDIO_DRIVE_CMD(null) to flush the disk's buffer.
When using it on my own block device (the new PS3 disk storage driver), hdparm
gives the following error message:

| HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl 
for device

When using it on an ATA or SCSI device, no such error message is printed.

According to the hdparm sources, hdparm expects the HDIO_DRIVE_CMD(null) ioctl
to either succeed, or to fail with errno EINVAL.

Apparently handling of ioctls is different for the different device types:
  - ATA/SATA handle HDIO_DRIVE_CMD(null) (and a few other variants)
=> fine for hdparm
  - SCSI doesn't handle HDIO_DRIVE_CMD(null), and returns EINVAL
=> fine for hdparm
  - If a block device doesn't support the ioctl, blkdev_driver_ioctl() returns
ENOTTY
=> hdparm error message

Which one is correct?
  - blkdev_ioctl()/blkdev_driver_ioctl() return -ENOTTY
  - scsi_cmd_ioctl() returns -ENOTTY
  - scsi_ioctl() returns -EINVAL
  - cdrom_ioctl() returns -ENOSYS to mean not handled, continue
  - some block layer routines return -ENOIOCTLCMD to mean not handled, continue

This causes constructs with different tests like e.g.:

sr_block_ioctl()
{
...
ret = cdrom_ioctl(...);
if (ret != -ENOSYS)
return ret;
...
return scsi_ioctl(...);
}

cdrom_ioctl()
{
...
ret = scsi_cmd_ioctl(...);
if (ret != -ENOTTY)
return ret;
...
return -ENOSYS;
}

blkdev_ioctl()
{
...
ret = blkdev_locked_ioctl(...);
...
if (ret != -ENOIOCTLCMD)
return ret;

return blkdev_driver_ioctl(...);
}

My questions:
  1. Does any of these have to be fixed?
  2. Shall I add a dummy HDIO_DRIVE_CMD(null) handler to my block device to
 return -EINVAL?
  3. Shall I just ignore the hdparm error message?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
[EMAIL PROTECTED] --- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622  B-1935 Zaventem, Belgium
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: use_sg != 0 assumption (was Re: [PATCH 5/9] Drop single buffer request support.)

2007-05-10 Thread Christoph Hellwig
On Thu, May 10, 2007 at 12:38:31PM +0200, Stefan Richter wrote:
> > fw_memcpy_to_be32(&orb->request, &orb->request, sizeof orb->request);
> >  
> 
> Would a BUG_ON(cmd->use_sg == 0); be in order?

I don't think we should put this into every driver.  If you want to
be sure this doesn't happen anymore put it just in front of the queuecommand
call.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/9] Make scsi_host_template::proc_name const char * instead of char *.

2007-05-10 Thread Stefan Richter
Kristian Høgsberg wrote:
> Signed-off-by: Kristian Hoegsberg <[EMAIL PROTECTED]>
> ---
>  drivers/scsi/scsi_debug.c |2 +-
>  include/scsi/scsi_host.h  |2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 3e2930b..843f9c1 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -2876,7 +2876,7 @@ static int __init scsi_debug_init(void)
>  
>   init_all_queued();
>  
> - sdebug_driver_template.proc_name = (char *)sdebug_proc_name;
> + sdebug_driver_template.proc_name = sdebug_proc_name;
>  
>   host_to_add = scsi_debug_add_host;
>  scsi_debug_add_host = 0;
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 7f1f411..0dfb5c2 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -343,7 +343,7 @@ struct scsi_host_template {
>   /*
>* Name of proc directory
>*/
> - char *proc_name;
> + const char *proc_name;
>  
>   /*
>* Used to store the procfs directory if a driver implements the

This has to go via James B and LSML.
-- 
Stefan Richter
-=-=-=== -=-= -=-=-
http://arcgraph.de/sr/
From: =?utf-8?q?Kristian_H=C3=B8gsberg?= <[EMAIL PROTECTED]>
Subject: [PATCH 6/9] Make scsi_host_template::proc_name const char * instead of 
char *.
Date: Wed,  9 May 2007 19:23:12 -0400

Signed-off-by: Kristian Hoegsberg <[EMAIL PROTECTED]>
---
 drivers/scsi/scsi_debug.c |2 +-
 include/scsi/scsi_host.h  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 3e2930b..843f9c1 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2876,7 +2876,7 @@ static int __init scsi_debug_init(void)
 
init_all_queued();
 
-   sdebug_driver_template.proc_name = (char *)sdebug_proc_name;
+   sdebug_driver_template.proc_name = sdebug_proc_name;
 
host_to_add = scsi_debug_add_host;
 scsi_debug_add_host = 0;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7f1f411..0dfb5c2 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -343,7 +343,7 @@ struct scsi_host_template {
/*
 * Name of proc directory
 */
-   char *proc_name;
+   const char *proc_name;
 
/*
 * Used to store the procfs directory if a driver implements the



use_sg != 0 assumption (was Re: [PATCH 5/9] Drop single buffer request support.)

2007-05-10 Thread Stefan Richter
Kristian Høgsberg wrote:
> The SCSI layer only passes sg requests down, so drop the
> use_sg == 0, request_bufflen != 0 case.
> 
> Signed-off-by: Kristian Hoegsberg <[EMAIL PROTECTED]>
> ---
>  drivers/firewire/fw-sbp2.c |   43 +--
>  1 files changed, 1 insertions(+), 42 deletions(-)

[...]

> @@ -1063,21 +1035,8 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd 
> *cmd, scsi_done_fn_t done)
>   orb->request.misc |=
>   COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
>  
> - if (cmd->use_sg) {
> - if (sbp2_command_orb_map_scatterlist(orb) < 0)
> - goto fail_map_payload;
> - } else if (cmd->request_bufflen > SBP2_MAX_SG_ELEMENT_LENGTH) {
> - /*
> -  * FIXME: Need to split this into a sg list... but
> -  * could we get the scsi or blk layer to do that by
> -  * reporting our max supported block size?
> -  */
> - fw_error("command > 64k\n");
> + if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
>   goto fail_map_payload;
> - } else if (cmd->request_bufflen > 0) {
> - if (sbp2_command_orb_map_buffer(orb) < 0)
> - goto fail_map_payload;
> - }
>  
>   fw_memcpy_to_be32(&orb->request, &orb->request, sizeof orb->request);
>  

Would a BUG_ON(cmd->use_sg == 0); be in order?
-- 
Stefan Richter
-=-=-=== -=-= -=-=-
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] PCI legacy I/O port free driver - Making Emulex lpfc driver legacy I/O port free

2007-05-10 Thread Tomohiro Kusumi
Hi

As you can see in the "10. pci_enable_device_bars() and Legacy I/O
Port space" of the Documentation/pci.txt, the latest kernel has
interfaces for PCI device drivers to tell the kernel which resource
the driver want to use, ex. I/O port or MMIO.

I've made a patch which makes Emulex lpfc driver legacy I/O port
free by using the PCI core changes I mentioned above. The Emulex
lpfc driver can handle some of its devices without using I/O port.
So this patch changes the driver not to enable/request I/O port
region.

As a result, the driver can handle its device even when there are
huge number of PCI devices being used on the system and no I/O
port region assigned to the device.

Tomohiro Kusumi

Signed-off-by: Tomohiro Kusumi <[EMAIL PROTECTED]>

---
 lpfc_init.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff -uprN linux-2.6.21.orig/drivers/scsi/lpfc/lpfc_init.c 
linux-2.6.21/drivers/scsi/lpfc/lpfc_init.c
--- linux-2.6.21.orig/drivers/scsi/lpfc/lpfc_init.c 2007-04-26 
12:08:32.0 +0900
+++ linux-2.6.21/drivers/scsi/lpfc/lpfc_init.c  2007-05-09 18:22:10.0 
+0900
@@ -1419,10 +1419,11 @@ lpfc_pci_probe_one(struct pci_dev *pdev,
int error = -ENODEV, retval;
int i;
uint16_t iotag;
+   int bars = pci_select_bars(pdev, IORESOURCE_MEM);

-   if (pci_enable_device(pdev))
+   if (pci_enable_device_bars(pdev, bars))
goto out;
-   if (pci_request_regions(pdev, LPFC_DRIVER_NAME))
+   if (pci_request_selected_regions(pdev, bars, LPFC_DRIVER_NAME))
goto out_disable_device;

host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba));
@@ -1734,7 +1735,7 @@ out_put_host:
phba->host = NULL;
scsi_host_put(host);
 out_release_regions:
-   pci_release_regions(pdev);
+   pci_release_selected_regions(pdev, bars);
 out_disable_device:
pci_disable_device(pdev);
 out:
@@ -1748,6 +1749,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev
struct Scsi_Host   *host = pci_get_drvdata(pdev);
struct lpfc_hba*phba = (struct lpfc_hba *)host->hostdata;
unsigned long iflag;
+   int bars = pci_select_bars(pdev, IORESOURCE_MEM);

lpfc_free_sysfs_attr(phba);

@@ -1792,7 +1794,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev
iounmap(phba->ctrl_regs_memmap_p);
iounmap(phba->slim_memmap_p);

-   pci_release_regions(phba->pcidev);
+   pci_release_selected_regions(phba->pcidev, bars);
pci_disable_device(phba->pcidev);

idr_remove(&lpfc_hba_index, phba->brd_no);

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] zfcp: Fix deadlock between zfcp ERP and SCSI

2007-05-10 Thread Heiko Carstens
On Tue, May 08, 2007 at 11:00:11AM -0400, James Smart wrote:
> Curious why you are calling scsi_scan_target() or
> scsi_target_block()/scsi_target_unblock() directly. I would have
> thought the add/remove rport code would have done this for you,
> and it deals with all the flush conditions, etc.
> 
> -- james
> 
> Swen Schillig wrote:
> >From: Christof Schmitt <[EMAIL PROTECTED]>
> >The SCSI stack requires low level drivers to register and
> >unregister devices. For zfcp this leads to the situation where
> >zfcp calls the SCSI stack, the SCSI tries to scan the new device
> >and the scan SCSI command fails. This would require the zfcp erp,
> >but the erp thread is already blocked in the register call.
> >The fix is to make sure that the calls from the ERP thread to
> >the SCSI stack do not block the ERP thread. In detail:
> >1) Use a workqueue to avoid blocking of the scsi_scan_target calls.
> >2) When removing a unit make sure that no scsi_scan_target call is
> >   pending.
> >3) Replace scsi_flush_work with scsi_target_unblock. This avoids
> >   blocking and has the same result.

Reading the patch again, I think there is still a race:

> >+static void zfcp_erp_scsi_scan(struct work_struct *work)
> >+{
> >+struct zfcp_erp_add_work *p =
> >+container_of(work, struct zfcp_erp_add_work, work);
> >+struct zfcp_unit *unit = p->unit;
> >+struct fc_rport *rport = unit->port->rport;
> >+scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
> >+ unit->scsi_lun, 0);
> >+atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
> >+wake_up(&unit->scsi_scan_wq);
> >+zfcp_unit_put(unit);
> >+kfree(p);

This function gets executed via schedule_work() and therefore there is
nothing that prevents the rport to go. E.g. the following might happen:
function gets enqueued for execution via schedule_work(), adapter gets
shut down, call to fc_remort_port_delete(), port->rport gets deleted,
then zfcp_erp_scsi_scan() gets called and tries to derefence port->rport
which is NULL. Addressing exception is the result.

The patch below should fix that, but it changes the call from
scsi_scan_target() to scsi_add_device(). I think that should be ok.

Not-yet-signed-off-by: Heiko Carstens <[EMAIL PROTECTED]>
---
 drivers/s390/scsi/zfcp_def.h |1 +
 drivers/s390/scsi/zfcp_erp.c |   37 +++--
 2 files changed, 20 insertions(+), 18 deletions(-)

Index: linux-2.6/drivers/s390/scsi/zfcp_def.h
===
--- linux-2.6.orig/drivers/s390/scsi/zfcp_def.h
+++ linux-2.6/drivers/s390/scsi/zfcp_def.h
@@ -961,6 +961,7 @@ struct zfcp_port {
 atomic_t   erp_counter;
u32maxframe_size;
u32supported_classes;
+   unsigned int   scsi_target_id;
 };
 
 /* the struct device sysfs_device must be at the beginning of this structure.
Index: linux-2.6/drivers/s390/scsi/zfcp_erp.c
===
--- linux-2.6.orig/drivers/s390/scsi/zfcp_erp.c
+++ linux-2.6/drivers/s390/scsi/zfcp_erp.c
@@ -1591,7 +1591,7 @@ zfcp_erp_strategy_check_adapter(struct z
 }
 
 struct zfcp_erp_add_work {
-   struct zfcp_unit  *unit;
+   struct zfcp_unit *unit;
struct work_struct work;
 };
 
@@ -1603,15 +1603,14 @@ struct zfcp_erp_add_work {
  */
 static void zfcp_erp_scsi_scan(struct work_struct *work)
 {
-   struct zfcp_erp_add_work *p =
-   container_of(work, struct zfcp_erp_add_work, work);
-   struct zfcp_unit *unit = p->unit;
-   struct fc_rport *rport = unit->port->rport;
-   scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
-unit->scsi_lun, 0);
-   atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
-   wake_up(&unit->scsi_scan_wq);
-   zfcp_unit_put(unit);
+   struct zfcp_erp_add_work *p;
+
+   p = container_of(work, struct zfcp_erp_add_work, work);
+   scsi_add_device(p->unit->port->adapter->scsi_host, 0,
+   p->unit->port->scsi_target_id, p->unit->scsi_lun);
+   atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &p->unit->status);
+   wake_up(&p->unit->scsi_scan_wq);
+   zfcp_unit_put(p->unit);
kfree(p);
 }
 
@@ -3161,25 +3160,27 @@ zfcp_erp_action_cleanup(int action, stru
break;
}
 
-   if ((result == ZFCP_ERP_SUCCEEDED)
-   && !port->rport) {
+   if ((result == ZFCP_ERP_SUCCEEDED) && !port->rport) {
struct fc_rport_identifiers ids;
+   struct fc_rport *rport;
+
ids.node_name = port->wwnn;
ids.port_name = port->wwpn;
ids.port_id = port->d_id;
ids.roles = FC_RPORT_ROLE_FCP_TARGET;
-   po

Re: [PATCH v2] add bidi support for block pc requests

2007-05-10 Thread FUJITA Tomonori
From: FUJITA Tomonori <[EMAIL PROTECTED]>
Subject: Re: [PATCH v2] add bidi support for block pc requests
Date: Thu, 10 May 2007 15:53:22 +0900

> From: Boaz Harrosh <[EMAIL PROTECTED]>
> Subject: Re: [PATCH v2] add bidi support for block pc requests
> Date: Wed, 09 May 2007 19:54:32 +0300
> 
> > James Bottomley wrote:
> > > Actually, the first order of business is to use accessors on the command
> > > pointers in the drivers to free them from the internal layout of the
> > > structure (and where it is allocated).
> > > 
> > Thanks! I totally second that. Let me look into my old patches and come
> > up with all the needed accessors. I hope 3-5 will be enough.
> > I will send some suggestions tomorrow.
> > > 
> > > No, that's why you do the accessors.  Convert all of the common drivers
> > > to accessors on the current structure, then throw the switch to convert
> > > to the new structure (whatever form is finally settled on).  Then any
> > > unconverted drivers break and people fix the ones they care about.
> > 
> > Last time I was able to compile 97% of drivers and convert by 
> > search-and-replace
> > the rest. Not a huge deal.
> 
> We need to remove the non-use-sg code in the drivers and convert
> them. So it's a bit more complicated than search-and-replace.

Here's a patch to convert ibmvscsi to use helper functions (though it
needs more testings).

---
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index fbc1d5c..fb764ff 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -353,20 +353,18 @@ static void unmap_cmd_data(struct srp_cm
}
 }
 
-static int map_sg_list(int num_entries, 
-  struct scatterlist *sg,
-  struct srp_direct_buf *md)
+static int map_sg_list(struct scsi_cmnd *cmd, int nseg, struct srp_direct_buf 
*md)
 {
int i;
+   struct scatterlist *sg;
u64 total_length = 0;
 
-   for (i = 0; i < num_entries; ++i) {
+   scsi_for_each_sg(cmd, nseg, i) {
struct srp_direct_buf *descr = md + i;
-   struct scatterlist *sg_entry = &sg[i];
-   descr->va = sg_dma_address(sg_entry);
-   descr->len = sg_dma_len(sg_entry);
+   descr->va = sg_dma_address(sg);
+   descr->len = sg_dma_len(sg);
descr->key = 0;
-   total_length += sg_dma_len(sg_entry);
+   total_length += sg_dma_len(sg);
}
return total_length;
 }
@@ -384,43 +382,39 @@ static int map_sg_data(struct scsi_cmnd
   struct srp_event_struct *evt_struct,
   struct srp_cmd *srp_cmd, struct device *dev)
 {
-
int sg_mapped;
u64 total_length = 0;
-   struct scatterlist *sg = cmd->request_buffer;
struct srp_direct_buf *data =
(struct srp_direct_buf *) srp_cmd->add_data;
struct srp_indirect_buf *indirect =
(struct srp_indirect_buf *) data;
 
-   sg_mapped = dma_map_sg(dev, sg, cmd->use_sg, DMA_BIDIRECTIONAL);
-
-   if (sg_mapped == 0)
+   sg_mapped = scsi_dma_map(dev, cmd);
+   if (!sg_mapped)
+   return 1;
+   else if (sg_mapped < 0)
return 0;
+   else if (sg_mapped > SG_ALL) {
+   printk(KERN_ERR
+  "ibmvscsi: More than %d mapped sg entries, got %d\n",
+  SG_ALL, sg_mapped);
+   return 0;
+   }
 
set_srp_direction(cmd, srp_cmd, sg_mapped);
 
/* special case; we can use a single direct descriptor */
if (sg_mapped == 1) {
-   data->va = sg_dma_address(&sg[0]);
-   data->len = sg_dma_len(&sg[0]);
-   data->key = 0;
+   map_sg_list(cmd, sg_mapped, data);
return 1;
}
 
-   if (sg_mapped > SG_ALL) {
-   printk(KERN_ERR
-  "ibmvscsi: More than %d mapped sg entries, got %d\n",
-  SG_ALL, sg_mapped);
-   return 0;
-   }
-
indirect->table_desc.va = 0;
indirect->table_desc.len = sg_mapped * sizeof(struct srp_direct_buf);
indirect->table_desc.key = 0;
 
if (sg_mapped <= MAX_INDIRECT_BUFS) {
-   total_length = map_sg_list(sg_mapped, sg,
+   total_length = map_sg_list(cmd, sg_mapped,
   &indirect->desc_list[0]);
indirect->len = total_length;
return 1;
@@ -429,61 +423,27 @@ static int map_sg_data(struct scsi_cmnd
/* get indirect table */
if (!evt_struct->ext_list) {
evt_struct->ext_list = (struct srp_direct_buf *)
-   dma_alloc_coherent(dev, 
+   dma_alloc_coherent(dev,
   SG_ALL * sizeof(struct 
srp_direct_buf),
   &evt_struct->ext_list_t