patch-2.2.18 linux/drivers/scsi/ibmmca.c
Next file: linux/drivers/scsi/ibmmca.h
Previous file: linux/drivers/scsi/hosts.c
Back to the patch index
Back to the overall index
- Lines: 2386
- Date:
Mon Jul 31 20:57:07 2000
- Orig file:
v2.2.17/drivers/scsi/ibmmca.c
- Orig date:
Fri Apr 21 12:46:28 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/scsi/ibmmca.c linux/drivers/scsi/ibmmca.c
@@ -7,7 +7,7 @@
* See the file README.ibmmca for a detailed description of this driver,
* the commandline arguments and the history of its development.
* See the WWW-page: http://www.uni-mainz.de/~langm000/linux.html for latest
- * updates and info.
+ * updates, info and ADF-files for adapters supported by this driver.
*/
/******************* HEADER FILE INCLUDES ************************************/
@@ -16,14 +16,12 @@
#endif
/* choose adaption for Kernellevel */
-#define local_LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-#if LINUX_VERSION_CODE < local_LinuxVersionCode(2,1,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,65)
#define OLDKERN
#else
#undef OLDKERN
#endif
-#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ctype.h>
@@ -36,10 +34,13 @@
#include <linux/stat.h>
#include <linux/mca.h>
#include <asm/system.h>
-#ifndef OLDKERN
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
+#include <linux/spinlock.h>
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
#include <asm/spinlock.h>
#endif
#include <asm/io.h>
+#include <linux/init.h>
#include "sd.h"
#include "scsi.h"
#include "hosts.h"
@@ -49,6 +50,7 @@
/******************* LOCAL DEFINES *******************************************/
+/* milliseconds of delay for timing out reset. */
#ifndef mdelay
#define mdelay(a) udelay((a) * 1000)
#endif
@@ -56,7 +58,7 @@
/*--------------------------------------------------------------------*/
/* current version of this driver-source: */
-#define IBMMCA_SCSI_DRIVER_VERSION "3.1e"
+#define IBMMCA_SCSI_DRIVER_VERSION "3.2"
/*--------------------------------------------------------------------*/
@@ -110,6 +112,7 @@
/*note: the lower nibble specifies the device(0-14), or subsystem(15) */
#define IM_SCB_CMD_COMPLETED 0x10
#define IM_SCB_CMD_COMPLETED_WITH_RETRIES 0x50
+#define IM_LOOP_SCATTER_BUFFER_FULL 0x60
#define IM_ADAPTER_HW_FAILURE 0x70
#define IM_IMMEDIATE_CMD_COMPLETED 0xa0
#define IM_CMD_COMPLETED_WITH_FAILURE 0xc0
@@ -153,7 +156,7 @@
unsigned short length; /*block length, on SCSI device */
}
blk;
- unsigned char scsi_command[12]; /*other scsi command */
+ unsigned char scsi_command[12]; /*other scsi command */
}
u2;
};
@@ -165,6 +168,31 @@
unsigned long byte_length;
};
+/*structure returned by a get_pos_info command: */
+struct im_pos_info
+ {
+ unsigned short pos_id; /* adapter id */
+ unsigned char pos_3a; /* pos 3 (if pos 6 = 0) */
+ unsigned char pos_2; /* pos 2 */
+ unsigned char int_level; /* interrupt level IRQ 11 or 14 */
+ unsigned char pos_4a; /* pos 4 (if pos 6 = 0) */
+ unsigned short connector_size; /* MCA connector size: 16 or 32 Bit */
+ unsigned char num_luns; /* number of supported luns per device */
+ unsigned char num_puns; /* number of supported puns */
+ unsigned char pacing_factor; /* pacing factor */
+ unsigned char num_ldns; /* number of ldns available */
+ unsigned char eoi_off; /* time EOI and interrupt inactive */
+ unsigned char max_busy; /* time between reset and busy on */
+ unsigned short cache_stat; /* ldn cachestat. Bit=1 = not cached */
+ unsigned short retry_stat; /* retry status of ldns. Bit=1=disabled */
+ unsigned char pos_4b; /* pos 4 (if pos 6 = 1) */
+ unsigned char pos_3b; /* pos 3 (if pos 6 = 1) */
+ unsigned char pos_6; /* pos 6 */
+ unsigned char pos_5; /* pos 5 */
+ unsigned short max_overlap; /* maximum overlapping requests */
+ unsigned short num_bus; /* number of SCSI-busses */
+ };
+
/*values for SCB command word */
#define IM_NO_SYNCHRONOUS 0x0040 /*flag for any command */
#define IM_NO_DISCONNECT 0x0080 /*flag for any command */
@@ -175,6 +203,7 @@
#define IM_REQUEST_SENSE_CMD 0x1c08
#define IM_READ_CAPACITY_CMD 0x1c09
#define IM_DEVICE_INQUIRY_CMD 0x1c0b
+#define IM_READ_LOGICAL_CMD 0x1c2a
#define IM_OTHER_SCSI_CMD_CMD 0x241f
/* unused, but supported, SCB commands */
@@ -190,6 +219,7 @@
#define IM_RETRY_ENABLE 0x2000
#define IM_POINTER_TO_LIST 0x1000
#define IM_SUPRESS_EXCEPTION_SHORT 0x0400
+#define IM_BYPASS_BUFFER 0x0200
#define IM_CHAIN_ON_NO_ERROR 0x0001
/*TSB (Termination Status Block) structure */
@@ -211,15 +241,17 @@
};
/*subsystem uses interrupt request level 14 */
-#define IM_IRQ 14
+#define IM_IRQ 14
+/*SCSI-2 F/W may evade to interrupt 11 */
+#define IM_IRQ_FW 11
/*--------------------------------------------------------------------*/
/*
The model 95 doesn't have a standard activity light. Instead it
- has a row of LEDs on the front. We use the last one as the activity
- indicator if we think we're on a model 95. I suspect the model id
- check will be either too narrow or too general, and some machines
- won't have an activity indicator. Oh well...
+ has a row of alphanumerial LEDs on the front. We use the last one
+ as the activity indicator if we think we're on a model 95. I suspect
+ the model id check will be either too narrow or too general, and some
+ machines won't have an activity indicator. Oh well...
The regular PS/2 disk led is turned on/off by bits 6,7 of system
control port.
@@ -229,6 +261,12 @@
#define MOD95_LED_PORT 0x108
/* system-control-register of PS/2s with diskindicator */
#define PS2_SYS_CTR 0x92
+/* activity displaying methods */
+#define LED_DISP 1
+#define LED_ADISP 2
+#define LED_ACTIVITY 4
+
+#define CMD_FAIL 255
/* The SCSI-ID(!) of the accessed SCSI-device is shown on PS/2-95 machines' LED
displays. ldn is no longer displayed here, because the ldn mapping is now
@@ -237,30 +275,39 @@
interest, debugging or just for having fun. The left number gives the
host-adapter number and the right shows the accessed SCSI-ID. */
-/* use_display is set by the ibmmcascsi=display command line arg */
-static int use_display = 0;
-/* use_adisplay is set by ibmmcascsi=adisplay, which offers a higher
- * level of displayed luxus on PS/2 95 (really fancy! :-))) */
-static int use_adisplay = 0;
+/* display_mode is set by the ibmmcascsi= command line arg */
+static int display_mode = 0;
+/* set default adapter timeout */
+static unsigned int adapter_timeout = 45;
+/* for probing on feature-command: */
+static unsigned int global_command_error_excuse = 0;
+/* global setting by command line for adapter_speed */
+static int global_adapter_speed = 0; /* full speed by default */
+/* Panel / LED on, do it right for F/W addressin, too. adisplay will
+ * just ignore ids>7, as the panel has only 7 digits available */
#define PS2_DISK_LED_ON(ad,id) {\
- if( use_display ) { outb((char)(id+48), MOD95_LED_PORT ); \
- outb((char)(ad+48), MOD95_LED_PORT+1); } \
- else if( use_adisplay ) { if (id<7) outb((char)(id+48), \
- MOD95_LED_PORT+1+id); outb((char)(ad+48), MOD95_LED_PORT); } \
- else outb(inb(PS2_SYS_CTR) | 0xc0, PS2_SYS_CTR); \
+ if (display_mode & LED_DISP) { \
+ if (id>9) \
+ outw((ad+48)|((id+55)<<8), MOD95_LED_PORT ); \
+ else \
+ outw((ad+48)|((id+48)<<8), MOD95_LED_PORT ); } \
+ else if (display_mode & LED_ADISP) { \
+ if (id<7) outb((char)(id+48),MOD95_LED_PORT+1+id); \
+ outb((char)(ad+48), MOD95_LED_PORT); } \
+ if ((display_mode & LED_ACTIVITY)||(!display_mode)) \
+ outb(inb(PS2_SYS_CTR) | 0xc0, PS2_SYS_CTR); \
}
-
+/* Panel / LED off */
/* bug fixed, Dec 15, 1997, where | was replaced by & here */
#define PS2_DISK_LED_OFF() {\
- if( use_display ) { outb( ' ', MOD95_LED_PORT ); \
- outb(' ', MOD95_LED_PORT+1); } \
- if ( use_adisplay ) { outb(' ',MOD95_LED_PORT ); \
- outb(' ',MOD95_LED_PORT+1); outb(' ',MOD95_LED_PORT+2); \
- outb(' ',MOD95_LED_PORT+3); outb(' ',MOD95_LED_PORT+4); \
- outb(' ',MOD95_LED_PORT+5); outb(' ',MOD95_LED_PORT+6); \
- outb(' ',MOD95_LED_PORT+7); } \
- else outb(inb(PS2_SYS_CTR) & 0x3f, PS2_SYS_CTR); \
+ if (display_mode & LED_DISP) \
+ outw(0x2020, MOD95_LED_PORT ); \
+ else if (display_mode & LED_ADISP) { \
+ outl(0x20202020,MOD95_LED_PORT); \
+ outl(0x20202020,MOD95_LED_PORT+4); } \
+ if ((display_mode & LED_ACTIVITY)||(!display_mode)) \
+ outb(inb(PS2_SYS_CTR) & 0x3f, PS2_SYS_CTR); \
}
/*--------------------------------------------------------------------*/
@@ -272,17 +319,29 @@
char *description;
};
+/* types of different supported hardware that goes to hostdata special */
+#define IBM_SCSI2_FW 0
+#define IBM_7568_WCACHE 1
+#define IBM_EXP_UNIT 2
+#define IBM_SCSI_WCACHE 3
+#define IBM_SCSI 4
+
+/* other special flags for hostdata structure */
+#define FORCED_DETECTION 100
+#define INTEGRATED_SCSI 101
+
/* List of possible IBM-SCSI-adapters */
struct subsys_list_struct subsys_list[] =
{
- {0x8efc, "IBM Fast SCSI-2 Adapter"}, /* special = 0 */
- {0x8efd, "IBM 7568 Industrial Computer SCSI Adapter w/cache"}, /* special = 1 */
+ {0x8efc, "IBM SCSI-2 F/W Adapter"}, /* special = 0 */
+ {0x8efd, "IBM 7568 Industrial Computer SCSI Adapter w/Cache"}, /* special = 1 */
{0x8ef8, "IBM Expansion Unit SCSI Controller"},/* special = 2 */
{0x8eff, "IBM SCSI Adapter w/Cache"}, /* special = 3 */
{0x8efe, "IBM SCSI Adapter"}, /* special = 4 */
};
-/*for /proc filesystem */
+/*for /proc filesystem, only valid in older kernel releases */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
struct proc_dir_entry proc_scsi_ibmmca =
{
PROC_SCSI_IBMMCA, 6, "ibmmca",
@@ -290,6 +349,7 @@
0, 0, 0, NULL, NULL, NULL, NULL,
NULL, NULL, NULL
};
+#endif
/* Max number of logical devices (can be up from 0 to 14). 15 is the address
of the adapter itself. */
@@ -302,11 +362,12 @@
struct im_tsb tsb; /* SCSI command complete status block structure */
struct im_sge sge[16]; /* scatter gather list structure */
unsigned char buf[256]; /* SCSI command return data buffer */
- Scsi_Cmnd *cmd; /* SCSI-command that is currently in progress */
-
+ Scsi_Cmnd *cmd; /* SCSI-command that is currently in progress */
int device_type; /* type of the SCSI-device. See include/scsi/scsi.h
for interpretation of the possible values */
int block_length;/* blocksize of a particular logical SCSI-device */
+ int cache_flag; /* 1 if this is uncached, 0 if cache is present for ldn */
+ int retry_flag; /* 1 if adapter retry is disabled, 0 if enabled */
};
/* statistics of the driver during operations (for proc_info) */
@@ -318,6 +379,8 @@
int ldn_write_access[MAX_LOG_DEV+1]; /* total write-access on a ldn */
int ldn_inquiry_access[MAX_LOG_DEV+1]; /* total inquiries on a ldn */
int ldn_modeselect_access[MAX_LOG_DEV+1]; /* total mode selects on ldn */
+ int scbs; /* short SCBs queued */
+ int long_scbs; /* long SCBs queued */
int total_accesses; /* total accesses on all ldns */
int total_interrupts; /* total interrupts (should be
same as total_accesses) */
@@ -336,10 +399,10 @@
/* array of logical devices: */
struct logical_device _ld[MAX_LOG_DEV+1];
/* array to convert (pun, lun) into logical device number: */
- unsigned char _get_ldn[8][8];
+ unsigned char _get_ldn[16][8];
/*array that contains the information about the physical SCSI-devices
attached to this host adapter: */
- unsigned char _get_scsi[8][8];
+ unsigned char _get_scsi[16][8];
/* used only when checking logical devices: */
int _local_checking_phase_flag;
/* report received interrupt: */
@@ -352,21 +415,30 @@
int _last_scsi_command[MAX_LOG_DEV+1];
/* identifier of the last SCSI-command type */
int _last_scsi_type[MAX_LOG_DEV+1];
+ /* last blockcount */
+ int _last_scsi_blockcount[MAX_LOG_DEV+1];
+ /* last locgical block address */
+ unsigned long _last_scsi_logical_block[MAX_LOG_DEV+1];
/* Counter that points on the next reassignable ldn for dynamical
remapping. The default value is 7, that is the first reassignable
number in the list at boottime: */
int _next_ldn;
/* Statistics-structure for this IBM-SCSI-host: */
struct Driver_Statistics _IBM_DS;
- /* This hostadapters pos-registers pos2 and pos3 */
- unsigned _pos2, _pos3;
+ /* This hostadapters pos-registers pos2 until pos6 */
+ unsigned _pos2, _pos3, _pos4, _pos5, _pos6;
/* assign a special variable, that contains dedicated info about the
adaptertype */
int _special;
+ /* connector size on the MCA bus */
+ int _connector_size;
+ /* synchronous SCSI transfer rate bitpattern */
+ int _adapter_speed;
};
/* macros to access host data structure */
#define subsystem_pun(hi) (hosts[(hi)]->this_id)
+#define subsystem_maxid(hi) (hosts[(hi)]->max_id)
#define ld(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_ld)
#define get_ldn(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_get_ldn)
#define get_scsi(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_get_scsi)
@@ -376,11 +448,19 @@
#define reset_status(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_reset_status)
#define last_scsi_command(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_last_scsi_command)
#define last_scsi_type(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_last_scsi_type)
+#define last_scsi_blockcount(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_last_scsi_blockcount)
+#define last_scsi_logical_block(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_last_scsi_logical_block)
+#define last_scsi_type(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_last_scsi_type)
#define next_ldn(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_next_ldn)
#define IBM_DS(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_IBM_DS)
#define special(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_special)
+#define subsystem_connector_size(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_connector_size)
+#define adapter_speed(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_adapter_speed)
#define pos2(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_pos2)
#define pos3(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_pos3)
+#define pos4(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_pos4)
+#define pos5(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_pos5)
+#define pos6(hi) (((struct ibmmca_hostdata *) hosts[(hi)]->hostdata)->_pos6)
/* Define a arbitrary number as subsystem-marker-type. This number is, as
described in the ANSI-SCSI-standard, not occupied by other device-types. */
@@ -412,10 +492,6 @@
#define IM_RESET_NOT_IN_PROGRESS_NO_INT 4
#define IM_RESET_FINISHED_OK_NO_INT 5
-/* special flags for hostdata structure */
-#define FORCED_DETECTION 100
-#define INTEGRATED_SCSI 101
-
/* define undefined SCSI-command */
#define NO_SCSI 0xffff
@@ -427,7 +503,10 @@
/* fill module-parameters only, when this define is present.
(that is kernel version 2.1.x) */
-#ifdef MODULE_PARM
+#if defined(MODULE)
+static char *boot_options = NULL;
+#include <linux/module.h>
+MODULE_PARM(boot_options, "s");
MODULE_PARM(io_port, "1-" __MODULE_STRING(IM_MAX_HOSTS) "i");
MODULE_PARM(scsi_id, "1-" __MODULE_STRING(IM_MAX_HOSTS) "i");
MODULE_PARM(display, "1i");
@@ -452,8 +531,10 @@
/* host information */
static int found = 0;
-static struct Scsi_Host *hosts[IM_MAX_HOSTS+1] = { NULL };
-static unsigned int pos[8]; /* whole pos register-line */
+static struct Scsi_Host *hosts[IM_MAX_HOSTS+1] = { NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL };
+static unsigned int pos[8]; /* whole pos register-line for diagnosis */
/* Taking into account the additions, made by ZP Gu.
* This selects now the preset value from the configfile and
* offers the 'normal' commandline option to be accepted */
@@ -473,25 +554,30 @@
#endif
static void issue_cmd (int, unsigned long, unsigned char);
static void internal_done (Scsi_Cmnd * cmd);
-static void check_devices (int);
+static void check_devices (int, int);
static int immediate_assign(int, unsigned int, unsigned int, unsigned int,
unsigned int);
+static int immediate_feature(int, unsigned int, unsigned int);
#ifdef CONFIG_IBMMCA_SCSI_DEV_RESET
static int immediate_reset(int, unsigned int);
#endif
static int device_inquiry(int, int);
static int read_capacity(int, int);
+static int get_pos_info(int);
static char *ti_p(int);
static char *ti_l(int);
+static char *ibmrate(unsigned int, int);
+static int probe_display(int);
+static int probe_bus_mode(int);
static int device_exists (int, int, int *, int *);
-static struct Scsi_Host *ibmmca_register(Scsi_Host_Template *,
- int, int, char *);
-
+static struct Scsi_Host *ibmmca_register(Scsi_Host_Template *,
+ int, int, int, char *);
/* local functions needed for proc_info */
static int ldn_access_load(int, int);
static int ldn_access_total_read_write(int);
static int bypass_controller = 0; /* bypass integrated SCSI-cmd set flag */
+
/*--------------------------------------------------------------------*/
/******************* LOCAL FUNCTIONS IMPLEMENTATION *************************/
@@ -515,20 +601,17 @@
unsigned int intr_reg;
unsigned int cmd_result;
unsigned int ldn;
- static unsigned long flags;
+ unsigned long flags;
Scsi_Cmnd *cmd;
- int errorflag;
- int interror;
-
- host_index=0; /* make sure, host_index is 0, else this won't work and
- never dare to ask, what happens, if an interrupt-handler
- does not work :-((( .... */
+ int lastSCSI;
+ host_index = 0; /* make sure, host_index is 0 */
+
/* search for one adapter-response on shared interrupt */
while (hosts[host_index]
&& !(inb(IM_STAT_REG(host_index)) & IM_INTR_REQUEST))
host_index++;
-
+
/* return if some other device on this IRQ caused the interrupt */
if (!hosts[host_index]) return;
@@ -541,11 +624,6 @@
return;
}
- /*get command result and logical device */
- intr_reg = inb (IM_INTR_REG(host_index));
- cmd_result = intr_reg & 0xf0;
- ldn = intr_reg & 0x0f;
-
/*must wait for attention reg not busy, then send EOI to subsystem */
while (1)
{
@@ -555,7 +633,8 @@
#else
spin_lock_irqsave(&intr_lock, flags);
#endif
- if (!(inb (IM_STAT_REG(host_index)) & IM_BUSY))
+ /* if (!(inb (IM_STAT_REG(host_index)) & IM_BUSY)) */
+ if ((inb(IM_STAT_REG(host_index)) & 0xf) == (IM_CMD_REG_EMPTY | IM_INTR_REQUEST))
break;
#ifdef OLDKERN
restore_flags(flags);
@@ -563,78 +642,107 @@
spin_unlock_irqrestore(&intr_lock, flags);
#endif
}
- outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+ /*get command result and logical device */
+ intr_reg = (unsigned char)(inb (IM_INTR_REG(host_index)));
+ cmd_result = intr_reg & 0xf0;
+ ldn = intr_reg & 0x0f;
+
/* get the last_scsi_command here */
- interror = last_scsi_command(host_index)[ldn];
-#ifdef OLDKERN
- restore_flags(flags);
-#else
- spin_unlock_irqrestore(&intr_lock, flags);
-#endif
- errorflag = 0; /* no errors by default */
+ lastSCSI = last_scsi_command(host_index)[ldn];
+
/*these should never happen (hw fails, or a local programming bug) */
- if (cmd_result == IM_ADAPTER_HW_FAILURE)
- {
- printk("\n");
- printk("IBM MCA SCSI: ERROR - subsystem hardware failure!\n");
- printk(" Last SCSI-command=0x%X, ldn=%d, host=%d.\n",
- last_scsi_command(host_index)[ldn],ldn,host_index);
- errorflag = 1;
- }
- if (cmd_result == IM_SOFTWARE_SEQUENCING_ERROR)
- {
- printk("\n");
- printk("IBM MCA SCSI: ERROR - software sequencing error!\n");
- printk(" Last SCSI-command=0x%X, ldn=%d, host=%d.\n",
- last_scsi_command(host_index)[ldn],ldn,host_index);
- errorflag = 1;
+ if (!global_command_error_excuse)
+ {
+ switch (cmd_result)
+ { /* Prevent from Ooopsing on error to show the real reason */
+ case IM_ADAPTER_HW_FAILURE:
+ case IM_SOFTWARE_SEQUENCING_ERROR:
+ case IM_CMD_ERROR:
+ printk("\nIBM MCA SCSI: Fatal Subsystem ERROR!\n");
+ printk(" Last cmd=0x%x, ena=%x, len=",lastSCSI,
+ ld(host_index)[ldn].scb.enable);
+ if (ld(host_index)[ldn].cmd)
+ printk("%ld/%ld",(long)(ld(host_index)[ldn].cmd->request_bufflen),
+ (long)(ld(host_index)[ldn].scb.sys_buf_length));
+ else
+ printk("none");
+ printk(", ");
+ if (ld(host_index)[ldn].cmd)
+ printk("Blocksize=%d",ld(host_index)[ldn].scb.u2.blk.length);
+ else
+ printk("Blocksize=none");
+ printk(", host=0x%x, ldn=0x%x\n",host_index, ldn);
+ if (ld(host_index)[ldn].cmd)
+ {
+ printk("Blockcount=%d/%d\n",last_scsi_blockcount(host_index)[ldn],
+ ld(host_index)[ldn].scb.u2.blk.count);
+ printk("Logical block=%lx/%lx\n",last_scsi_logical_block(host_index)[ldn],
+ ld(host_index)[ldn].scb.u1.log_blk_adr);
+ }
+ printk("Reason given: %s\n",
+ (cmd_result==IM_ADAPTER_HW_FAILURE) ? "HARDWARE FAILURE" :
+ (cmd_result==IM_SOFTWARE_SEQUENCING_ERROR) ? "SOFTWARE SEQUENCING ERROR" :
+ (cmd_result==IM_CMD_ERROR) ? "COMMAND ERROR" : "UNKNOWN");
+ /* if errors appear, enter this section to give detailed info */
+ printk("IBM MCA SCSI: Subsystem Error-Status follows:\n");
+ printk(" Command Type................: %x\n",
+ last_scsi_type(host_index)[ldn]);
+ printk(" Attention Register..........: %x\n",
+ inb (IM_ATTN_REG(host_index)));
+ printk(" Basic Control Register......: %x\n",
+ inb (IM_CTR_REG(host_index)));
+ printk(" Interrupt Status Register...: %x\n",
+ intr_reg);
+ printk(" Basic Status Register.......: %x\n",
+ inb (IM_STAT_REG(host_index)));
+ if ((last_scsi_type(host_index)[ldn]==IM_SCB)||
+ (last_scsi_type(host_index)[ldn]==IM_LONG_SCB))
+ {
+ printk(" SCB-Command.................: %x\n",
+ ld(host_index)[ldn].scb.command);
+ printk(" SCB-Enable..................: %x\n",
+ ld(host_index)[ldn].scb.enable);
+ printk(" SCB-logical block address...: %lx\n",
+ ld(host_index)[ldn].scb.u1.log_blk_adr);
+ printk(" SCB-system buffer address...: %lx\n",
+ ld(host_index)[ldn].scb.sys_buf_adr);
+ printk(" SCB-system buffer length....: %lx\n",
+ ld(host_index)[ldn].scb.sys_buf_length);
+ printk(" SCB-tsb address.............: %lx\n",
+ ld(host_index)[ldn].scb.tsb_adr);
+ printk(" SCB-Chain address...........: %lx\n",
+ ld(host_index)[ldn].scb.scb_chain_adr);
+ printk(" SCB-block count.............: %x\n",
+ ld(host_index)[ldn].scb.u2.blk.count);
+ printk(" SCB-block length............: %x\n",
+ ld(host_index)[ldn].scb.u2.blk.length);
+ }
+ printk(" Send this report to the maintainer.\n");
+ panic("IBM MCA SCSI: Fatal errormessage from the subsystem (0x%X,0x%X)!\n",
+ lastSCSI,cmd_result);
+ break;
+ }
}
- if (cmd_result == IM_CMD_ERROR)
- {
- printk("\n");
- printk("IBM MCA SCSI: ERROR - command error!\n");
- printk(" Last SCSI-command=0x%X, ldn=%d, host=%d.\n",
- last_scsi_command(host_index)[ldn],ldn,host_index);
- errorflag = 1;
- }
- if (errorflag)
- { /* if errors appear, enter this section to give detailed info */
- printk("IBM MCA SCSI: Subsystem Error-Status follows:\n");
- printk(" Command Type................: %x\n",
- last_scsi_type(host_index)[ldn]);
- printk(" Attention Register..........: %x\n",
- inb (IM_ATTN_REG(host_index)));
- printk(" Basic Control Register......: %x\n",
- inb (IM_CTR_REG(host_index)));
- printk(" Interrupt Status Register...: %x\n",
- intr_reg);
- printk(" Basic Status Register.......: %x\n",
- inb (IM_STAT_REG(host_index)));
- if ((last_scsi_type(host_index)[ldn]==IM_SCB)||
- (last_scsi_type(host_index)[ldn]==IM_LONG_SCB))
- {
- printk(" SCB End Status Word.........: %x\n",
- ld(host_index)[ldn].tsb.end_status);
- printk(" Command Status..............: %x\n",
- ld(host_index)[ldn].tsb.cmd_status);
- printk(" Device Status...............: %x\n",
- ld(host_index)[ldn].tsb.dev_status);
- printk(" Command Error...............: %x\n",
- ld(host_index)[ldn].tsb.cmd_error);
- printk(" Device Error................: %x\n",
- ld(host_index)[ldn].tsb.dev_error);
- printk(" Last SCB Address (LSW)......: %x\n",
- ld(host_index)[ldn].tsb.low_of_last_scb_adr);
- printk(" Last SCB Address (MSW)......: %x\n",
- ld(host_index)[ldn].tsb.high_of_last_scb_adr);
+ else
+ { /* The command error handling is made silent, but we tell the
+ * calling function, that there is a reported error from the
+ * adapter. */
+ switch (cmd_result)
+ {
+ case IM_ADAPTER_HW_FAILURE:
+ case IM_SOFTWARE_SEQUENCING_ERROR:
+ case IM_CMD_ERROR:
+ global_command_error_excuse = CMD_FAIL;
+ break;
+ default:
+ global_command_error_excuse = 0;
+ break;
}
- printk(" Send report to the maintainer.\n");
- panic("IBM MCA SCSI: Fatal errormessage from the subsystem!\n");
- }
+ }
/* if no panic appeared, increase the interrupt-counter */
IBM_DS(host_index).total_interrupts++;
-
+
/*only for local checking phase */
if (local_checking_phase_flag(host_index))
{
@@ -642,6 +750,13 @@
got_interrupt(host_index) = 1;
reset_status(host_index) = IM_RESET_FINISHED_OK;
last_scsi_command(host_index)[ldn] = NO_SCSI;
+
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
return;
}
/*handling of commands coming from upper level of scsi driver */
@@ -668,6 +783,13 @@
}
stat_result(host_index) = cmd_result;
last_scsi_command(host_index)[ldn] = NO_SCSI;
+ last_scsi_type(host_index)[ldn] = 0;
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
return;
}
else if (last_scsi_command(host_index)[ldn] == IM_ABORT_IMM_CMD)
@@ -678,14 +800,22 @@
disk_rw_in_progress = 0;
PS2_DISK_LED_OFF();
cmd = ld(host_index)[ldn].cmd;
+ ld(host_index)[ldn].cmd = NULL;
if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE)
cmd->result = DID_NO_CONNECT << 16;
else
cmd->result = DID_ABORT << 16;
stat_result(host_index) = cmd_result;
last_scsi_command(host_index)[ldn] = NO_SCSI;
+ last_scsi_type(host_index)[ldn] = 0;
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
if (cmd->scsi_done)
- (cmd->scsi_done) (cmd); /* should be the internal_done */
+ (cmd->scsi_done)(cmd); /* should be the internal_done */
return;
}
else
@@ -695,26 +825,49 @@
reset_status(host_index) = IM_RESET_FINISHED_OK;
stat_result(host_index) = cmd_result;
last_scsi_command(host_index)[ldn] = NO_SCSI;
+
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
return;
}
}
- last_scsi_command(host_index)[ldn] = NO_SCSI;
+ last_scsi_command(host_index)[ldn] = NO_SCSI;
+ last_scsi_type(host_index)[ldn] = 0;
cmd = ld(host_index)[ldn].cmd;
+ ld(host_index)[ldn].cmd = NULL;
#ifdef IM_DEBUG_TIMEOUT
if (cmd)
{
- if ((cmd->target == TIMEOUT_PUN)&&(cmd->lun == TIMEOUT_LUN))
+ if ((cmd->target == TIMEOUT_PUN)&&
+ (cmd->lun == TIMEOUT_LUN))
{
printk("IBM MCA SCSI: Ignoring interrupt from pun=%x, lun=%x.\n",
cmd->target, cmd->lun);
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
return;
}
}
#endif
/*if no command structure, just return, else clear cmd */
if (!cmd)
- return;
- ld(host_index)[ldn].cmd = NULL;
+ {
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
+ return;
+ }
#ifdef IM_DEBUG_INT
printk("cmd=%02x ireg=%02x ds=%02x cs=%02x de=%02x ce=%02x\n",
@@ -743,19 +896,37 @@
}
/* IBM describes the status-mask to be 0x1e, but this is not conform
- * with SCSI-defintion, I suppose, it is a printing error in the
- * technical reference and assume as mask 0x3e. (ML) */
- cmd->result = (ld(host_index)[ldn].tsb.dev_status & 0x3e);
- /* write device status into cmd->result, and call done function */
+ * with SCSI-defintion, I suppose, the reason for it is that IBM
+ * adapters do not support CMD_TERMINATED, TASK_SET_FULL and
+ * ACA_ACTIVE as returning statusbyte information. (ML) */
if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE)
- IBM_DS(host_index).total_errors++;
- if (interror == NO_SCSI) /* unexpected interrupt :-( */
- cmd->result |= DID_BAD_INTR << 16;
+ {
+ cmd->result = (unsigned char)(ld(host_index)[ldn].tsb.dev_status & 0x1e);
+ IBM_DS(host_index).total_errors++;
+ }
else
+ cmd->result = 0;
+ /* write device status into cmd->result, and call done function */
+ if (lastSCSI == NO_SCSI) /* unexpected interrupt :-( */
+ cmd->result |= DID_BAD_INTR << 16;
+ else /* things went right :-) */
cmd->result |= DID_OK << 16;
- (cmd->scsi_done) (cmd);
- }
- if (interror == NO_SCSI)
+ outb (IM_EOI | ldn, IM_ATTN_REG(host_index));
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&intr_lock, flags);
+#endif
+ /* This is for Kernel 2.2.x. Something weired happens here.
+ * Between the command got queued and the interrupt is released,
+ * the flags sometimes contain different values, which must
+ * be a strange thing. E.g. it appears when cold-booting with a
+ * tape drive at id0. */
+ cmd->flags &= 0x3f;
+ if (cmd->scsi_done)
+ (cmd->scsi_done)(cmd);
+ }
+ if (lastSCSI == NO_SCSI)
printk("IBM MCA SCSI: WARNING - Interrupt from non-pending SCSI-command!\n");
return;
}
@@ -775,7 +946,7 @@
#else
spin_lock_irqsave(&issue_lock, flags);
#endif
- if (!(inb (IM_STAT_REG(host_index)) & IM_BUSY))
+ if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
break;
#ifdef OLDKERN
restore_flags(flags);
@@ -791,6 +962,7 @@
#else
spin_unlock_irqrestore(&issue_lock, flags);
#endif
+ return;
}
/*--------------------------------------------------------------------*/
@@ -798,6 +970,7 @@
static void internal_done (Scsi_Cmnd * cmd)
{
cmd->SCp.Status++;
+ return;
}
/*--------------------------------------------------------------------*/
@@ -827,18 +1000,18 @@
{
if (bypass_controller)
{ /* bypass the hardware integrated command set */
- scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
+ scb->command = IM_OTHER_SCSI_CMD_CMD | IM_NO_DISCONNECT;
+ scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd.cmd_len;
memcpy (scb->u2.scsi_command, &(cmd.cmnd), cmd.cmd_len);
last_scsi_command(host_index)[ldn] = INQUIRY;
- last_scsi_type(host_index)[ldn] = IM_SCB;
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
{
/*fill scb with inquiry command */
- scb->command = IM_DEVICE_INQUIRY_CMD;
- scb->enable = IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
+ scb->command = IM_DEVICE_INQUIRY_CMD | IM_NO_DISCONNECT;
+ scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
last_scsi_command(host_index)[ldn] = IM_DEVICE_INQUIRY_CMD;
last_scsi_type(host_index)[ldn] = IM_SCB;
}
@@ -848,16 +1021,17 @@
/*issue scb to passed ldn, and busy wait for interrupt */
got_interrupt(host_index) = 0;
- issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
+ if ((scb->command & IM_OTHER_SCSI_CMD_CMD) == IM_OTHER_SCSI_CMD_CMD)
+ issue_cmd (host_index, virt_to_bus(scb), IM_LONG_SCB | ldn);
+ else
+ issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
while (!got_interrupt(host_index))
barrier ();
/*if command succesful, break */
if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED)||
(stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
- {
- return 1;
- }
+ return 1;
}
/*if all three retries failed, return "no device at this ldn" */
@@ -892,7 +1066,7 @@
if (bypass_controller)
{ /* bypass the SCSI-command */
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd.cmd_len;
memcpy (scb->u2.scsi_command, &(cmd.cmnd), cmd.cmd_len);
last_scsi_command(host_index)[ldn] = READ_CAPACITY;
@@ -901,7 +1075,7 @@
else
{
scb->command = IM_READ_CAPACITY_CMD;
- scb->enable = IM_READ_CONTROL;
+ scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
last_scsi_command(host_index)[ldn] = IM_READ_CAPACITY_CMD;
last_scsi_type(host_index)[ldn] = IM_SCB;
}
@@ -911,16 +1085,17 @@
/*issue scb to passed ldn, and busy wait for interrupt */
got_interrupt(host_index) = 0;
- issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
+ if ((scb->command & IM_OTHER_SCSI_CMD_CMD) == IM_OTHER_SCSI_CMD_CMD)
+ issue_cmd (host_index, virt_to_bus(scb), IM_LONG_SCB | ldn);
+ else
+ issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
while (!got_interrupt(host_index))
barrier ();
- /*if got capacity, get block length and return one device found */
+ /*if got capacity, get block length and return one device found */
if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED)||
(stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
- {
- return 1;
- }
+ return 1;
}
/*if all three retries failed, return "no device at this ldn" */
if (retries >= 3)
@@ -929,6 +1104,52 @@
return 1;
}
+static int get_pos_info(int host_index)
+{
+ int retries;
+ struct im_scb *scb;
+ struct im_tsb *tsb;
+ unsigned char *buf;
+
+ scb = &(ld(host_index)[MAX_LOG_DEV].scb);
+ tsb = &(ld(host_index)[MAX_LOG_DEV].tsb);
+ buf = (unsigned char *)(&(ld(host_index)[MAX_LOG_DEV].buf));
+ ld(host_index)[MAX_LOG_DEV].tsb.dev_status = 0;
+
+ for (retries = 0; retries < 3; retries++)
+ {
+ /*fill scb with get_pos_info command */
+ scb->command = IM_GET_POS_INFO_CMD;
+ scb->enable = IM_READ_CONTROL | IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE | IM_BYPASS_BUFFER | IM_SUPRESS_EXCEPTION_SHORT;
+ last_scsi_command(host_index)[MAX_LOG_DEV] = IM_GET_POS_INFO_CMD;
+ last_scsi_type(host_index)[MAX_LOG_DEV] = IM_SCB;
+
+ scb->sys_buf_adr = virt_to_bus(buf);
+ if (special(host_index)==IBM_SCSI2_FW)
+ scb->sys_buf_length = 256; /* get all info from F/W adapter */
+ else
+ scb->sys_buf_length = 18; /* get exactly 18 bytes for other SCSI */
+
+ scb->tsb_adr = virt_to_bus(tsb);
+
+ /*issue scb to ldn=15, and busy wait for interrupt */
+ got_interrupt(host_index) = 0;
+ issue_cmd (host_index, virt_to_bus(scb), IM_SCB | MAX_LOG_DEV);
+ while (!got_interrupt(host_index))
+ barrier ();
+
+ /*if got POS-stuff, get block length and return one device found */
+ if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED)||
+ (stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
+ return 1;
+ }
+ /* if all three retries failed, return "no device at this ldn" */
+ if (retries >= 3)
+ return 0;
+ else
+ return 1;
+}
+
/* SCSI-immediate-command for assign. This functions maps/unmaps specific
ldn-numbers on SCSI (PUN,LUN). It is needed for presetting of the
subsystem and for dynamical remapping od ldns. */
@@ -941,26 +1162,80 @@
for (retries=0; retries<3; retries ++)
{
- imm_command = inl(IM_CMD_REG(host_index));
- imm_command &= (unsigned long)(0xF8000000); /* keep reserved bits */
- imm_command |= (unsigned long)(IM_ASSIGN_IMM_CMD);
- imm_command |= (unsigned long)((lun & 7) << 24);
- imm_command |= (unsigned long)((operation & 1) << 23);
- imm_command |= (unsigned long)((pun & 7) << 20);
- imm_command |= (unsigned long)((ldn & 15) << 16);
-
- last_scsi_command(host_index)[0xf] = IM_ASSIGN_IMM_CMD;
- last_scsi_type(host_index)[0xf] = IM_IMM_CMD;
+ /* select mutation level of the SCSI-adapter */
+ switch (special(host_index))
+ {
+ case IBM_SCSI2_FW:
+ imm_command = (unsigned long)(IM_ASSIGN_IMM_CMD);
+ imm_command |= (unsigned long)((lun & 7) << 24);
+ imm_command |= (unsigned long)((operation & 1) << 23);
+ imm_command |= (unsigned long)((pun & 7)<< 20)|((pun & 8)<< 24);
+ imm_command |= (unsigned long)((ldn & 15) << 16);
+ break;
+ default:
+ imm_command = inl(IM_CMD_REG(host_index));
+ imm_command &= (unsigned long)(0xF8000000); /* keep reserved bits */
+ imm_command |= (unsigned long)(IM_ASSIGN_IMM_CMD);
+ imm_command |= (unsigned long)((lun & 7) << 24);
+ imm_command |= (unsigned long)((operation & 1) << 23);
+ imm_command |= (unsigned long)((pun & 7) << 20);
+ imm_command |= (unsigned long)((ldn & 15) << 16);
+ break;
+ }
+ last_scsi_command(host_index)[MAX_LOG_DEV] = IM_ASSIGN_IMM_CMD;
+ last_scsi_type(host_index)[MAX_LOG_DEV] = IM_IMM_CMD;
got_interrupt(host_index) = 0;
- issue_cmd (host_index, (unsigned long)(imm_command), IM_IMM_CMD | 0xf);
+ issue_cmd (host_index, (unsigned long)(imm_command), IM_IMM_CMD | MAX_LOG_DEV);
while (!got_interrupt(host_index))
barrier ();
/*if command succesful, break */
if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
+ return 1;
+ }
+ if (retries >= 3)
+ return 0;
+ else
+ return 1;
+}
+
+static int immediate_feature(int host_index, unsigned int speed,
+ unsigned int timeout)
+{
+ int retries;
+ unsigned long imm_command;
+
+ for (retries=0; retries<3; retries ++)
+ {
+ /* select mutation level of the SCSI-adapter */
+ switch (special(host_index))
{
- return 1;
+ default:
+ imm_command = IM_FEATURE_CTR_IMM_CMD;
+ imm_command |= (unsigned long)((speed & 0x7) << 29);
+ imm_command |= (unsigned long)((timeout & 0x1fff) << 16);
+ break;
+ }
+ last_scsi_command(host_index)[MAX_LOG_DEV] = IM_FEATURE_CTR_IMM_CMD;
+ last_scsi_type(host_index)[MAX_LOG_DEV] = IM_IMM_CMD;
+ got_interrupt(host_index) = 0;
+ /* we need to run into command errors in order to probe for the
+ * right speed! */
+ global_command_error_excuse = 1;
+ issue_cmd (host_index, (unsigned long)(imm_command), IM_IMM_CMD | MAX_LOG_DEV);
+ while (!got_interrupt(host_index))
+ barrier ();
+ if (global_command_error_excuse == CMD_FAIL)
+ {
+ global_command_error_excuse = 0;
+ return 2;
}
+ else
+ global_command_error_excuse = 0;
+
+ /*if command succesful, break */
+ if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
+ return 1;
}
if (retries >= 3)
@@ -1004,9 +1279,7 @@
}
/*if command succesful, break */
if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
- {
- return 1;
- }
+ return 1;
}
if (retries >= 3)
@@ -1052,6 +1325,97 @@
return (char *)&answer;
}
+/* transfers bitpattern of the feature command to values in MHz */
+static char *ibmrate(unsigned int speed, int adaptertype)
+{
+ int i;
+ i=adaptertype;
+ switch (speed)
+ {
+ case 0: if (i) return "5.00"; else return "10.00"; break;
+ case 1: if (i) return "4.00"; else return "8.00"; break;
+ case 2: if (i) return "3.33"; else return "6.66"; break;
+ case 3: if (i) return "2.86"; else return "5.00"; break;
+ case 4: if (i) return "2.50"; else return "4.00"; break;
+ case 5: if (i) return "2.22"; else return "3.10"; break;
+ case 6: if (i) return "2.00"; else return "2.50"; break;
+ case 7: if (i) return "1.82"; else return "2.00"; break;
+ }
+ return "---";
+}
+
+static int probe_display(int what)
+{
+ static int rotator = 0;
+ const char rotor[] = "|/-\\";
+
+ if (!(display_mode & LED_DISP))
+ return 0;
+ if (!what)
+ {
+ outl(0x20202020,MOD95_LED_PORT);
+ outl(0x20202020,MOD95_LED_PORT+4);
+ }
+ else
+ {
+ outb('S',MOD95_LED_PORT+7);
+ outb('C',MOD95_LED_PORT+6);
+ outb('S',MOD95_LED_PORT+5);
+ outb('I',MOD95_LED_PORT+4);
+ outb('i',MOD95_LED_PORT+3);
+ outb('n',MOD95_LED_PORT+2);
+ outb('i',MOD95_LED_PORT+1);
+ outb((char)(rotor[rotator]),MOD95_LED_PORT);
+ rotator++;
+ if (rotator>3)
+ rotator=0;
+ }
+ return 0;
+}
+
+static int probe_bus_mode(int host_index)
+{
+ struct im_pos_info *info;
+ int num_bus = 0;
+ int ldn;
+
+ info = (struct im_pos_info *)(&(ld(host_index)[MAX_LOG_DEV].buf));
+
+ if (get_pos_info(host_index))
+ {
+ if (info->connector_size & 0xf000)
+ subsystem_connector_size(host_index)=16;
+ else
+ subsystem_connector_size(host_index)=32;
+ num_bus |= (info->pos_4b & 8) >> 3;
+ for (ldn=0; ldn<=MAX_LOG_DEV; ldn++)
+ {
+ if ((special(host_index)==IBM_SCSI_WCACHE)||
+ (special(host_index)==IBM_7568_WCACHE))
+ {
+ if (!((info->cache_stat >> ldn) & 1))
+ ld(host_index)[ldn].cache_flag = 0;
+ }
+ if (!((info->retry_stat >> ldn) & 1))
+ ld(host_index)[ldn].retry_flag = 0;
+ }
+#ifdef IM_DEBUG_PROBE
+ printk("IBM MCA SCSI: SCSI-Cache bits: ");
+ for (ldn=0; ldn<=MAX_LOG_DEV; ldn++)
+ {
+ printk("%d",ld(host_index)[ldn].cache_flag);
+ }
+ printk("\nIBM MCA SCSI: SCSI-Retry bits: ");
+ for (ldn=0; ldn<=MAX_LOG_DEV; ldn++)
+ {
+ printk("%d",ld(host_index)[ldn].retry_flag);
+ }
+ printk("\n");
+#endif
+ }
+ return num_bus;
+}
+
/*
The following routine probes the SCSI-devices in four steps:
1. The current ldn -> pun,lun mapping is removed on the SCSI-adapter.
@@ -1072,27 +1436,31 @@
The assignment of ALL ldns avoids dynamical remapping by the adapter
itself.
*/
-static void check_devices (int host_index)
+static void check_devices (int host_index, int adaptertype)
{
int id, lun, ldn, ticks;
int count_devices; /* local counter for connected device */
-
+ int max_pun;
+ int num_bus;
+ int speedrun; /* local adapter_speed check variable */
+
/* assign default values to certain variables */
-
ticks = 0;
count_devices = 0;
IBM_DS(host_index).dyn_flag = 0; /* normally no need for dynamical ldn management */
IBM_DS(host_index).total_errors = 0; /* set errorcounter to 0 */
next_ldn(host_index) = 7; /* next ldn to be assigned is 7, because 0-6 is 'hardwired'*/
+
+ /* initialize the very important driver-informational arrays/structs */
+ memset (ld(host_index), 0,
+ sizeof(ld(host_index)));
for (ldn=0; ldn<=MAX_LOG_DEV; ldn++)
{
last_scsi_command(host_index)[ldn] = NO_SCSI; /* emptify last SCSI-command storage */
last_scsi_type(host_index)[ldn] = 0;
+ ld(host_index)[ldn].cache_flag = 1;
+ ld(host_index)[ldn].retry_flag = 1;
}
-
- /* initialize the very important driver-informational arrays/structs */
- memset (ld(host_index), 0,
- sizeof(ld(host_index)));
memset (get_ldn(host_index), TYPE_NO_DEVICE,
sizeof(get_ldn(host_index))); /* this is essential ! */
memset (get_scsi(host_index), TYPE_NO_DEVICE,
@@ -1105,14 +1473,59 @@
ldn is active for all
luns. */
}
+
+ probe_display(0); /* Supercool display usage during SCSI-probing. */
+ /* This makes sense, when booting without any */
+ /* monitor connected on model XX95. */
/* STEP 1: */
+ adapter_speed(host_index) = global_adapter_speed;
+ speedrun = adapter_speed(host_index);
+ while (immediate_feature(host_index,speedrun,adapter_timeout)==2)
+ {
+ probe_display(1);
+ if (speedrun==7)
+ panic("IBM MCA SCSI: Cannot set Synchronous-Transfer-Rate!\n");
+ speedrun++;
+ if (speedrun>7)
+ speedrun=7;
+ }
+ adapter_speed(host_index) = speedrun;
+ /* Get detailed information about the current adapter, necessary for
+ * device operations: */
+ num_bus=probe_bus_mode(host_index);
+
+ /* num_bus contains only valid data for the F/W adapter! */
+ if (adaptertype==IBM_SCSI2_FW) /* F/W SCSI adapter: */
+ {
+ /* F/W adapter PUN-space extension evaluation: */
+ if (num_bus)
+ {
+ printk("IBM MCA SCSI: Seperate bus mode (wide-addressing enabled)\n");
+ subsystem_maxid(host_index) = 16;
+ }
+ else
+ {
+ printk("IBM MCA SCSI: Combined bus mode (wide-addressing disabled)\n");
+ subsystem_maxid(host_index) = 8;
+ }
+ printk("IBM MCA SCSI: Sync.-Rate (F/W: 20, Int.: 10, Ext.: %s) MBytes/s\n",
+ ibmrate(speedrun,adaptertype));
+ }
+ else /* all other IBM SCSI adapters: */
+ printk("IBM MCA SCSI: Synchronous-SCSI-Transfer-Rate: %s MBytes/s\n",
+ ibmrate(speedrun,adaptertype));
+
+ /* assign correct PUN device space */
+ max_pun = subsystem_maxid(host_index);
+
#ifdef IM_DEBUG_PROBE
printk("IBM MCA SCSI: Current SCSI-host index: %d\n",host_index);
#endif
printk("IBM MCA SCSI: Removing default logical SCSI-device mapping.");
for (ldn=0; ldn<MAX_LOG_DEV; ldn++)
{
+ probe_display(1);
#ifdef IM_DEBUG_PROBE
printk(".");
#endif
@@ -1122,19 +1535,25 @@
lun = 0; /* default lun is 0 */
/* STEP 2: */
- printk("\nIBM MCA SCSI: Probing SCSI-devices.");
- for (id=0; id<8; id++)
+ printk("\nIBM MCA SCSI: Probing SCSI-devices");
+#ifndef IM_DEBUG_PROBE
+ printk(" (this can take up to 2 minutes)");
+#endif
+ printk(".");
+
+ for (id=0; id<max_pun ; id++)
#ifdef CONFIG_SCSI_MULTI_LUN
for (lun=0; lun<8; lun++)
#endif
{
+ probe_display(1);
#ifdef IM_DEBUG_PROBE
printk(".");
#endif
if (id != subsystem_pun(host_index))
{ /* if pun is not the adapter: */
/*set ldn=0 to pun,lun*/
- immediate_assign(host_index,id,lun,PROBE_LDN,SET_LDN);
+ immediate_assign(host_index,id,lun,PROBE_LDN,SET_LDN);
if (device_inquiry(host_index, PROBE_LDN)) /* probe device */
{
get_scsi(host_index)[id][lun]=
@@ -1144,7 +1563,7 @@
count_devices++; /* a existing device is found */
}
/* remove ldn */
- immediate_assign(host_index,id,lun,PROBE_LDN,REMOVE_LDN);
+ immediate_assign(host_index,id,lun,PROBE_LDN,REMOVE_LDN);
}
}
@@ -1157,8 +1576,9 @@
#ifdef CONFIG_SCSI_MULTI_LUN
for (lun=0; lun<8 && ldn<MAX_LOG_DEV; lun++)
#endif
- for (id=0; id<8 && ldn<MAX_LOG_DEV; id++)
+ for (id=0; id<max_pun && ldn<MAX_LOG_DEV; id++)
{
+ probe_display(1);
#ifdef IM_DEBUG_PROBE
printk(".");
#endif
@@ -1208,11 +1628,12 @@
/* map remaining ldns to non-existing devices */
for (lun=1; lun<8 && ldn<MAX_LOG_DEV; lun++)
- for (id=0; id<8 && ldn<MAX_LOG_DEV; id++)
+ for (id=0; id<max_pun && ldn<MAX_LOG_DEV; id++)
{
if (get_scsi(host_index)[id][lun] == TYPE_NO_LUN ||
get_scsi(host_index)[id][lun] == TYPE_NO_DEVICE)
{
+ probe_display(1);
/* Map remaining ldns only to NON-existing pun,lun
combinations to make sure an inquiry will fail.
For MULTI_LUN, it is needed to avoid adapter autonome
@@ -1234,7 +1655,7 @@
printk("IBM MCA SCSI: Determined SCSI-device-mapping:\n");
printk(" Physical SCSI-Device Map Logical SCSI-Device Map\n");
printk("ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n");
- for (id=0; id<8; id++)
+ for (id=0; id<max_pun; id++)
{
printk("%2d ",id);
for (lun=0; lun<8; lun++)
@@ -1261,6 +1682,8 @@
printk("IBM MCA SCSI: Warning: No SCSI-devices found/assigned!\n");
/* reset the counters for statistics on the current adapter */
+ IBM_DS(host_index).scbs = 0;
+ IBM_DS(host_index).long_scbs = 0;
IBM_DS(host_index).total_accesses = 0;
IBM_DS(host_index).total_interrupts = 0;
IBM_DS(host_index).dynamical_assignments = 0;
@@ -1276,7 +1699,7 @@
sizeof (IBM_DS(host_index).ldn_modeselect_access));
memset (IBM_DS(host_index).ldn_assignments, 0x0,
sizeof (IBM_DS(host_index).ldn_assignments));
-
+ probe_display(0);
return;
}
@@ -1375,7 +1798,7 @@
#ifdef CONFIG_SCSI_IBMMCA
-void ibmmca_scsi_setup (char *str, int *ints)
+void internal_ibmmca_scsi_setup (char *str, int *ints)
{
int i, j, io_base, id_base;
char *token;
@@ -1389,36 +1812,30 @@
j = 0;
while (token)
{
+ if (!strcmp(token,"activity"))
+ display_mode |= LED_ACTIVITY;
if (!strcmp(token,"display"))
- {
- use_display = 1;
- }
+ display_mode |= LED_DISP;
if (!strcmp(token,"adisplay"))
- {
- use_adisplay = 1;
- }
+ display_mode |= LED_ADISP;
if (!strcmp(token,"bypass"))
- {
- bypass_controller = 1;
- }
+ bypass_controller = 1;
if (!strcmp(token,"normal"))
- {
- ibm_ansi_order = 0;
- }
+ ibm_ansi_order = 0;
if (!strcmp(token,"ansi"))
- {
- ibm_ansi_order = 1;
- }
+ ibm_ansi_order = 1;
+ if (!strcmp(token,"fast"))
+ global_adapter_speed = 0;
+ if (!strcmp(token,"medium"))
+ global_adapter_speed = 4;
+ if (!strcmp(token,"slow"))
+ global_adapter_speed = 7;
if ( (*token == '-') || (isdigit(*token)) )
{
if (!(j%2) && (io_base < IM_MAX_HOSTS))
- {
- io_port[io_base++] = simple_strtoul(token,NULL,0);
- }
+ io_port[io_base++] = simple_strtoul(token,NULL,0);
if ((j%2) && (id_base < IM_MAX_HOSTS))
- {
- scsi_id[id_base++] = simple_strtoul(token,NULL,0);
- }
+ scsi_id[id_base++] = simple_strtoul(token,NULL,0);
j++;
}
token = strtok(NULL,",");
@@ -1442,7 +1859,7 @@
static int ibmmca_getinfo (char *buf, int slot, void *dev)
{
struct Scsi_Host *shpnt;
- int len, special;
+ int len, speciale,connectore;
unsigned int pos2, pos3;
static unsigned long flags;
@@ -1456,21 +1873,22 @@
shpnt = dev; /* assign host-structure to local pointer */
len = 0; /* set filled text-buffer index to 0 */
/* get the _special contents of the hostdata structure */
- special = ((struct ibmmca_hostdata *)shpnt->hostdata)->_special;
+ speciale = ((struct ibmmca_hostdata *)shpnt->hostdata)->_special;
+ connectore = ((struct ibmmca_hostdata *)shpnt->hostdata)->_connector_size;
pos2 = ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos2;
pos3 = ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos3;
- if (special == FORCED_DETECTION) /* forced detection */
+ if (speciale == FORCED_DETECTION) /* forced detection */
{
- len += sprintf (buf + len, "Adapter cathegory: forced detected\n");
+ len += sprintf (buf + len, "Adapter category: forced detected\n");
len += sprintf(buf + len, "***************************************\n");
len += sprintf(buf + len, "*** Forced detected SCSI Adapter ***\n");
len += sprintf(buf + len, "*** No chip-information available ***\n");
len += sprintf(buf + len, "***************************************\n");
}
- else if (special == INTEGRATED_SCSI)
+ else if (speciale == INTEGRATED_SCSI)
{ /* if the integrated subsystem has been found automatically: */
- len += sprintf (buf + len, "Adapter cathegory: integrated\n");
+ len += sprintf (buf + len, "Adapter category: integrated\n");
len += sprintf (buf + len, "Chip revision level: %d\n",
((pos2 & 0xf0) >> 4));
len += sprintf (buf + len, "Chip status: %s\n",
@@ -1478,27 +1896,32 @@
len += sprintf (buf + len, "8 kByte NVRAM status: %s\n",
(pos2 & 2) ? "locked" : "accessible");
}
- else if ((special>=0)&&
- (special<(sizeof(subsys_list)/sizeof(struct subsys_list_struct))))
- { /* if the subsystem is a slot adapter */
- len += sprintf (buf + len, "Adapter cathegory: slot-card\n");
- len += sprintf (buf + len, "Chip revision level: %d\n",
- ((pos2 & 0xf0) >> 4));
+ else if ((speciale>=0)&&
+ (speciale<(sizeof(subsys_list)/sizeof(struct subsys_list_struct))))
+ { /* if the subsystem is a slot adapter */
+ len += sprintf (buf + len, "Adapter category: slot-card\n");
+ len += sprintf (buf + len, "ROM Segment Address: ");
+ if ((pos2 & 0xf0) == 0xf0)
+ len += sprintf (buf + len, "off\n");
+ else
+ len += sprintf (buf + len, "0x%x\n",
+ ((pos2 & 0xf0) << 13) + 0xc0000);
len += sprintf (buf + len, "Chip status: %s\n",
(pos2 & 1) ? "enabled" : "disabled");
- len += sprintf (buf + len, "Port offset: 0x%x\n",
+ len += sprintf (buf + len, "Adapter I/O Offset: 0x%x\n",
((pos2 & 0x0e) << 2));
}
else
{
- len += sprintf (buf + len, "Adapter cathegory: unknown\n");
+ len += sprintf (buf + len, "Adapter category: unknown\n");
}
/* common subsystem information to write to the slotn file */
len += sprintf (buf + len, "Subsystem PUN: %d\n", shpnt->this_id);
- len += sprintf (buf + len, "I/O base address range: 0x%x-0x%x",
+ len += sprintf (buf + len, "I/O base address range: 0x%x-0x%x\n",
(unsigned int)(shpnt->io_port),
(unsigned int)(shpnt->io_port+7));
- /* Now make sure, the bufferlength is devideable by 4 to avoid
+ len += sprintf (buf + len, "MCA-slot size: %d bits",connectore);
+ /* Now make sure, the bufferlength is devidable by 4 to avoid
* paging problems of the buffer. */
while ( len % sizeof( int ) != ( sizeof ( int ) - 1 ) )
{
@@ -1518,17 +1941,31 @@
{
struct Scsi_Host *shpnt;
int port, id, i, j, list_size, slot;
+ int devices_on_irq_11 = 0;
+ int devices_on_irq_14 = 0;
+ int IRQ14_registered = 0;
+ int IRQ11_registered = 0;
found = 0; /* make absolutely sure, that found is set to 0 */
-
+
+ /* First of all, print the version number of the driver. This is
+ * important to allow better user bugreports in case of already
+ * having problems with the MCA_bus probing. */
+ printk("IBM MCA SCSI: Version %s\n",IBMMCA_SCSI_DRIVER_VERSION);
/* if this is not MCA machine, return "nothing found" */
if (!MCA_bus)
{
- printk("IBM MCA SCSI: No Microchannel-bus support present -> Aborting.\n");
+ printk("IBM MCA SCSI: No Microchannel-bus present --> Aborting.\n");
+ printk(" This machine does not have any IBM MCA-bus\n");
+ printk(" or the MCA-Kernel-support is not enabled!\n");
return 0;
}
- else
- printk("IBM MCA SCSI: Version %s\n",IBMMCA_SCSI_DRIVER_VERSION);
+
+#ifdef MODULE
+ /* If the driver is run as module, read from conf.modules or cmd-line */
+ if (boot_options)
+ option_setup(boot_options);
+#endif
/* get interrupt request level */
#ifdef OLDKERN
@@ -1542,7 +1979,9 @@
printk("IBM MCA SCSI: Unable to get shared IRQ %d.\n", IM_IRQ);
return 0;
}
-
+ else
+ IRQ14_registered++;
+
/* if ibmmcascsi setup option was passed to kernel, return "found" */
for (i = 0; i < IM_MAX_HOSTS; i++)
if (io_port[i] > 0 && scsi_id[i] >= 0 && scsi_id[i] < 8)
@@ -1550,16 +1989,21 @@
printk("IBM MCA SCSI: forced detected SCSI Adapter, io=0x%x, scsi id=%d.\n",
io_port[i], scsi_id[i]);
if ((shpnt = ibmmca_register(scsi_template, io_port[i], scsi_id[i],
+ FORCED_DETECTION,
"forced detected SCSI Adapter")))
{
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos2 = 0;
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos3 = 0;
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos4 = 0;
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos5 = 0;
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos6 = 0;
((struct ibmmca_hostdata *)shpnt->hostdata)->_special =
FORCED_DETECTION;
mca_set_adapter_name(MCA_INTEGSCSI, "forced detected SCSI Adapter");
mca_set_adapter_procfn(MCA_INTEGSCSI, (MCA_ProcFn) ibmmca_getinfo,
shpnt);
mca_mark_as_used(MCA_INTEGSCSI);
+ devices_on_irq_14++;
}
}
if (found) return found;
@@ -1592,12 +2036,14 @@
for (j=0;j<8;j++) /* read the pos-information */
pos[j] = mca_read_stored_pos(MCA_INTEGSCSI,j);
/* pos2 = pos3 = 0xff if there is no integrated SCSI-subsystem present */
- if (( pos[2] != 0xff) || (pos[3] != 0xff ))
+ /* if (( pos[2] != 0xff) || (pos[3] != 0xff )) */
+ /* Previous if-arguments do fail! Therefore, we use now the following to
+ * make sure, we see a real integrated onboard SCSI-interface: */
+ if ((!pos[0] && !pos[1] && pos[2]>0 && pos[3]>0 && !pos[4] && !pos[5] && !pos[6] && !pos[7]) ||
+ (pos[0]==0xff && pos[1]==0xff && pos[2]<0xff && pos[3]<0xff && pos[4]==0xff && pos[5]==0xff && pos[6]==0xff && pos[7]==0xff))
{
if ((pos[2] & 1) == 1) /* is the subsystem chip enabled ? */
- {
- port = IM_IO_PORT;
- }
+ port = IM_IO_PORT;
else
{ /* if disabled, no IRQs will be generated, as the chip won't
* listen to the incomming commands and will do really nothing,
@@ -1622,16 +2068,21 @@
/* register the found integrated SCSI-subsystem */
if ((shpnt = ibmmca_register(scsi_template, port, id,
+ INTEGRATED_SCSI,
"IBM Integrated SCSI Controller")))
{
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos2 = pos[2];
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos3 = pos[3];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos4 = pos[4];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos5 = pos[5];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos6 = pos[6];
((struct ibmmca_hostdata *)shpnt->hostdata)->_special =
INTEGRATED_SCSI;
mca_set_adapter_name(MCA_INTEGSCSI, "IBM Integrated SCSI Controller");
mca_set_adapter_procfn(MCA_INTEGSCSI, (MCA_ProcFn) ibmmca_getinfo,
shpnt);
mca_mark_as_used(MCA_INTEGSCSI);
+ devices_on_irq_14++;
}
}
@@ -1657,42 +2108,177 @@
printk("IBM MCA SCSI: WARNING - Your SCSI-subsystem is disabled!\n");
printk(" SCSI-operations may not work.\n");
}
- id = (pos[3] & 0xe0) >> 5; /* get subsystem PUN */
+ if ((i==IBM_SCSI2_FW)&&(pos[6]!=0))
+ {
+ printk("IBM MCA SCSI: ERROR - Wrong POS(6)-register setting!\n");
+ printk(" Impossible to determine adapter PUN!\n");
+ printk(" Guessing adapter PUN = 7.\n");
+ id = 7;
+ }
+ else
+ {
+ id = (pos[3] & 0xe0) >> 5; /* get subsystem PUN */
+ if (i==IBM_SCSI2_FW)
+ {
+ id |= (pos[3] & 0x10) >> 1; /* get subsystem PUN high-bit
+ * for F/W adapters */
+ }
+ }
+ if ((i==IBM_SCSI2_FW)&&(pos[4] & 0x01)&&(pos[6]==0))
+ { /* IRQ11 is used by SCSI-2 F/W Adapter/A */
+ printk("IBM MCA SCSI: SCSI-2 F/W adapter needs IRQ 11.\n");
+ /* get interrupt request level */
+#ifdef OLDKERN
+ if (request_irq (IM_IRQ_FW, interrupt_handler, SA_SHIRQ,
+ "ibmmcascsi", hosts))
+#else
+ if (request_irq (IM_IRQ_FW, do_interrupt_handler, SA_SHIRQ,
+ "ibmmcascsi", hosts))
+#endif
+ {
+ printk("IBM MCA SCSI: Unable to get shared IRQ %d.\n",
+ IM_IRQ_FW);
+ }
+ else
+ IRQ11_registered++;
+ }
printk("IBM MCA SCSI: %s found in slot %d, io=0x%x, scsi id=%d,\n",
subsys_list[i].description, slot + 1, port, id);
- printk(" chip rev.=%d, port-offset=0x%x, subsystem=%s\n",
- ((pos[2] & 0xf0) >> 4),
+ if ((pos[2] & 0xf0) == 0xf0)
+ printk(" ROM Addr.=off,");
+ else
+ printk(" ROM Addr.=0x%x,",
+ ((pos[2] & 0xf0) << 13) + 0xc0000);
+ printk(" port-offset=0x%x, subsystem=%s\n",
((pos[2] & 0x0e) << 2),
(pos[2] & 1) ? "enabled." : "disabled.");
/* register the hostadapter */
- if ((shpnt = ibmmca_register(scsi_template, port, id,
+ if ((shpnt = ibmmca_register(scsi_template, port, id, i,
subsys_list[i].description)))
{
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos2 = pos[2];
((struct ibmmca_hostdata *)shpnt->hostdata)->_pos3 = pos[3];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos4 = pos[4];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos5 = pos[5];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos6 = pos[6];
((struct ibmmca_hostdata *)shpnt->hostdata)->_special = i;
mca_set_adapter_name (slot, subsys_list[i].description);
mca_set_adapter_procfn (slot, (MCA_ProcFn) ibmmca_getinfo,
shpnt);
mca_mark_as_used(slot);
+ if ((i==IBM_SCSI2_FW)&&(pos[4] & 0x01)&&(pos[6]==0))
+ devices_on_irq_11++;
+ else
+ devices_on_irq_14++;
}
slot++; /* advance to next slot */
} /* advance to next adapter id in the list of IBM-SCSI-subsystems*/
}
+
- if (!found)
- { /* maybe ESDI, or other producers' SCSI-hosts */
- free_irq (IM_IRQ, hosts);
- printk("IBM MCA SCSI: No IBM SCSI-subsystem adapter attached.\n");
- }
+ /* now look for SCSI-adapters, by bugs mapped to the integrated SCSI
+ * area. E.g. a W/Cache in MCA-slot 9 ???? Arrrrgh!! */
+ list_size = sizeof(subsys_list) / sizeof(struct subsys_list_struct);
+ for (i = 0; i < list_size; i++)
+ { /* scan each slot for a fitting adapter id */
+ slot = mca_find_adapter(subsys_list[i].mca_id, MCA_INTEGSCSI);
+ if (slot != MCA_NOTFOUND)
+ { /* scan through all slots */
+ for (j=0;j<8;j++) /* read the pos-information */
+ pos[j] = mca_read_stored_pos(slot, j);
+ if ((pos[2] & 1) == 1) /* is the subsystem chip enabled ? */
+ { /* (explanations see above) */
+ port = IM_IO_PORT + ((pos[2] & 0x0e) << 2);
+ }
+ else
+ { /* anyway, set the portnumber and warn */
+ port = IM_IO_PORT + ((pos[2] & 0x0e) << 2);
+ printk("IBM MCA SCSI: WARNING - Your SCSI-subsystem is disabled!\n");
+ printk(" SCSI-operations may not work.\n");
+ }
+ if ((i==IBM_SCSI2_FW)&&(pos[6]!=0))
+ {
+ printk("IBM MCA SCSI: ERROR - Wrong POS(6)-register setting!\n");
+ printk(" Impossible to determine adapter PUN!\n");
+ printk(" Guessing adapter PUN = 7.\n");
+ id = 7;
+ }
+ else
+ {
+ id = (pos[3] & 0xe0) >> 5; /* get subsystem PUN */
+ if (i==IBM_SCSI2_FW)
+ {
+ id |= (pos[3] & 0x10) >> 1; /* get subsystem PUN high-bit
+ * for F/W adapters */
+ }
+ }
+ if ((i==IBM_SCSI2_FW)&&(pos[4] & 0x01)&&(pos[6]==0))
+ { /* IRQ11 is used by SCSI-2 F/W Adapter/A */
+ printk("IBM MCA SCSI: SCSI-2 F/W adapter needs IRQ 11.\n");
+ /* get interrupt request level */
+#ifdef OLDKERN
+ if (request_irq (IM_IRQ_FW, interrupt_handler, SA_SHIRQ,
+ "ibmmcascsi", hosts))
+#else
+ if (request_irq (IM_IRQ_FW, do_interrupt_handler, SA_SHIRQ,
+ "ibmmcascsi", hosts))
+#endif
+ {
+ printk("IBM MCA SCSI: Unable to get shared IRQ %d.\n",
+ IM_IRQ_FW);
+ }
+ else
+ IRQ11_registered++;
+ }
+ printk("IBM MCA SCSI: %s found in slot %d, io=0x%x, scsi id=%d,\n",
+ subsys_list[i].description, slot + 1, port, id);
+ if ((pos[2] & 0xf0) == 0xf0)
+ printk(" ROM Addr.=off,");
+ else
+ printk(" ROM Addr.=0x%x,",
+ ((pos[2] & 0xf0) << 13) + 0xc0000);
+ printk(" port-offset=0x%x, subsystem=%s\n",
+ ((pos[2] & 0x0e) << 2),
+ (pos[2] & 1) ? "enabled." : "disabled.");
+
+ /* register the hostadapter */
+ if ((shpnt = ibmmca_register(scsi_template, port, id, i,
+ subsys_list[i].description)))
+ {
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos2 = pos[2];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos3 = pos[3];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos4 = pos[4];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos5 = pos[5];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_pos6 = pos[6];
+ ((struct ibmmca_hostdata *)shpnt->hostdata)->_special = i;
+
+ mca_set_adapter_name (slot, subsys_list[i].description);
+ mca_set_adapter_procfn (slot, (MCA_ProcFn) ibmmca_getinfo,
+ shpnt);
+ mca_mark_as_used(slot);
+ if ((i==IBM_SCSI2_FW)&&(pos[4] & 0x01)&&(pos[6]==0))
+ devices_on_irq_11++;
+ else
+ devices_on_irq_14++;
+ }
+ slot++; /* advance to next slot */
+ } /* advance to next adapter id in the list of IBM-SCSI-subsystems*/
+ }
+
+ if ( IRQ11_registered && !devices_on_irq_11 )
+ free_irq(IM_IRQ_FW, hosts); /* no devices on IRQ 11 */
+ if ( IRQ14_registered && !devices_on_irq_14 )
+ free_irq(IM_IRQ, hosts); /* no devices on IRQ 14 */
+ if ( !devices_on_irq_11 && !devices_on_irq_14 )
+ printk("IBM MCA SCSI: No IBM SCSI-subsystem adapter attached.\n");
return found; /* return the number of found SCSI hosts. Should be 1 or 0. */
}
static struct Scsi_Host *
-ibmmca_register(Scsi_Host_Template * scsi_template, int port, int id,
- char *hostname)
+ibmmca_register(Scsi_Host_Template * scsi_template, int port, int id,
+ int adaptertype, char *hostname)
{
struct Scsi_Host *shpnt;
int i, j;
@@ -1716,15 +2302,18 @@
/* request I/O region */
request_region(port, IM_N_IO_PORT, hostname);
-
+
hosts[found] = shpnt; /* add new found hostadapter to the list */
+ special(found) = adaptertype; /* important assignment or else crash! */
+ subsystem_connector_size(found) = 0; /* preset slot-size */
shpnt->irq = IM_IRQ; /* assign necessary stuff for the adapter */
shpnt->io_port = port;
shpnt->n_io_port = IM_N_IO_PORT;
shpnt->this_id = id;
+ shpnt->max_id = 8; /* 8 PUNs are default */
/* now, the SCSI-subsystem is connected to Linux */
-
- ctrl = (unsigned int)(inb(IM_CTR_REG(found))); /* get control-register status */
+
+ ctrl = (unsigned int)(inb(IM_CTR_REG(found))); /* get control-register status */
#ifdef IM_DEBUG_PROBE
printk("IBM MCA SCSI: Control Register contents: %x, status: %x\n",
ctrl,inb(IM_STAT_REG(found)));
@@ -1738,13 +2327,14 @@
reset_status(found) = IM_RESET_NOT_IN_PROGRESS;
- for (i = 0; i < 8; i++) /* reset the tables */
+ for (i = 0; i < 16; i++) /* reset the tables */
for (j = 0; j < 8; j++)
get_ldn(found)[i][j] = MAX_LOG_DEV;
/* check which logical devices exist */
- local_checking_phase_flag(found) = 1;
- check_devices(found); /* call by value, using the global variable hosts*/
+ /* after this line, local interrupting is possible: */
+ local_checking_phase_flag(found) = 1;
+ check_devices(found,adaptertype); /* call by value, using the global variable hosts*/
local_checking_phase_flag(found) = 0;
found++; /* now increase index to be prepared for next found subsystem */
@@ -1802,30 +2392,43 @@
int id,lun;
int target;
int host_index;
-
- if (ibm_ansi_order)
- target = 6 - cmd->target;
- else
- target = cmd->target;
+ int max_pun;
+ int i;
+ struct scatterlist *sl;
shpnt = cmd->host;
-
+
/* search for the right hostadapter */
for (host_index = 0; hosts[host_index] && hosts[host_index]->host_no != shpnt->host_no; host_index++);
if (!hosts[host_index])
{ /* invalid hostadapter descriptor address */
cmd->result = DID_NO_CONNECT << 16;
- done (cmd);
+ if (done)
+ done (cmd);
return 0;
}
+ max_pun = subsystem_maxid(host_index);
+
+ if (ibm_ansi_order)
+ {
+ target = max_pun - 1 - cmd->target;
+ if ((target <= subsystem_pun(host_index))&&(cmd->target <= subsystem_pun(host_index)))
+ target--;
+ else if ((target >= subsystem_pun(host_index))&&(cmd->target >= subsystem_pun(host_index)))
+ target++;
+ }
+ else
+ target = cmd->target;
+
/*if (target,lun) is NO LUN or not existing at all, return error */
if ((get_scsi(host_index)[target][cmd->lun] == TYPE_NO_LUN)||
(get_scsi(host_index)[target][cmd->lun] == TYPE_NO_DEVICE))
{
cmd->result = DID_NO_CONNECT << 16;
- done (cmd);
+ if (done)
+ done (cmd);
return 0;
}
@@ -1848,13 +2451,14 @@
printk(" Reporting DID_NO_CONNECT for device (%d,%d).\n",
target, cmd->lun);
cmd->result = DID_NO_CONNECT << 16;/* return no connect*/
- done (cmd);
+ if (done)
+ done (cmd);
return 0;
}
}
/* unmap non-processing ldn */
- for (id=0; id<8; id ++)
+ for (id=0; id<max_pun; id ++)
for (lun=0; lun<8; lun++)
{
if (get_ldn(host_index)[id][lun] == next_ldn(host_index))
@@ -1907,7 +2511,8 @@
else
{ /* wall against Linux accesses to the subsystem adapter */
cmd->result = DID_BAD_TARGET << 16;
- done (cmd);
+ if (done)
+ done (cmd);
return 0;
}
}
@@ -1923,17 +2528,19 @@
/*fill scb information independent of the scsi command */
scb = &(ld(host_index)[ldn].scb);
ld(host_index)[ldn].tsb.dev_status = 0;
- scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR;
+ scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE;
scb->tsb_adr = virt_to_bus(&(ld(host_index)[ldn].tsb));
+ scsi_cmd = cmd->cmnd[0];
+
if (cmd->use_sg)
{
- int i = cmd->use_sg;
- struct scatterlist *sl = (struct scatterlist *) cmd->request_buffer;
+ i = cmd->use_sg;
+ sl = (struct scatterlist *)(cmd->request_buffer);
if (i > 16)
panic ("IBM MCA SCSI: scatter-gather list too long.\n");
while (--i >= 0)
{
- ld(host_index)[ldn].sge[i].address = (void *) virt_to_bus(sl[i].address);
+ ld(host_index)[ldn].sge[i].address = (void *)(virt_to_bus(sl[i].address));
ld(host_index)[ldn].sge[i].byte_length = sl[i].length;
}
scb->enable |= IM_POINTER_TO_LIST;
@@ -1943,11 +2550,26 @@
else
{
scb->sys_buf_adr = virt_to_bus(cmd->request_buffer);
- scb->sys_buf_length = cmd->request_bufflen;
+ /* recent Linux midlevel SCSI places 1024 byte for inquiry
+ * command. Far too much for old PS/2 hardware. */
+ switch (scsi_cmd)
+ { /* avoid command errors by setting bufferlengths to
+ * ANSI-standard. */
+ case INQUIRY:
+ case REQUEST_SENSE:
+ case MODE_SENSE:
+ case MODE_SELECT:
+ scb->sys_buf_length = 255;
+ break;
+ case TEST_UNIT_READY:
+ scb->sys_buf_length = 0;
+ break;
+ default:
+ scb->sys_buf_length = cmd->request_bufflen;
+ break;
+ }
}
-
/*fill scb information dependent on scsi command */
- scsi_cmd = cmd->cmnd[0];
#ifdef IM_DEBUG_CMD
printk("issue scsi cmd=%02x to ldn=%d\n", scsi_cmd, ldn);
@@ -1962,8 +2584,7 @@
/* for possible panics store current command */
last_scsi_command(host_index)[ldn] = scsi_cmd;
- last_scsi_type(host_index)[ldn] = IM_SCB;
-
+ last_scsi_type(host_index)[ldn] = IM_SCB;
/* update statistical info */
IBM_DS(host_index).total_accesses++;
IBM_DS(host_index).ldn_access[ldn]++;
@@ -1976,16 +2597,9 @@
case WRITE_10:
case READ_12:
case WRITE_12:
- /* statistics for proc_info */
- if ((scsi_cmd == READ_6)||(scsi_cmd == READ_10)||(scsi_cmd == READ_12))
- IBM_DS(host_index).ldn_read_access[ldn]++; /* increase READ-access on ldn stat. */
- else if ((scsi_cmd == WRITE_6)||(scsi_cmd == WRITE_10)||
- (scsi_cmd == WRITE_12))
- IBM_DS(host_index).ldn_write_access[ldn]++; /* increase write-count on ldn stat.*/
-
/* Distinguish between disk and other devices. Only disks (that are the
most frequently accessed devices) should be supported by the
- IBM-SCSI-Subsystem commands. */
+ IBM-SCSI-Subsystem commands. */
switch (ld(host_index)[ldn].device_type)
{
case TYPE_DISK: /* for harddisks enter here ... */
@@ -1994,31 +2608,32 @@
if (scsi_cmd == READ_6 || scsi_cmd == READ_10 ||
scsi_cmd == READ_12)
{ /* read command preparations */
+ scb->enable |= IM_READ_CONTROL;
+ IBM_DS(host_index).ldn_read_access[ldn]++; /* increase READ-access on ldn stat. */
if (bypass_controller)
{
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy(scb->u2.scsi_command,cmd->cmnd,cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
- {
- scb->command = IM_READ_DATA_CMD;
- scb->enable |= IM_READ_CONTROL;
- }
+ scb->command = IM_READ_DATA_CMD | IM_NO_DISCONNECT;
}
else
{ /* write command preparations */
+ IBM_DS(host_index).ldn_write_access[ldn]++; /* increase write-count on ldn stat.*/
if (bypass_controller)
{
scb->command = IM_OTHER_SCSI_CMD_CMD;
+ scb->enable |= IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy(scb->u2.scsi_command,cmd->cmnd,cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
- {
- scb->command = IM_WRITE_DATA_CMD;
- }
+ scb->command = IM_WRITE_DATA_CMD | IM_NO_DISCONNECT;
}
if (!bypass_controller)
@@ -2039,6 +2654,8 @@
scb->u2.blk.count = (((unsigned) cmd->cmnd[8]) << 0) |
(((unsigned) cmd->cmnd[7]) << 8);
}
+ last_scsi_logical_block(host_index)[ldn] = scb->u1.log_blk_adr;
+ last_scsi_blockcount(host_index)[ldn] = scb->u2.blk.count;
scb->u2.blk.length = ld(host_index)[ldn].block_length;
}
if (++disk_rw_in_progress == 1)
@@ -2052,8 +2669,7 @@
case TYPE_PROCESSOR:
case TYPE_WORM:
case TYPE_SCANNER:
- case TYPE_MEDIUM_CHANGER:
-
+ case TYPE_MEDIUM_CHANGER:
/* If there is a sequential-device, IBM recommends to use
IM_OTHER_SCSI_CMD_CMD instead of subsystem READ/WRITE.
Good/modern CD-ROM-drives are capable of
@@ -2068,15 +2684,14 @@
scb->command = IM_OTHER_SCSI_CMD_CMD;
if (scsi_cmd == READ_6 || scsi_cmd == READ_10 ||
scsi_cmd == READ_12) /* enable READ */
- {
- scb->enable |= IM_READ_CONTROL;
- }
-
+ scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
/* Read/write on this non-disk devices is also displayworthy,
- so flash-up the LED/display. */
+ so flash-up the LED/display. */
if (++disk_rw_in_progress == 1)
PS2_DISK_LED_ON (shpnt->host_no, target);
break;
@@ -2087,17 +2702,27 @@
if (bypass_controller)
{
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
+ scb->u1.log_blk_adr = 0;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
{
scb->command = IM_DEVICE_INQUIRY_CMD;
scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
+ scb->u1.log_blk_adr = 0;
}
- break;
-
+ break;
+ case TEST_UNIT_READY:
+ scb->command = IM_OTHER_SCSI_CMD_CMD;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
+ scb->u1.log_blk_adr = 0;
+ scb->u1.scsi_cmd_length = 6;
+ memcpy (scb->u2.scsi_command, cmd->cmnd, 6);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
+ break;
case READ_CAPACITY:
/* the length of system memory buffer must be exactly 8 bytes */
if (scb->sys_buf_length > 8)
@@ -2105,55 +2730,67 @@
if (bypass_controller)
{
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
- memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
{
scb->command = IM_READ_CAPACITY_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
}
break;
- /* Commands that need read-only-mode (system <- device): */
+ /* Commands that need read-only-mode (system <- device): */
case REQUEST_SENSE:
- if (bypass_controller)
+ if (bypass_controller)
{
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
}
else
{
scb->command = IM_REQUEST_SENSE_CMD;
- scb->enable |= IM_READ_CONTROL;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
}
break;
- /* Commands that need write-only-mode (system -> device): */
+ /* Commands that need write-only-mode (system -> device): */
case MODE_SELECT:
case MODE_SELECT_10:
IBM_DS(host_index).ldn_modeselect_access[ldn]++;
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_SUPRESS_EXCEPTION_SHORT; /*Select needs WRITE-enabled*/
+ scb->enable |= IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; /*Select needs WRITE-enabled*/
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
break;
/* For other commands, read-only is useful. Most other commands are
running without an input-data-block. */
default:
scb->command = IM_OTHER_SCSI_CMD_CMD;
- scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT;
+ scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
scb->u1.scsi_cmd_length = cmd->cmd_len;
memcpy (scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
+ last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
break;
}
-
/*issue scb command, and return */
- issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
+ if (last_scsi_type(host_index)[ldn] == IM_LONG_SCB)
+ {
+ issue_cmd (host_index, virt_to_bus(scb), IM_LONG_SCB | ldn);
+ IBM_DS(host_index).long_scbs++;
+ }
+ else
+ {
+ issue_cmd (host_index, virt_to_bus(scb), IM_SCB | ldn);
+ IBM_DS(host_index).scbs++;
+ }
return 0;
}
@@ -2170,6 +2807,7 @@
void (*saved_done) (Scsi_Cmnd *);
int target;
int host_index;
+ int max_pun;
static unsigned long flags;
unsigned long imm_command;
@@ -2180,12 +2818,7 @@
cli();
#else
spin_lock_irqsave(&abort_lock, flags);
-#endif
- if (ibm_ansi_order)
- target = 6 - cmd->target;
- else
- target = cmd->target;
-
+#endif
shpnt = cmd->host;
/* search for the right hostadapter */
@@ -2195,9 +2828,22 @@
{ /* invalid hostadapter descriptor address */
cmd->result = DID_NO_CONNECT << 16;
if (cmd->scsi_done)
- (cmd->done) (cmd);
+ (cmd->scsi_done) (cmd);
return SCSI_ABORT_SNOOZE;
}
+
+ max_pun = subsystem_maxid(host_index);
+
+ if (ibm_ansi_order)
+ {
+ target = max_pun - 1 - cmd->target;
+ if ((target <= subsystem_pun(host_index))&&(cmd->target <= subsystem_pun(host_index)))
+ target--;
+ else if ((target >= subsystem_pun(host_index))&&(cmd->target >= subsystem_pun(host_index)))
+ target++;
+ }
+ else
+ target = cmd->target;
/*get logical device number, and disable system interrupts */
printk ("IBM MCA SCSI: Sending abort to device pun=%d, lun=%d.\n",
@@ -2294,7 +2940,12 @@
int host_index;
static unsigned long flags;
unsigned long imm_command;
-
+
+ if (cmd == NULL)
+ {
+ printk("IBM MCA SCSI: Reset called with NULL-command!\n");
+ return(SCSI_RESET_SNOOZE);
+ }
#ifdef OLDKERN
save_flags(flags);
cli();
@@ -2310,9 +2961,19 @@
{ /* invalid hostadapter descriptor address */
if (!local_checking_phase_flag(host_index))
{
- cmd->result = DID_NO_CONNECT << 16;
- if (cmd->scsi_done)
- (cmd->done) (cmd);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,132)
+ if (flags & SCSI_RESET_SYNCHRONOUS)
+ {
+#ifdef OLDKERN
+ restore_flags(flags);
+#else
+ spin_unlock_irqrestore(&reset_lock, flags);
+#endif
+ cmd->result = DID_NO_CONNECT << 16;
+ if (cmd->scsi_done)
+ (cmd->scsi_done) (cmd);
+ }
+#endif
}
return SCSI_ABORT_SNOOZE;
}
@@ -2399,7 +3060,7 @@
}
/* so reset finished ok - call outstanding done's, and return success */
- printk ("IBM MCA SCSI: Reset completed without known error.\n");
+ printk ("IBM MCA SCSI: Reset successfully completed.\n");
#ifdef OLDKERN
restore_flags(flags);
#else
@@ -2412,10 +3073,22 @@
{
ld(host_index)[i].cmd = NULL;
cmd_aid->result = DID_RESET << 16;
- (cmd_aid->scsi_done) (cmd_aid);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,132)
+ if (flags & SCSI_RESET_SYNCHRONOUS)
+ {
+ cmd_aid->result = DID_BUS_BUSY << 16;
+ if (cmd_aid->scsi_done)
+ (cmd_aid->scsi_done) (cmd_aid);
+ }
+#endif
}
}
- return SCSI_RESET_SUCCESS;
+ if (flags & SCSI_RESET_SUGGEST_HOST_RESET)
+ return (SCSI_RESET_SUCCESS | SCSI_RESET_HOST_RESET);
+ else if (flags & SCSI_RESET_SUGGEST_BUS_RESET)
+ return (SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET);
+ else
+ return SCSI_RESET_SUCCESS;
}
/*--------------------------------------------------------------------*/
@@ -2492,7 +3165,8 @@
int i,id,lun,host_index;
struct Scsi_Host *shpnt;
unsigned long flags;
-
+ int max_pun;
+
#ifdef OLDKERN
save_flags(flags);
cli();
@@ -2504,10 +3178,11 @@
shpnt = hosts[i];
host_index = i;
if (!shpnt) {
- len += sprintf(buffer+len, "\nCan't find adapter for host number %d\n", hostno);
+ len += sprintf(buffer+len, "\nIBM MCA SCSI: Can't find adapter for host number %d\n", hostno);
return len;
}
-
+ max_pun = subsystem_maxid(host_index);
+
len += sprintf(buffer+len, "\n IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n",
IBMMCA_SCSI_DRIVER_VERSION);
len += sprintf(buffer+len, " SCSI Access-Statistics:\n");
@@ -2528,8 +3203,12 @@
(bypass_controller) ? "software" : "hardware integrated");
len += sprintf(buffer+len, " Total Interrupts.........: %d\n",
IBM_DS(host_index).total_interrupts);
- len += sprintf(buffer+len, " Total SCSI Accesses......: %d\n",
+ len += sprintf(buffer+len, " Total SCSI Accesses......: %d\n",
IBM_DS(host_index).total_accesses);
+ len += sprintf(buffer+len, " Total short SCBs.........: %d\n",
+ IBM_DS(host_index).scbs);
+ len += sprintf(buffer+len, " Total long SCBs..........: %d\n",
+ IBM_DS(host_index).long_scbs);
len += sprintf(buffer+len, " Total SCSI READ/WRITE..: %d\n",
ldn_access_total_read_write(host_index));
len += sprintf(buffer+len, " Total SCSI Inquiries...: %d\n",
@@ -2554,7 +3233,7 @@
len += sprintf(buffer+len, " Dynamical-LDN-Assignment-Statistics:\n");
len += sprintf(buffer+len, " Number of physical SCSI-devices..: %d (+ Adapter)\n",
IBM_DS(host_index).total_scsi_devices);
- len += sprintf(buffer+len, " Dynamical Assignment necessaray..: %s\n",
+ len += sprintf(buffer+len, " Dynamical Assignment necessary...: %s\n",
IBM_DS(host_index).dyn_flag ? "Yes" : "No ");
len += sprintf(buffer+len, " Next LDN to be assigned..........: 0x%x\n",
next_ldn(host_index));
@@ -2564,7 +3243,7 @@
len += sprintf(buffer+len, "\n Current SCSI-Device-Mapping:\n");
len += sprintf(buffer+len, " Physical SCSI-Device Map Logical SCSI-Device Map\n");
len += sprintf(buffer+len, " ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n");
- for (id=0; id<=7; id++)
+ for (id=0; id<max_pun; id++)
{
len += sprintf(buffer+len, " %2d ",id);
for (lun=0; lun<8; lun++)
@@ -2590,6 +3269,30 @@
#endif
return len;
}
+
+void ibmmca_scsi_setup (char *str, int *ints)
+{
+ internal_ibmmca_scsi_setup (str, ints);
+}
+
+static int option_setup(char *str)
+{
+ int ints[IM_MAX_HOSTS];
+ char *cur = str;
+ int i = 1;
+
+ while (cur && isdigit(*cur) && i <= IM_MAX_HOSTS) {
+ ints[i++] = simple_strtoul(cur, NULL, 0);
+ if ((cur = strchr(cur,',')) != NULL) cur++;
+ }
+ ints[0] = i - 1;
+ internal_ibmmca_scsi_setup(cur, ints);
+ return 0;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,18)
+__setup("ibmmcascsi=", option_setup);
+#endif
#ifdef MODULE
/* Eventually this will go into an include file, but this will be later */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)