Re: [PATCH 16/22] advansys: Eliminate prototypes

2007-09-16 Thread Matthew Wilcox
On Sat, Sep 15, 2007 at 09:39:05AM -0500, James Bottomley wrote:
> I get a compile failure at this point in your patch sequence:

Thanks.  I'd been compiling with CONFIG_ISA=n, so hadn't spotted these
two problems.  I've set it back to Y now.

> I've put 1-15 in .. could you rebase against scsi-misc and eliminate
> this problem?

Yup.  I've written some more patches since, and I'll include those too.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/17] advansys: Remove ASC_WIDE_BOARD predicate

2007-09-16 Thread Matthew Wilcox
Replace it with !ASC_NARROW_BOARD

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 5e6bcf2..a5bb4e4 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2232,7 +2232,6 @@ do { \
 #define ASC_IS_WIDE_BOARD   0x04   /* AdvanSys Wide Board */
 
 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
-#define ASC_WIDE_BOARD(boardp)   ((boardp)->flags & ASC_IS_WIDE_BOARD)
 
 #define NO_ISA_DMA  0xff   /* No ISA DMA Channel Used */
 
@@ -4385,7 +4384,7 @@ advansys_proc_info(struct Scsi_Host *shost, char *buffer, 
char **start,
/*
 * Display Wide Board BIOS Information.
 */
-   if (ASC_WIDE_BOARD(boardp)) {
+   if (!ASC_NARROW_BOARD(boardp)) {
cp = boardp->prtbuf;
cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
BUG_ON(cplen >= ASC_PRTBUF_SIZE);
@@ -14432,7 +14431,7 @@ static int advansys_release(struct Scsi_Host *shost)
ASC_DBG(1, "advansys_release: free_dma()\n");
free_dma(shost->dma_channel);
}
-   if (ASC_WIDE_BOARD(boardp)) {
+   if (!ASC_NARROW_BOARD(boardp)) {
iounmap(boardp->ioremap_addr);
advansys_wide_free_mem(boardp);
}
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/17] advansys: Remove array of scsi targets

2007-09-16 Thread Matthew Wilcox
The driver was saving a scsi_device for each target, but wasn't doing
anything useful with them.  Just delete the array.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4f047cc..737c0e4 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2514,7 +2514,6 @@ typedef struct asc_board {
} dvc_cfg;
ushort asc_n_io_port;   /* Number I/O ports. */
ADV_SCSI_BIT_ID_TYPE init_tidmask;  /* Target init./valid mask */
-   struct scsi_device *device[ADV_MAX_TID + 1];/* Mid-Level Scsi 
Device */
ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
ADV_SCSI_BIT_ID_TYPE queue_full;/* Queue full mask */
ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
@@ -10183,13 +10182,6 @@ static int advansys_slave_configure(struct scsi_device 
*sdev)
asc_board_t *boardp = ASC_BOARDP(sdev->host);
boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
 
-   /*
-* Save a pointer to the sdev and set its initial/maximum
-* queue depth.  Only save the pointer for a lun0 dev though.
-*/
-   if (sdev->lun == 0)
-   boardp->device[sdev->id] = sdev;
-
if (ASC_NARROW_BOARD(boardp))
advansys_narrow_slave_configure(sdev,
&boardp->dvc_var.asc_dvc_var);
@@ -11343,14 +11335,12 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd 
*scp)
ASC_DVC_VAR *asc_dvc_varp;
ADV_DVC_VAR *adv_dvc_varp;
ADV_SCSI_REQ_Q *adv_scsiqp;
-   struct scsi_device *device;
int ret;
 
ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
 (ulong)scp, (ulong)scp->scsi_done);
 
boardp = ASC_BOARDP(scp->device->host);
-   device = boardp->device[scp->device->id];
 
if (ASC_NARROW_BOARD(boardp)) {
/*
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/17] advansys: Remove ASC_SELECT_QUEUE_DEPTHS

2007-09-16 Thread Matthew Wilcox
It was only ever set; never tested, nor cleared.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 52ea41d..5e6bcf2 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2230,7 +2230,6 @@ do { \
 
 /* asc_board_t flags */
 #define ASC_IS_WIDE_BOARD   0x04   /* AdvanSys Wide Board */
-#define ASC_SELECT_QUEUE_DEPTHS 0x08
 
 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
 #define ASC_WIDE_BOARD(boardp)   ((boardp)->flags & ASC_IS_WIDE_BOARD)
@@ -10135,7 +10134,6 @@ advansys_wide_slave_configure(struct scsi_device *sdev, 
ADV_DVC_VAR *adv_dvc)
 static int advansys_slave_configure(struct scsi_device *sdev)
 {
asc_board_t *boardp = ASC_BOARDP(sdev->host);
-   boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
 
if (ASC_NARROW_BOARD(boardp))
advansys_narrow_slave_configure(sdev,
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/17] advansys: Fix simultaneous calls to ->queuecommand

2007-09-16 Thread Matthew Wilcox
The narrow board used two global structures to set up a command;
unfortunately they weren't locked, so with two boards in the machine,
one call to queuecommand could corrupt the data being used by the other
call to queuecommand.

Fix this by allocating asc_scsi_q on the stack (64 bytes) and using kmalloc
for the asc_sg_head (2k)

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   88 +--
 1 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 3dd7856..fd4d669 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -380,7 +380,7 @@ typedef struct asc_sg_head {
ushort queue_cnt;
ushort entry_to_copy;
ushort res;
-   ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
+   ASC_SG_LIST sg_list[0];
 } ASC_SG_HEAD;
 
 typedef struct asc_scsi_q {
@@ -2559,12 +2559,6 @@ static int asc_board_count;
 /* Overrun buffer used by all narrow boards. */
 static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
 
-/*
- * Global structures required to issue a command.
- */
-static ASC_SCSI_Q asc_scsi_q = { {0} };
-static ASC_SG_HEAD asc_sg_head = { 0 };
-
 #ifdef ADVANSYS_DEBUG
 static int asc_dbglvl = 3;
 
@@ -10192,39 +10186,28 @@ static int advansys_slave_configure(struct 
scsi_device *sdev)
return 0;
 }
 
-/*
- * Build a request structure for the Asc Library (Narrow Board).
- *
- * The global structures 'asc_scsi_q' and 'asc_sg_head' are
- * used to build the request.
- *
- * If an error occurs, then return ASC_ERROR.
- */
-static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
+static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
+   struct asc_scsi_q *asc_scsi_q)
 {
-   /*
-* Mutually exclusive access is required to 'asc_scsi_q' and
-* 'asc_sg_head' until after the request is started.
-*/
-   memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
+   memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
 
/*
 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
 */
-   asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
+   asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
 
/*
 * Build the ASC_SCSI_Q request.
 */
-   asc_scsi_q.cdbptr = &scp->cmnd[0];
-   asc_scsi_q.q2.cdb_len = scp->cmd_len;
-   asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
-   asc_scsi_q.q1.target_lun = scp->device->lun;
-   asc_scsi_q.q2.target_ix =
+   asc_scsi_q->cdbptr = &scp->cmnd[0];
+   asc_scsi_q->q2.cdb_len = scp->cmd_len;
+   asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
+   asc_scsi_q->q1.target_lun = scp->device->lun;
+   asc_scsi_q->q2.target_ix =
ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
-   asc_scsi_q.q1.sense_addr =
+   asc_scsi_q->q1.sense_addr =
cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
-   asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
+   asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
 
/*
 * If there are any outstanding requests for the current target,
@@ -10239,9 +10222,9 @@ static int asc_build_req(asc_board_t *boardp, struct 
scsi_cmnd *scp)
 */
if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
(boardp->reqcnt[scp->device->id] % 255) == 0) {
-   asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
+   asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
} else {
-   asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
+   asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
}
 
/*
@@ -10257,12 +10240,12 @@ static int asc_build_req(asc_board_t *boardp, struct 
scsi_cmnd *scp)
dma_map_single(boardp->dev, scp->request_buffer,
   scp->request_bufflen,
   scp->sc_data_direction) : 0;
-   asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
-   asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
+   asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
+   asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
ASC_STATS_ADD(scp->device->host, cont_xfer,
  ASC_CEILING(scp->request_bufflen, 512));
-   asc_scsi_q.q1.sg_queue_cnt = 0;
-   asc_scsi_q.sg_head = NULL;
+   asc_scsi_q->q1.sg_queue_cnt = 0;
+   asc_scsi_q->sg_head = NULL;
} else {
/*
 * CDB scatter-gather request list.
@@ -10270,6 +10253,7 @@ static int asc_build_req(asc_board_t *boardp, struct 
scsi_cmnd *scp)
int sgcnt;
int use_sg;
struct scatterlist *slp;
+   struct asc_sg_head *asc_sg_head;
 
 

[PATCH 05/17] advansys: Improve reset handler

2007-09-16 Thread Matthew Wilcox
 - Don't need to set ASC_HOST_IN_RESET any more
 - Don't need to test scp->device->host for NULL -- if it's NULL, we
   couldn't've been called.
 - Use scmd_printk instead of ASC_PRINT

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   83 --
 1 files changed, 22 insertions(+), 61 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index fd4d669..52ea41d 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2229,7 +2229,6 @@ do { \
 #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
 
 /* asc_board_t flags */
-#define ASC_HOST_IN_RESET   0x01
 #define ASC_IS_WIDE_BOARD   0x04   /* AdvanSys Wide Board */
 #define ASC_SELECT_QUEUE_DEPTHS 0x08
 
@@ -9751,106 +9750,68 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
  */
 static int advansys_reset(struct scsi_cmnd *scp)
 {
-   struct Scsi_Host *shost;
-   asc_board_t *boardp;
-   ASC_DVC_VAR *asc_dvc_varp;
-   ADV_DVC_VAR *adv_dvc_varp;
-   ulong flags;
+   struct Scsi_Host *shost = scp->device->host;
+   struct asc_board *boardp = ASC_BOARDP(shost);
+   unsigned long flags;
int status;
int ret = SUCCESS;
 
-   ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
+   ASC_DBG1(1, "advansys_reset: 0x%p\n", scp);
 
-#ifdef ADVANSYS_STATS
-   if (scp->device->host != NULL) {
-   ASC_STATS(scp->device->host, reset);
-   }
-#endif /* ADVANSYS_STATS */
-
-   if ((shost = scp->device->host) == NULL) {
-   scp->result = HOST_BYTE(DID_ERROR);
-   return FAILED;
-   }
+   ASC_STATS(shost, reset);
 
-   boardp = ASC_BOARDP(shost);
-
-   ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
-  boardp->id);
-   /*
-* Check for re-entrancy.
-*/
-   spin_lock_irqsave(&boardp->lock, flags);
-   if (boardp->flags & ASC_HOST_IN_RESET) {
-   spin_unlock_irqrestore(&boardp->lock, flags);
-   return FAILED;
-   }
-   boardp->flags |= ASC_HOST_IN_RESET;
-   spin_unlock_irqrestore(&boardp->lock, flags);
+   scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
 
if (ASC_NARROW_BOARD(boardp)) {
-   /*
-* Narrow Board
-*/
-   asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
+   ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 
-   /*
-* Reset the chip and SCSI bus.
-*/
+   /* Reset the chip and SCSI bus. */
ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
-   status = AscInitAsc1000Driver(asc_dvc_varp);
+   status = AscInitAsc1000Driver(asc_dvc);
 
/* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
-   if (asc_dvc_varp->err_code) {
-   ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
-  "error: 0x%x\n", boardp->id,
-  asc_dvc_varp->err_code);
+   if (asc_dvc->err_code) {
+   scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
+   "0x%x\n", asc_dvc->err_code);
ret = FAILED;
} else if (status) {
-   ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
-  "warning: 0x%x\n", boardp->id, status);
+   scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
+   "0x%x\n", status);
} else {
-   ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
-  "successful.\n", boardp->id);
+   scmd_printk(KERN_INFO, scp, "SCSI bus reset "
+   "successful\n");
}
 
ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
spin_lock_irqsave(&boardp->lock, flags);
-
} else {
/*
-* Wide Board
-*
 * If the suggest reset bus flags are set, then reset the bus.
 * Otherwise only reset the device.
 */
-   adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
+   ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
 
/*
 * Reset the target's SCSI bus.
 */
ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
-   switch (AdvResetChipAndSB(adv_dvc_varp)) {
+   switch (AdvResetChipAndSB(adv_dvc)) {
case ASC_TRUE:
-   ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
-  "successful.\n", boardp->id);
+  

[PATCH 03/17] advansys: Restructure asc_execute_scsi_cmnd()

2007-09-16 Thread Matthew Wilcox
The wide and narrow boards share identical handling of the return value,
except for some trivial error messages.  Move the handling to the common
end of the function.  Also move variable declarations to the arms of
the `if' that they're used in and delete some pointless comments.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  131 ++-
 1 files changed, 39 insertions(+), 92 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 737c0e4..3dd7856 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -11331,80 +11331,26 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, 
ADV_SCSI_REQ_Q *scsiq)
  */
 static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 {
-   asc_board_t *boardp;
-   ASC_DVC_VAR *asc_dvc_varp;
-   ADV_DVC_VAR *adv_dvc_varp;
-   ADV_SCSI_REQ_Q *adv_scsiqp;
-   int ret;
+   int ret, err_code;
+   asc_board_t *boardp = ASC_BOARDP(scp->device->host);
 
-   ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
-(ulong)scp, (ulong)scp->scsi_done);
-
-   boardp = ASC_BOARDP(scp->device->host);
+   ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
 
if (ASC_NARROW_BOARD(boardp)) {
-   /*
-* Build and execute Narrow Board request.
-*/
-
-   asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
+   ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 
-   /*
-* Build Asc Library request structure using the
-* global structures 'asc_scsi_req' and 'asc_sg_head'.
-*
-* If an error is returned, then the request has been
-* queued on the board done queue. It will be completed
-* by the caller.
-*
-* asc_build_req() can not return ASC_BUSY.
-*/
+   /* asc_build_req() can not return ASC_BUSY. */
if (asc_build_req(boardp, scp) == ASC_ERROR) {
ASC_STATS(scp->device->host, build_error);
return ASC_ERROR;
}
 
-   switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
-   case ASC_NOERROR:
-   ASC_STATS(scp->device->host, exe_noerror);
-   /*
-* Increment monotonically increasing per device
-* successful request counter. Wrapping doesn't matter.
-*/
-   boardp->reqcnt[scp->device->id]++;
-   ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
-   "ASC_NOERROR\n");
-   break;
-   case ASC_BUSY:
-   ASC_STATS(scp->device->host, exe_busy);
-   break;
-   case ASC_ERROR:
-   ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
-   "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
-   boardp->id, asc_dvc_varp->err_code);
-   ASC_STATS(scp->device->host, exe_error);
-   scp->result = HOST_BYTE(DID_ERROR);
-   break;
-   default:
-   ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
-   "AscExeScsiQueue() unknown, err_code 0x%x\n",
-   boardp->id, asc_dvc_varp->err_code);
-   ASC_STATS(scp->device->host, exe_unknown);
-   scp->result = HOST_BYTE(DID_ERROR);
-   break;
-   }
+   ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
+   err_code = asc_dvc->err_code;
} else {
-   /*
-* Build and execute Wide Board request.
-*/
-   adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
+   ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
+   ADV_SCSI_REQ_Q *adv_scsiqp;
 
-   /*
-* Build and get a pointer to an Adv Library request structure.
-*
-* If the request is successfully built then send it below,
-* otherwise return with an error.
-*/
switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
case ASC_NOERROR:
ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
@@ -11428,35 +11374,36 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd 
*scp)
return ASC_ERROR;
}
 
-   switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
-   case ASC_NOERROR:
-   ASC_STATS(scp->device->host, exe_noerror);
-   /*
- 

[PATCH 10/17] advansys: Remove asc_board_t typedef and ASC_BOARDP macro

2007-09-16 Thread Matthew Wilcox
asc_board_t was simply a typedef for struct asc_board.  ASC_BOARDP()
can be replaced by shost_priv() except in the ASC_STATS* macros which
rely on the cast; add an explicit cast there.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  132 ++-
 1 files changed, 51 insertions(+), 81 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4c792db..e09ab95 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2203,10 +2203,7 @@ do { \
  (sizeof(ADV_SG_BLOCK) * \
   ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
 
-/* Reference Scsi_Host hostdata */
-#define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
-
-/* asc_board_t flags */
+/* struct asc_board flags */
 #define ASC_IS_WIDE_BOARD   0x04   /* AdvanSys Wide Board */
 
 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
@@ -2244,15 +2241,12 @@ do { \
 #define HOST_BYTE(byte) ((byte) << 16)
 #define DRIVER_BYTE(byte)   ((byte) << 24)
 
+#define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
 #ifndef ADVANSYS_STATS
-#define ASC_STATS(shost, counter)
 #define ASC_STATS_ADD(shost, counter, count)
 #else /* ADVANSYS_STATS */
-#define ASC_STATS(shost, counter) \
-(ASC_BOARDP(shost)->asc_stats.counter++)
-
 #define ASC_STATS_ADD(shost, counter, count) \
-(ASC_BOARDP(shost)->asc_stats.counter += (count))
+   (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
 #endif /* ADVANSYS_STATS */
 
 #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
@@ -2475,7 +2469,7 @@ typedef struct adv_req {
  * of the 'Scsi_Host' structure starting at the 'hostdata'
  * field. It is guaranteed to be allocated from DMA-able memory.
  */
-typedef struct asc_board {
+struct asc_board {
struct device *dev;
int id; /* Board Id */
uint flags; /* Board flags */
@@ -2523,7 +2517,7 @@ typedef struct asc_board {
ushort bios_version;/* BIOS Version. */
ushort bios_codeseg;/* BIOS Code Segment. */
ushort bios_codelen;/* BIOS Code Segment Length. */
-} asc_board_t;
+} asc_board;
 
 #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
dvc_var.adv_dvc_var)
@@ -2543,9 +2537,7 @@ static int asc_dbglvl = 3;
  */
 static void asc_prt_scsi_host(struct Scsi_Host *s)
 {
-   asc_board_t *boardp;
-
-   boardp = ASC_BOARDP(s);
+   struct asc_board *boardp = shost_priv(s);
 
printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
printk(" host_busy %u, host_no %d, last_reset %d,\n",
@@ -2561,11 +2553,11 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
   s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
 
if (ASC_NARROW_BOARD(boardp)) {
-   asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
-   asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
+   asc_prt_asc_dvc_var(boardp->dvc_var.asc_dvc_var);
+   asc_prt_asc_dvc_cfg(boardp->dvc_cfg.asc_dvc_cfg);
} else {
-   asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
-   asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
+   asc_prt_adv_dvc_var(boardp->dvc_var.adv_dvc_var);
+   asc_prt_adv_dvc_cfg(boardp->dvc_cfg.adv_dvc_cfg);
}
 }
 
@@ -2914,13 +2906,12 @@ static void asc_prt_hex(char *f, uchar *s, int l)
 static const char *advansys_info(struct Scsi_Host *shost)
 {
static char info[ASC_INFO_SIZE];
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
ASC_DVC_VAR *asc_dvc_varp;
ADV_DVC_VAR *adv_dvc_varp;
char *busname;
char *widename = NULL;
 
-   boardp = ASC_BOARDP(shost);
if (ASC_NARROW_BOARD(boardp)) {
asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
ASC_DBG(1, "advansys_info: begin\n");
@@ -3032,14 +3023,13 @@ static int asc_prt_line(char *buf, int buflen, char 
*fmt, ...)
  */
 static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
 {
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
int leftlen;
int totlen;
int len;
int chip_scsi_id;
int i;
 
-   boardp = ASC_BOARDP(shost);
leftlen = cplen;
totlen = len = 0;
 
@@ -3073,13 +3063,12 @@ static int asc_prt_board_devices(struct Scsi_Host 
*shost, char *cp, int cplen)
  */
 static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
 {
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
int leftlen;
int totlen;
int len;
ushort major, minor, letter;
 
-   boardp = ASC_BOARDP(shost);
leftlen = cplen;
   

[PATCH 17/17] advansys: Remove DvcGetPhyAddr

2007-09-16 Thread Matthew Wilcox
This rather complex function boiled down to calling virt_to_bus().
Also get rid of some obsolete defines and variables that could never vary.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   73 ++-
 1 files changed, 3 insertions(+), 70 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 2b50aa1..bd5bbc9 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -992,19 +992,6 @@ typedef struct asc_mc_saved {
 #define ADV_MAX_SG_LIST 255
 #define NO_OF_SG_PER_BLOCK  15
 
-/* Number of SG blocks needed. */
-#define ADV_NUM_SG_BLOCK \
-((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
-
-/* Total contiguous memory needed for SG blocks. */
-#define ADV_SG_TOTAL_MEM_SIZE \
-(sizeof(ADV_SG_BLOCK) *  ADV_NUM_SG_BLOCK)
-
-#define ADV_PAGE_SIZE PAGE_SIZE
-
-#define ADV_NUM_PAGE_CROSSING \
-((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
-
 #define ADV_EEP_DVC_CFG_BEGIN   (0x00)
 #define ADV_EEP_DVC_CFG_END (0x15)
 #define ADV_EEP_DVC_CTL_BEGIN   (0x16) /* location of OEM name */
@@ -1792,8 +1779,7 @@ typedef struct adv_carr_t {
 #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
 
 #define ADV_CARRIER_NUM_PAGE_CROSSING \
-(((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
-(ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
+(((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
 
 #define ADV_CARRIER_BUFSIZE \
 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
@@ -2174,16 +2160,6 @@ do { \
 #define QHSTA_M_FROZEN_TIDQ 0x46   /* TID Queue frozen. */
 #define QHSTA_M_SGBACKUP_ERROR  0x47   /* Scatter-Gather backup error 
*/
 
-/*
- * DvcGetPhyAddr() flag arguments
- */
-#define ADV_IS_SCSIQ_FLAG   0x01   /* 'addr' is ASC_SCSI_REQ_Q pointer */
-#define ADV_ASCGETSGLIST_VADDR  0x02   /* 'addr' is AscGetSGList() virtual 
addr */
-#define ADV_IS_SENSE_FLAG   0x04   /* 'addr' is sense virtual pointer */
-#define ADV_IS_DATA_FLAG0x08   /* 'addr' is data virtual pointer */
-#define ADV_IS_SGLIST_FLAG  0x10   /* 'addr' is sglist virtual pointer */
-#define ADV_IS_CARRIER_FLAG 0x20   /* 'addr' is ADV_CARR_T pointer */
-
 /* Return the address that is aligned at the next doubleword >= to 'addr'. */
 #define ADV_8BALIGN(addr)  (((ulong) (addr) + 0x7) & ~0x7)
 #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
@@ -6483,29 +6459,6 @@ static int AdvLoadMicrocode(AdvPortAddr iop_base, 
unsigned char *buf, int size,
return 0;
 }
 
-/*
- * DvcGetPhyAddr()
- *
- * Return the physical address of 'vaddr' and set '*lenp' to the
- * number of physically contiguous bytes that follow 'vaddr'.
- * 'flag' indicates the type of structure whose physical address
- * is being translated.
- *
- * Note: Because Linux currently doesn't page the kernel and all
- * kernel buffers are physically contiguous, leave '*lenp' unchanged.
- */
-ADV_PADDR
-DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
- uchar *vaddr, ADV_SDCNT *lenp, int flag)
-{
-   ADV_PADDR paddr = virt_to_bus(vaddr);
-
-   ASC_DBG(4, "vaddr 0x%p, lenp 0x%p *lenp %lu, paddr 0x%lx\n",
-vaddr, lenp, (ulong)*((ulong *)lenp), (ulong)paddr);
-
-   return paddr;
-}
-
 static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
 {
ADV_CARR_T *carrp;
@@ -6522,24 +6475,10 @@ static void AdvBuildCarrierFreelist(struct adv_dvc_var 
*asc_dvc)
 
do {
/* Get physical address of the carrier 'carrp'. */
-   ADV_DCNT contig_len = sizeof(ADV_CARR_T);
-   carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
-  (uchar *)carrp,
-  (ADV_SDCNT *)&contig_len,
-  ADV_IS_CARRIER_FLAG));
+   carr_paddr = cpu_to_le32(virt_to_bus(carrp));
 
buf_size -= sizeof(ADV_CARR_T);
 
-   /*
-* If the current carrier is not physically contiguous, then
-* maybe there was a page crossing. Try the next carrier
-* aligned start address.
-*/
-   if (contig_len < sizeof(ADV_CARR_T)) {
-   carrp++;
-   continue;
-   }
-
carrp->carr_pa = carr_paddr;
carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
 
@@ -10915,7 +10854,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, 
ASC_SCSI_Q *scsiq)
 static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
 {
AdvPortAddr iop_base;
-   ADV_DCNT req_size;
ADV_PADDR req_paddr;
ADV_CARR_T *new_carrp;
 
@@ -10953,13 +10891,8 @@ static int AdvExeScsiQueue(ADV_DVC_VAR 

[PATCH 16/17] advansys: Move a couple of fields from struct board to struct adv_dvc

2007-09-16 Thread Matthew Wilcox
board->carrp is a duplicate of asc_dvc->carrier_buf, so cut out the
middle-man and assign directly to carrier_buf.  Move orig_reqp to adv_dvc
too, since it's wide-board specific.  Also eliminate an unnecessary BUG_ON
(we'll never get there with a NULL carrier_buf, and will crash if we do).
The bulk of this patch is rearranging structures so everything's declared
in the right order.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  193 ++
 1 files changed, 92 insertions(+), 101 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 899151a..2b50aa1 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -983,15 +983,14 @@ typedef struct asc_mc_saved {
  * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  * structures or 255 scatter-gather elements.
- *
  */
 #define ADV_TOT_SG_BLOCKASC_DEF_MAX_HOST_QNG
 
 /*
- * Define Adv Library required maximum number of scatter-gather
- * elements per request.
+ * Define maximum number of scatter-gather elements per request.
  */
 #define ADV_MAX_SG_LIST 255
+#define NO_OF_SG_PER_BLOCK  15
 
 /* Number of SG blocks needed. */
 #define ADV_NUM_SG_BLOCK \
@@ -1839,55 +1838,6 @@ typedef struct adv_dvc_cfg {
 struct adv_dvc_var;
 struct adv_scsi_req_q;
 
-/*
- * Adapter operation variable structure.
- *
- * One structure is required per host adapter.
- *
- * Field naming convention:
- *
- *  *_able indicates both whether a feature should be enabled or disabled
- *  and whether a device isi capable of the feature. At initialization
- *  this field may be set, but later if a device is found to be incapable
- *  of the feature, the field is cleared.
- */
-typedef struct adv_dvc_var {
-   AdvPortAddr iop_base;   /* I/O port address */
-   ushort err_code;/* fatal error code */
-   ushort bios_ctrl;   /* BIOS control word, EEPROM word 12 */
-   ushort wdtr_able;   /* try WDTR for a device */
-   ushort sdtr_able;   /* try SDTR for a device */
-   ushort ultra_able;  /* try SDTR Ultra speed for a device */
-   ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3   */
-   ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7   */
-   ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11  */
-   ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
-   ushort tagqng_able; /* try tagged queuing with a device */
-   ushort ppr_able;/* PPR message capable per TID bitmask. */
-   uchar max_dvc_qng;  /* maximum number of tagged commands per device 
*/
-   ushort start_motor; /* start motor command allowed */
-   uchar scsi_reset_wait;  /* delay in seconds after scsi bus reset */
-   uchar chip_no;  /* should be assigned by caller */
-   uchar max_host_qng; /* maximum number of Q'ed command allowed */
-   ushort no_scam; /* scam_tolerant of EEPROM */
-   struct asc_board *drv_ptr;  /* driver pointer to private structure 
*/
-   uchar chip_scsi_id; /* chip SCSI target ID */
-   uchar chip_type;
-   uchar bist_err_code;
-   ADV_CARR_T *carrier_buf;
-   ADV_CARR_T *carr_freelist;  /* Carrier free list. */
-   ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
-   ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
-   ushort carr_pending_cnt;/* Count of pending carriers. */
-   /*
-* Note: The following fields will not be used after initialization. The
-* driver may discard the buffer after initialization is done.
-*/
-   ADV_DVC_CFG *cfg;   /* temporary configuration structure  */
-} ADV_DVC_VAR;
-
-#define NO_OF_SG_PER_BLOCK  15
-
 typedef struct asc_sg_block {
uchar reserved1;
uchar reserved2;
@@ -1946,6 +1896,83 @@ typedef struct adv_scsi_req_q {
 } ADV_SCSI_REQ_Q;
 
 /*
+ * The following two structures are used to process Wide Board requests.
+ *
+ * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
+ * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
+ * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
+ * Mid-Level SCSI request structure.
+ *
+ * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
+ * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
+ * up to 255 scatter-gather elements may be used per request or
+ * ADV_SCSI_REQ_Q.
+ *
+ * Both structures must be 32 byte aligned.
+ */
+typedef struct adv_sgblk {
+   ADV_SG_BLOCK sg_block;  /* Sgblock structure. */
+   uchar align[32];/* Sgblock structure padding. */
+   struct adv_sgblk *next_sgblkp;  /* Next scatter-gather structure. */
+} adv_sgblk_t;
+
+typedef struc

[PATCH 15/17] advansys: Make sdtr_period_tbl a pointer

2007-09-16 Thread Matthew Wilcox
It's somewhat neater to make this a pointer to one of two tables
than initialising an array in the driver.  Also delete the unused
AscSynIndexToPeriod and rename host_init_sdtr_index to min_sdtr_index

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   90 +--
 1 files changed, 25 insertions(+), 65 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 798545d..899151a 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -481,34 +481,22 @@ typedef struct asc_risc_sg_list_q {
 #define ASC_MAX_PCI_INRAM_TOTAL_QNG  20
 #define ASC_MAX_INRAM_TAG_QNG   16
 #define ASC_IOADR_GAP   0x10
-#define ASC_MAX_SYN_XFER_NO16
 #define ASC_SYN_MAX_OFFSET 0x0F
 #define ASC_DEF_SDTR_OFFSET0x0F
 #define ASC_SDTR_ULTRA_PCI_10MB_INDEX  0x02
-#define SYN_XFER_NS_0  25
-#define SYN_XFER_NS_1  30
-#define SYN_XFER_NS_2  35
-#define SYN_XFER_NS_3  40
-#define SYN_XFER_NS_4  50
-#define SYN_XFER_NS_5  60
-#define SYN_XFER_NS_6  70
-#define SYN_XFER_NS_7  85
-#define SYN_ULTRA_XFER_NS_012
-#define SYN_ULTRA_XFER_NS_119
-#define SYN_ULTRA_XFER_NS_225
-#define SYN_ULTRA_XFER_NS_332
-#define SYN_ULTRA_XFER_NS_438
-#define SYN_ULTRA_XFER_NS_544
-#define SYN_ULTRA_XFER_NS_650
-#define SYN_ULTRA_XFER_NS_757
-#define SYN_ULTRA_XFER_NS_863
-#define SYN_ULTRA_XFER_NS_969
-#define SYN_ULTRA_XFER_NS_10   75
-#define SYN_ULTRA_XFER_NS_11   82
-#define SYN_ULTRA_XFER_NS_12   88
-#define SYN_ULTRA_XFER_NS_13   94
-#define SYN_ULTRA_XFER_NS_14  100
-#define SYN_ULTRA_XFER_NS_15  107
+#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
+
+/* The narrow chip only supports a limited selection of transfer rates.
+ * These are encoded in the range 0..7 or 0..15 depending whether the chip
+ * is Ultra-capable or not.  These tables let us convert from one to the other.
+ */
+static const unsigned char asc_syn_xfer_period[8] = {
+   25, 30, 35, 40, 50, 60, 70, 85
+};
+
+static const unsigned char asc_syn_ultra_xfer_period[16] = {
+   12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
+};
 
 typedef struct ext_msg {
uchar msg_type;
@@ -572,7 +560,6 @@ typedef struct asc_dvc_cfg {
 #define ASC_INIT_STATE_WITHOUT_EEP   0x8000
 #define ASC_BUG_FIX_IF_NOT_DWB   0x0001
 #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
-#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
 #define ASC_MIN_TAGGED_CMD  7
 #define ASC_MAX_SCSI_RESET_WAIT  30
 
@@ -602,7 +589,7 @@ typedef struct asc_dvc_var {
uchar max_dvc_qng[ASC_MAX_TID + 1];
ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
-   uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
+   const uchar *sdtr_period_tbl;
ASC_DVC_CFG *cfg;
ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
char redo_scam;
@@ -611,8 +598,8 @@ typedef struct asc_dvc_var {
ASC_DCNT max_dma_count;
ASC_SCSI_BIT_ID_TYPE no_scam;
ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
+   uchar min_sdtr_index;
uchar max_sdtr_index;
-   uchar host_init_sdtr_index;
struct asc_board *drv_ptr;
ASC_DCNT uc_break;
 } ASC_DVC_VAR;
@@ -896,7 +883,6 @@ typedef struct asc_mc_saved {
 #define AscGetMCodeSDTRDoneAtID(port, id)AscReadLramByte((port), 
(ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
 #define AscPutMCodeInitSDTRAtID(port, id, data)  AscWriteLramByte((port), 
(ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
 #define AscGetMCodeInitSDTRAtID(port, id)AscReadLramByte((port), 
(ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
-#define AscSynIndexToPeriod(index)(uchar)(asc_dvc->sdtr_period_tbl[ 
(index) ])
 #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
 #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
 #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
@@ -8556,14 +8542,14 @@ static void AscAckInterrupt(PortAddr iop_base)
 
 static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
 {
-   uchar *period_table;
+   const uchar *period_table;
int max_index;
int min_index;
int i;
 
period_table = asc_dvc->sdtr_period_tbl;
max_index = (int)asc_dvc->max_sdtr_index;
-   min_index = (int)asc_dvc->host_init_sdtr_index;
+   min_index = (int)asc_dvc->min_sdtr_index;
if ((syn_time <= period_table[max_index])) {
for (i = min_index; i < (max_index - 1); i++) {
if (syn_time <= period_table[i]) {
@@ -8612,9 +8598,8 @@ AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, 
uchar syn_offset)
uchar sdtr_period_ix;
 
sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
-   if (sdtr_period_ix > asc_dvc->max_sdtr_index) {
+   if (sdtr_period_ix > asc_dvc->max_sdtr_index)
return 0xFF;
-

[PATCH 14/17] advansys: Get rid of board index number

2007-09-16 Thread Matthew Wilcox
It's always a mistake to have your own index of boards; just use the
scsi host number.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  236 ---
 1 files changed, 100 insertions(+), 136 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index b652032..798545d 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -66,8 +66,7 @@
  *  5. check DMA mapping functions for failure
  *  6. Use scsi_transport_spi
  *  7. advansys_info is not safe against multiple simultaneous callers
- *  8. Kill boardp->id
- *  9. Add module_param to override ISA/VLB ioport array
+ *  8. Add module_param to override ISA/VLB ioport array
  */
 #warning this driver is still not properly converted to the DMA API
 
@@ -2416,7 +2415,6 @@ typedef struct adv_req {
  */
 struct asc_board {
struct device *dev;
-   int id; /* Board Id */
uint flags; /* Board flags */
unsigned int irq;
union {
@@ -2467,9 +2465,6 @@ struct asc_board {
dvc_var.adv_dvc_var)
 #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
 
-/* Number of boards detected in system. */
-static int asc_board_count;
-
 /* Overrun buffer used by all narrow boards. */
 static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
 
@@ -2848,9 +2843,8 @@ static const char *advansys_info(struct Scsi_Host *shost)
}
} else {
busname = "?";
-   ASC_PRINT2("advansys_info: board %d: unknown "
-  "bus type %d\n", boardp->id,
-  asc_dvc_varp->bus_type);
+   shost_printk(KERN_ERR, shost, "unknown bus "
+   "type %d\n", asc_dvc_varp->bus_type);
}
sprintf(info,
"AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 
0x%X",
@@ -4382,7 +4376,6 @@ static void AscSetBank(PortAddr iop_base, uchar bank)
val &= ~CC_BANK_ONE;
}
AscSetChipControl(iop_base, val);
-   return;
 }
 
 static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
@@ -4390,7 +4383,6 @@ static void AscSetChipIH(PortAddr iop_base, ushort 
ins_code)
AscSetBank(iop_base, 1);
AscWriteChipIH(iop_base, ins_code);
AscSetBank(iop_base, 0);
-   return;
 }
 
 static int AscStartChip(PortAddr iop_base)
@@ -4475,7 +4467,6 @@ static void AscEnableInterrupt(PortAddr iop_base)
 
cfg = AscGetChipCfgLsw(iop_base);
AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
-   return;
 }
 
 static void AscDisableInterrupt(PortAddr iop_base)
@@ -4484,7 +4475,6 @@ static void AscDisableInterrupt(PortAddr iop_base)
 
cfg = AscGetChipCfgLsw(iop_base);
AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
-   return;
 }
 
 static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
@@ -4542,7 +4532,6 @@ static void AscWriteLramWord(PortAddr iop_base, ushort 
addr, ushort word_val)
 {
AscSetChipLramAddr(iop_base, addr);
AscSetChipLramData(iop_base, word_val);
-   return;
 }
 
 static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
@@ -4560,7 +4549,6 @@ static void AscWriteLramByte(PortAddr iop_base, ushort 
addr, uchar byte_val)
word_data |= ((ushort)byte_val & 0x00FF);
}
AscWriteLramWord(iop_base, addr, word_data);
-   return;
 }
 
 /*
@@ -4588,7 +4576,6 @@ AscMemWordCopyPtrToLram(PortAddr iop_base,
outpw(iop_base + IOP_RAM_DATA,
  ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
}
-   return;
 }
 
 /*
@@ -4608,7 +4595,6 @@ AscMemDWordCopyPtrToLram(PortAddr iop_base,
outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | 
s_buffer[i]);   /* LSW */
outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | 
s_buffer[i + 2]);   /* MSW */
}
-   return;
 }
 
 /*
@@ -4630,7 +4616,6 @@ AscMemWordCopyPtrFromLram(PortAddr iop_base,
d_buffer[i] = word & 0xff;
d_buffer[i + 1] = (word >> 8) & 0xff;
}
-   return;
 }
 
 static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
@@ -8397,8 +8382,6 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, 
ADV_SCSI_REQ_Q *scsiqp)
boardp->adv_reqp = reqp;
 
ASC_DBG(1, "done\n");
-
-   return;
 }
 
 /*
@@ -8569,7 +8552,6 @@ static void AscAckInterrupt(PortAddr iop_base)
}
}
AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
-   return;
 }
 
 static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
@@ -9325,8 +9307,6 @

[PATCH 09/17] advansys: Merge ASC_IERR definitions

2007-09-16 Thread Matthew Wilcox
There were two blocks of ASC_IERR definitions; one for narrow and one for
wide boards.  Some of the same names were used (with the same values),
and some of the same values were used with different names.  This could
only lead to confusion, so I unified them in one block of definitions
with no overlapping values.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   40 
 1 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index ad9639d..4c792db 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -459,14 +459,22 @@ typedef struct asc_risc_sg_list_q {
 #define ASC_WARN_CFG_MSW_RECOVER  0x0040
 
 /*
- * Error code values are set in ASC_DVC_VAR  'err_code'.
- */
-#define ASC_IERR_MCODE_CHKSUM 0x0002
-#define ASC_IERR_SET_PC_ADDR  0x0004
-#define ASC_IERR_START_STOP_CHIP  0x0008
-#define ASC_IERR_SET_SCSI_ID  0x0080
-#define ASC_IERR_BAD_SIGNATURE0x0200
-#define ASC_IERR_NO_BUS_TYPE  0x0400
+ * Error code values are set in {ASC/ADV}_DVC_VAR  'err_code'.
+ */
+#define ASC_IERR_NO_CARRIER0x0001  /* No more carrier memory */
+#define ASC_IERR_MCODE_CHKSUM  0x0002  /* micro code check sum error */
+#define ASC_IERR_SET_PC_ADDR   0x0004
+#define ASC_IERR_START_STOP_CHIP   0x0008  /* start/stop chip failed */
+#define ASC_IERR_ILLEGAL_CONNECTION0x0010  /* Illegal cable connection */
+#define ASC_IERR_SINGLE_END_DEVICE 0x0020  /* SE device on DIFF bus */
+#define ASC_IERR_REVERSED_CABLE0x0040  /* Narrow flat cable 
reversed */
+#define ASC_IERR_SET_SCSI_ID   0x0080  /* set SCSI ID failed */
+#define ASC_IERR_HVD_DEVICE0x0100  /* HVD device on LVD port */
+#define ASC_IERR_BAD_SIGNATURE 0x0200  /* signature not found */
+#define ASC_IERR_NO_BUS_TYPE   0x0400
+#define ASC_IERR_BIST_PRE_TEST 0x0800  /* BIST pre-test error */
+#define ASC_IERR_BIST_RAM_TEST 0x1000  /* BIST RAM test error */
+#define ASC_IERR_BAD_CHIPTYPE  0x2000  /* Invalid chip_type setting */
 
 #define ASC_DEF_MAX_TOTAL_QNG   (0xF0)
 #define ASC_MIN_TAG_Q_PER_DVC   (0x04)
@@ -1698,22 +1706,6 @@ typedef struct adveep_38C1600_config {
 #define ADV_MAX_LUN 7  /* max. logical unit number */
 
 /*
- * Error code values are set in ADV_DVC_VAR 'err_code'.
- */
-#define ASC_IERR_MCODE_CHKSUM   0x0002 /* micro code check sum error */
-#define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
-#define ASC_IERR_START_STOP_CHIP0x0008 /* start/stop chip failed */
-#define ASC_IERR_SET_SCSI_ID0x0080 /* set SCSI ID failed */
-#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD 
connector. */
-#define ASC_IERR_BAD_SIGNATURE  0x0200 /* signature not found */
-#define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
-#define ASC_IERR_SINGLE_END_DEVICE  0x0800 /* Single-end used 
w/differential */
-#define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
-#define ASC_IERR_BIST_PRE_TEST  0x2000 /* BIST pre-test error */
-#define ASC_IERR_BIST_RAM_TEST  0x4000 /* BIST RAM test error */
-#define ASC_IERR_BAD_CHIPTYPE   0x8000 /* Invalid 'chip_type' setting. 
*/
-
-/*
  * Fixed locations of microcode operating variables.
  */
 #define ASC_MC_CODE_BEGIN_ADDR  0x0028 /* microcode start address */
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/17] advansys: Remove library version & serial numbers

2007-09-16 Thread Matthew Wilcox
With the ASC and ADV libraries merged into the driver, there really is
no point in reporting their version numbers, or even trying to maintain
them.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   60 +++---
 1 files changed, 15 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index e09ab95..530765f 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -77,10 +77,6 @@
 /* Enable driver tracing. */
 /* #define ADVANSYS_DEBUG */
 
-#define ASC_LIB_VERSION_MAJOR  1
-#define ASC_LIB_VERSION_MINOR  24
-#define ASC_LIB_SERIAL_NUMBER  123
-
 /*
  * Portable Data Types
  *
@@ -554,8 +550,6 @@ typedef struct asc_dvc_cfg {
uchar isa_dma_speed;
uchar isa_dma_channel;
uchar chip_version;
-   ushort lib_serial_no;
-   ushort lib_version;
ushort mcode_date;
ushort mcode_version;
uchar max_tag_qng[ASC_MAX_TID + 1];
@@ -958,13 +952,6 @@ typedef struct asc_mc_saved {
 #define AscReadChipDvcID(port)(uchar)inp((port)+IOP_REG_ID)
 #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
 
-#define ADV_LIB_VERSION_MAJOR  5
-#define ADV_LIB_VERSION_MINOR  14
-
-/*
- * Define Adv Library required special types.
- */
-
 /*
  * Portable Data Types
  *
@@ -1856,7 +1843,6 @@ typedef struct adv_dvc_cfg {
ushort disc_enable; /* enable disconnection */
uchar chip_version; /* chip version */
uchar termination;  /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
-   ushort lib_version; /* Adv Library version number */
ushort control_flag;/* Microcode Control Flag */
ushort mcode_date;  /* Microcode date */
ushort mcode_version;   /* Microcode version */
@@ -2637,18 +2623,13 @@ static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
   h->disc_enable, h->sdtr_enable);
 
-   printk
-   (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, 
chip_version %d,\n",
-h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
-h->chip_version);
-
-   printk
-   (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 
0x%x,\n",
-to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
-h->mcode_date);
+   printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
+   "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
+   h->isa_dma_channel, h->chip_version);
 
-   printk(" mcode_version %d, overrun_buf 0x%lx\n",
-  h->mcode_version, (ulong)h->overrun_buf);
+   printk(" pci_device_id %d, mcode_date 0x%x, mcode_version %d, "
+   "overrun_buf 0x%p\n", to_pci_dev(h->dev)->device,
+   h->mcode_date, h->mcode_version, h->overrun_buf);
 }
 
 /*
@@ -2752,8 +2733,8 @@ static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
printk("  chip_version 0x%x, mcode_date 0x%x\n",
   h->chip_version, h->mcode_date);
 
-   printk("  mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
-  h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
+   printk("  mcode_version 0x%x, pci_device_id 0x%x\n",
+  h->mcode_version, to_pci_dev(h->dev)->device);
 
printk("  control_flag 0x%x\n", h->control_flag);
 }
@@ -3731,15 +3712,10 @@ static int asc_prt_asc_board_info(struct Scsi_Host 
*shost, char *cp, int cplen)
   shost->host_no);
ASC_PRT_NEXT();
 
-   len = asc_prt_line(cp, leftlen,
-  " chip_version %u, lib_version 0x%x, lib_serial_no 
%u, mcode_date 0x%x\n",
-  c->chip_version, c->lib_version, c->lib_serial_no,
-  c->mcode_date);
-   ASC_PRT_NEXT();
-
-   len = asc_prt_line(cp, leftlen,
-  " mcode_version 0x%x, err_code %u\n",
-  c->mcode_version, v->err_code);
+   len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
+  "mcode_version 0x%x, err_code %u\n",
+  c->chip_version, c->mcode_date, c->mcode_version,
+  v->err_code);
ASC_PRT_NEXT();
 
/* Current number of commands waiting for the host. */
@@ -3934,10 +3910,9 @@ static int asc_prt_adv_board_info(struct Scsi_Host 
*shost, char *cp, int cplen)
   v->err_code);
ASC_PRT_NEXT();
 
-   len = asc_prt_line(cp, leftlen,
-  " chip_version %u, lib_version 0x%x, mcode_date 
0x%x, mcode_version 0x%x\n",
-  c->chip_version, c->lib_version, c->mcode_date,
-  c->mcode_version);
+   len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
+

[PATCH 08/17] advansys: Sort out irq number mess

2007-09-16 Thread Matthew Wilcox
The interrupt number was being stored in 4-5 different places, each with
its own type, rules and usage.  Fix this by keeping an unsigned int in
the struct asc_board, and filling it in from the bus probe functions
(since it's different for each of the four bus types).  In order to do
this, we have to allocate the Scsi_Host in the bus probe functions too.
Then we can return an error from advansys_board_found, which requires
a little rearranging of code (and removing of the err_code variable).
Move the Wide Board flag setting into the PCI bus probe function.

Split the AscGetChipIRQ function into three functions (one for each bus
type that needs it) and add some commentary to explain what's going on.
Also get rid of the AscSetChipIRQ function as we only ever set the
interrupt number to the same value it already had.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  387 +++
 1 files changed, 189 insertions(+), 198 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index a5bb4e4..ad9639d 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -461,23 +461,13 @@ typedef struct asc_risc_sg_list_q {
 /*
  * Error code values are set in ASC_DVC_VAR  'err_code'.
  */
-#define ASC_IERR_WRITE_EEPROM 0x0001
 #define ASC_IERR_MCODE_CHKSUM 0x0002
 #define ASC_IERR_SET_PC_ADDR  0x0004
 #define ASC_IERR_START_STOP_CHIP  0x0008
-#define ASC_IERR_IRQ_NO   0x0010
-#define ASC_IERR_SET_IRQ_NO   0x0020
-#define ASC_IERR_CHIP_VERSION 0x0040
 #define ASC_IERR_SET_SCSI_ID  0x0080
-#define ASC_IERR_GET_PHY_ADDR 0x0100
 #define ASC_IERR_BAD_SIGNATURE0x0200
 #define ASC_IERR_NO_BUS_TYPE  0x0400
-#define ASC_IERR_SCAM 0x0800
-#define ASC_IERR_SET_SDTR 0x1000
-#define ASC_IERR_RW_LRAM  0x8000
 
-#define ASC_MAX_IRQ_NO  15
-#define ASC_MIN_IRQ_NO  10
 #define ASC_DEF_MAX_TOTAL_QNG   (0xF0)
 #define ASC_MIN_TAG_Q_PER_DVC   (0x04)
 #define ASC_MIN_FREE_Q(0x02)
@@ -605,7 +595,6 @@ typedef struct asc_dvc_var {
uchar max_total_qng;
uchar cur_total_qng;
uchar in_critical_cnt;
-   uchar irq_no;
uchar last_q_shortage;
ushort init_state;
uchar cur_dvc_qng[ASC_MAX_TID + 1];
@@ -1711,11 +1700,9 @@ typedef struct adveep_38C1600_config {
 /*
  * Error code values are set in ADV_DVC_VAR 'err_code'.
  */
-#define ASC_IERR_WRITE_EEPROM   0x0001 /* write EEPROM error */
 #define ASC_IERR_MCODE_CHKSUM   0x0002 /* micro code check sum error */
 #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
 #define ASC_IERR_START_STOP_CHIP0x0008 /* start/stop chip failed */
-#define ASC_IERR_CHIP_VERSION   0x0040 /* wrong chip version */
 #define ASC_IERR_SET_SCSI_ID0x0080 /* set SCSI ID failed */
 #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD 
connector. */
 #define ASC_IERR_BAD_SIGNATURE  0x0200 /* signature not found */
@@ -1919,7 +1906,6 @@ typedef struct adv_dvc_var {
uchar scsi_reset_wait;  /* delay in seconds after scsi bus reset */
uchar chip_no;  /* should be assigned by caller */
uchar max_host_qng; /* maximum number of Q'ed command allowed */
-   uchar irq_no;   /* IRQ number */
ushort no_scam; /* scam_tolerant of EEPROM */
struct asc_board *drv_ptr;  /* driver pointer to private structure 
*/
uchar chip_scsi_id; /* chip SCSI target ID */
@@ -2501,6 +2487,7 @@ typedef struct asc_board {
struct device *dev;
int id; /* Board Id */
uint flags; /* Board flags */
+   unsigned int irq;
union {
ASC_DVC_VAR asc_dvc_var;/* Narrow board */
ADV_DVC_VAR adv_dvc_var;/* Wide board */
@@ -2573,7 +2560,7 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
   s->host_busy, s->host_no, (unsigned)s->last_reset);
 
printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
-  (ulong)s->base, (ulong)s->io_port, s->irq);
+  (ulong)s->base, (ulong)s->io_port, boardp->irq);
 
printk(" dma_channel %d, this_id %d, can_queue %d,\n",
   s->dma_channel, s->this_id, s->can_queue);
@@ -2651,7 +2638,7 @@ static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
   (unsigned)h->init_state, (unsigned)h->no_scam,
   (unsigned)h->pci_fix_asyn_xfer);
 
-   printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
+   printk(" cfg 0x%lx\n", (ulong)h->cfg);
 }
 
 /*
@@ -2749,9 +2736,8 @@ static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
   (ulong)h->isr_callback, (unsigned)h->sdtr_able,
   (unsigned)h->wdtr_able);
 
-   printk("  start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,

[PATCH 13/17] advansys: Remove private lock

2007-09-16 Thread Matthew Wilcox
The board lock was essentially identical with the host lock.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   21 +
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 95df291..b652032 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2439,7 +2439,6 @@ struct asc_board {
ADVEEP_38C1600_CONFIG adv_38C1600_eep;  /* 38C1600 EEPROM 
config. */
} eep_config;
ulong last_reset;   /* Saved last reset time */
-   spinlock_t lock;/* Board spinlock */
/* /proc/scsi/advansys/[0...] */
char *prtbuf;   /* /proc print buffer */
 #ifdef ADVANSYS_STATS
@@ -9621,7 +9620,7 @@ static int advansys_reset(struct scsi_cmnd *scp)
}
 
ASC_DBG(1, "after AscInitAsc1000Driver()\n");
-   spin_lock_irqsave(&boardp->lock, flags);
+   spin_lock_irqsave(shost->host_lock, flags);
} else {
/*
 * If the suggest reset bus flags are set, then reset the bus.
@@ -9644,13 +9643,13 @@ static int advansys_reset(struct scsi_cmnd *scp)
ret = FAILED;
break;
}
-   spin_lock_irqsave(&boardp->lock, flags);
+   spin_lock_irqsave(shost->host_lock, flags);
AdvISR(adv_dvc);
}
 
/* Save the time of the most recently completed reset. */
boardp->last_reset = jiffies;
-   spin_unlock_irqrestore(&boardp->lock, flags);
+   spin_unlock_irqrestore(shost->host_lock, flags);
 
ASC_DBG(1, "ret %d\n", ret);
 
@@ -9707,13 +9706,12 @@ advansys_biosparam(struct scsi_device *sdev, struct 
block_device *bdev,
  */
 static irqreturn_t advansys_interrupt(int irq, void *dev_id)
 {
-   unsigned long flags;
struct Scsi_Host *shost = dev_id;
struct asc_board *boardp = shost_priv(shost);
irqreturn_t result = IRQ_NONE;
 
ASC_DBG(2, "boardp 0x%p\n", boardp);
-   spin_lock_irqsave(&boardp->lock, flags);
+   spin_lock(shost->host_lock);
if (ASC_NARROW_BOARD(boardp)) {
if (AscIsIntPending(shost->io_port)) {
result = IRQ_HANDLED;
@@ -9728,7 +9726,7 @@ static irqreturn_t advansys_interrupt(int irq, void 
*dev_id)
ASC_STATS(shost, interrupt);
}
}
-   spin_unlock_irqrestore(&boardp->lock, flags);
+   spin_unlock(shost->host_lock);
 
ASC_DBG(1, "end\n");
return result;
@@ -11203,20 +11201,12 @@ static int
 advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
 {
struct Scsi_Host *shost = scp->device->host;
-   struct asc_board *boardp = shost_priv(shost);
-   unsigned long flags;
int asc_res, result = 0;
 
ASC_STATS(shost, queuecommand);
scp->scsi_done = done;
 
-   /*
-* host_lock taken by mid-level prior to call, but need
-* to protect against own ISR
-*/
-   spin_lock_irqsave(&boardp->lock, flags);
asc_res = asc_execute_scsi_cmnd(scp);
-   spin_unlock_irqrestore(&boardp->lock, flags);
 
switch (asc_res) {
case ASC_NOERROR:
@@ -13633,7 +13623,6 @@ static int __devinit advansys_board_found(struct 
Scsi_Host *shost,
int share_irq, warn_code, ret;
 
boardp->id = asc_board_count++;
-   spin_lock_init(&boardp->lock);
pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
 
if (ASC_NARROW_BOARD(boardp)) {
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/17] advansys: Sort out debug macros

2007-09-16 Thread Matthew Wilcox
Replace ASC_DBG{,1,2,3,4,5} with a single variadic macro ASC_DBG.  As
suggested by Jeff Garzik, include DRV_NAME and __FUNCTION__ in the output.
Change all callers to no longer include the function name in the string.

Enabling ADVANSYS_DEBUG to test this feature shows a lot of other problems
that need to be fixed:
 - Reorder asc_prt_* functions now that their prototypes have been removed.
 - There is no longer a struct device in ASC_DVC_CFG/ADV_DVC_CFG, and it
   wasn't necessarily a PCI device to begin with.  Print the bus_id from
   asc_board->dev instead.
 - isr_callback no longer exists.
 - ASC_DBG_PRT_SCSI_CMND isn't being used, so delete asc_prt_scsi_cmnd
   too.
 - A missing semicolon

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  628 ---
 1 files changed, 262 insertions(+), 366 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 530765f..95df291 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -75,7 +75,7 @@
 #define ADVANSYS_STATS
 
 /* Enable driver tracing. */
-/* #define ADVANSYS_DEBUG */
+#undef ADVANSYS_DEBUG
 
 /*
  * Portable Data Types
@@ -2277,13 +2277,8 @@ do { \
 
 #ifndef ADVANSYS_DEBUG
 
-#define ASC_DBG(lvl, s)
-#define ASC_DBG1(lvl, s, a1)
-#define ASC_DBG2(lvl, s, a1, a2)
-#define ASC_DBG3(lvl, s, a1, a2, a3)
-#define ASC_DBG4(lvl, s, a1, a2, a3, a4)
+#define ASC_DBG(lvl, s...)
 #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
-#define ASC_DBG_PRT_SCSI_CMND(lvl, s)
 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
 #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
 #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
@@ -2302,40 +2297,11 @@ do { \
  * 2-N: Verbose Tracing
  */
 
-#define ASC_DBG(lvl, s) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-printk(s); \
-} \
-}
-
-#define ASC_DBG1(lvl, s, a1) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-printk((s), (a1)); \
-} \
-}
-
-#define ASC_DBG2(lvl, s, a1, a2) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-printk((s), (a1), (a2)); \
-} \
-}
-
-#define ASC_DBG3(lvl, s, a1, a2, a3) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-printk((s), (a1), (a2), (a3)); \
-} \
-}
-
-#define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-printk((s), (a1), (a2), (a3), (a4)); \
-} \
-}
+#define ASC_DBG(lvl, format, arg...) { \
+   if (asc_dbglvl >= (lvl))\
+   printk(KERN_DEBUG "%s: %s: " format, DRV_NAME,  \
+   __FUNCTION__ , ## arg); \
+}
 
 #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
 { \
@@ -2344,13 +2310,6 @@ do { \
 } \
 }
 
-#define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
-{ \
-if (asc_dbglvl >= (lvl)) { \
-asc_prt_scsi_cmnd(s); \
-} \
-}
-
 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
 { \
 if (asc_dbglvl >= (lvl)) { \
@@ -2519,64 +2478,6 @@ static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
 static int asc_dbglvl = 3;
 
 /*
- * asc_prt_scsi_host()
- */
-static void asc_prt_scsi_host(struct Scsi_Host *s)
-{
-   struct asc_board *boardp = shost_priv(s);
-
-   printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
-   printk(" host_busy %u, host_no %d, last_reset %d,\n",
-  s->host_busy, s->host_no, (unsigned)s->last_reset);
-
-   printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
-  (ulong)s->base, (ulong)s->io_port, boardp->irq);
-
-   printk(" dma_channel %d, this_id %d, can_queue %d,\n",
-  s->dma_channel, s->this_id, s->can_queue);
-
-   printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
-  s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
-
-   if (ASC_NARROW_BOARD(boardp)) {
-   asc_prt_asc_dvc_var(boardp->dvc_var.asc_dvc_var);
-   asc_prt_asc_dvc_cfg(boardp->dvc_cfg.asc_dvc_cfg);
-   } else {
-   asc_prt_adv_dvc_var(boardp->dvc_var.adv_dvc_var);
-   asc_prt_adv_dvc_cfg(boardp->dvc_cfg.adv_dvc_cfg);
-   }
-}
-
-/*
- * asc_prt_scsi_cmnd()
- */
-static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
-{
-   printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
-
-   printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
-  (ulong)s->device->host, (ulong)s->device, s->device->id,
-  s->device->lun, s->device->channel);
-
-   asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
-
-   printk("sc_data_direction %u, resid %d\n",
-  s->sc_data_direction, s->resid);
-
-   printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
-
-   printk(" serial_number 0x%x, retries %d, allowed %d\n",
-  (unsigned)s->serial_number, s->retries, s->allowed);
-
-   printk

[PATCH] typos in megaraid driver

2007-09-16 Thread dann frazier
Cleanup a few typos in megaraid

Signed-off-by: dann frazier <[EMAIL PROTECTED]>

diff --git a/drivers/scsi/megaraid/megaraid_mbox.c 
b/drivers/scsi/megaraid/megaraid_mbox.c
index c6a53dc..4963b96 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -500,7 +500,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct 
pci_device_id *id)
// Start the mailbox based controller
if (megaraid_init_mbox(adapter) != 0) {
con_log(CL_ANN, (KERN_WARNING
-   "megaraid: maibox adapter did not initialize\n"));
+   "megaraid: mailbox adapter did not initialize\n"));
 
goto out_free_adapter;
}
@@ -972,8 +972,8 @@ megaraid_fini_mbox(adapter_t *adapter)
  * megaraid_alloc_cmd_packets - allocate shared mailbox
  * @adapter: soft state of the raid controller
  *
- * Allocate and align the shared mailbox. This maibox is used to issue
- * all the commands. For IO based controllers, the mailbox is also regsitered
+ * Allocate and align the shared mailbox. This mailbox is used to issue
+ * all the commands. For IO based controllers, the mailbox is also registered
  * with the FW. Allocate memory for all commands as well.
  * This is our big allocator.
  */
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h 
b/drivers/scsi/megaraid/megaraid_mbox.h
index 626459d..2e760c2 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.h
+++ b/drivers/scsi/megaraid/megaraid_mbox.h
@@ -116,7 +116,7 @@
  * @raw_mbox   : raw mailbox pointer
  * @mbox   : mailbox
  * @mbox64 : extended mailbox
- * @mbox_dma_h : maibox dma address
+ * @mbox_dma_h : mailbox dma address
  * @sgl64  : 64-bit scatter-gather list
  * @sgl32  : 32-bit scatter-gather list
  * @sgl_dma_h  : dma handle for the scatter-gather list
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/17] advansys: Remove asc_board_t typedef and ASC_BOARDP macro

2007-09-16 Thread Matthew Wilcox
On Sun, Sep 16, 2007 at 09:37:41AM -0600, Matthew Wilcox wrote:
> @@ -2475,7 +2469,7 @@ typedef struct adv_req {
>   * of the 'Scsi_Host' structure starting at the 'hostdata'
>   * field. It is guaranteed to be allocated from DMA-able memory.
>   */
> -typedef struct asc_board {
> +struct asc_board {
>   struct device *dev;
>   int id; /* Board Id */
>   uint flags; /* Board flags */
> @@ -2523,7 +2517,7 @@ typedef struct asc_board {
>   ushort bios_version;/* BIOS Version. */
>   ushort bios_codeseg;/* BIOS Code Segment. */
>   ushort bios_codelen;/* BIOS Code Segment Length. */
> -} asc_board_t;
> +} asc_board;
>  
>  #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
>   dvc_var.adv_dvc_var)

"oops".  I'll send a replacement for this patch.  I can't believe this
struct is 512 bytes.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] aic94xx: fix smartctl utility problem

2007-09-16 Thread James Bottomley
On Sat, 2007-09-15 at 12:05 -0500, James Bottomley wrote:
> On Fri, 2007-09-14 at 10:58 -0700, Gilbert Wu wrote:
> > Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
> > not work on SATA device. ( The smartctl v5.38 does need "-d ata"
> > option.)
> >   The aic94xx need to return ATA output register for all ATA commands
> > except ATA Read/Write commands.
> >   The aic94xx also mark out the DRQ bit from status register which is
> > treated as AC_ERR_HSM (host state machine violation) error by top layer
> > if it set to one.
> >  The firmware of aic94xx chip handle all ATA handshaking, data transfer
> > and return ATA output register which is sent by the device.  So the DRQ
> > bit may not reflect the last state of device when the command finished
> > and it is no meaning for the caller.
> > 
> > Signed-off-by: Gilbert Wu <[EMAIL PROTECTED]>
> 
> I'm afraid this can't go in.  It has a bad effect on my expander remote
> ATAPI device:

OK, found the root cause: your CSMI_TASK flag is getting set on all
packet commands.  I can think of two fixes: either smartctl should never
be used on ATAPI devices (reasonable, since smart is a disc protocol),
so we predicate the check by a test for the device being ATA:

if (dev->sata_dev.command_set == ATA_COMMAND_SET
&& !is_ata_rw_cmd(scb->ata_task.fis.command))

Or simply add ATA_CMD_PACKET to your is_ata_rw_cmd() switch.

Either works on my system ... which do you prefer.

James




-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] aic94xx: fix smartctl utility problem

2007-09-16 Thread Jeff Garzik

James Bottomley wrote:

On Sat, 2007-09-15 at 12:05 -0500, James Bottomley wrote:

On Fri, 2007-09-14 at 10:58 -0700, Gilbert Wu wrote:

Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
not work on SATA device. ( The smartctl v5.38 does need "-d ata"
option.)
  The aic94xx need to return ATA output register for all ATA commands
except ATA Read/Write commands.
  The aic94xx also mark out the DRQ bit from status register which is
treated as AC_ERR_HSM (host state machine violation) error by top layer
if it set to one.
 The firmware of aic94xx chip handle all ATA handshaking, data transfer
and return ATA output register which is sent by the device.  So the DRQ
bit may not reflect the last state of device when the command finished
and it is no meaning for the caller.

Signed-off-by: Gilbert Wu <[EMAIL PROTECTED]>

I'm afraid this can't go in.  It has a bad effect on my expander remote
ATAPI device:


OK, found the root cause: your CSMI_TASK flag is getting set on all
packet commands.  I can think of two fixes: either smartctl should never
be used on ATAPI devices (reasonable, since smart is a disc protocol),
so we predicate the check by a test for the device being ATA:

if (dev->sata_dev.command_set == ATA_COMMAND_SET
&& !is_ata_rw_cmd(scb->ata_task.fis.command))

Or simply add ATA_CMD_PACKET to your is_ata_rw_cmd() switch.


Agreed.  I missed that in my review.

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/17] advansys: Remove asc_board_t typedef and ASC_BOARDP macro

2007-09-16 Thread Matthew Wilcox
asc_board_t was simply a typedef for struct asc_board.  ASC_BOARDP()
can be replaced by shost_priv() except in the ASC_STATS* macros which
rely on the cast; add an explicit cast there.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |  132 ++-
 1 files changed, 51 insertions(+), 81 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4c792db..e17626c 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2203,10 +2203,7 @@ do { \
  (sizeof(ADV_SG_BLOCK) * \
   ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
 
-/* Reference Scsi_Host hostdata */
-#define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
-
-/* asc_board_t flags */
+/* struct asc_board flags */
 #define ASC_IS_WIDE_BOARD   0x04   /* AdvanSys Wide Board */
 
 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
@@ -2244,15 +2241,12 @@ do { \
 #define HOST_BYTE(byte) ((byte) << 16)
 #define DRIVER_BYTE(byte)   ((byte) << 24)
 
+#define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
 #ifndef ADVANSYS_STATS
-#define ASC_STATS(shost, counter)
 #define ASC_STATS_ADD(shost, counter, count)
 #else /* ADVANSYS_STATS */
-#define ASC_STATS(shost, counter) \
-(ASC_BOARDP(shost)->asc_stats.counter++)
-
 #define ASC_STATS_ADD(shost, counter, count) \
-(ASC_BOARDP(shost)->asc_stats.counter += (count))
+   (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
 #endif /* ADVANSYS_STATS */
 
 #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
@@ -2475,7 +2469,7 @@ typedef struct adv_req {
  * of the 'Scsi_Host' structure starting at the 'hostdata'
  * field. It is guaranteed to be allocated from DMA-able memory.
  */
-typedef struct asc_board {
+struct asc_board {
struct device *dev;
int id; /* Board Id */
uint flags; /* Board flags */
@@ -2523,7 +2517,7 @@ typedef struct asc_board {
ushort bios_version;/* BIOS Version. */
ushort bios_codeseg;/* BIOS Code Segment. */
ushort bios_codelen;/* BIOS Code Segment Length. */
-} asc_board_t;
+};
 
 #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
dvc_var.adv_dvc_var)
@@ -2543,9 +2537,7 @@ static int asc_dbglvl = 3;
  */
 static void asc_prt_scsi_host(struct Scsi_Host *s)
 {
-   asc_board_t *boardp;
-
-   boardp = ASC_BOARDP(s);
+   struct asc_board *boardp = shost_priv(s);
 
printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
printk(" host_busy %u, host_no %d, last_reset %d,\n",
@@ -2561,11 +2553,11 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
   s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
 
if (ASC_NARROW_BOARD(boardp)) {
-   asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
-   asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
+   asc_prt_asc_dvc_var(boardp->dvc_var.asc_dvc_var);
+   asc_prt_asc_dvc_cfg(boardp->dvc_cfg.asc_dvc_cfg);
} else {
-   asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
-   asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
+   asc_prt_adv_dvc_var(boardp->dvc_var.adv_dvc_var);
+   asc_prt_adv_dvc_cfg(boardp->dvc_cfg.adv_dvc_cfg);
}
 }
 
@@ -2914,13 +2906,12 @@ static void asc_prt_hex(char *f, uchar *s, int l)
 static const char *advansys_info(struct Scsi_Host *shost)
 {
static char info[ASC_INFO_SIZE];
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
ASC_DVC_VAR *asc_dvc_varp;
ADV_DVC_VAR *adv_dvc_varp;
char *busname;
char *widename = NULL;
 
-   boardp = ASC_BOARDP(shost);
if (ASC_NARROW_BOARD(boardp)) {
asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
ASC_DBG(1, "advansys_info: begin\n");
@@ -3032,14 +3023,13 @@ static int asc_prt_line(char *buf, int buflen, char 
*fmt, ...)
  */
 static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
 {
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
int leftlen;
int totlen;
int len;
int chip_scsi_id;
int i;
 
-   boardp = ASC_BOARDP(shost);
leftlen = cplen;
totlen = len = 0;
 
@@ -3073,13 +3063,12 @@ static int asc_prt_board_devices(struct Scsi_Host 
*shost, char *cp, int cplen)
  */
 static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
 {
-   asc_board_t *boardp;
+   struct asc_board *boardp = shost_priv(shost);
int leftlen;
int totlen;
int len;
ushort major, minor, letter;
 
-   boardp = ASC_BOARDP(shost);
leftlen = cplen;
totle

Re: [PATCH 16/22] advansys: Eliminate prototypes

2007-09-16 Thread FUJITA Tomonori
On Sun, 16 Sep 2007 09:31:34 -0600
Matthew Wilcox <[EMAIL PROTECTED]> wrote:

> On Sat, Sep 15, 2007 at 09:39:05AM -0500, James Bottomley wrote:
> > I get a compile failure at this point in your patch sequence:
> 
> Thanks.  I'd been compiling with CONFIG_ISA=n, so hadn't spotted these
> two problems.  I've set it back to Y now.

If I compile your latest patchset with CONFIG_ISA=n, I got:

drivers/built-in.o: In function `advansys_init':
advansys.c:(.init.text+0x3edc): undefined reference to `isa_register_driver'
advansys.c:(.init.text+0x3efb): undefined reference to `isa_register_driver'
advansys.c:(.init.text+0x3f22): undefined reference to `isa_unregister_driver'
advansys.c:(.init.text+0x3f36): undefined reference to `isa_unregister_driver'
drivers/built-in.o: In function `advansys_exit':
advansys.c:(.exit.text+0x210): undefined reference to `isa_unregister_driver'
advansys.c:(.exit.text+0x21a): undefined reference to `isa_unregister_driver'
make[1]: *** [.tmp_vmlinux1] Error 1
make[1]: Leaving directory `/home/fujita/git/linux-2.6'
make: *** [debian/stamp-build-kernel] Error 2


Is this already fixed like this?

-
From: FUJITA Tomonori <[EMAIL PROTECTED]>
Subject: [PATCH] isa: add fake isa_register_driver and isa_unregister_driver

add fake isa_register_driver and isa_unregister_driver for !CONFIG_ISA
case.

Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]>
---
 include/linux/isa.h |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/isa.h b/include/linux/isa.h
index 1b85533..6d3aaaf 100644
--- a/include/linux/isa.h
+++ b/include/linux/isa.h
@@ -22,7 +22,17 @@ struct isa_driver {
 
 #define to_isa_driver(x) container_of((x), struct isa_driver, driver)
 
+#ifdef CONFIG_ISA
 int isa_register_driver(struct isa_driver *, unsigned int);
 void isa_unregister_driver(struct isa_driver *);
+#else
+static inline int isa_register_driver(struct isa_driver *idrv, unsigned int n)
+{
+   return 0;
+}
+static inline void isa_unregister_driver(struct isa_driver *idrv)
+{
+}
+#endif
 
 #endif /* __LINUX_ISA_H */
-- 
1.5.2.4


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] SCSI: split Kconfig menu into two

2007-09-16 Thread Greg KH
On Sat, Sep 15, 2007 at 06:23:13PM +0200, Adrian Bunk wrote:
> 
> @Greg:
> Do you have any numbers regarding how your "Linux Kernel in a Nutshell" 
> is selling?

It is selling reasonably well for an O'Reilly book from what I have been
told.  But I have not seen any real numbers yet.

> Even download numbers?

The downloads are spread around all of the kernel.org mirrors so I have
absolutely no idea what they are.

Nor do I really want to, as it doesn't matter to me.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] aic94xx: fix smartctl utility problem

2007-09-16 Thread Douglas Gilbert
James Bottomley wrote:
> On Sat, 2007-09-15 at 12:05 -0500, James Bottomley wrote:
>> On Fri, 2007-09-14 at 10:58 -0700, Gilbert Wu wrote:
>>> Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
>>> not work on SATA device. ( The smartctl v5.38 does need "-d ata"
>>> option.)
>>>   The aic94xx need to return ATA output register for all ATA commands
>>> except ATA Read/Write commands.
>>>   The aic94xx also mark out the DRQ bit from status register which is
>>> treated as AC_ERR_HSM (host state machine violation) error by top layer
>>> if it set to one.
>>>  The firmware of aic94xx chip handle all ATA handshaking, data transfer
>>> and return ATA output register which is sent by the device.  So the DRQ
>>> bit may not reflect the last state of device when the command finished
>>> and it is no meaning for the caller.
>>>
>>> Signed-off-by: Gilbert Wu <[EMAIL PROTECTED]>
>> I'm afraid this can't go in.  It has a bad effect on my expander remote
>> ATAPI device:
> 
> OK, found the root cause: your CSMI_TASK flag is getting set on all
> packet commands.  I can think of two fixes: either smartctl should never
> be used on ATAPI devices (reasonable, since smart is a disc protocol),

Feature code 101h in MMC seems to sink your argument for
cd/dvd drives.

Also tape drives may support SMART and if they do,
smartmontools can access the associated data. And tape
drives may be on an ATAPI transport.

Doug Gilbert

> so we predicate the check by a test for the device being ATA:
> 
>   if (dev->sata_dev.command_set == ATA_COMMAND_SET
>   && !is_ata_rw_cmd(scb->ata_task.fis.command))
> 
> Or simply add ATA_CMD_PACKET to your is_ata_rw_cmd() switch.
> 
> Either works on my system ... which do you prefer.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/22] advansys: Eliminate prototypes

2007-09-16 Thread Matthew Wilcox
On Mon, Sep 17, 2007 at 07:41:06AM +0900, FUJITA Tomonori wrote:
> On Sun, 16 Sep 2007 09:31:34 -0600
> Matthew Wilcox <[EMAIL PROTECTED]> wrote:
> 
> > On Sat, Sep 15, 2007 at 09:39:05AM -0500, James Bottomley wrote:
> > > I get a compile failure at this point in your patch sequence:
> > 
> > Thanks.  I'd been compiling with CONFIG_ISA=n, so hadn't spotted these
> > two problems.  I've set it back to Y now.
> 
> If I compile your latest patchset with CONFIG_ISA=n, I got:
> 
> drivers/built-in.o: In function `advansys_init':
> advansys.c:(.init.text+0x3efb): undefined reference to `isa_register_driver'
> advansys.c:(.init.text+0x3f22): undefined reference to `isa_unregister_driver'

Fixed by http://marc.info/?l=linux-kernel&m=118780055118323&w=2 which I
thought was in -mm, but I can't find it.  I've just reset it to Linus &
Andrew.  Thanks for mentioning it.

Now I'm back home, I'll add your sg patch to my tree.  I'd forgotten
about it ...

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/22] advansys: Eliminate prototypes

2007-09-16 Thread FUJITA Tomonori
On Sun, 16 Sep 2007 17:03:50 -0600
Matthew Wilcox <[EMAIL PROTECTED]> wrote:

> On Mon, Sep 17, 2007 at 07:41:06AM +0900, FUJITA Tomonori wrote:
> > On Sun, 16 Sep 2007 09:31:34 -0600
> > Matthew Wilcox <[EMAIL PROTECTED]> wrote:
> > 
> > > On Sat, Sep 15, 2007 at 09:39:05AM -0500, James Bottomley wrote:
> > > > I get a compile failure at this point in your patch sequence:
> > > 
> > > Thanks.  I'd been compiling with CONFIG_ISA=n, so hadn't spotted these
> > > two problems.  I've set it back to Y now.
> > 
> > If I compile your latest patchset with CONFIG_ISA=n, I got:
> > 
> > drivers/built-in.o: In function `advansys_init':
> > advansys.c:(.init.text+0x3efb): undefined reference to `isa_register_driver'
> > advansys.c:(.init.text+0x3f22): undefined reference to 
> > `isa_unregister_driver'
> 
> Fixed by http://marc.info/?l=linux-kernel&m=118780055118323&w=2 which I
> thought was in -mm, but I can't find it.  I've just reset it to Linus &
> Andrew.  Thanks for mentioning it.

Oh, I see.


> Now I'm back home, I'll add your sg patch to my tree.  I'd forgotten
> about it ...

I updated the previous patch for your latest patchset. I removed the
sg chaining support so you can send it to scsi-misc now.

Just a one-line patch is necessary for the sg chaining support. It'll
be push to mainline via Jens' tree.


From: FUJITA Tomonori <[EMAIL PROTECTED]>
Subject: [PATCH] advansys: convert to use the data buffer accessors

- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]>
---
 drivers/scsi/advansys.c |   83 +-
 1 files changed, 24 insertions(+), 59 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index bd5bbc9..bc24f74 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -4301,15 +4301,7 @@ advansys_proc_info(struct Scsi_Host *shost, char 
*buffer, char **start,
 
 static void asc_scsi_done(struct scsi_cmnd *scp)
 {
-   struct asc_board *boardp = shost_priv(scp->device->host);
-
-   if (scp->use_sg)
-   dma_unmap_sg(boardp->dev,
-(struct scatterlist *)scp->request_buffer,
-scp->use_sg, scp->sc_data_direction);
-   else if (scp->request_bufflen)
-   dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
-scp->request_bufflen, scp->sc_data_direction);
+   scsi_dma_unmap(scp);
 
ASC_STATS(scp->device->host, done);
 
@@ -8210,11 +8202,11 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, 
ADV_SCSI_REQ_Q *scsiqp)
 * then return the number of underrun bytes.
 */
resid_cnt = le32_to_cpu(scsiqp->data_cnt);
-   if (scp->request_bufflen != 0 && resid_cnt != 0 &&
-   resid_cnt <= scp->request_bufflen) {
+   if (scsi_bufflen(scp) != 0 && resid_cnt != 0 &&
+   resid_cnt <= scsi_bufflen(scp)) {
ASC_DBG(1, "underrun condition %lu bytes\n",
 (ulong)resid_cnt);
-   scp->resid = resid_cnt;
+   scsi_set_resid(scp, resid_cnt);
}
break;
 
@@ -9877,6 +9869,7 @@ static int advansys_slave_configure(struct scsi_device 
*sdev)
 static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
struct asc_scsi_q *asc_scsi_q)
 {
+   int use_sg;
memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
 
/*
@@ -9919,40 +9912,28 @@ static int asc_build_req(struct asc_board *boardp, 
struct scsi_cmnd *scp,
 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
 * buffer command.
 */
-   if (scp->use_sg == 0) {
+   use_sg = scsi_dma_map(scp);
+   if (use_sg == 0) {
/*
 * CDB request of single contiguous buffer.
 */
ASC_STATS(scp->device->host, cont_cnt);
-   scp->SCp.dma_handle = scp->request_bufflen ?
-   dma_map_single(boardp->dev, scp->request_buffer,
-  scp->request_bufflen,
-  scp->sc_data_direction) : 0;
-   asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
-   asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
+   scp->SCp.dma_handle = 0;
ASC_STATS_ADD(scp->device->host, cont_xfer,
  ASC_CEILING(scp->request_bufflen, 512));
-   asc_scsi_q->q1.sg_queue_cnt = 0;
-   asc_scsi_q->sg_head = NULL;
} else {
/*
 * CDB scatter-gather request list.
 */
int sgcnt;
-   int use_sg;
struct scatterlist *slp;
struct a

Re: [PATCH] aic94xx: fix smartctl utility problem

2007-09-16 Thread James Bottomley
On Sun, 2007-09-16 at 19:01 -0400, Douglas Gilbert wrote:
> James Bottomley wrote:
> > On Sat, 2007-09-15 at 12:05 -0500, James Bottomley wrote:
> >> On Fri, 2007-09-14 at 10:58 -0700, Gilbert Wu wrote:
> >>> Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
> >>> not work on SATA device. ( The smartctl v5.38 does need "-d ata"
> >>> option.)
> >>>   The aic94xx need to return ATA output register for all ATA commands
> >>> except ATA Read/Write commands.
> >>>   The aic94xx also mark out the DRQ bit from status register which is
> >>> treated as AC_ERR_HSM (host state machine violation) error by top layer
> >>> if it set to one.
> >>>  The firmware of aic94xx chip handle all ATA handshaking, data transfer
> >>> and return ATA output register which is sent by the device.  So the DRQ
> >>> bit may not reflect the last state of device when the command finished
> >>> and it is no meaning for the caller.
> >>>
> >>> Signed-off-by: Gilbert Wu <[EMAIL PROTECTED]>
> >> I'm afraid this can't go in.  It has a bad effect on my expander remote
> >> ATAPI device:
> > 
> > OK, found the root cause: your CSMI_TASK flag is getting set on all
> > packet commands.  I can think of two fixes: either smartctl should never
> > be used on ATAPI devices (reasonable, since smart is a disc protocol),
> 
> Feature code 101h in MMC seems to sink your argument for
> cd/dvd drives.

I was more thinking that smartctl is a pure ATA type thing (The problem
which the flag is set for is to allow smartctl to muck with ATA
commands)... the MMC devices supporting smart features report this via
the informational exceptions mode page to conform to the MMC command
set.  So, when smartctl does SCSI transports, they'll go via a packet
command anyway.

> Also tape drives may support SMART and if they do,
> smartmontools can access the associated data. And tape
> drives may be on an ATAPI transport.

That's probably via the same mechanism, isn't it?

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html