2005-04-17 06:20:36 +08:00
|
|
|
/* gdth_proc.c
|
2006-06-10 02:34:29 +08:00
|
|
|
* $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/completion.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
int gdth_set_info(struct Scsi_Host *host, char *buffer, int length)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(host);
|
2006-06-10 02:34:29 +08:00
|
|
|
int ret_val = -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (length >= 4) {
|
|
|
|
if (strncmp(buffer,"gdth",4) == 0) {
|
|
|
|
buffer += 5;
|
|
|
|
length -= 5;
|
2007-10-03 05:05:53 +08:00
|
|
|
ret_val = gdth_set_asc_info(host, buffer, length, ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2006-06-10 02:34:29 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
2006-06-10 02:34:29 +08:00
|
|
|
static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
|
2007-10-03 05:05:53 +08:00
|
|
|
int length, gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-06-10 02:34:29 +08:00
|
|
|
int orig_length, drive, wb_mode;
|
|
|
|
int i, found;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_cmd_str gdtcmd;
|
|
|
|
gdth_cpar_str *pcpar;
|
2010-01-04 23:19:34 +08:00
|
|
|
u64 paddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
char cmnd[MAX_COMMAND_SIZE];
|
|
|
|
memset(cmnd, 0xff, 12);
|
|
|
|
memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
orig_length = length + 5;
|
|
|
|
drive = -1;
|
|
|
|
wb_mode = 0;
|
|
|
|
found = FALSE;
|
|
|
|
|
|
|
|
if (length >= 5 && strncmp(buffer,"flush",5)==0) {
|
|
|
|
buffer += 6;
|
|
|
|
length -= 6;
|
|
|
|
if (length && *buffer>='0' && *buffer<='9') {
|
|
|
|
drive = (int)(*buffer-'0');
|
|
|
|
++buffer; --length;
|
|
|
|
if (length && *buffer>='0' && *buffer<='9') {
|
|
|
|
drive = drive*10 + (int)(*buffer-'0');
|
|
|
|
++buffer; --length;
|
|
|
|
}
|
|
|
|
printk("GDT: Flushing host drive %d .. ",drive);
|
|
|
|
} else {
|
|
|
|
printk("GDT: Flushing all host drives .. ");
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAX_HDRIVES; ++i) {
|
|
|
|
if (ha->hdr[i].present) {
|
|
|
|
if (drive != -1 && i != drive)
|
|
|
|
continue;
|
|
|
|
found = TRUE;
|
|
|
|
gdtcmd.Service = CACHESERVICE;
|
|
|
|
gdtcmd.OpCode = GDT_FLUSH;
|
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
|
|
|
gdtcmd.u.cache64.DeviceNo = i;
|
|
|
|
gdtcmd.u.cache64.BlockNo = 1;
|
|
|
|
} else {
|
|
|
|
gdtcmd.u.cache.DeviceNo = i;
|
|
|
|
gdtcmd.u.cache.BlockNo = 1;
|
|
|
|
}
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
printk("\nNo host drive found !\n");
|
|
|
|
else
|
|
|
|
printk("Done.\n");
|
|
|
|
return(orig_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (length >= 7 && strncmp(buffer,"wbp_off",7)==0) {
|
|
|
|
buffer += 8;
|
|
|
|
length -= 8;
|
|
|
|
printk("GDT: Disabling write back permanently .. ");
|
|
|
|
wb_mode = 1;
|
|
|
|
} else if (length >= 6 && strncmp(buffer,"wbp_on",6)==0) {
|
|
|
|
buffer += 7;
|
|
|
|
length -= 7;
|
|
|
|
printk("GDT: Enabling write back permanently .. ");
|
|
|
|
wb_mode = 2;
|
|
|
|
} else if (length >= 6 && strncmp(buffer,"wb_off",6)==0) {
|
|
|
|
buffer += 7;
|
|
|
|
length -= 7;
|
|
|
|
printk("GDT: Disabling write back commands .. ");
|
|
|
|
if (ha->cache_feat & GDT_WR_THROUGH) {
|
|
|
|
gdth_write_through = TRUE;
|
|
|
|
printk("Done.\n");
|
|
|
|
} else {
|
|
|
|
printk("Not supported !\n");
|
|
|
|
}
|
|
|
|
return(orig_length);
|
|
|
|
} else if (length >= 5 && strncmp(buffer,"wb_on",5)==0) {
|
|
|
|
buffer += 6;
|
|
|
|
length -= 6;
|
|
|
|
printk("GDT: Enabling write back commands .. ");
|
|
|
|
gdth_write_through = FALSE;
|
|
|
|
printk("Done.\n");
|
|
|
|
return(orig_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wb_mode) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, &paddr))
|
2005-04-17 06:20:36 +08:00
|
|
|
return(-EBUSY);
|
|
|
|
pcpar = (gdth_cpar_str *)ha->pscratch;
|
|
|
|
memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) );
|
|
|
|
gdtcmd.Service = CACHESERVICE;
|
|
|
|
gdtcmd.OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd.u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str);
|
|
|
|
gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
|
|
|
|
gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
|
|
|
|
pcpar->write_back = wb_mode==1 ? 0:1;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("Done.\n");
|
|
|
|
return(orig_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
printk("GDT: Unknown command: %s Length: %d\n",buffer,length);
|
|
|
|
return(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-03-31 12:52:08 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(host);
|
2009-06-09 20:44:02 +08:00
|
|
|
int hlen;
|
2005-04-17 06:20:36 +08:00
|
|
|
int id, i, j, k, sec, flag;
|
|
|
|
int no_mdrv = 0, drv_no, is_mirr;
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 cnt;
|
|
|
|
u64 paddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
int rc = -ENOMEM;
|
|
|
|
|
|
|
|
gdth_cmd_str *gdtcmd;
|
|
|
|
gdth_evt_str *estr;
|
2017-07-14 20:06:59 +08:00
|
|
|
char hrec[277];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
char *buf;
|
|
|
|
gdth_dskstat_str *pds;
|
|
|
|
gdth_diskinfo_str *pdi;
|
|
|
|
gdth_arrayinf_str *pai;
|
|
|
|
gdth_defcnt_str *pdef;
|
|
|
|
gdth_cdrinfo_str *pcdi;
|
|
|
|
gdth_hget_str *phg;
|
|
|
|
char cmnd[MAX_COMMAND_SIZE];
|
|
|
|
|
|
|
|
gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL);
|
|
|
|
estr = kmalloc(sizeof(*estr), GFP_KERNEL);
|
|
|
|
if (!gdtcmd || !estr)
|
2006-06-10 02:34:29 +08:00
|
|
|
goto free_fail;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
memset(cmnd, 0xff, 12);
|
|
|
|
memset(gdtcmd, 0, sizeof(gdth_cmd_str));
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_get_info() ha %d\n",ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* request is i.e. "cat /proc/scsi/gdth/0" */
|
|
|
|
/* format: %-15s\t%-10s\t%-15s\t%s */
|
|
|
|
/* driver parameters */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "Driver Parameters:\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (reserve_list[0] == 0xff)
|
|
|
|
strcpy(hrec, "--");
|
|
|
|
else {
|
2009-06-09 20:44:02 +08:00
|
|
|
hlen = sprintf(hrec, "%d", reserve_list[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 1; i < MAX_RES_ARGS; i++) {
|
|
|
|
if (reserve_list[i] == 0xff)
|
|
|
|
break;
|
2009-06-09 20:44:02 +08:00
|
|
|
hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" reserve_mode: \t%d \treserve_list: \t%s\n",
|
|
|
|
reserve_mode, hrec);
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" max_ids: \t%-3d \thdr_channel: \t%d\n",
|
|
|
|
max_ids, hdr_channel);
|
|
|
|
|
|
|
|
/* controller information */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nDisk Array Controller Information:\n");
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Number: \t%d \tName: \t%s\n",
|
2013-03-31 12:52:08 +08:00
|
|
|
ha->hanum, ha->binfo.type_string);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
|
|
|
" Driver Ver.: \t%-10s\tFirmware Ver.: \t",
|
|
|
|
GDTH_VERSION_STR);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->more_proc)
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m, "%d.%02d.%02d-%c%03X\n",
|
2010-01-04 23:19:34 +08:00
|
|
|
(u8)(ha->binfo.upd_fw_ver>>24),
|
|
|
|
(u8)(ha->binfo.upd_fw_ver>>16),
|
|
|
|
(u8)(ha->binfo.upd_fw_ver),
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->bfeat.raid ? 'R':'N',
|
|
|
|
ha->binfo.upd_revision);
|
|
|
|
else
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8),
|
2010-01-04 23:19:34 +08:00
|
|
|
(u8)(ha->cpar.version));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (ha->more_proc)
|
2005-04-17 06:20:36 +08:00
|
|
|
/* more information: 1. about controller */
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
|
|
|
|
ha->binfo.ser_no, ha->binfo.memsize / 1024);
|
|
|
|
|
|
|
|
#ifdef GDTH_DMA_STATISTICS
|
|
|
|
/* controller statistics */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nController Statistics:\n");
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
|
|
|
|
ha->dma32_cnt, ha->dma64_cnt);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ha->more_proc) {
|
|
|
|
/* more information: 2. about physical devices */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nPhysical Devices:");
|
2005-04-17 06:20:36 +08:00
|
|
|
flag = FALSE;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!buf)
|
|
|
|
goto stop_output;
|
|
|
|
for (i = 0; i < ha->bus_cnt; ++i) {
|
|
|
|
/* 2.a statistics (and retries/reassigns) */
|
|
|
|
TRACE2(("pdr_statistics() chn %d\n",i));
|
|
|
|
pds = (gdth_dskstat_str *)(buf + GDTH_SCRATCH/4);
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr + GDTH_SCRATCH/4;
|
|
|
|
gdtcmd->u.ioctl.param_size = 3*GDTH_SCRATCH/4;
|
|
|
|
gdtcmd->u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN;
|
|
|
|
gdtcmd->u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL;
|
|
|
|
pds->bid = ha->raw[i].local_no;
|
|
|
|
pds->first = 0;
|
|
|
|
pds->entries = ha->raw[i].pdev_cnt;
|
2010-01-04 23:19:34 +08:00
|
|
|
cnt = (3*GDTH_SCRATCH/4 - 5 * sizeof(u32)) /
|
2005-04-17 06:20:36 +08:00
|
|
|
sizeof(pds->list[0]);
|
|
|
|
if (pds->entries > cnt)
|
|
|
|
pds->entries = cnt;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
|
2005-04-17 06:20:36 +08:00
|
|
|
pds->count = 0;
|
|
|
|
|
|
|
|
/* other IOCTLs must fit into area GDTH_SCRATCH/4 */
|
|
|
|
for (j = 0; j < ha->raw[i].pdev_cnt; ++j) {
|
|
|
|
/* 2.b drive info */
|
|
|
|
TRACE2(("scsi_drv_info() chn %d dev %d\n",
|
|
|
|
i, ha->raw[i].id_list[j]));
|
|
|
|
pdi = (gdth_diskinfo_str *)buf;
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd->u.ioctl.param_size = sizeof(gdth_diskinfo_str);
|
|
|
|
gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
|
|
|
|
gdtcmd->u.ioctl.channel =
|
|
|
|
ha->raw[i].address | ha->raw[i].id_list[j];
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
|
2005-04-17 06:20:36 +08:00
|
|
|
strncpy(hrec,pdi->vendor,8);
|
|
|
|
strncpy(hrec+8,pdi->product,16);
|
|
|
|
strncpy(hrec+24,pdi->revision,4);
|
|
|
|
hrec[28] = 0;
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
"\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
|
|
|
|
'A'+i,pdi->target_id,pdi->lun,hrec);
|
|
|
|
flag = TRUE;
|
|
|
|
pdi->no_ldrive &= 0xffff;
|
|
|
|
if (pdi->no_ldrive == 0xffff)
|
|
|
|
strcpy(hrec,"--");
|
|
|
|
else
|
|
|
|
sprintf(hrec,"%d",pdi->no_ldrive);
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n",
|
|
|
|
pdi->blkcnt/(1024*1024/pdi->blksize),
|
|
|
|
hrec);
|
|
|
|
} else {
|
|
|
|
pdi->devtype = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdi->devtype == 0) {
|
|
|
|
/* search retries/reassigns */
|
|
|
|
for (k = 0; k < pds->count; ++k) {
|
|
|
|
if (pds->list[k].tid == pdi->target_id &&
|
|
|
|
pds->list[k].lun == pdi->lun) {
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Retries: \t%-6d \tReassigns: \t%d\n",
|
|
|
|
pds->list[k].retries,
|
|
|
|
pds->list[k].reassigns);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* 2.c grown defects */
|
|
|
|
TRACE2(("scsi_drv_defcnt() chn %d dev %d\n",
|
|
|
|
i, ha->raw[i].id_list[j]));
|
|
|
|
pdef = (gdth_defcnt_str *)buf;
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd->u.ioctl.param_size = sizeof(gdth_defcnt_str);
|
|
|
|
gdtcmd->u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN;
|
|
|
|
gdtcmd->u.ioctl.channel =
|
|
|
|
ha->raw[i].address | ha->raw[i].id_list[j];
|
|
|
|
pdef->sddc_type = 0x08;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Grown Defects:\t%d\n",
|
|
|
|
pdef->sddc_cnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (!flag)
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\n --\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 3. about logical drives */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nLogical Drives:");
|
2005-04-17 06:20:36 +08:00
|
|
|
flag = FALSE;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!buf)
|
|
|
|
goto stop_output;
|
|
|
|
for (i = 0; i < MAX_LDRIVES; ++i) {
|
|
|
|
if (!ha->hdr[i].is_logdrv)
|
|
|
|
continue;
|
|
|
|
drv_no = i;
|
|
|
|
j = k = 0;
|
|
|
|
is_mirr = FALSE;
|
|
|
|
do {
|
|
|
|
/* 3.a log. drive info */
|
|
|
|
TRACE2(("cache_drv_info() drive no %d\n",drv_no));
|
|
|
|
pcdi = (gdth_cdrinfo_str *)buf;
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
|
|
|
|
gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO;
|
|
|
|
gdtcmd->u.ioctl.channel = drv_no;
|
2006-06-10 02:34:29 +08:00
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
pcdi->ld_dtype >>= 16;
|
|
|
|
j++;
|
|
|
|
if (pcdi->ld_dtype > 2) {
|
|
|
|
strcpy(hrec, "missing");
|
|
|
|
} else if (pcdi->ld_error & 1) {
|
|
|
|
strcpy(hrec, "fault");
|
|
|
|
} else if (pcdi->ld_error & 2) {
|
|
|
|
strcpy(hrec, "invalid");
|
|
|
|
k++; j--;
|
|
|
|
} else {
|
|
|
|
strcpy(hrec, "ok");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drv_no == i) {
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
"\n Number: \t%-2d \tStatus: \t%s\n",
|
|
|
|
drv_no, hrec);
|
|
|
|
flag = TRUE;
|
|
|
|
no_mdrv = pcdi->cd_ldcnt;
|
|
|
|
if (no_mdrv > 1 || pcdi->ld_slave != -1) {
|
|
|
|
is_mirr = TRUE;
|
|
|
|
strcpy(hrec, "RAID-1");
|
|
|
|
} else if (pcdi->ld_dtype == 0) {
|
|
|
|
strcpy(hrec, "Disk");
|
|
|
|
} else if (pcdi->ld_dtype == 1) {
|
|
|
|
strcpy(hrec, "RAID-0");
|
|
|
|
} else if (pcdi->ld_dtype == 2) {
|
|
|
|
strcpy(hrec, "Chain");
|
|
|
|
} else {
|
|
|
|
strcpy(hrec, "???");
|
|
|
|
}
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Capacity [MB]:\t%-6d \tType: \t%s\n",
|
|
|
|
pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize),
|
|
|
|
hrec);
|
|
|
|
} else {
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Slave Number: \t%-2d \tStatus: \t%s\n",
|
|
|
|
drv_no & 0x7fff, hrec);
|
|
|
|
}
|
|
|
|
drv_no = pcdi->ld_slave;
|
|
|
|
} while (drv_no != -1);
|
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (is_mirr)
|
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n",
|
|
|
|
no_mdrv - j - k, k);
|
2013-03-31 12:52:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ha->hdr[i].is_arraydrv)
|
|
|
|
strcpy(hrec, "--");
|
|
|
|
else
|
|
|
|
sprintf(hrec, "%d", ha->hdr[i].master_no);
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" To Array Drv.:\t%s\n", hrec);
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (!flag)
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\n --\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 4. about array drives */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nArray Drives:");
|
2005-04-17 06:20:36 +08:00
|
|
|
flag = FALSE;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!buf)
|
|
|
|
goto stop_output;
|
|
|
|
for (i = 0; i < MAX_LDRIVES; ++i) {
|
|
|
|
if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
|
|
|
|
continue;
|
|
|
|
/* 4.a array drive info */
|
|
|
|
TRACE2(("array_info() drive no %d\n",i));
|
|
|
|
pai = (gdth_arrayinf_str *)buf;
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str);
|
|
|
|
gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
|
|
|
|
gdtcmd->u.ioctl.channel = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pai->ai_state == 0)
|
|
|
|
strcpy(hrec, "idle");
|
|
|
|
else if (pai->ai_state == 2)
|
|
|
|
strcpy(hrec, "build");
|
|
|
|
else if (pai->ai_state == 4)
|
|
|
|
strcpy(hrec, "ready");
|
|
|
|
else if (pai->ai_state == 6)
|
|
|
|
strcpy(hrec, "fail");
|
|
|
|
else if (pai->ai_state == 8 || pai->ai_state == 10)
|
|
|
|
strcpy(hrec, "rebuild");
|
|
|
|
else
|
|
|
|
strcpy(hrec, "error");
|
|
|
|
if (pai->ai_ext_state & 0x10)
|
|
|
|
strcat(hrec, "/expand");
|
|
|
|
else if (pai->ai_ext_state & 0x1)
|
|
|
|
strcat(hrec, "/patch");
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
"\n Number: \t%-2d \tStatus: \t%s\n",
|
|
|
|
i,hrec);
|
|
|
|
flag = TRUE;
|
|
|
|
|
|
|
|
if (pai->ai_type == 0)
|
|
|
|
strcpy(hrec, "RAID-0");
|
|
|
|
else if (pai->ai_type == 4)
|
|
|
|
strcpy(hrec, "RAID-4");
|
|
|
|
else if (pai->ai_type == 5)
|
|
|
|
strcpy(hrec, "RAID-5");
|
|
|
|
else
|
|
|
|
strcpy(hrec, "RAID-10");
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Capacity [MB]:\t%-6d \tType: \t%s\n",
|
|
|
|
pai->ai_size/(1024*1024/pai->ai_secsize),
|
|
|
|
hrec);
|
|
|
|
}
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (!flag)
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\n --\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 5. about host drives */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nHost Drives:");
|
2005-04-17 06:20:36 +08:00
|
|
|
flag = FALSE;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!buf)
|
|
|
|
goto stop_output;
|
|
|
|
for (i = 0; i < MAX_LDRIVES; ++i) {
|
|
|
|
if (!ha->hdr[i].is_logdrv ||
|
|
|
|
(ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
|
|
|
|
continue;
|
|
|
|
/* 5.a get host drive list */
|
|
|
|
TRACE2(("host_get() drv_no %d\n",i));
|
|
|
|
phg = (gdth_hget_str *)buf;
|
|
|
|
gdtcmd->Service = CACHESERVICE;
|
|
|
|
gdtcmd->OpCode = GDT_IOCTL;
|
|
|
|
gdtcmd->u.ioctl.p_param = paddr;
|
|
|
|
gdtcmd->u.ioctl.param_size = sizeof(gdth_hget_str);
|
|
|
|
gdtcmd->u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN;
|
|
|
|
gdtcmd->u.ioctl.channel = i;
|
|
|
|
phg->entries = MAX_HDRIVES;
|
|
|
|
phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
|
2006-06-10 02:34:29 +08:00
|
|
|
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->hdr[i].ldr_no = i;
|
|
|
|
ha->hdr[i].rw_attribs = 0;
|
|
|
|
ha->hdr[i].start_sec = 0;
|
|
|
|
} else {
|
|
|
|
for (j = 0; j < phg->entries; ++j) {
|
|
|
|
k = phg->entry[j].host_drive;
|
|
|
|
if (k >= MAX_LDRIVES)
|
|
|
|
continue;
|
|
|
|
ha->hdr[k].ldr_no = phg->entry[j].log_drive;
|
|
|
|
ha->hdr[k].rw_attribs = phg->entry[j].rw_attribs;
|
|
|
|
ha->hdr[k].start_sec = phg->entry[j].start_sec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_HDRIVES; ++i) {
|
|
|
|
if (!(ha->hdr[i].present))
|
|
|
|
continue;
|
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
"\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
|
|
|
|
i, ha->hdr[i].ldr_no);
|
|
|
|
flag = TRUE;
|
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m,
|
2005-04-17 06:20:36 +08:00
|
|
|
" Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
|
2010-01-04 23:19:34 +08:00
|
|
|
(u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-03-31 12:52:08 +08:00
|
|
|
if (!flag)
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\n --\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* controller events */
|
2014-12-03 07:10:52 +08:00
|
|
|
seq_puts(m, "\nController Events:\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (id = -1;;) {
|
|
|
|
id = gdth_read_event(ha, id, estr);
|
|
|
|
if (estr->event_source == 0)
|
|
|
|
break;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (estr->event_data.eu.driver.ionode == ha->hanum &&
|
2005-04-17 06:20:36 +08:00
|
|
|
estr->event_source == ES_ASYNC) {
|
|
|
|
gdth_log_event(&estr->event_data, hrec);
|
2016-02-18 13:29:34 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Elapsed seconds subtraction with unsigned operands is
|
|
|
|
* safe from wrap around in year 2106. Executes as:
|
|
|
|
* operand a + (2's complement operand b) + 1
|
|
|
|
*/
|
|
|
|
|
|
|
|
sec = (int)((u32)ktime_get_real_seconds() - estr->first_stamp);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (sec < 0) sec = 0;
|
2013-03-31 12:52:08 +08:00
|
|
|
seq_printf(m," date- %02d:%02d:%02d\t%s\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
sec/3600, sec%3600/60, sec%60, hrec);
|
|
|
|
}
|
|
|
|
if (id == -1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stop_output:
|
2013-03-31 12:52:08 +08:00
|
|
|
rc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
free_fail:
|
|
|
|
kfree(gdtcmd);
|
|
|
|
kfree(estr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch,
|
2010-01-04 23:19:34 +08:00
|
|
|
u64 *paddr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
char *ret_val;
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
if (!ha->scratch_busy && size <= GDTH_SCRATCH) {
|
|
|
|
ha->scratch_busy = TRUE;
|
|
|
|
ret_val = ha->pscratch;
|
|
|
|
*paddr = ha->scratch_phys;
|
|
|
|
} else if (scratch) {
|
|
|
|
ret_val = NULL;
|
|
|
|
} else {
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
|
|
|
|
ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr);
|
|
|
|
*paddr = dma_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, u64 paddr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (buf == ha->pscratch) {
|
2008-02-18 01:24:51 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->scratch_busy = FALSE;
|
2008-02-18 01:24:51 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
pci_free_consistent(ha->pdev, size, buf, paddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDTH_IOCTL_PROC
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_ioctl_check_bin(gdth_ha_str *ha, u16 size)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
int ret_val;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
ret_val = FALSE;
|
|
|
|
if (ha->scratch_busy) {
|
2010-01-04 23:19:34 +08:00
|
|
|
if (((gdth_iord_str *)ha->pscratch)->size == (u32)size)
|
2005-04-17 06:20:36 +08:00
|
|
|
ret_val = TRUE;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
Scsi_Cmnd *scp;
|
2007-10-03 05:16:01 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b, t;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
for (i = 0; i < GDTH_MAXCMDS; ++i) {
|
|
|
|
scp = ha->cmd_tab[i].cmnd;
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo = gdth_cmnd_priv(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 04:59:53 +08:00
|
|
|
b = scp->device->channel;
|
2005-04-17 06:20:36 +08:00
|
|
|
t = scp->device->id;
|
2010-01-04 23:19:34 +08:00
|
|
|
if (!SPECIAL_SCP(scp) && t == (u8)id &&
|
|
|
|
b == (u8)busnum) {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->wait_for_completion = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2007-10-03 05:16:01 +08:00
|
|
|
while (!cmndinfo->wait_for_completion)
|
2005-04-17 06:20:36 +08:00
|
|
|
barrier();
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|