Commit 7dde47cc authored by Jeff Garzik's avatar Jeff Garzik Committed by James Bottomley

[PATCH] add ssleep(), kill scsi_sleep()

So, the kernel needs a 'sleep', but that token is far too common, so I
chose ssleep().

scsi_sleep() is a manually implemented msleep(), so I remove it.
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent fb62897b
......@@ -44,6 +44,7 @@
#include <linux/spinlock.h>
#include <linux/syscalls.h>
#include <linux/ioctl32.h>
#include <linux/delay.h>
#include <asm/semaphore.h>
#include <scsi/scsi.h>
......@@ -430,7 +431,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
if (active == 0)
return SUCCESS;
spin_unlock_irq(host->host_lock);
scsi_sleep(HZ);
ssleep(1);
spin_lock_irq(host->host_lock);
}
printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME);
......
......@@ -1479,7 +1479,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
* we are pretty desperate anyways.
*/
spin_unlock_irq(SCpnt->device->host->host_lock);
scsi_sleep(4 * HZ);
ssleep(4);
spin_lock_irq(SCpnt->device->host->host_lock);
WAIT(STATUS(SCpnt->device->host->io_port),
......@@ -1543,7 +1543,7 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
* we are pretty desperate anyways.
*/
spin_unlock_irq(SCpnt->device->host->host_lock);
scsi_sleep(4 * HZ);
ssleep(4);
spin_lock_irq(SCpnt->device->host->host_lock);
WAIT(STATUS(SCpnt->device->host->io_port),
......
......@@ -61,6 +61,7 @@
#endif
#include <linux/mm.h> /* For fetching system memory size */
#include <linux/delay.h> /* For ssleep/msleep */
/*
* Lock protecting manipulation of the ahd softc list.
......@@ -3160,7 +3161,7 @@ ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
break;
}
if (status & SSQ_DELAY)
scsi_sleep(1 * HZ);
ssleep(1);
break;
case SS_START:
......@@ -3320,7 +3321,7 @@ ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
}
if (targ->dv_state_retry <= 10) {
if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0)
scsi_sleep(ahd->our_id*HZ/10);
msleep(ahd->our_id*1000/10);
break;
}
#ifdef AHD_DEBUG
......@@ -3364,7 +3365,7 @@ ahd_linux_dv_transition(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
targ->dv_state_retry--;
} else if (targ->dv_state_retry < 60) {
if ((status & SSQ_DELAY) != 0)
scsi_sleep(1 * HZ);
ssleep(1);
} else {
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_DV) {
......
......@@ -140,6 +140,7 @@
#include <linux/mm.h> /* For fetching system memory size */
#include <linux/blkdev.h> /* For block_size() */
#include <linux/delay.h> /* For ssleep/msleep */
/*
* Lock protecting manipulation of the ahc softc list.
......@@ -2822,7 +2823,7 @@ ahc_linux_dv_transition(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
break;
}
if (status & SSQ_DELAY)
scsi_sleep(1 * HZ);
ssleep(1);
break;
case SS_START:
......@@ -2982,7 +2983,7 @@ ahc_linux_dv_transition(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
}
if (targ->dv_state_retry <= 10) {
if ((status & (SSQ_DELAY_RANDOM|SSQ_DELAY))!= 0)
scsi_sleep(ahc->our_id*HZ/10);
msleep(ahc->our_id*1000/10);
break;
}
#ifdef AHC_DEBUG
......@@ -3026,7 +3027,7 @@ ahc_linux_dv_transition(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
targ->dv_state_retry--;
} else if (targ->dv_state_retry < 60) {
if ((status & SSQ_DELAY) != 0)
scsi_sleep(1 * HZ);
ssleep(1);
} else {
#ifdef AHC_DEBUG
if (ahc_debug & AHC_SHOW_DV) {
......
......@@ -10489,7 +10489,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
aic_outb(p, lastphase | ATNO, SCSISIGO);
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
scsi_sleep(HZ);
ssleep(1);
spin_lock_irq(p->host->host_lock);
if(aic_dev->flags & BUS_DEVICE_RESET_PENDING)
return FAILED;
......@@ -10548,7 +10548,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
aic_outb(p, saved_scbptr, SCBPTR);
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
scsi_sleep(HZ/4);
msleep(1000/4);
spin_lock_irq(p->host->host_lock);
if(aic_dev->flags & BUS_DEVICE_RESET_PENDING)
return FAILED;
......@@ -10786,7 +10786,7 @@ aic7xxx_abort(Scsi_Cmnd *cmd)
}
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
scsi_sleep(HZ/4);
msleep(1000/4);
spin_lock_irq(p->host->host_lock);
if (p->flags & AHC_ABORT_PENDING)
{
......@@ -10887,7 +10887,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
aic7xxx_run_done_queue(p, TRUE);
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
scsi_sleep(2 * HZ);
ssleep(2);
spin_lock_irq(p->host->host_lock);
return SUCCESS;
}
......
......@@ -2681,7 +2681,7 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt)
* IRQs after the sleep.
*/
spin_unlock_irq(info->host->host_lock);
scsi_sleep(50 * HZ/100);
msleep(50 * 1000/100);
spin_lock_irq(info->host->host_lock);
/*
......@@ -2920,7 +2920,7 @@ int fas216_add(struct Scsi_Host *host, struct device *dev)
* scsi standard says wait 250ms
*/
spin_unlock_irq(info->host->host_lock);
scsi_sleep(100*HZ/100);
msleep(100*1000/100);
spin_lock_irq(info->host->host_lock);
fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]);
......
......@@ -23,6 +23,7 @@
#include <linux/interrupt.h>
#include <linux/blkdev.h>
#include <linux/smp_lock.h>
#include <linux/delay.h>
#include <scsi/scsi.h>
#include <scsi/scsi_dbg.h>
......@@ -42,8 +43,8 @@
* These should *probably* be handled by the host itself.
* Since it is allowed to sleep, it probably should.
*/
#define BUS_RESET_SETTLE_TIME (10*HZ)
#define HOST_RESET_SETTLE_TIME (10*HZ)
#define BUS_RESET_SETTLE_TIME (10)
#define HOST_RESET_SETTLE_TIME (10)
/* called with shost->host_lock held */
void scsi_eh_wakeup(struct Scsi_Host *shost)
......@@ -1044,7 +1045,7 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
if (rtn == SUCCESS) {
if (!scmd->device->host->hostt->skip_settle_delay)
scsi_sleep(BUS_RESET_SETTLE_TIME);
ssleep(BUS_RESET_SETTLE_TIME);
spin_lock_irqsave(scmd->device->host->host_lock, flags);
scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
......@@ -1076,7 +1077,7 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
if (rtn == SUCCESS) {
if (!scmd->device->host->hostt->skip_settle_delay)
scsi_sleep(HOST_RESET_SETTLE_TIME);
ssleep(HOST_RESET_SETTLE_TIME);
spin_lock_irqsave(scmd->device->host->host_lock, flags);
scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
......@@ -1215,43 +1216,6 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
return;
}
/**
* scsi_sleep_done - timer function for scsi_sleep
* @sem: semphore to signal
*
**/
static void scsi_sleep_done(unsigned long data)
{
struct semaphore *sem = (struct semaphore *)data;
if (sem)
up(sem);
}
/**
* scsi_sleep - sleep for specified timeout
* @timeout: timeout value
*
**/
void scsi_sleep(int timeout)
{
DECLARE_MUTEX_LOCKED(sem);
struct timer_list timer;
init_timer(&timer);
timer.data = (unsigned long)&sem;
timer.expires = jiffies + timeout;
timer.function = (void (*)(unsigned long))scsi_sleep_done;
SCSI_LOG_ERROR_RECOVERY(5, printk("sleeping for timer tics %d\n",
timeout));
add_timer(&timer);
down(&sem);
del_timer(&timer);
}
/**
* scsi_decide_disposition - Disposition a cmd on return from LLD.
* @scmd: SCSI cmd to examine.
......
......@@ -69,8 +69,6 @@ EXPORT_SYMBOL(scsi_track_queue_full);
EXPORT_SYMBOL(scsi_get_host_dev);
EXPORT_SYMBOL(scsi_free_host_dev);
EXPORT_SYMBOL(scsi_sleep);
EXPORT_SYMBOL(scsi_io_completion);
EXPORT_SYMBOL(scsi_add_device);
......
......@@ -47,8 +47,9 @@ static int sg_version_num = 30531; /* 2 digits for each component */
#include <linux/devfs_fs_kernel.h>
#include <linux/cdev.h>
#include <linux/seq_file.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
#include <scsi/scsi_driver.h>
......@@ -1533,7 +1534,7 @@ sg_remove(struct class_device *cl_dev)
}
if (delay)
scsi_sleep(2); /* dirty detach so delay device destruction */
msleep(10); /* dirty detach so delay device destruction */
}
/* Set 'perm' (4th argument) to 0 to disable module_param's definition
......
......@@ -7,6 +7,7 @@
#include <linux/blkdev.h>
#include <linux/blkpg.h>
#include <linux/cdrom.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/uaccess.h>
......@@ -131,7 +132,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
printk(KERN_INFO "%s: CDROM not ready yet.\n", cd->cdi.name);
if (retries++ < 10) {
/* sleep 2 sec and try again */
scsi_sleep(2 * HZ);
ssleep(2);
goto retry;
} else {
/* 20 secs are enough? */
......
......@@ -40,4 +40,9 @@ extern unsigned long loops_per_jiffy;
void msleep(unsigned int msecs);
static inline void ssleep(unsigned int seconds)
{
msleep(seconds * 1000);
}
#endif /* defined(_LINUX_DELAY_H) */
......@@ -11,7 +11,6 @@ extern int scsi_delete_timer(struct scsi_cmnd *);
extern void scsi_report_bus_reset(struct Scsi_Host *, int);
extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
extern int scsi_block_when_processing_errors(struct scsi_device *);
extern void scsi_sleep(int);
/*
* Reset request from external source
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment