From 6c93bf34d2f73130a3d86d22d3b7993aab088ee3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Apr 2005 14:52:44 -0500 Subject: [PATCH] --- yaml --- r: 205 b: refs/heads/master c: b6651129cc27d56a9cbefcb5f713cea7706fd6b7 h: refs/heads/master i: 203: 1034f2a7844647abe283533dfb7279b8304bbd23 v: v3 --- [refs] | 2 +- trunk/drivers/block/ll_rw_blk.c | 9 -- trunk/drivers/block/scsi_ioctl.c | 5 - trunk/drivers/s390/scsi/zfcp_aux.c | 34 +++-- trunk/drivers/scsi/53c700.c | 3 +- trunk/drivers/scsi/53c700.h | 192 ++++++++++++++++++++++++--- trunk/drivers/scsi/Kconfig | 10 ++ trunk/drivers/scsi/NCR_D700.c | 5 +- trunk/drivers/scsi/lasi700.c | 1 - trunk/drivers/scsi/scsi_ioctl.c | 5 - trunk/drivers/scsi/scsi_lib.c | 6 +- trunk/drivers/scsi/scsi_scan.c | 1 + trunk/drivers/scsi/scsi_sysfs.c | 3 - trunk/drivers/scsi/sg.c | 203 ++++++++++------------------- trunk/drivers/scsi/sim710.c | 5 +- trunk/include/linux/blkdev.h | 5 +- trunk/include/scsi/scsi.h | 9 ++ trunk/include/scsi/scsi_device.h | 2 +- 18 files changed, 298 insertions(+), 202 deletions(-) diff --git a/[refs] b/[refs] index 9a3b0921b9da..0d15ce345a5e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c2a9331c62216e222a08de8dd58559367fef0af6 +refs/heads/master: b6651129cc27d56a9cbefcb5f713cea7706fd6b7 diff --git a/trunk/drivers/block/ll_rw_blk.c b/trunk/drivers/block/ll_rw_blk.c index 11ef9d9ea139..46e54b441663 100644 --- a/trunk/drivers/block/ll_rw_blk.c +++ b/trunk/drivers/block/ll_rw_blk.c @@ -1715,15 +1715,6 @@ request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) if (blk_init_free_list(q)) goto out_init; - /* - * if caller didn't supply a lock, they get per-queue locking with - * our embedded lock - */ - if (!lock) { - spin_lock_init(&q->__queue_lock); - lock = &q->__queue_lock; - } - q->request_fn = rfn; q->back_merge_fn = ll_back_merge_fn; q->front_merge_fn = ll_front_merge_fn; diff --git a/trunk/drivers/block/scsi_ioctl.c b/trunk/drivers/block/scsi_ioctl.c index 689527a89de7..681871ca5d60 100644 --- a/trunk/drivers/block/scsi_ioctl.c +++ b/trunk/drivers/block/scsi_ioctl.c @@ -328,11 +328,6 @@ static int sg_io(struct file *file, request_queue_t *q, return 0; } -#define FORMAT_UNIT_TIMEOUT (2 * 60 * 60 * HZ) -#define START_STOP_TIMEOUT (60 * HZ) -#define MOVE_MEDIUM_TIMEOUT (5 * 60 * HZ) -#define READ_ELEMENT_STATUS_TIMEOUT (5 * 60 * HZ) -#define READ_DEFECT_DATA_TIMEOUT (60 * HZ ) #define OMAX_SB_LEN 16 /* For backward compatibility */ static int sg_scsi_ioctl(struct file *file, request_queue_t *q, diff --git a/trunk/drivers/s390/scsi/zfcp_aux.c b/trunk/drivers/s390/scsi/zfcp_aux.c index ce398aa9e019..6a43322ccb0a 100644 --- a/trunk/drivers/s390/scsi/zfcp_aux.c +++ b/trunk/drivers/s390/scsi/zfcp_aux.c @@ -52,18 +52,19 @@ static inline int zfcp_sg_list_copy_from_user(struct zfcp_sg_list *, static inline int zfcp_sg_list_copy_to_user(void __user *, struct zfcp_sg_list *, size_t); -static int zfcp_cfdc_dev_ioctl(struct file *, unsigned int, unsigned long); +static int zfcp_cfdc_dev_ioctl(struct inode *, struct file *, + unsigned int, unsigned long); #define ZFCP_CFDC_IOC_MAGIC 0xDD #define ZFCP_CFDC_IOC \ _IOWR(ZFCP_CFDC_IOC_MAGIC, 0, struct zfcp_cfdc_sense_data) - -static struct file_operations zfcp_cfdc_fops = { - .unlocked_ioctl = zfcp_cfdc_dev_ioctl, #ifdef CONFIG_COMPAT - .compat_ioctl = zfcp_cfdc_dev_ioctl +static struct ioctl_trans zfcp_ioctl_trans = {ZFCP_CFDC_IOC, (void*) sys_ioctl}; #endif + +static struct file_operations zfcp_cfdc_fops = { + .ioctl = zfcp_cfdc_dev_ioctl }; static struct miscdevice zfcp_cfdc_misc = { @@ -307,16 +308,23 @@ zfcp_module_init(void) if (!zfcp_transport_template) return -ENODEV; + retval = register_ioctl32_conversion(zfcp_ioctl_trans.cmd, + zfcp_ioctl_trans.handler); + if (retval != 0) { + ZFCP_LOG_INFO("registration of ioctl32 conversion failed\n"); + goto out; + } + retval = misc_register(&zfcp_cfdc_misc); if (retval != 0) { ZFCP_LOG_INFO("registration of misc device " "zfcp_cfdc failed\n"); - goto out; + goto out_misc_register; + } else { + ZFCP_LOG_TRACE("major/minor for zfcp_cfdc: %d/%d\n", + ZFCP_CFDC_DEV_MAJOR, zfcp_cfdc_misc.minor); } - ZFCP_LOG_TRACE("major/minor for zfcp_cfdc: %d/%d\n", - ZFCP_CFDC_DEV_MAJOR, zfcp_cfdc_misc.minor); - /* Initialise proc semaphores */ sema_init(&zfcp_data.config_sema, 1); @@ -340,6 +348,8 @@ zfcp_module_init(void) out_ccw_register: misc_deregister(&zfcp_cfdc_misc); + out_misc_register: + unregister_ioctl32_conversion(zfcp_ioctl_trans.cmd); out: return retval; } @@ -360,9 +370,9 @@ zfcp_module_init(void) * -EPERM - Cannot create or queue FSF request or create SBALs * -ERESTARTSYS- Received signal (is mapped to EAGAIN by VFS) */ -static long -zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command, - unsigned long buffer) +static int +zfcp_cfdc_dev_ioctl(struct inode *inode, struct file *file, + unsigned int command, unsigned long buffer) { struct zfcp_cfdc_sense_data *sense_data, __user *sense_data_user; struct zfcp_adapter *adapter = NULL; diff --git a/trunk/drivers/scsi/53c700.c b/trunk/drivers/scsi/53c700.c index 4b1bb529f676..a591fcb8aab1 100644 --- a/trunk/drivers/scsi/53c700.c +++ b/trunk/drivers/scsi/53c700.c @@ -389,7 +389,8 @@ NCR_700_detect(struct scsi_host_template *tpnt, host->max_lun = NCR_700_MAX_LUNS; BUG_ON(NCR_700_transport_template == NULL); host->transportt = NCR_700_transport_template; - host->unique_id = (unsigned long)hostdata->base; + host->unique_id = hostdata->base; + host->base = hostdata->base; hostdata->eh_complete = NULL; host->hostdata[0] = (unsigned long)hostdata; /* kick the chip */ diff --git a/trunk/drivers/scsi/53c700.h b/trunk/drivers/scsi/53c700.h index e86012cf6ab7..df4aa30ae0aa 100644 --- a/trunk/drivers/scsi/53c700.h +++ b/trunk/drivers/scsi/53c700.h @@ -14,6 +14,10 @@ #include +#if defined(CONFIG_53C700_MEM_MAPPED) && defined(CONFIG_53C700_IO_MAPPED) +#define CONFIG_53C700_BOTH_MAPPED +#endif + /* Turn on for general debugging---too verbose for normal use */ #undef NCR_700_DEBUG /* Debug the tag queues, checking hash queue allocation and deallocation @@ -45,6 +49,13 @@ /* magic byte identifying an internally generated REQUEST_SENSE command */ #define NCR_700_INTERNAL_SENSE_MAGIC 0x42 +/* WARNING: Leave this in for now: the dependency preprocessor doesn't + * pick up file specific flags, so must define here if they are not + * set */ +#if !defined(CONFIG_53C700_IO_MAPPED) && !defined(CONFIG_53C700_MEM_MAPPED) +#error "Config.in must define either CONFIG_53C700_IO_MAPPED or CONFIG_53C700_MEM_MAPPED to use this scsi core." +#endif + struct NCR_700_Host_Parameters; /* These are the externally used routines */ @@ -173,7 +184,7 @@ struct NCR_700_command_slot { struct NCR_700_Host_Parameters { /* These must be filled in by the calling driver */ int clock; /* board clock speed in MHz */ - void __iomem *base; /* the base for the port (copied to host) */ + unsigned long base; /* the base for the port (copied to host) */ struct device *dev; __u32 dmode_extra; /* adjustable bus settings */ __u32 differential:1; /* if we are differential */ @@ -188,6 +199,9 @@ struct NCR_700_Host_Parameters { /* NOTHING BELOW HERE NEEDS ALTERING */ __u32 fast:1; /* if we can alter the SCSI bus clock speed (so can negiotiate sync) */ +#ifdef CONFIG_53C700_BOTH_MAPPED + __u32 mem_mapped; /* set if memory mapped */ +#endif int sync_clock; /* The speed of the SYNC core */ __u32 *script; /* pointer to script location */ @@ -232,18 +246,12 @@ struct NCR_700_Host_Parameters { #ifdef CONFIG_53C700_LE_ON_BE #define bE (hostdata->force_le_on_be ? 0 : 3) #define bSWAP (hostdata->force_le_on_be) -/* This is terrible, but there's no raw version of ioread32. That means - * that on a be board we swap twice (once in ioread32 and once again to - * get the value correct) */ -#define bS_to_io(x) ((hostdata->force_le_on_be) ? (x) : cpu_to_le32(x)) #elif defined(__BIG_ENDIAN) #define bE 3 #define bSWAP 0 -#define bS_to_io(x) (x) #elif defined(__LITTLE_ENDIAN) #define bE 0 #define bSWAP 0 -#define bS_to_io(x) (x) #else #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?" #endif @@ -447,42 +455,91 @@ struct NCR_700_Host_Parameters { static inline __u8 -NCR_700_readb(struct Scsi_Host *host, __u32 reg) +NCR_700_mem_readb(struct Scsi_Host *host, __u32 reg) { - const struct NCR_700_Host_Parameters *hostdata + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) = (struct NCR_700_Host_Parameters *)host->hostdata[0]; - return ioread8(hostdata->base + (reg^bE)); + return readb(host->base + (reg^bE)); } static inline __u32 -NCR_700_readl(struct Scsi_Host *host, __u32 reg) +NCR_700_mem_readl(struct Scsi_Host *host, __u32 reg) { - const struct NCR_700_Host_Parameters *hostdata + __u32 value = __raw_readl(host->base + reg); + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) = (struct NCR_700_Host_Parameters *)host->hostdata[0]; - __u32 value = ioread32(hostdata->base + reg); #if 1 /* sanity check the register */ if((reg & 0x3) != 0) BUG(); #endif - return bS_to_io(value); + return bS_to_cpu(value); } static inline void -NCR_700_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) +NCR_700_mem_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) { - const struct NCR_700_Host_Parameters *hostdata + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) = (struct NCR_700_Host_Parameters *)host->hostdata[0]; - iowrite8(value, hostdata->base + (reg^bE)); + writeb(value, host->base + (reg^bE)); } static inline void -NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) +NCR_700_mem_writel(__u32 value, struct Scsi_Host *host, __u32 reg) +{ + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + +#if 1 + /* sanity check the register */ + if((reg & 0x3) != 0) + BUG(); +#endif + + __raw_writel(bS_to_host(value), host->base + reg); +} + +static inline __u8 +NCR_700_io_readb(struct Scsi_Host *host, __u32 reg) +{ + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + return inb(host->base + (reg^bE)); +} + +static inline __u32 +NCR_700_io_readl(struct Scsi_Host *host, __u32 reg) +{ + __u32 value = inl(host->base + reg); + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + +#if 1 + /* sanity check the register */ + if((reg & 0x3) != 0) + BUG(); +#endif + + return bS_to_cpu(value); +} + +static inline void +NCR_700_io_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) +{ + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + outb(value, host->base + (reg^bE)); +} + +static inline void +NCR_700_io_writel(__u32 value, struct Scsi_Host *host, __u32 reg) { - const struct NCR_700_Host_Parameters *hostdata + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) = (struct NCR_700_Host_Parameters *)host->hostdata[0]; #if 1 @@ -491,7 +548,102 @@ NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) BUG(); #endif - iowrite32(bS_to_io(value), hostdata->base + reg); + outl(bS_to_host(value), host->base + reg); +} + +#ifdef CONFIG_53C700_BOTH_MAPPED + +static inline __u8 +NCR_700_readb(struct Scsi_Host *host, __u32 reg) +{ + __u8 val; + + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + if(hostdata->mem_mapped) + val = NCR_700_mem_readb(host, reg); + else + val = NCR_700_io_readb(host, reg); + + return val; +} + +static inline __u32 +NCR_700_readl(struct Scsi_Host *host, __u32 reg) +{ + __u32 val; + + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + if(hostdata->mem_mapped) + val = NCR_700_mem_readl(host, reg); + else + val = NCR_700_io_readl(host, reg); + + return val; +} + +static inline void +NCR_700_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) +{ + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + if(hostdata->mem_mapped) + NCR_700_mem_writeb(value, host, reg); + else + NCR_700_io_writeb(value, host, reg); +} + +static inline void +NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) +{ + const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) + = (struct NCR_700_Host_Parameters *)host->hostdata[0]; + + if(hostdata->mem_mapped) + NCR_700_mem_writel(value, host, reg); + else + NCR_700_io_writel(value, host, reg); +} + +static inline void +NCR_700_set_mem_mapped(struct NCR_700_Host_Parameters *hostdata) +{ + hostdata->mem_mapped = 1; +} + +static inline void +NCR_700_set_io_mapped(struct NCR_700_Host_Parameters *hostdata) +{ + hostdata->mem_mapped = 0; } + +#elif defined(CONFIG_53C700_IO_MAPPED) + +#define NCR_700_readb NCR_700_io_readb +#define NCR_700_readl NCR_700_io_readl +#define NCR_700_writeb NCR_700_io_writeb +#define NCR_700_writel NCR_700_io_writel + +#define NCR_700_set_io_mapped(x) +#define NCR_700_set_mem_mapped(x) error I/O mapped only + +#elif defined(CONFIG_53C700_MEM_MAPPED) + +#define NCR_700_readb NCR_700_mem_readb +#define NCR_700_readl NCR_700_mem_readl +#define NCR_700_writeb NCR_700_mem_writeb +#define NCR_700_writel NCR_700_mem_writel + +#define NCR_700_set_io_mapped(x) error MEM mapped only +#define NCR_700_set_mem_mapped(x) + +#else +#error neither CONFIG_53C700_MEM_MAPPED nor CONFIG_53C700_IO_MAPPED is set +#endif + #endif diff --git a/trunk/drivers/scsi/Kconfig b/trunk/drivers/scsi/Kconfig index 718df4c6c3b2..d22b32f4662d 100644 --- a/trunk/drivers/scsi/Kconfig +++ b/trunk/drivers/scsi/Kconfig @@ -942,6 +942,11 @@ config SCSI_NCR_D700 Unless you have an NCR manufactured machine, the chances are that you do not have this SCSI card, so say N. +config 53C700_IO_MAPPED + bool + depends on SCSI_NCR_D700 + default y + config SCSI_LASI700 tristate "HP Lasi SCSI support for 53c700/710" depends on GSC && SCSI @@ -951,6 +956,11 @@ config SCSI_LASI700 many PA-RISC workstations & servers. If you do not know whether you have a Lasi chip, it is safe to say "Y" here. +config 53C700_MEM_MAPPED + bool + depends on SCSI_LASI700 + default y + config 53C700_LE_ON_BE bool depends on SCSI_LASI700 diff --git a/trunk/drivers/scsi/NCR_D700.c b/trunk/drivers/scsi/NCR_D700.c index e993a7ba276f..507751941f1e 100644 --- a/trunk/drivers/scsi/NCR_D700.c +++ b/trunk/drivers/scsi/NCR_D700.c @@ -197,10 +197,12 @@ NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq, } /* Fill in the three required pieces of hostdata */ - hostdata->base = ioport_map(region, 64); + hostdata->base = region; hostdata->differential = (((1<clock = NCR_D700_CLOCK_MHZ; + NCR_700_set_io_mapped(hostdata); + /* and register the siop */ host = NCR_700_detect(&NCR_D700_driver_template, hostdata, p->dev); if (!host) { @@ -212,7 +214,6 @@ NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq, /* FIXME: read this from SUS */ host->this_id = id_array[slot * 2 + siop]; host->irq = irq; - host->base = region; scsi_scan_host(host); return 0; diff --git a/trunk/drivers/scsi/lasi700.c b/trunk/drivers/scsi/lasi700.c index 4cbb6187cc44..29f250c80b98 100644 --- a/trunk/drivers/scsi/lasi700.c +++ b/trunk/drivers/scsi/lasi700.c @@ -131,7 +131,6 @@ lasi700_probe(struct parisc_device *dev) if (!host) goto out_kfree; host->this_id = 7; - host->base = base; host->irq = dev->irq; if(request_irq(dev->irq, NCR_700_intr, SA_SHIRQ, "lasi700", host)) { printk(KERN_ERR "lasi700: request_irq failed!\n"); diff --git a/trunk/drivers/scsi/scsi_ioctl.c b/trunk/drivers/scsi/scsi_ioctl.c index 68c9728dfbbb..7a6b530115ac 100644 --- a/trunk/drivers/scsi/scsi_ioctl.c +++ b/trunk/drivers/scsi/scsi_ioctl.c @@ -27,11 +27,6 @@ #define NORMAL_RETRIES 5 #define IOCTL_NORMAL_TIMEOUT (10 * HZ) -#define FORMAT_UNIT_TIMEOUT (2 * 60 * 60 * HZ) -#define START_STOP_TIMEOUT (60 * HZ) -#define MOVE_MEDIUM_TIMEOUT (5 * 60 * HZ) -#define READ_ELEMENT_STATUS_TIMEOUT (5 * 60 * HZ) -#define READ_DEFECT_DATA_TIMEOUT (60 * HZ ) /* ZIP-250 on parallel port takes as long! */ #define MAX_BUF PAGE_SIZE diff --git a/trunk/drivers/scsi/scsi_lib.c b/trunk/drivers/scsi/scsi_lib.c index d230c699c728..7cbc4127fb5a 100644 --- a/trunk/drivers/scsi/scsi_lib.c +++ b/trunk/drivers/scsi/scsi_lib.c @@ -360,9 +360,9 @@ void scsi_device_unbusy(struct scsi_device *sdev) shost->host_failed)) scsi_eh_wakeup(shost); spin_unlock(shost->host_lock); - spin_lock(sdev->request_queue->queue_lock); + spin_lock(&sdev->sdev_lock); sdev->device_busy--; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); + spin_unlock_irqrestore(&sdev->sdev_lock, flags); } /* @@ -1425,7 +1425,7 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) struct Scsi_Host *shost = sdev->host; struct request_queue *q; - q = blk_init_queue(scsi_request_fn, NULL); + q = blk_init_queue(scsi_request_fn, &sdev->sdev_lock); if (!q) return NULL; diff --git a/trunk/drivers/scsi/scsi_scan.c b/trunk/drivers/scsi/scsi_scan.c index 287d197a7c17..a8a37a338c02 100644 --- a/trunk/drivers/scsi/scsi_scan.c +++ b/trunk/drivers/scsi/scsi_scan.c @@ -249,6 +249,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, */ sdev->borken = 1; + spin_lock_init(&sdev->sdev_lock); sdev->request_queue = scsi_alloc_queue(sdev); if (!sdev->request_queue) { /* release fn is set up in scsi_sysfs_device_initialise, so diff --git a/trunk/drivers/scsi/scsi_sysfs.c b/trunk/drivers/scsi/scsi_sysfs.c index e75ee4671ee3..134d3a3e4222 100644 --- a/trunk/drivers/scsi/scsi_sysfs.c +++ b/trunk/drivers/scsi/scsi_sysfs.c @@ -171,9 +171,6 @@ void scsi_device_dev_release(struct device *dev) if (sdev->request_queue) { sdev->request_queue->queuedata = NULL; scsi_free_queue(sdev->request_queue); - /* temporary expedient, try to catch use of queue lock - * after free of sdev */ - sdev->request_queue = NULL; } scsi_target_reap(scsi_target(sdev)); diff --git a/trunk/drivers/scsi/sg.c b/trunk/drivers/scsi/sg.c index 32de9aabcb99..fd72d73bb244 100644 --- a/trunk/drivers/scsi/sg.c +++ b/trunk/drivers/scsi/sg.c @@ -18,8 +18,8 @@ * */ -static int sg_version_num = 30533; /* 2 digits for each component */ -#define SG_VERSION_STR "3.5.33" +static int sg_version_num = 30532; /* 2 digits for each component */ +#define SG_VERSION_STR "3.5.32" /* * D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au), notes: @@ -60,7 +60,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */ #ifdef CONFIG_SCSI_PROC_FS #include -static char *sg_version_date = "20050328"; +static char *sg_version_date = "20050117"; static int sg_proc_init(void); static void sg_proc_cleanup(void); @@ -330,13 +330,14 @@ sg_release(struct inode *inode, struct file *filp) static ssize_t sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) { + int res; Sg_device *sdp; Sg_fd *sfp; Sg_request *srp; int req_pack_id = -1; + struct sg_header old_hdr; + sg_io_hdr_t new_hdr; sg_io_hdr_t *hp; - struct sg_header *old_hdr = NULL; - int retval = 0; if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) return -ENXIO; @@ -345,138 +346,98 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) if (!access_ok(VERIFY_WRITE, buf, count)) return -EFAULT; if (sfp->force_packid && (count >= SZ_SG_HEADER)) { - old_hdr = kmalloc(SZ_SG_HEADER, GFP_KERNEL); - if (!old_hdr) - return -ENOMEM; - if (__copy_from_user(old_hdr, buf, SZ_SG_HEADER)) { - retval = -EFAULT; - goto free_old_hdr; - } - if (old_hdr->reply_len < 0) { + if (__copy_from_user(&old_hdr, buf, SZ_SG_HEADER)) + return -EFAULT; + if (old_hdr.reply_len < 0) { if (count >= SZ_SG_IO_HDR) { - sg_io_hdr_t *new_hdr; - new_hdr = kmalloc(SZ_SG_IO_HDR, GFP_KERNEL); - if (!new_hdr) { - retval = -ENOMEM; - goto free_old_hdr; - } - retval =__copy_from_user - (new_hdr, buf, SZ_SG_IO_HDR); - req_pack_id = new_hdr->pack_id; - kfree(new_hdr); - if (retval) { - retval = -EFAULT; - goto free_old_hdr; - } + if (__copy_from_user + (&new_hdr, buf, SZ_SG_IO_HDR)) + return -EFAULT; + req_pack_id = new_hdr.pack_id; } } else - req_pack_id = old_hdr->pack_id; + req_pack_id = old_hdr.pack_id; } srp = sg_get_rq_mark(sfp, req_pack_id); if (!srp) { /* now wait on packet to arrive */ - if (sdp->detached) { - retval = -ENODEV; - goto free_old_hdr; - } - if (filp->f_flags & O_NONBLOCK) { - retval = -EAGAIN; - goto free_old_hdr; - } + if (sdp->detached) + return -ENODEV; + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; while (1) { - retval = 0; /* following macro beats race condition */ + res = 0; /* following is a macro that beats race condition */ __wait_event_interruptible(sfp->read_wait, - (sdp->detached || - (srp = sg_get_rq_mark(sfp, req_pack_id))), - retval); - if (sdp->detached) { - retval = -ENODEV; - goto free_old_hdr; - } - if (0 == retval) + (sdp->detached || (srp = sg_get_rq_mark(sfp, req_pack_id))), + res); + if (sdp->detached) + return -ENODEV; + if (0 == res) break; - - /* -ERESTARTSYS as signal hit process */ - goto free_old_hdr; + return res; /* -ERESTARTSYS because signal hit process */ } } - if (srp->header.interface_id != '\0') { - retval = sg_new_read(sfp, buf, count, srp); - goto free_old_hdr; - } + if (srp->header.interface_id != '\0') + return sg_new_read(sfp, buf, count, srp); hp = &srp->header; - if (old_hdr == NULL) { - old_hdr = kmalloc(SZ_SG_HEADER, GFP_KERNEL); - if (! old_hdr) { - retval = -ENOMEM; - goto free_old_hdr; - } - } - memset(old_hdr, 0, SZ_SG_HEADER); - old_hdr->reply_len = (int) hp->timeout; - old_hdr->pack_len = old_hdr->reply_len; /* old, strange behaviour */ - old_hdr->pack_id = hp->pack_id; - old_hdr->twelve_byte = + memset(&old_hdr, 0, SZ_SG_HEADER); + old_hdr.reply_len = (int) hp->timeout; + old_hdr.pack_len = old_hdr.reply_len; /* very old, strange behaviour */ + old_hdr.pack_id = hp->pack_id; + old_hdr.twelve_byte = ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0; - old_hdr->target_status = hp->masked_status; - old_hdr->host_status = hp->host_status; - old_hdr->driver_status = hp->driver_status; + old_hdr.target_status = hp->masked_status; + old_hdr.host_status = hp->host_status; + old_hdr.driver_status = hp->driver_status; if ((CHECK_CONDITION & hp->masked_status) || (DRIVER_SENSE & hp->driver_status)) - memcpy(old_hdr->sense_buffer, srp->sense_b, - sizeof (old_hdr->sense_buffer)); + memcpy(old_hdr.sense_buffer, srp->sense_b, + sizeof (old_hdr.sense_buffer)); switch (hp->host_status) { /* This setup of 'result' is for backward compatibility and is best ignored by the user who should use target, host + driver status */ case DID_OK: case DID_PASSTHROUGH: case DID_SOFT_ERROR: - old_hdr->result = 0; + old_hdr.result = 0; break; case DID_NO_CONNECT: case DID_BUS_BUSY: case DID_TIME_OUT: - old_hdr->result = EBUSY; + old_hdr.result = EBUSY; break; case DID_BAD_TARGET: case DID_ABORT: case DID_PARITY: case DID_RESET: case DID_BAD_INTR: - old_hdr->result = EIO; + old_hdr.result = EIO; break; case DID_ERROR: - old_hdr->result = (srp->sense_b[0] == 0 && + old_hdr.result = (srp->sense_b[0] == 0 && hp->masked_status == GOOD) ? 0 : EIO; break; default: - old_hdr->result = EIO; + old_hdr.result = EIO; break; } /* Now copy the result back to the user buffer. */ if (count >= SZ_SG_HEADER) { - if (__copy_to_user(buf, old_hdr, SZ_SG_HEADER)) { - retval = -EFAULT; - goto free_old_hdr; - } + if (__copy_to_user(buf, &old_hdr, SZ_SG_HEADER)) + return -EFAULT; buf += SZ_SG_HEADER; - if (count > old_hdr->reply_len) - count = old_hdr->reply_len; + if (count > old_hdr.reply_len) + count = old_hdr.reply_len; if (count > SZ_SG_HEADER) { - if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) { - retval = -EFAULT; - goto free_old_hdr; - } + if ((res = + sg_read_oxfer(srp, buf, count - SZ_SG_HEADER))) + return -EFAULT; } } else - count = (old_hdr->result == 0) ? 0 : -EIO; + count = (old_hdr.result == 0) ? 0 : -EIO; sg_finish_rem_req(srp); - retval = count; -free_old_hdr: - if (old_hdr) - kfree(old_hdr); - return retval; + return count; } static ssize_t @@ -763,7 +724,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, srp->data.sglist_len = 0; srp->data.bufflen = 0; srp->data.buffer = NULL; - hp->duration = jiffies_to_msecs(jiffies); + hp->duration = jiffies; /* unit jiffies now, millisecs after done */ /* Now send everything of to mid-level. The next time we hear about this packet is when sg_cmd_done() is called (i.e. a callback). */ scsi_do_req(SRpnt, (void *) cmnd, @@ -976,13 +937,8 @@ sg_ioctl(struct inode *inode, struct file *filp, if (!access_ok(VERIFY_WRITE, p, SZ_SG_REQ_INFO * SG_MAX_QUEUE)) return -EFAULT; else { - sg_req_info_t *rinfo; - unsigned int ms; - - rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, - GFP_KERNEL); - if (!rinfo) - return -ENOMEM; + sg_req_info_t rinfo[SG_MAX_QUEUE]; + Sg_request *srp; read_lock_irqsave(&sfp->rq_list_lock, iflags); for (srp = sfp->headrp, val = 0; val < SG_MAX_QUEUE; ++val, srp = srp ? srp->nextrp : srp) { @@ -993,30 +949,19 @@ sg_ioctl(struct inode *inode, struct file *filp, srp->header.masked_status & srp->header.host_status & srp->header.driver_status; - if (srp->done) - rinfo[val].duration = - srp->header.duration; - else { - ms = jiffies_to_msecs(jiffies); - rinfo[val].duration = - (ms > srp->header.duration) ? - (ms - srp->header.duration) : 0; - } + rinfo[val].duration = + srp->done ? srp->header.duration : + jiffies_to_msecs( + jiffies - srp->header.duration); rinfo[val].orphan = srp->orphan; - rinfo[val].sg_io_owned = - srp->sg_io_owned; - rinfo[val].pack_id = - srp->header.pack_id; - rinfo[val].usr_ptr = - srp->header.usr_ptr; + rinfo[val].sg_io_owned = srp->sg_io_owned; + rinfo[val].pack_id = srp->header.pack_id; + rinfo[val].usr_ptr = srp->header.usr_ptr; } } read_unlock_irqrestore(&sfp->rq_list_lock, iflags); - result = __copy_to_user(p, rinfo, - SZ_SG_REQ_INFO * SG_MAX_QUEUE); - result = result ? -EFAULT : 0; - kfree(rinfo); - return result; + return (__copy_to_user(p, rinfo, + SZ_SG_REQ_INFO * SG_MAX_QUEUE) ? -EFAULT : 0); } case SG_EMULATED_HOST: if (sdp->detached) @@ -1263,12 +1208,11 @@ static int sg_mmap(struct file *filp, struct vm_area_struct *vma) { Sg_fd *sfp; - unsigned long req_sz; + unsigned long req_sz = vma->vm_end - vma->vm_start; Sg_scatter_hold *rsv_schp; if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) return -ENXIO; - req_sz = vma->vm_end - vma->vm_start; SCSI_LOG_TIMEOUT(3, printk("sg_mmap starting, vm_start=%p, len=%d\n", (void *) vma->vm_start, (int) req_sz)); if (vma->vm_pgoff) @@ -1315,7 +1259,6 @@ sg_cmd_done(Scsi_Cmnd * SCpnt) Sg_fd *sfp; Sg_request *srp = NULL; unsigned long iflags; - unsigned int ms; if (SCpnt && (SRpnt = SCpnt->sc_request)) srp = (Sg_request *) SRpnt->upper_private_data; @@ -1352,9 +1295,9 @@ sg_cmd_done(Scsi_Cmnd * SCpnt) SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", sdp->disk->disk_name, srp->header.pack_id, (int) SRpnt->sr_result)); srp->header.resid = SCpnt->resid; - ms = jiffies_to_msecs(jiffies); - srp->header.duration = (ms > srp->header.duration) ? - (ms - srp->header.duration) : 0; + /* N.B. unit of duration changes here from jiffies to millisecs */ + srp->header.duration = + jiffies_to_msecs(jiffies - srp->header.duration); if (0 != SRpnt->sr_result) { struct scsi_sense_hdr sshdr; @@ -2452,7 +2395,7 @@ sg_add_request(Sg_fd * sfp) } if (resp) { resp->nextrp = NULL; - resp->header.duration = jiffies_to_msecs(jiffies); + resp->header.duration = jiffies; resp->my_cmdp = NULL; } write_unlock_irqrestore(&sfp->rq_list_lock, iflags); @@ -3047,7 +2990,6 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) Sg_fd *fp; const sg_io_hdr_t *hp; const char * cp; - unsigned int ms; for (k = 0; (fp = sg_get_nth_sfp(sdp, k)); ++k) { seq_printf(s, " FD(%d): timeout=%dms bufflen=%d " @@ -3086,13 +3028,10 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) srp->header.pack_id, blen); if (srp->done) seq_printf(s, " dur=%d", hp->duration); - else { - ms = jiffies_to_msecs(jiffies); + else seq_printf(s, " t_o/elap=%d/%d", - (new_interface ? hp->timeout : - jiffies_to_msecs(fp->timeout)), - (ms > hp->duration ? ms - hp->duration : 0)); - } + new_interface ? hp->timeout : jiffies_to_msecs(fp->timeout), + jiffies_to_msecs(hp->duration ? (jiffies - hp->duration) : 0)); seq_printf(s, "ms sgat=%d op=0x%02x\n", usg, (int) srp->data.cmd_opcode); } diff --git a/trunk/drivers/scsi/sim710.c b/trunk/drivers/scsi/sim710.c index 9171788348c4..63bf2aecbc57 100644 --- a/trunk/drivers/scsi/sim710.c +++ b/trunk/drivers/scsi/sim710.c @@ -120,10 +120,11 @@ sim710_probe_common(struct device *dev, unsigned long base_addr, } /* Fill in the three required pieces of hostdata */ - hostdata->base = ioport_map(base_addr, 64); + hostdata->base = base_addr; hostdata->differential = differential; hostdata->clock = clock; hostdata->chip710 = 1; + NCR_700_set_io_mapped(hostdata); /* and register the chip */ if((host = NCR_700_detect(&sim710_driver_template, hostdata, dev)) @@ -132,7 +133,6 @@ sim710_probe_common(struct device *dev, unsigned long base_addr, goto out_release; } host->this_id = scsi_id; - host->base = base_addr; host->irq = irq; if (request_irq(irq, NCR_700_intr, SA_SHIRQ, "sim710", host)) { printk(KERN_ERR "sim710: request_irq failed\n"); @@ -164,7 +164,6 @@ sim710_device_remove(struct device *dev) NCR_700_release(host); kfree(hostdata); free_irq(host->irq, host); - release_region(host->base, 64); return 0; } diff --git a/trunk/include/linux/blkdev.h b/trunk/include/linux/blkdev.h index ef1afc178c0a..70ac2860a605 100644 --- a/trunk/include/linux/blkdev.h +++ b/trunk/include/linux/blkdev.h @@ -355,11 +355,8 @@ struct request_queue unsigned long queue_flags; /* - * protects queue structures from reentrancy. ->__queue_lock should - * _never_ be used directly, it is queue private. always use - * ->queue_lock. + * protects queue structures from reentrancy */ - spinlock_t __queue_lock; spinlock_t *queue_lock; /* diff --git a/trunk/include/scsi/scsi.h b/trunk/include/scsi/scsi.h index 1d54c063ae52..3507b3d7c0eb 100644 --- a/trunk/include/scsi/scsi.h +++ b/trunk/include/scsi/scsi.h @@ -360,6 +360,15 @@ struct scsi_lun { #define sense_error(sense) ((sense) & 0xf) #define sense_valid(sense) ((sense) & 0x80); +/* + * default timeouts +*/ +#define FORMAT_UNIT_TIMEOUT (2 * 60 * 60 * HZ) +#define START_STOP_TIMEOUT (60 * HZ) +#define MOVE_MEDIUM_TIMEOUT (5 * 60 * HZ) +#define READ_ELEMENT_STATUS_TIMEOUT (5 * 60 * HZ) +#define READ_DEFECT_DATA_TIMEOUT (60 * HZ ) + #define IDENTIFY_BASE 0x80 #define IDENTIFY(can_disconnect, lun) (IDENTIFY_BASE |\ diff --git a/trunk/include/scsi/scsi_device.h b/trunk/include/scsi/scsi_device.h index fe9571d2e306..07d974051b0c 100644 --- a/trunk/include/scsi/scsi_device.h +++ b/trunk/include/scsi/scsi_device.h @@ -43,8 +43,8 @@ struct scsi_device { struct list_head siblings; /* list of all devices on this host */ struct list_head same_target_siblings; /* just the devices sharing same target id */ - /* this is now protected by the request_queue->queue_lock */ volatile unsigned short device_busy; /* commands actually active on low-level */ + spinlock_t sdev_lock; /* also the request queue_lock */ spinlock_t list_lock; struct list_head cmd_list; /* queue of in use SCSI Command structures */ struct list_head starved_entry;