Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31930
b: refs/heads/master
c: 0f13fc0
h: refs/heads/master
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Jun 29, 2006
1 parent 03a3f55 commit 553e301
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53cb8a1f45e06a2627a6d89b151cccb95fa45cbf
refs/heads/master: 0f13fc09db68de92585558984bff1c51b87db72f
56 changes: 30 additions & 26 deletions trunk/drivers/scsi/53c700.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ STATIC int NCR_700_bus_reset(struct scsi_cmnd * SCpnt);
STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt);
STATIC void NCR_700_chip_setup(struct Scsi_Host *host);
STATIC void NCR_700_chip_reset(struct Scsi_Host *host);
STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt);
STATIC int NCR_700_slave_configure(struct scsi_device *SDpnt);
STATIC void NCR_700_slave_destroy(struct scsi_device *SDpnt);
static int NCR_700_change_queue_depth(struct scsi_device *SDpnt, int depth);
Expand All @@ -183,10 +184,6 @@ STATIC struct device_attribute *NCR_700_dev_attrs[];

STATIC struct scsi_transport_template *NCR_700_transport_template = NULL;

struct NCR_700_sense {
unsigned char cmnd[MAX_COMMAND_SIZE];
};

static char *NCR_700_phase[] = {
"",
"after selection",
Expand Down Expand Up @@ -334,6 +331,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
tpnt->use_clustering = ENABLE_CLUSTERING;
tpnt->slave_configure = NCR_700_slave_configure;
tpnt->slave_destroy = NCR_700_slave_destroy;
tpnt->slave_alloc = NCR_700_slave_alloc;
tpnt->change_queue_depth = NCR_700_change_queue_depth;
tpnt->change_queue_type = NCR_700_change_queue_type;

Expand Down Expand Up @@ -612,9 +610,10 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
struct NCR_700_command_slot *slot =
(struct NCR_700_command_slot *)SCp->host_scribble;

NCR_700_unmap(hostdata, SCp, slot);
dma_unmap_single(hostdata->dev, slot->pCmd,
sizeof(SCp->cmnd), DMA_TO_DEVICE);
if (slot->flags == NCR_700_FLAG_AUTOSENSE) {
struct NCR_700_sense *sense = SCp->device->hostdata;
char *cmnd = NCR_700_get_sense_cmnd(SCp->device);
#ifdef NCR_700_DEBUG
printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",
SCp, SCp->cmnd[7], result);
Expand All @@ -625,10 +624,9 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
/* restore the old result if the request sense was
* successful */
if(result == 0)
result = sense->cmnd[7];
result = cmnd[7];
} else
dma_unmap_single(hostdata->dev, slot->pCmd,
sizeof(SCp->cmnd), DMA_TO_DEVICE);
NCR_700_unmap(hostdata, SCp, slot);

