All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Cleanup struct Scsi_Host
@ 2013-05-06  7:20 Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 1/5] scsi: remove 'resetting' field from " Hannes Reinecke
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

The 'Scsi_Host' structure has two fields 'resetting' and
'last_reset' which are basically unused. There are only
4 drivers referencing 'last_reset' (dpt_i2o, tmscsim, dc395, and advansys),
and only dpt_i2o makes usage of both fields.
However, dpt_i2o does _not_ require a delay after reset,
so even there the usage is questionable.

So move the 'last_reset' field into the internal host
structure where needed and remove both fields from
struct Scsi_Host.

Hannes Reinecke (5):
  scsi: remove 'resetting' field from struct Scsi_Host
  tmscsim: Move 'last_reset' into host structure
  dc395: Move 'last_reset' into internal host structure
  advansys: Remove references to 'last_reset'
  scsi: Remove 'last_reset' for struct Scsi_Host

 drivers/scsi/advansys.c  |  8 ++++----
 drivers/scsi/dc395x.c    | 24 +++++++++++++-----------
 drivers/scsi/dpt_i2o.c   | 22 +++-------------------
 drivers/scsi/scsi.c      | 25 +------------------------
 drivers/scsi/tmscsim.c   | 12 ++++++------
 drivers/scsi/tmscsim.h   |  1 +
 include/scsi/scsi_host.h |  4 +---
 7 files changed, 29 insertions(+), 67 deletions(-)

-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] scsi: remove 'resetting' field from struct Scsi_Host
  2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
@ 2013-05-06  7:20 ` Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 2/5] tmscsim: Move 'last_reset' into host structure Hannes Reinecke
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

struct Scsi_Host has a field 'resetting' which is only ever used
in dpt_i2o. And even there the usage is questionable.
So remove the field and have dpt_i2o use the standard mechanism
for delaying I/O.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/dpt_i2o.c   | 22 +++-------------------
 drivers/scsi/scsi.c      | 25 +------------------------
 include/scsi/scsi_host.h |  1 -
 3 files changed, 4 insertions(+), 44 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 19e1b42..943d9c0 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -448,18 +448,8 @@ static int adpt_queue_lck(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd
 	}
 
 	rmb();
-	/*
-	 * TODO: I need to block here if I am processing ioctl cmds
-	 * but if the outstanding cmds all finish before the ioctl,
-	 * the scsi-core will not know to start sending cmds to me again.
-	 * I need to a way to restart the scsi-cores queues or should I block
-	 * calling scsi_done on the outstanding cmds instead
-	 * for now we don't set the IOCTL state
-	 */
-	if(((pHba->state) & DPTI_STATE_IOCTL) || ((pHba->state) & DPTI_STATE_RESET)) {
-		pHba->host->last_reset = jiffies;
-		pHba->host->resetting = 1;
-		return 1;
+	if(((pHba->state) & DPTI_STATE_RESET)) {
+		return SCSI_MLQUEUE_HOST_BUSY;
 	}
 
 	// TODO if the cmd->device if offline then I may need to issue a bus rescan
@@ -1813,19 +1803,13 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg)
 	do {
 		if(pHba->host)
 			spin_lock_irqsave(pHba->host->host_lock, flags);
-		// This state stops any new commands from enterring the
-		// controller while processing the ioctl
-//		pHba->state |= DPTI_STATE_IOCTL;
-//		We can't set this now - The scsi subsystem sets host_blocked and
-//		the queue empties and stops.  We need a way to restart the queue
 		rcode = adpt_i2o_post_wait(pHba, msg, size, FOREVER);
 		if (rcode != 0)
 			printk("adpt_i2o_passthru: post wait failed %d %p\n",
 					rcode, reply);
-//		pHba->state &= ~DPTI_STATE_IOCTL;
 		if(pHba->host)
 			spin_unlock_irqrestore(pHba->host->host_lock, flags);
-	} while(rcode == -ETIMEDOUT);  
+	} while(rcode == -ETIMEDOUT);
 
 	if(rcode){
 		goto cleanup;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2c0d0ec..173c6bc 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -658,7 +658,6 @@ EXPORT_SYMBOL(scsi_cmd_get_serial);
 int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *host = cmd->device->host;
-	unsigned long timeout;
 	int rtn = 0;
 
 	atomic_inc(&cmd->device->iorequest_cnt);
@@ -695,7 +694,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 		goto out;
 	}
 
-	/* 
+	/*
 	 * If SCSI-2 or lower, store the LUN value in cmnd.
 	 */
 	if (cmd->device->scsi_level <= SCSI_2 &&
@@ -704,28 +703,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 			       (cmd->device->lun << 5 & 0xe0);
 	}
 
-	/*
-	 * We will wait MIN_RESET_DELAY clock ticks after the last reset so
-	 * we can avoid the drive not being ready.
-	 */
-	timeout = host->last_reset + MIN_RESET_DELAY;
-
-	if (host->resetting && time_before(jiffies, timeout)) {
-		int ticks_remaining = timeout - jiffies;
-		/*
-		 * NOTE: This may be executed from within an interrupt
-		 * handler!  This is bad, but for now, it'll do.  The irq
-		 * level of the interrupt handler has been masked out by the
-		 * platform dependent interrupt handling code already, so the
-		 * sti() here will not cause another call to the SCSI host's
-		 * interrupt handler (assuming there is one irq-level per
-		 * host).
-		 */
-		while (--ticks_remaining >= 0)
-			mdelay(1 + 999 / HZ);
-		host->resetting = 0;
-	}
-
 	scsi_log_send(cmd);
 
 	/*
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7552435..af7ad0e 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -598,7 +598,6 @@ struct Scsi_Host {
 	unsigned int host_eh_scheduled;    /* EH scheduled without command */
     
 	unsigned int host_no;  /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
-	int resetting; /* if set, it means that last_reset is a valid value */
 	unsigned long last_reset;
 
 	/*
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] tmscsim: Move 'last_reset' into host structure
  2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 1/5] scsi: remove 'resetting' field from " Hannes Reinecke
@ 2013-05-06  7:20 ` Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 3/5] dc395: Move 'last_reset' into internal " Hannes Reinecke
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

