Commit 7cbecb83 authored by James Bottomley's avatar James Bottomley

Merge raven.il.steeleye.com:/home/jejb/BK/linux-2.5

into raven.il.steeleye.com:/home/jejb/BK/scsi-misc-2.5
parents eb0a5728 a950688a
......@@ -299,13 +299,14 @@ static int sg_io(request_queue_t *q, struct block_device *bdev,
#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(request_queue_t *q, struct block_device *bdev,
Scsi_Ioctl_Command *sic)
{
struct request *rq;
int err, in_len, out_len, bytes, opcode, cmdlen;
char *buffer = NULL, sense[24];
char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
/*
* get in an out lengths, verify they don't exceed a page worth of data
......@@ -378,9 +379,12 @@ static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
blk_do_rq(q, bdev, rq);
err = rq->errors & 0xff; /* only 8 bit SCSI status */
if (err) {
if (rq->sense_len)
if (copy_to_user(sic->data, rq->sense, rq->sense_len))
if (rq->sense_len && rq->sense) {
bytes = (OMAX_SB_LEN > rq->sense_len) ?
rq->sense_len : OMAX_SB_LEN;
if (copy_to_user(sic->data, rq->sense, bytes))
err = -EFAULT;
}
} else {
if (copy_to_user(sic->data, buffer, out_len))
err = -EFAULT;
......
......@@ -3213,6 +3213,7 @@ static void BusLogic_ProcessCompletedCCBs(BusLogic_HostAdapter_T *HostAdapter)
Place CCB back on the Host Adapter's free list.
*/
BusLogic_DeallocateCCB(CCB);
#if 0 /* this needs to be redone different for new EH */
/*
Bus Device Reset CCBs have the Command field non-NULL only when a
Bus Device Reset was requested for a Command that did not have a
......@@ -3228,6 +3229,7 @@ static void BusLogic_ProcessCompletedCCBs(BusLogic_HostAdapter_T *HostAdapter)
Command->scsi_done(Command);
Command = NextCommand;
}
#endif
/*
Iterate over the CCBs for this Host Adapter performing completion
processing for any CCBs marked as Reset for this Target.
......@@ -3948,6 +3950,7 @@ static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter,
{
Command = CCB->Command;
BusLogic_DeallocateCCB(CCB);
#if 0 /* this needs to be redone different for new EH */
while (Command != NULL)
{
SCSI_Command_T *NextCommand = Command->reset_chain;
......@@ -3956,6 +3959,7 @@ static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter,
Command->scsi_done(Command);
Command = NextCommand;
}
#endif
}
for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
{
......@@ -3967,7 +3971,7 @@ static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter,
return Result;
}
#if 0 /* old-style EH code references a dead struct scsi_cmnd member */
/*
BusLogic_SendBusDeviceReset sends a Bus Device Reset to the Target
Device associated with Command.
......@@ -4204,6 +4208,7 @@ int BusLogic_ResetCommand(SCSI_Command_T *Command, unsigned int ResetFlags)
}
return SCSI_RESET_PUNT;
}
#endif
/*
......
......@@ -677,11 +677,6 @@ int cpqfcTS_ioctl( Scsi_Device *ScsiDev, int Cmnd, void *arg)
scsi_release_request(ScsiPassThruReq); // "de-allocate"
ScsiPassThruReq = NULL;
// if (!SDpnt->was_reset && SDpnt->scsi_request_fn)
// (*SDpnt->scsi_request_fn)();
wake_up(&SDpnt->scpnt_wait);
// need to pass data back to user (space)?
if( (vendor_cmd->rw_flag == VENDOR_READ_OPCODE) &&
vendor_cmd->len )
......@@ -1656,10 +1651,6 @@ return -ENOTSUPP;
scsi_put_command(SCpnt);
SCpnt = NULL;
// if (!SDpnt->was_reset && SDpnt->scsi_request_fn)
// (*SDpnt->scsi_request_fn)();
wake_up(&SDpnt->scpnt_wait);
// printk(" LEAVING cpqfcTS_TargetDeviceReset() - return SUCCESS \n");
return SUCCESS;
}
......
......@@ -2495,8 +2495,6 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
pDev->pScsi_dev->online = FALSE;
if (pDev->pScsi_dev->access_count) {
// A drive that was mounted is no longer there... bad!
SCSI_LOG_ERROR_RECOVERY(1, printk ("%s:Rescan: Previously "
"mounted drive not found!\n",pHba->name));
printk(KERN_WARNING"%s:Mounted drive taken offline\n",pHba->name);
}
}
......
......@@ -32,20 +32,20 @@
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/completion.h>
#define __KERNEL_SYSCALLS__
#include <linux/unistd.h>
#include <asm/dma.h>
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
#include "scsi_logging.h"
static LIST_HEAD(scsi_host_list);
static spinlock_t scsi_host_list_lock = SPIN_LOCK_UNLOCKED;
......@@ -423,7 +423,13 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes)
shost->use_clustering = shost_tp->use_clustering;
if (!blk_nohighio)
shost->highmem_io = shost_tp->highmem_io;
if (!shost_tp->max_sectors) {
/*
* Driver imposes no hard sector transfer limit.
* start at machine infinity initially.
*/
shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
} else
shost->max_sectors = shost_tp->max_sectors;
shost->use_blk_tcq = shost_tp->use_blk_tcq;
......
......@@ -527,13 +527,6 @@ static inline struct device *scsi_get_device(struct Scsi_Host *shost)
return shost->host_gendev;
}
/*
* Prototypes for functions/data in scsi_scan.c
*/
extern void scsi_scan_host(struct Scsi_Host *);
extern void scsi_forget_host(struct Scsi_Host *);
struct Scsi_Device_Template
{
struct list_head list;
......@@ -572,16 +565,8 @@ extern int scsi_remove_host(struct Scsi_Host *);
extern int scsi_register_host(Scsi_Host_Template *);
extern int scsi_unregister_host(Scsi_Host_Template *);
extern struct Scsi_Host *scsi_host_get_next(struct Scsi_Host *);
extern struct Scsi_Host *scsi_host_hn_get(unsigned short);
extern void scsi_host_put(struct Scsi_Host *);
extern void scsi_host_init(void);
/*
* host_busy inc/dec/test functions
*/
extern void scsi_host_busy_inc(struct Scsi_Host *, Scsi_Device *);
extern void scsi_host_busy_dec_and_test(struct Scsi_Host *, Scsi_Device *);
/**
* scsi_find_device - find a device given the host
......@@ -610,21 +595,3 @@ extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
extern struct class shost_class;
#endif
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-indent-level: 4
* c-brace-imaginary-offset: 0
* c-brace-offset: -4
* c-argdecl-indent: 4
* c-label-offset: -4
* c-continued-statement-offset: 4
* c-continued-brace-offset: 0
* indent-tabs-mode: nil
* tab-width: 8
* End:
*/
......@@ -98,9 +98,8 @@ MODULE_LICENSE("Dual MPL/GPL");
typedef struct scsi_info_t {
dev_link_t link;
dev_node_t node;
struct Scsi_Host *host;
int ndev;
dev_node_t node[8];
} scsi_info_t;
static void aha152x_release_cs(u_long arg);
......@@ -217,8 +216,6 @@ static void aha152x_config_cs(dev_link_t *link)
cisparse_t parse;
int i, last_ret, last_fn;
u_char tuple_data[64];
struct scsi_device *dev;
dev_node_t *node, **tail;
struct Scsi_Host *host;
DEBUG(0, "aha152x_config(0x%p)\n", link);
......@@ -275,9 +272,6 @@ static void aha152x_config_cs(dev_link_t *link)
if (ext_trans)
s.ext_trans = ext_trans;
tail = &link->dev;
info->ndev = 0;
host = aha152x_probe_one(&s);
if (host == NULL) {
printk(KERN_INFO "aha152x_cs: no SCSI devices found\n");
......@@ -286,39 +280,10 @@ static void aha152x_config_cs(dev_link_t *link)
scsi_add_host(host, NULL);
list_for_each_entry(dev, &host->my_devices, siblings) {
u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
node = &info->node[info->ndev];
node->minor = 0;
switch (dev->type) {
case TYPE_TAPE:
node->major = SCSI_TAPE_MAJOR;
sprintf(node->dev_name, "st#%04lx", id);
break;
case TYPE_DISK:
case TYPE_MOD:
node->major = SCSI_DISK0_MAJOR;
sprintf(node->dev_name, "sd#%04lx", id);
break;
case TYPE_ROM:
case TYPE_WORM:
node->major = SCSI_CDROM_MAJOR;
sprintf(node->dev_name, "sr#%04lx", id);
break;
default:
node->major = SCSI_GENERIC_MAJOR;
sprintf(node->dev_name, "sg#%04lx", id);
break;
}
*tail = node; tail = &node->next;
info->ndev++;
info->host = dev->host;
}
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev = &info->node;
info->host = host;
*tail = NULL;
link->state &= ~DEV_CONFIG_PENDING;
return;
......
......@@ -81,9 +81,8 @@ static char *version =
typedef struct scsi_info_t {
dev_link_t link;
dev_node_t node;
struct Scsi_Host *host;
int ndev;
dev_node_t node[8];
} scsi_info_t;
extern Scsi_Host_Template fdomain_driver_template;
......@@ -206,8 +205,6 @@ static void fdomain_config(dev_link_t *link)
cisparse_t parse;
int i, last_ret, last_fn, ints[3];
u_char tuple_data[64];
Scsi_Device *dev;
dev_node_t *node, **tail;
char str[16];
struct Scsi_Host *host;
......@@ -259,42 +256,8 @@ static void fdomain_config(dev_link_t *link)
scsi_add_host(host, NULL);
tail = &link->dev;
info->ndev = 0;
list_for_each_entry (dev, &host->my_devices, siblings) {
u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
node = &info->node[info->ndev];
node->minor = 0;
switch (dev->type) {
case TYPE_TAPE:
node->major = SCSI_TAPE_MAJOR;
sprintf(node->dev_name, "st#%04lx", id);
break;
case TYPE_DISK:
case TYPE_MOD:
node->major = SCSI_DISK0_MAJOR;
sprintf(node->dev_name, "sd#%04lx", id);
break;
case TYPE_ROM:
case TYPE_WORM:
node->major = SCSI_CDROM_MAJOR;
sprintf(node->dev_name, "sr#%04lx", id);
break;
default:
node->major = SCSI_GENERIC_MAJOR;
sprintf(node->dev_name, "sg#%04lx", id);
break;
}
*tail = node; tail = &node->next;
info->ndev++;
}
*tail = NULL;
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev = &info->node;
info->host = host;
link->state &= ~DEV_CONFIG_PENDING;
......
......@@ -88,9 +88,8 @@ static char *version = "$Id: nsp_cs.c,v 1.5 2002/11/05 12:06:29 elca Exp $";
typedef struct scsi_info_t {
dev_link_t link;
dev_node_t node;
struct Scsi_Host *host;
int ndev;
dev_node_t node[8];
int stop;
} scsi_info_t;
......@@ -1621,8 +1620,6 @@ static void nsp_cs_config(dev_link_t *link)
memreq_t map;
cistpl_cftable_entry_t dflt = { 0 };
Scsi_Device *dev;
dev_node_t **tail, *node;
struct Scsi_Host *host;
nsp_hw_data *data = &nsp_data;
......@@ -1762,58 +1759,13 @@ static void nsp_cs_config(dev_link_t *link)
goto cs_failed;
}
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2))
host = __nsp_detect(&nsp_driver_template);
#else
scsi_register_module(MODULE_SCSI_HA, &nsp_driver_template);
for (host = scsi_hostlist; host != NULL; host = host->next) {
if (host->hostt == &nsp_driver_template)
break;
#endif
if (!host)
goto cs_failed;
DEBUG(0, "GET_SCSI_INFO\n");
tail = &link->dev;
info->ndev = 0;
list_for_each_entry (dev, &host->my_devices, siblings) {
u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
node = &info->node[info->ndev];
node->minor = 0;
switch (dev->type) {
case TYPE_TAPE:
node->major = SCSI_TAPE_MAJOR;
sprintf(node->dev_name, "st#%04lx", id);
break;
case TYPE_DISK:
case TYPE_MOD:
node->major = SCSI_DISK0_MAJOR;
sprintf(node->dev_name, "sd#%04lx", id);
break;
case TYPE_ROM:
case TYPE_WORM:
node->major = SCSI_CDROM_MAJOR;
sprintf(node->dev_name, "sr#%04lx", id);
break;
default:
node->major = SCSI_GENERIC_MAJOR;
sprintf(node->dev_name, "sg#%04lx", id);
break;
}
*tail = node; tail = &node->next;
info->ndev++;
info->host = dev->host;
}
*tail = NULL;
if (info->ndev == 0) {
printk(KERN_INFO "nsp_cs: no SCSI devices found\n");
}
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev = &info->node;
info->host = host;
/* Finally, report what we've done */
printk(KERN_INFO "nsp_cs: index 0x%02x: Vcc %d.%d",
......@@ -1837,10 +1789,7 @@ static void nsp_cs_config(dev_link_t *link)
req.Base+req.Size-1);
printk("\n");
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
scsi_add_host(host, NULL);
#endif
link->state &= ~DEV_CONFIG_PENDING;
return;
......
......@@ -85,10 +85,9 @@ MODULE_PARM(irq_list, "1-4i");
typedef struct scsi_info_t {
dev_link_t link;
dev_node_t node;
struct Scsi_Host *host;
unsigned short manf_id;
int ndev;
dev_node_t node[8];
} scsi_info_t;
static void qlogic_release(u_long arg);
......@@ -205,8 +204,6 @@ static void qlogic_config(dev_link_t * link)
cisparse_t parse;
int i, last_ret, last_fn;
unsigned short tuple_data[32];
Scsi_Device *dev;
dev_node_t **tail, *node;
struct Scsi_Host *host;
DEBUG(0, "qlogic_config(0x%p)\n", link);
......@@ -263,51 +260,18 @@ static void qlogic_config(dev_link_t * link)
else
qlogicfas_preset(link->io.BasePort1, link->irq.AssignedIRQ);
tail = &link->dev;
info->ndev = 0;
host = __qlogicfas_detect(&qlogicfas_driver_template);
if (!host) {
printk(KERN_INFO "qlogic_cs: no SCSI devices found\n");
goto out;
}
scsi_add_host(host, NULL);
list_for_each_entry(dev, &host->my_devices, siblings) {
u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
id = (arg[0] & 0x0f) + ((arg[0] >> 4) & 0xf0) + ((arg[0] >> 8) & 0xf00) + ((arg[0] >> 12) & 0xf000);
node = &info->node[info->ndev];
node->minor = 0;
switch (dev->type) {
case TYPE_TAPE:
node->major = SCSI_TAPE_MAJOR;
sprintf(node->dev_name, "st#%04lx", id);
break;
case TYPE_DISK:
case TYPE_MOD:
node->major = SCSI_DISK0_MAJOR;
sprintf(node->dev_name, "sd#%04lx", id);
break;
case TYPE_ROM:
case TYPE_WORM:
node->major = SCSI_CDROM_MAJOR;
sprintf(node->dev_name, "sr#%04lx", id);
break;
default:
node->major = SCSI_GENERIC_MAJOR;
sprintf(node->dev_name, "sg#%04lx", id);
break;
}
*tail = node;
tail = &node->next;
info->ndev++;
}
*tail = NULL;
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev = &info->node;
info->host = host;
scsi_add_host(host, NULL);
out:
link->state &= ~DEV_CONFIG_PENDING;
return;
......
......@@ -246,11 +246,6 @@ int __init pluto_detect(Scsi_Host_Template *tpnt)
host->max_channel = inq->channels;
host->irq = fc->irq;
#ifdef __sparc_v9__
host->unchecked_isa_dma = 1;
#endif
fc->channels = inq->channels + 1;
fc->targets = inq->targets;
fc->ages = ages;
......
......@@ -56,6 +56,9 @@
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
#include "scsi_logging.h"
/*
* Definitions and constants.
......@@ -116,11 +119,6 @@ static const char * const spaces = " "; /* 16 of them */
static unsigned scsi_default_dev_flags;
LIST_HEAD(scsi_dev_info_list);
/*
* Function prototypes.
*/
extern void scsi_times_out(struct scsi_cmnd *cmd);
MODULE_PARM(scsi_logging_level, "i");
MODULE_PARM_DESC(scsi_logging_level, "SCSI logging level; should be zero or nonzero");
......@@ -534,7 +532,6 @@ void scsi_init_cmd_from_req(struct scsi_cmnd *cmd, struct scsi_request *sreq)
cmd->request = sreq->sr_request;
memcpy(cmd->data_cmnd, sreq->sr_cmnd, sizeof(cmd->data_cmnd));
cmd->reset_chain = NULL;
cmd->serial_number = 0;
cmd->serial_number_at_timeout = 0;
cmd->bufflen = sreq->sr_bufflen;
......
......@@ -18,7 +18,6 @@
#include <linux/config.h> /* for CONFIG_SCSI_LOGGING */
#include <scsi/scsi.h>
/*
* These are the values that the SCpnt->sc_data_direction and
* SRpnt->sr_data_direction can take. These need to be set
......@@ -126,144 +125,11 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
#define SCSI_STATE_BHQUEUE 0x100a
#define SCSI_STATE_MLQUEUE 0x100b
/*
* These are the values that the owner field can take.
* They are used as an indication of who the command belongs to.
*/
#define SCSI_OWNER_HIGHLEVEL 0x100
#define SCSI_OWNER_MIDLEVEL 0x101
#define SCSI_OWNER_LOWLEVEL 0x102
#define SCSI_OWNER_ERROR_HANDLER 0x103
#define SCSI_OWNER_BH_HANDLER 0x104
#define SCSI_OWNER_NOBODY 0x105
#define IDENTIFY_BASE 0x80
#define IDENTIFY(can_disconnect, lun) (IDENTIFY_BASE |\
((can_disconnect) ? 0x40 : 0) |\
((lun) & 0x07))
/*
* This defines the scsi logging feature. It is a means by which the
* user can select how much information they get about various goings on,
* and it can be really useful for fault tracing. The logging word is divided
* into 8 nibbles, each of which describes a loglevel. The division of things
* is somewhat arbitrary, and the division of the word could be changed if it
* were really needed for any reason. The numbers below are the only place where these
* are specified. For a first go-around, 3 bits is more than enough, since this
* gives 8 levels of logging (really 7, since 0 is always off). Cutting to 2 bits
* might be wise at some point.
*/
#define SCSI_LOG_ERROR_SHIFT 0
#define SCSI_LOG_TIMEOUT_SHIFT 3
#define SCSI_LOG_SCAN_SHIFT 6
#define SCSI_LOG_MLQUEUE_SHIFT 9
#define SCSI_LOG_MLCOMPLETE_SHIFT 12
#define SCSI_LOG_LLQUEUE_SHIFT 15
#define SCSI_LOG_LLCOMPLETE_SHIFT 18
#define SCSI_LOG_HLQUEUE_SHIFT 21
#define SCSI_LOG_HLCOMPLETE_SHIFT 24
#define SCSI_LOG_IOCTL_SHIFT 27
#define SCSI_LOG_ERROR_BITS 3
#define SCSI_LOG_TIMEOUT_BITS 3
#define SCSI_LOG_SCAN_BITS 3
#define SCSI_LOG_MLQUEUE_BITS 3
#define SCSI_LOG_MLCOMPLETE_BITS 3
#define SCSI_LOG_LLQUEUE_BITS 3
#define SCSI_LOG_LLCOMPLETE_BITS 3
#define SCSI_LOG_HLQUEUE_BITS 3
#define SCSI_LOG_HLCOMPLETE_BITS 3
#define SCSI_LOG_IOCTL_BITS 3
#ifdef CONFIG_SCSI_LOGGING
#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) \
{ \
unsigned int mask; \
\
mask = (1 << (BITS)) - 1; \
if( ((scsi_logging_level >> (SHIFT)) & mask) > (LEVEL) ) \
{ \
(CMD); \
} \
}
#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL) \
{ \
unsigned int mask; \
\
mask = ((1 << (BITS)) - 1) << SHIFT; \
scsi_logging_level = ((scsi_logging_level & ~mask) \
| ((LEVEL << SHIFT) & mask)); \
}
#else
/*
* With no logging enabled, stub these out so they don't do anything.
*/
#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)
#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
#endif
/*
* These are the macros that are actually used throughout the code to
* log events. If logging isn't enabled, they are no-ops and will be
* completely absent from the user's code.
*
* The 'set' versions of the macros are really intended to only be called
* from the /proc filesystem, and in production kernels this will be about
* all that is ever used. It could be useful in a debugging environment to
* bump the logging level when certain strange events are detected, however.
*/
#define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
#define SCSI_LOG_TIMEOUT(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
#define SCSI_LOG_SCAN_BUS(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
#define SCSI_LOG_MLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_MLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_LLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_LLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_HLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_HLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_IOCTL(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
#define SCSI_SET_ERROR_RECOVERY_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL);
#define SCSI_SET_TIMEOUT_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL);
#define SCSI_SET_SCAN_BUS_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL);
#define SCSI_SET_MLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL);
#define SCSI_SET_MLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_LLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL);
#define SCSI_SET_LLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_HLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL);
#define SCSI_SET_HLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_IOCTL_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL);
/* host byte codes */
#define DID_OK 0x00 /* NO error */
#define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */
......@@ -356,6 +222,7 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
* Forward-declaration of structs for prototypes.
*/
struct Scsi_Host;
struct scsi_target;
struct scatterlist;
/*
......@@ -365,24 +232,12 @@ typedef struct scsi_device Scsi_Device;
typedef struct scsi_cmnd Scsi_Cmnd;
typedef struct scsi_request Scsi_Request;
#define SCSI_CMND_MAGIC 0xE25C23A5
#define SCSI_REQ_MAGIC 0x75F6D354
/*
* Here is where we prototype most of the mid-layer.
*/
extern unsigned int scsi_logging_level; /* What do we log? */
/*
* These are the error handling functions defined in scsi_error.c
*/
extern void scsi_times_out(Scsi_Cmnd * SCpnt);
extern void scsi_add_timer(Scsi_Cmnd * SCset, int timeout,
void (*complete) (Scsi_Cmnd *));
extern int scsi_delete_timer(Scsi_Cmnd * SCset);
extern void scsi_error_handler(void *host);
extern int scsi_decide_disposition(Scsi_Cmnd * SCpnt);
extern int scsi_block_when_processing_errors(Scsi_Device *);
extern void scsi_sleep(int);
......@@ -396,23 +251,12 @@ extern int scsi_partsize(unsigned char *buf, unsigned long capacity,
/*
* Prototypes for functions in scsi_lib.c
*/
extern int scsi_maybe_unblock_host(Scsi_Device * SDpnt);
extern void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt);
extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
int block_sectors);
extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
extern void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd);
extern request_queue_t *scsi_alloc_queue(struct scsi_device *sdev);
extern void scsi_free_queue(request_queue_t *q);
extern int scsi_init_queue(void);
extern void scsi_exit_queue(void);
/*
* Prototypes for functions in scsi.c
*/
extern int scsi_dispatch_cmd(Scsi_Cmnd * SCpnt);
extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
extern struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int flags);
extern void scsi_put_command(struct scsi_cmnd *cmd);
extern void scsi_adjust_queue_depth(Scsi_Device *, int, int);
......@@ -422,13 +266,6 @@ extern void scsi_slave_detach(struct scsi_device *);
extern int scsi_device_get(struct scsi_device *);
extern void scsi_device_put(struct scsi_device *);
extern void scsi_set_device_offline(struct scsi_device *);
extern void scsi_done(Scsi_Cmnd * SCpnt);
extern void scsi_finish_command(Scsi_Cmnd *);
extern int scsi_retry_command(Scsi_Cmnd *);
extern int scsi_attach_device(struct scsi_device *);
extern void scsi_detach_device(struct scsi_device *);
extern void scsi_rescan_device(struct scsi_device *);
extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
/*
* Newer request-based interfaces.
......@@ -438,30 +275,10 @@ extern void scsi_release_request(Scsi_Request *);
extern void scsi_wait_req(Scsi_Request *, const void *cmnd,
void *buffer, unsigned bufflen,
int timeout, int retries);
extern void scsi_do_req(Scsi_Request *, const void *cmnd,
void *buffer, unsigned bufflen,
void (*done) (struct scsi_cmnd *),
int timeout, int retries);
extern int scsi_insert_special_req(Scsi_Request * SRpnt, int);
extern void scsi_init_cmd_from_req(Scsi_Cmnd *, Scsi_Request *);
/*
* Prototypes for functions in scsi_proc.c
*/
#ifdef CONFIG_PROC_FS
extern int scsi_init_procfs(void);
extern void scsi_exit_procfs(void);
extern void scsi_proc_host_add(struct Scsi_Host *);
extern void scsi_proc_host_rm(struct Scsi_Host *);
#else
static inline int scsi_init_procfs(void) { return 0; }
static inline void scsi_exit_procfs(void) { ; }
static inline void scsi_proc_host_add(struct Scsi_Host *);
static inline void scsi_proc_host_rm(struct Scsi_Host *);
#endif /* CONFIG_PROC_FS */
/*
* Prototypes for functions in scsi_scan.c
......@@ -486,40 +303,6 @@ extern int print_msg(const unsigned char *);
extern const char *scsi_sense_key_string(unsigned char);
extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
/*
* dev_info: for the black/white list in the old scsi_static_device_list
*/
struct dev_info {
char *vendor;
char *model;
char *revision; /* revision known to be bad, unused */
unsigned flags;
};
extern struct dev_info scsi_static_device_list[];
/*
* scsi_dev_info_list: structure to hold black/white listed devices.
*/
struct scsi_dev_info_list {
struct list_head dev_info_list;
char vendor[8];
char model[16];
unsigned flags;
unsigned compatible; /* for use with scsi_static_device_list entries */
};
extern struct list_head scsi_dev_info_list;
extern int scsi_dev_info_list_add_str(char *);
/*
* scsi_target: representation of a scsi target, for now, this is only
* used for single_lun devices. If no one has active IO to the target,
* starget_sdev_user is NULL, else it points to the active sdev.
*/
struct scsi_target {
struct scsi_device *starget_sdev_user;
unsigned int starget_refcnt;
};
/*
* The scsi_device struct contains what we know about each given scsi
......@@ -540,8 +323,6 @@ 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 */
wait_queue_head_t scpnt_wait; /* Used to wait if
device is busy */
struct Scsi_Host *host;
request_queue_t *request_queue;
volatile unsigned short device_busy; /* commands actually active on low-level */
......@@ -619,9 +400,6 @@ struct scsi_device {
/* default value if the device doesn't override */
#define SCSI_DEFAULT_DEVICE_BLOCKED 3
// Flag to allow revalidate to succeed in sd_open
int allow_revalidate;
struct device sdev_driverfs_dev;
};
#define to_scsi_device(d) \
......@@ -698,7 +476,6 @@ struct scsi_cmnd {
unsigned short state;
unsigned short owner;
Scsi_Request *sc_request;
struct scsi_cmnd *reset_chain;
struct list_head list; /* scsi_cmnd participates in queue lists */
......@@ -783,14 +560,6 @@ struct scsi_cmnd {
unsigned flags;
/*
* Used to indicate that a command which has timed out also
* completed normally. Typically the completion function will
* do nothing but set this flag in this instance because the
* timeout handler is already running.
*/
unsigned done_late:1;
/* Low-level done function - can be used by low-level driver to point
* to completion function. Not used by mid/upper level code. */
void (*scsi_done) (struct scsi_cmnd *);
......@@ -816,11 +585,6 @@ struct scsi_cmnd {
unsigned long pid; /* Process ID, starts at 0 */
};
/*
* Flag bit for the internal_timeout array
*/
#define NORMAL_TIMEOUT 0
/*
* Definitions and prototypes used for scsi mid-level queue.
*/
......@@ -829,8 +593,7 @@ struct scsi_cmnd {
#define SCSI_MLQUEUE_EH_RETRY 0x1057
/*
* old style reset request from external source
* (private to sg.c and scsi_error.c, supplied by scsi_obsolete.c)
* Reset request from external source
*/
#define SCSI_TRY_RESET_DEVICE 1
#define SCSI_TRY_RESET_BUS 2
......@@ -922,34 +685,6 @@ static inline Scsi_Cmnd *scsi_find_tag(Scsi_Device *SDpnt, int tag) {
return (Scsi_Cmnd *)req->special;
}
#define scsi_eh_eflags_chk(scp, flags) (scp->eh_eflags & flags)
#define scsi_eh_eflags_set(scp, flags) do { \
scp->eh_eflags |= flags; \
} while(0)
#define scsi_eh_eflags_clr(scp, flags) do { \
scp->eh_eflags &= ~flags; \
} while(0)
#define scsi_eh_eflags_clr_all(scp) (scp->eh_eflags = 0)
/*
* Scsi Error Handler Flags
*/
#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
#define SCSI_EH_REC_TIMEOUT 0x0002 /* EH retry timed out */
#define SCSI_SENSE_VALID(scmd) ((scmd->sense_buffer[0] & 0x70) == 0x70)
extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
int scsi_set_medium_removal(Scsi_Device *dev, char state);
extern int scsi_device_register(struct scsi_device *);
extern void scsi_device_unregister(struct scsi_device *);
extern int scsi_sysfs_register(void);
extern void scsi_sysfs_unregister(void);
#endif /* _SCSI_H */
......@@ -52,6 +52,7 @@
#include <linux/version.h>
#endif
#include "scsi_logging.h"
#include "scsi_debug.h"
static const char * scsi_debug_version_str = "Version: 1.69 (20030329)";
......@@ -865,7 +866,7 @@ static int resp_report_luns(unsigned char * cmd, unsigned char * buff,
static void timer_intr_handler(unsigned long indx)
{
struct sdebug_queued_cmd * sqcp;
unsigned int iflags;
unsigned long iflags;
if (indx >= SCSI_DEBUG_CANQUEUE) {
printk(KERN_ERR "scsi_debug:timer_intr_handler: indx too "
......
......@@ -28,6 +28,9 @@
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
#include "scsi_logging.h"
#ifdef DEBUG
#define SENSE_TIMEOUT SCSI_TIMEOUT
#else
......@@ -916,7 +919,6 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
**/
static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
{
struct scsi_device *sdev;
unsigned long flags;
int rtn;
......@@ -934,16 +936,9 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
if (rtn == SUCCESS) {
scsi_sleep(BUS_RESET_SETTLE_TIME);
/*
* Mark all affected devices to expect a unit attention.
*/
list_for_each_entry(sdev, &scmd->device->host->my_devices,
siblings)
if (scmd->device->channel == sdev->channel) {
sdev->was_reset = 1;
sdev->expecting_cc_ua = 1;
}
scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
}
return rtn;
}
......@@ -953,7 +948,6 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
**/
static int scsi_try_host_reset(struct scsi_cmnd *scmd)
{
struct scsi_device *sdev;
unsigned long flags;
int rtn;
......@@ -971,16 +965,9 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
if (rtn == SUCCESS) {
scsi_sleep(HOST_RESET_SETTLE_TIME);
/*
* Mark all affected devices to expect a unit attention.
*/
list_for_each_entry(sdev, &scmd->device->host->my_devices,
siblings)
if (scmd->device->channel == sdev->channel) {
sdev->was_reset = 1;
sdev->expecting_cc_ua = 1;
}
scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
}
return rtn;
}
......@@ -1674,13 +1661,10 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
scmd->scsi_done = scsi_reset_provider_done_command;
scmd->done = NULL;
scmd->reset_chain = NULL;
scmd->buffer = NULL;
scmd->bufflen = 0;
scmd->request_buffer = NULL;
scmd->request_bufflen = 0;
scmd->internal_timeout = NORMAL_TIMEOUT;
scmd->abort_reason = DID_ABORT;
......
......@@ -23,6 +23,8 @@
#include "hosts.h"
#include <scsi/scsi_ioctl.h>
#include "scsi_logging.h"
#define NORMAL_RETRIES 5
#define IOCTL_NORMAL_TIMEOUT (10 * HZ)
#define FORMAT_UNIT_TIMEOUT (2 * 60 * 60 * HZ)
......
......@@ -19,6 +19,9 @@
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
#include "scsi_logging.h"
#define SG_MEMPOOL_NR 5
#define SG_MEMPOOL_SIZE 32
......@@ -271,7 +274,6 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer,
static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)
{
cmd->owner = SCSI_OWNER_MIDLEVEL;
cmd->reset_chain = NULL;
cmd->serial_number = 0;
cmd->serial_number_at_timeout = 0;
cmd->flags = 0;
......@@ -296,7 +298,6 @@ static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)
memcpy(cmd->data_cmnd, cmd->cmnd, sizeof(cmd->cmnd));
cmd->buffer = cmd->request_buffer;
cmd->bufflen = cmd->request_bufflen;
cmd->reset_chain = NULL;
cmd->internal_timeout = NORMAL_TIMEOUT;
cmd->abort_reason = 0;
......@@ -1140,66 +1141,61 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
*
* Lock status: IO request lock assumed to be held when called.
*/
static void scsi_request_fn(request_queue_t *q)
static void scsi_request_fn(struct request_queue *q)
{
struct scsi_device *sdev = q->queuedata;
struct Scsi_Host *shost = sdev->host;
struct scsi_cmnd *cmd;
struct request *req;
unsigned long flags;
/*
* To start with, we keep looping until the queue is empty, or until
* the host is no longer able to accept any more requests.
*/
for (;;) {
if (blk_queue_plugged(q))
goto completed;
while (!blk_queue_plugged(q)) {
/*
* get next queueable request. We do this early to make sure
* that the request is fully prepared even if we cannot
* accept it.
*/
req = elv_next_request(q);
if (!req)
goto completed;
if (!scsi_dev_queue_ready(q, sdev))
goto completed;
if (!req || !scsi_dev_queue_ready(q, sdev))
break;
/*
* Remove the request from the request list.
*/
if (!(blk_queue_tagged(q) && (blk_queue_start_tag(q, req) == 0)))
if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
blkdev_dequeue_request(req);
sdev->device_busy++;
spin_unlock_irq(q->queue_lock);
spin_lock_irqsave(shost->host_lock, flags);
if (!scsi_host_queue_ready(q, shost, sdev))
goto host_lock_held;
spin_unlock(q->queue_lock);
spin_lock(shost->host_lock);
if (!scsi_host_queue_ready(q, shost, sdev))
goto not_ready;
if (sdev->single_lun) {
if (sdev->sdev_target->starget_sdev_user &&
(sdev->sdev_target->starget_sdev_user != sdev))
goto host_lock_held;
else
sdev->sdev_target->starget_sdev_user != sdev)
goto not_ready;
sdev->sdev_target->starget_sdev_user = sdev;
}
shost->host_busy++;
spin_unlock_irqrestore(shost->host_lock, flags);
cmd = req->special;
/*
* Should be impossible for a correctly prepared request
* please mail the stack trace to linux-scsi@vger.kernel.org
* XXX(hch): This is rather suboptimal, scsi_dispatch_cmd will
* take the lock again.
*/
BUG_ON(!cmd);
spin_unlock_irq(shost->host_lock);
cmd = req->special;
if (unlikely(cmd == NULL)) {
printk(KERN_CRIT "impossible request in %s.\n"
"please mail a stack trace to "
"linux-scsi@vger.kernel.org",
__FUNCTION__);
BUG();
}
/*
* Finally, initialize any error handling parameters, and set up
......@@ -1211,18 +1207,14 @@ static void scsi_request_fn(request_queue_t *q)
* Dispatch the command to the low-level driver.
*/
scsi_dispatch_cmd(cmd);
/*
* Now we need to grab the lock again. We are about to mess
* with the request queue and try to find another command.
*/
spin_lock_irq(q->queue_lock);
}
completed:
return;
host_lock_held:
spin_unlock_irqrestore(shost->host_lock, flags);
not_ready:
spin_unlock_irq(shost->host_lock);
/*
* lock q, handle tag, requeue req, and decrement device_busy. We
* must return with queue_lock held.
......@@ -1257,28 +1249,15 @@ u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
return BLK_BOUNCE_HIGH;
}
request_queue_t *scsi_alloc_queue(struct scsi_device *sdev)
struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
{
request_queue_t *q;
struct Scsi_Host *shost;
struct Scsi_Host *shost = sdev->host;
struct request_queue *q = kmalloc(sizeof(*q), GFP_ATOMIC);
q = kmalloc(sizeof(*q), GFP_ATOMIC);
if (!q)
return NULL;
memset(q, 0, sizeof(*q));
/*
* XXX move host code to scsi_register
*/
shost = sdev->host;
if (!shost->max_sectors) {
/*
* Driver imposes no hard sector transfer limit.
* start at machine infinity initially.
*/
shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
}
blk_init_queue(q, scsi_request_fn, &sdev->sdev_lock);
blk_queue_prep_rq(q, scsi_prep_fn);
......@@ -1289,11 +1268,10 @@ request_queue_t *scsi_alloc_queue(struct scsi_device *sdev)
if (!shost->use_clustering)
clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
return q;
}
void scsi_free_queue(request_queue_t *q)
void scsi_free_queue(struct request_queue *q)
{
blk_cleanup_queue(q);
kfree(q);
......
#ifndef _SCSI_LOGGING_H
#define _SCSI_LOGGING_H
#include <linux/config.h>
/*
* This defines the scsi logging feature. It is a means by which the user
* can select how much information they get about various goings on, and it
* can be really useful for fault tracing. The logging word is divided into
* 8 nibbles, each of which describes a loglevel. The division of things is
* somewhat arbitrary, and the division of the word could be changed if it
* were really needed for any reason. The numbers below are the only place
* where these are specified. For a first go-around, 3 bits is more than
* enough, since this gives 8 levels of logging (really 7, since 0 is always
* off). Cutting to 2 bits might be wise at some point.
*/
#define SCSI_LOG_ERROR_SHIFT 0
#define SCSI_LOG_TIMEOUT_SHIFT 3
#define SCSI_LOG_SCAN_SHIFT 6
#define SCSI_LOG_MLQUEUE_SHIFT 9
#define SCSI_LOG_MLCOMPLETE_SHIFT 12
#define SCSI_LOG_LLQUEUE_SHIFT 15
#define SCSI_LOG_LLCOMPLETE_SHIFT 18
#define SCSI_LOG_HLQUEUE_SHIFT 21
#define SCSI_LOG_HLCOMPLETE_SHIFT 24
#define SCSI_LOG_IOCTL_SHIFT 27
#define SCSI_LOG_ERROR_BITS 3
#define SCSI_LOG_TIMEOUT_BITS 3
#define SCSI_LOG_SCAN_BITS 3
#define SCSI_LOG_MLQUEUE_BITS 3
#define SCSI_LOG_MLCOMPLETE_BITS 3
#define SCSI_LOG_LLQUEUE_BITS 3
#define SCSI_LOG_LLCOMPLETE_BITS 3
#define SCSI_LOG_HLQUEUE_BITS 3
#define SCSI_LOG_HLCOMPLETE_BITS 3
#define SCSI_LOG_IOCTL_BITS 3
#ifdef CONFIG_SCSI_LOGGING
extern unsigned int scsi_logging_level;
#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) \
{ \
unsigned int mask = (1 << (BITS)) - 1; \
if (((scsi_logging_level >> (SHIFT)) & mask) > (LEVEL)) \
(CMD); \
}
#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL) \
{ \
unsigned int mask = ((1 << (BITS)) - 1) << SHIFT; \
scsi_logging_level = ((scsi_logging_level & ~mask) \
| ((LEVEL << SHIFT) & mask)); \
}
#else
/*
* With no logging enabled, stub these out so they don't do anything.
*/
#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)
#endif /* CONFIG_SCSI_LOGGING */
/*
* These are the macros that are actually used throughout the code to
* log events. If logging isn't enabled, they are no-ops and will be
* completely absent from the user's code.
*
* The 'set' versions of the macros are really intended to only be called
* from the /proc filesystem, and in production kernels this will be about
* all that is ever used. It could be useful in a debugging environment to
* bump the logging level when certain strange events are detected, however.
*/
#define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
#define SCSI_LOG_TIMEOUT(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
#define SCSI_LOG_SCAN_BUS(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
#define SCSI_LOG_MLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_MLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_LLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_LLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_HLQUEUE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_HLCOMPLETE(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
#define SCSI_LOG_IOCTL(LEVEL,CMD) \
SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
#define SCSI_SET_ERROR_RECOVERY_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL);
#define SCSI_SET_TIMEOUT_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL);
#define SCSI_SET_SCAN_BUS_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL);
#define SCSI_SET_MLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL);
#define SCSI_SET_MLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_LLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL);
#define SCSI_SET_LLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_HLQUEUE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL);
#define SCSI_SET_HLCOMPLETE_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL);
#define SCSI_SET_IOCTL_LOGGING(LEVEL) \
SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL);
#endif /* _SCSI_LOGGING_H */
#ifndef _SCSI_PRIV_H
#define _SCSI_PRIV_H
/*
* These are the values that the owner field can take.
* They are used as an indication of who the command belongs to.
*/
#define SCSI_OWNER_HIGHLEVEL 0x100
#define SCSI_OWNER_MIDLEVEL 0x101
#define SCSI_OWNER_LOWLEVEL 0x102
#define SCSI_OWNER_ERROR_HANDLER 0x103
#define SCSI_OWNER_BH_HANDLER 0x104
#define SCSI_OWNER_NOBODY 0x105
/*
* Magic values for certain scsi structs. Shouldn't ever be used.
*/
#define SCSI_CMND_MAGIC 0xE25C23A5
#define SCSI_REQ_MAGIC 0x75F6D354
/*
* Flag bit for the internal_timeout array
*/
#define NORMAL_TIMEOUT 0
/*
* Scsi Error Handler Flags
*/
#define scsi_eh_eflags_chk(scp, flags) \
((scp)->eh_eflags & (flags))
#define scsi_eh_eflags_set(scp, flags) \
do { (scp)->eh_eflags |= (flags); } while(0)
#define scsi_eh_eflags_clr(scp, flags) \
do { (scp)->eh_eflags &= ~(flags); } while(0)
#define scsi_eh_eflags_clr_all(scp) \
(scp->eh_eflags = 0)
#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
#define SCSI_EH_REC_TIMEOUT 0x0002 /* EH retry timed out */
#define SCSI_SENSE_VALID(scmd) \
(((scmd)->sense_buffer[0] & 0x70) == 0x70)
/*
* scsi_target: representation of a scsi target, for now, this is only
* used for single_lun devices. If no one has active IO to the target,
* starget_sdev_user is NULL, else it points to the active sdev.
*/
struct scsi_target {
struct scsi_device *starget_sdev_user;
unsigned int starget_refcnt;
};
/* hosts.c */
extern void scsi_host_busy_inc(struct Scsi_Host *, Scsi_Device *);
extern void scsi_host_busy_dec_and_test(struct Scsi_Host *, Scsi_Device *);
extern struct Scsi_Host *scsi_host_get_next(struct Scsi_Host *);
extern void scsi_host_init(void);
/* scsi.c */
extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
extern void scsi_done(struct scsi_cmnd *cmd);
extern void scsi_finish_command(struct scsi_cmnd *cmd);
extern int scsi_retry_command(struct scsi_cmnd *cmd);
extern int scsi_attach_device(struct scsi_device *sdev);
extern void scsi_detach_device(struct scsi_device *sdev);
extern void scsi_rescan_device(struct scsi_device *sdev);
extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
extern int scsi_insert_special_req(struct scsi_request *sreq, int);
extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd,
struct scsi_request *sreq);
/* scsi_error.c */
extern void scsi_times_out(struct scsi_cmnd *cmd);
extern void scsi_error_handler(void *host);
extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
/* scsi_lib.c */
extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
extern void scsi_setup_cmd_retry(struct scsi_cmnd *cmd);
extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
extern void scsi_queue_next_request(struct request_queue *q,
struct scsi_cmnd *cmd);
extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
extern void scsi_free_queue(struct request_queue *q);
extern int scsi_init_queue(void);
extern void scsi_exit_queue(void);
/* scsi_proc.c */
#ifdef CONFIG_PROC_FS
extern void scsi_proc_host_add(struct Scsi_Host *);
extern void scsi_proc_host_rm(struct Scsi_Host *);
extern int scsi_init_procfs(void);
extern void scsi_exit_procfs(void);
#else
# define scsi_proc_host_add(shost) do { } while (0)
# define scsi_proc_host_rm(shost) do { } while (0)
# define scsi_init_procfs() (0)
# define scsi_exit_procfs do { } while (0)
#endif /* CONFIG_PROC_FS */
/* scsi_scan.c */
extern void scsi_scan_host(struct Scsi_Host *shost);
extern void scsi_forget_host(struct Scsi_Host *shost);
/* scsi_sysfs.c */
extern int scsi_device_register(struct scsi_device *);
extern void scsi_device_unregister(struct scsi_device *);
extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
extern int scsi_sysfs_register(void);
extern void scsi_sysfs_unregister(void);
/*
* dev_info: for the black/white list in the old scsi_static_device_list
*/
struct dev_info {
char *vendor;
char *model;
char *revision; /* revision known to be bad, unused */
unsigned flags;
};
extern struct dev_info scsi_static_device_list[];
/*
* scsi_dev_info_list: structure to hold black/white listed devices.
*/
struct scsi_dev_info_list {
struct list_head dev_info_list;
char vendor[8];
char model[16];
unsigned flags;
unsigned compatible; /* for use with scsi_static_device_list entries */
};
extern struct list_head scsi_dev_info_list;
extern int scsi_dev_info_list_add_str(char *);
#endif /* _SCSI_PRIV_H */
......@@ -29,6 +29,10 @@
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
#include "scsi_logging.h"
/* 4K page size, but our output routines, use some slack for overruns */
#define PROC_BLOCK_SIZE (3*1024)
......@@ -312,91 +316,6 @@ static int scsi_proc_info(char *buffer, char **start, off_t offset, int length)
return (len);
}
#ifdef CONFIG_SCSI_LOGGING
/*
* Function: scsi_dump_status
*
* Purpose: Brain dump of scsi system, used for problem solving.
*
* Arguments: level - used to indicate level of detail.
*
* Notes: The level isn't used at all yet, but we need to find some
* way of sensibly logging varying degrees of information.
* A quick one-line display of each command, plus the status
* would be most useful.
*
* This does depend upon CONFIG_SCSI_LOGGING - I do want some
* way of turning it all off if the user wants a lean and mean
* kernel. It would probably also be useful to allow the user
* to specify one single host to be dumped. A second argument
* to the function would be useful for that purpose.
*
* FIXME - some formatting of the output into tables would be
* very handy.
*/
static void scsi_dump_status(int level)
{
int i;
struct Scsi_Host *shpnt;
Scsi_Cmnd *SCpnt;
Scsi_Device *SDpnt;
printk(KERN_INFO "Dump of scsi host parameters:\n");
i = 0;
for (shpnt = scsi_host_get_next(NULL); shpnt;
shpnt = scsi_host_get_next(shpnt)) {
printk(KERN_INFO " %d %d : %d %d\n",
shpnt->host_failed,
shpnt->host_busy,
shpnt->host_blocked,
shpnt->host_self_blocked);
}
printk(KERN_INFO "\n\n");
printk(KERN_INFO "Dump of scsi command parameters:\n");
for (shpnt = scsi_host_get_next(NULL); shpnt;
shpnt = scsi_host_get_next(shpnt)) {
printk(KERN_INFO "h:c:t:l (dev sect nsect cnumsec sg) "
"(ret all flg) (to/cmd to ito) cmd snse result\n");
list_for_each_entry(SDpnt, &shpnt->my_devices, siblings) {
unsigned long flags;
spin_lock_irqsave(&SDpnt->list_lock, flags);
list_for_each_entry(SCpnt, &SDpnt->cmd_list, list) {
/* (0) h:c:t:l (dev sect nsect cnumsec sg) (ret all flg) (to/cmd to ito) cmd snse result %d %x */
printk(KERN_INFO "(%3d) %2d:%1d:%2d:%2d (%6s %4llu %4ld %4ld %4x %1d) (%1d %1d 0x%2x) (%4d %4d %4d) 0x%2.2x 0x%2.2x 0x%8.8x\n",
i++,
SCpnt->device->host->host_no,
SCpnt->device->channel,
SCpnt->device->id,
SCpnt->device->lun,
SCpnt->request->rq_disk ?
SCpnt->request->rq_disk->disk_name : "?",
(unsigned long long)SCpnt->request->sector,
SCpnt->request->nr_sectors,
(long)SCpnt->request->current_nr_sectors,
SCpnt->request->rq_status,
SCpnt->use_sg,
SCpnt->retries,
SCpnt->allowed,
SCpnt->flags,
SCpnt->timeout_per_command,
SCpnt->timeout,
SCpnt->internal_timeout,
SCpnt->cmnd[0],
SCpnt->sense_buffer[2],
SCpnt->result);
}
spin_unlock_irqrestore(&SDpnt->list_lock, flags);
}
}
}
#endif /* CONFIG_SCSI_LOGGING */
static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
{
struct Scsi_Host *shost;
......@@ -470,22 +389,6 @@ static int proc_scsi_gen_write(struct file * file, const char * buf,
goto out;
#ifdef CONFIG_SCSI_LOGGING
/*
* Usage: echo "scsi dump #N" > /proc/scsi/scsi
* to dump status of all scsi commands. The number is used to
* specify the level of detail in the dump.
*/
if (!strncmp("dump", buffer + 5, 4)) {
unsigned int level;
p = buffer + 10;
if (*p == '\0')
goto out;
level = simple_strtoul(p, NULL, 0);
scsi_dump_status(level);
}
/*
* Usage: echo "scsi log token #N" > /proc/scsi/scsi
* where token is one of [error,scan,mlqueue,mlcomplete,llqueue,
......
......@@ -33,9 +33,9 @@
#include "scsi.h"
#include "hosts.h"
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
#include "scsi_priv.h"
#include "scsi_logging.h"
/*
* Flags for SCSI devices that need special treatment
......@@ -429,7 +429,6 @@ static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
sdev->request_queue->queuedata = sdev;
scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
init_waitqueue_head(&sdev->scpnt_wait);
if (shost->hostt->slave_alloc) {
if (shost->hostt->slave_alloc(sdev))
......
......@@ -21,6 +21,7 @@
#include "scsi.h"
#include <scsi/scsi_ioctl.h>
#include "hosts.h"
#include "scsi_logging.h"
#include <scsi/scsicam.h>
......@@ -104,8 +105,6 @@ EXPORT_SYMBOL(scsi_calculate_bounce_limit);
/*
* Externalize timers so that HBAs can safely start/restart commands.
*/
extern void scsi_add_timer(Scsi_Cmnd *, int, void ((*) (Scsi_Cmnd *)));
extern int scsi_delete_timer(Scsi_Cmnd *);
EXPORT_SYMBOL(scsi_add_timer);
EXPORT_SYMBOL(scsi_delete_timer);
......
......@@ -14,6 +14,7 @@
#include "scsi.h"
#include "hosts.h"
#include "scsi_priv.h"
/*
* shost_show_function: macro to create an attr function that can be used to
......
......@@ -52,6 +52,9 @@
#include <scsi/scsi_ioctl.h>
#include <scsi/scsicam.h>
#include "scsi_logging.h"
/*
* Remaining dev_t-handling stuff
*/
......@@ -1503,6 +1506,7 @@ static int sd_synchronize_cache(struct scsi_disk *sdkp, int verbose)
return 0;
}
SRpnt->sr_data_direction = SCSI_DATA_NONE;
for(retries = 3; retries > 0; --retries) {
unsigned char cmd[10] = { 0 };
......
......@@ -67,6 +67,8 @@ static int sg_version_num = 30528; /* 2 digits for each component */
#include <scsi/scsi_ioctl.h>
#include <scsi/sg.h>
#include "scsi_logging.h"
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
static int sg_proc_init(void);
......
......@@ -50,6 +50,7 @@
#include "hosts.h"
#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */
#include "scsi_logging.h"
#include "sr.h"
......
......@@ -2558,34 +2558,16 @@ sym53c8xx_pci_init(Scsi_Host_Template *tpnt, pcidev_t pdev, sym_device *device)
bcopy(chip, &device->chip, sizeof(device->chip));
device->chip.revision_id = revision;
if (pci_enable_device(pdev))
return -1;
pci_set_master(pdev);
/*
* Read additionnal info from the configuration space.
*/
pci_read_config_word(pdev, PCI_COMMAND, &command);
pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_line_size);
/*
* Enable missing capabilities in the PCI COMMAND register.
*/
#ifdef SYM_CONF_IOMAPPED
#define PCI_COMMAND_BITS_TO_ENABLE (PCI_COMMAND_IO | \
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_PARITY)
#else
#define PCI_COMMAND_BITS_TO_ENABLE \
(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_PARITY)
#endif
if ((command & PCI_COMMAND_BITS_TO_ENABLE)
!= PCI_COMMAND_BITS_TO_ENABLE) {
printf_info("%s: setting%s%s%s%s...\n", sym_name(device),
(command & PCI_COMMAND_IO) ? "" : " PCI_COMMAND_IO",
(command & PCI_COMMAND_MEMORY) ? "" : " PCI_COMMAND_MEMORY",
(command & PCI_COMMAND_MASTER) ? "" : " PCI_COMMAND_MASTER",
(command & PCI_COMMAND_PARITY) ? "" : " PCI_COMMAND_PARITY");
command |= PCI_COMMAND_BITS_TO_ENABLE;
pci_write_config_word(pdev, PCI_COMMAND, command);
}
#undef PCI_COMMAND_BITS_TO_ENABLE
/*
* If cache line size is not configured, suggest
* a value for well known CPUs.
......@@ -2625,6 +2607,7 @@ sym53c8xx_pci_init(Scsi_Host_Template *tpnt, pcidev_t pdev, sym_device *device)
sym_name(device), cache_line_size);
}
pci_read_config_word(pdev, PCI_COMMAND, &command);
if ((pci_fix_up & 2) && cache_line_size &&
(chip->features & FE_WRIE) && !(command & PCI_COMMAND_INVALIDATE)) {
printf_info("%s: setting PCI_COMMAND_INVALIDATE.\n",
......
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