tree ab08b51486c4d0094a25b73239b8e7a6402118f0
parent c5b11b13e1077a0ed94214bee516d150d4f073d5
author Ju, Seokmann <[EMAIL PROTECTED]> Fri, 05 Aug 2005 01:09:22 -0400
committer Marcelo Tosatti <[EMAIL PROTECTED]> Fri, 05 Aug 2005 23:31:43 -0300

[PATCH] megaraid2 v2.10.10.1

This patch contains accumulated changes over the time.

Description of the changes.
### Version 2.10.10.1
Thu Jan 27 15:59:59 EDT 2005 - Seokmann Ju <[EMAIL PROTECTED]>
1. There was a bug in the 'megadev_ioctl()' function that cause random
deletion error and has been fixed.

### Version 2.10.10.0
Fri Jan 21 15:59:59 EDT 2005 - Seokmann Ju <[EMAIL PROTECTED]>
1. Fixed Tape drive issue : For any Direct CDB command to physical
device including tape, timeout value set by driver was 10 minutes. With
this value, most of command will return within timeout. However, for
those command like ERASE or FORMAT, it takes more than an hour depends
on capacity of the device and the command could be terminated before
it completes. To address this issue, the 'timeout' field in the DCDB
command will have NO TIMEOUT (i.e., 4) value as its timeout on DCDB
command.

2. Added NEC ROMB support : NEC MegaRAID PCI Express ROMB
controller

### Version 2.10.9.0
Fri Aug 13 15:59:59 EDT 2004 - Rajesh Prabhakaran <[EMAIL PROTECTED]>
1. Added Support for 64-applications : mega_ioctl function and
nitioctl_t struct where changed to accomadate 64-bit addressing.

Signed-off-by: Seokmann Ju <[EMAIL PROTECTED]>

diff -Naur old/drivers/scsi/megaraid2.c new/drivers/scsi/megaraid2.c

 drivers/scsi/megaraid2.c |  755 +++++++++++++++++++++++------------------------
 drivers/scsi/megaraid2.h |   32 +
 2 files changed, 396 insertions(+), 391 deletions(-)

diff --git a/drivers/scsi/megaraid2.c b/drivers/scsi/megaraid2.c
--- a/drivers/scsi/megaraid2.c
+++ b/drivers/scsi/megaraid2.c
@@ -14,7 +14,7 @@
  *       - speed-ups (list handling fixes, issued_list, optimizations.)
  *       - lots of cleanups.
  *
- * Version : v2.10.8.2 (July 26, 2004)
+ * Version : v2.10.10.1 (January 27, 2005)
  *
  * Authors:    Atul Mukker <[EMAIL PROTECTED]>
  *             Sreenivas Bagalkote <[EMAIL PROTECTED]>
@@ -46,7 +46,7 @@
 
 #include "megaraid2.h"
 
-#if defined(__x86_64__)
+#ifdef LSI_CONFIG_COMPAT
 #include <asm/ioctl32.h>
 #endif
 