free_slot(slot, hostdata);
#ifdef NCR_700_DEBUG
Expand Down Expand Up @@ -970,14 +968,15 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
status_byte(hostdata->status[0]) == COMMAND_TERMINATED) {
struct NCR_700_command_slot *slot =
(struct NCR_700_command_slot *)SCp->host_scribble;
if(SCp->cmnd[0] == REQUEST_SENSE) {
if(slot->flags == NCR_700_FLAG_AUTOSENSE) {
/* OOPS: bad device, returning another
* contingent allegiance condition */
scmd_printk(KERN_ERR, SCp,
"broken device is looping in contingent allegiance: ignoring\n");
NCR_700_scsi_done(hostdata, SCp, hostdata->status[0]);
} else {
struct NCR_700_sense *sense = SCp->device->hostdata;
char *cmnd =
NCR_700_get_sense_cmnd(SCp->device);
#ifdef NCR_DEBUG
scsi_print_command(SCp);
printk(" cmd %p has status %d, requesting sense\n",
Expand All @@ -995,21 +994,21 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
sizeof(SCp->cmnd),
DMA_TO_DEVICE);

sense->cmnd[0] = REQUEST_SENSE;
sense->cmnd[1] = (SCp->device->lun & 0x7) << 5;
sense->cmnd[2] = 0;
sense->cmnd[3] = 0;
sense->cmnd[4] = sizeof(SCp->sense_buffer);
sense->cmnd[5] = 0;
cmnd[0] = REQUEST_SENSE;
cmnd[1] = (SCp->device->lun & 0x7) << 5;
cmnd[2] = 0;
cmnd[3] = 0;
cmnd[4] = sizeof(SCp->sense_buffer);
cmnd[5] = 0;
/* Here's a quiet hack: the
* REQUEST_SENSE command is six bytes,
* so store a flag indicating that
* this was an internal sense request
* and the original status at the end
* of the command */
sense->cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;
sense->cmnd[7] = hostdata->status[0];
slot->pCmd = dma_map_single(hostdata->dev, sense->cmnd, sizeof(sense->cmnd), DMA_TO_DEVICE);
cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;
cmnd[7] = hostdata->status[0];
slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
Expand Down Expand Up @@ -1531,7 +1530,7 @@ NCR_700_intr(int irq, void *dev_id, struct pt_regs *regs)

/* clear all the negotiated parameters */
__shost_for_each_device(SDp, host)
SDp->hostdata = NULL;
NCR_700_clear_flag(SDp, ~0);

/* clear all the slots and their pending commands */
for(i = 0; i < NCR_700_COMMAND_SLOTS_PER_HOST; i++) {
Expand Down Expand Up @@ -2036,19 +2035,24 @@ NCR_700_set_offset(struct scsi_target *STp, int offset)
spi_flags(STp) |= NCR_700_DEV_PRINT_SYNC_NEGOTIATION;
}

STATIC int
NCR_700_slave_alloc(struct scsi_device *SDp)
{
SDp->hostdata = kzalloc(sizeof(struct NCR_700_Device_Parameters),
GFP_KERNEL);

if (!SDp->hostdata)
return -ENOMEM;

return 0;
}

STATIC int
NCR_700_slave_configure(struct scsi_device *SDp)
{
struct NCR_700_Host_Parameters *hostdata =
(struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];

SDp->hostdata = kmalloc(sizeof(struct NCR_700_sense), GFP_KERNEL);

if (!SDp->hostdata)
return -ENOMEM;

/* to do here: allocate memory; build a queue_full list */
if(SDp->tagged_supported) {
scsi_set_tag_type(SDp, MSG_ORDERED_TAG);
Expand Down
34 changes: 23 additions & 11 deletions trunk/drivers/scsi/53c700.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <asm/io.h>

#include <scsi/scsi_device.h>

#include <scsi/scsi_cmnd.h>

/* Turn on for general debugging---too verbose for normal use */
#undef NCR_700_DEBUG
Expand Down Expand Up @@ -76,11 +76,16 @@ struct NCR_700_SG_List {
#define SCRIPT_RETURN 0x90080000
};

/* We use device->hostdata to store negotiated parameters. This is
* supposed to be a pointer to a device private area, but we cannot
* really use it as such since it will never be freed, so just use the
* 32 bits to cram the information. The SYNC negotiation sequence looks
* like:
struct NCR_700_Device_Parameters {
/* space for creating a request sense command. Really, except
* for the annoying SCSI-2 requirement for LUN information in
* cmnd[1], this could be in static storage */
unsigned char cmnd[MAX_COMMAND_SIZE];
__u8 depth;
};


/* The SYNC negotiation sequence looks like:
*
* If DEV_NEGOTIATED_SYNC not set, tack and SDTR message on to the
* initial identify for the device and set DEV_BEGIN_SYNC_NEGOTATION
Expand All @@ -98,19 +103,26 @@ struct NCR_700_SG_List {
#define NCR_700_DEV_BEGIN_SYNC_NEGOTIATION (1<<17)
#define NCR_700_DEV_PRINT_SYNC_NEGOTIATION (1<<19)

static inline char *NCR_700_get_sense_cmnd(struct scsi_device *SDp)
{
struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;

return hostdata->cmnd;
}

static inline void
NCR_700_set_depth(struct scsi_device *SDp, __u8 depth)
{
long l = (long)SDp->hostdata;
struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;

l &= 0xffff00ff;
l |= 0xff00 & (depth << 8);
SDp->hostdata = (void *)l;
hostdata->depth = depth;
}
static inline __u8
NCR_700_get_depth(struct scsi_device *SDp)
{
return ((((unsigned long)SDp->hostdata) & 0xff00)>>8);
struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;

return hostdata->depth;
}
static inline int
NCR_700_is_flag_set(struct scsi_device *SDp, __u32 flag)
Expand Down

0 comments on commit 553e301

Please sign in to comment.