The 'last_reset' value is only used internally, so move it into
the internal host structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/tmscsim.c | 12 ++++++------
 drivers/scsi/tmscsim.h |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 9327f5f..ec74087 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -521,7 +521,7 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_sr
 	pACB->SelConn++;
 	return 1;
     }
-    if (time_before (jiffies, pACB->pScsiHost->last_reset))
+    if (time_before (jiffies, pACB->last_reset))
     {
 	DEBUG0(printk ("DC390: We were just reset and don't accept commands yet!\n"));
 	return 1;
@@ -1863,7 +1863,7 @@ dc390_ScsiRstDetect( struct dc390_acb* pACB )
     /* delay half a second */
     udelay (1000);
     DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    pACB->pScsiHost->last_reset = jiffies + 5*HZ/2
+    pACB->last_reset = jiffies + 5*HZ/2
 		    + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
     pACB->Connected = 0;
 
@@ -2048,7 +2048,7 @@ static int DC390_bus_reset (struct scsi_cmnd *cmd)
 
 	dc390_ResetDevParam(pACB);
 	mdelay(1);
-	pACB->pScsiHost->last_reset = jiffies + 3*HZ/2 
+	pACB->last_reset = jiffies + 3*HZ/2 
 		+ HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
     
 	DC390_write8(ScsiCmd, CLEAR_FIFO_CMD);
@@ -2383,7 +2383,7 @@ static void dc390_init_hw(struct dc390_acb *pACB, u8 index)
 	if (pACB->Gmode2 & RST_SCSI_BUS) {
 		dc390_ResetSCSIBus(pACB);
 		udelay(1000);
-		shost->last_reset = jiffies + HZ/2 +
+		pACB->last_reset = jiffies + HZ/2 +
 			HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
 	}
 
@@ -2455,8 +2455,8 @@ static int dc390_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	shost->irq = pdev->irq;
 	shost->base = io_port;
 	shost->unique_id = io_port;
-	shost->last_reset = jiffies;
-	
+
+	pACB->last_reset = jiffies;
 	pACB->pScsiHost = shost;
 	pACB->IOPortBase = (u16) io_port;
 	pACB->IRQLevel = pdev->irq;
diff --git a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
index 77adc54..3d1bb4a 100644
--- a/drivers/scsi/tmscsim.h
+++ b/drivers/scsi/tmscsim.h
@@ -143,6 +143,7 @@ u8		Ignore_IRQ;	/* Not used */
 
 struct pci_dev	*pdev;
 
+unsigned long   last_reset;
 unsigned long	Cmds;
 u32		SelLost;
 u32		SelConn;
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] dc395: Move 'last_reset' into internal host structure
  2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 1/5] scsi: remove 'resetting' field from " Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 2/5] tmscsim: Move 'last_reset' into host structure Hannes Reinecke