@@ -181,7 +181,7 @@ megaraid_detect(Scsi_Host_Template *host
        /*
         * Scan PCI bus for our all devices.
         */
-       for( i = 0; i < sizeof(dev_sw_table)/sizeof(u16); i += 2 ) {
+       for( i = 0; i < ((int) (sizeof(dev_sw_table)/sizeof(u16))); i += 2 ) {
 
                mega_find_card(host_template, dev_sw_table[i],
                                dev_sw_table[i+1]);
@@ -233,7 +233,7 @@ megaraid_detect(Scsi_Host_Template *host
                                "MegaRAID Shutdown routine not registered!!\n");
                }
 
-#if defined(__x86_64__)
+#ifdef LSI_CONFIG_COMPAT
                /*
                 * Register the 32-bit ioctl conversion
                 */
@@ -341,6 +341,7 @@ mega_find_card(Scsi_Host_Template *host_
                                (subsysvid != INTEL_SUBSYS_VID) &&
                                (subsysvid != FSC_SUBSYS_VID) &&
                                (subsysvid != ACER_SUBSYS_VID) &&
+                               (subsysvid != NEC_SUBSYS_VID) &&
                                (subsysvid != LSI_SUBSYS_VID) ) continue;
 
 
@@ -821,6 +822,78 @@ mega_setup_mailbox(adapter_t *adapter)
 }
 
 
+/**
+ * issue_scb()
+ * @adapter - pointer to our soft state
+ * @scb - scsi control block
+ *
+ * Post a command to the card if the mailbox is available, otherwise return
+ * busy. We also take the scb from the pending list if the mailbox is
+ * available.
+ */
+static inline int
+issue_scb(adapter_t *adapter, scb_t *scb)
+{
+       volatile mbox64_t       *mbox64 = adapter->mbox64;
+       volatile mbox_t         *mbox = adapter->mbox;
+       unsigned int    i = 0;
+
+       if(unlikely(mbox->busy)) {
+               do {
+                       udelay(1);
+                       i++;
+               } while( mbox->busy && (i < max_mbox_busy_wait) );
+
+               if(mbox->busy) return -1;
+       }
+
+       /* Copy mailbox data into host structure */
+       memcpy((char *)mbox, (char *)scb->raw_mbox, 16);
+
+       mbox->cmdid = scb->idx; /* Set cmdid */
+       mbox->busy = 1;         /* Set busy */
+
+
+       /*
+        * Increment the pending queue counter
+        */
+       atomic_inc(&adapter->pend_cmds);
+
+       switch (mbox->cmd) {
+       case MEGA_MBOXCMD_EXTPTHRU:
+               if( !adapter->has_64bit_addr ) break;
+               // else fall through
+       case MEGA_MBOXCMD_LREAD64:
+       case MEGA_MBOXCMD_LWRITE64:
+       case MEGA_MBOXCMD_PASSTHRU64:
+               mbox64->xfer_segment_lo = mbox->xferaddr;
+               mbox64->xfer_segment_hi = 0;
+               mbox->xferaddr = 0xFFFFFFFF;
+               break;
+       default:
+               mbox64->xfer_segment_lo = 0;
+               mbox64->xfer_segment_hi = 0;
+       }
+
+       /*
+        * post the command
+        */
+       scb->state |= SCB_ISSUED;
+
+       if( likely(adapter->flag & BOARD_MEMMAP) ) {
+               mbox->poll = 0;
+               mbox->ack = 0;
+               WRINDOOR(adapter, adapter->mbox_dma | 0x1);
+       }
+       else {
+               irq_enable(adapter);
+               issue_command(adapter);
+       }
+
+       return 0;
+}
+
+
 /*
  * mega_query_adapter()
  * @adapter - pointer to our soft state
@@ -990,78 +1063,6 @@ mega_query_adapter(adapter_t *adapter)
 
 
 /**
- * issue_scb()
- * @adapter - pointer to our soft state
- * @scb - scsi control block
- *
- * Post a command to the card if the mailbox is available, otherwise return
- * busy. We also take the scb from the pending list if the mailbox is
- * available.
- */
-static inline int
-issue_scb(adapter_t *adapter, scb_t *scb)
-{
-       volatile mbox64_t       *mbox64 = adapter->mbox64;
-       volatile mbox_t         *mbox = adapter->mbox;
-       unsigned int    i = 0;
-
-       if(unlikely(mbox->busy)) {
-               do {
-                       udelay(1);
-                       i++;
-               } while( mbox->busy && (i < max_mbox_busy_wait) );
-
-               if(mbox->busy) return -1;
-       }
-
-       /* Copy mailbox data into host structure */
-       memcpy((char *)mbox, (char *)scb->raw_mbox, 16);
-
-       mbox->cmdid = scb->idx; /* Set cmdid */
-       mbox->busy = 1;         /* Set busy */
-
-
-       /*
-        * Increment the pending queue counter
-        */
-       atomic_inc(&adapter->pend_cmds);
-
-       switch (mbox->cmd) {
-       case MEGA_MBOXCMD_EXTPTHRU:
-               if( !adapter->has_64bit_addr ) break;
-               // else fall through
-       case MEGA_MBOXCMD_LREAD64:
-       case MEGA_MBOXCMD_LWRITE64:
-       case MEGA_MBOXCMD_PASSTHRU64:
-               mbox64->xfer_segment_lo = mbox->xferaddr;
-               mbox64->xfer_segment_hi = 0;
-               mbox->xferaddr = 0xFFFFFFFF;
-               break;
-       default:
-               mbox64->xfer_segment_lo = 0;
-               mbox64->xfer_segment_hi = 0;
-       }
-
-       /*
-        * post the command
-        */
-       scb->state |= SCB_ISSUED;
-
-       if( likely(adapter->flag & BOARD_MEMMAP) ) {
-               mbox->poll = 0;
-               mbox->ack = 0;
-               WRINDOOR(adapter, adapter->mbox_dma | 0x1);
-       }
-       else {
-               irq_enable(adapter);
-               issue_command(adapter);
-       }
-
-       return 0;
-}
-
-
-/**
  * mega_runpendq()
  * @adapter - pointer to our soft state
  *
@@ -1074,7 +1075,6 @@ mega_runpendq(adapter_t *adapter)
                __mega_runpendq(adapter);
 }
 
-
 static void
 __mega_runpendq(adapter_t *adapter)
 {
@@ -1176,80 +1176,6 @@ mega_get_ldrv_num(adapter_t *adapter, Sc
        return ldrv_num;
 }
 
-/*
- * Wait until the controller's mailbox is available
- */
-static inline int
-mega_busywait_mbox (adapter_t *adapter)
-{
-       if (adapter->mbox->busy)
-               return __mega_busywait_mbox(adapter);
-       return 0;
-}
-
-
-/**
- * megaraid_iombox_ack_sequence - interrupt ack sequence for IO mapped HBAs
- * @adapter    - controller's soft state
- *
- * Interrupt ackrowledgement sequence for IO mapped HBAs
- */
-static inline void
-megaraid_iombox_ack_sequence(adapter_t *adapter)
-{
-       u8      status;
-       u8      nstatus;
-       u8      completed[MAX_FIRMWARE_STATUS];
-       u8      byte;
-       int     i;
-
-
-       /*
-        * loop till F/W has more commands for us to complete.
-        */
-       do {
-               /* Check if a valid interrupt is pending */
-               byte = irq_state(adapter);
-               if( (byte & VALID_INTR_BYTE) == 0 ) {
-                       return;
-               }
-               set_irq_state(adapter, byte);
-
-               while ((nstatus = adapter->mbox->numstatus) == 0xFF) {
-                       cpu_relax();
-               }
-               adapter->mbox->numstatus = 0xFF;
-
-               for (i = 0; i < nstatus; i++) {
-                       while ((completed[i] = adapter->mbox->completed[i])
-                                       == 0xFF) {
-                               cpu_relax();
-                       }
-
-                       adapter->mbox->completed[i] = 0xFF;
-               }
-
-               // we must read the valid status now
-               if ((status = adapter->mbox->status) == 0xFF) {
-                       printk(KERN_WARNING
-                       "megaraid critical: status 0xFF from firmware.\n");
-               }
-               adapter->mbox->status = 0xFF;
-
-               /*
-                * decrement the pending queue counter
-                */
-               atomic_sub(nstatus, &adapter->pend_cmds);
-
-               /* Acknowledge interrupt */
-               irq_ack(adapter);
-
-               mega_cmd_done(adapter, completed, nstatus, status);
-
-       } while(1);
-}
-
-
 
 /*
  * megaraid_queue()
@@ -1755,8 +1681,8 @@ mega_prepare_passthru(adapter_t *adapter
        pthru = scb->pthru;
        memset(pthru, 0, sizeof (mega_passthru));
 
-       /* 0=6sec/1=60sec/2=10min/3=3hrs */
-       pthru->timeout = 2;
+       /* 0=6sec/1=60sec/2=10min/3=3hrs/4=NO timeout */
+       pthru->timeout = 4;
 
        pthru->ars = 1;
        pthru->reqsenselen = 14;
@@ -1819,8 +1745,8 @@ mega_prepare_extpassthru(adapter_t *adap
        epthru = scb->epthru;
        memset(epthru, 0, sizeof(mega_ext_passthru));
 
-       /* 0=6sec/1=60sec/2=10min/3=3hrs */
-       epthru->timeout = 2;
+       /* 0=6sec/1=60sec/2=10min/3=3hrs/4=NO timeout */
+       epthru->timeout = 4;
 
        epthru->ars = 1;
        epthru->reqsenselen = 14;
@@ -1862,6 +1788,32 @@ mega_prepare_extpassthru(adapter_t *adap
 }
 
 
+/*
+ * Wait until the controller's mailbox is available
+ */
+static inline int
+mega_busywait_mbox (adapter_t *adapter)
+{
+       if (adapter->mbox->busy)
+               return __mega_busywait_mbox(adapter);
+       return 0;
+}
+
+static int
+__mega_busywait_mbox (adapter_t *adapter)
+{
+       volatile mbox_t *mbox = adapter->mbox;
+       long counter;
+
+       for (counter = 0; counter < 10000; counter++) {
+               if (!mbox->busy)
+                       return 0;
+               udelay(100); yield();
+       }
+       return -1;              /* give up after 1 second */
+}
+
+
 /**
  * issue_scb_block()
  * @adapter - pointer to our soft state
@@ -1962,137 +1914,7 @@ bug_blocked_mailbox:
        return -1;
 }
 
-
-/**
- * megaraid_isr_iomapped()
- * @irq - irq
- * @devp - pointer to our soft state
- * @regs - unused
- *
- * Interrupt service routine for io-mapped controllers.
- * Find out if our device is interrupting. If yes, acknowledge the interrupt
- * and service the completed commands.
- */
-static void
-megaraid_isr_iomapped(int irq, void *devp, struct pt_regs *regs)
-{
-       adapter_t       *adapter = devp;
-       unsigned long   flags;
-
-
-       spin_lock_irqsave(adapter->host_lock, flags);
-
-       megaraid_iombox_ack_sequence(adapter);
-
-       /* Loop through any pending requests */
-       if( atomic_read(&adapter->quiescent ) == 0) {
-               mega_runpendq(adapter);
-       }
-
-       spin_unlock_irqrestore(adapter->host_lock, flags);
-
-       return;
-}
-
-
-/**
- * megaraid_memmbox_ack_sequence - interrupt ack sequence for memory mapped 
HBAs
- * @adapter    - controller's soft state
- *
- * Interrupt ackrowledgement sequence for memory mapped HBAs
- */
-static inline void
-megaraid_memmbox_ack_sequence(adapter_t *adapter)
-{
-       u8      status;
-       u32     dword = 0;
-       u8      nstatus;
-       u8      completed[MAX_FIRMWARE_STATUS];
-       int     i;
-
-
-       /*
-        * loop till F/W has more commands for us to complete.
-        */
-       do {
-               /* Check if a valid interrupt is pending */
-               dword = RDOUTDOOR(adapter);
-               if( dword != 0x10001234 ) {
-                       /*
-                        * No more pending commands
-                        */
-                       return;
-               }
-               WROUTDOOR(adapter, 0x10001234);
-
-               while ((nstatus = adapter->mbox->numstatus) == 0xFF) {
-                       cpu_relax();
-               }
-               adapter->mbox->numstatus = 0xFF;
-
-               for (i = 0; i < nstatus; i++ ) {
-                       while ((completed[i] = adapter->mbox->completed[i])
-                                       == 0xFF) {
-                               cpu_relax();
-                       }
-
-                       adapter->mbox->completed[i] = 0xFF;
-               }
-
-               // we must read the valid status now
-               if ((status = adapter->mbox->status) == 0xFF) {
-                       printk(KERN_WARNING
-                       "megaraid critical: status 0xFF from firmware.\n");
-               }
-               adapter->mbox->status = 0xFF;
-
-               /*
-                * decrement the pending queue counter
-                */
-               atomic_sub(nstatus, &adapter->pend_cmds);
-
-               /* Acknowledge interrupt */
-               WRINDOOR(adapter, 0x2);
-
-               while( RDINDOOR(adapter) & 0x02 ) cpu_relax();
-
-               mega_cmd_done(adapter, completed, nstatus, status);
-
-       } while(1);
-}
-
-
-/**
- * megaraid_isr_memmapped()
- * @irq - irq
- * @devp - pointer to our soft state
- * @regs - unused
- *
- * Interrupt service routine for memory-mapped controllers.
- * Find out if our device is interrupting. If yes, acknowledge the interrupt
- * and service the completed commands.
- */
-static void
-megaraid_isr_memmapped(int irq, void *devp, struct pt_regs *regs)
-{
-       adapter_t       *adapter = devp;
-       unsigned long   flags;
-
-
-       spin_lock_irqsave(adapter->host_lock, flags);
-
-       megaraid_memmbox_ack_sequence(adapter);
-
-       /* Loop through any pending requests */
-       if(atomic_read(&adapter->quiescent) == 0) {
-               mega_runpendq(adapter);
-       }
-
-       spin_unlock_irqrestore(adapter->host_lock, flags);
-
-       return;
-}
-
+
 /**
  * mega_cmd_done()
  * @adapter - pointer to our soft state
@@ -2102,7 +1924,7 @@ megaraid_isr_memmapped(int irq, void *de
  *
  * Complete the comamnds and call the scsi mid-layer callback hooks.
  */
-static void
+static inline void
 mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
 {
        mega_ext_passthru       *epthru = NULL;
@@ -2351,6 +2173,197 @@ mega_cmd_done(adapter_t *adapter, u8 com
 }
 
 
+/**
+ * megaraid_iombox_ack_sequence - interrupt ack sequence for IO mapped HBAs
+ * @adapter    - controller's soft state
+ *
+ * Interrupt ackrowledgement sequence for IO mapped HBAs
+ */
+static inline void
+megaraid_iombox_ack_sequence(adapter_t *adapter)
+{
+       u8      status;
+       int     nstatus;
+       u8      completed[MAX_FIRMWARE_STATUS];
+       u8      byte;
+       int     i;
+
+
+       /*
+        * loop till F/W has more commands for us to complete.
+        */
+       do {
+               /* Check if a valid interrupt is pending */
+               byte = irq_state(adapter);
+               if( (byte & VALID_INTR_BYTE) == 0 ) {
+                       return;
+               }
+               set_irq_state(adapter, byte);
+
+               while ((nstatus = adapter->mbox->numstatus) == 0xFF) {
+                       cpu_relax();
+               }
+               adapter->mbox->numstatus = 0xFF;
+
+               for (i = 0; i < nstatus; i++) {
+                       while ((completed[i] = adapter->mbox->completed[i])
+                                       == 0xFF) {
+                               cpu_relax();
+                       }
+
+                       adapter->mbox->completed[i] = 0xFF;
+               }
+
+               // we must read the valid status now
+               if ((status = adapter->mbox->status) == 0xFF) {
+                       printk(KERN_WARNING
+                       "megaraid critical: status 0xFF from firmware.\n");
+               }
+               adapter->mbox->status = 0xFF;
+
+               /*
+                * decrement the pending queue counter
+                */
+               atomic_sub(nstatus, &adapter->pend_cmds);
+
+               /* Acknowledge interrupt */
+               irq_ack(adapter);
+
+               mega_cmd_done(adapter, completed, nstatus, status);
+
+       } while(1);
+}
+
+
+/**
+ * megaraid_isr_iomapped()
+ * @irq - irq
+ * @devp - pointer to our soft state
+ * @regs - unused
+ *
+ * Interrupt service routine for io-mapped controllers.
+ * Find out if our device is interrupting. If yes, acknowledge the interrupt
+ * and service the completed commands.
+ */
+static void
+megaraid_isr_iomapped(int irq, void *devp, struct pt_regs *regs)
+{
+       adapter_t       *adapter = devp;
+       unsigned long   flags;
+
+       spin_lock_irqsave(adapter->host_lock, flags);
+
+       megaraid_iombox_ack_sequence(adapter);
+
+       /* Loop through any pending requests */
+       if( atomic_read(&adapter->quiescent ) == 0) {
+               mega_runpendq(adapter);
+       }
+
+       spin_unlock_irqrestore(adapter->host_lock, flags);
+
+       return;
+}
+
+
+/**
+ * megaraid_memmbox_ack_sequence - interrupt ack sequence for memory mapped 
HBAs
+ * @adapter    - controller's soft state
+ *
+ * Interrupt ackrowledgement sequence for memory mapped HBAs
+ */
+static inline void
+megaraid_memmbox_ack_sequence(adapter_t *adapter)
+{
+       u8      status;
+       u32     dword = 0;
+       int     nstatus;
+       u8      completed[MAX_FIRMWARE_STATUS];
+       int     i;
+
+
+       /*
+        * loop till F/W has more commands for us to complete.
+        */
+       do {
+               /* Check if a valid interrupt is pending */
+               dword = RDOUTDOOR(adapter);
+               if( dword != 0x10001234 ) {
+                       /*
+                        * No more pending commands
+                        */
+                       return;
+               }
+               WROUTDOOR(adapter, 0x10001234);
+
+               while ((nstatus = adapter->mbox->numstatus) == 0xFF) {
+                       cpu_relax();
+               }
+               adapter->mbox->numstatus = 0xFF;
+
+               for (i = 0; i < nstatus; i++ ) {
+                       while ((completed[i] = adapter->mbox->completed[i])
+                                       == 0xFF) {
+                               cpu_relax();
+                       }
+
+                       adapter->mbox->completed[i] = 0xFF;
+               }
+
+               // we must read the valid status now
+               if ((status = adapter->mbox->status) == 0xFF) {
+                       printk(KERN_WARNING
+                       "megaraid critical: status 0xFF from firmware.\n");
+               }
+               adapter->mbox->status = 0xFF;
+
+               /*
+                * decrement the pending queue counter
+                */
+               atomic_sub(nstatus, &adapter->pend_cmds);
+
+               /* Acknowledge interrupt */
+               WRINDOOR(adapter, 0x2);
+
+               while( RDINDOOR(adapter) & 0x02 ) cpu_relax();
+
+               mega_cmd_done(adapter, completed, nstatus, status);
+
+       } while(1);
+}
+
+
+/**
+ * megaraid_isr_memmapped()
+ * @irq - irq
+ * @devp - pointer to our soft state
+ * @regs - unused
+ *
+ * Interrupt service routine for memory-mapped controllers.
+ * Find out if our device is interrupting. If yes, acknowledge the interrupt
+ * and service the completed commands.
+ */
+static void
+megaraid_isr_memmapped(int irq, void *devp, struct pt_regs *regs)
+{
+       adapter_t       *adapter = devp;
+       unsigned long   flags;
+
+       spin_lock_irqsave(adapter->host_lock, flags);
+
+       megaraid_memmbox_ack_sequence(adapter);
+
+       /* Loop through any pending requests */
+       if(atomic_read(&adapter->quiescent) == 0) {
+               mega_runpendq(adapter);
+       }
+
+       spin_unlock_irqrestore(adapter->host_lock, flags);
+
+       return;
+}
+
+
 /*
  * Free a SCB structure
  * Note: We assume the scsi commands associated with this scb is not free yet.
@@ -2404,19 +2417,6 @@ mega_free_scb(adapter_t *adapter, scb_t 
        list_add(&scb->list, &adapter->free_list);
 }
 
-static int
-__mega_busywait_mbox (adapter_t *adapter)
-{
-       volatile mbox_t *mbox = adapter->mbox;
-       long counter;
-
-       for (counter = 0; counter < 10000; counter++) {
-               if (!mbox->busy)
-                       return 0;
-               udelay(100); yield();
-       }
-       return -1;              /* give up after 1 second */
-}
 
 /*
  * Copies data to SGLIST
@@ -2434,7 +2434,7 @@ mega_build_sglist(adapter_t *adapter, sc
 
        cmd = scb->cmd;
 
-       /* return 0 elements if no data transfer */
+       // return 0 elements if no data transfer
        if (!cmd->request_buffer || !cmd->request_bufflen)
                return 0;
 
@@ -2561,6 +2561,7 @@ mega_8_to_40ld(mraid_inquiry *inquiry, m
                enquiry3->pdrv_state[i] = inquiry->pdrv_info.pdrv_state[i];
 }
 
+
 static inline void
 mega_free_sgl(adapter_t *adapter)
 {
@@ -2726,7 +2727,7 @@ megaraid_release(struct Scsi_Host *host)
         */
        scsi_unregister(host);
 
-#if defined(__x86_64__)
+#ifdef LSI_CONFIG_COMPAT
        unregister_ioctl32_conversion(MEGAIOCCMD);
 #endif
 
@@ -2835,7 +2836,6 @@ megaraid_abort(Scsi_Cmnd *scp)
        return SUCCESS;
 }
 
-
 static int
 megaraid_reset(Scsi_Cmnd *cmd)
 {
@@ -2903,12 +2903,10 @@ megaraid_reset(Scsi_Cmnd *cmd)
                /*
                 * Perform the ack sequence, since interrupts are unavailable
                 */
-               if( adapter->flag & BOARD_MEMMAP ) {
+               if (adapter->flag & BOARD_MEMMAP)
                        megaraid_memmbox_ack_sequence(adapter);
-               }
-               else {
+               else
                        megaraid_iombox_ack_sequence(adapter);
-               }
 
                spin_unlock(adapter->host_lock);
 
@@ -2941,7 +2939,6 @@ megaraid_reset(Scsi_Cmnd *cmd)
        return rval;
 }
 
-
 #ifdef CONFIG_PROC_FS
 /* Following code handles /proc fs  */
 
@@ -3200,6 +3197,7 @@ proc_read_mbox(char *page, char **start,
        return len;
 }
 
+
 /**
  * mega_allocate_inquiry()
  * @dma_handle - handle returned for dma address
@@ -3582,7 +3580,7 @@ proc_pdrv(adapter_t *adapter, char *page
                 * Check for overflow. We print less than 240
                 * characters for inquiry
                 */
-               if( (len + 240) >= PAGE_SIZE ) break;
+               if( (len + 240) >= ((int) PAGE_SIZE) ) break;
 
                len += sprintf(page+len, "%s.\n", str);
 
@@ -3886,7 +3884,7 @@ proc_rdrv(adapter_t *adapter, char *page
                 * Check for overflow. We print less than 240 characters for
                 * information about each logical drive.
                 */
-               if( (len + 240) >= PAGE_SIZE ) break;
+               if( (len + 240) >= ((int) PAGE_SIZE) ) break;
 
                len += sprintf(page+len, "Logical drive:%2d:, ", i);
 
@@ -4172,7 +4170,7 @@ megadev_open (struct inode *inode, struc
 }
 
 
-#if defined(__x86_64__)
+#ifdef LSI_CONFIG_COMPAT
 static int
 megadev_compat_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
                struct file *filep)
@@ -4221,7 +4219,7 @@ megadev_ioctl(struct inode *inode, struc
        megacmd_t       mc;
        megastat_t      *ustats;
        int             num_ldrv;
-       u32             uxferaddr = 0;
+       caddr_t         uxferaddr=NULL;
        struct pci_dev  *pdev;
 
        ustats = NULL; /* avoid compilation warnings */
@@ -4251,13 +4249,13 @@ megadev_ioctl(struct inode *inode, struc
        switch( uioc.opcode ) {
 
        case GET_DRIVER_VER:
-               if( put_user(driver_ver, (u32 *)uioc.uioc_uaddr) )
+               if( put_user(driver_ver, (u32 *)uioc.u_dataaddr) )
                        return (-EFAULT);
 
                break;
 
        case GET_N_ADAP:
-               if( put_user(hba_count, (u32 *)uioc.uioc_uaddr) )
+               if( put_user(hba_count, (u32 *)uioc.u_dataaddr) )
                        return (-EFAULT);
 
                /*
@@ -4275,7 +4273,7 @@ megadev_ioctl(struct inode *inode, struc
                if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
                        return (-ENODEV);
 
-               if( copy_to_user(uioc.uioc_uaddr, mcontroller+adapno,
+               if( copy_to_user(uioc.u_dataaddr, mcontroller+adapno,
                                sizeof(struct mcontroller)) )
                        return (-EFAULT);
                break;
@@ -4291,7 +4289,7 @@ megadev_ioctl(struct inode *inode, struc
 
                adapter = hba_soft_state[adapno];
 
-               ustats = (megastat_t *)uioc.uioc_uaddr;
+               ustats = (megastat_t *)uioc.u_dataaddr;
 
                if( copy_from_user(&num_ldrv, &ustats->num_ldrv, sizeof(int)) )
                        return (-EFAULT);
@@ -4333,7 +4331,7 @@ megadev_ioctl(struct inode *inode, struc
                /*
                 * Which adapter
                 */
-               if( (adapno = GETADAP(uioc.adapno)) >= hba_count ) 
+               if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
                        return (-ENODEV);
 
                adapter = hba_soft_state[adapno];
@@ -4342,37 +4340,37 @@ megadev_ioctl(struct inode *inode, struc
                 * Deletion of logical drive is a special case. The adapter
                 * should be quiescent before this command is issued.
                 */
-               if( uioc.uioc_rmbox[0] == FC_DEL_LOGDRV &&
-                               uioc.uioc_rmbox[2] == OP_DEL_LOGDRV ) {
+               if( RMBOX(uioc)[0] == FC_DEL_LOGDRV ) {
+                       if ( RMBOX(uioc)[2] == OP_DEL_LOGDRV ) {
+                               /*
+                                * Do we support this feature
+                                */
+                               if( !adapter->support_random_del ) {
+                                       printk(KERN_WARNING "megaraid: logdrv 
");
+                                       printk("delete on non-supporting 
F/W.\n");
 
-                       /*
-                        * Do we support this feature
-                        */
-                       if( !adapter->support_random_del ) {
-                               printk(KERN_WARNING "megaraid: logdrv ");
-                               printk("delete on non-supporting F/W.\n");
+                                       return (-EINVAL);
+                               }
 
-                               return (-EINVAL);
-                       }
+                               rval = mega_del_logdrv( adapter, RMBOX(uioc)[3] 
);
 
-                       rval = mega_del_logdrv( adapter, uioc.uioc_rmbox[3] );
+                               if( rval == 0 ) {
+                                       memset(&mc, 0, sizeof(megacmd_t));
 
-                       if( rval == 0 ) {
-                               memset(&mc, 0, sizeof(megacmd_t));
+                                       mc.status = rval;
 
-                               mc.status = rval;
+                                       rval = mega_n_to_m((void *)arg, &mc);
+                               }
 
-                               rval = mega_n_to_m((void *)arg, &mc);
+                               return rval;
                        }
-
-                       return rval;
                }
                /*
                 * This interface only support the regular passthru commands.
                 * Reject extended passthru and 64-bit passthru
                 */
-               if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU64 ||
-                       uioc.uioc_rmbox[0] == MEGA_MBOXCMD_EXTPTHRU ) {
+               if( RMBOX(uioc)[0] == MEGA_MBOXCMD_PASSTHRU64 ||
+                       RMBOX(uioc)[0] == MEGA_MBOXCMD_EXTPTHRU ) {
 
                        printk(KERN_WARNING "megaraid: rejected passthru.\n");
 
@@ -4386,7 +4384,7 @@ megadev_ioctl(struct inode *inode, struc
                pdev = adapter->dev;
 
                /* Is it a passthru command or a DCMD */
-               if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
+               if( RMBOX(uioc)[0] == MEGA_MBOXCMD_PASSTHRU ) {
                        /* Passthru commands */
 
                        pthru = adapter->int_pthru;
@@ -4394,20 +4392,12 @@ megadev_ioctl(struct inode *inode, struc
                        /*
                         * The user passthru structure
                         */
-                       upthru = (mega_passthru *)
-                                       ((ulong)(MBOX(uioc)->xferaddr));
-                       /*
-                        * Copy in the user passthru here.
-                        */
-                       if( copy_from_user(pthru, (char *)upthru,
-                                               sizeof(mega_passthru)) ) {
-                               return (-EFAULT);
-                       }
-
+                        upthru = &uioc.pthru;
+                        memcpy(pthru, (char *)upthru,sizeof(mega_passthru));
                        /*
                         * Is there a data transfer; If the data transfer
-                        * length is <= INT_MEMBLK_SZ, usr the buffer 
-                        * allocated at the load time. Otherwise, allocate it 
+                        * length is <= INT_MEMBLK_SZ, usr the buffer
+                        * allocated at the load time. Otherwise, allocate it
                         * here.
                         */
                        if (pthru->dataxferlen) {
@@ -4417,8 +4407,9 @@ megadev_ioctl(struct inode *inode, struc
                                                        pthru->dataxferlen,
                                                        &data_dma_hndl );
 
-                                       if (data == NULL)
+                                       if (data == NULL) {
                                                return (-ENOMEM);
+                                       }
                                }
                                else {
                                        data = adapter->int_data;
@@ -4428,11 +4419,11 @@ megadev_ioctl(struct inode *inode, struc
                                 * Save the user address and point the kernel
                                 * address at just allocated memory
                                 */
-                               uxferaddr = pthru->dataxferaddr;
+                               uxferaddr = (caddr_t) uioc.u_dataaddr;
                                if (data_dma_hndl)
                                        pthru->dataxferaddr = data_dma_hndl;
                                else
-                                       pthru->dataxferaddr = 
+                                       pthru->dataxferaddr =
                                                adapter->int_data_dma_hndl;
                        }
 
@@ -4440,12 +4431,12 @@ megadev_ioctl(struct inode *inode, struc
                        /*
                         * Is data coming down-stream
                         */
-                       if( pthru->dataxferlen && (uioc.flags & UIOC_WR) ) {
+                       if(pthru->dataxferlen  && (uioc.flags & UIOC_WR) ) {
                                /*
                                 * Get the user data
                                 */
                                if( copy_from_user(data,
-                                               (char *)((ulong)uxferaddr),
+                                               (char *)uxferaddr,
                                                pthru->dataxferlen) ) {
                                        rval = (-EFAULT);
                                        goto freedata_and_return;
@@ -4471,7 +4462,7 @@ megadev_ioctl(struct inode *inode, struc
                         * Is data going up-stream
                         */
                        if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) {
-                               if( copy_to_user((char *)((ulong)uxferaddr),
+                               if( copy_to_user((char *)uxferaddr,
                                                data, pthru->dataxferlen) ) {
                                        rval = (-EFAULT);
                                }
@@ -4511,7 +4502,7 @@ freedata_and_return:
                                else {
                                        data = adapter->int_data;
                                }
-                               uxferaddr = MBOX(uioc)->xferaddr;
+                               uxferaddr = uioc.u_dataaddr;
                        }
 
                        /*
@@ -4559,7 +4550,7 @@ freedata_and_return:
                         * Is data going up-stream
                         */
                        if( uioc.xferlen && (uioc.flags & UIOC_RD) ) {
-                               if( copy_to_user((char *)((ulong)uxferaddr),
+                               if( copy_to_user((char *)uxferaddr,
                                                data, uioc.xferlen) ) {
 
                                        rval = (-EFAULT);
@@ -4648,18 +4639,18 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
 
                case MEGAIOC_QDRVRVER:  /* Query driver version */
                        uioc->opcode = GET_DRIVER_VER;
-                       uioc->uioc_uaddr = uioc_mimd.data;
+                       uioc->u_dataaddr = uioc_mimd.data;
                        break;
 
                case MEGAIOC_QNADAP:    /* Get # of adapters */
                        uioc->opcode = GET_N_ADAP;
-                       uioc->uioc_uaddr = uioc_mimd.data;
+                       uioc->u_dataaddr = uioc_mimd.data;
                        break;
 
                case MEGAIOC_QADAPINFO: /* Get adapter information */
                        uioc->opcode = GET_ADAP_INFO;
                        uioc->adapno = uioc_mimd.ui.fcs.adapno;
-                       uioc->uioc_uaddr = uioc_mimd.data;
+                       uioc->u_dataaddr = uioc_mimd.data;
                        break;
 
                default:
@@ -4674,9 +4665,16 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
                uioc->opcode = MBOX_CMD;
                uioc->adapno = uioc_mimd.ui.fcs.adapno;
 
-               memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18);
+               memcpy(&uioc->u_mbox, uioc_mimd.mbox, 18);
 
                uioc->xferlen = uioc_mimd.ui.fcs.length;
+               uioc->u_dataaddr = uioc_mimd.ui.fcs.buffer;
+
+               if (uioc_mimd.mbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
+                       memcpy(&uioc->pthru,&uioc_mimd.pthru,
+                               sizeof(mega_passthru));
+
+               }
 
                if( uioc_mimd.outlen ) uioc->flags = UIOC_RD;
                if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR;
@@ -4688,13 +4686,20 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
                uioc->opcode = MBOX_CMD;
                uioc->adapno = uioc_mimd.ui.fcs.adapno;
 
-               memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18);
+               memcpy(&uioc->u_mbox, uioc_mimd.mbox, 18);
 
                /*
                 * Choose the xferlen bigger of input and output data
                 */
                uioc->xferlen = uioc_mimd.outlen > uioc_mimd.inlen ?
                        uioc_mimd.outlen : uioc_mimd.inlen;
+               uioc->u_dataaddr = uioc_mimd.data;
+
+               if (uioc_mimd.mbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
+                       memcpy(&uioc->pthru,&uioc_mimd.pthru,
+                               sizeof(mega_passthru));
+
+               }
 
                if( uioc_mimd.outlen ) uioc->flags = UIOC_RD;
                if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR;
@@ -4720,7 +4725,6 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
 static int
 mega_n_to_m(void *arg, megacmd_t *mc)
 {
-       nitioctl_t      *uiocp;
        megacmd_t       *umc;
        megacmd_t       kmc;
        mega_passthru   *upthru;
@@ -4735,20 +4739,14 @@ mega_n_to_m(void *arg, megacmd_t *mc)
 
        if( memcmp(signature, "MEGANIT", 7) == 0 ) {
 
-               uiocp = (nitioctl_t *)arg;
-
-               if( put_user(mc->status, (u8 *)&MBOX_P(uiocp)->status) )
-                       return (-EFAULT);
-
-               if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
-
-                       umc = MBOX_P(uiocp);
 
-                       upthru = (mega_passthru *)((ulong)(umc->xferaddr));
-
-                       if( put_user(mc->status, (u8 *)&upthru->scsistatus) )
-                               return (-EFAULT);
-               }
+               /*
+                * NOTE: The nit ioctl is still under flux because of
+                * change of mailbox definition, in HPE. No applications yet
+                * use this interface and let's not have applications use this
+                * interface till the new specifitions are in place.
+                */
+               return -EINVAL;
        }
        else {
                uioc_mimd = (struct uioctl_t *)arg;
@@ -4763,8 +4761,7 @@ mega_n_to_m(void *arg, megacmd_t *mc)
                        if (copy_from_user(&kmc, umc, sizeof(megacmd_t))) {
                                return -EFAULT;
                        }
-
-                       upthru = (mega_passthru *)((ulong)kmc.xferaddr);
+                       upthru = (mega_passthru *)((ulong)&uioc_mimd->pthru);
 
                        if( put_user(mc->status, (u8 *)&upthru->scsistatus) ){
                                return (-EFAULT);
@@ -5179,6 +5176,7 @@ mega_support_cluster(adapter_t *adapter)
 }
 
 
+
 /**
  * mega_reorder_hosts()
  *
@@ -5393,7 +5391,6 @@ mega_adapinq(adapter_t *adapter, dma_add
 }
 
 
-
 /** mega_internal_dev_inquiry()
  * @adapter - pointer to our soft state
  * @ch - channel for this device
diff --git a/drivers/scsi/megaraid2.h b/drivers/scsi/megaraid2.h
--- a/drivers/scsi/megaraid2.h
+++ b/drivers/scsi/megaraid2.h
@@ -6,7 +6,7 @@
 
 
 #define MEGARAID_VERSION       \
-       "v2.10.8.2 (Release Date: Mon Jul 26 12:15:51 EDT 2004)\n"
+       "v2.10.10.1 (Release Date: Thu Jan 27 16:19:44 EDT 2005)\n"
 
 /*
  * Driver features - change the values to enable or disable features in the
@@ -83,6 +83,7 @@
 #define INTEL_SUBSYS_VID               0x8086
 #define FSC_SUBSYS_VID                 0x1734
 #define ACER_SUBSYS_VID                        0x1025
+#define NEC_SUBSYS_VID                 0x1033
 
 #define HBA_SIGNATURE                  0x3344
 #define HBA_SIGNATURE_471              0xCCCC
@@ -707,15 +708,15 @@ typedef struct {
        char            signature[8];   /* Must contain "MEGANIT" */
        u32             opcode;         /* opcode for the command */
        u32             adapno;         /* adapter number */
-       union {
-               u8      __raw_mbox[18];
-               caddr_t __uaddr; /* xferaddr for non-mbox cmds */
-       }__ua;
-
-#define uioc_rmbox     __ua.__raw_mbox
-#define MBOX(uioc)     ((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
-#define MBOX_P(uioc)   ((megacmd_t *)&((uioc)->__ua.__raw_mbox[0]))
-#define uioc_uaddr     __ua.__uaddr
+       mbox_t          u_mbox;         /* user mailbox */
+       caddr_t         u_dataaddr;     /* xferaddr for DCMD and non-mbox
+                                          commands */
+       mega_passthru   pthru;
+
+#define RMBOX(uioc)    ((u8 *)&(uioc).u_mbox)
+#define MBOX(uioc)     ((megacmd_t *)&(uioc).u_mbox)
+#define MBOX_P(uioc)   ((megacmd_t *)&(uioc)->u_mbox)
+
 
        u32             xferlen;        /* xferlen for DCMD and non-mbox
                                           commands */
@@ -1128,7 +1129,7 @@ static int mega_build_sglist (adapter_t 
                              u32 *buffer, u32 *length);
 static inline int mega_busywait_mbox (adapter_t *);
 static int __mega_busywait_mbox (adapter_t *);
-static void mega_cmd_done(adapter_t *, u8 [], int, int);
+static inline void mega_cmd_done(adapter_t *, u8 [], int, int);
 static inline void mega_free_sgl (adapter_t *adapter);
 static void mega_8_to_40ld (mraid_inquiry *inquiry,
                mega_inquiry3 *enquiry3, mega_product_info *);
@@ -1137,7 +1138,14 @@ static int megaraid_reboot_notify (struc
                                   unsigned long, void *);
 static int megadev_open (struct inode *, struct file *);
 
-#if defined(__x86_64__)
+#if defined( __x86_64__) || defined(IA32_EMULATION)
+#ifndef __ia64__
+#define LSI_CONFIG_COMPAT
+#endif
+#endif
+
+
+#ifdef LSI_CONFIG_COMPAT
 static int megadev_compat_ioctl(unsigned int, unsigned int, unsigned long,
        struct file *);
 #endif
-
To unsubscribe from this list: send the line "unsubscribe git-commits-24" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to