165 #include <asm/byteorder.h>
166 #include <asm/page.h>
167 #include <linux/stddef.h>
168 #include <linux/string.h>
169 #include <linux/errno.h>
170 #include <linux/kernel.h>
172 #include <linux/slab.h>
174 #include <linux/pci.h>
176 #include <linux/reboot.h>
180 #include <linux/types.h>
189 #include <linux/module.h>
191 #include <linux/stat.h>
199 static char *ips =
NULL;
206 #define IPS_VERSION_HIGH IPS_VER_MAJOR_STRING "." IPS_VER_MINOR_STRING
207 #define IPS_VERSION_LOW "." IPS_VER_BUILD_STRING " "
209 #if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
210 #warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
213 #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
214 DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
215 PCI_DMA_BIDIRECTIONAL : \
216 scb->scsi_cmd->sc_data_direction)
219 #define METHOD_TRACE(s, i) if (ips_debug >= (i+10)) printk(KERN_NOTICE s "\n");
220 #define DEBUG(i, s) if (ips_debug >= i) printk(KERN_NOTICE s "\n");
221 #define DEBUG_VAR(i, s, v...) if (ips_debug >= i) printk(KERN_NOTICE s "\n", v);
223 #define METHOD_TRACE(s, i)
225 #define DEBUG_VAR(i, s, v...)
232 static int ips_release(
struct Scsi_Host *);
233 static int ips_eh_abort(
struct scsi_cmnd *);
234 static int ips_eh_reset(
struct scsi_cmnd *);
236 static const char *ips_info(
struct Scsi_Host *);
247 static int ips_deallocatescbs(
ips_ha_t *,
int);
248 static int ips_allocatescbs(
ips_ha_t *);
249 static int ips_reset_copperhead(
ips_ha_t *);
250 static int ips_reset_copperhead_memio(
ips_ha_t *);
251 static int ips_reset_morpheus(
ips_ha_t *);
256 static int ips_isintr_copperhead(
ips_ha_t *);
257 static int ips_isintr_copperhead_memio(
ips_ha_t *);
258 static int ips_isintr_morpheus(
ips_ha_t *);
259 static int ips_wait(
ips_ha_t *,
int,
int);
260 static int ips_write_driver_status(
ips_ha_t *,
int);
261 static int ips_read_adapter_status(
ips_ha_t *,
int);
262 static int ips_read_subsystem_parameters(
ips_ha_t *,
int);
263 static int ips_read_config(
ips_ha_t *,
int);
264 static int ips_clear_adapter(
ips_ha_t *,
int);
265 static int ips_readwrite_page5(
ips_ha_t *,
int,
int);
266 static int ips_init_copperhead(
ips_ha_t *);
267 static int ips_init_copperhead_memio(
ips_ha_t *);
268 static int ips_init_morpheus(
ips_ha_t *);
269 static int ips_isinit_copperhead(
ips_ha_t *);
270 static int ips_isinit_copperhead_memio(
ips_ha_t *);
271 static int ips_isinit_morpheus(
ips_ha_t *);
272 static int ips_erase_bios(
ips_ha_t *);
275 static int ips_erase_bios_memio(
ips_ha_t *);
281 static void ips_free_flash_copperhead(
ips_ha_t * ha);
282 static void ips_get_bios_version(
ips_ha_t *,
int);
283 static void ips_identify_controller(
ips_ha_t *);
285 static void ips_enable_int_copperhead(
ips_ha_t *);
286 static void ips_enable_int_copperhead_memio(
ips_ha_t *);
287 static void ips_enable_int_morpheus(
ips_ha_t *);
288 static int ips_intr_copperhead(
ips_ha_t *);
289 static int ips_intr_morpheus(
ips_ha_t *);
290 static void ips_next(
ips_ha_t *,
int);
297 static void ips_setup_funclist(
ips_ha_t *);
298 static void ips_statinit(
ips_ha_t *);
299 static void ips_statinit_memio(
ips_ha_t *);
301 static void ips_ffdc_reset(
ips_ha_t *,
int);
302 static void ips_ffdc_time(
ips_ha_t *);
320 static int ips_is_passthru(
struct scsi_cmnd *);
324 static void ips_scmd_buf_write(
struct scsi_cmnd * scmd,
void *
data,
326 static void ips_scmd_buf_read(
struct scsi_cmnd * scmd,
void *
data,
329 static int ips_proc_info(
struct Scsi_Host *,
char *,
char **,
off_t,
int,
int);
331 static void copy_mem_info(
IPS_INFOSTR *,
char *,
int);
334 static int ips_init_phase2(
int index);
336 static int ips_init_phase1(
struct pci_dev *
pci_dev,
int *indexPtr);
337 static int ips_register_scsi(
int index);
339 static int ips_poll_for_flush_complete(
ips_ha_t * ha);
340 static void ips_flush_and_reset(
ips_ha_t *ha);
345 static const char ips_name[] =
"ips";
348 static unsigned int ips_next_controller;
349 static unsigned int ips_num_controllers;
350 static unsigned int ips_released_controllers;
351 static int ips_hotplug;
352 static int ips_cmd_timeout = 60;
353 static int ips_reset_timeout = 60 * 5;
354 static int ips_force_memio = 1;
355 static int ips_force_i2o = 1;
357 static int ips_cd_boot;
358 static char *ips_FlashData =
NULL;
360 static long ips_FlashDataInUse;
363 .detect = ips_detect,
364 .release = ips_release,
366 .queuecommand = ips_queue,
367 .eh_abort_handler = ips_eh_abort,
368 .eh_host_reset_handler = ips_eh_reset,
370 .proc_info = ips_proc_info,
371 .slave_configure = ips_slave_configure,
372 .bios_param = ips_biosparam,
390 static char ips_hot_plug_name[] =
"ips";
396 .name = ips_hot_plug_name,
397 .id_table = ips_pci_table,
398 .probe = ips_insert_device,
408 #define MAX_ADAPTER_NAME 15
410 static char ips_adapter_name[][30] = {
413 "ServeRAID on motherboard",
414 "ServeRAID on motherboard",
438 static char ips_command_direction[] = {
503 ips_setup(
char *ips_str)
510 {
"noi2o", &ips_force_i2o, 0},
511 {
"nommap", &ips_force_memio, 0},
513 {
"cdboot", &ips_cd_boot, 0},
514 {
"maxcmds", &MaxLiteCmds, 32},
519 while ((key =
strsep(&ips_str,
",."))) {
531 (key, options[i].option_name,
532 strlen(options[i].option_name)) == 0) {
572 for (i = 0; i < ips_num_controllers; i++) {
573 if (ips_register_scsi(i))
575 ips_released_controllers++;
578 return (ips_num_controllers);
604 ha->
func.
isintr = ips_isintr_copperhead_memio;
605 ha->
func.
isinit = ips_isinit_copperhead_memio;
606 ha->
func.
init = ips_init_copperhead_memio;
609 ha->
func.
reset = ips_reset_copperhead_memio;
610 ha->
func.
intr = ips_intr_copperhead;
618 ha->
func.
issue = ips_issue_copperhead_memio;
623 ha->
func.
init = ips_init_copperhead;
627 ha->
func.
intr = ips_intr_copperhead;
664 "(%s) release, invalid Scsi_Host pointer.\n", ips_name);
677 ips_init_scb(ha, scb);
679 scb->
timeout = ips_cmd_timeout;
709 ips_released_controllers++;
732 return (NOTIFY_DONE);
734 for (i = 0; i < ips_next_controller; i++) {
746 ips_init_scb(ha, scb);
748 scb->
timeout = ips_cmd_timeout;
762 if (ips_send_wait(ha, scb, ips_cmd_timeout,
IPS_INTR_ON) ==
765 "Incomplete Flush.\n");
768 "Flushing Complete.\n");
808 while ((item) && (item->
scsi_cmd != SC))
840 static int __ips_eh_reset(
struct scsi_cmnd *SC)
855 DEBUG(1,
"Reset called with NULL scsi command");
863 DEBUG(1,
"Reset called with NULL ha struct");
873 while ((item) && (item->
scsi_cmd != SC))
901 ips_init_scb(ha, scb);
903 scb->
timeout = ips_cmd_timeout;
915 ret = ips_send_wait(ha, scb, ips_cmd_timeout,
IPS_INTR_IORL);
918 "Reset Request - Flushed Cache\n");
939 "Controller reset failed - controller now offline.\n");
942 DEBUG_VAR(1,
"(%s%d) Failing active commands",
948 ips_freescb(ha, scb);
952 DEBUG_VAR(1,
"(%s%d) Failing pending commands",
955 while ((scsi_cmd = ips_removeq_wait_head(&ha->
scb_waitlist))) {
968 "Controller reset failed - controller now offline.\n");
971 DEBUG_VAR(1,
"(%s%d) Failing active commands",
977 ips_freescb(ha, scb);
981 DEBUG_VAR(1,
"(%s%d) Failing pending commands",
984 while ((scsi_cmd = ips_removeq_wait_head(&ha->
scb_waitlist))) {
1009 ips_freescb(ha, scb);
1013 for (i = 1; i < ha->
nbus; i++)
1026 static int ips_eh_reset(
struct scsi_cmnd *SC)
1030 spin_lock_irq(SC->
device->host->host_lock);
1031 rc = __ips_eh_reset(SC);
1032 spin_unlock_irq(SC->
device->host->host_lock);
1064 if (ips_is_passthru(SC)) {
1080 DEBUG_VAR(2,
"(%s%d): ips_queue: cmd 0x%X (%d %d %d)",
1095 if (ips_is_passthru(SC)) {
1172 if ((capacity > 0x400000) && ((ha->
enq->
ucMiscFlag & 0x8) == 0)) {
1182 DEBUG_VAR(2,
"Geometry: heads: %d, sectors: %d, cylinders: %d",
1230 do_ipsintr(
int irq,
void *
dev_id)
1316 ips_chkstatus(ha, &cstatus);
1375 if (cstatus.
value == 0xffffffff)
1381 "Spurious interrupt; no ccb.\n");
1386 ips_chkstatus(ha, &cstatus);
1422 memset(bp, 0,
sizeof (buffer));
1424 sprintf(bp,
"%s%s%s Build %d",
"IBM PCI ServeRAID ",
1456 for (i = 0; i < ips_next_controller; i++) {
1458 if (ips_sh[i] == host) {
1476 ret = ips_host_info(ha, buffer, offset, length);
1495 static int ips_is_passthru(
struct scsi_cmnd *SC)
1497 unsigned long flags;
1505 (SC->
device->channel == 0) &&
1507 (SC->
device->lun == 0) && scsi_sglist(SC)) {
1515 if (buffer && buffer[0] ==
'C' && buffer[1] ==
'O' &&
1516 buffer[2] ==
'P' && buffer[3] ==
'P') {
1536 ips_alloc_passthru_buffer(
ips_ha_t * ha,
int length)
1541 if (ha->
ioctl_data && length <= ha->ioctl_len)
1579 length += sg->length;
1583 DEBUG_VAR(1,
"(%s%d) Passthru structure wrong size",
1587 if (ips_alloc_passthru_buffer(ha, length)) {
1592 ips_scmd_buf_read(SC, pt,
sizeof (ips_passthru_t));
1595 ips_scmd_buf_write(SC, pt,
sizeof (ips_passthru_t));
1617 &ips_num_controllers,
sizeof (
int));
1619 sizeof (ips_passthru_t) +
sizeof (
int));
1627 if (length < (
sizeof (ips_passthru_t) + pt->
CmdBSize)) {
1630 "(%s%d) Passthru structure wrong size",
1639 ret = ips_flash_copperhead(ha, pt, scb);
1641 sizeof (ips_passthru_t));
1644 if (ips_usrcmd(ha, pt, scb))
1670 if (ips_usrcmd(ha, pt, scb))
1683 return ips_flash_bios(ha, pt, scb);
1707 ips_free_flash_copperhead(ha);
1709 "failed size sanity check\n");
1722 return ips_flash_bios(ha, pt, scb);
1724 return ips_flash_firmware(ha, pt, scb);
1745 "(%s%d) flash bios failed - unable to erase flash",
1755 "(%s%d) flash bios failed - unable to flash",
1765 "(%s%d) flash bios failed - unable to verify flash",
1769 ips_free_flash_copperhead(ha);
1777 "(%s%d) flash bios failed - unable to erase flash",
1786 ips_free_flash_copperhead(ha);
1800 ips_scb_t * scb,
int indx,
unsigned int e_len)
1850 ips_free_flash_copperhead(ha);
1869 scb->
timeout = ips_cmd_timeout;
1890 ips_free_flash_copperhead(
ips_ha_t * ha)
1917 if ((!scb) || (!pt) || (!ha))
1938 scb->
timeout = ips_cmd_timeout;
1956 (
unsigned long) &scb->
1958 (
unsigned long) scb);
2005 DEBUG_VAR(1,
"(%s%d) couldn't cleanup after passthru",
2023 ips_free_flash_copperhead(ha);
2050 copy_info(&info,
"\nIBM ServeRAID General Information:\n\n");
2054 copy_info(&info,
"\tController Type : %s\n",
2055 ips_adapter_name[ha->
ad_type - 1]);
2058 "\tController Type : Unknown\n");
2062 "\tIO region : 0x%lx (%d bytes)\n",
2067 "\tMemory region : 0x%lx (%d bytes)\n",
2070 "\tShared memory address : 0x%lx\n",
2074 copy_info(&info,
"\tIRQ number : %d\n", ha->
pcidev->irq);
2082 "\tBIOS Version : %c%c%c%c%c%c%c\n",
2090 "\tBIOS Version : %c%c%c%c%c%c%c%c\n",
2101 "\tFirmware Version : %c%c%c%c%c%c%c\n",
2108 "\tFirmware Version : %c%c%c%c%c%c%c%c\n",
2117 "\tBoot Block Version : %c%c%c%c%c%c%c\n",
2124 "\tBoot Block Version : %c%c%c%c%c%c%c%c\n",
2131 copy_info(&info,
"\tDriver Version : %s%s\n",
2134 copy_info(&info,
"\tDriver Build : %d\n",
2137 copy_info(&info,
"\tMax Physical Devices : %d\n",
2139 copy_info(&info,
"\tMax Active Commands : %d\n",
2141 copy_info(&info,
"\tCurrent Queued Commands : %d\n",
2143 copy_info(&info,
"\tCurrent Active Commands : %d\n",
2145 copy_info(&info,
"\tCurrent Queued PT Commands : %d\n",
2147 copy_info(&info,
"\tCurrent Active PT Commands : %d\n",
2150 copy_info(&info,
"\n");
2169 if (info->
pos + len < info->offset) {
2212 copy_mem_info(info, buf, len);
2227 ips_identify_controller(
ips_ha_t * ha)
2231 switch (ha->
pcidev->device) {
2255 switch (ha->
pcidev->subsystem_device) {
2284 switch (ha->
pcidev->subsystem_device) {
2312 ips_get_bios_version(
ips_ha_t * ha,
int intr)
2321 {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
2414 memset(buffer, 0, 0x1000);
2418 ips_init_scb(ha, scb);
2420 scb->
timeout = ips_cmd_timeout;
2435 ips_send_wait(ha, scb, ips_cmd_timeout,
2444 if ((buffer[0xC0] == 0x55) && (buffer[0xC1] == 0xAA)) {
2445 major = buffer[0x1ff + 0xC0];
2446 minor = buffer[0x1fe + 0xC0];
2447 subminor = buffer[0x1fd + 0xC0];
2499 "unable to read config from controller.\n");
2506 "unable to read controller status.\n");
2512 ips_identify_controller(ha);
2516 "unable to read subsystem parameters.\n");
2524 "unable to write driver info to controller.\n");
2587 if ((ha->
max_cmds > MaxLiteCmds) && (MaxLiteCmds))
2593 for (i = 1; i < ha->
nbus; i++) {
2661 ret = ips_make_passthru(ha, scb->
scsi_cmd, scb, intr);
2672 ips_freescb(ha, scb);
2680 ips_freescb(ha, scb);
2691 ret = ips_send_cmd(ha, scb);
2704 ips_freescb(ha, scb);
2707 ips_freescb(ha, scb);
2720 while ((p) && (scb = ips_getscb(ha))) {
2725 ips_freescb(ha, scb);
2746 scb->
timeout = ips_cmd_timeout;
2761 if (ips_fill_scb_sg_single
2775 ips_command_direction[scb->
scsi_cmd->cmnd[0]];
2793 ret = ips_send_cmd(ha, scb);
2809 ips_freescb(ha, scb);
2819 ips_freescb(ha, scb);
2888 if (queue->
tail == item)
2917 if (item == queue->
head) {
2918 return (ips_removeq_scb_head(queue));
2923 while ((p) && (item != p->
q_next))
2963 queue->
tail->host_scribble = (
char *) item;
3028 if (item == queue->
head) {
3029 return (ips_removeq_wait_head(queue));
3112 if (queue->
tail == item)
3141 if (item == queue->
head) {
3142 return (ips_removeq_copp_head(queue));
3147 while ((p) && (item != p->
next))
3180 ips_freescb(ha, scb);
3204 "Spurious interrupt; scb NULL.\n");
3212 "Spurious interrupt; scsi_cmd not set.\n");
3240 ips_cleanup_passthru(ha, scb);
3250 int i, sg_dma_index, ips_sg_index = 0;
3259 for (i = 0; i < scb->
breakup; i++)
3263 ips_fill_scb_sg_single(ha,
3265 scb, ips_sg_index++,
3268 for (; sg_dma_index < scsi_sg_count(scb->
scsi_cmd);
3269 sg_dma_index++, sg =
sg_next(sg)) {
3270 if (ips_fill_scb_sg_single
3273 scb, ips_sg_index++,
3280 ips_command_direction[scb->
scsi_cmd->cmnd[0]];
3290 ret = ips_send_cmd(ha, scb);
3299 ips_freescb(ha, scb);
3307 ips_freescb(ha, scb);
3323 ips_freescb(ha, scb);
3348 "(%s%d) Physical device error (%d %d %d): %x %x, Sense Key: %x, ASC: %x, ASCQ: %x",
3396 if ((scb->
bus) && (transfer_len < scb->
data_len)) {
3403 &inquiryData,
sizeof (inquiryData));
3456 scb->
scsi_cmd->result = device_error | (errcode << 16);
3484 ret = ips_send_cmd(ha, scb);
3490 ret = ips_wait(ha, timeout, intr);
3503 ips_scmd_buf_write(
struct scsi_cmnd *scmd,
void *data,
unsigned int count)
3505 unsigned long flags;
3508 scsi_sg_copy_from_buffer(scmd, data, count);
3520 ips_scmd_buf_read(
struct scsi_cmnd *scmd,
void *data,
unsigned int count)
3522 unsigned long flags;
3525 scsi_sg_copy_to_buffer(scmd, data, count);
3564 }
else if ((scb->
bus == 0) && (!ips_is_passthru(scb->
scsi_cmd))) {
3637 ips_reqsen(ha, scb);
3673 cmnd[1] & 0x1f) << 16) | (scb->
scsi_cmd->
3718 ((scb->
scsi_cmd->cmnd[2] << 24) | (scb->
3722 (scb->
scsi_cmd->cmnd[4] << 8) | scb->
3783 sp = (
char *) scb->
scsi_cmd->sense_buffer;
3813 (
unsigned long) &scb->
3815 (
unsigned long) scb);
3822 TimeOut = scb->
scsi_cmd->request->timeout;
3841 if (TimeOut < (10 *
HZ))
3843 else if (TimeOut < (60 *
HZ))
3845 else if (TimeOut < (1200 *
HZ))
3878 if (TimeOut < (10 *
HZ))
3880 else if (TimeOut < (60 *
HZ))
3882 else if (TimeOut < (1200 *
HZ))
3948 DEBUG_VAR(2,
"(%s%d) ips_chkstatus: cmd 0x%X id %d (%d %d %d)",
3964 if (scb->
bus == 0) {
3965 if ((basic_status & IPS_GSC_STATUS_MASK) ==
3968 "(%s%d) Recovered Logical Drive Error OpCode: %x, BSB: %x, ESB: %x",
3971 basic_status, ext_status);
3987 if (!ips_online(ha, scb)) {
3993 if (ips_online(ha, scb)) {
3994 ips_inquiry(ha, scb);
4001 ips_reqsen(ha, scb);
4013 if (!ips_online(ha, scb)
4014 || !ips_msense(ha, scb)) {
4020 if (ips_online(ha, scb))
4046 scb->
scsi_cmd->result = errcode << 16;
4051 &inquiryData,
sizeof (inquiryData));
4057 if (scb->
bus == 0) {
4059 "(%s%d) Unrecovered Logical Drive Error OpCode: %x, BSB: %x, ESB: %x",
4065 ips_map_status(ha, scb, sp);
4155 if (scsi_bufflen(scb->
scsi_cmd) < 8)
4161 drive_info[scb->
target_id].sector_count) - 1);
4199 1) / (heads * sectors);
4205 switch (scb->
scsi_cmd->cmnd[2] & 0x3f) {
4343 ips_deallocatescbs(ha, ha->
max_cmds);
4372 ha->
scbs->sg_list.list,
4373 ha->
scbs->sg_busaddr);
4419 for (i = 0; i < ha->
max_cmds; i++) {
4420 scb_p = &ha->
scbs[
i];
4516 ips_init_scb(ha, scb);
4560 ips_isinit_copperhead(
ips_ha_t * ha)
4586 ips_isinit_copperhead_memio(
ips_ha_t * ha)
4596 if (((isr & IPS_BIT_EI) == 0) && ((scpr & IPS_BIT_EBM) == 0))
4619 if (ips_isintr_morpheus(ha))
4620 ips_flush_and_reset(ha);
4627 else if (bits & 0x3)
4656 ips_init_scb(ha, scb);
4659 scb->
timeout = ips_cmd_timeout;
4670 ret = ips_send_cmd(ha, scb);
4676 while ((time > 0) && (!done)) {
4677 done = ips_poll_for_flush_complete(ha);
4703 ips_poll_for_flush_complete(
ips_ha_t * ha)
4710 if (cstatus.
value == 0xffffffff)
4730 ips_enable_int_copperhead(
ips_ha_t * ha)
4747 ips_enable_int_copperhead_memio(
ips_ha_t * ha)
4764 ips_enable_int_morpheus(
ips_ha_t * ha)
4797 for (j = 0; j < 45; j++) {
4816 "reset controller fails (post status %x %x).\n",
4817 PostByte[0], PostByte[1]);
4823 for (j = 0; j < 240; j++) {
4840 for (i = 0; i < 240; i++) {
4880 ips_init_copperhead_memio(
ips_ha_t * ha)
4891 for (j = 0; j < 45; j++) {
4910 "reset controller fails (post status %x %x).\n",
4911 PostByte[0], PostByte[1]);
4917 for (j = 0; j < 240; j++) {
4934 for (i = 0; i < 240; i++) {
4986 for (i = 0; i < 45; i++) {
4999 "timeout waiting for post.\n");
5006 if (Post == 0x4F00) {
5008 "Flashing Battery PIC, Please wait ...\n");
5014 for (i = 0; i < 120; i++) {
5024 "timeout waiting for Battery PIC Flash\n");
5036 "reset controller fails (post status %x).\n", Post);
5042 for (i = 0; i < 240; i++) {
5055 "timeout waiting for config.\n");
5074 if (Post == 0xEF10) {
5075 if ((Config == 0x000F) || (Config == 0x0009))
5092 ips_reset_copperhead(
ips_ha_t * ha)
5098 DEBUG_VAR(1,
"(%s%d) ips_reset_copperhead: io addr: %x, irq: %d",
5103 while (reset_counter < 2) {
5118 else if (reset_counter >= 2) {
5137 ips_reset_copperhead_memio(
ips_ha_t * ha)
5143 DEBUG_VAR(1,
"(%s%d) ips_reset_copperhead_memio: mem addr: %x, irq: %d",
5148 while (reset_counter < 2) {
5163 else if (reset_counter >= 2) {
5189 DEBUG_VAR(1,
"(%s%d) ips_reset_morpheus: mem addr: %x, irq: %d",
5194 while (reset_counter < 2) {
5203 pci_read_config_byte(ha->
pcidev, 4, &junk);
5207 else if (reset_counter >= 2) {
5287 ips_statupd_copperhead(
ips_ha_t * ha)
5315 ips_statupd_copperhead_memio(
ips_ha_t * ha)
5342 ips_statupd_morpheus(
ips_ha_t * ha)
5371 DEBUG_VAR(2,
"(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)",
5393 "ips_issue val [0x%x].\n", val);
5395 "ips_issue semaphore chk timeout.\n");
5425 DEBUG_VAR(2,
"(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)",
5432 DEBUG_VAR(2,
"(%s%d) ips_issue: logical cmd id %d",
5446 "ips_issue val [0x%x].\n", val);
5448 "ips_issue semaphore chk timeout.\n");
5476 DEBUG_VAR(2,
"(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)",
5483 DEBUG_VAR(2,
"(%s%d) ips_issue: logical cmd id %d",
5508 DEBUG_VAR(2,
"(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)",
5515 DEBUG_VAR(2,
"(%s%d) ips_issue: logical cmd id %d",
5534 ips_isintr_copperhead(
ips_ha_t * ha)
5567 ips_isintr_copperhead_memio(
ips_ha_t * ha)
5579 if (Isr & IPS_BIT_SCE)
5624 ips_wait(
ips_ha_t * ha,
int time,
int intr)
5636 while ((time > 0) && (!done)) {
5682 ips_write_driver_status(
ips_ha_t * ha,
int intr)
5686 if (!ips_readwrite_page5(ha,
FALSE, intr)) {
5688 "unable to read NVRAM page 5.\n");
5697 "(%s%d) NVRAM page 5 has an invalid signature: %X.",
5703 "(%s%d) Ad Type: %d, Ad Slot: %d, BIOS: %c%c%c%c %c%c%c%c.",
5711 ips_get_bios_version(ha, intr);
5724 if (!ips_readwrite_page5(ha,
TRUE, intr)) {
5726 "unable to write NVRAM page 5.\n");
5747 ips_read_adapter_status(
ips_ha_t * ha,
int intr)
5756 ips_init_scb(ha, scb);
5758 scb->
timeout = ips_cmd_timeout;
5772 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) ==
IPS_FAILURE)
5790 ips_read_subsystem_parameters(
ips_ha_t * ha,
int intr)
5799 ips_init_scb(ha, scb);
5801 scb->
timeout = ips_cmd_timeout;
5815 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) ==
IPS_FAILURE)
5834 ips_read_config(
ips_ha_t * ha,
int intr)
5843 for (i = 0; i < 4; i++)
5848 ips_init_scb(ha, scb);
5850 scb->
timeout = ips_cmd_timeout;
5860 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) ==
IPS_FAILURE)
5867 for (i = 0; i < 4; i++)
5901 ips_init_scb(ha, scb);
5903 scb->
timeout = ips_cmd_timeout;
5919 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) ==
IPS_FAILURE)
5942 ips_clear_adapter(
ips_ha_t * ha,
int intr)
5951 ips_init_scb(ha, scb);
5953 scb->
timeout = ips_reset_timeout;
5966 ips_send_wait(ha, scb, ips_reset_timeout, intr)) ==
IPS_FAILURE)
5972 ips_init_scb(ha, scb);
5975 scb->
timeout = ips_reset_timeout;
5987 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) ==
IPS_FAILURE)
6005 ips_ffdc_reset(
ips_ha_t * ha,
int intr)
6013 ips_init_scb(ha, scb);
6015 scb->
timeout = ips_cmd_timeout;
6023 ips_fix_ffdc_time(ha, scb, ha->
last_ffdc);
6026 ips_send_wait(ha, scb, ips_cmd_timeout, intr);
6049 ips_init_scb(ha, scb);
6051 scb->
timeout = ips_cmd_timeout;
6059 ips_fix_ffdc_time(ha, scb, ha->
last_ffdc);
6062 ips_send_wait(ha, scb, ips_cmd_timeout,
IPS_FFDC);
6082 int month_lengths[12][2] = { {31, 31},
6122 for (i = 0; days >= month_lengths[
i][yleap]; ++
i)
6123 days -= month_lengths[i][yleap];
6177 while (timeout > 0) {
6203 while (timeout > 0) {
6254 ips_erase_bios_memio(
ips_ha_t * ha)
6289 while (timeout > 0) {
6315 while (timeout > 0) {
6377 for (i = 0; i < buffersize; i++) {
6393 while (timeout > 0) {
6422 if (status & 0x18) {
6468 for (i = 0; i < buffersize; i++) {
6484 while (timeout > 0) {
6513 if (status & 0x18) {
6571 for (i = 2; i < buffersize; i++) {
6620 for (i = 2; i < buffersize; i++) {
6663 ips_shift_controllers(
int lowindex,
int highindex)
6665 ips_ha_t *ha_sav = ips_ha[highindex];
6666 struct Scsi_Host *sh_sav = ips_sh[highindex];
6669 for (i = highindex; i > lowindex; i--) {
6670 ips_ha[
i] = ips_ha[i - 1];
6671 ips_sh[
i] = ips_sh[i - 1];
6675 ips_ha[lowindex] = ha_sav;
6676 ips_sh[lowindex] = sh_sav;
6687 ips_order_controllers(
void)
6689 int i,
j,
tmp, position = 0;
6693 nvram = ips_ha[0]->
nvram;
6697 for (j = position; j < ips_num_controllers; j++) {
6698 switch (ips_ha[j]->ad_type) {
6702 ips_shift_controllers(position,
6712 ips_shift_controllers(position,
6722 ips_shift_controllers(position,
6735 ips_shift_controllers(position,
6750 for (i = position; i < ips_num_controllers; i++) {
6753 ips_shift_controllers(position, i);
6761 for (i = position; i < ips_num_controllers; i++) {
6766 ips_shift_controllers(position, i);
6782 ips_register_scsi(
int index)
6789 "Unable to register controller with SCSI subsystem\n");
6798 "Unable to install interrupt handler\n");
6817 if (scsi_add_host(sh, &ha->
pcidev->dev))
6843 struct Scsi_Host *sh = pci_get_drvdata(pci_dev);
6845 pci_set_drvdata(pci_dev,
NULL);
6861 ips_module_init(
void)
6863 if (pci_register_driver(&ips_pci_driver) < 0)
6866 ips_order_controllers();
6867 if (!ips_detect(&ips_driver_template)) {
6883 ips_module_exit(
void)
6916 rc = ips_init_phase1(pci_dev, &index);
6918 rc = ips_init_phase2(index);
6921 if (ips_register_scsi(index)) {
6922 ips_free(ips_ha[index]);
6927 ips_num_controllers++;
6929 ips_next_controller = ips_num_controllers;
6933 goto err_out_regions;
6936 pci_set_drvdata(pci_dev, ips_sh[index]);
6956 ips_init_phase1(
struct pci_dev *pci_dev,
int *indexPtr)
6975 if (ips_ha[j] ==
NULL) {
6981 if (index >= IPS_MAX_ADAPTERS)
6985 bus = pci_dev->
bus->number;
6986 func = pci_dev->
devfn;
6994 for (j = 0; j < 2; j++) {
7013 offs = mem_addr -
base;
7017 mem_ptr = ioremap_ptr +
offs;
7027 "Unable to allocate temporary ha struct\n");
7058 return ips_abort_init(ha, index);
7061 if(ips_cd_boot && !ips_FlashData){
7070 "Unable to allocate host inquiry structure\n");
7071 return ips_abort_init(ha, index);
7078 "Unable to allocate host adapt & dummy structures\n");
7079 return ips_abort_init(ha, index);
7089 "Unable to allocate logical drive info structure\n");
7090 return ips_abort_init(ha, index);
7099 "Unable to allocate host conf structure\n");
7100 return ips_abort_init(ha, index);
7107 "Unable to allocate host NVRAM structure\n");
7108 return ips_abort_init(ha, index);
7115 "Unable to allocate host subsystem structure\n");
7116 return ips_abort_init(ha, index);
7129 "Unable to allocate IOCTL data\n");
7130 return ips_abort_init(ha, index);
7136 ips_setup_funclist(ha);
7141 if (IsDead == 0xDEADBEEF) {
7142 ips_reset_morpheus(ha);
7156 "Unable to initialize controller\n");
7157 return ips_abort_init(ha, index);
7175 ips_init_phase2(
int index)
7190 "Unable to install interrupt handler\n");
7191 return ips_abort_init(ha, index);
7198 if (!ips_allocatescbs(ha)) {
7200 "Unable to allocate a CCB\n");
7202 return ips_abort_init(ha, index);
7205 if (!ips_hainit(ha)) {
7207 "Unable to initialize controller\n");
7209 return ips_abort_init(ha, index);
7212 ips_deallocatescbs(ha, 1);
7215 if (!ips_allocatescbs(ha)) {
7217 "Unable to allocate CCBs\n");
7219 return ips_abort_init(ha, index);