@ 2013-05-06  7:20 ` Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 4/5] advansys: Remove references to 'last_reset' Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 5/5] scsi: Remove 'last_reset' for struct Scsi_Host Hannes Reinecke
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

'last_reset' is only used internally, so move it into the
internal host structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/dc395x.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 694e13c..42e8624 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -308,6 +308,8 @@ struct AdapterCtlBlk {
 	struct timer_list waiting_timer;
 	struct timer_list selto_timer;
 
+	unsigned long last_reset;
+
 	u16 srb_count;
 
 	u8 sel_timeout;
@@ -860,9 +862,9 @@ static void waiting_set_timer(struct AdapterCtlBlk *acb, unsigned long to)
 	init_timer(&acb->waiting_timer);
 	acb->waiting_timer.function = waiting_timeout;
 	acb->waiting_timer.data = (unsigned long) acb;
-	if (time_before(jiffies + to, acb->scsi_host->last_reset - HZ / 2))
+	if (time_before(jiffies + to, acb->last_reset - HZ / 2))
 		acb->waiting_timer.expires =
-		    acb->scsi_host->last_reset - HZ / 2 + 1;
+		    acb->last_reset - HZ / 2 + 1;
 	else
 		acb->waiting_timer.expires = jiffies + to + 1;
 	add_timer(&acb->waiting_timer);
@@ -1319,7 +1321,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	udelay(500);
 
 	/* We may be in serious trouble. Wait some seconds */
-	acb->scsi_host->last_reset =
+	acb->last_reset =
 	    jiffies + 3 * HZ / 2 +
 	    HZ * acb->eeprom.delay_time;
 
@@ -1462,9 +1464,9 @@ static void selto_timer(struct AdapterCtlBlk *acb)
 	acb->selto_timer.function = selection_timeout_missed;
 	acb->selto_timer.data = (unsigned long) acb;
 	if (time_before
-	    (jiffies + HZ, acb->scsi_host->last_reset + HZ / 2))
+	    (jiffies + HZ, acb->last_reset + HZ / 2))
 		acb->selto_timer.expires =
-		    acb->scsi_host->last_reset + HZ / 2 + 1;
+		    acb->last_reset + HZ / 2 + 1;
 	else
 		acb->selto_timer.expires = jiffies + HZ + 1;
 	add_timer(&acb->selto_timer);
@@ -1535,7 +1537,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb,
 	}
 	/* Allow starting of SCSI commands half a second before we allow the mid-level
 	 * to queue them again after a reset */
-	if (time_before(jiffies, acb->scsi_host->last_reset - HZ / 2)) {
+	if (time_before(jiffies, acb->last_reset - HZ / 2)) {
 		dprintkdbg(DBG_KG, "start_scsi: Refuse cmds (reset wait)\n");
 		return 1;
 	}
@@ -3031,7 +3033,7 @@ static void disconnect(struct AdapterCtlBlk *acb)
 		dprintkl(KERN_ERR, "disconnect: No such device\n");
 		udelay(500);
 		/* Suspend queue for a while */
-		acb->scsi_host->last_reset =
+		acb->last_reset =
 		    jiffies + HZ / 2 +
 		    HZ * acb->eeprom.delay_time;
 		clear_fifo(acb, "disconnectEx");
@@ -3053,7 +3055,7 @@ static void disconnect(struct AdapterCtlBlk *acb)
 		waiting_process_next(acb);
 	} else if (srb->state & SRB_ABORT_SENT) {
 		dcb->flag &= ~ABORT_DEV_;
-		acb->scsi_host->last_reset = jiffies + HZ / 2 + 1;
+		acb->last_reset = jiffies + HZ / 2 + 1;
 		dprintkl(KERN_ERR, "disconnect: SRB_ABORT_SENT\n");
 		doing_srb_done(acb, DID_ABORT, srb->cmd, 1);
 		waiting_process_next(acb);
@@ -3649,7 +3651,7 @@ static void scsi_reset_detect(struct AdapterCtlBlk *acb)
 	/*DC395x_write8(acb, TRM_S1040_DMA_CONTROL,STOPDMAXFER); */
 	udelay(500);
 	/* Maybe we locked up the bus? Then lets wait even longer ... */
-	acb->scsi_host->last_reset =
+	acb->last_reset =
 	    jiffies + 5 * HZ / 2 +
 	    HZ * acb->eeprom.delay_time;
 
@@ -4426,7 +4428,7 @@ static void adapter_init_scsi_host(struct Scsi_Host *host)
 	host->dma_channel = -1;
 	host->unique_id = acb->io_port_base;
 	host->irq = acb->irq_level;
-	host->last_reset = jiffies;
+	acb->last_reset = jiffies;
 
 	host->max_id = 16;
 	if (host->max_id - 1 == eeprom->scsi_id)
@@ -4484,7 +4486,7 @@ static void adapter_init_chip(struct AdapterCtlBlk *acb)
 		/*spin_unlock_irq (&io_request_lock); */
 		udelay(500);
 
-		acb->scsi_host->last_reset =
+		acb->last_reset =
 		    jiffies + HZ / 2 +
 		    HZ * acb->eeprom.delay_time;
 
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] advansys: Remove references to 'last_reset'
  2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
                   ` (2 preceding siblings ...)
  2013-05-06  7:20 ` [PATCH 3/5] dc395: Move 'last_reset' into internal " Hannes Reinecke
@ 2013-05-06  7:20 ` Hannes Reinecke
  2013-05-06  7:20 ` [PATCH 5/5] scsi: Remove 'last_reset' for struct Scsi_Host Hannes Reinecke
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

The 'last_reset' field is only displayed in logging messages but
never actually used. Remove references to it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index c67e401..d814588 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2511,8 +2511,8 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
 	struct asc_board *boardp = shost_priv(s);
 
 	printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
-	printk(" host_busy %u, host_no %d, last_reset %d,\n",
-	       s->host_busy, s->host_no, (unsigned)s->last_reset);
+	printk(" host_busy %u, host_no %d,\n",
+	       s->host_busy, s->host_no);
 
 	printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
 	       (ulong)s->base, (ulong)s->io_port, boardp->irq);
@@ -3345,8 +3345,8 @@ static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost)
 		shost->host_no);
 
 	seq_printf(m,
-		   " host_busy %u, last_reset %lu, max_id %u, max_lun %u, max_channel %u\n",
-		   shost->host_busy, shost->last_reset, shost->max_id,
+		   " host_busy %u, max_id %u, max_lun %u, max_channel %u\n",
+		   shost->host_busy, shost->max_id,
 		   shost->max_lun, shost->max_channel);
 
 	seq_printf(m,
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] scsi: Remove 'last_reset' for struct Scsi_Host
  2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
                   ` (3 preceding siblings ...)
  2013-05-06  7:20 ` [PATCH 4/5] advansys: Remove references to 'last_reset' Hannes Reinecke
@ 2013-05-06  7:20 ` Hannes Reinecke
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2013-05-06  7:20 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke

Field is now unused, so remove it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/scsi/scsi_host.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index af7ad0e..dcf17dc 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -596,9 +596,8 @@ struct Scsi_Host {
 	unsigned int host_busy;		   /* commands actually active on low-level */
 	unsigned int host_failed;	   /* commands that failed. */
 	unsigned int host_eh_scheduled;    /* EH scheduled without command */
-    
+
 	unsigned int host_no;  /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
-	unsigned long last_reset;
 
 	/*
 	 * These three parameters can be used to allow for wide scsi,
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-06  7:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06  7:20 [PATCH 0/5] Cleanup struct Scsi_Host Hannes Reinecke
2013-05-06  7:20 ` [PATCH 1/5] scsi: remove 'resetting' field from " Hannes Reinecke
2013-05-06  7:20 ` [PATCH 2/5] tmscsim: Move 'last_reset' into host structure Hannes Reinecke
2013-05-06  7:20 ` [PATCH 3/5] dc395: Move 'last_reset' into internal " Hannes Reinecke
2013-05-06  7:20 ` [PATCH 4/5] advansys: Remove references to 'last_reset' Hannes Reinecke
2013-05-06  7:20 ` [PATCH 5/5] scsi: Remove 'last_reset' for struct Scsi_Host Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.