2005-04-23 06:02:25 +08:00
|
|
|
/*
|
|
|
|
* linux/drivers/message/fusion/mptspi.c
|
2007-08-14 18:52:54 +08:00
|
|
|
* For use with LSI PCI chip/adapter(s)
|
|
|
|
* running LSI Fusion MPT (Message Passing Technology) firmware.
|
2005-04-23 06:02:25 +08:00
|
|
|
*
|
2008-05-21 03:26:41 +08:00
|
|
|
* Copyright (c) 1999-2008 LSI Corporation
|
2007-06-14 06:31:07 +08:00
|
|
|
* (mailto:DL-MPTFusionLinux@lsi.com)
|
2005-04-23 06:02:25 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
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; version 2 of the License.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
NO WARRANTY
|
|
|
|
THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
|
|
|
|
LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
|
|
|
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
|
|
|
|
solely responsible for determining the appropriateness of using and
|
|
|
|
distributing the Program and assumes all risks associated with its
|
|
|
|
exercise of rights under this Agreement, including but not limited to
|
|
|
|
the risks and costs of program errors, damage to or loss of data,
|
|
|
|
programs or equipment, and unavailability or interruption of operations.
|
|
|
|
|
|
|
|
DISCLAIMER OF LIABILITY
|
|
|
|
NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
|
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
|
|
USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
|
|
|
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-23 06:02:25 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kdev_t.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h> /* for mdelay */
|
|
|
|
#include <linux/interrupt.h> /* needed for in_interrupt() proto */
|
|
|
|
#include <linux/reboot.h> /* notifier code */
|
|
|
|
#include <linux/workqueue.h>
|
2006-03-01 23:02:49 +08:00
|
|
|
#include <linux/raid_class.h>
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_cmnd.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_tcq.h>
|
2006-03-01 23:02:49 +08:00
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_spi.h>
|
2007-01-30 00:44:06 +08:00
|
|
|
#include <scsi/scsi_dbg.h>
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
#include "mptbase.h"
|
|
|
|
#include "mptscsih.h"
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
#define my_NAME "Fusion MPT SPI Host driver"
|
|
|
|
#define my_VERSION MPT_LINUX_VERSION_COMMON
|
|
|
|
#define MYNAM "mptspi"
|
|
|
|
|
|
|
|
MODULE_AUTHOR(MODULEAUTHOR);
|
|
|
|
MODULE_DESCRIPTION(my_NAME);
|
|
|
|
MODULE_LICENSE("GPL");
|
2007-01-05 11:47:47 +08:00
|
|
|
MODULE_VERSION(my_VERSION);
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
/* Command line args */
|
|
|
|
static int mpt_saf_te = MPTSCSIH_SAF_TE;
|
|
|
|
module_param(mpt_saf_te, int, 0);
|
|
|
|
MODULE_PARM_DESC(mpt_saf_te, " Force enabling SEP Processor: enable=1 (default=MPTSCSIH_SAF_TE=0)");
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
static void mptspi_write_offset(struct scsi_target *, int);
|
|
|
|
static void mptspi_write_width(struct scsi_target *, int);
|
|
|
|
static int mptspi_write_spi_device_pg1(struct scsi_target *,
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 *);
|
|
|
|
|
|
|
|
static struct scsi_transport_template *mptspi_transport_template = NULL;
|
|
|
|
|
2007-08-14 18:42:53 +08:00
|
|
|
static u8 mptspiDoneCtx = MPT_MAX_PROTOCOL_DRIVERS;
|
|
|
|
static u8 mptspiTaskCtx = MPT_MAX_PROTOCOL_DRIVERS;
|
|
|
|
static u8 mptspiInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */
|
2005-04-23 06:02:25 +08:00
|
|
|
|
2007-01-30 00:43:17 +08:00
|
|
|
/**
|
2007-02-21 03:17:03 +08:00
|
|
|
* mptspi_setTargetNegoParms - Update the target negotiation parameters
|
2007-01-30 00:43:17 +08:00
|
|
|
* @hd: Pointer to a SCSI Host Structure
|
2007-02-21 03:17:03 +08:00
|
|
|
* @target: per target private data
|
2007-01-30 00:43:17 +08:00
|
|
|
* @sdev: SCSI device
|
|
|
|
*
|
2007-02-21 03:17:03 +08:00
|
|
|
* Update the target negotiation parameters based on the the Inquiry
|
|
|
|
* data, adapter capabilities, and NVRAM settings.
|
2007-01-30 00:43:17 +08:00
|
|
|
**/
|
|
|
|
static void
|
|
|
|
mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
|
|
|
|
struct scsi_device *sdev)
|
|
|
|
{
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
|
|
|
SpiCfgData *pspi_data = &ioc->spi_data;
|
2007-01-30 00:43:17 +08:00
|
|
|
int id = (int) target->id;
|
|
|
|
int nvram;
|
|
|
|
u8 width = MPT_NARROW;
|
|
|
|
u8 factor = MPT_ASYNC;
|
|
|
|
u8 offset = 0;
|
|
|
|
u8 nfactor;
|
|
|
|
u8 noQas = 1;
|
|
|
|
|
|
|
|
target->negoFlags = pspi_data->noQas;
|
|
|
|
|
|
|
|
if (sdev->scsi_level < SCSI_2) {
|
|
|
|
width = 0;
|
|
|
|
factor = MPT_ULTRA2;
|
|
|
|
offset = pspi_data->maxSyncOffset;
|
|
|
|
target->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
|
|
|
|
} else {
|
|
|
|
if (scsi_device_wide(sdev))
|
|
|
|
width = 1;
|
|
|
|
|
|
|
|
if (scsi_device_sync(sdev)) {
|
|
|
|
factor = pspi_data->minSyncFactor;
|
|
|
|
if (!scsi_device_dt(sdev))
|
|
|
|
factor = MPT_ULTRA2;
|
|
|
|
else {
|
|
|
|
if (!scsi_device_ius(sdev) &&
|
|
|
|
!scsi_device_qas(sdev))
|
|
|
|
factor = MPT_ULTRA160;
|
|
|
|
else {
|
|
|
|
factor = MPT_ULTRA320;
|
|
|
|
if (scsi_device_qas(sdev)) {
|
2007-09-15 08:49:03 +08:00
|
|
|
ddvprintk(ioc,
|
2007-09-15 08:46:51 +08:00
|
|
|
printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to "
|
2007-09-15 08:49:03 +08:00
|
|
|
"byte56=%02x on id=%d!\n", ioc->name,
|
2007-09-15 08:46:51 +08:00
|
|
|
scsi_device_qas(sdev), id));
|
2007-01-30 00:43:17 +08:00
|
|
|
noQas = 0;
|
|
|
|
}
|
|
|
|
if (sdev->type == TYPE_TAPE &&
|
|
|
|
scsi_device_ius(sdev))
|
|
|
|
target->negoFlags |= MPT_TAPE_NEGO_IDP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
offset = pspi_data->maxSyncOffset;
|
|
|
|
|
|
|
|
/* If RAID, never disable QAS
|
|
|
|
* else if non RAID, do not disable
|
|
|
|
* QAS if bit 1 is set
|
|
|
|
* bit 1 QAS support, non-raid only
|
|
|
|
* bit 0 IU support
|
|
|
|
*/
|
|
|
|
if (target->raidVolume == 1)
|
|
|
|
noQas = 0;
|
|
|
|
} else {
|
|
|
|
factor = MPT_ASYNC;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sdev->tagged_supported)
|
|
|
|
target->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
|
|
|
|
|
|
|
|
/* Update tflags based on NVRAM settings. (SCSI only)
|
|
|
|
*/
|
|
|
|
if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) {
|
|
|
|
nvram = pspi_data->nvram[id];
|
|
|
|
nfactor = (nvram & MPT_NVRAM_SYNC_MASK) >> 8;
|
|
|
|
|
|
|
|
if (width)
|
|
|
|
width = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
|
|
|
|
|
|
|
|
if (offset > 0) {
|
|
|
|
/* Ensure factor is set to the
|
|
|
|
* maximum of: adapter, nvram, inquiry
|
|
|
|
*/
|
|
|
|
if (nfactor) {
|
|
|
|
if (nfactor < pspi_data->minSyncFactor )
|
|
|
|
nfactor = pspi_data->minSyncFactor;
|
|
|
|
|
|
|
|
factor = max(factor, nfactor);
|
|
|
|
if (factor == MPT_ASYNC)
|
|
|
|
offset = 0;
|
|
|
|
} else {
|
|
|
|
offset = 0;
|
|
|
|
factor = MPT_ASYNC;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
factor = MPT_ASYNC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure data is consistent
|
|
|
|
*/
|
|
|
|
if ((!width) && (factor < MPT_ULTRA2))
|
|
|
|
factor = MPT_ULTRA2;
|
|
|
|
|
|
|
|
/* Save the data to the target structure.
|
|
|
|
*/
|
|
|
|
target->minSyncFactor = factor;
|
|
|
|
target->maxOffset = offset;
|
|
|
|
target->maxWidth = width;
|
|
|
|
|
2010-03-18 21:51:34 +08:00
|
|
|
spi_min_period(scsi_target(sdev)) = factor;
|
|
|
|
spi_max_offset(scsi_target(sdev)) = offset;
|
|
|
|
spi_max_width(scsi_target(sdev)) = width;
|
|
|
|
|
2007-01-30 00:43:17 +08:00
|
|
|
target->tflags |= MPT_TARGET_FLAGS_VALID_NEGO;
|
|
|
|
|
|
|
|
/* Disable unused features.
|
|
|
|
*/
|
|
|
|
if (!width)
|
|
|
|
target->negoFlags |= MPT_TARGET_NO_NEGO_WIDE;
|
|
|
|
|
|
|
|
if (!offset)
|
|
|
|
target->negoFlags |= MPT_TARGET_NO_NEGO_SYNC;
|
|
|
|
|
|
|
|
if ( factor > MPT_ULTRA320 )
|
|
|
|
noQas = 0;
|
|
|
|
|
|
|
|
if (noQas && (pspi_data->noQas == 0)) {
|
|
|
|
pspi_data->noQas |= MPT_TARGET_NO_NEGO_QAS;
|
|
|
|
target->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
|
|
|
|
|
|
|
|
/* Disable QAS in a mixed configuration case
|
|
|
|
*/
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
|
|
|
|
"Disabling QAS due to noQas=%02x on id=%d!\n", ioc->name, noQas, id));
|
2007-01-30 00:43:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mptspi_writeIOCPage4 - write IOC Page 4
|
|
|
|
* @hd: Pointer to a SCSI Host Structure
|
2007-02-21 03:17:03 +08:00
|
|
|
* @channel: channel number
|
2007-01-30 00:43:17 +08:00
|
|
|
* @id: write IOC Page4 for this ID & Bus
|
|
|
|
*
|
|
|
|
* Return: -EAGAIN if unable to obtain a Message Frame
|
|
|
|
* or 0 if success.
|
|
|
|
*
|
|
|
|
* Remark: We do not wait for a return, write pages sequentially.
|
|
|
|
**/
|
|
|
|
static int
|
|
|
|
mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id)
|
|
|
|
{
|
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
|
|
|
Config_t *pReq;
|
|
|
|
IOCPage4_t *IOCPage4Ptr;
|
|
|
|
MPT_FRAME_HDR *mf;
|
|
|
|
dma_addr_t dataDma;
|
|
|
|
u16 req_idx;
|
|
|
|
u32 frameOffset;
|
|
|
|
u32 flagsLength;
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
/* Get a MF for this command.
|
|
|
|
*/
|
|
|
|
if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
|
2007-07-24 18:17:41 +08:00
|
|
|
dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
|
|
|
|
"writeIOCPage4 : no msg frames!\n",ioc->name));
|
2007-01-30 00:43:17 +08:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the request and the data pointers.
|
|
|
|
* Place data at end of MF.
|
|
|
|
*/
|
|
|
|
pReq = (Config_t *)mf;
|
|
|
|
|
|
|
|
req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
|
|
|
|
frameOffset = ioc->req_sz - sizeof(IOCPage4_t);
|
|
|
|
|
|
|
|
/* Complete the request frame (same for all requests).
|
|
|
|
*/
|
|
|
|
pReq->Action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
|
|
|
|
pReq->Reserved = 0;
|
|
|
|
pReq->ChainOffset = 0;
|
|
|
|
pReq->Function = MPI_FUNCTION_CONFIG;
|
|
|
|
pReq->ExtPageLength = 0;
|
|
|
|
pReq->ExtPageType = 0;
|
|
|
|
pReq->MsgFlags = 0;
|
|
|
|
for (ii=0; ii < 8; ii++) {
|
|
|
|
pReq->Reserved2[ii] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IOCPage4Ptr = ioc->spi_data.pIocPg4;
|
|
|
|
dataDma = ioc->spi_data.IocPg4_dma;
|
|
|
|
ii = IOCPage4Ptr->ActiveSEP++;
|
|
|
|
IOCPage4Ptr->SEP[ii].SEPTargetID = id;
|
|
|
|
IOCPage4Ptr->SEP[ii].SEPBus = channel;
|
|
|
|
pReq->Header = IOCPage4Ptr->Header;
|
|
|
|
pReq->PageAddress = cpu_to_le32(id | (channel << 8 ));
|
|
|
|
|
|
|
|
/* Add a SGE to the config request.
|
|
|
|
*/
|
|
|
|
flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE |
|
|
|
|
(IOCPage4Ptr->Header.PageLength + ii) * 4;
|
|
|
|
|
2009-05-29 19:07:04 +08:00
|
|
|
ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
|
2007-01-30 00:43:17 +08:00
|
|
|
|
2007-07-24 18:17:41 +08:00
|
|
|
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
|
2007-01-30 00:43:17 +08:00
|
|
|
"writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n",
|
2007-09-15 08:46:51 +08:00
|
|
|
ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel));
|
2007-01-30 00:43:17 +08:00
|
|
|
|
|
|
|
mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mptspi_initTarget - Target, LUN alloc/free functionality.
|
|
|
|
* @hd: Pointer to MPT_SCSI_HOST structure
|
|
|
|
* @vtarget: per target private data
|
|
|
|
* @sdev: SCSI device
|
|
|
|
*
|
|
|
|
* NOTE: It's only SAFE to call this routine if data points to
|
|
|
|
* sane & valid STANDARD INQUIRY data!
|
|
|
|
*
|
|
|
|
* Allocate and initialize memory for this target.
|
|
|
|
* Save inquiry data.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
static void
|
|
|
|
mptspi_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget,
|
|
|
|
struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Is LUN supported? If so, upper 2 bits will be 0
|
|
|
|
* in first byte of inquiry data.
|
|
|
|
*/
|
|
|
|
if (sdev->inq_periph_qual != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (vtarget == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
vtarget->type = sdev->type;
|
|
|
|
|
|
|
|
if ((sdev->type == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) {
|
|
|
|
/* Treat all Processors as SAF-TE if
|
|
|
|
* command line option is set */
|
|
|
|
vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
|
|
|
|
mptspi_writeIOCPage4(hd, vtarget->channel, vtarget->id);
|
|
|
|
}else if ((sdev->type == TYPE_PROCESSOR) &&
|
|
|
|
!(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {
|
|
|
|
if (sdev->inquiry_len > 49 ) {
|
|
|
|
if (sdev->inquiry[44] == 'S' &&
|
|
|
|
sdev->inquiry[45] == 'A' &&
|
|
|
|
sdev->inquiry[46] == 'F' &&
|
|
|
|
sdev->inquiry[47] == '-' &&
|
|
|
|
sdev->inquiry[48] == 'T' &&
|
|
|
|
sdev->inquiry[49] == 'E' ) {
|
|
|
|
vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
|
|
|
|
mptspi_writeIOCPage4(hd, vtarget->channel, vtarget->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mptspi_setTargetNegoParms(hd, vtarget, sdev);
|
|
|
|
}
|
2007-01-30 00:42:20 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* mptspi_is_raid - Determines whether target is belonging to volume
|
|
|
|
* @hd: Pointer to a SCSI HOST structure
|
|
|
|
* @id: target device id
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* non-zero = true
|
|
|
|
* zero = false
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id)
|
|
|
|
{
|
|
|
|
int i, rc = 0;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2007-01-30 00:42:20 +08:00
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
if (!ioc->raid_data.pIocPg2)
|
2007-01-30 00:42:20 +08:00
|
|
|
goto out;
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
|
2007-01-30 00:42:20 +08:00
|
|
|
goto out;
|
2007-09-15 08:49:03 +08:00
|
|
|
for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
|
|
|
|
if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {
|
2007-01-30 00:42:20 +08:00
|
|
|
rc = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
static int mptspi_target_alloc(struct scsi_target *starget)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(shost);
|
2007-01-30 00:42:20 +08:00
|
|
|
VirtTarget *vtarget;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
if (hd == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
ioc = hd->ioc;
|
2007-01-30 00:42:20 +08:00
|
|
|
vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
|
|
|
|
if (!vtarget)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
vtarget->ioc_id = ioc->id;
|
2007-01-30 00:42:20 +08:00
|
|
|
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
|
|
|
|
vtarget->id = (u8)starget->id;
|
|
|
|
vtarget->channel = (u8)starget->channel;
|
|
|
|
vtarget->starget = starget;
|
|
|
|
starget->hostdata = vtarget;
|
|
|
|
|
|
|
|
if (starget->channel == 1) {
|
2007-09-15 08:49:03 +08:00
|
|
|
if (mptscsih_is_phys_disk(ioc, 0, starget->id) == 0)
|
2007-01-30 00:42:20 +08:00
|
|
|
return 0;
|
|
|
|
vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
|
|
|
|
/* The real channel for this device is zero */
|
|
|
|
vtarget->channel = 0;
|
|
|
|
/* The actual physdisknum (for RAID passthrough) */
|
2007-09-15 08:49:03 +08:00
|
|
|
vtarget->id = mptscsih_raid_id_to_num(ioc, 0,
|
2007-01-30 00:42:20 +08:00
|
|
|
starget->id);
|
|
|
|
}
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
if (starget->channel == 0 &&
|
|
|
|
mptspi_is_raid(hd, starget->id)) {
|
|
|
|
vtarget->raidVolume = 1;
|
2007-09-15 08:49:03 +08:00
|
|
|
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
|
|
|
|
"RAID Volume @ channel=%d id=%d\n", ioc->name, starget->channel,
|
2007-01-30 00:42:20 +08:00
|
|
|
starget->id));
|
|
|
|
}
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
if (ioc->spi_data.nvram &&
|
|
|
|
ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) {
|
|
|
|
u32 nvram = ioc->spi_data.nvram[starget->id];
|
2006-03-01 23:02:49 +08:00
|
|
|
spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;
|
|
|
|
spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
|
|
|
|
} else {
|
2007-09-15 08:49:03 +08:00
|
|
|
spi_min_period(starget) = ioc->spi_data.minSyncFactor;
|
|
|
|
spi_max_width(starget) = ioc->spi_data.maxBusWidth;
|
2006-03-01 23:02:49 +08:00
|
|
|
}
|
2007-09-15 08:49:03 +08:00
|
|
|
spi_max_offset(starget) = ioc->spi_data.maxSyncOffset;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
spi_offset(starget) = 0;
|
2008-05-21 03:31:11 +08:00
|
|
|
spi_period(starget) = 0xFF;
|
2006-03-01 23:02:49 +08:00
|
|
|
mptspi_write_width(starget, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-27 13:59:46 +08:00
|
|
|
static void
|
2007-01-30 00:42:20 +08:00
|
|
|
mptspi_target_destroy(struct scsi_target *starget)
|
|
|
|
{
|
|
|
|
if (starget->hostdata)
|
|
|
|
kfree(starget->hostdata);
|
|
|
|
starget->hostdata = NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-30 00:44:06 +08:00
|
|
|
/**
|
|
|
|
* mptspi_print_write_nego - negotiation parameters debug info that is being sent
|
|
|
|
* @hd: Pointer to a SCSI HOST structure
|
|
|
|
* @starget: SCSI target
|
|
|
|
* @ii: negotiation parameters
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
mptspi_print_write_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii)
|
|
|
|
{
|
2007-07-24 18:17:41 +08:00
|
|
|
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d Requested = 0x%08x"
|
2007-01-30 00:44:06 +08:00
|
|
|
" ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n",
|
|
|
|
hd->ioc->name, starget->id, ii,
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "",
|
|
|
|
((ii >> 8) & 0xFF), ((ii >> 16) & 0xFF),
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_IU ? "IU ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_DT ? "DT ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_QAS ? "QAS ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_HOLD_MCS ? "HOLDMCS ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_WR_FLOW ? "WRFLOW ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_RD_STRM ? "RDSTRM ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_RTI ? "RTI ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_PCOMP_EN ? "PCOMP ": ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mptspi_print_read_nego - negotiation parameters debug info that is being read
|
|
|
|
* @hd: Pointer to a SCSI HOST structure
|
|
|
|
* @starget: SCSI target
|
|
|
|
* @ii: negotiation parameters
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
mptspi_print_read_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii)
|
|
|
|
{
|
2007-07-24 18:17:41 +08:00
|
|
|
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d Read = 0x%08x"
|
2007-01-30 00:44:06 +08:00
|
|
|
" ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n",
|
|
|
|
hd->ioc->name, starget->id, ii,
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "",
|
|
|
|
((ii >> 8) & 0xFF), ((ii >> 16) & 0xFF),
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_IU ? "IU ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_DT ? "DT ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_QAS ? "QAS ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_HOLD_MCS ? "HOLDMCS ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_WR_FLOW ? "WRFLOW ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_RD_STRM ? "RDSTRM ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_RTI ? "RTI ": "",
|
|
|
|
ii & MPI_SCSIDEVPAGE0_NP_PCOMP_EN ? "PCOMP ": ""));
|
|
|
|
}
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
static int mptspi_read_spi_device_pg0(struct scsi_target *starget,
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(shost);
|
2006-03-01 23:02:49 +08:00
|
|
|
struct _MPT_ADAPTER *ioc = hd->ioc;
|
2007-09-30 00:16:28 +08:00
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_0 *spi_dev_pg0;
|
|
|
|
dma_addr_t spi_dev_pg0_dma;
|
2006-03-01 23:02:49 +08:00
|
|
|
int size;
|
|
|
|
struct _x_config_parms cfg;
|
|
|
|
struct _CONFIG_PAGE_HEADER hdr;
|
|
|
|
int err = -EBUSY;
|
|
|
|
|
|
|
|
/* No SPI parameters for RAID devices */
|
|
|
|
if (starget->channel == 0 &&
|
2007-01-30 00:42:20 +08:00
|
|
|
mptspi_is_raid(hd, starget->id))
|
2006-03-01 23:02:49 +08:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
size = ioc->spi_data.sdp0length * 4;
|
|
|
|
/*
|
|
|
|
if (ioc->spi_data.sdp0length & 1)
|
|
|
|
size += size + 4;
|
|
|
|
size += 2048;
|
|
|
|
*/
|
|
|
|
|
2007-09-30 00:16:28 +08:00
|
|
|
spi_dev_pg0 = dma_alloc_coherent(&ioc->pcidev->dev, size, &spi_dev_pg0_dma, GFP_KERNEL);
|
|
|
|
if (spi_dev_pg0 == NULL) {
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, starget, MYIOC_s_FMT
|
2007-09-15 08:46:51 +08:00
|
|
|
"dma_alloc_coherent for parameters failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
|
|
|
|
hdr.PageVersion = ioc->spi_data.sdp0version;
|
|
|
|
hdr.PageLength = ioc->spi_data.sdp0length;
|
|
|
|
hdr.PageNumber = 0;
|
|
|
|
hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
|
|
|
|
|
|
|
|
memset(&cfg, 0, sizeof(cfg));
|
|
|
|
|
|
|
|
cfg.cfghdr.hdr = &hdr;
|
2007-09-30 00:16:28 +08:00
|
|
|
cfg.physAddr = spi_dev_pg0_dma;
|
2006-03-01 23:02:49 +08:00
|
|
|
cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
cfg.dir = 0;
|
|
|
|
cfg.pageAddr = starget->id;
|
2010-03-18 21:51:34 +08:00
|
|
|
cfg.timeout = 60;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
if (mpt_config(ioc, &cfg)) {
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, starget, MYIOC_s_FMT "mpt_config failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
err = 0;
|
2007-09-30 00:16:28 +08:00
|
|
|
memcpy(pass_pg0, spi_dev_pg0, size);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-09-30 00:16:28 +08:00
|
|
|
mptspi_print_read_nego(hd, starget, le32_to_cpu(spi_dev_pg0->NegotiatedParameters));
|
2007-01-30 00:44:06 +08:00
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
out_free:
|
2007-09-30 00:16:28 +08:00
|
|
|
dma_free_coherent(&ioc->pcidev->dev, size, spi_dev_pg0, spi_dev_pg0_dma);
|
2006-03-01 23:02:49 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 mptspi_getRP(struct scsi_target *starget)
|
|
|
|
{
|
|
|
|
u32 nego = 0;
|
|
|
|
|
|
|
|
nego |= spi_iu(starget) ? MPI_SCSIDEVPAGE1_RP_IU : 0;
|
|
|
|
nego |= spi_dt(starget) ? MPI_SCSIDEVPAGE1_RP_DT : 0;
|
|
|
|
nego |= spi_qas(starget) ? MPI_SCSIDEVPAGE1_RP_QAS : 0;
|
|
|
|
nego |= spi_hold_mcs(starget) ? MPI_SCSIDEVPAGE1_RP_HOLD_MCS : 0;
|
|
|
|
nego |= spi_wr_flow(starget) ? MPI_SCSIDEVPAGE1_RP_WR_FLOW : 0;
|
|
|
|
nego |= spi_rd_strm(starget) ? MPI_SCSIDEVPAGE1_RP_RD_STRM : 0;
|
|
|
|
nego |= spi_rti(starget) ? MPI_SCSIDEVPAGE1_RP_RTI : 0;
|
|
|
|
nego |= spi_pcomp_en(starget) ? MPI_SCSIDEVPAGE1_RP_PCOMP_EN : 0;
|
|
|
|
|
|
|
|
nego |= (spi_period(starget) << MPI_SCSIDEVPAGE1_RP_SHIFT_MIN_SYNC_PERIOD) & MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK;
|
|
|
|
nego |= (spi_offset(starget) << MPI_SCSIDEVPAGE1_RP_SHIFT_MAX_SYNC_OFFSET) & MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK;
|
|
|
|
nego |= spi_width(starget) ? MPI_SCSIDEVPAGE1_RP_WIDE : 0;
|
|
|
|
|
|
|
|
return nego;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_read_parameters(struct scsi_target *starget)
|
|
|
|
{
|
|
|
|
int nego;
|
2007-09-30 00:16:28 +08:00
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_0 spi_dev_pg0;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-09-30 00:16:28 +08:00
|
|
|
mptspi_read_spi_device_pg0(starget, &spi_dev_pg0);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-09-30 00:16:28 +08:00
|
|
|
nego = le32_to_cpu(spi_dev_pg0.NegotiatedParameters);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
spi_iu(starget) = (nego & MPI_SCSIDEVPAGE0_NP_IU) ? 1 : 0;
|
|
|
|
spi_dt(starget) = (nego & MPI_SCSIDEVPAGE0_NP_DT) ? 1 : 0;
|
|
|
|
spi_qas(starget) = (nego & MPI_SCSIDEVPAGE0_NP_QAS) ? 1 : 0;
|
|
|
|
spi_wr_flow(starget) = (nego & MPI_SCSIDEVPAGE0_NP_WR_FLOW) ? 1 : 0;
|
|
|
|
spi_rd_strm(starget) = (nego & MPI_SCSIDEVPAGE0_NP_RD_STRM) ? 1 : 0;
|
|
|
|
spi_rti(starget) = (nego & MPI_SCSIDEVPAGE0_NP_RTI) ? 1 : 0;
|
|
|
|
spi_pcomp_en(starget) = (nego & MPI_SCSIDEVPAGE0_NP_PCOMP_EN) ? 1 : 0;
|
|
|
|
spi_hold_mcs(starget) = (nego & MPI_SCSIDEVPAGE0_NP_HOLD_MCS) ? 1 : 0;
|
|
|
|
spi_period(starget) = (nego & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK) >> MPI_SCSIDEVPAGE0_NP_SHIFT_SYNC_PERIOD;
|
|
|
|
spi_offset(starget) = (nego & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) >> MPI_SCSIDEVPAGE0_NP_SHIFT_SYNC_OFFSET;
|
|
|
|
spi_width(starget) = (nego & MPI_SCSIDEVPAGE0_NP_WIDE) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2009-05-29 19:14:06 +08:00
|
|
|
int
|
2007-01-30 00:42:20 +08:00
|
|
|
mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
|
2006-03-01 23:02:49 +08:00
|
|
|
{
|
2009-05-29 19:14:06 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2006-03-01 23:02:49 +08:00
|
|
|
MpiRaidActionRequest_t *pReq;
|
|
|
|
MPT_FRAME_HDR *mf;
|
2009-05-29 19:14:06 +08:00
|
|
|
int ret;
|
|
|
|
unsigned long timeleft;
|
|
|
|
|
|
|
|
mutex_lock(&ioc->internal_cmds.mutex);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
/* Get and Populate a free Frame
|
|
|
|
*/
|
2007-09-15 08:49:03 +08:00
|
|
|
if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
|
2009-05-29 19:14:06 +08:00
|
|
|
dfailprintk(hd->ioc, printk(MYIOC_s_WARN_FMT
|
|
|
|
"%s: no msg frames!\n", ioc->name, __func__));
|
|
|
|
ret = -EAGAIN;
|
|
|
|
goto out;
|
2006-03-01 23:02:49 +08:00
|
|
|
}
|
|
|
|
pReq = (MpiRaidActionRequest_t *)mf;
|
|
|
|
if (quiesce)
|
|
|
|
pReq->Action = MPI_RAID_ACTION_QUIESCE_PHYS_IO;
|
|
|
|
else
|
|
|
|
pReq->Action = MPI_RAID_ACTION_ENABLE_PHYS_IO;
|
|
|
|
pReq->Reserved1 = 0;
|
|
|
|
pReq->ChainOffset = 0;
|
|
|
|
pReq->Function = MPI_FUNCTION_RAID_ACTION;
|
2007-01-30 00:42:20 +08:00
|
|
|
pReq->VolumeID = id;
|
|
|
|
pReq->VolumeBus = channel;
|
2006-03-01 23:02:49 +08:00
|
|
|
pReq->PhysDiskNum = 0;
|
|
|
|
pReq->MsgFlags = 0;
|
|
|
|
pReq->Reserved2 = 0;
|
|
|
|
pReq->ActionDataWord = 0; /* Reserved for this action */
|
|
|
|
|
2009-05-29 19:07:04 +08:00
|
|
|
ioc->add_sge((char *)&pReq->ActionDataSGE,
|
2006-03-01 23:02:49 +08:00
|
|
|
MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n",
|
|
|
|
ioc->name, pReq->Action, channel, id));
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2009-05-29 19:14:06 +08:00
|
|
|
INITIALIZE_MGMT_STATUS(ioc->internal_cmds.status)
|
2007-09-15 08:49:03 +08:00
|
|
|
mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
|
2009-05-29 19:14:06 +08:00
|
|
|
timeleft = wait_for_completion_timeout(&ioc->internal_cmds.done, 10*HZ);
|
|
|
|
if (!(ioc->internal_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
|
|
|
|
ret = -ETIME;
|
|
|
|
dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: TIMED OUT!\n",
|
|
|
|
ioc->name, __func__));
|
|
|
|
if (ioc->internal_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET)
|
|
|
|
goto out;
|
|
|
|
if (!timeleft) {
|
|
|
|
printk(MYIOC_s_WARN_FMT "Issuing Reset from %s!!\n",
|
|
|
|
ioc->name, __func__);
|
|
|
|
mpt_HardResetHandler(ioc, CAN_SLEEP);
|
|
|
|
mpt_free_msg_frame(ioc, mf);
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
}
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2009-05-29 19:14:06 +08:00
|
|
|
ret = ioc->internal_cmds.completion_code;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2009-05-29 19:14:06 +08:00
|
|
|
out:
|
|
|
|
CLEAR_MGMT_STATUS(ioc->internal_cmds.status)
|
|
|
|
mutex_unlock(&ioc->internal_cmds.mutex);
|
|
|
|
return ret;
|
2006-03-01 23:02:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
|
|
|
|
struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
VirtTarget *vtarget = scsi_target(sdev)->hostdata;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
/* no DV on RAID devices */
|
|
|
|
if (sdev->channel == 0 &&
|
2007-01-30 00:42:20 +08:00
|
|
|
mptspi_is_raid(hd, sdev->id))
|
2006-03-01 23:02:49 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If this is a piece of a RAID, then quiesce first */
|
|
|
|
if (sdev->channel == 1 &&
|
2007-01-30 00:42:20 +08:00
|
|
|
mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) {
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT
|
2007-09-15 08:49:03 +08:00
|
|
|
"Integrated RAID quiesce failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-08 07:51:40 +08:00
|
|
|
hd->spi_pending |= (1 << sdev->id);
|
2006-03-01 23:02:49 +08:00
|
|
|
spi_dv_device(sdev);
|
2007-02-08 07:51:40 +08:00
|
|
|
hd->spi_pending &= ~(1 << sdev->id);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
if (sdev->channel == 1 &&
|
2007-01-30 00:42:20 +08:00
|
|
|
mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0)
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT
|
2007-09-15 08:49:03 +08:00
|
|
|
"Integrated RAID resume failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
mptspi_read_parameters(sdev->sdev_target);
|
|
|
|
spi_display_xfer_agreement(sdev->sdev_target);
|
|
|
|
mptspi_read_parameters(sdev->sdev_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mptspi_slave_alloc(struct scsi_device *sdev)
|
|
|
|
{
|
2007-09-30 00:15:59 +08:00
|
|
|
MPT_SCSI_HOST *hd = shost_priv(sdev->host);
|
2007-01-30 00:42:20 +08:00
|
|
|
VirtTarget *vtarget;
|
2007-09-15 08:48:19 +08:00
|
|
|
VirtDevice *vdevice;
|
2007-01-30 00:42:20 +08:00
|
|
|
struct scsi_target *starget;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
if (sdev->channel == 1 &&
|
2007-09-15 08:49:03 +08:00
|
|
|
mptscsih_is_phys_disk(ioc, 0, sdev->id) == 0)
|
2007-01-30 00:42:20 +08:00
|
|
|
return -ENXIO;
|
|
|
|
|
2007-09-15 08:48:19 +08:00
|
|
|
vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
|
|
|
|
if (!vdevice) {
|
2007-01-30 00:42:20 +08:00
|
|
|
printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
|
2007-09-15 08:49:03 +08:00
|
|
|
ioc->name, sizeof(VirtDevice));
|
2007-01-30 00:42:20 +08:00
|
|
|
return -ENOMEM;
|
2006-03-01 23:02:49 +08:00
|
|
|
}
|
|
|
|
|
2007-09-15 08:48:19 +08:00
|
|
|
vdevice->lun = sdev->lun;
|
|
|
|
sdev->hostdata = vdevice;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
starget = scsi_target(sdev);
|
|
|
|
vtarget = starget->hostdata;
|
2007-09-15 08:48:19 +08:00
|
|
|
vdevice->vtarget = vtarget;
|
2007-01-30 00:42:20 +08:00
|
|
|
vtarget->num_luns++;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
if (sdev->channel == 1)
|
2006-03-01 23:02:49 +08:00
|
|
|
sdev->no_uld_attach = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mptspi_slave_configure(struct scsi_device *sdev)
|
|
|
|
{
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(sdev->host);
|
2007-01-30 00:43:17 +08:00
|
|
|
VirtTarget *vtarget = scsi_target(sdev)->hostdata;
|
2007-05-08 03:59:46 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
mptspi_initTarget(hd, vtarget, sdev);
|
|
|
|
|
|
|
|
ret = mptscsih_slave_configure(sdev);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2007-07-24 18:17:41 +08:00
|
|
|
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d min_period=0x%02x"
|
2007-01-30 00:44:06 +08:00
|
|
|
" max_offset=0x%02x max_width=%d\n", hd->ioc->name,
|
|
|
|
sdev->id, spi_min_period(scsi_target(sdev)),
|
|
|
|
spi_max_offset(scsi_target(sdev)),
|
|
|
|
spi_max_width(scsi_target(sdev))));
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
if ((sdev->channel == 1 ||
|
2007-01-30 00:42:20 +08:00
|
|
|
!(mptspi_is_raid(hd, sdev->id))) &&
|
2006-03-01 23:02:49 +08:00
|
|
|
!spi_initial_dv(sdev->sdev_target))
|
|
|
|
mptspi_dv_device(hd, sdev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
static int
|
2010-11-16 15:10:29 +08:00
|
|
|
mptspi_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
|
2007-01-30 00:42:20 +08:00
|
|
|
{
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host);
|
2007-09-15 08:48:19 +08:00
|
|
|
VirtDevice *vdevice = SCpnt->device->hostdata;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2007-01-30 00:42:20 +08:00
|
|
|
|
2007-09-15 08:48:19 +08:00
|
|
|
if (!vdevice || !vdevice->vtarget) {
|
2007-01-30 00:42:20 +08:00
|
|
|
SCpnt->result = DID_NO_CONNECT << 16;
|
|
|
|
done(SCpnt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SCpnt->device->channel == 1 &&
|
2007-09-15 08:49:03 +08:00
|
|
|
mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) {
|
2007-01-30 00:42:20 +08:00
|
|
|
SCpnt->result = DID_NO_CONNECT << 16;
|
|
|
|
done(SCpnt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-30 00:44:06 +08:00
|
|
|
if (spi_dv_pending(scsi_target(SCpnt->device)))
|
2007-09-15 08:49:03 +08:00
|
|
|
ddvprintk(ioc, scsi_print_command(SCpnt));
|
2007-01-30 00:44:06 +08:00
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
return mptscsih_qcmd(SCpnt,done);
|
|
|
|
}
|
|
|
|
|
2010-11-16 15:10:29 +08:00
|
|
|
static DEF_SCSI_QCMD(mptspi_qcmd)
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
static void mptspi_slave_destroy(struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
struct scsi_target *starget = scsi_target(sdev);
|
|
|
|
VirtTarget *vtarget = starget->hostdata;
|
|
|
|
VirtDevice *vdevice = sdev->hostdata;
|
|
|
|
|
|
|
|
/* Will this be the last lun on a non-raid device? */
|
|
|
|
if (vtarget->num_luns == 1 && vdevice->configured_lun) {
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
|
|
|
|
/* Async Narrow */
|
|
|
|
pg1.RequestedParameters = 0;
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mptscsih_slave_destroy(sdev);
|
|
|
|
}
|
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
static struct scsi_host_template mptspi_driver_template = {
|
2005-11-17 09:54:14 +08:00
|
|
|
.module = THIS_MODULE,
|
2005-04-23 06:02:25 +08:00
|
|
|
.proc_name = "mptspi",
|
|
|
|
.proc_info = mptscsih_proc_info,
|
|
|
|
.name = "MPT SPI Host",
|
|
|
|
.info = mptscsih_info,
|
2007-01-30 00:42:20 +08:00
|
|
|
.queuecommand = mptspi_qcmd,
|
2006-03-01 23:02:49 +08:00
|
|
|
.target_alloc = mptspi_target_alloc,
|
|
|
|
.slave_alloc = mptspi_slave_alloc,
|
|
|
|
.slave_configure = mptspi_slave_configure,
|
2007-01-30 00:42:20 +08:00
|
|
|
.target_destroy = mptspi_target_destroy,
|
2006-03-01 23:02:49 +08:00
|
|
|
.slave_destroy = mptspi_slave_destroy,
|
2005-06-25 02:18:57 +08:00
|
|
|
.change_queue_depth = mptscsih_change_queue_depth,
|
2005-04-23 06:02:25 +08:00
|
|
|
.eh_abort_handler = mptscsih_abort,
|
|
|
|
.eh_device_reset_handler = mptscsih_dev_reset,
|
|
|
|
.eh_bus_reset_handler = mptscsih_bus_reset,
|
|
|
|
.eh_host_reset_handler = mptscsih_host_reset,
|
|
|
|
.bios_param = mptscsih_bios_param,
|
|
|
|
.can_queue = MPT_SCSI_CAN_QUEUE,
|
|
|
|
.this_id = -1,
|
|
|
|
.sg_tablesize = MPT_SCSI_SG_DEPTH,
|
|
|
|
.max_sectors = 8192,
|
|
|
|
.cmd_per_lun = 7,
|
|
|
|
.use_clustering = ENABLE_CLUSTERING,
|
2007-07-17 17:09:14 +08:00
|
|
|
.shost_attrs = mptscsih_host_attrs,
|
2005-04-23 06:02:25 +08:00
|
|
|
};
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
static int mptspi_write_spi_device_pg1(struct scsi_target *starget,
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(shost);
|
2006-03-01 23:02:49 +08:00
|
|
|
struct _MPT_ADAPTER *ioc = hd->ioc;
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1;
|
|
|
|
dma_addr_t pg1_dma;
|
|
|
|
int size;
|
|
|
|
struct _x_config_parms cfg;
|
|
|
|
struct _CONFIG_PAGE_HEADER hdr;
|
|
|
|
int err = -EBUSY;
|
2011-04-26 14:39:46 +08:00
|
|
|
u32 nego_parms;
|
|
|
|
u32 period;
|
|
|
|
struct scsi_device *sdev;
|
|
|
|
int i;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
/* don't allow updating nego parameters on RAID devices */
|
|
|
|
if (starget->channel == 0 &&
|
2007-01-30 00:42:20 +08:00
|
|
|
mptspi_is_raid(hd, starget->id))
|
2006-03-01 23:02:49 +08:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
size = ioc->spi_data.sdp1length * 4;
|
|
|
|
|
|
|
|
pg1 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg1_dma, GFP_KERNEL);
|
|
|
|
if (pg1 == NULL) {
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, starget, MYIOC_s_FMT
|
2007-09-15 08:46:51 +08:00
|
|
|
"dma_alloc_coherent for parameters failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
|
|
|
|
hdr.PageVersion = ioc->spi_data.sdp1version;
|
|
|
|
hdr.PageLength = ioc->spi_data.sdp1length;
|
|
|
|
hdr.PageNumber = 1;
|
|
|
|
hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
|
|
|
|
|
|
|
|
memset(&cfg, 0, sizeof(cfg));
|
|
|
|
|
|
|
|
cfg.cfghdr.hdr = &hdr;
|
|
|
|
cfg.physAddr = pg1_dma;
|
|
|
|
cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
|
|
|
|
cfg.dir = 1;
|
|
|
|
cfg.pageAddr = starget->id;
|
|
|
|
|
|
|
|
memcpy(pg1, pass_pg1, size);
|
|
|
|
|
|
|
|
pg1->Header.PageVersion = hdr.PageVersion;
|
|
|
|
pg1->Header.PageLength = hdr.PageLength;
|
|
|
|
pg1->Header.PageNumber = hdr.PageNumber;
|
|
|
|
pg1->Header.PageType = hdr.PageType;
|
|
|
|
|
2011-04-26 14:39:46 +08:00
|
|
|
nego_parms = le32_to_cpu(pg1->RequestedParameters);
|
|
|
|
period = (nego_parms & MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK) >>
|
|
|
|
MPI_SCSIDEVPAGE1_RP_SHIFT_MIN_SYNC_PERIOD;
|
|
|
|
if (period == 8) {
|
|
|
|
/* Turn on inline data padding for TAPE when running U320 */
|
|
|
|
for (i = 0 ; i < 16; i++) {
|
|
|
|
sdev = scsi_device_lookup_by_target(starget, i);
|
|
|
|
if (sdev && sdev->type == TYPE_TAPE) {
|
|
|
|
sdev_printk(KERN_DEBUG, sdev, MYIOC_s_FMT
|
|
|
|
"IDP:ON\n", ioc->name);
|
|
|
|
nego_parms |= MPI_SCSIDEVPAGE1_RP_IDP;
|
|
|
|
pg1->RequestedParameters =
|
|
|
|
cpu_to_le32(nego_parms);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 00:44:06 +08:00
|
|
|
mptspi_print_write_nego(hd, starget, le32_to_cpu(pg1->RequestedParameters));
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
if (mpt_config(ioc, &cfg)) {
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_ERR, starget, MYIOC_s_FMT
|
2007-09-15 08:46:51 +08:00
|
|
|
"mpt_config failed\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
err = 0;
|
|
|
|
|
|
|
|
out_free:
|
|
|
|
dma_free_coherent(&ioc->pcidev->dev, size, pg1, pg1_dma);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_write_offset(struct scsi_target *starget, int offset)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if (offset < 0)
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
if (offset > 255)
|
|
|
|
offset = 255;
|
|
|
|
|
|
|
|
if (spi_offset(starget) == -1)
|
|
|
|
mptspi_read_parameters(starget);
|
|
|
|
|
|
|
|
spi_offset(starget) = offset;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_write_period(struct scsi_target *starget, int period)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if (period < 8)
|
|
|
|
period = 8;
|
|
|
|
|
|
|
|
if (period > 255)
|
|
|
|
period = 255;
|
|
|
|
|
|
|
|
if (spi_period(starget) == -1)
|
|
|
|
mptspi_read_parameters(starget);
|
|
|
|
|
|
|
|
if (period == 8) {
|
|
|
|
spi_iu(starget) = 1;
|
|
|
|
spi_dt(starget) = 1;
|
|
|
|
} else if (period == 9) {
|
|
|
|
spi_dt(starget) = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
spi_period(starget) = period;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_write_dt(struct scsi_target *starget, int dt)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if (spi_period(starget) == -1)
|
|
|
|
mptspi_read_parameters(starget);
|
|
|
|
|
|
|
|
if (!dt && spi_period(starget) < 10)
|
|
|
|
spi_period(starget) = 10;
|
|
|
|
|
|
|
|
spi_dt(starget) = dt;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_write_iu(struct scsi_target *starget, int iu)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if (spi_period(starget) == -1)
|
|
|
|
mptspi_read_parameters(starget);
|
|
|
|
|
|
|
|
if (!iu && spi_period(starget) < 9)
|
|
|
|
spi_period(starget) = 9;
|
|
|
|
|
|
|
|
spi_iu(starget) = iu;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MPTSPI_SIMPLE_TRANSPORT_PARM(parm) \
|
|
|
|
static void mptspi_write_##parm(struct scsi_target *starget, int parm)\
|
|
|
|
{ \
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; \
|
|
|
|
u32 nego; \
|
|
|
|
\
|
|
|
|
spi_##parm(starget) = parm; \
|
|
|
|
\
|
|
|
|
nego = mptspi_getRP(starget); \
|
|
|
|
\
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego); \
|
|
|
|
pg1.Reserved = 0; \
|
|
|
|
pg1.Configuration = 0; \
|
|
|
|
\
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1); \
|
|
|
|
}
|
|
|
|
|
|
|
|
MPTSPI_SIMPLE_TRANSPORT_PARM(rd_strm)
|
|
|
|
MPTSPI_SIMPLE_TRANSPORT_PARM(wr_flow)
|
|
|
|
MPTSPI_SIMPLE_TRANSPORT_PARM(rti)
|
|
|
|
MPTSPI_SIMPLE_TRANSPORT_PARM(hold_mcs)
|
|
|
|
MPTSPI_SIMPLE_TRANSPORT_PARM(pcomp_en)
|
|
|
|
|
|
|
|
static void mptspi_write_qas(struct scsi_target *starget, int qas)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(shost);
|
2006-03-01 23:02:49 +08:00
|
|
|
VirtTarget *vtarget = starget->hostdata;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if ((vtarget->negoFlags & MPT_TARGET_NO_NEGO_QAS) ||
|
|
|
|
hd->ioc->spi_data.noQas)
|
|
|
|
spi_qas(starget) = 0;
|
|
|
|
else
|
|
|
|
spi_qas(starget) = qas;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mptspi_write_width(struct scsi_target *starget, int width)
|
|
|
|
{
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
|
|
|
|
|
|
|
if (!width) {
|
|
|
|
spi_dt(starget) = 0;
|
|
|
|
if (spi_period(starget) < 10)
|
|
|
|
spi_period(starget) = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
spi_width(starget) = width;
|
|
|
|
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct work_queue_wrapper {
|
|
|
|
struct work_struct work;
|
|
|
|
struct _MPT_SCSI_HOST *hd;
|
|
|
|
int disk;
|
|
|
|
};
|
|
|
|
|
2006-11-22 22:57:56 +08:00
|
|
|
static void mpt_work_wrapper(struct work_struct *work)
|
2006-03-01 23:02:49 +08:00
|
|
|
{
|
2006-11-22 22:57:56 +08:00
|
|
|
struct work_queue_wrapper *wqw =
|
|
|
|
container_of(work, struct work_queue_wrapper, work);
|
2006-03-01 23:02:49 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = wqw->hd;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
|
|
|
struct Scsi_Host *shost = ioc->sh;
|
2006-03-01 23:02:49 +08:00
|
|
|
struct scsi_device *sdev;
|
|
|
|
int disk = wqw->disk;
|
|
|
|
struct _CONFIG_PAGE_IOC_3 *pg3;
|
|
|
|
|
|
|
|
kfree(wqw);
|
|
|
|
|
2007-09-15 08:49:03 +08:00
|
|
|
mpt_findImVolumes(ioc);
|
|
|
|
pg3 = ioc->raid_data.pIocPg3;
|
2006-03-01 23:02:49 +08:00
|
|
|
if (!pg3)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shost_for_each_device(sdev,shost) {
|
|
|
|
struct scsi_target *starget = scsi_target(sdev);
|
|
|
|
VirtTarget *vtarget = starget->hostdata;
|
|
|
|
|
|
|
|
/* only want to search RAID components */
|
|
|
|
if (sdev->channel != 1)
|
|
|
|
continue;
|
|
|
|
|
2007-01-30 00:42:20 +08:00
|
|
|
/* The id is the raid PhysDiskNum, even if
|
2006-03-01 23:02:49 +08:00
|
|
|
* starget->id is the actual target address */
|
2007-01-30 00:42:20 +08:00
|
|
|
if(vtarget->id != disk)
|
2006-03-01 23:02:49 +08:00
|
|
|
continue;
|
|
|
|
|
2007-09-30 00:17:21 +08:00
|
|
|
starget_printk(KERN_INFO, vtarget->starget, MYIOC_s_FMT
|
2007-09-15 08:49:03 +08:00
|
|
|
"Integrated RAID requests DV of new device\n", ioc->name);
|
2006-03-01 23:02:49 +08:00
|
|
|
mptspi_dv_device(hd, sdev);
|
|
|
|
}
|
2007-09-30 00:17:21 +08:00
|
|
|
shost_printk(KERN_INFO, shost, MYIOC_s_FMT
|
2007-09-15 08:49:03 +08:00
|
|
|
"Integrated RAID detects new device %d\n", ioc->name, disk);
|
|
|
|
scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1);
|
2006-03-01 23:02:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
|
|
|
|
{
|
|
|
|
struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC);
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2006-03-01 23:02:49 +08:00
|
|
|
|
|
|
|
if (!wqw) {
|
2007-09-30 00:17:21 +08:00
|
|
|
shost_printk(KERN_ERR, ioc->sh, MYIOC_s_FMT
|
2007-09-15 08:46:51 +08:00
|
|
|
"Failed to act on RAID event for physical disk %d\n",
|
2007-09-15 08:49:03 +08:00
|
|
|
ioc->name, disk);
|
2006-03-01 23:02:49 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-11-22 22:57:56 +08:00
|
|
|
INIT_WORK(&wqw->work, mpt_work_wrapper);
|
2006-03-01 23:02:49 +08:00
|
|
|
wqw->hd = hd;
|
|
|
|
wqw->disk = disk;
|
|
|
|
|
|
|
|
schedule_work(&wqw->work);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
|
|
|
|
{
|
|
|
|
u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
|
2006-03-01 23:02:49 +08:00
|
|
|
|
2010-03-18 21:50:38 +08:00
|
|
|
if (ioc->bus_type != SPI)
|
|
|
|
return 0;
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
if (hd && event == MPI_EVENT_INTEGRATED_RAID) {
|
|
|
|
int reason
|
|
|
|
= (le32_to_cpu(pEvReply->Data[0]) & 0x00FF0000) >> 16;
|
|
|
|
|
|
|
|
if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
|
|
|
|
int disk = (le32_to_cpu(pEvReply->Data[0]) & 0xFF000000) >> 24;
|
|
|
|
mpt_dv_raid(hd, disk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mptscsih_event_process(ioc, pEvReply);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mptspi_deny_binding(struct scsi_target *starget)
|
|
|
|
{
|
|
|
|
struct _MPT_SCSI_HOST *hd =
|
|
|
|
(struct _MPT_SCSI_HOST *)dev_to_shost(starget->dev.parent)->hostdata;
|
2007-01-30 00:42:20 +08:00
|
|
|
return ((mptspi_is_raid(hd, starget->id)) &&
|
2006-03-01 23:02:49 +08:00
|
|
|
starget->channel == 0) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct spi_function_template mptspi_transport_functions = {
|
|
|
|
.get_offset = mptspi_read_parameters,
|
|
|
|
.set_offset = mptspi_write_offset,
|
|
|
|
.show_offset = 1,
|
|
|
|
.get_period = mptspi_read_parameters,
|
|
|
|
.set_period = mptspi_write_period,
|
|
|
|
.show_period = 1,
|
|
|
|
.get_width = mptspi_read_parameters,
|
|
|
|
.set_width = mptspi_write_width,
|
|
|
|
.show_width = 1,
|
|
|
|
.get_iu = mptspi_read_parameters,
|
|
|
|
.set_iu = mptspi_write_iu,
|
|
|
|
.show_iu = 1,
|
|
|
|
.get_dt = mptspi_read_parameters,
|
|
|
|
.set_dt = mptspi_write_dt,
|
|
|
|
.show_dt = 1,
|
|
|
|
.get_qas = mptspi_read_parameters,
|
|
|
|
.set_qas = mptspi_write_qas,
|
|
|
|
.show_qas = 1,
|
|
|
|
.get_wr_flow = mptspi_read_parameters,
|
|
|
|
.set_wr_flow = mptspi_write_wr_flow,
|
|
|
|
.show_wr_flow = 1,
|
|
|
|
.get_rd_strm = mptspi_read_parameters,
|
|
|
|
.set_rd_strm = mptspi_write_rd_strm,
|
|
|
|
.show_rd_strm = 1,
|
|
|
|
.get_rti = mptspi_read_parameters,
|
|
|
|
.set_rti = mptspi_write_rti,
|
|
|
|
.show_rti = 1,
|
|
|
|
.get_pcomp_en = mptspi_read_parameters,
|
|
|
|
.set_pcomp_en = mptspi_write_pcomp_en,
|
|
|
|
.show_pcomp_en = 1,
|
|
|
|
.get_hold_mcs = mptspi_read_parameters,
|
|
|
|
.set_hold_mcs = mptspi_write_hold_mcs,
|
|
|
|
.show_hold_mcs = 1,
|
|
|
|
.deny_binding = mptspi_deny_binding,
|
|
|
|
};
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Supported hardware
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct pci_device_id mptspi_pci_table[] = {
|
2006-06-28 06:09:26 +08:00
|
|
|
{ PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030,
|
2005-04-23 06:02:25 +08:00
|
|
|
PCI_ANY_ID, PCI_ANY_ID },
|
2007-08-15 07:28:27 +08:00
|
|
|
{ PCI_VENDOR_ID_ATTO, MPI_MANUFACTPAGE_DEVID_53C1030,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID },
|
2006-06-28 06:09:26 +08:00
|
|
|
{ PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035,
|
2005-04-23 06:02:25 +08:00
|
|
|
PCI_ANY_ID, PCI_ANY_ID },
|
|
|
|
{0} /* Terminating entry */
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, mptspi_pci_table);
|
|
|
|
|
2006-04-26 07:38:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* renegotiate for a given target
|
|
|
|
*/
|
|
|
|
static void
|
2006-11-22 22:57:56 +08:00
|
|
|
mptspi_dv_renegotiate_work(struct work_struct *work)
|
2006-04-26 07:38:58 +08:00
|
|
|
{
|
2006-11-22 22:57:56 +08:00
|
|
|
struct work_queue_wrapper *wqw =
|
|
|
|
container_of(work, struct work_queue_wrapper, work);
|
2006-04-26 07:38:58 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = wqw->hd;
|
|
|
|
struct scsi_device *sdev;
|
2007-02-08 07:51:40 +08:00
|
|
|
struct scsi_target *starget;
|
|
|
|
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
|
|
|
|
u32 nego;
|
2007-09-15 08:49:03 +08:00
|
|
|
MPT_ADAPTER *ioc = hd->ioc;
|
2006-04-26 07:38:58 +08:00
|
|
|
|
|
|
|
kfree(wqw);
|
|
|
|
|
2007-02-08 07:51:40 +08:00
|
|
|
if (hd->spi_pending) {
|
2007-09-15 08:49:03 +08:00
|
|
|
shost_for_each_device(sdev, ioc->sh) {
|
2007-02-08 07:51:40 +08:00
|
|
|
if (hd->spi_pending & (1 << sdev->id))
|
|
|
|
continue;
|
|
|
|
starget = scsi_target(sdev);
|
|
|
|
nego = mptspi_getRP(starget);
|
|
|
|
pg1.RequestedParameters = cpu_to_le32(nego);
|
|
|
|
pg1.Reserved = 0;
|
|
|
|
pg1.Configuration = 0;
|
|
|
|
mptspi_write_spi_device_pg1(starget, &pg1);
|
|
|
|
}
|
|
|
|
} else {
|
2007-09-15 08:49:03 +08:00
|
|
|
shost_for_each_device(sdev, ioc->sh)
|
2007-02-08 07:51:40 +08:00
|
|
|
mptspi_dv_device(hd, sdev);
|
|
|
|
}
|
2006-04-26 07:38:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd)
|
|
|
|
{
|
|
|
|
struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (!wqw)
|
|
|
|
return;
|
|
|
|
|
2006-11-22 22:57:56 +08:00
|
|
|
INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work);
|
2006-04-26 07:38:58 +08:00
|
|
|
wqw->hd = hd;
|
|
|
|
|
|
|
|
schedule_work(&wqw->work);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* spi module reset handler
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = mptscsih_ioc_reset(ioc, reset_phase);
|
2010-03-18 21:50:38 +08:00
|
|
|
if ((ioc->bus_type != SPI) || (!rc))
|
|
|
|
return rc;
|
2006-04-26 07:38:58 +08:00
|
|
|
|
2008-07-08 00:24:06 +08:00
|
|
|
/* only try to do a renegotiation if we're properly set up
|
|
|
|
* if we get an ioc fault on bringup, ioc->sh will be NULL */
|
|
|
|
if (reset_phase == MPT_IOC_POST_RESET &&
|
|
|
|
ioc->sh) {
|
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
|
|
|
|
|
2006-04-26 07:38:58 +08:00
|
|
|
mptspi_dv_renegotiate(hd);
|
2008-07-08 00:24:06 +08:00
|
|
|
}
|
2006-04-26 07:38:58 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-06-10 08:01:48 +08:00
|
|
|
#ifdef CONFIG_PM
|
2006-04-26 07:38:58 +08:00
|
|
|
/*
|
|
|
|
* spi module resume handler
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mptspi_resume(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
|
2007-09-30 00:15:59 +08:00
|
|
|
struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
|
2006-04-26 07:38:58 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = mptscsih_resume(pdev);
|
|
|
|
mptspi_dv_renegotiate(hd);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2006-06-10 08:01:48 +08:00
|
|
|
#endif
|
2006-04-26 07:38:58 +08:00
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
* mptspi_probe - Installs scsi devices per bus.
|
|
|
|
* @pdev: Pointer to pci_dev structure
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *sh;
|
|
|
|
MPT_SCSI_HOST *hd;
|
|
|
|
MPT_ADAPTER *ioc;
|
|
|
|
unsigned long flags;
|
2006-01-14 01:27:50 +08:00
|
|
|
int ii;
|
2005-04-23 06:02:25 +08:00
|
|
|
int numSGE = 0;
|
|
|
|
int scale;
|
|
|
|
int ioc_cap;
|
|
|
|
int error=0;
|
|
|
|
int r;
|
2005-08-18 22:24:53 +08:00
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
if ((r = mpt_attach(pdev,id)) != 0)
|
|
|
|
return r;
|
2005-08-18 22:24:53 +08:00
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
ioc = pci_get_drvdata(pdev);
|
2005-05-01 06:09:38 +08:00
|
|
|
ioc->DoneCtx = mptspiDoneCtx;
|
|
|
|
ioc->TaskCtx = mptspiTaskCtx;
|
|
|
|
ioc->InternalCtx = mptspiInternalCtx;
|
2005-08-18 22:24:53 +08:00
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
/* Added sanity check on readiness of the MPT adapter.
|
|
|
|
*/
|
|
|
|
if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
|
|
|
|
printk(MYIOC_s_WARN_FMT
|
|
|
|
"Skipping because it's not operational!\n",
|
|
|
|
ioc->name);
|
2005-11-17 09:54:17 +08:00
|
|
|
error = -ENODEV;
|
|
|
|
goto out_mptspi_probe;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ioc->active) {
|
|
|
|
printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
|
|
|
|
ioc->name);
|
2005-11-17 09:54:17 +08:00
|
|
|
error = -ENODEV;
|
|
|
|
goto out_mptspi_probe;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity check - ensure at least 1 port is INITIATOR capable
|
|
|
|
*/
|
|
|
|
ioc_cap = 0;
|
|
|
|
for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
|
|
|
|
if (ioc->pfacts[ii].ProtocolFlags &
|
|
|
|
MPI_PORTFACTS_PROTOCOL_INITIATOR)
|
|
|
|
ioc_cap ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ioc_cap) {
|
|
|
|
printk(MYIOC_s_WARN_FMT
|
|
|
|
"Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n",
|
|
|
|
ioc->name, ioc);
|
[SCSI] fusion SAS support (mptsas driver) updates
Summary of Changes:
* splitting mpt_interrupt per Christophs suggestion
about a month ago
* rename ScsiCfgData to SpiCfgData structure,
then move all the raid related info into
new structure called RaidCfgData. This is
done because SAS supports RAID, as well as SPI,
so the raid stuff should be seperate.
* incorrect timeout calculation for cntdn
inside WaitForDoorbellAck and WaitForDoortbellInt
* add support for interpreting SAS Log Info
* Increase Event Log Size from 0xA to 0x32
* Fix bug in mptsas/mptfc/mptspi - when controller
has Initiator Mode Disabled, and only running in
TargetMode, the mptctl would panic when loading.
The fix is to return 0, instead of -ENODEV, in
SCSI LLD respective probe routines
* Fix bug in mptlan.c - driver will panic if
there is host reset, due to dev being set to
zero in mpt_lan_ioc_reset
* Fix's for SPI - Echo Buffer
* Several fix's in mptscsih_io_done - FCP Response
info, RESIDUAL_MISMATCH, Data Underrun, etc.
* Cleanup Error Handling - EH handlers,
mptscsih_flush_cmds, and zeroing out ScsiLookup
from mptscsih_qcmd
* Cleanup asyn event handling from
mptscsih -> mptscsih_event_process. Also
added support for SAS Persistent Table Full,
an asyn event
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-09-15 08:09:10 +08:00
|
|
|
return 0;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sh = scsi_host_alloc(&mptspi_driver_template, sizeof(MPT_SCSI_HOST));
|
|
|
|
|
|
|
|
if (!sh) {
|
|
|
|
printk(MYIOC_s_WARN_FMT
|
|
|
|
"Unable to register controller with SCSI subsystem\n",
|
|
|
|
ioc->name);
|
2005-11-17 09:54:17 +08:00
|
|
|
error = -1;
|
|
|
|
goto out_mptspi_probe;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ioc->FreeQlock, flags);
|
|
|
|
|
|
|
|
/* Attach the SCSI Host to the IOC structure
|
|
|
|
*/
|
|
|
|
ioc->sh = sh;
|
|
|
|
|
|
|
|
sh->io_port = 0;
|
|
|
|
sh->n_io_port = 0;
|
|
|
|
sh->irq = 0;
|
|
|
|
|
|
|
|
/* set 16 byte cdb's */
|
|
|
|
sh->max_cmd_len = 16;
|
|
|
|
|
|
|
|
/* Yikes! This is important!
|
|
|
|
* Otherwise, by default, linux
|
|
|
|
* only scans target IDs 0-7!
|
|
|
|
* pfactsN->MaxDevices unreliable
|
|
|
|
* (not supported in early
|
|
|
|
* versions of the FW).
|
|
|
|
* max_id = 1 + actual max id,
|
|
|
|
* max_lun = 1 + actual last lun,
|
|
|
|
* see hosts.h :o(
|
|
|
|
*/
|
2007-01-30 00:42:20 +08:00
|
|
|
sh->max_id = ioc->devices_per_bus;
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
sh->max_lun = MPT_LAST_LUN + 1;
|
2006-03-01 23:02:49 +08:00
|
|
|
/*
|
|
|
|
* If RAID Firmware Detected, setup virtual channel
|
|
|
|
*/
|
2007-01-30 00:45:37 +08:00
|
|
|
if (ioc->ir_firmware)
|
2006-03-01 23:02:49 +08:00
|
|
|
sh->max_channel = 1;
|
|
|
|
else
|
|
|
|
sh->max_channel = 0;
|
2005-04-23 06:02:25 +08:00
|
|
|
sh->this_id = ioc->pfacts[0].PortSCSIID;
|
|
|
|
|
|
|
|
/* Required entry.
|
|
|
|
*/
|
|
|
|
sh->unique_id = ioc->id;
|
|
|
|
|
|
|
|
/* Verify that we won't exceed the maximum
|
|
|
|
* number of chain buffers
|
|
|
|
* We can optimize: ZZ = req_sz/sizeof(SGE)
|
|
|
|
* For 32bit SGE's:
|
|
|
|
* numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ
|
|
|
|
* + (req_sz - 64)/sizeof(SGE)
|
|
|
|
* A slightly different algorithm is required for
|
|
|
|
* 64bit SGEs.
|
|
|
|
*/
|
2009-05-29 19:07:04 +08:00
|
|
|
scale = ioc->req_sz/ioc->SGE_size;
|
|
|
|
if (ioc->sg_addr_size == sizeof(u64)) {
|
2005-04-23 06:02:25 +08:00
|
|
|
numSGE = (scale - 1) *
|
|
|
|
(ioc->facts.MaxChainDepth-1) + scale +
|
2009-05-29 19:07:04 +08:00
|
|
|
(ioc->req_sz - 60) / ioc->SGE_size;
|
2005-04-23 06:02:25 +08:00
|
|
|
} else {
|
|
|
|
numSGE = 1 + (scale - 1) *
|
|
|
|
(ioc->facts.MaxChainDepth-1) + scale +
|
2009-05-29 19:07:04 +08:00
|
|
|
(ioc->req_sz - 64) / ioc->SGE_size;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numSGE < sh->sg_tablesize) {
|
|
|
|
/* Reset this value */
|
2007-09-15 08:46:51 +08:00
|
|
|
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
|
2005-04-23 06:02:25 +08:00
|
|
|
"Resetting sg_tablesize to %d from %d\n",
|
|
|
|
ioc->name, numSGE, sh->sg_tablesize));
|
|
|
|
sh->sg_tablesize = numSGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ioc->FreeQlock, flags);
|
|
|
|
|
2007-09-30 00:15:59 +08:00
|
|
|
hd = shost_priv(sh);
|
2005-04-23 06:02:25 +08:00
|
|
|
hd->ioc = ioc;
|
|
|
|
|
|
|
|
/* SCSI needs scsi_cmnd lookup table!
|
|
|
|
* (with size equal to req_depth*PtrSz!)
|
|
|
|
*/
|
2007-09-30 00:16:53 +08:00
|
|
|
ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
|
|
|
|
if (!ioc->ScsiLookup) {
|
2005-04-23 06:02:25 +08:00
|
|
|
error = -ENOMEM;
|
2005-11-17 09:54:17 +08:00
|
|
|
goto out_mptspi_probe;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
2007-09-30 00:16:53 +08:00
|
|
|
spin_lock_init(&ioc->scsi_lookup_lock);
|
2005-04-23 06:02:25 +08:00
|
|
|
|
2007-07-24 18:17:41 +08:00
|
|
|
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
|
2007-09-30 00:16:53 +08:00
|
|
|
ioc->name, ioc->ScsiLookup));
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
ioc->spi_data.Saf_Te = mpt_saf_te;
|
2007-07-24 18:17:41 +08:00
|
|
|
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
|
2006-07-12 07:34:01 +08:00
|
|
|
"saf_te %x\n",
|
2005-04-23 06:02:25 +08:00
|
|
|
ioc->name,
|
2006-07-12 07:34:01 +08:00
|
|
|
mpt_saf_te));
|
2005-04-23 06:02:25 +08:00
|
|
|
ioc->spi_data.noQas = 0;
|
|
|
|
|
|
|
|
hd->last_queue_full = 0;
|
2007-02-08 07:51:40 +08:00
|
|
|
hd->spi_pending = 0;
|
2005-04-23 06:02:25 +08:00
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
/* Some versions of the firmware don't support page 0; without
|
|
|
|
* that we can't get the parameters */
|
2007-09-15 08:49:03 +08:00
|
|
|
if (ioc->spi_data.sdp0length != 0)
|
2006-03-01 23:02:49 +08:00
|
|
|
sh->transportt = mptspi_transport_template;
|
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
error = scsi_add_host (sh, &ioc->pcidev->dev);
|
|
|
|
if(error) {
|
2007-09-15 08:46:51 +08:00
|
|
|
dprintk(ioc, printk(MYIOC_s_ERR_FMT
|
|
|
|
"scsi_add_host failed\n", ioc->name));
|
2005-11-17 09:54:17 +08:00
|
|
|
goto out_mptspi_probe;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
2006-01-17 09:53:06 +08:00
|
|
|
/*
|
|
|
|
* issue internal bus reset
|
|
|
|
*/
|
|
|
|
if (ioc->spi_data.bus_reset)
|
2009-05-29 19:14:48 +08:00
|
|
|
mptscsih_IssueTaskMgmt(hd,
|
2006-01-17 09:53:06 +08:00
|
|
|
MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
|
|
|
|
0, 0, 0, 0, 5);
|
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
scsi_scan_host(sh);
|
|
|
|
return 0;
|
|
|
|
|
2005-11-17 09:54:17 +08:00
|
|
|
out_mptspi_probe:
|
2005-04-23 06:02:25 +08:00
|
|
|
|
|
|
|
mptscsih_remove(pdev);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver mptspi_driver = {
|
|
|
|
.name = "mptspi",
|
|
|
|
.id_table = mptspi_pci_table,
|
|
|
|
.probe = mptspi_probe,
|
2012-12-22 07:04:26 +08:00
|
|
|
.remove = mptscsih_remove,
|
2005-06-24 08:35:56 +08:00
|
|
|
.shutdown = mptscsih_shutdown,
|
2005-04-23 06:02:25 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = mptscsih_suspend,
|
2006-04-26 07:38:58 +08:00
|
|
|
.resume = mptspi_resume,
|
2005-04-23 06:02:25 +08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/**
|
2006-12-07 12:38:43 +08:00
|
|
|
* mptspi_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
|
2005-04-23 06:02:25 +08:00
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
static int __init
|
|
|
|
mptspi_init(void)
|
|
|
|
{
|
2007-07-02 19:34:10 +08:00
|
|
|
int error;
|
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
show_mptmod_ver(my_NAME, my_VERSION);
|
|
|
|
|
2006-03-01 23:02:49 +08:00
|
|
|
mptspi_transport_template = spi_attach_transport(&mptspi_transport_functions);
|
|
|
|
if (!mptspi_transport_template)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2010-07-26 21:27:36 +08:00
|
|
|
mptspiDoneCtx = mpt_register(mptscsih_io_done, MPTSPI_DRIVER,
|
|
|
|
"mptscsih_io_done");
|
|
|
|
mptspiTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSPI_DRIVER,
|
|
|
|
"mptscsih_taskmgmt_complete");
|
|
|
|
mptspiInternalCtx = mpt_register(mptscsih_scandv_complete,
|
|
|
|
MPTSPI_DRIVER, "mptscsih_scandv_complete");
|
2005-04-23 06:02:25 +08:00
|
|
|
|
2007-07-24 18:17:41 +08:00
|
|
|
mpt_event_register(mptspiDoneCtx, mptspi_event_process);
|
|
|
|
mpt_reset_register(mptspiDoneCtx, mptspi_ioc_reset);
|
2005-04-23 06:02:25 +08:00
|
|
|
|
2007-07-02 19:34:10 +08:00
|
|
|
error = pci_register_driver(&mptspi_driver);
|
|
|
|
if (error)
|
|
|
|
spi_release_transport(mptspi_transport_template);
|
|
|
|
|
|
|
|
return error;
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/**
|
|
|
|
* mptspi_exit - Unregisters MPT adapter(s)
|
|
|
|
*/
|
|
|
|
static void __exit
|
|
|
|
mptspi_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&mptspi_driver);
|
2006-01-17 09:53:06 +08:00
|
|
|
|
2005-04-23 06:02:25 +08:00
|
|
|
mpt_reset_deregister(mptspiDoneCtx);
|
|
|
|
mpt_event_deregister(mptspiDoneCtx);
|
|
|
|
|
|
|
|
mpt_deregister(mptspiInternalCtx);
|
|
|
|
mpt_deregister(mptspiTaskCtx);
|
|
|
|
mpt_deregister(mptspiDoneCtx);
|
2006-03-01 23:02:49 +08:00
|
|
|
spi_release_transport(mptspi_transport_template);
|
2005-04-23 06:02:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mptspi_init);
|
|
|
|
module_exit(mptspi_exit);
|