]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/qla2xxx/qla_mbx.c
[SCSI] qla2xxx: Add port-speed FC transport attribute.
[linux-2.6-omap-h63xx.git] / drivers / scsi / qla2xxx / qla_mbx.c
index 13e1c9047079e8fcfd2ef808f1ba93d1fbef13e9..3099b379de9d89d554ebd1b5e9dde9d21fdb5d47 100644 (file)
@@ -1,20 +1,8 @@
 /*
- *                  QLOGIC LINUX SOFTWARE
- *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2005 QLogic Corporation
- * (www.qlogic.com)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * QLogic Fibre Channel HBA Driver
+ * Copyright (c)  2003-2005 QLogic Corporation
  *
+ * See LICENSE.qla2xxx for copyright and licensing details.
  */
 #include "qla_def.h"
 
@@ -208,7 +196,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                        /* Check for pending interrupts. */
                        qla2x00_poll(ha);
 
-                       udelay(10); /* v4.27 */
+                       if (command != MBC_LOAD_RISC_RAM_EXTENDED &&
+                           !ha->flags.mbox_int)
+                               msleep(10);
                } /* while */
        }
 
@@ -337,113 +327,30 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
        return rval;
 }
 
-/*
- * qla2x00_load_ram
- *     Load adapter RAM using DMA.
- *
- * Input:
- *     ha = adapter block pointer.
- *
- * Returns:
- *     qla2x00 local function return status code.
- *
- * Context:
- *     Kernel context.
- */
 int
-qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint16_t risc_addr,
-    uint16_t risc_code_size)
+qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
+    uint32_t risc_code_size)
 {
        int rval;
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
-       uint32_t        req_len;
-       dma_addr_t      nml_dma;
-       uint32_t        nml_len;
-       uint32_t        normalized;
 
-       DEBUG11(printk("qla2x00_load_ram(%ld): entered.\n",
-           ha->host_no);)
-
-       req_len = risc_code_size;
-       nml_dma = 0;
-       nml_len = 0;
-
-       normalized = qla2x00_normalize_dma_addr(&req_dma, &req_len, &nml_dma,
-           &nml_len);
-
-       /* Load first segment */
-       mcp->mb[0] = MBC_LOAD_RISC_RAM;
-       mcp->mb[1] = risc_addr;
-       mcp->mb[2] = MSW(req_dma);
-       mcp->mb[3] = LSW(req_dma);
-       mcp->mb[4] = (uint16_t)req_len;
-       mcp->mb[6] = MSW(MSD(req_dma));
-       mcp->mb[7] = LSW(MSD(req_dma));
-       mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
-       mcp->in_mb = MBX_0;
-       mcp->tov = 30;
-       mcp->flags = 0;
-       rval = qla2x00_mailbox_command(ha, mcp);
-
-       /* Load second segment - if necessary */
-       if (normalized && (rval == QLA_SUCCESS)) {
-               mcp->mb[0] = MBC_LOAD_RISC_RAM;
-               mcp->mb[1] = risc_addr + (uint16_t)req_len;
-               mcp->mb[2] = MSW(nml_dma);
-               mcp->mb[3] = LSW(nml_dma);
-               mcp->mb[4] = (uint16_t)nml_len;
-               mcp->mb[6] = MSW(MSD(nml_dma));
-               mcp->mb[7] = LSW(MSD(nml_dma));
-               mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
-               mcp->in_mb = MBX_0;
-               mcp->tov = 30;
-               mcp->flags = 0;
-               rval = qla2x00_mailbox_command(ha, mcp);
-       }
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
-       if (rval == QLA_SUCCESS) {
-               /* Empty */
-               DEBUG11(printk("qla2x00_load_ram(%ld): done.\n", ha->host_no);)
+       if (MSW(risc_addr) || IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
+               mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
+               mcp->mb[8] = MSW(risc_addr);
+               mcp->out_mb = MBX_8|MBX_0;
        } else {
-               /* Empty */
-               DEBUG2_3_11(printk("qla2x00_load_ram(%ld): failed. rval=%x "
-                   "mb[0]=%x.\n", ha->host_no, rval, mcp->mb[0]);)
+               mcp->mb[0] = MBC_LOAD_RISC_RAM;
+               mcp->out_mb = MBX_0;
        }
-       return rval;
-}
-
-/*
- * qla2x00_load_ram_ext
- *     Load adapter extended RAM using DMA.
- *
- * Input:
- *     ha = adapter block pointer.
- *
- * Returns:
- *     qla2x00 local function return status code.
- *
- * Context:
- *     Kernel context.
- */
-int
-qla2x00_load_ram_ext(scsi_qla_host_t *ha, dma_addr_t req_dma,
-    uint32_t risc_addr, uint32_t risc_code_size)
-{
-       int rval;
-       mbx_cmd_t mc;
-       mbx_cmd_t *mcp = &mc;
-
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
-
-       mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
        mcp->mb[1] = LSW(risc_addr);
        mcp->mb[2] = MSW(req_dma);
        mcp->mb[3] = LSW(req_dma);
        mcp->mb[6] = MSW(MSD(req_dma));
        mcp->mb[7] = LSW(MSD(req_dma));
-       mcp->mb[8] = MSW(risc_addr);
-       mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+       mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
        if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
                mcp->mb[4] = MSW(risc_code_size);
                mcp->mb[5] = LSW(risc_code_size);
@@ -880,10 +787,6 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);)
 
        fcport = sp->fcport;
-       if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
-           atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
-               return 1;
-       }
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
        for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
@@ -1020,6 +923,8 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
        mcp->tov = 30;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(ha, mcp);
+       if (mcp->mb[0] == MBS_COMMAND_ERROR)
+               rval = QLA_COMMAND_ERROR;
 
        /* Return data. */
        *id = mcp->mb[1];
@@ -2191,10 +2096,6 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
 
        fcport = sp->fcport;
-       if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
-           atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
-               return QLA_FUNCTION_FAILED;
-       }
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
        for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {