2019-05-24 18:04:08 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/************************************************************************
|
|
|
|
* Linux driver for *
|
2018-12-12 15:41:21 +08:00
|
|
|
* ICP vortex GmbH: GDT PCI Disk Array Controllers *
|
2005-04-17 06:20:36 +08:00
|
|
|
* Intel Corporation: Storage RAID Controllers *
|
|
|
|
* *
|
|
|
|
* gdth.c *
|
2006-06-10 02:34:29 +08:00
|
|
|
* Copyright (C) 1995-06 ICP vortex GmbH, Achim Leubner *
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (C) 2002-04 Intel Corporation *
|
2006-06-10 02:34:29 +08:00
|
|
|
* Copyright (C) 2003-06 Adaptec Inc. *
|
2005-04-17 06:20:36 +08:00
|
|
|
* <achim_leubner@adaptec.com> *
|
|
|
|
* *
|
|
|
|
* Additions/Fixes: *
|
|
|
|
* Boji Tony Kannanthanam <boji.t.kannanthanam@intel.com> *
|
|
|
|
* Johannes Dinner <johannes_dinner@adaptec.com> *
|
|
|
|
* *
|
|
|
|
* *
|
2007-10-03 04:54:28 +08:00
|
|
|
* Linux kernel 2.6.x supported *
|
2005-04-17 06:20:36 +08:00
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/* All GDT Disk Array Controllers are fully supported by this driver.
|
2018-12-12 15:41:21 +08:00
|
|
|
* This includes the PCI SCSI Disk Array Controllers and the
|
2005-04-17 06:20:36 +08:00
|
|
|
* PCI Fibre Channel Disk Array Controllers. See gdth.h for a complete
|
|
|
|
* list of all controller types.
|
|
|
|
*
|
|
|
|
* After the optional list of IRQ values, other possible
|
|
|
|
* command line options are:
|
|
|
|
* disable:Y disable driver
|
|
|
|
* disable:N enable driver
|
|
|
|
* reserve_mode:0 reserve no drives for the raw service
|
|
|
|
* reserve_mode:1 reserve all not init., removable drives
|
|
|
|
* reserve_mode:2 reserve all not init. drives
|
|
|
|
* reserve_list:h,b,t,l,h,b,t,l,... reserve particular drive(s) with
|
|
|
|
* h- controller no., b- channel no.,
|
|
|
|
* t- target ID, l- LUN
|
|
|
|
* reverse_scan:Y reverse scan order for PCI controllers
|
|
|
|
* reverse_scan:N scan PCI controllers like BIOS
|
|
|
|
* max_ids:x x - target ID count per channel (1..MAXID)
|
|
|
|
* rescan:Y rescan all channels/IDs
|
|
|
|
* rescan:N use all devices found until now
|
|
|
|
* hdr_channel:x x - number of virtual bus for host drives
|
|
|
|
* shared_access:Y disable driver reserve/release protocol to
|
|
|
|
* access a shared resource from several nodes,
|
2006-01-15 09:00:17 +08:00
|
|
|
* appropriate controller firmware required
|
2005-04-17 06:20:36 +08:00
|
|
|
* shared_access:N enable driver reserve/release protocol
|
|
|
|
* force_dma32:Y use only 32 bit DMA mode
|
|
|
|
* force_dma32:N use 64 bit DMA mode, if supported
|
|
|
|
*
|
|
|
|
* The default values are: "gdth=disable:N,reserve_mode:1,reverse_scan:N,
|
2007-10-03 04:59:53 +08:00
|
|
|
* max_ids:127,rescan:N,hdr_channel:0,
|
2018-12-12 15:41:21 +08:00
|
|
|
* shared_access:Y,force_dma32:N".
|
2005-04-17 06:20:36 +08:00
|
|
|
* Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y".
|
|
|
|
*
|
|
|
|
* When loading the gdth driver as a module, the same options are available.
|
|
|
|
* You can set the IRQs with "IRQ=...". However, the syntax to specify the
|
|
|
|
* options changes slightly. You must replace all ',' between options
|
|
|
|
* with ' ' and all ':' with '=' and you must use
|
|
|
|
* '1' in place of 'Y' and '0' in place of 'N'.
|
|
|
|
*
|
|
|
|
* Default: "modprobe gdth disable=0 reserve_mode=1 reverse_scan=0
|
2007-10-03 04:59:53 +08:00
|
|
|
* max_ids=127 rescan=0 hdr_channel=0 shared_access=0
|
2018-12-12 15:41:21 +08:00
|
|
|
* force_dma32=0"
|
2005-04-17 06:20:36 +08:00
|
|
|
* The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The meaning of the Scsi_Pointer members in this driver is as follows:
|
|
|
|
* ptr: Chaining
|
2008-02-28 07:31:20 +08:00
|
|
|
* this_residual: unused
|
|
|
|
* buffer: unused
|
2007-10-03 05:18:03 +08:00
|
|
|
* dma_handle: unused
|
2008-02-28 07:31:20 +08:00
|
|
|
* buffers_residual: unused
|
2007-10-03 05:18:03 +08:00
|
|
|
* Status: unused
|
2007-10-03 05:16:01 +08:00
|
|
|
* Message: unused
|
|
|
|
* have_data_in: unused
|
|
|
|
* sent_command: unused
|
|
|
|
* phase: unused
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* statistics */
|
|
|
|
#define GDTH_STATISTICS
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/timer.h>
|
2006-03-28 17:56:48 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
2007-10-03 05:09:56 +08:00
|
|
|
#include <linux/list.h>
|
2010-06-02 20:28:52 +08:00
|
|
|
#include <linux/mutex.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
|
|
|
#include <linux/reboot.h>
|
|
|
|
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/io.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/blkdev.h>
|
2007-10-03 05:18:03 +08:00
|
|
|
#include <linux/scatterlist.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "scsi.h"
|
|
|
|
#include <scsi/scsi_host.h>
|
2006-06-10 02:34:29 +08:00
|
|
|
#include "gdth.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-06-02 20:28:52 +08:00
|
|
|
static DEFINE_MUTEX(gdth_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void gdth_delay(int milliseconds);
|
2010-01-04 23:19:34 +08:00
|
|
|
static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs);
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t gdth_interrupt(int irq, void *dev_id);
|
2007-12-14 08:14:12 +08:00
|
|
|
static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
|
2007-10-03 05:08:10 +08:00
|
|
|
int gdth_from_wait, int* pIndex);
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index,
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *scp);
|
2007-10-03 05:05:53 +08:00
|
|
|
static int gdth_async_event(gdth_ha_str *ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void gdth_log_event(gdth_evt_data *dvr, char *buffer);
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static void gdth_putq(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 priority);
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_next(gdth_ha_str *ha);
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b);
|
|
|
|
static int gdth_special_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp);
|
2010-01-04 23:19:34 +08:00
|
|
|
static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, u16 source,
|
|
|
|
u16 idx, gdth_evt_data *evt);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr);
|
2010-01-04 23:19:34 +08:00
|
|
|
static void gdth_readapp_event(gdth_ha_str *ha, u8 application,
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_evt_str *estr);
|
|
|
|
static void gdth_clear_events(void);
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static void gdth_copy_internal_data(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
2010-01-04 23:19:34 +08:00
|
|
|
char *buffer, u16 count);
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp);
|
|
|
|
static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
|
|
|
u16 hdrive);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_enable_int(gdth_ha_str *ha);
|
|
|
|
static int gdth_test_busy(gdth_ha_str *ha);
|
|
|
|
static int gdth_get_cmd_index(gdth_ha_str *ha);
|
|
|
|
static void gdth_release_event(gdth_ha_str *ha);
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_wait(gdth_ha_str *ha, int index,u32 time);
|
|
|
|
static int gdth_internal_cmd(gdth_ha_str *ha, u8 service, u16 opcode,
|
|
|
|
u32 p1, u64 p2,u64 p3);
|
2007-10-03 05:05:53 +08:00
|
|
|
static int gdth_search_drives(gdth_ha_str *ha);
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_analyse_hdrive(gdth_ha_str *ha, u16 hdrive);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static const char *gdth_ctr_name(gdth_ha_str *ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int gdth_open(struct inode *inode, struct file *filep);
|
|
|
|
static int gdth_close(struct inode *inode, struct file *filep);
|
2010-04-27 06:24:01 +08:00
|
|
|
static long gdth_unlocked_ioctl(struct file *filep, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_flush(gdth_ha_str *ha);
|
2010-11-16 15:10:29 +08:00
|
|
|
static int gdth_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
|
2007-10-03 05:14:39 +08:00
|
|
|
static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
|
|
|
struct gdth_cmndinfo *cmndinfo);
|
2006-06-10 02:34:29 +08:00
|
|
|
static void gdth_scsi_done(struct scsi_cmnd *scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG_GDTH
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 DebugState = DEBUG_GDTH;
|
2005-04-17 06:20:36 +08:00
|
|
|
#define TRACE(a) {if (DebugState==1) {printk a;}}
|
|
|
|
#define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}}
|
|
|
|
#define TRACE3(a) {if (DebugState!=0) {printk a;}}
|
|
|
|
#else /* !DEBUG */
|
|
|
|
#define TRACE(a)
|
|
|
|
#define TRACE2(a)
|
|
|
|
#define TRACE3(a)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
2010-01-04 23:19:34 +08:00
|
|
|
static u32 max_rq=0, max_index=0, max_sg=0;
|
|
|
|
static u32 act_ints=0, act_ios=0, act_stats=0, act_rq=0;
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct timer_list gdth_timer;
|
|
|
|
#endif
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
#define PTR2USHORT(a) (u16)(unsigned long)(a)
|
2006-06-09 13:23:48 +08:00
|
|
|
#define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
|
|
|
|
#define INDEX_OK(i,t) ((i)<ARRAY_SIZE(t))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 gdth_polling; /* polling if TRUE */
|
2005-04-17 06:20:36 +08:00
|
|
|
static int gdth_ctr_count = 0; /* controller count */
|
2007-10-03 05:11:24 +08:00
|
|
|
static LIST_HEAD(gdth_instances); /* controller list */
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 gdth_write_through = FALSE; /* write through */
|
2005-04-17 06:20:36 +08:00
|
|
|
static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */
|
|
|
|
static int elastidx;
|
|
|
|
static int eoldidx;
|
|
|
|
static int major;
|
|
|
|
|
|
|
|
#define DIN 1 /* IN data direction */
|
|
|
|
#define DOU 2 /* OUT data direction */
|
|
|
|
#define DNO DIN /* no data transfer */
|
|
|
|
#define DUN DIN /* unknown data direction */
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 gdth_direction_tab[0x100] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN,
|
|
|
|
DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN,
|
|
|
|
DIN,DUN,DIN,DUN,DOU,DIN,DUN,DUN,DIN,DIN,DOU,DNO,DUN,DIN,DOU,DOU,
|
|
|
|
DOU,DOU,DOU,DNO,DIN,DNO,DNO,DIN,DOU,DOU,DOU,DOU,DIN,DOU,DIN,DOU,
|
|
|
|
DOU,DOU,DIN,DIN,DIN,DNO,DUN,DNO,DNO,DNO,DUN,DNO,DOU,DIN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DIN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DIN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DIN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DNO,DNO,DUN,DIN,DNO,DOU,DUN,DNO,DUN,DOU,DOU,
|
|
|
|
DOU,DOU,DOU,DNO,DUN,DIN,DOU,DIN,DIN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,
|
|
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN
|
|
|
|
};
|
|
|
|
|
|
|
|
/* LILO and modprobe/insmod parameters */
|
|
|
|
/* disable driver flag */
|
|
|
|
static int disable __initdata = 0;
|
|
|
|
/* reserve flag */
|
|
|
|
static int reserve_mode = 1;
|
|
|
|
/* reserve list */
|
|
|
|
static int reserve_list[MAX_RES_ARGS] =
|
|
|
|
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
|
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
|
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
|
|
|
|
/* scan order for PCI controllers */
|
|
|
|
static int reverse_scan = 0;
|
|
|
|
/* virtual channel for the host drives */
|
|
|
|
static int hdr_channel = 0;
|
|
|
|
/* max. IDs per channel */
|
|
|
|
static int max_ids = MAXID;
|
|
|
|
/* rescan all IDs */
|
|
|
|
static int rescan = 0;
|
|
|
|
/* shared access */
|
|
|
|
static int shared_access = 1;
|
|
|
|
/* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
|
|
|
|
static int force_dma32 = 0;
|
|
|
|
|
|
|
|
/* parameters for modprobe/insmod */
|
|
|
|
module_param(disable, int, 0);
|
|
|
|
module_param(reserve_mode, int, 0);
|
|
|
|
module_param_array(reserve_list, int, NULL, 0);
|
|
|
|
module_param(reverse_scan, int, 0);
|
|
|
|
module_param(hdr_channel, int, 0);
|
|
|
|
module_param(max_ids, int, 0);
|
|
|
|
module_param(rescan, int, 0);
|
|
|
|
module_param(shared_access, int, 0);
|
|
|
|
module_param(force_dma32, int, 0);
|
|
|
|
MODULE_AUTHOR("Achim Leubner");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/* ioctl interface */
|
2007-02-12 16:55:34 +08:00
|
|
|
static const struct file_operations gdth_fops = {
|
2010-04-27 06:24:01 +08:00
|
|
|
.unlocked_ioctl = gdth_unlocked_ioctl,
|
2005-04-17 06:20:36 +08:00
|
|
|
.open = gdth_open,
|
|
|
|
.release = gdth_close,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-16 00:52:59 +08:00
|
|
|
.llseek = noop_llseek,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#include "gdth_proc.h"
|
|
|
|
#include "gdth_proc.c"
|
|
|
|
|
2007-10-03 05:11:24 +08:00
|
|
|
static gdth_ha_str *gdth_find_ha(int hanum)
|
|
|
|
{
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
|
|
|
list_for_each_entry(ha, &gdth_instances, list)
|
|
|
|
if (hanum == ha->hanum)
|
|
|
|
return ha;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
static struct gdth_cmndinfo *gdth_get_cmndinfo(gdth_ha_str *ha)
|
|
|
|
{
|
|
|
|
struct gdth_cmndinfo *priv = NULL;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2007-10-03 05:14:39 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
for (i=0; i<GDTH_MAXCMDS; ++i) {
|
|
|
|
if (ha->cmndinfo[i].index == 0) {
|
|
|
|
priv = &ha->cmndinfo[i];
|
|
|
|
memset(priv, 0, sizeof(*priv));
|
2008-02-28 07:29:15 +08:00
|
|
|
priv->index = i+1;
|
2007-10-03 05:14:39 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gdth_put_cmndinfo(struct gdth_cmndinfo *priv)
|
|
|
|
{
|
|
|
|
BUG_ON(!priv);
|
|
|
|
priv->index = 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static void gdth_delay(int milliseconds)
|
|
|
|
{
|
|
|
|
if (milliseconds == 0) {
|
|
|
|
udelay(1);
|
|
|
|
} else {
|
|
|
|
mdelay(milliseconds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-10 02:34:29 +08:00
|
|
|
static void gdth_scsi_done(struct scsi_cmnd *scp)
|
|
|
|
{
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
|
|
|
int internal_command = cmndinfo->internal_command;
|
|
|
|
|
2007-10-03 04:40:22 +08:00
|
|
|
TRACE2(("gdth_scsi_done()\n"));
|
2006-06-10 02:34:29 +08:00
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
gdth_put_cmndinfo(cmndinfo);
|
|
|
|
scp->host_scribble = NULL;
|
|
|
|
|
|
|
|
if (internal_command)
|
2007-10-03 04:40:22 +08:00
|
|
|
complete((struct completion *)scp->request);
|
|
|
|
else
|
|
|
|
scp->scsi_done(scp);
|
2006-06-10 02:34:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
|
|
|
|
int timeout, u32 *info)
|
|
|
|
{
|
2007-10-03 05:14:39 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(sdev->host);
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *scp;
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo cmndinfo;
|
2006-10-01 14:28:10 +08:00
|
|
|
DECLARE_COMPLETION_ONSTACK(wait);
|
2006-06-10 02:34:29 +08:00
|
|
|
int rval;
|
|
|
|
|
[SCSI] kmalloc + memset conversion to kzalloc
In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-08-11 16:13:24 +08:00
|
|
|
scp = kzalloc(sizeof(*scp), GFP_KERNEL);
|
2006-06-10 02:34:29 +08:00
|
|
|
if (!scp)
|
|
|
|
return -ENOMEM;
|
[SCSI] kmalloc + memset conversion to kzalloc
In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-08-11 16:13:24 +08:00
|
|
|
|
2008-03-11 05:50:04 +08:00
|
|
|
scp->sense_buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
|
|
|
|
if (!scp->sense_buffer) {
|
|
|
|
kfree(scp);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2006-06-10 02:34:29 +08:00
|
|
|
scp->device = sdev;
|
2007-10-03 05:14:39 +08:00
|
|
|
memset(&cmndinfo, 0, sizeof(cmndinfo));
|
|
|
|
|
2006-06-11 00:01:03 +08:00
|
|
|
/* use request field to save the ptr. to completion struct. */
|
|
|
|
scp->request = (struct request *)&wait;
|
2006-06-10 02:34:29 +08:00
|
|
|
scp->cmd_len = 12;
|
2008-04-30 16:19:47 +08:00
|
|
|
scp->cmnd = cmnd;
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo.priority = IOCTL_PRI;
|
2008-02-28 07:29:15 +08:00
|
|
|
cmndinfo.internal_cmd_str = gdtcmd;
|
2007-10-03 05:14:39 +08:00
|
|
|
cmndinfo.internal_command = 1;
|
|
|
|
|
|
|
|
TRACE(("__gdth_execute() cmd 0x%x\n", scp->cmnd[0]));
|
|
|
|
__gdth_queuecommand(ha, scp, &cmndinfo);
|
|
|
|
|
2006-06-10 02:34:29 +08:00
|
|
|
wait_for_completion(&wait);
|
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
rval = cmndinfo.status;
|
2006-06-10 02:34:29 +08:00
|
|
|
if (info)
|
2007-10-03 05:16:01 +08:00
|
|
|
*info = cmndinfo.info;
|
2008-03-11 05:50:04 +08:00
|
|
|
kfree(scp->sense_buffer);
|
2006-06-10 02:34:29 +08:00
|
|
|
kfree(scp);
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd,
|
|
|
|
int timeout, u32 *info)
|
|
|
|
{
|
|
|
|
struct scsi_device *sdev = scsi_get_host_dev(shost);
|
|
|
|
int rval = __gdth_execute(sdev, gdtcmd, cmnd, timeout, info);
|
|
|
|
|
|
|
|
scsi_free_host_dev(sdev);
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
*cyls = size /HEADS/SECS;
|
|
|
|
if (*cyls <= MAXCYLS) {
|
|
|
|
*heads = HEADS;
|
|
|
|
*secs = SECS;
|
|
|
|
} else { /* too high for 64*32 */
|
|
|
|
*cyls = size /MEDHEADS/MEDSECS;
|
|
|
|
if (*cyls <= MAXCYLS) {
|
|
|
|
*heads = MEDHEADS;
|
|
|
|
*secs = MEDSECS;
|
|
|
|
} else { /* too high for 127*63 */
|
|
|
|
*cyls = size /BIGHEADS/BIGSECS;
|
|
|
|
*heads = BIGHEADS;
|
|
|
|
*secs = BIGSECS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static bool gdth_search_vortex(u16 device)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-16 11:20:09 +08:00
|
|
|
if (device <= PCI_DEVICE_ID_VORTEX_GDT6555)
|
|
|
|
return true;
|
|
|
|
if (device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP &&
|
|
|
|
device <= PCI_DEVICE_ID_VORTEX_GDTMAXRP)
|
|
|
|
return true;
|
|
|
|
if (device == PCI_DEVICE_ID_VORTEX_GDTNEWRX ||
|
|
|
|
device == PCI_DEVICE_ID_VORTEX_GDTNEWRX2)
|
|
|
|
return true;
|
|
|
|
return false;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out);
|
|
|
|
static int gdth_pci_init_one(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent);
|
|
|
|
static void gdth_pci_remove_one(struct pci_dev *pdev);
|
|
|
|
static void gdth_remove_one(gdth_ha_str *ha);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Vortex only makes RAID controllers.
|
|
|
|
* We do not really want to specify all 550 ids here, so wildcard match.
|
|
|
|
*/
|
2008-02-16 11:20:09 +08:00
|
|
|
static const struct pci_device_id gdthtable[] = {
|
|
|
|
{ PCI_VDEVICE(VORTEX, PCI_ANY_ID) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC_XSCALE) },
|
|
|
|
{ } /* terminate list */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2008-02-16 11:20:09 +08:00
|
|
|
MODULE_DEVICE_TABLE(pci, gdthtable);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
static struct pci_driver gdth_pci_driver = {
|
|
|
|
.name = "gdth",
|
|
|
|
.id_table = gdthtable,
|
|
|
|
.probe = gdth_pci_init_one,
|
|
|
|
.remove = gdth_pci_remove_one,
|
|
|
|
};
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static void gdth_pci_remove_one(struct pci_dev *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-16 11:20:09 +08:00
|
|
|
gdth_ha_str *ha = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
list_del(&ha->list);
|
|
|
|
gdth_remove_one(ha);
|
|
|
|
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static int gdth_pci_init_one(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent)
|
2008-02-16 11:20:09 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 vendor = pdev->vendor;
|
|
|
|
u16 device = pdev->device;
|
|
|
|
unsigned long base0, base1, base2;
|
2008-02-16 11:20:09 +08:00
|
|
|
int rc;
|
|
|
|
gdth_pci_str gdth_pcistr;
|
|
|
|
gdth_ha_str *ha = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n",
|
|
|
|
gdth_ctr_count, vendor, device));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
memset(&gdth_pcistr, 0, sizeof(gdth_pcistr));
|
|
|
|
|
|
|
|
if (vendor == PCI_VENDOR_ID_VORTEX && !gdth_search_vortex(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
rc = pci_enable_device(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
if (gdth_ctr_count >= MAXHA)
|
|
|
|
return -EBUSY;
|
2008-02-13 07:48:03 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* GDT PCI controller found, resources are already in pdev */
|
2008-02-16 11:20:09 +08:00
|
|
|
gdth_pcistr.pdev = pdev;
|
2005-04-17 06:20:36 +08:00
|
|
|
base0 = pci_resource_flags(pdev, 0);
|
|
|
|
base1 = pci_resource_flags(pdev, 1);
|
|
|
|
base2 = pci_resource_flags(pdev, 2);
|
|
|
|
if (device <= PCI_DEVICE_ID_VORTEX_GDT6000B || /* GDT6000/B */
|
|
|
|
device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP) { /* MPR */
|
|
|
|
if (!(base0 & IORESOURCE_MEM))
|
2008-02-16 11:20:09 +08:00
|
|
|
return -ENODEV;
|
|
|
|
gdth_pcistr.dpmem = pci_resource_start(pdev, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else { /* GDT6110, GDT6120, .. */
|
|
|
|
if (!(base0 & IORESOURCE_MEM) ||
|
|
|
|
!(base2 & IORESOURCE_MEM) ||
|
|
|
|
!(base1 & IORESOURCE_IO))
|
2008-02-16 11:20:09 +08:00
|
|
|
return -ENODEV;
|
|
|
|
gdth_pcistr.dpmem = pci_resource_start(pdev, 2);
|
|
|
|
gdth_pcistr.io = pci_resource_start(pdev, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
|
2008-02-16 11:20:09 +08:00
|
|
|
gdth_pcistr.pdev->bus->number,
|
|
|
|
PCI_SLOT(gdth_pcistr.pdev->devfn),
|
|
|
|
gdth_pcistr.irq,
|
|
|
|
gdth_pcistr.dpmem));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
rc = gdth_pci_probe_one(&gdth_pcistr, &ha);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static int gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr,
|
|
|
|
gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdt6_dpram_str __iomem *dp6_ptr;
|
|
|
|
register gdt6c_dpram_str __iomem *dp6c_ptr;
|
|
|
|
register gdt6m_dpram_str __iomem *dp6m_ptr;
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 retries;
|
|
|
|
u8 prot_ver;
|
|
|
|
u16 command;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i, found = FALSE;
|
|
|
|
|
|
|
|
TRACE(("gdth_init_pci()\n"));
|
|
|
|
|
2008-02-16 10:35:26 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL)
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->oem_id = OEM_ID_INTEL;
|
|
|
|
else
|
|
|
|
ha->oem_id = OEM_ID_ICP;
|
2008-02-16 10:35:26 +08:00
|
|
|
ha->brd_phys = (pdev->bus->number << 8) | (pdev->devfn & 0xf8);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->stype = (u32)pdev->device;
|
2008-02-16 10:35:26 +08:00
|
|
|
ha->irq = pdev->irq;
|
|
|
|
ha->pdev = pdev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-07-17 17:25:17 +08:00
|
|
|
if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
|
|
|
|
ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* check and reset interface area */
|
|
|
|
dp6_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6_ptr->u);
|
|
|
|
if (readl(&dp6_ptr->u) != DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
|
|
|
|
pcistr->dpmem);
|
|
|
|
found = FALSE;
|
|
|
|
for (i = 0xC8000; i < 0xE8000; i += 0x4000) {
|
|
|
|
iounmap(ha->brd);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(u16));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
if (readw(ha->brd) != 0xffff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("init_pci_old() address 0x%x busy\n", i));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
iounmap(ha->brd);
|
2008-02-16 10:35:26 +08:00
|
|
|
pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(gdt6_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
dp6_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6_ptr->u);
|
|
|
|
if (readl(&dp6_ptr->u) == DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Use free address at 0x%x\n", i);
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
printk("GDT-PCI: No free address found!\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memset_io(&dp6_ptr->u, 0, sizeof(dp6_ptr->u));
|
2007-10-03 04:55:53 +08:00
|
|
|
if (readl(&dp6_ptr->u) != 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable board interrupts, deinit services */
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
|
|
|
writeb(0x00, &dp6_ptr->io.irqen);
|
|
|
|
writeb(0x00, &dp6_ptr->u.ic.S_Status);
|
|
|
|
writeb(0x00, &dp6_ptr->u.ic.Cmd_Index);
|
|
|
|
|
|
|
|
writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]);
|
|
|
|
writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx);
|
|
|
|
writeb(0, &dp6_ptr->io.event);
|
2005-04-17 06:20:36 +08:00
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
prot_ver = (u8)readl(&dp6_ptr->u.ic.S_Info[0]);
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6_ptr->u.ic.S_Status);
|
|
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
|
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->type = GDT_PCI;
|
|
|
|
ha->ic_all_size = sizeof(dp6_ptr->u);
|
|
|
|
|
|
|
|
/* special command to controller BIOS */
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[0]);
|
|
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[1]);
|
|
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[2]);
|
|
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[3]);
|
|
|
|
writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx);
|
|
|
|
writeb(0, &dp6_ptr->io.event);
|
2005-04-17 06:20:36 +08:00
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6_ptr->u.ic.S_Status);
|
|
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ha->dma64_support = 0;
|
|
|
|
|
2007-07-17 17:25:17 +08:00
|
|
|
} else if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->plx = (gdt6c_plx_regs *)pcistr->io;
|
|
|
|
TRACE2(("init_pci_new() dpmem %lx irq %d\n",
|
|
|
|
pcistr->dpmem,ha->irq));
|
|
|
|
ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6c_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* check and reset interface area */
|
|
|
|
dp6c_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6c_ptr->u);
|
|
|
|
if (readl(&dp6c_ptr->u) != DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
|
|
|
|
pcistr->dpmem);
|
|
|
|
found = FALSE;
|
|
|
|
for (i = 0xC8000; i < 0xE8000; i += 0x4000) {
|
|
|
|
iounmap(ha->brd);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(u16));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
if (readw(ha->brd) != 0xffff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("init_pci_plx() address 0x%x busy\n", i));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
iounmap(ha->brd);
|
2008-02-16 10:35:26 +08:00
|
|
|
pci_write_config_dword(pdev, PCI_BASE_ADDRESS_2, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(gdt6c_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
dp6c_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6c_ptr->u);
|
|
|
|
if (readl(&dp6c_ptr->u) == DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Use free address at 0x%x\n", i);
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
printk("GDT-PCI: No free address found!\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memset_io(&dp6c_ptr->u, 0, sizeof(dp6c_ptr->u));
|
2007-10-03 04:55:53 +08:00
|
|
|
if (readl(&dp6c_ptr->u) != 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable board interrupts, deinit services */
|
|
|
|
outb(0x00,PTR2USHORT(&ha->plx->control1));
|
|
|
|
outb(0xff,PTR2USHORT(&ha->plx->edoor_reg));
|
|
|
|
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0x00, &dp6c_ptr->u.ic.S_Status);
|
|
|
|
writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]);
|
|
|
|
writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
|
|
|
|
|
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
prot_ver = (u8)readl(&dp6c_ptr->u.ic.S_Info[0]);
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6c_ptr->u.ic.Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
|
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->type = GDT_PCINEW;
|
|
|
|
ha->ic_all_size = sizeof(dp6c_ptr->u);
|
|
|
|
|
|
|
|
/* special command to controller BIOS */
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[0]);
|
|
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[1]);
|
|
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[2]);
|
|
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[3]);
|
|
|
|
writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
|
|
|
|
|
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6c_ptr->u.ic.S_Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ha->dma64_support = 0;
|
|
|
|
|
|
|
|
} else { /* MPR */
|
|
|
|
TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
|
|
|
|
ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6m_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* manipulate config. space to enable DPMEM, start RP controller */
|
2008-02-16 10:35:26 +08:00
|
|
|
pci_read_config_word(pdev, PCI_COMMAND, &command);
|
2005-04-17 06:20:36 +08:00
|
|
|
command |= 6;
|
2008-02-16 10:35:26 +08:00
|
|
|
pci_write_config_word(pdev, PCI_COMMAND, command);
|
2012-11-07 06:04:44 +08:00
|
|
|
gdth_delay(1);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
dp6m_ptr = ha->brd;
|
|
|
|
|
|
|
|
/* Ensure that it is safe to access the non HW portions of DPMEM.
|
|
|
|
* Aditional check needed for Xscale based RAID controllers */
|
2007-10-03 04:55:53 +08:00
|
|
|
while( ((int)readb(&dp6m_ptr->i960r.sema0_reg) ) & 3 )
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(1);
|
|
|
|
|
|
|
|
/* check and reset interface area */
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6m_ptr->u);
|
|
|
|
if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
|
|
|
|
pcistr->dpmem);
|
|
|
|
found = FALSE;
|
|
|
|
for (i = 0xC8000; i < 0xE8000; i += 0x4000) {
|
|
|
|
iounmap(ha->brd);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(u16));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
if (readw(ha->brd) != 0xffff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("init_pci_mpr() address 0x%x busy\n", i));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
iounmap(ha->brd);
|
2008-02-16 10:35:26 +08:00
|
|
|
pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->brd = ioremap(i, sizeof(gdt6m_dpram_str));
|
|
|
|
if (ha->brd == NULL) {
|
|
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
dp6m_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(DPMEM_MAGIC, &dp6m_ptr->u);
|
|
|
|
if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-PCI: Use free address at 0x%x\n", i);
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
printk("GDT-PCI: No free address found!\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memset_io(&dp6m_ptr->u, 0, sizeof(dp6m_ptr->u));
|
|
|
|
|
|
|
|
/* disable board interrupts, deinit services */
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6m_ptr->i960r.edoor_en_reg);
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
|
|
|
writeb(0x00, &dp6m_ptr->u.ic.S_Status);
|
|
|
|
writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]);
|
|
|
|
writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx);
|
|
|
|
writeb(1, &dp6m_ptr->i960r.ldoor_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
prot_ver = (u8)readl(&dp6m_ptr->u.ic.S_Info[0]);
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6m_ptr->u.ic.S_Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
|
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ha->type = GDT_PCIMPR;
|
|
|
|
ha->ic_all_size = sizeof(dp6m_ptr->u);
|
|
|
|
|
|
|
|
/* special command to controller BIOS */
|
2007-10-03 04:55:53 +08:00
|
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[0]);
|
|
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[1]);
|
|
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[2]);
|
|
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[3]);
|
|
|
|
writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx);
|
|
|
|
writeb(1, &dp6m_ptr->i960r.ldoor_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6m_ptr->u.ic.S_Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* read FW version to detect 64-bit DMA support */
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0xfd, &dp6m_ptr->u.ic.S_Cmd_Indx);
|
|
|
|
writeb(1, &dp6m_ptr->i960r.ldoor_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
retries = INIT_RETRIES;
|
|
|
|
gdth_delay(20);
|
2007-10-03 04:55:53 +08:00
|
|
|
while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfd) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (--retries == 0) {
|
|
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
|
|
|
iounmap(ha->brd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
prot_ver = (u8)(readl(&dp6m_ptr->u.ic.S_Info[0]) >> 16);
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &dp6m_ptr->u.ic.S_Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (prot_ver < 0x2b) /* FW < x.43: no 64-bit DMA support */
|
|
|
|
ha->dma64_support = 0;
|
|
|
|
else
|
|
|
|
ha->dma64_support = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* controller protocol functions */
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static void gdth_enable_int(gdth_ha_str *ha)
|
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
|
|
|
gdt6_dpram_str __iomem *dp6_ptr;
|
|
|
|
gdt6m_dpram_str __iomem *dp6m_ptr;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_enable_int() hanum %d\n",ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dp6_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(1, &dp6_ptr->io.irqdel);
|
|
|
|
writeb(0, &dp6_ptr->u.ic.Cmd_Index);
|
|
|
|
writeb(1, &dp6_ptr->io.irqen);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (ha->type == GDT_PCINEW) {
|
|
|
|
outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
|
|
|
|
outb(0x03, PTR2USHORT(&ha->plx->control1));
|
|
|
|
} else if (ha->type == GDT_PCIMPR) {
|
|
|
|
dp6m_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
|
|
|
writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6m_ptr->i960r.edoor_en_reg);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:08:10 +08:00
|
|
|
/* return IStatus if interrupt was from this card else 0 */
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 gdth_get_status(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 IStatus = 0;
|
2007-10-03 05:08:10 +08:00
|
|
|
|
2007-12-14 08:14:12 +08:00
|
|
|
TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha->irq, gdth_ctr_count));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI)
|
2007-10-03 05:08:10 +08:00
|
|
|
IStatus =
|
2007-10-03 04:55:53 +08:00
|
|
|
readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index);
|
2005-04-17 06:20:36 +08:00
|
|
|
else if (ha->type == GDT_PCINEW)
|
2007-10-03 05:08:10 +08:00
|
|
|
IStatus = inb(PTR2USHORT(&ha->plx->edoor_reg));
|
2005-04-17 06:20:36 +08:00
|
|
|
else if (ha->type == GDT_PCIMPR)
|
2007-10-03 05:08:10 +08:00
|
|
|
IStatus =
|
2007-10-03 04:55:53 +08:00
|
|
|
readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg);
|
2007-10-03 05:08:10 +08:00
|
|
|
|
|
|
|
return IStatus;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-03 05:08:10 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static int gdth_test_busy(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register int gdtsema0 = 0;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_test_busy() hanum %d\n", ha->hanum));
|
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI)
|
2007-10-03 04:55:53 +08:00
|
|
|
gdtsema0 = (int)readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
|
2005-04-17 06:20:36 +08:00
|
|
|
else if (ha->type == GDT_PCINEW)
|
|
|
|
gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg));
|
|
|
|
else if (ha->type == GDT_PCIMPR)
|
|
|
|
gdtsema0 =
|
2007-10-03 04:55:53 +08:00
|
|
|
(int)readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (gdtsema0 & 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static int gdth_get_cmd_index(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_get_cmd_index() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i=0; i<GDTH_MAXCMDS; ++i) {
|
|
|
|
if (ha->cmd_tab[i].cmnd == UNUSED_CMND) {
|
|
|
|
ha->cmd_tab[i].cmnd = ha->pccb->RequestBuffer;
|
|
|
|
ha->cmd_tab[i].service = ha->pccb->Service;
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->pccb->CommandIndex = (u32)i+2;
|
2005-04-17 06:20:36 +08:00
|
|
|
return (i+2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_set_sema0(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_set_sema0() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(1, &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (ha->type == GDT_PCINEW) {
|
|
|
|
outb(1, PTR2USHORT(&ha->plx->sema0_reg));
|
|
|
|
} else if (ha->type == GDT_PCIMPR) {
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_copy_command(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdth_cmd_str *cmd_ptr;
|
|
|
|
register gdt6m_dpram_str __iomem *dp6m_ptr;
|
|
|
|
register gdt6c_dpram_str __iomem *dp6c_ptr;
|
|
|
|
gdt6_dpram_str __iomem *dp6_ptr;
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 cp_count,dp_offset,cmd_no;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_copy_command() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
cp_count = ha->cmd_len;
|
|
|
|
dp_offset= ha->cmd_offs_dpmem;
|
|
|
|
cmd_no = ha->cmd_cnt;
|
|
|
|
cmd_ptr = ha->pccb;
|
|
|
|
|
|
|
|
++ha->cmd_cnt;
|
|
|
|
|
|
|
|
/* set cpcount dword aligned */
|
|
|
|
if (cp_count & 3)
|
|
|
|
cp_count += (4 - (cp_count & 3));
|
|
|
|
|
|
|
|
ha->cmd_offs_dpmem += cp_count;
|
|
|
|
|
|
|
|
/* set offset and service, copy command to DPMEM */
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dp6_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6_ptr->u.ic.comm_queue[cmd_no].offset);
|
2010-01-04 23:19:34 +08:00
|
|
|
writew((u16)cmd_ptr->Service,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
|
|
|
memcpy_toio(&dp6_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
|
|
|
} else if (ha->type == GDT_PCINEW) {
|
|
|
|
dp6c_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6c_ptr->u.ic.comm_queue[cmd_no].offset);
|
2010-01-04 23:19:34 +08:00
|
|
|
writew((u16)cmd_ptr->Service,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6c_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
|
|
|
memcpy_toio(&dp6c_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
|
|
|
} else if (ha->type == GDT_PCIMPR) {
|
|
|
|
dp6m_ptr = ha->brd;
|
2007-10-03 04:55:53 +08:00
|
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6m_ptr->u.ic.comm_queue[cmd_no].offset);
|
2010-01-04 23:19:34 +08:00
|
|
|
writew((u16)cmd_ptr->Service,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dp6m_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
|
|
|
memcpy_toio(&dp6m_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_release_event(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_release_event() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 i,j;
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i=0,j=0; j<GDTH_MAXCMDS; ++j) {
|
|
|
|
if (ha->cmd_tab[j].cmnd != UNUSED_CMND)
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (max_index < i) {
|
|
|
|
max_index = i;
|
2010-01-04 23:19:34 +08:00
|
|
|
TRACE3(("GDT: max_index = %d\n",(u16)i));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ha->pccb->OpCode == GDT_INIT)
|
|
|
|
ha->pccb->Service |= 0x80;
|
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0, &((gdt6_dpram_str __iomem *)ha->brd)->io.event);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (ha->type == GDT_PCINEW) {
|
|
|
|
outb(1, PTR2USHORT(&ha->plx->ldoor_reg));
|
|
|
|
} else if (ha->type == GDT_PCIMPR) {
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_wait(gdth_ha_str *ha, int index, u32 time)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int answer_found = FALSE;
|
2007-10-03 05:08:10 +08:00
|
|
|
int wait_index = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_wait() hanum %d index %d time %d\n", ha->hanum, index, time));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (index == 0)
|
|
|
|
return 1; /* no wait required */
|
|
|
|
|
|
|
|
do {
|
2007-12-14 08:14:12 +08:00
|
|
|
__gdth_interrupt(ha, true, &wait_index);
|
2007-10-03 05:08:10 +08:00
|
|
|
if (wait_index == index) {
|
2005-04-17 06:20:36 +08:00
|
|
|
answer_found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gdth_delay(1);
|
|
|
|
} while (--time);
|
2007-10-03 05:05:53 +08:00
|
|
|
|
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
|
|
|
|
|
|
|
return (answer_found);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_internal_cmd(gdth_ha_str *ha, u8 service, u16 opcode,
|
|
|
|
u32 p1, u64 p2, u64 p3)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdth_cmd_str *cmd_ptr;
|
|
|
|
int retries,index;
|
|
|
|
|
|
|
|
TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service,opcode));
|
|
|
|
|
|
|
|
cmd_ptr = ha->pccb;
|
|
|
|
memset((char*)cmd_ptr,0,sizeof(gdth_cmd_str));
|
|
|
|
|
|
|
|
/* make command */
|
|
|
|
for (retries = INIT_RETRIES;;) {
|
|
|
|
cmd_ptr->Service = service;
|
|
|
|
cmd_ptr->RequestBuffer = INTERNAL_CMND;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(index=gdth_get_cmd_index(ha))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("GDT: No free command index found\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmd_ptr->OpCode = opcode;
|
|
|
|
cmd_ptr->BoardNode = LOCALBOARD;
|
|
|
|
if (service == CACHESERVICE) {
|
|
|
|
if (opcode == GDT_IOCTL) {
|
|
|
|
cmd_ptr->u.ioctl.subfunc = p1;
|
2010-01-04 23:19:34 +08:00
|
|
|
cmd_ptr->u.ioctl.channel = (u32)p2;
|
|
|
|
cmd_ptr->u.ioctl.param_size = (u16)p3;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmd_ptr->u.ioctl.p_param = ha->scratch_phys;
|
|
|
|
} else {
|
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
2010-01-04 23:19:34 +08:00
|
|
|
cmd_ptr->u.cache64.DeviceNo = (u16)p1;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmd_ptr->u.cache64.BlockNo = p2;
|
|
|
|
} else {
|
2010-01-04 23:19:34 +08:00
|
|
|
cmd_ptr->u.cache.DeviceNo = (u16)p1;
|
|
|
|
cmd_ptr->u.cache.BlockNo = (u32)p2;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (service == SCSIRAWSERVICE) {
|
|
|
|
if (ha->raw_feat & GDT_64BIT) {
|
|
|
|
cmd_ptr->u.raw64.direction = p1;
|
2010-01-04 23:19:34 +08:00
|
|
|
cmd_ptr->u.raw64.bus = (u8)p2;
|
|
|
|
cmd_ptr->u.raw64.target = (u8)p3;
|
|
|
|
cmd_ptr->u.raw64.lun = (u8)(p3 >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
cmd_ptr->u.raw.direction = p1;
|
2010-01-04 23:19:34 +08:00
|
|
|
cmd_ptr->u.raw.bus = (u8)p2;
|
|
|
|
cmd_ptr->u.raw.target = (u8)p3;
|
|
|
|
cmd_ptr->u.raw.lun = (u8)(p3 >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else if (service == SCREENSERVICE) {
|
|
|
|
if (opcode == GDT_REALTIME) {
|
2010-01-04 23:19:34 +08:00
|
|
|
*(u32 *)&cmd_ptr->u.screen.su.data[0] = p1;
|
|
|
|
*(u32 *)&cmd_ptr->u.screen.su.data[4] = (u32)p2;
|
|
|
|
*(u32 *)&cmd_ptr->u.screen.su.data[8] = (u32)p3;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ha->cmd_len = sizeof(gdth_cmd_str);
|
|
|
|
ha->cmd_offs_dpmem = 0;
|
|
|
|
ha->cmd_cnt = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
|
|
|
gdth_release_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(20);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_wait(ha, index, INIT_TIMEOUT)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT: Initialization error (timeout service %d)\n",service);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (ha->status != S_BSY || --retries == 0)
|
|
|
|
break;
|
|
|
|
gdth_delay(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ha->status != S_OK ? 0:1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* search for devices */
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static int gdth_search_drives(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 cdev_cnt, i;
|
2005-04-17 06:20:36 +08:00
|
|
|
int ok;
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 bus_no, drv_cnt, drv_no, j;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_getch_str *chn;
|
|
|
|
gdth_drlist_str *drl;
|
|
|
|
gdth_iochan_str *ioc;
|
|
|
|
gdth_raw_iochan_str *iocr;
|
|
|
|
gdth_arcdl_str *alst;
|
|
|
|
gdth_alist_str *alst2;
|
|
|
|
gdth_oem_str_ioctl *oemstr;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_search_drives() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
ok = 0;
|
|
|
|
|
|
|
|
/* initialize controller services, at first: screen service */
|
|
|
|
ha->screen_feat = 0;
|
|
|
|
if (!force_dma32) {
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_X_INIT_SCR, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ok)
|
|
|
|
ha->screen_feat = GDT_64BIT;
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC))
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_INIT, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ok) {
|
|
|
|
printk("GDT-HA %d: Initialization error screen service (code %d)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
|
|
|
|
|
|
|
|
/* unfreeze all IOs */
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_internal_cmd(ha, CACHESERVICE, GDT_UNFREEZE_IO, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* initialize cache service */
|
|
|
|
ha->cache_feat = 0;
|
|
|
|
if (!force_dma32) {
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INIT_HOST, LINUX_OS,
|
|
|
|
0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ok)
|
|
|
|
ha->cache_feat = GDT_64BIT;
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC))
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_INIT, LINUX_OS, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ok) {
|
|
|
|
printk("GDT-HA %d: Initialization error cache service (code %d)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
|
2010-01-04 23:19:34 +08:00
|
|
|
cdev_cnt = (u16)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->fw_vers = ha->service;
|
|
|
|
|
|
|
|
/* detect number of buses - try new IOCTL */
|
|
|
|
iocr = (gdth_raw_iochan_str *)ha->pscratch;
|
|
|
|
iocr->hdr.version = 0xffffffff;
|
|
|
|
iocr->hdr.list_entries = MAXBUS;
|
|
|
|
iocr->hdr.first_chan = 0;
|
|
|
|
iocr->hdr.last_chan = MAXBUS-1;
|
|
|
|
iocr->hdr.list_offset = GDTOFFSOF(gdth_raw_iochan_str, list[0]);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_RAW_DESC,
|
2005-04-17 06:20:36 +08:00
|
|
|
INVALID_CHANNEL,sizeof(gdth_raw_iochan_str))) {
|
|
|
|
TRACE2(("IOCHAN_RAW_DESC supported!\n"));
|
|
|
|
ha->bus_cnt = iocr->hdr.chan_count;
|
|
|
|
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
|
|
|
|
if (iocr->list[bus_no].proc_id < MAXID)
|
|
|
|
ha->bus_id[bus_no] = iocr->list[bus_no].proc_id;
|
|
|
|
else
|
|
|
|
ha->bus_id[bus_no] = 0xff;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* old method */
|
|
|
|
chn = (gdth_getch_str *)ha->pscratch;
|
|
|
|
for (bus_no = 0; bus_no < MAXBUS; ++bus_no) {
|
|
|
|
chn->channel_no = bus_no;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
SCSI_CHAN_CNT | L_CTRL_PATTERN,
|
|
|
|
IO_CHANNEL | INVALID_CHANNEL,
|
|
|
|
sizeof(gdth_getch_str))) {
|
|
|
|
if (bus_no == 0) {
|
|
|
|
printk("GDT-HA %d: Error detecting channel count (0x%x)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (chn->siop_id < MAXID)
|
|
|
|
ha->bus_id[bus_no] = chn->siop_id;
|
|
|
|
else
|
|
|
|
ha->bus_id[bus_no] = 0xff;
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->bus_cnt = (u8)bus_no;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
TRACE2(("gdth_search_drives() %d channels\n",ha->bus_cnt));
|
|
|
|
|
|
|
|
/* read cache configuration */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_INFO,
|
2005-04-17 06:20:36 +08:00
|
|
|
INVALID_CHANNEL,sizeof(gdth_cinfo_str))) {
|
|
|
|
printk("GDT-HA %d: Initialization error cache service (code %d)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ha->cpar = ((gdth_cinfo_str *)ha->pscratch)->cpar;
|
|
|
|
TRACE2(("gdth_search_drives() cinfo: vs %x sta %d str %d dw %d b %d\n",
|
|
|
|
ha->cpar.version,ha->cpar.state,ha->cpar.strategy,
|
|
|
|
ha->cpar.write_back,ha->cpar.block_size));
|
|
|
|
|
|
|
|
/* read board info and features */
|
|
|
|
ha->more_proc = FALSE;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_INFO,
|
2005-04-17 06:20:36 +08:00
|
|
|
INVALID_CHANNEL,sizeof(gdth_binfo_str))) {
|
|
|
|
memcpy(&ha->binfo, (gdth_binfo_str *)ha->pscratch,
|
|
|
|
sizeof(gdth_binfo_str));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_FEATURES,
|
2005-04-17 06:20:36 +08:00
|
|
|
INVALID_CHANNEL,sizeof(gdth_bfeat_str))) {
|
|
|
|
TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n"));
|
|
|
|
ha->bfeat = *(gdth_bfeat_str *)ha->pscratch;
|
|
|
|
ha->more_proc = TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n"));
|
2007-10-03 05:05:53 +08:00
|
|
|
strcpy(ha->binfo.type_string, gdth_ctr_name(ha));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
TRACE2(("Controller name: %s\n",ha->binfo.type_string));
|
|
|
|
|
|
|
|
/* read more informations */
|
|
|
|
if (ha->more_proc) {
|
|
|
|
/* physical drives, channel addresses */
|
|
|
|
ioc = (gdth_iochan_str *)ha->pscratch;
|
|
|
|
ioc->hdr.version = 0xffffffff;
|
|
|
|
ioc->hdr.list_entries = MAXBUS;
|
|
|
|
ioc->hdr.first_chan = 0;
|
|
|
|
ioc->hdr.last_chan = MAXBUS-1;
|
|
|
|
ioc->hdr.list_offset = GDTOFFSOF(gdth_iochan_str, list[0]);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_DESC,
|
2005-04-17 06:20:36 +08:00
|
|
|
INVALID_CHANNEL,sizeof(gdth_iochan_str))) {
|
|
|
|
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
|
|
|
|
ha->raw[bus_no].address = ioc->list[bus_no].address;
|
|
|
|
ha->raw[bus_no].local_no = ioc->list[bus_no].local_no;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
|
|
|
|
ha->raw[bus_no].address = IO_CHANNEL;
|
|
|
|
ha->raw[bus_no].local_no = bus_no;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
|
|
|
|
chn = (gdth_getch_str *)ha->pscratch;
|
|
|
|
chn->channel_no = ha->raw[bus_no].local_no;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
SCSI_CHAN_CNT | L_CTRL_PATTERN,
|
|
|
|
ha->raw[bus_no].address | INVALID_CHANNEL,
|
|
|
|
sizeof(gdth_getch_str))) {
|
|
|
|
ha->raw[bus_no].pdev_cnt = chn->drive_cnt;
|
|
|
|
TRACE2(("Channel %d: %d phys. drives\n",
|
|
|
|
bus_no,chn->drive_cnt));
|
|
|
|
}
|
|
|
|
if (ha->raw[bus_no].pdev_cnt > 0) {
|
|
|
|
drl = (gdth_drlist_str *)ha->pscratch;
|
|
|
|
drl->sc_no = ha->raw[bus_no].local_no;
|
|
|
|
drl->sc_cnt = ha->raw[bus_no].pdev_cnt;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
SCSI_DR_LIST | L_CTRL_PATTERN,
|
|
|
|
ha->raw[bus_no].address | INVALID_CHANNEL,
|
|
|
|
sizeof(gdth_drlist_str))) {
|
|
|
|
for (j = 0; j < ha->raw[bus_no].pdev_cnt; ++j)
|
|
|
|
ha->raw[bus_no].id_list[j] = drl->sc_list[j];
|
|
|
|
} else {
|
|
|
|
ha->raw[bus_no].pdev_cnt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* logical drives */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_CNT,
|
2010-01-04 23:19:34 +08:00
|
|
|
INVALID_CHANNEL,sizeof(u32))) {
|
|
|
|
drv_cnt = *(u32 *)ha->pscratch;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_LIST,
|
2010-01-04 23:19:34 +08:00
|
|
|
INVALID_CHANNEL,drv_cnt * sizeof(u32))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
for (j = 0; j < drv_cnt; ++j) {
|
2010-01-04 23:19:34 +08:00
|
|
|
drv_no = ((u32 *)ha->pscratch)[j];
|
2005-04-17 06:20:36 +08:00
|
|
|
if (drv_no < MAX_LDRIVES) {
|
|
|
|
ha->hdr[drv_no].is_logdrv = TRUE;
|
|
|
|
TRACE2(("Drive %d is log. drive\n",drv_no));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
alst = (gdth_arcdl_str *)ha->pscratch;
|
|
|
|
alst->entries_avail = MAX_LDRIVES;
|
|
|
|
alst->first_entry = 0;
|
|
|
|
alst->list_offset = GDTOFFSOF(gdth_arcdl_str, list[0]);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
ARRAY_DRV_LIST2 | LA_CTRL_PATTERN,
|
|
|
|
INVALID_CHANNEL, sizeof(gdth_arcdl_str) +
|
|
|
|
(alst->entries_avail-1) * sizeof(gdth_alist_str))) {
|
|
|
|
for (j = 0; j < alst->entries_init; ++j) {
|
|
|
|
ha->hdr[j].is_arraydrv = alst->list[j].is_arrayd;
|
|
|
|
ha->hdr[j].is_master = alst->list[j].is_master;
|
|
|
|
ha->hdr[j].is_parity = alst->list[j].is_parity;
|
|
|
|
ha->hdr[j].is_hotfix = alst->list[j].is_hotfix;
|
|
|
|
ha->hdr[j].master_no = alst->list[j].cd_handle;
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
} else if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
ARRAY_DRV_LIST | LA_CTRL_PATTERN,
|
|
|
|
0, 35 * sizeof(gdth_alist_str))) {
|
|
|
|
for (j = 0; j < 35; ++j) {
|
|
|
|
alst2 = &((gdth_alist_str *)ha->pscratch)[j];
|
|
|
|
ha->hdr[j].is_arraydrv = alst2->is_arrayd;
|
|
|
|
ha->hdr[j].is_master = alst2->is_master;
|
|
|
|
ha->hdr[j].is_parity = alst2->is_parity;
|
|
|
|
ha->hdr[j].is_hotfix = alst2->is_hotfix;
|
|
|
|
ha->hdr[j].master_no = alst2->cd_handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize raw service */
|
|
|
|
ha->raw_feat = 0;
|
|
|
|
if (!force_dma32) {
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_X_INIT_RAW, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ok)
|
|
|
|
ha->raw_feat = GDT_64BIT;
|
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC))
|
2007-10-03 05:05:53 +08:00
|
|
|
ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_INIT, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ok) {
|
|
|
|
printk("GDT-HA %d: Initialization error raw service (code %d)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
|
|
|
|
|
|
|
|
/* set/get features raw service (scatter/gather) */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_SET_FEAT, SCATTER_GATHER,
|
|
|
|
0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_GET_FEAT, 0, 0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n",
|
|
|
|
ha->info));
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->raw_feat |= (u16)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set/get features cache service (equal to raw service) */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_SET_FEAT, 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
SCATTER_GATHER,0)) {
|
|
|
|
TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_GET_FEAT, 0, 0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n",
|
|
|
|
ha->info));
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->cache_feat |= (u16)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reserve drives for raw service */
|
|
|
|
if (reserve_mode != 0) {
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE_ALL,
|
2005-04-17 06:20:36 +08:00
|
|
|
reserve_mode == 1 ? 1 : 3, 0, 0);
|
|
|
|
TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n",
|
|
|
|
ha->status));
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAX_RES_ARGS; i += 4) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (reserve_list[i] == ha->hanum && reserve_list[i+1] < ha->bus_cnt &&
|
2005-04-17 06:20:36 +08:00
|
|
|
reserve_list[i+2] < ha->tid_cnt && reserve_list[i+3] < MAXLUN) {
|
|
|
|
TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n",
|
|
|
|
reserve_list[i], reserve_list[i+1],
|
|
|
|
reserve_list[i+2], reserve_list[i+3]));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE, 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
reserve_list[i+1], reserve_list[i+2] |
|
|
|
|
(reserve_list[i+3] << 8))) {
|
|
|
|
printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine OEM string using IOCTL */
|
|
|
|
oemstr = (gdth_oem_str_ioctl *)ha->pscratch;
|
|
|
|
oemstr->params.ctl_version = 0x01;
|
|
|
|
oemstr->params.buffer_size = sizeof(oemstr->text);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
|
2005-04-17 06:20:36 +08:00
|
|
|
CACHE_READ_OEM_STRING_RECORD,INVALID_CHANNEL,
|
|
|
|
sizeof(gdth_oem_str_ioctl))) {
|
|
|
|
TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n"));
|
|
|
|
printk("GDT-HA %d: Vendor: %s Name: %s\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Save the Host Drive inquiry data */
|
|
|
|
strlcpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id,
|
|
|
|
sizeof(ha->oem_name));
|
|
|
|
} else {
|
|
|
|
/* Old method, based on PCI ID */
|
|
|
|
TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n"));
|
|
|
|
printk("GDT-HA %d: Name: %s\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->binfo.type_string);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->oem_id == OEM_ID_INTEL)
|
|
|
|
strlcpy(ha->oem_name,"Intel ", sizeof(ha->oem_name));
|
|
|
|
else
|
|
|
|
strlcpy(ha->oem_name,"ICP ", sizeof(ha->oem_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* scanning for host drives */
|
|
|
|
for (i = 0; i < cdev_cnt; ++i)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_analyse_hdrive(ha, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE(("gdth_search_drives() OK\n"));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_analyse_hdrive(gdth_ha_str *ha, u16 hdrive)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 drv_cyls;
|
2005-04-17 06:20:36 +08:00
|
|
|
int drv_hds, drv_secs;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n", ha->hanum, hdrive));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (hdrive >= MAX_HDRIVES)
|
|
|
|
return 0;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_INFO, hdrive, 0, 0))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
ha->hdr[hdrive].present = TRUE;
|
|
|
|
ha->hdr[hdrive].size = ha->info;
|
|
|
|
|
|
|
|
/* evaluate mapping (sectors per head, heads per cylinder) */
|
|
|
|
ha->hdr[hdrive].size &= ~SECS32;
|
|
|
|
if (ha->info2 == 0) {
|
|
|
|
gdth_eval_mapping(ha->hdr[hdrive].size,&drv_cyls,&drv_hds,&drv_secs);
|
|
|
|
} else {
|
|
|
|
drv_hds = ha->info2 & 0xff;
|
|
|
|
drv_secs = (ha->info2 >> 8) & 0xff;
|
2010-01-04 23:19:34 +08:00
|
|
|
drv_cyls = (u32)ha->hdr[hdrive].size / drv_hds / drv_secs;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[hdrive].heads = (u8)drv_hds;
|
|
|
|
ha->hdr[hdrive].secs = (u8)drv_secs;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* round size */
|
|
|
|
ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs;
|
|
|
|
|
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INFO, hdrive, 0, 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
&& ha->info2 != 0) {
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[hdrive].size = ((u64)ha->info2 << 32) | ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE2(("gdth_search_dr() cdr. %d size %d hds %d scs %d\n",
|
|
|
|
hdrive,ha->hdr[hdrive].size,drv_hds,drv_secs));
|
|
|
|
|
|
|
|
/* get informations about device */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_DEVTYPE, hdrive, 0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_dr() cache drive %d devtype %d\n",
|
|
|
|
hdrive,ha->info));
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[hdrive].devtype = (u16)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cluster info */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_CLUST_INFO, hdrive, 0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n",
|
|
|
|
hdrive,ha->info));
|
|
|
|
if (!shared_access)
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[hdrive].cluster_type = (u8)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* R/W attributes */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE, GDT_RW_ATTRIBS, hdrive, 0, 0)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n",
|
|
|
|
hdrive,ha->info));
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[hdrive].rw_attribs = (u8)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* command queueing/sending functions */
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static void gdth_putq(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 priority)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2018-06-13 15:53:47 +08:00
|
|
|
register struct scsi_cmnd *pscp;
|
|
|
|
register struct scsi_cmnd *nscp;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE(("gdth_putq() priority %d\n",priority));
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
2008-09-14 20:55:09 +08:00
|
|
|
if (!cmndinfo->internal_command)
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->priority = priority;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (ha->req_first==NULL) {
|
|
|
|
ha->req_first = scp; /* queue was empty */
|
|
|
|
scp->SCp.ptr = NULL;
|
|
|
|
} else { /* queue not empty */
|
|
|
|
pscp = ha->req_first;
|
2018-06-13 15:53:47 +08:00
|
|
|
nscp = (struct scsi_cmnd *)pscp->SCp.ptr;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* priority: 0-highest,..,0xff-lowest */
|
2007-10-03 05:16:01 +08:00
|
|
|
while (nscp && gdth_cmnd_priv(nscp)->priority <= priority) {
|
2005-04-17 06:20:36 +08:00
|
|
|
pscp = nscp;
|
2018-06-13 15:53:47 +08:00
|
|
|
nscp = (struct scsi_cmnd *)pscp->SCp.ptr;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
pscp->SCp.ptr = (char *)scp;
|
|
|
|
scp->SCp.ptr = (char *)nscp;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
|
|
|
flags = 0;
|
2018-06-13 15:53:47 +08:00
|
|
|
for (nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
++flags;
|
|
|
|
if (max_rq < flags) {
|
|
|
|
max_rq = flags;
|
2010-01-04 23:19:34 +08:00
|
|
|
TRACE3(("GDT: max_rq = %d\n",(u16)max_rq));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_next(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2018-06-13 15:53:47 +08:00
|
|
|
register struct scsi_cmnd *pscp;
|
|
|
|
register struct scsi_cmnd *nscp;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b, t, l, firsttime;
|
|
|
|
u8 this_cmd, next_cmd;
|
|
|
|
unsigned long flags = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
int cmd_index;
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE(("gdth_next() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!gdth_polling)
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
ha->cmd_cnt = ha->cmd_offs_dpmem = 0;
|
|
|
|
this_cmd = firsttime = TRUE;
|
|
|
|
next_cmd = gdth_polling ? FALSE:TRUE;
|
|
|
|
cmd_index = 0;
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
for (nscp = pscp = ha->req_first; nscp; nscp = (struct scsi_cmnd *)nscp->SCp.ptr) {
|
2007-10-03 05:16:01 +08:00
|
|
|
struct gdth_cmndinfo *nscp_cmndinfo = gdth_cmnd_priv(nscp);
|
2018-06-13 15:53:47 +08:00
|
|
|
if (nscp != pscp && nscp != (struct scsi_cmnd *)pscp->SCp.ptr)
|
|
|
|
pscp = (struct scsi_cmnd *)pscp->SCp.ptr;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->internal_command) {
|
2007-10-03 04:59:53 +08:00
|
|
|
b = nscp->device->channel;
|
2006-06-10 02:34:29 +08:00
|
|
|
t = nscp->device->id;
|
|
|
|
l = nscp->device->lun;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (nscp_cmndinfo->priority >= DEFAULT_PRI) {
|
2006-06-10 02:34:29 +08:00
|
|
|
if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
|
|
|
|
(b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
b = t = l = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (firsttime) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_test_busy(ha)) { /* controller busy ? */
|
|
|
|
TRACE(("gdth_next() controller %d busy !\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!gdth_polling) {
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return;
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(1);
|
|
|
|
}
|
|
|
|
firsttime = FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->internal_command) {
|
|
|
|
if (nscp_cmndinfo->phase == -1) {
|
|
|
|
nscp_cmndinfo->phase = CACHESERVICE; /* default: cache svc. */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (nscp->cmnd[0] == TEST_UNIT_READY) {
|
|
|
|
TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n",
|
|
|
|
b, t, l));
|
|
|
|
/* TEST_UNIT_READY -> set scan mode */
|
|
|
|
if ((ha->scan_mode & 0x0f) == 0) {
|
|
|
|
if (b == 0 && t == 0 && l == 0) {
|
|
|
|
ha->scan_mode |= 1;
|
|
|
|
TRACE2(("Scan mode: 0x%x\n", ha->scan_mode));
|
|
|
|
}
|
|
|
|
} else if ((ha->scan_mode & 0x0f) == 1) {
|
|
|
|
if (b == 0 && ((t == 0 && l == 1) ||
|
|
|
|
(t == 1 && l == 0))) {
|
2007-10-03 05:16:01 +08:00
|
|
|
nscp_cmndinfo->OpCode = GDT_SCAN_START;
|
|
|
|
nscp_cmndinfo->phase = ((ha->scan_mode & 0x10 ? 1:0) << 8)
|
2005-04-17 06:20:36 +08:00
|
|
|
| SCSIRAWSERVICE;
|
|
|
|
ha->scan_mode = 0x12;
|
|
|
|
TRACE2(("Scan mode: 0x%x (SCAN_START)\n",
|
|
|
|
ha->scan_mode));
|
|
|
|
} else {
|
|
|
|
ha->scan_mode &= 0x10;
|
|
|
|
TRACE2(("Scan mode: 0x%x\n", ha->scan_mode));
|
|
|
|
}
|
|
|
|
} else if (ha->scan_mode == 0x12) {
|
|
|
|
if (b == ha->bus_cnt && t == ha->tid_cnt-1) {
|
2007-10-03 05:16:01 +08:00
|
|
|
nscp_cmndinfo->phase = SCSIRAWSERVICE;
|
|
|
|
nscp_cmndinfo->OpCode = GDT_SCAN_END;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->scan_mode &= 0x10;
|
|
|
|
TRACE2(("Scan mode: 0x%x (SCAN_END)\n",
|
|
|
|
ha->scan_mode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (b == ha->virt_bus && nscp->cmnd[0] != INQUIRY &&
|
|
|
|
nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE &&
|
|
|
|
(ha->hdr[t].cluster_type & CLUSTER_DRIVE)) {
|
|
|
|
/* always GDT_CLUST_INFO! */
|
2007-10-03 05:16:01 +08:00
|
|
|
nscp_cmndinfo->OpCode = GDT_CLUST_INFO;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
if (nscp_cmndinfo->OpCode != -1) {
|
|
|
|
if ((nscp_cmndinfo->phase & 0xff) == CACHESERVICE) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
next_cmd = FALSE;
|
2007-10-03 05:16:01 +08:00
|
|
|
} else if ((nscp_cmndinfo->phase & 0xff) == SCSIRAWSERVICE) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b))))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
next_cmd = FALSE;
|
|
|
|
} else {
|
|
|
|
memset((char*)nscp->sense_buffer,0,16);
|
|
|
|
nscp->sense_buffer[0] = 0x70;
|
|
|
|
nscp->sense_buffer[2] = NOT_READY;
|
|
|
|
nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-03 05:14:39 +08:00
|
|
|
} else if (gdth_cmnd_priv(nscp)->internal_command) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_special_cmd(ha, nscp)))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
next_cmd = FALSE;
|
|
|
|
} else if (b != ha->virt_bus) {
|
|
|
|
if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW ||
|
2007-10-03 05:05:53 +08:00
|
|
|
!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b))))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
else
|
|
|
|
ha->raw[BUS_L2P(ha,b)].io_cnt[t]++;
|
|
|
|
} else if (t >= MAX_HDRIVES || !ha->hdr[t].present || l != 0) {
|
|
|
|
TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n",
|
|
|
|
nscp->cmnd[0], b, t, l));
|
|
|
|
nscp->result = DID_BAD_TARGET << 16;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
switch (nscp->cmnd[0]) {
|
|
|
|
case TEST_UNIT_READY:
|
|
|
|
case INQUIRY:
|
|
|
|
case REQUEST_SENSE:
|
|
|
|
case READ_CAPACITY:
|
|
|
|
case VERIFY:
|
|
|
|
case START_STOP:
|
|
|
|
case MODE_SENSE:
|
2014-11-17 21:25:19 +08:00
|
|
|
case SERVICE_ACTION_IN_16:
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0],
|
|
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
|
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
|
|
|
if (ha->hdr[t].media_changed && nscp->cmnd[0] != INQUIRY) {
|
|
|
|
/* return UNIT_ATTENTION */
|
|
|
|
TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
|
|
|
|
nscp->cmnd[0], t));
|
|
|
|
ha->hdr[t].media_changed = FALSE;
|
|
|
|
memset((char*)nscp->sense_buffer,0,16);
|
|
|
|
nscp->sense_buffer[0] = 0x70;
|
|
|
|
nscp->sense_buffer[2] = UNIT_ATTENTION;
|
|
|
|
nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2007-10-03 05:05:53 +08:00
|
|
|
} else if (gdth_internal_cache_cmd(ha, nscp))
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALLOW_MEDIUM_REMOVAL:
|
|
|
|
TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0],
|
|
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
|
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
|
|
|
if ( (nscp->cmnd[4]&1) && !(ha->hdr[t].devtype&1) ) {
|
|
|
|
TRACE(("Prevent r. nonremov. drive->do nothing\n"));
|
|
|
|
nscp->result = DID_OK << 16;
|
|
|
|
nscp->sense_buffer[0] = 0;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0;
|
|
|
|
TRACE(("Prevent/allow r. %d rem. drive %d\n",
|
|
|
|
nscp->cmnd[4],nscp->cmnd[3]));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESERVE:
|
|
|
|
case RELEASE:
|
|
|
|
TRACE2(("cache cmd %s\n",nscp->cmnd[0] == RESERVE ?
|
|
|
|
"RESERVE" : "RELEASE"));
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case READ_6:
|
|
|
|
case WRITE_6:
|
|
|
|
case READ_10:
|
|
|
|
case WRITE_10:
|
|
|
|
case READ_16:
|
|
|
|
case WRITE_16:
|
|
|
|
if (ha->hdr[t].media_changed) {
|
|
|
|
/* return UNIT_ATTENTION */
|
|
|
|
TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
|
|
|
|
nscp->cmnd[0], t));
|
|
|
|
ha->hdr[t].media_changed = FALSE;
|
|
|
|
memset((char*)nscp->sense_buffer,0,16);
|
|
|
|
nscp->sense_buffer[0] = 0x70;
|
|
|
|
nscp->sense_buffer[2] = UNIT_ATTENTION;
|
|
|
|
nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2007-10-03 05:05:53 +08:00
|
|
|
} else if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
|
2005-04-17 06:20:36 +08:00
|
|
|
this_cmd = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp->cmnd[0],
|
|
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
|
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
|
|
|
printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, nscp->cmnd[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
nscp->result = DID_ABORT << 16;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!nscp_cmndinfo->wait_for_completion)
|
|
|
|
nscp_cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(nscp);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this_cmd)
|
|
|
|
break;
|
|
|
|
if (nscp == ha->req_first)
|
2018-06-13 15:53:47 +08:00
|
|
|
ha->req_first = pscp = (struct scsi_cmnd *)nscp->SCp.ptr;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
pscp->SCp.ptr = nscp->SCp.ptr;
|
|
|
|
if (!next_cmd)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ha->cmd_cnt > 0) {
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_release_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gdth_polling)
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
if (gdth_polling && ha->cmd_cnt > 0) {
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_wait(ha, cmd_index, POLL_TIMEOUT))
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-HA %d: Command %d timed out !\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, cmd_index);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2007-10-03 05:18:03 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* gdth_copy_internal_data() - copy to/from a buffer onto a scsi_cmnd's
|
|
|
|
* buffers, kmap_atomic() as needed.
|
|
|
|
*/
|
2018-06-13 15:53:47 +08:00
|
|
|
static void gdth_copy_internal_data(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
2010-01-04 23:19:34 +08:00
|
|
|
char *buffer, u16 count)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 cpcount,i, max_sg = scsi_sg_count(scp);
|
|
|
|
u16 cpsum,cpnow;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct scatterlist *sl;
|
|
|
|
char *address;
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
cpcount = min_t(u16, count, scsi_bufflen(scp));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:18:03 +08:00
|
|
|
if (cpcount) {
|
|
|
|
cpsum=0;
|
|
|
|
scsi_for_each_sg(scp, sl, max_sg, i) {
|
2006-06-10 02:34:29 +08:00
|
|
|
unsigned long flags;
|
2010-01-04 23:19:34 +08:00
|
|
|
cpnow = (u16)sl->length;
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("copy_internal() now %d sum %d count %d %d\n",
|
2008-02-28 07:31:20 +08:00
|
|
|
cpnow, cpsum, cpcount, scsi_bufflen(scp)));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (cpsum+cpnow > cpcount)
|
|
|
|
cpnow = cpcount - cpsum;
|
|
|
|
cpsum += cpnow;
|
2007-10-23 03:19:53 +08:00
|
|
|
if (!sg_page(sl)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-06-10 02:34:29 +08:00
|
|
|
local_irq_save(flags);
|
2011-11-25 23:14:23 +08:00
|
|
|
address = kmap_atomic(sg_page(sl)) + sl->offset;
|
2008-02-28 07:29:15 +08:00
|
|
|
memcpy(address, buffer, cpnow);
|
2007-10-23 03:19:53 +08:00
|
|
|
flush_dcache_page(sg_page(sl));
|
2011-11-25 23:14:23 +08:00
|
|
|
kunmap_atomic(address);
|
2006-06-10 02:34:29 +08:00
|
|
|
local_irq_restore(flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (cpsum == cpcount)
|
|
|
|
break;
|
|
|
|
buffer += cpnow;
|
|
|
|
}
|
2007-10-03 05:18:03 +08:00
|
|
|
} else if (count) {
|
|
|
|
printk("GDT-HA %d: SCSI command with no buffers but data transfer expected!\n",
|
|
|
|
ha->hanum);
|
|
|
|
WARN_ON(1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 t;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_inq_data inq;
|
|
|
|
gdth_rdcap_data rdc;
|
|
|
|
gdth_sense_data sd;
|
|
|
|
gdth_modep_data mpd;
|
2007-10-03 05:16:01 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
t = scp->device->id;
|
|
|
|
TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
|
|
|
|
scp->cmnd[0],t));
|
|
|
|
|
|
|
|
scp->result = DID_OK << 16;
|
|
|
|
scp->sense_buffer[0] = 0;
|
|
|
|
|
|
|
|
switch (scp->cmnd[0]) {
|
|
|
|
case TEST_UNIT_READY:
|
|
|
|
case VERIFY:
|
|
|
|
case START_STOP:
|
|
|
|
TRACE2(("Test/Verify/Start hdrive %d\n",t));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INQUIRY:
|
|
|
|
TRACE2(("Inquiry hdrive %d devtype %d\n",
|
|
|
|
t,ha->hdr[t].devtype));
|
|
|
|
inq.type_qual = (ha->hdr[t].devtype&4) ? TYPE_ROM:TYPE_DISK;
|
|
|
|
/* you can here set all disks to removable, if you want to do
|
|
|
|
a flush using the ALLOW_MEDIUM_REMOVAL command */
|
|
|
|
inq.modif_rmb = 0x00;
|
|
|
|
if ((ha->hdr[t].devtype & 1) ||
|
|
|
|
(ha->hdr[t].cluster_type & CLUSTER_DRIVE))
|
|
|
|
inq.modif_rmb = 0x80;
|
|
|
|
inq.version = 2;
|
|
|
|
inq.resp_aenc = 2;
|
|
|
|
inq.add_length= 32;
|
|
|
|
strcpy(inq.vendor,ha->oem_name);
|
2017-07-14 20:06:57 +08:00
|
|
|
snprintf(inq.product, sizeof(inq.product), "Host Drive #%02d",t);
|
2005-04-17 06:20:36 +08:00
|
|
|
strcpy(inq.revision," ");
|
2008-02-28 07:29:15 +08:00
|
|
|
gdth_copy_internal_data(ha, scp, (char*)&inq, sizeof(gdth_inq_data));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case REQUEST_SENSE:
|
|
|
|
TRACE2(("Request sense hdrive %d\n",t));
|
|
|
|
sd.errorcode = 0x70;
|
|
|
|
sd.segno = 0x00;
|
|
|
|
sd.key = NO_SENSE;
|
|
|
|
sd.info = 0;
|
|
|
|
sd.add_length= 0;
|
2008-02-28 07:29:15 +08:00
|
|
|
gdth_copy_internal_data(ha, scp, (char*)&sd, sizeof(gdth_sense_data));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MODE_SENSE:
|
|
|
|
TRACE2(("Mode sense hdrive %d\n",t));
|
|
|
|
memset((char*)&mpd,0,sizeof(gdth_modep_data));
|
|
|
|
mpd.hd.data_length = sizeof(gdth_modep_data);
|
|
|
|
mpd.hd.dev_par = (ha->hdr[t].devtype&2) ? 0x80:0;
|
|
|
|
mpd.hd.bd_length = sizeof(mpd.bd);
|
|
|
|
mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16;
|
|
|
|
mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8;
|
|
|
|
mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff);
|
2008-02-28 07:29:15 +08:00
|
|
|
gdth_copy_internal_data(ha, scp, (char*)&mpd, sizeof(gdth_modep_data));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case READ_CAPACITY:
|
|
|
|
TRACE2(("Read capacity hdrive %d\n",t));
|
2010-01-04 23:19:34 +08:00
|
|
|
if (ha->hdr[t].size > (u64)0xffffffff)
|
2005-04-17 06:20:36 +08:00
|
|
|
rdc.last_block_no = 0xffffffff;
|
|
|
|
else
|
|
|
|
rdc.last_block_no = cpu_to_be32(ha->hdr[t].size-1);
|
|
|
|
rdc.block_length = cpu_to_be32(SECTOR_SIZE);
|
2008-02-28 07:29:15 +08:00
|
|
|
gdth_copy_internal_data(ha, scp, (char*)&rdc, sizeof(gdth_rdcap_data));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2014-11-17 21:25:19 +08:00
|
|
|
case SERVICE_ACTION_IN_16:
|
2005-04-17 06:20:36 +08:00
|
|
|
if ((scp->cmnd[1] & 0x1f) == SAI_READ_CAPACITY_16 &&
|
|
|
|
(ha->cache_feat & GDT_64BIT)) {
|
|
|
|
gdth_rdcap16_data rdc16;
|
|
|
|
|
|
|
|
TRACE2(("Read capacity (16) hdrive %d\n",t));
|
|
|
|
rdc16.last_block_no = cpu_to_be64(ha->hdr[t].size-1);
|
|
|
|
rdc16.block_length = cpu_to_be32(SECTOR_SIZE);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_internal_data(ha, scp, (char*)&rdc16,
|
2008-02-28 07:29:15 +08:00
|
|
|
sizeof(gdth_rdcap16_data));
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
scp->result = DID_ABORT << 16;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE2(("Internal cache cmd 0x%x unknown\n",scp->cmnd[0]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!cmndinfo->wait_for_completion)
|
|
|
|
cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
|
|
|
u16 hdrive)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdth_cmd_str *cmdp;
|
2007-10-03 05:16:01 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 cnt, blockcnt;
|
|
|
|
u64 no, blockno;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i, cmd_index, read_write, sgcnt, mode64;
|
|
|
|
|
|
|
|
cmdp = ha->pccb;
|
|
|
|
TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
|
|
|
|
scp->cmnd[0],scp->cmd_len,hdrive));
|
|
|
|
|
|
|
|
mode64 = (ha->cache_feat & GDT_64BIT) ? TRUE : FALSE;
|
|
|
|
/* test for READ_16, WRITE_16 if !mode64 ? ---
|
|
|
|
not required, should not occur due to error return on
|
|
|
|
READ_CAPACITY_16 */
|
|
|
|
|
|
|
|
cmdp->Service = CACHESERVICE;
|
|
|
|
cmdp->RequestBuffer = scp;
|
|
|
|
/* search free command index */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_get_cmd_index(ha))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("GDT: No free command index found\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* if it's the first command, set command semaphore */
|
|
|
|
if (ha->cmd_cnt == 0)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* fill command */
|
|
|
|
read_write = 0;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode != -1)
|
|
|
|
cmdp->OpCode = cmndinfo->OpCode; /* special cache cmd. */
|
2005-04-17 06:20:36 +08:00
|
|
|
else if (scp->cmnd[0] == RESERVE)
|
|
|
|
cmdp->OpCode = GDT_RESERVE_DRV;
|
|
|
|
else if (scp->cmnd[0] == RELEASE)
|
|
|
|
cmdp->OpCode = GDT_RELEASE_DRV;
|
|
|
|
else if (scp->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
|
|
|
|
if (scp->cmnd[4] & 1) /* prevent ? */
|
|
|
|
cmdp->OpCode = GDT_MOUNT;
|
|
|
|
else if (scp->cmnd[3] & 1) /* removable drive ? */
|
|
|
|
cmdp->OpCode = GDT_UNMOUNT;
|
|
|
|
else
|
|
|
|
cmdp->OpCode = GDT_FLUSH;
|
|
|
|
} else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10 ||
|
|
|
|
scp->cmnd[0] == WRITE_12 || scp->cmnd[0] == WRITE_16
|
|
|
|
) {
|
|
|
|
read_write = 1;
|
|
|
|
if (gdth_write_through || ((ha->hdr[hdrive].rw_attribs & 1) &&
|
|
|
|
(ha->cache_feat & GDT_WR_THROUGH)))
|
|
|
|
cmdp->OpCode = GDT_WRITE_THR;
|
|
|
|
else
|
|
|
|
cmdp->OpCode = GDT_WRITE;
|
|
|
|
} else {
|
|
|
|
read_write = 2;
|
|
|
|
cmdp->OpCode = GDT_READ;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
if (mode64) {
|
|
|
|
cmdp->u.cache64.DeviceNo = hdrive;
|
|
|
|
cmdp->u.cache64.BlockNo = 1;
|
|
|
|
cmdp->u.cache64.sg_canz = 0;
|
|
|
|
} else {
|
|
|
|
cmdp->u.cache.DeviceNo = hdrive;
|
|
|
|
cmdp->u.cache.BlockNo = 1;
|
|
|
|
cmdp->u.cache.sg_canz = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read_write) {
|
|
|
|
if (scp->cmd_len == 16) {
|
2010-01-04 23:19:34 +08:00
|
|
|
memcpy(&no, &scp->cmnd[2], sizeof(u64));
|
2005-04-17 06:20:36 +08:00
|
|
|
blockno = be64_to_cpu(no);
|
2010-01-04 23:19:34 +08:00
|
|
|
memcpy(&cnt, &scp->cmnd[10], sizeof(u32));
|
2005-04-17 06:20:36 +08:00
|
|
|
blockcnt = be32_to_cpu(cnt);
|
|
|
|
} else if (scp->cmd_len == 10) {
|
2010-01-04 23:19:34 +08:00
|
|
|
memcpy(&no, &scp->cmnd[2], sizeof(u32));
|
2005-04-17 06:20:36 +08:00
|
|
|
blockno = be32_to_cpu(no);
|
2010-01-04 23:19:34 +08:00
|
|
|
memcpy(&cnt, &scp->cmnd[7], sizeof(u16));
|
2005-04-17 06:20:36 +08:00
|
|
|
blockcnt = be16_to_cpu(cnt);
|
|
|
|
} else {
|
2010-01-04 23:19:34 +08:00
|
|
|
memcpy(&no, &scp->cmnd[0], sizeof(u32));
|
2005-04-17 06:20:36 +08:00
|
|
|
blockno = be32_to_cpu(no) & 0x001fffffUL;
|
|
|
|
blockcnt= scp->cmnd[4]==0 ? 0x100 : scp->cmnd[4];
|
|
|
|
}
|
|
|
|
if (mode64) {
|
|
|
|
cmdp->u.cache64.BlockNo = blockno;
|
|
|
|
cmdp->u.cache64.BlockCnt = blockcnt;
|
|
|
|
} else {
|
2010-01-04 23:19:34 +08:00
|
|
|
cmdp->u.cache.BlockNo = (u32)blockno;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.cache.BlockCnt = blockcnt;
|
|
|
|
}
|
|
|
|
|
2008-02-28 07:31:20 +08:00
|
|
|
if (scsi_bufflen(scp)) {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->dma_dir = (read_write == 1 ?
|
2018-12-12 15:41:27 +08:00
|
|
|
DMA_TO_DEVICE : DMA_FROM_DEVICE);
|
|
|
|
sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp),
|
|
|
|
scsi_sg_count(scp), cmndinfo->dma_dir);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (mode64) {
|
2007-10-03 05:18:03 +08:00
|
|
|
struct scatterlist *sl;
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
cmdp->u.cache64.DestAddr= (u64)-1;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.cache64.sg_canz = sgcnt;
|
2007-10-03 05:18:03 +08:00
|
|
|
scsi_for_each_sg(scp, sl, sgcnt, i) {
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.cache64.sg_lst[i].sg_ptr = sg_dma_address(sl);
|
|
|
|
cmdp->u.cache64.sg_lst[i].sg_len = sg_dma_len(sl);
|
|
|
|
}
|
|
|
|
} else {
|
2007-10-03 05:18:03 +08:00
|
|
|
struct scatterlist *sl;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.cache.DestAddr= 0xffffffff;
|
|
|
|
cmdp->u.cache.sg_canz = sgcnt;
|
2007-10-03 05:18:03 +08:00
|
|
|
scsi_for_each_sg(scp, sl, sgcnt, i) {
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.cache.sg_lst[i].sg_ptr = sg_dma_address(sl);
|
|
|
|
cmdp->u.cache.sg_lst[i].sg_len = sg_dma_len(sl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
2010-01-04 23:19:34 +08:00
|
|
|
if (max_sg < (u32)sgcnt) {
|
|
|
|
max_sg = (u32)sgcnt;
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE3(("GDT: max_sg = %d\n",max_sg));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* evaluate command size, check space */
|
|
|
|
if (mode64) {
|
|
|
|
TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
|
|
|
|
cmdp->u.cache64.DestAddr,cmdp->u.cache64.sg_canz,
|
|
|
|
cmdp->u.cache64.sg_lst[0].sg_ptr,
|
|
|
|
cmdp->u.cache64.sg_lst[0].sg_len));
|
|
|
|
TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
|
|
|
|
cmdp->OpCode,cmdp->u.cache64.BlockNo,cmdp->u.cache64.BlockCnt));
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache64.sg_lst) +
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)cmdp->u.cache64.sg_canz * sizeof(gdth_sg64_str);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
|
|
|
|
cmdp->u.cache.DestAddr,cmdp->u.cache.sg_canz,
|
|
|
|
cmdp->u.cache.sg_lst[0].sg_ptr,
|
|
|
|
cmdp->u.cache.sg_lst[0].sg_len));
|
|
|
|
TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
|
|
|
|
cmdp->OpCode,cmdp->u.cache.BlockNo,cmdp->u.cache.BlockCnt));
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) +
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)cmdp->u.cache.sg_canz * sizeof(gdth_sg_str);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (ha->cmd_len & 3)
|
|
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
|
|
|
|
|
|
|
if (ha->cmd_cnt > 0) {
|
|
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
|
|
|
ha->ic_all_size) {
|
|
|
|
TRACE2(("gdth_fill_cache() DPMEM overflow\n"));
|
|
|
|
ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy command */
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return cmd_index;
|
|
|
|
}
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdth_cmd_str *cmdp;
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 i;
|
2007-10-03 05:18:03 +08:00
|
|
|
dma_addr_t sense_paddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
int cmd_index, sgcnt, mode64;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 t,l;
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
t = scp->device->id;
|
|
|
|
l = scp->device->lun;
|
|
|
|
cmdp = ha->pccb;
|
|
|
|
TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
|
|
|
|
scp->cmnd[0],b,t,l));
|
|
|
|
|
|
|
|
mode64 = (ha->raw_feat & GDT_64BIT) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
cmdp->Service = SCSIRAWSERVICE;
|
|
|
|
cmdp->RequestBuffer = scp;
|
|
|
|
/* search free command index */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_get_cmd_index(ha))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("GDT: No free command index found\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* if it's the first command, set command semaphore */
|
|
|
|
if (ha->cmd_cnt == 0)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
cmndinfo = gdth_cmnd_priv(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* fill command */
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode != -1) {
|
|
|
|
cmdp->OpCode = cmndinfo->OpCode; /* special raw cmd. */
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
if (mode64) {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmdp->u.raw64.direction = (cmndinfo->phase >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("special raw cmd 0x%x param 0x%x\n",
|
|
|
|
cmdp->OpCode, cmdp->u.raw64.direction));
|
|
|
|
/* evaluate command size */
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst);
|
|
|
|
} else {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmdp->u.raw.direction = (cmndinfo->phase >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("special raw cmd 0x%x param 0x%x\n",
|
|
|
|
cmdp->OpCode, cmdp->u.raw.direction));
|
|
|
|
/* evaluate command size */
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2018-12-12 15:41:27 +08:00
|
|
|
sense_paddr = dma_map_single(&ha->pdev->dev, scp->sense_buffer, 16,
|
|
|
|
DMA_FROM_DEVICE);
|
2007-10-03 05:14:39 +08:00
|
|
|
|
|
|
|
cmndinfo->sense_paddr = sense_paddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->OpCode = GDT_WRITE; /* always */
|
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
if (mode64) {
|
|
|
|
cmdp->u.raw64.reserved = 0;
|
|
|
|
cmdp->u.raw64.mdisc_time = 0;
|
|
|
|
cmdp->u.raw64.mcon_time = 0;
|
|
|
|
cmdp->u.raw64.clen = scp->cmd_len;
|
|
|
|
cmdp->u.raw64.target = t;
|
|
|
|
cmdp->u.raw64.lun = l;
|
|
|
|
cmdp->u.raw64.bus = b;
|
|
|
|
cmdp->u.raw64.priority = 0;
|
2008-02-28 07:31:20 +08:00
|
|
|
cmdp->u.raw64.sdlen = scsi_bufflen(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw64.sense_len = 16;
|
|
|
|
cmdp->u.raw64.sense_data = sense_paddr;
|
|
|
|
cmdp->u.raw64.direction =
|
|
|
|
gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN;
|
|
|
|
memcpy(cmdp->u.raw64.cmd,scp->cmnd,16);
|
2007-03-06 18:46:54 +08:00
|
|
|
cmdp->u.raw64.sg_ranz = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
cmdp->u.raw.reserved = 0;
|
|
|
|
cmdp->u.raw.mdisc_time = 0;
|
|
|
|
cmdp->u.raw.mcon_time = 0;
|
|
|
|
cmdp->u.raw.clen = scp->cmd_len;
|
|
|
|
cmdp->u.raw.target = t;
|
|
|
|
cmdp->u.raw.lun = l;
|
|
|
|
cmdp->u.raw.bus = b;
|
|
|
|
cmdp->u.raw.priority = 0;
|
|
|
|
cmdp->u.raw.link_p = 0;
|
2008-02-28 07:31:20 +08:00
|
|
|
cmdp->u.raw.sdlen = scsi_bufflen(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw.sense_len = 16;
|
|
|
|
cmdp->u.raw.sense_data = sense_paddr;
|
|
|
|
cmdp->u.raw.direction =
|
|
|
|
gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN;
|
|
|
|
memcpy(cmdp->u.raw.cmd,scp->cmnd,12);
|
2007-03-06 18:46:54 +08:00
|
|
|
cmdp->u.raw.sg_ranz = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-02-28 07:31:20 +08:00
|
|
|
if (scsi_bufflen(scp)) {
|
2018-12-12 15:41:27 +08:00
|
|
|
cmndinfo->dma_dir = DMA_BIDIRECTIONAL;
|
|
|
|
sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp),
|
|
|
|
scsi_sg_count(scp), cmndinfo->dma_dir);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (mode64) {
|
2007-10-03 05:18:03 +08:00
|
|
|
struct scatterlist *sl;
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
cmdp->u.raw64.sdata = (u64)-1;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw64.sg_ranz = sgcnt;
|
2007-10-03 05:18:03 +08:00
|
|
|
scsi_for_each_sg(scp, sl, sgcnt, i) {
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw64.sg_lst[i].sg_ptr = sg_dma_address(sl);
|
|
|
|
cmdp->u.raw64.sg_lst[i].sg_len = sg_dma_len(sl);
|
|
|
|
}
|
|
|
|
} else {
|
2007-10-03 05:18:03 +08:00
|
|
|
struct scatterlist *sl;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw.sdata = 0xffffffff;
|
|
|
|
cmdp->u.raw.sg_ranz = sgcnt;
|
2007-10-03 05:18:03 +08:00
|
|
|
scsi_for_each_sg(scp, sl, sgcnt, i) {
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->u.raw.sg_lst[i].sg_ptr = sg_dma_address(sl);
|
|
|
|
cmdp->u.raw.sg_lst[i].sg_len = sg_dma_len(sl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
|
|
|
if (max_sg < sgcnt) {
|
|
|
|
max_sg = sgcnt;
|
|
|
|
TRACE3(("GDT: max_sg = %d\n",sgcnt));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
if (mode64) {
|
|
|
|
TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
|
|
|
|
cmdp->u.raw64.sdata,cmdp->u.raw64.sg_ranz,
|
|
|
|
cmdp->u.raw64.sg_lst[0].sg_ptr,
|
|
|
|
cmdp->u.raw64.sg_lst[0].sg_len));
|
|
|
|
/* evaluate command size */
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst) +
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)cmdp->u.raw64.sg_ranz * sizeof(gdth_sg64_str);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
|
|
|
|
cmdp->u.raw.sdata,cmdp->u.raw.sg_ranz,
|
|
|
|
cmdp->u.raw.sg_lst[0].sg_ptr,
|
|
|
|
cmdp->u.raw.sg_lst[0].sg_len));
|
|
|
|
/* evaluate command size */
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) +
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)cmdp->u.raw.sg_ranz * sizeof(gdth_sg_str);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* check space */
|
|
|
|
if (ha->cmd_len & 3)
|
|
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
|
|
|
|
|
|
|
if (ha->cmd_cnt > 0) {
|
|
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
|
|
|
ha->ic_all_size) {
|
|
|
|
TRACE2(("gdth_fill_raw() DPMEM overflow\n"));
|
|
|
|
ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy command */
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return cmd_index;
|
|
|
|
}
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_special_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
register gdth_cmd_str *cmdp;
|
2008-02-28 07:29:15 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
int cmd_index;
|
|
|
|
|
|
|
|
cmdp= ha->pccb;
|
|
|
|
TRACE2(("gdth_special_cmd(): "));
|
|
|
|
|
2008-02-28 07:29:15 +08:00
|
|
|
*cmdp = *cmndinfo->internal_cmd_str;
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->RequestBuffer = scp;
|
|
|
|
|
|
|
|
/* search free command index */
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!(cmd_index=gdth_get_cmd_index(ha))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE(("GDT: No free command index found\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if it's the first command, set command semaphore */
|
|
|
|
if (ha->cmd_cnt == 0)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* evaluate command size, check space */
|
|
|
|
if (cmdp->OpCode == GDT_IOCTL) {
|
|
|
|
TRACE2(("IOCTL\n"));
|
|
|
|
ha->cmd_len =
|
2010-01-04 23:19:34 +08:00
|
|
|
GDTOFFSOF(gdth_cmd_str,u.ioctl.p_param) + sizeof(u64);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (cmdp->Service == CACHESERVICE) {
|
|
|
|
TRACE2(("cache command %d\n",cmdp->OpCode));
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
ha->cmd_len =
|
|
|
|
GDTOFFSOF(gdth_cmd_str,u.cache64.sg_lst) + sizeof(gdth_sg64_str);
|
|
|
|
else
|
|
|
|
ha->cmd_len =
|
|
|
|
GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + sizeof(gdth_sg_str);
|
|
|
|
} else if (cmdp->Service == SCSIRAWSERVICE) {
|
|
|
|
TRACE2(("raw command %d\n",cmdp->OpCode));
|
|
|
|
if (ha->raw_feat & GDT_64BIT)
|
|
|
|
ha->cmd_len =
|
|
|
|
GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst) + sizeof(gdth_sg64_str);
|
|
|
|
else
|
|
|
|
ha->cmd_len =
|
|
|
|
GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + sizeof(gdth_sg_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ha->cmd_len & 3)
|
|
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
|
|
|
|
|
|
|
if (ha->cmd_cnt > 0) {
|
|
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
|
|
|
ha->ic_all_size) {
|
|
|
|
TRACE2(("gdth_special_cmd() DPMEM overflow\n"));
|
|
|
|
ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy command */
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return cmd_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Controller event handling functions */
|
2010-01-04 23:19:34 +08:00
|
|
|
static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, u16 source,
|
|
|
|
u16 idx, gdth_evt_data *evt)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdth_evt_str *e;
|
|
|
|
|
|
|
|
/* no GDTH_LOCK_HA() ! */
|
|
|
|
TRACE2(("gdth_store_event() source %d idx %d\n", source, idx));
|
|
|
|
if (source == 0) /* no source -> no event */
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (ebuffer[elastidx].event_source == source &&
|
|
|
|
ebuffer[elastidx].event_idx == idx &&
|
|
|
|
((evt->size != 0 && ebuffer[elastidx].event_data.size != 0 &&
|
|
|
|
!memcmp((char *)&ebuffer[elastidx].event_data.eu,
|
|
|
|
(char *)&evt->eu, evt->size)) ||
|
|
|
|
(evt->size == 0 && ebuffer[elastidx].event_data.size == 0 &&
|
|
|
|
!strcmp((char *)&ebuffer[elastidx].event_data.event_string,
|
|
|
|
(char *)&evt->event_string)))) {
|
|
|
|
e = &ebuffer[elastidx];
|
2016-02-18 13:29:34 +08:00
|
|
|
e->last_stamp = (u32)ktime_get_real_seconds();
|
2005-04-17 06:20:36 +08:00
|
|
|
++e->same_count;
|
|
|
|
} else {
|
|
|
|
if (ebuffer[elastidx].event_source != 0) { /* entry not free ? */
|
|
|
|
++elastidx;
|
|
|
|
if (elastidx == MAX_EVENTS)
|
|
|
|
elastidx = 0;
|
|
|
|
if (elastidx == eoldidx) { /* reached mark ? */
|
|
|
|
++eoldidx;
|
|
|
|
if (eoldidx == MAX_EVENTS)
|
|
|
|
eoldidx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e = &ebuffer[elastidx];
|
|
|
|
e->event_source = source;
|
|
|
|
e->event_idx = idx;
|
2016-02-18 13:29:34 +08:00
|
|
|
e->first_stamp = e->last_stamp = (u32)ktime_get_real_seconds();
|
2005-04-17 06:20:36 +08:00
|
|
|
e->same_count = 1;
|
|
|
|
e->event_data = *evt;
|
|
|
|
e->application = 0;
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr)
|
|
|
|
{
|
|
|
|
gdth_evt_str *e;
|
|
|
|
int eindex;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE2(("gdth_read_event() handle %d\n", handle));
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
if (handle == -1)
|
|
|
|
eindex = eoldidx;
|
|
|
|
else
|
|
|
|
eindex = handle;
|
|
|
|
estr->event_source = 0;
|
|
|
|
|
2009-10-20 07:55:13 +08:00
|
|
|
if (eindex < 0 || eindex >= MAX_EVENTS) {
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return eindex;
|
|
|
|
}
|
|
|
|
e = &ebuffer[eindex];
|
|
|
|
if (e->event_source != 0) {
|
|
|
|
if (eindex != elastidx) {
|
|
|
|
if (++eindex == MAX_EVENTS)
|
|
|
|
eindex = 0;
|
|
|
|
} else {
|
|
|
|
eindex = -1;
|
|
|
|
}
|
|
|
|
memcpy(estr, e, sizeof(gdth_evt_str));
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return eindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gdth_readapp_event(gdth_ha_str *ha,
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 application, gdth_evt_str *estr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdth_evt_str *e;
|
|
|
|
int eindex;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
|
|
|
u8 found = FALSE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE2(("gdth_readapp_event() app. %d\n", application));
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
eindex = eoldidx;
|
|
|
|
for (;;) {
|
|
|
|
e = &ebuffer[eindex];
|
|
|
|
if (e->event_source == 0)
|
|
|
|
break;
|
|
|
|
if ((e->application & application) == 0) {
|
|
|
|
e->application |= application;
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (eindex == elastidx)
|
|
|
|
break;
|
|
|
|
if (++eindex == MAX_EVENTS)
|
|
|
|
eindex = 0;
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
memcpy(estr, e, sizeof(gdth_evt_str));
|
|
|
|
else
|
|
|
|
estr->event_source = 0;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gdth_clear_events(void)
|
|
|
|
{
|
|
|
|
TRACE(("gdth_clear_events()"));
|
|
|
|
|
|
|
|
eoldidx = elastidx = 0;
|
|
|
|
ebuffer[0].event_source = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* SCSI interface functions */
|
|
|
|
|
2007-12-14 08:14:12 +08:00
|
|
|
static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
|
2007-10-03 05:08:10 +08:00
|
|
|
int gdth_from_wait, int* pIndex)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdt6m_dpram_str __iomem *dp6m_ptr = NULL;
|
|
|
|
gdt6_dpram_str __iomem *dp6_ptr;
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *scp;
|
2007-10-03 05:08:10 +08:00
|
|
|
int rval, i;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 IStatus;
|
|
|
|
u16 Service;
|
|
|
|
unsigned long flags = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-12-14 08:14:12 +08:00
|
|
|
TRACE(("gdth_interrupt() IRQ %d\n", ha->irq));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* if polling and not from gdth_wait() -> return */
|
|
|
|
if (gdth_polling) {
|
|
|
|
if (!gdth_from_wait) {
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* search controller */
|
2007-12-14 08:14:12 +08:00
|
|
|
IStatus = gdth_get_status(ha);
|
|
|
|
if (IStatus == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* spurious interrupt */
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
return IRQ_HANDLED;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
|
|
|
++act_ints;
|
|
|
|
#endif
|
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dp6_ptr = ha->brd;
|
|
|
|
if (IStatus & 0x80) { /* error flag */
|
|
|
|
IStatus &= ~0x80;
|
2007-10-03 04:55:53 +08:00
|
|
|
ha->status = readw(&dp6_ptr->u.ic.Status);
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
|
|
|
|
} else /* no error */
|
|
|
|
ha->status = S_OK;
|
2007-10-03 04:55:53 +08:00
|
|
|
ha->info = readl(&dp6_ptr->u.ic.Info[0]);
|
|
|
|
ha->service = readw(&dp6_ptr->u.ic.Service);
|
|
|
|
ha->info2 = readl(&dp6_ptr->u.ic.Info[1]);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 04:55:53 +08:00
|
|
|
writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */
|
|
|
|
writeb(0, &dp6_ptr->u.ic.Cmd_Index);/* reset command index */
|
|
|
|
writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (ha->type == GDT_PCINEW) {
|
|
|
|
if (IStatus & 0x80) { /* error flag */
|
|
|
|
IStatus &= ~0x80;
|
|
|
|
ha->status = inw(PTR2USHORT(&ha->plx->status));
|
|
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
|
|
|
|
} else
|
|
|
|
ha->status = S_OK;
|
|
|
|
ha->info = inl(PTR2USHORT(&ha->plx->info[0]));
|
|
|
|
ha->service = inw(PTR2USHORT(&ha->plx->service));
|
|
|
|
ha->info2 = inl(PTR2USHORT(&ha->plx->info[1]));
|
|
|
|
|
|
|
|
outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
|
|
|
|
outb(0x00, PTR2USHORT(&ha->plx->sema1_reg));
|
|
|
|
} else if (ha->type == GDT_PCIMPR) {
|
|
|
|
dp6m_ptr = ha->brd;
|
|
|
|
if (IStatus & 0x80) { /* error flag */
|
|
|
|
IStatus &= ~0x80;
|
2018-12-12 15:41:26 +08:00
|
|
|
ha->status = readw(&dp6m_ptr->i960r.status);
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
|
|
|
|
} else /* no error */
|
|
|
|
ha->status = S_OK;
|
2018-12-12 15:41:26 +08:00
|
|
|
|
|
|
|
ha->info = readl(&dp6m_ptr->i960r.info[0]);
|
|
|
|
ha->service = readw(&dp6m_ptr->i960r.service);
|
|
|
|
ha->info2 = readl(&dp6m_ptr->i960r.info[1]);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* event string */
|
|
|
|
if (IStatus == ASYNCINDEX) {
|
|
|
|
if (ha->service != SCREENSERVICE &&
|
|
|
|
(ha->fw_vers & 0xff) >= 0x1a) {
|
2007-10-03 04:55:53 +08:00
|
|
|
ha->dvr.severity = readb
|
2005-04-17 06:20:36 +08:00
|
|
|
(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.severity);
|
|
|
|
for (i = 0; i < 256; ++i) {
|
2007-10-03 04:55:53 +08:00
|
|
|
ha->dvr.event_string[i] = readb
|
2005-04-17 06:20:36 +08:00
|
|
|
(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.evt_str[i]);
|
|
|
|
if (ha->dvr.event_string[i] == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 15:41:26 +08:00
|
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
|
|
|
writeb(0, &dp6m_ptr->i960r.sema1_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
TRACE2(("gdth_interrupt() unknown controller type\n"));
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE(("gdth_interrupt() index %d stat %d info %d\n",
|
|
|
|
IStatus,ha->status,ha->info));
|
|
|
|
|
|
|
|
if (gdth_from_wait) {
|
2007-10-03 05:08:10 +08:00
|
|
|
*pIndex = (int)IStatus;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IStatus == ASYNCINDEX) {
|
|
|
|
TRACE2(("gdth_interrupt() async. event\n"));
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_async_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_next(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IStatus == SPEZINDEX) {
|
|
|
|
TRACE2(("Service unknown or not initialized !\n"));
|
|
|
|
ha->dvr.size = sizeof(ha->dvr.eu.driver);
|
2007-10-03 05:08:10 +08:00
|
|
|
ha->dvr.eu.driver.ionode = ha->hanum;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_store_event(ha, ES_DRIVER, 4, &ha->dvr);
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
scp = ha->cmd_tab[IStatus-2].cmnd;
|
|
|
|
Service = ha->cmd_tab[IStatus-2].service;
|
|
|
|
ha->cmd_tab[IStatus-2].cmnd = UNUSED_CMND;
|
|
|
|
if (scp == UNUSED_CMND) {
|
|
|
|
TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus));
|
|
|
|
ha->dvr.size = sizeof(ha->dvr.eu.driver);
|
2007-10-03 05:08:10 +08:00
|
|
|
ha->dvr.eu.driver.ionode = ha->hanum;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->dvr.eu.driver.index = IStatus;
|
|
|
|
gdth_store_event(ha, ES_DRIVER, 1, &ha->dvr);
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
if (scp == INTERNAL_CMND) {
|
|
|
|
TRACE(("gdth_interrupt() answer to internal command\n"));
|
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE(("gdth_interrupt() sync. status\n"));
|
2007-10-03 05:05:53 +08:00
|
|
|
rval = gdth_sync_event(ha,Service,IStatus,scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!gdth_polling)
|
2007-10-03 05:08:10 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (rval == 2) {
|
2007-10-03 05:16:01 +08:00
|
|
|
gdth_putq(ha, scp, gdth_cmnd_priv(scp)->priority);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (rval == 1) {
|
2007-10-03 04:40:22 +08:00
|
|
|
gdth_scsi_done(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_next(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:08:10 +08:00
|
|
|
static irqreturn_t gdth_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
2007-12-14 08:14:12 +08:00
|
|
|
gdth_ha_str *ha = dev_id;
|
2007-10-03 05:08:10 +08:00
|
|
|
|
2007-12-14 08:14:12 +08:00
|
|
|
return __gdth_interrupt(ha, false, NULL);
|
2007-10-03 05:08:10 +08:00
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index,
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *scp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdth_msg_str *msg;
|
|
|
|
gdth_cmd_str *cmdp;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b, t;
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
cmdp = ha->pccb;
|
|
|
|
TRACE(("gdth_sync_event() serv %d status %d\n",
|
|
|
|
service,ha->status));
|
|
|
|
|
|
|
|
if (service == SCREENSERVICE) {
|
|
|
|
msg = ha->pmsg;
|
|
|
|
TRACE(("len: %d, answer: %d, ext: %d, alen: %d\n",
|
|
|
|
msg->msg_len,msg->msg_answer,msg->msg_ext,msg->msg_alen));
|
|
|
|
if (msg->msg_len > MSGLEN+1)
|
|
|
|
msg->msg_len = MSGLEN+1;
|
|
|
|
if (msg->msg_len)
|
|
|
|
if (!(msg->msg_answer && msg->msg_ext)) {
|
|
|
|
msg->msg_text[msg->msg_len] = '\0';
|
|
|
|
printk("%s",msg->msg_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg->msg_ext && !msg->msg_answer) {
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
|
|
|
cmdp->Service = SCREENSERVICE;
|
|
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_get_cmd_index(ha);
|
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->OpCode = GDT_READ;
|
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
cmdp->u.screen.reserved = 0;
|
|
|
|
cmdp->u.screen.su.msg.msg_handle= msg->msg_handle;
|
|
|
|
cmdp->u.screen.su.msg.msg_addr = ha->msg_phys;
|
|
|
|
ha->cmd_offs_dpmem = 0;
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
|
2010-01-04 23:19:34 +08:00
|
|
|
+ sizeof(u64);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->cmd_cnt = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
|
|
|
gdth_release_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg->msg_answer && msg->msg_alen) {
|
|
|
|
/* default answers (getchar() not possible) */
|
|
|
|
if (msg->msg_alen == 1) {
|
|
|
|
msg->msg_alen = 0;
|
|
|
|
msg->msg_len = 1;
|
|
|
|
msg->msg_text[0] = 0;
|
|
|
|
} else {
|
|
|
|
msg->msg_alen -= 2;
|
|
|
|
msg->msg_len = 2;
|
|
|
|
msg->msg_text[0] = 1;
|
|
|
|
msg->msg_text[1] = 0;
|
|
|
|
}
|
|
|
|
msg->msg_ext = 0;
|
|
|
|
msg->msg_answer = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
|
|
|
cmdp->Service = SCREENSERVICE;
|
|
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_get_cmd_index(ha);
|
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->OpCode = GDT_WRITE;
|
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
cmdp->u.screen.reserved = 0;
|
|
|
|
cmdp->u.screen.su.msg.msg_handle= msg->msg_handle;
|
|
|
|
cmdp->u.screen.su.msg.msg_addr = ha->msg_phys;
|
|
|
|
ha->cmd_offs_dpmem = 0;
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
|
2010-01-04 23:19:34 +08:00
|
|
|
+ sizeof(u64);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->cmd_cnt = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
|
|
|
gdth_release_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
printk("\n");
|
|
|
|
|
|
|
|
} else {
|
2007-10-03 04:59:53 +08:00
|
|
|
b = scp->device->channel;
|
2005-04-17 06:20:36 +08:00
|
|
|
t = scp->device->id;
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode == -1 && b != ha->virt_bus) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->raw[BUS_L2P(ha,b)].io_cnt[t]--;
|
|
|
|
}
|
|
|
|
/* cache or raw service */
|
|
|
|
if (ha->status == S_BSY) {
|
|
|
|
TRACE2(("Controller busy -> retry !\n"));
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode == GDT_MOUNT)
|
|
|
|
cmndinfo->OpCode = GDT_CLUST_INFO;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* retry */
|
|
|
|
return 2;
|
|
|
|
}
|
2008-02-28 07:31:20 +08:00
|
|
|
if (scsi_bufflen(scp))
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_unmap_sg(&ha->pdev->dev, scsi_sglist(scp), scsi_sg_count(scp),
|
2007-10-03 05:18:03 +08:00
|
|
|
cmndinfo->dma_dir);
|
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
if (cmndinfo->sense_paddr)
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_unmap_page(&ha->pdev->dev, cmndinfo->sense_paddr, 16,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (ha->status == S_OK) {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->status = S_OK;
|
|
|
|
cmndinfo->info = ha->info;
|
|
|
|
if (cmndinfo->OpCode != -1) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n",
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->OpCode));
|
2005-04-17 06:20:36 +08:00
|
|
|
/* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode == GDT_CLUST_INFO) {
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[t].cluster_type = (u8)ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!(ha->hdr[t].cluster_type &
|
|
|
|
CLUSTER_MOUNTED)) {
|
|
|
|
/* NOT MOUNTED -> MOUNT */
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->OpCode = GDT_MOUNT;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ha->hdr[t].cluster_type &
|
|
|
|
CLUSTER_RESERVED) {
|
|
|
|
/* cluster drive RESERVED (on the other node) */
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->phase = -2; /* reservation conflict */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->OpCode = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode == GDT_MOUNT) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->hdr[t].cluster_type |= CLUSTER_MOUNTED;
|
|
|
|
ha->hdr[t].media_changed = TRUE;
|
2007-10-03 05:16:01 +08:00
|
|
|
} else if (cmndinfo->OpCode == GDT_UNMOUNT) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED;
|
|
|
|
ha->hdr[t].media_changed = TRUE;
|
|
|
|
}
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->OpCode = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
/* retry */
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->priority = HIGH_PRI;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 2;
|
|
|
|
} else {
|
|
|
|
/* RESERVE/RELEASE ? */
|
|
|
|
if (scp->cmnd[0] == RESERVE) {
|
|
|
|
ha->hdr[t].cluster_type |= CLUSTER_RESERVED;
|
|
|
|
} else if (scp->cmnd[0] == RELEASE) {
|
|
|
|
ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED;
|
|
|
|
}
|
|
|
|
scp->result = DID_OK << 16;
|
|
|
|
scp->sense_buffer[0] = 0;
|
|
|
|
}
|
|
|
|
} else {
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->status = ha->status;
|
|
|
|
cmndinfo->info = ha->info;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
if (cmndinfo->OpCode != -1) {
|
2005-04-17 06:20:36 +08:00
|
|
|
TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n",
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->OpCode, ha->status));
|
|
|
|
if (cmndinfo->OpCode == GDT_SCAN_START ||
|
|
|
|
cmndinfo->OpCode == GDT_SCAN_END) {
|
|
|
|
cmndinfo->OpCode = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* retry */
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->priority = HIGH_PRI;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
memset((char*)scp->sense_buffer,0,16);
|
|
|
|
scp->sense_buffer[0] = 0x70;
|
|
|
|
scp->sense_buffer[2] = NOT_READY;
|
|
|
|
scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
|
|
|
} else if (service == CACHESERVICE) {
|
|
|
|
if (ha->status == S_CACHE_UNKNOWN &&
|
|
|
|
(ha->hdr[t].cluster_type &
|
|
|
|
CLUSTER_RESERVE_STATE) == CLUSTER_RESERVE_STATE) {
|
|
|
|
/* bus reset -> force GDT_CLUST_INFO */
|
|
|
|
ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED;
|
|
|
|
}
|
|
|
|
memset((char*)scp->sense_buffer,0,16);
|
2010-01-04 23:19:34 +08:00
|
|
|
if (ha->status == (u16)S_CACHE_RESERV) {
|
2005-04-17 06:20:36 +08:00
|
|
|
scp->result = (DID_OK << 16) | (RESERVATION_CONFLICT << 1);
|
|
|
|
} else {
|
|
|
|
scp->sense_buffer[0] = 0x70;
|
|
|
|
scp->sense_buffer[2] = NOT_READY;
|
|
|
|
scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
|
|
|
}
|
2007-10-03 05:14:39 +08:00
|
|
|
if (!cmndinfo->internal_command) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->dvr.size = sizeof(ha->dvr.eu.sync);
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->dvr.eu.sync.ionode = ha->hanum;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->dvr.eu.sync.service = service;
|
|
|
|
ha->dvr.eu.sync.status = ha->status;
|
|
|
|
ha->dvr.eu.sync.info = ha->info;
|
|
|
|
ha->dvr.eu.sync.hostdrive = t;
|
|
|
|
if (ha->status >= 0x8000)
|
|
|
|
gdth_store_event(ha, ES_SYNC, 0, &ha->dvr);
|
|
|
|
else
|
|
|
|
gdth_store_event(ha, ES_SYNC, service, &ha->dvr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* sense buffer filled from controller firmware (DMA) */
|
|
|
|
if (ha->status != S_RAW_SCSI || ha->info >= 0x100) {
|
|
|
|
scp->result = DID_BAD_TARGET << 16;
|
|
|
|
} else {
|
|
|
|
scp->result = (DID_OK << 16) | ha->info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-03 05:16:01 +08:00
|
|
|
if (!cmndinfo->wait_for_completion)
|
|
|
|
cmndinfo->wait_for_completion++;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *async_cache_tab[] = {
|
|
|
|
/* 0*/ "\011\000\002\002\002\004\002\006\004"
|
|
|
|
"GDT HA %u, service %u, async. status %u/%lu unknown",
|
|
|
|
/* 1*/ "\011\000\002\002\002\004\002\006\004"
|
|
|
|
"GDT HA %u, service %u, async. status %u/%lu unknown",
|
|
|
|
/* 2*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Host Drive %lu not ready",
|
|
|
|
/* 3*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Host Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
|
|
|
|
/* 4*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, mirror update on Host Drive %lu failed",
|
|
|
|
/* 5*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Mirror Drive %lu failed",
|
|
|
|
/* 6*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Mirror Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
|
|
|
|
/* 7*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Host Drive %lu write protected",
|
|
|
|
/* 8*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, media changed in Host Drive %lu",
|
|
|
|
/* 9*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Host Drive %lu is offline",
|
|
|
|
/*10*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, media change of Mirror Drive %lu",
|
|
|
|
/*11*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Mirror Drive %lu is write protected",
|
|
|
|
/*12*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!",
|
|
|
|
/*13*/ "\007\000\002\006\002\010\002"
|
|
|
|
"GDT HA %u, Array Drive %u: Cache Drive %u failed",
|
|
|
|
/*14*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: FAIL state entered",
|
|
|
|
/*15*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: error",
|
|
|
|
/*16*/ "\007\000\002\006\002\010\002"
|
|
|
|
"GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u",
|
|
|
|
/*17*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity build failed",
|
|
|
|
/*18*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive rebuild failed",
|
|
|
|
/*19*/ "\005\000\002\010\002"
|
|
|
|
"GDT HA %u, Test of Hot Fix %u failed",
|
|
|
|
/*20*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive build finished successfully",
|
|
|
|
/*21*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive rebuild finished successfully",
|
|
|
|
/*22*/ "\007\000\002\006\002\010\002"
|
|
|
|
"GDT HA %u, Array Drive %u: Hot Fix %u activated",
|
|
|
|
/*23*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error",
|
|
|
|
/*24*/ "\005\000\002\010\002"
|
|
|
|
"GDT HA %u, mirror update on Cache Drive %u completed",
|
|
|
|
/*25*/ "\005\000\002\010\002"
|
|
|
|
"GDT HA %u, mirror update on Cache Drive %lu failed",
|
|
|
|
/*26*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive rebuild started",
|
|
|
|
/*27*/ "\005\000\002\012\001"
|
|
|
|
"GDT HA %u, Fault bus %u: SHELF OK detected",
|
|
|
|
/*28*/ "\005\000\002\012\001"
|
|
|
|
"GDT HA %u, Fault bus %u: SHELF not OK detected",
|
|
|
|
/*29*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started",
|
|
|
|
/*30*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: new disk detected",
|
|
|
|
/*31*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: old disk detected",
|
|
|
|
/*32*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: plugging an active disk is invalid",
|
|
|
|
/*33*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: invalid device detected",
|
|
|
|
/*34*/ "\011\000\002\012\001\013\001\006\004"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)",
|
|
|
|
/*35*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: disk write protected",
|
|
|
|
/*36*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: disk not available",
|
|
|
|
/*37*/ "\007\000\002\012\001\006\004"
|
|
|
|
"GDT HA %u, Fault bus %u: swap detected (%lu)",
|
|
|
|
/*38*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully",
|
|
|
|
/*39*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug",
|
|
|
|
/*40*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted",
|
|
|
|
/*41*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started",
|
|
|
|
/*42*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive build started",
|
|
|
|
/*43*/ "\003\000\002"
|
|
|
|
"GDT HA %u, DRAM parity error detected",
|
|
|
|
/*44*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Mirror Drive %u: update started",
|
|
|
|
/*45*/ "\007\000\002\006\002\010\002"
|
|
|
|
"GDT HA %u, Mirror Drive %u: Hot Fix %u activated",
|
|
|
|
/*46*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available",
|
|
|
|
/*47*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: Pool Hot Fix Drive available",
|
|
|
|
/*48*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available",
|
|
|
|
/*49*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available",
|
|
|
|
/*50*/ "\007\000\002\012\001\013\001"
|
|
|
|
"GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received",
|
|
|
|
/*51*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: expand started",
|
|
|
|
/*52*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: expand finished successfully",
|
|
|
|
/*53*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: expand failed",
|
|
|
|
/*54*/ "\003\000\002"
|
|
|
|
"GDT HA %u, CPU temperature critical",
|
|
|
|
/*55*/ "\003\000\002"
|
|
|
|
"GDT HA %u, CPU temperature OK",
|
|
|
|
/*56*/ "\005\000\002\006\004"
|
|
|
|
"GDT HA %u, Host drive %lu created",
|
|
|
|
/*57*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: expand restarted",
|
|
|
|
/*58*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: expand stopped",
|
|
|
|
/*59*/ "\005\000\002\010\002"
|
|
|
|
"GDT HA %u, Mirror Drive %u: drive build quited",
|
|
|
|
/*60*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity build quited",
|
|
|
|
/*61*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: drive rebuild quited",
|
|
|
|
/*62*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity verify started",
|
|
|
|
/*63*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity verify done",
|
|
|
|
/*64*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity verify failed",
|
|
|
|
/*65*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity error detected",
|
|
|
|
/*66*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Array Drive %u: parity verify quited",
|
|
|
|
/*67*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host Drive %u reserved",
|
|
|
|
/*68*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host Drive %u mounted and released",
|
|
|
|
/*69*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host Drive %u released",
|
|
|
|
/*70*/ "\003\000\002"
|
|
|
|
"GDT HA %u, DRAM error detected and corrected with ECC",
|
|
|
|
/*71*/ "\003\000\002"
|
|
|
|
"GDT HA %u, Uncorrectable DRAM error detected with ECC",
|
|
|
|
/*72*/ "\011\000\002\012\001\013\001\014\001"
|
|
|
|
"GDT HA %u, SCSI bus %u, ID %u, LUN %u: reassigning block",
|
|
|
|
/*73*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host drive %u resetted locally",
|
|
|
|
/*74*/ "\005\000\002\006\002"
|
|
|
|
"GDT HA %u, Host drive %u resetted remotely",
|
|
|
|
/*75*/ "\003\000\002"
|
|
|
|
"GDT HA %u, async. status 75 unknown",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static int gdth_async_event(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdth_cmd_str *cmdp;
|
|
|
|
int cmd_index;
|
|
|
|
|
|
|
|
cmdp= ha->pccb;
|
|
|
|
TRACE2(("gdth_async_event() ha %d serv %d\n",
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->hanum, ha->service));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (ha->service == SCREENSERVICE) {
|
|
|
|
if (ha->status == MSG_REQUEST) {
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
|
|
|
cmdp->Service = SCREENSERVICE;
|
|
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2007-10-03 05:05:53 +08:00
|
|
|
cmd_index = gdth_get_cmd_index(ha);
|
|
|
|
gdth_set_sema0(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmdp->OpCode = GDT_READ;
|
|
|
|
cmdp->BoardNode = LOCALBOARD;
|
|
|
|
cmdp->u.screen.reserved = 0;
|
|
|
|
cmdp->u.screen.su.msg.msg_handle= MSG_INV_HANDLE;
|
|
|
|
cmdp->u.screen.su.msg.msg_addr = ha->msg_phys;
|
|
|
|
ha->cmd_offs_dpmem = 0;
|
|
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
|
2010-01-04 23:19:34 +08:00
|
|
|
+ sizeof(u64);
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->cmd_cnt = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_copy_command(ha);
|
2018-12-12 15:41:21 +08:00
|
|
|
printk("[PCI %d/%d] ",(u16)(ha->brd_phys>>8),
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)((ha->brd_phys>>3)&0x1f));
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_release_event(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (ha->type == GDT_PCIMPR &&
|
|
|
|
(ha->fw_vers & 0xff) >= 0x1a) {
|
|
|
|
ha->dvr.size = 0;
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->dvr.eu.async.ionode = ha->hanum;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->dvr.eu.async.status = ha->status;
|
|
|
|
/* severity and event_string already set! */
|
|
|
|
} else {
|
|
|
|
ha->dvr.size = sizeof(ha->dvr.eu.async);
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->dvr.eu.async.ionode = ha->hanum;
|
2005-04-17 06:20:36 +08:00
|
|
|
ha->dvr.eu.async.service = ha->service;
|
|
|
|
ha->dvr.eu.async.status = ha->status;
|
|
|
|
ha->dvr.eu.async.info = ha->info;
|
2010-01-04 23:19:34 +08:00
|
|
|
*(u32 *)ha->dvr.eu.async.scsi_coord = ha->info2;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
gdth_store_event( ha, ES_ASYNC, ha->service, &ha->dvr );
|
|
|
|
gdth_log_event( &ha->dvr, NULL );
|
|
|
|
|
|
|
|
/* new host drive from expand? */
|
|
|
|
if (ha->service == CACHESERVICE && ha->status == 56) {
|
|
|
|
TRACE2(("gdth_async_event(): new host drive %d created\n",
|
2010-01-04 23:19:34 +08:00
|
|
|
(u16)ha->info));
|
|
|
|
/* gdth_analyse_hdrive(hanum, (u16)ha->info); */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gdth_log_event(gdth_evt_data *dvr, char *buffer)
|
|
|
|
{
|
|
|
|
gdth_stackframe stack;
|
|
|
|
char *f = NULL;
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
TRACE2(("gdth_log_event()\n"));
|
|
|
|
if (dvr->size == 0) {
|
|
|
|
if (buffer == NULL) {
|
|
|
|
printk("Adapter %d: %s\n",dvr->eu.async.ionode,dvr->event_string);
|
|
|
|
} else {
|
|
|
|
sprintf(buffer,"Adapter %d: %s\n",
|
|
|
|
dvr->eu.async.ionode,dvr->event_string);
|
|
|
|
}
|
|
|
|
} else if (dvr->eu.async.service == CACHESERVICE &&
|
|
|
|
INDEX_OK(dvr->eu.async.status, async_cache_tab)) {
|
|
|
|
TRACE2(("GDT: Async. event cache service, event no.: %d\n",
|
|
|
|
dvr->eu.async.status));
|
|
|
|
|
|
|
|
f = async_cache_tab[dvr->eu.async.status];
|
|
|
|
|
|
|
|
/* i: parameter to push, j: stack element to fill */
|
|
|
|
for (j=0,i=1; i < f[0]; i+=2) {
|
|
|
|
switch (f[i+1]) {
|
|
|
|
case 4:
|
2010-01-04 23:19:34 +08:00
|
|
|
stack.b[j++] = *(u32*)&dvr->eu.stream[(int)f[i]];
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-01-04 23:19:34 +08:00
|
|
|
stack.b[j++] = *(u16*)&dvr->eu.stream[(int)f[i]];
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2010-01-04 23:19:34 +08:00
|
|
|
stack.b[j++] = *(u8*)&dvr->eu.stream[(int)f[i]];
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer == NULL) {
|
|
|
|
printk(&f[(int)f[0]],stack);
|
|
|
|
printk("\n");
|
|
|
|
} else {
|
|
|
|
sprintf(buffer,&f[(int)f[0]],stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (buffer == NULL) {
|
|
|
|
printk("GDT HA %u, Unknown async. event service %d event no. %d\n",
|
|
|
|
dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status);
|
|
|
|
} else {
|
|
|
|
sprintf(buffer,"GDT HA %u, Unknown async. event service %d event no. %d",
|
|
|
|
dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
2010-01-04 23:19:34 +08:00
|
|
|
static u8 gdth_timer_running;
|
2008-05-05 11:34:49 +08:00
|
|
|
|
2017-10-12 08:17:42 +08:00
|
|
|
static void gdth_timeout(struct timer_list *unused)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u32 i;
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *nscp;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_ha_str *ha;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-05-05 11:34:49 +08:00
|
|
|
if(unlikely(list_empty(&gdth_instances))) {
|
|
|
|
gdth_timer_running = 0;
|
|
|
|
return;
|
|
|
|
}
|
2008-02-28 07:27:16 +08:00
|
|
|
|
2007-10-03 05:11:24 +08:00
|
|
|
ha = list_first_entry(&gdth_instances, gdth_ha_str, list);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
for (act_stats=0,i=0; i<GDTH_MAXCMDS; ++i)
|
|
|
|
if (ha->cmd_tab[i].cmnd != UNUSED_CMND)
|
|
|
|
++act_stats;
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
for (act_rq=0,
|
|
|
|
nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
++act_rq;
|
|
|
|
|
|
|
|
TRACE2(("gdth_to(): ints %d, ios %d, act_stats %d, act_rq %d\n",
|
|
|
|
act_ints, act_ios, act_stats, act_rq));
|
|
|
|
act_ints = act_ios = 0;
|
|
|
|
|
|
|
|
gdth_timer.expires = jiffies + 30 * HZ;
|
|
|
|
add_timer(&gdth_timer);
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|
2008-05-05 11:34:49 +08:00
|
|
|
|
|
|
|
static void gdth_timer_init(void)
|
|
|
|
{
|
|
|
|
if (gdth_timer_running)
|
|
|
|
return;
|
|
|
|
gdth_timer_running = 1;
|
|
|
|
TRACE2(("gdth_detect(): Initializing timer !\n"));
|
|
|
|
gdth_timer.expires = jiffies + HZ;
|
|
|
|
add_timer(&gdth_timer);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void gdth_timer_init(void)
|
|
|
|
{
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2005-04-18 04:28:39 +08:00
|
|
|
static void __init internal_setup(char *str,int *ints)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2018-12-12 15:41:21 +08:00
|
|
|
int i;
|
2005-04-17 06:20:36 +08:00
|
|
|
char *cur_str, *argv;
|
|
|
|
|
|
|
|
TRACE2(("internal_setup() str %s ints[0] %d\n",
|
|
|
|
str ? str:"NULL", ints ? ints[0]:0));
|
|
|
|
|
|
|
|
/* analyse string */
|
|
|
|
argv = str;
|
|
|
|
while (argv && (cur_str = strchr(argv, ':'))) {
|
|
|
|
int val = 0, c = *++cur_str;
|
|
|
|
|
|
|
|
if (c == 'n' || c == 'N')
|
|
|
|
val = 0;
|
|
|
|
else if (c == 'y' || c == 'Y')
|
|
|
|
val = 1;
|
|
|
|
else
|
|
|
|
val = (int)simple_strtoul(cur_str, NULL, 0);
|
|
|
|
|
|
|
|
if (!strncmp(argv, "disable:", 8))
|
|
|
|
disable = val;
|
|
|
|
else if (!strncmp(argv, "reserve_mode:", 13))
|
|
|
|
reserve_mode = val;
|
|
|
|
else if (!strncmp(argv, "reverse_scan:", 13))
|
|
|
|
reverse_scan = val;
|
|
|
|
else if (!strncmp(argv, "hdr_channel:", 12))
|
|
|
|
hdr_channel = val;
|
|
|
|
else if (!strncmp(argv, "max_ids:", 8))
|
|
|
|
max_ids = val;
|
|
|
|
else if (!strncmp(argv, "rescan:", 7))
|
|
|
|
rescan = val;
|
|
|
|
else if (!strncmp(argv, "shared_access:", 14))
|
|
|
|
shared_access = val;
|
|
|
|
else if (!strncmp(argv, "reserve_list:", 13)) {
|
|
|
|
reserve_list[0] = val;
|
|
|
|
for (i = 1; i < MAX_RES_ARGS; i++) {
|
|
|
|
cur_str = strchr(cur_str, ',');
|
|
|
|
if (!cur_str)
|
|
|
|
break;
|
|
|
|
if (!isdigit((int)*++cur_str)) {
|
|
|
|
--cur_str;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
reserve_list[i] =
|
|
|
|
(int)simple_strtoul(cur_str, NULL, 0);
|
|
|
|
}
|
|
|
|
if (!cur_str)
|
|
|
|
break;
|
|
|
|
argv = ++cur_str;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((argv = strchr(argv, ',')))
|
|
|
|
++argv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int __init option_setup(char *str)
|
|
|
|
{
|
|
|
|
int ints[MAXHA];
|
|
|
|
char *cur = str;
|
|
|
|
int i = 1;
|
|
|
|
|
|
|
|
TRACE2(("option_setup() str %s\n", str ? str:"NULL"));
|
|
|
|
|
2010-03-12 06:09:35 +08:00
|
|
|
while (cur && isdigit(*cur) && i < MAXHA) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ints[i++] = simple_strtoul(cur, NULL, 0);
|
|
|
|
if ((cur = strchr(cur, ',')) != NULL) cur++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ints[0] = i - 1;
|
|
|
|
internal_setup(cur, ints);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
static const char *gdth_ctr_name(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
TRACE2(("gdth_ctr_name()\n"));
|
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type == GDT_PCI) {
|
2007-07-17 17:25:17 +08:00
|
|
|
switch (ha->pdev->device) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case PCI_DEVICE_ID_VORTEX_GDT60x0:
|
|
|
|
return("GDT6000/6020/6050");
|
|
|
|
case PCI_DEVICE_ID_VORTEX_GDT6000B:
|
|
|
|
return("GDT6000B/6010");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */
|
|
|
|
|
|
|
|
return("");
|
|
|
|
}
|
|
|
|
|
2005-04-18 04:28:39 +08:00
|
|
|
static const char *gdth_info(struct Scsi_Host *shp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(shp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE2(("gdth_info()\n"));
|
|
|
|
return ((const char *)ha->binfo.type_string);
|
|
|
|
}
|
|
|
|
|
2008-09-14 20:55:09 +08:00
|
|
|
static enum blk_eh_timer_return gdth_timed_out(struct scsi_cmnd *scp)
|
|
|
|
{
|
|
|
|
gdth_ha_str *ha = shost_priv(scp->device->host);
|
|
|
|
struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b, t;
|
|
|
|
unsigned long flags;
|
2018-05-29 21:52:29 +08:00
|
|
|
enum blk_eh_timer_return retval = BLK_EH_DONE;
|
2008-09-14 20:55:09 +08:00
|
|
|
|
|
|
|
TRACE(("%s() cmd 0x%x\n", scp->cmnd[0], __func__));
|
|
|
|
b = scp->device->channel;
|
|
|
|
t = scp->device->id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't really honor the command timeout, but we try to
|
|
|
|
* honor 6 times of the actual command timeout! So reset the
|
|
|
|
* timer if this is less than 6th timeout on this command!
|
|
|
|
*/
|
|
|
|
if (++cmndinfo->timeout_count < 6)
|
|
|
|
retval = BLK_EH_RESET_TIMER;
|
|
|
|
|
|
|
|
/* Reset the timeout if it is locked IO */
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha, b)].lock) ||
|
|
|
|
(b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) {
|
|
|
|
TRACE2(("%s(): locked IO, reset timeout\n", __func__));
|
|
|
|
retval = BLK_EH_RESET_TIMER;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-13 15:53:47 +08:00
|
|
|
static int gdth_eh_bus_reset(struct scsi_cmnd *scp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(scp->device->host);
|
|
|
|
int i;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *cmnd;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE2(("gdth_eh_bus_reset()\n"));
|
|
|
|
|
2007-10-03 04:59:53 +08:00
|
|
|
b = scp->device->channel;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* clear command tab */
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
for (i = 0; i < GDTH_MAXCMDS; ++i) {
|
|
|
|
cmnd = ha->cmd_tab[i].cmnd;
|
|
|
|
if (!SPECIAL_SCP(cmnd) && cmnd->device->channel == b)
|
|
|
|
ha->cmd_tab[i].cmnd = UNUSED_CMND;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
if (b == ha->virt_bus) {
|
|
|
|
/* host drives */
|
|
|
|
for (i = 0; i < MAX_HDRIVES; ++i) {
|
|
|
|
if (ha->hdr[i].present) {
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
gdth_polling = TRUE;
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
2007-10-03 05:05:53 +08:00
|
|
|
if (gdth_internal_cmd(ha, CACHESERVICE,
|
2005-04-17 06:20:36 +08:00
|
|
|
GDT_CLUST_RESET, i, 0, 0))
|
|
|
|
ha->hdr[i].cluster_type &= ~CLUSTER_RESERVED;
|
|
|
|
gdth_polling = FALSE;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* raw devices */
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
for (i = 0; i < MAXID; ++i)
|
|
|
|
ha->raw[BUS_L2P(ha,b)].io_cnt[i] = 0;
|
|
|
|
gdth_polling = TRUE;
|
2007-10-03 05:05:53 +08:00
|
|
|
while (gdth_test_busy(ha))
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_delay(0);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESET_BUS,
|
2005-04-17 06:20:36 +08:00
|
|
|
BUS_L2P(ha,b), 0, 0);
|
|
|
|
gdth_polling = FALSE;
|
2006-06-10 02:34:29 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-04-18 04:28:39 +08:00
|
|
|
static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 b, t;
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(sdev->host);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct scsi_device *sd;
|
|
|
|
unsigned capacity;
|
|
|
|
|
|
|
|
sd = sdev;
|
|
|
|
capacity = cap;
|
2007-10-03 04:59:53 +08:00
|
|
|
b = sd->channel;
|
2005-04-17 06:20:36 +08:00
|
|
|
t = sd->id;
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", ha->hanum, b, t));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (b != ha->virt_bus || ha->hdr[t].heads == 0) {
|
|
|
|
/* raw device or host drive without mapping information */
|
|
|
|
TRACE2(("Evaluate mapping\n"));
|
|
|
|
gdth_eval_mapping(capacity,&ip[2],&ip[0],&ip[1]);
|
|
|
|
} else {
|
|
|
|
ip[0] = ha->hdr[t].heads;
|
|
|
|
ip[1] = ha->hdr[t].secs;
|
|
|
|
ip[2] = capacity / ip[0] / ip[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n",
|
|
|
|
ip[0],ip[1],ip[2]));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-16 15:10:29 +08:00
|
|
|
static int gdth_queuecommand_lck(struct scsi_cmnd *scp,
|
2007-10-03 04:40:22 +08:00
|
|
|
void (*done)(struct scsi_cmnd *))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_ha_str *ha = shost_priv(scp->device->host);
|
2007-10-03 05:14:39 +08:00
|
|
|
struct gdth_cmndinfo *cmndinfo;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0]));
|
2007-10-03 05:14:39 +08:00
|
|
|
|
|
|
|
cmndinfo = gdth_get_cmndinfo(ha);
|
|
|
|
BUG_ON(!cmndinfo);
|
|
|
|
|
2007-10-03 04:40:22 +08:00
|
|
|
scp->scsi_done = done;
|
2008-09-14 20:55:09 +08:00
|
|
|
cmndinfo->timeout_count = 0;
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->priority = DEFAULT_PRI;
|
2007-10-03 05:18:03 +08:00
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
return __gdth_queuecommand(ha, scp, cmndinfo);
|
|
|
|
}
|
|
|
|
|
2010-11-16 15:10:29 +08:00
|
|
|
static DEF_SCSI_QCMD(gdth_queuecommand)
|
|
|
|
|
2007-10-03 05:14:39 +08:00
|
|
|
static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,
|
|
|
|
struct gdth_cmndinfo *cmndinfo)
|
|
|
|
{
|
|
|
|
scp->host_scribble = (unsigned char *)cmndinfo;
|
2007-10-03 05:16:01 +08:00
|
|
|
cmndinfo->wait_for_completion = 1;
|
|
|
|
cmndinfo->phase = -1;
|
|
|
|
cmndinfo->OpCode = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
|
|
|
++act_ios;
|
|
|
|
#endif
|
|
|
|
|
2007-10-03 05:16:01 +08:00
|
|
|
gdth_putq(ha, scp, cmndinfo->priority);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_next(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int gdth_open(struct inode *inode, struct file *filep)
|
|
|
|
{
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
2010-06-02 20:28:52 +08:00
|
|
|
mutex_lock(&gdth_mutex);
|
2007-10-03 05:11:24 +08:00
|
|
|
list_for_each_entry(ha, &gdth_instances, list) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ha->sdev)
|
2007-10-03 05:11:24 +08:00
|
|
|
ha->sdev = scsi_get_host_dev(ha->shost);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-06-02 20:28:52 +08:00
|
|
|
mutex_unlock(&gdth_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
TRACE(("gdth_open()\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gdth_close(struct inode *inode, struct file *filep)
|
|
|
|
{
|
|
|
|
TRACE(("gdth_close()\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ioc_event(void __user *arg)
|
|
|
|
{
|
|
|
|
gdth_ioctl_event evt;
|
|
|
|
gdth_ha_str *ha;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-03 05:11:24 +08:00
|
|
|
if (copy_from_user(&evt, arg, sizeof(gdth_ioctl_event)))
|
|
|
|
return -EFAULT;
|
|
|
|
ha = gdth_find_ha(evt.ionode);
|
|
|
|
if (!ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (evt.erase == 0xff) {
|
|
|
|
if (evt.event.event_source == ES_TEST)
|
|
|
|
evt.event.event_data.size=sizeof(evt.event.event_data.eu.test);
|
|
|
|
else if (evt.event.event_source == ES_DRIVER)
|
|
|
|
evt.event.event_data.size=sizeof(evt.event.event_data.eu.driver);
|
|
|
|
else if (evt.event.event_source == ES_SYNC)
|
|
|
|
evt.event.event_data.size=sizeof(evt.event.event_data.eu.sync);
|
|
|
|
else
|
|
|
|
evt.event.event_data.size=sizeof(evt.event.event_data.eu.async);
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
gdth_store_event(ha, evt.event.event_source, evt.event.event_idx,
|
|
|
|
&evt.event.event_data);
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
} else if (evt.erase == 0xfe) {
|
|
|
|
gdth_clear_events();
|
|
|
|
} else if (evt.erase == 0) {
|
|
|
|
evt.handle = gdth_read_event(ha, evt.handle, &evt.event);
|
|
|
|
} else {
|
|
|
|
gdth_readapp_event(ha, evt.erase, &evt.event);
|
|
|
|
}
|
|
|
|
if (copy_to_user(arg, &evt, sizeof(gdth_ioctl_event)))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ioc_lockdrv(void __user *arg)
|
|
|
|
{
|
|
|
|
gdth_ioctl_lockdrv ldrv;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 i, j;
|
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
2007-10-03 05:11:24 +08:00
|
|
|
if (copy_from_user(&ldrv, arg, sizeof(gdth_ioctl_lockdrv)))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
2007-10-03 05:11:24 +08:00
|
|
|
ha = gdth_find_ha(ldrv.ionode);
|
|
|
|
if (!ha)
|
|
|
|
return -EFAULT;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) {
|
|
|
|
j = ldrv.drives[i];
|
|
|
|
if (j >= MAX_HDRIVES || !ha->hdr[j].present)
|
|
|
|
continue;
|
|
|
|
if (ldrv.lock) {
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
ha->hdr[j].lock = 1;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_wait_completion(ha, ha->bus_cnt, j);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
ha->hdr[j].lock = 0;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_next(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ioc_resetdrv(void __user *arg, char *cmnd)
|
|
|
|
{
|
|
|
|
gdth_ioctl_reset res;
|
|
|
|
gdth_cmd_str cmd;
|
|
|
|
gdth_ha_str *ha;
|
2006-06-10 02:34:29 +08:00
|
|
|
int rval;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_from_user(&res, arg, sizeof(gdth_ioctl_reset)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
res.number >= MAX_HDRIVES)
|
|
|
|
return -EFAULT;
|
|
|
|
ha = gdth_find_ha(res.ionode);
|
|
|
|
if (!ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
2007-10-03 05:05:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ha->hdr[res.number].present)
|
|
|
|
return 0;
|
|
|
|
memset(&cmd, 0, sizeof(gdth_cmd_str));
|
|
|
|
cmd.Service = CACHESERVICE;
|
|
|
|
cmd.OpCode = GDT_CLUST_RESET;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd.u.cache64.DeviceNo = res.number;
|
|
|
|
else
|
|
|
|
cmd.u.cache.DeviceNo = res.number;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
rval = __gdth_execute(ha->sdev, &cmd, cmnd, 30, NULL);
|
|
|
|
if (rval < 0)
|
|
|
|
return rval;
|
|
|
|
res.status = rval;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_to_user(arg, &res, sizeof(gdth_ioctl_reset)))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-12 15:41:18 +08:00
|
|
|
static void gdth_ioc_cacheservice(gdth_ha_str *ha, gdth_ioctl_general *gen,
|
|
|
|
u64 paddr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2018-12-12 15:41:18 +08:00
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
|
|
|
/* copy elements from 32-bit IOCTL structure */
|
|
|
|
gen->command.u.cache64.BlockCnt = gen->command.u.cache.BlockCnt;
|
|
|
|
gen->command.u.cache64.BlockNo = gen->command.u.cache.BlockNo;
|
|
|
|
gen->command.u.cache64.DeviceNo = gen->command.u.cache.DeviceNo;
|
|
|
|
|
|
|
|
if (ha->cache_feat & SCATTER_GATHER) {
|
|
|
|
gen->command.u.cache64.DestAddr = (u64)-1;
|
|
|
|
gen->command.u.cache64.sg_canz = 1;
|
|
|
|
gen->command.u.cache64.sg_lst[0].sg_ptr = paddr;
|
|
|
|
gen->command.u.cache64.sg_lst[0].sg_len = gen->data_len;
|
|
|
|
gen->command.u.cache64.sg_lst[1].sg_len = 0;
|
|
|
|
} else {
|
|
|
|
gen->command.u.cache64.DestAddr = paddr;
|
|
|
|
gen->command.u.cache64.sg_canz = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ha->cache_feat & SCATTER_GATHER) {
|
|
|
|
gen->command.u.cache.DestAddr = 0xffffffff;
|
|
|
|
gen->command.u.cache.sg_canz = 1;
|
|
|
|
gen->command.u.cache.sg_lst[0].sg_ptr = (u32)paddr;
|
|
|
|
gen->command.u.cache.sg_lst[0].sg_len = gen->data_len;
|
|
|
|
gen->command.u.cache.sg_lst[1].sg_len = 0;
|
|
|
|
} else {
|
|
|
|
gen->command.u.cache.DestAddr = paddr;
|
|
|
|
gen->command.u.cache.sg_canz = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-12-12 15:41:18 +08:00
|
|
|
static void gdth_ioc_scsiraw(gdth_ha_str *ha, gdth_ioctl_general *gen,
|
|
|
|
u64 paddr)
|
|
|
|
{
|
|
|
|
if (ha->raw_feat & GDT_64BIT) {
|
|
|
|
/* copy elements from 32-bit IOCTL structure */
|
|
|
|
char cmd[16];
|
|
|
|
|
|
|
|
gen->command.u.raw64.sense_len = gen->command.u.raw.sense_len;
|
|
|
|
gen->command.u.raw64.bus = gen->command.u.raw.bus;
|
|
|
|
gen->command.u.raw64.lun = gen->command.u.raw.lun;
|
|
|
|
gen->command.u.raw64.target = gen->command.u.raw.target;
|
|
|
|
memcpy(cmd, gen->command.u.raw.cmd, 16);
|
|
|
|
memcpy(gen->command.u.raw64.cmd, cmd, 16);
|
|
|
|
gen->command.u.raw64.clen = gen->command.u.raw.clen;
|
|
|
|
gen->command.u.raw64.sdlen = gen->command.u.raw.sdlen;
|
|
|
|
gen->command.u.raw64.direction = gen->command.u.raw.direction;
|
|
|
|
|
|
|
|
/* addresses */
|
|
|
|
if (ha->raw_feat & SCATTER_GATHER) {
|
|
|
|
gen->command.u.raw64.sdata = (u64)-1;
|
|
|
|
gen->command.u.raw64.sg_ranz = 1;
|
|
|
|
gen->command.u.raw64.sg_lst[0].sg_ptr = paddr;
|
|
|
|
gen->command.u.raw64.sg_lst[0].sg_len = gen->data_len;
|
|
|
|
gen->command.u.raw64.sg_lst[1].sg_len = 0;
|
|
|
|
} else {
|
|
|
|
gen->command.u.raw64.sdata = paddr;
|
|
|
|
gen->command.u.raw64.sg_ranz = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2018-12-12 15:41:18 +08:00
|
|
|
|
|
|
|
gen->command.u.raw64.sense_data = paddr + gen->data_len;
|
|
|
|
} else {
|
|
|
|
if (ha->raw_feat & SCATTER_GATHER) {
|
|
|
|
gen->command.u.raw.sdata = 0xffffffff;
|
|
|
|
gen->command.u.raw.sg_ranz = 1;
|
|
|
|
gen->command.u.raw.sg_lst[0].sg_ptr = (u32)paddr;
|
|
|
|
gen->command.u.raw.sg_lst[0].sg_len = gen->data_len;
|
|
|
|
gen->command.u.raw.sg_lst[1].sg_len = 0;
|
|
|
|
} else {
|
|
|
|
gen->command.u.raw.sdata = paddr;
|
|
|
|
gen->command.u.raw.sg_ranz = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2018-12-12 15:41:18 +08:00
|
|
|
gen->command.u.raw.sense_data = (u32)paddr + gen->data_len;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-12-12 15:41:18 +08:00
|
|
|
static int ioc_general(void __user *arg, char *cmnd)
|
|
|
|
{
|
|
|
|
gdth_ioctl_general gen;
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
char *buf = NULL;
|
2018-12-12 15:41:20 +08:00
|
|
|
dma_addr_t paddr;
|
2018-12-12 15:41:18 +08:00
|
|
|
int rval;
|
|
|
|
|
|
|
|
if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general)))
|
|
|
|
return -EFAULT;
|
|
|
|
ha = gdth_find_ha(gen.ionode);
|
|
|
|
if (!ha)
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (gen.data_len > INT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
if (gen.sense_len > INT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
if (gen.data_len + gen.sense_len > INT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (gen.data_len + gen.sense_len > 0) {
|
2018-12-12 15:41:27 +08:00
|
|
|
buf = dma_alloc_coherent(&ha->pdev->dev,
|
|
|
|
gen.data_len + gen.sense_len, &paddr,
|
|
|
|
GFP_KERNEL);
|
2018-12-12 15:41:18 +08:00
|
|
|
if (!buf)
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
rval = -EFAULT;
|
|
|
|
if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general),
|
|
|
|
gen.data_len + gen.sense_len))
|
|
|
|
goto out_free_buf;
|
|
|
|
|
|
|
|
if (gen.command.OpCode == GDT_IOCTL)
|
|
|
|
gen.command.u.ioctl.p_param = paddr;
|
|
|
|
else if (gen.command.Service == CACHESERVICE)
|
|
|
|
gdth_ioc_cacheservice(ha, &gen, paddr);
|
|
|
|
else if (gen.command.Service == SCSIRAWSERVICE)
|
|
|
|
gdth_ioc_scsiraw(ha, &gen, paddr);
|
|
|
|
else
|
|
|
|
goto out_free_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = __gdth_execute(ha->sdev, &gen.command, cmnd, gen.timeout,
|
|
|
|
&gen.info);
|
|
|
|
if (rval < 0)
|
|
|
|
goto out_free_buf;
|
|
|
|
gen.status = rval;
|
|
|
|
|
|
|
|
rval = -EFAULT;
|
|
|
|
if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf,
|
|
|
|
gen.data_len + gen.sense_len))
|
|
|
|
goto out_free_buf;
|
|
|
|
if (copy_to_user(arg, &gen,
|
|
|
|
sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str)))
|
|
|
|
goto out_free_buf;
|
|
|
|
|
|
|
|
rval = 0;
|
|
|
|
out_free_buf:
|
2019-03-08 07:18:39 +08:00
|
|
|
if (buf)
|
|
|
|
dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len,
|
|
|
|
buf, paddr);
|
2018-12-12 15:41:18 +08:00
|
|
|
return rval;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ioc_hdrlist(void __user *arg, char *cmnd)
|
|
|
|
{
|
|
|
|
gdth_ioctl_rescan *rsc;
|
|
|
|
gdth_cmd_str *cmd;
|
|
|
|
gdth_ha_str *ha;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 i;
|
2007-10-03 05:05:53 +08:00
|
|
|
int rc = -ENOMEM;
|
2006-06-10 02:34:29 +08:00
|
|
|
u32 cluster_type = 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
rsc = kmalloc(sizeof(*rsc), GFP_KERNEL);
|
|
|
|
cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
|
|
|
|
if (!rsc || !cmd)
|
2006-06-10 02:34:29 +08:00
|
|
|
goto free_fail;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
(NULL == (ha = gdth_find_ha(rsc->ionode)))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = -EFAULT;
|
2006-06-10 02:34:29 +08:00
|
|
|
goto free_fail;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
memset(cmd, 0, sizeof(gdth_cmd_str));
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_HDRIVES; ++i) {
|
|
|
|
if (!ha->hdr[i].present) {
|
|
|
|
rsc->hdr_list[i].bus = 0xff;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rsc->hdr_list[i].bus = ha->virt_bus;
|
|
|
|
rsc->hdr_list[i].target = i;
|
|
|
|
rsc->hdr_list[i].lun = 0;
|
|
|
|
rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type;
|
|
|
|
if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) {
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
cmd->OpCode = GDT_CLUST_INFO;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd->u.cache64.DeviceNo = i;
|
|
|
|
else
|
|
|
|
cmd->u.cache.DeviceNo = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
if (__gdth_execute(ha->sdev, cmd, cmnd, 30, &cluster_type) == S_OK)
|
|
|
|
rsc->hdr_list[i].cluster_type = cluster_type;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2006-06-10 02:34:29 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan)))
|
|
|
|
rc = -EFAULT;
|
|
|
|
else
|
2006-06-10 02:34:29 +08:00
|
|
|
rc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
free_fail:
|
|
|
|
kfree(rsc);
|
|
|
|
kfree(cmd);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ioc_rescan(void __user *arg, char *cmnd)
|
|
|
|
{
|
|
|
|
gdth_ioctl_rescan *rsc;
|
|
|
|
gdth_cmd_str *cmd;
|
2010-01-04 23:19:34 +08:00
|
|
|
u16 i, status, hdr_cnt;
|
|
|
|
u32 info;
|
2007-10-03 05:05:53 +08:00
|
|
|
int cyls, hds, secs;
|
2005-04-17 06:20:36 +08:00
|
|
|
int rc = -ENOMEM;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
|
|
|
rsc = kmalloc(sizeof(*rsc), GFP_KERNEL);
|
|
|
|
cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
|
|
|
|
if (!cmd || !rsc)
|
2006-06-10 02:34:29 +08:00
|
|
|
goto free_fail;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
(NULL == (ha = gdth_find_ha(rsc->ionode)))) {
|
2006-06-10 02:34:29 +08:00
|
|
|
rc = -EFAULT;
|
|
|
|
goto free_fail;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
memset(cmd, 0, sizeof(gdth_cmd_str));
|
|
|
|
|
|
|
|
if (rsc->flag == 0) {
|
|
|
|
/* old method: re-init. cache service */
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
|
|
|
cmd->OpCode = GDT_X_INIT_HOST;
|
|
|
|
cmd->u.cache64.DeviceNo = LINUX_OS;
|
|
|
|
} else {
|
|
|
|
cmd->OpCode = GDT_INIT;
|
|
|
|
cmd->u.cache.DeviceNo = LINUX_OS;
|
|
|
|
}
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info);
|
2005-04-17 06:20:36 +08:00
|
|
|
i = 0;
|
2010-01-04 23:19:34 +08:00
|
|
|
hdr_cnt = (status == S_OK ? (u16)info : 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
i = rsc->hdr_no;
|
|
|
|
hdr_cnt = i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; i < hdr_cnt && i < MAX_HDRIVES; ++i) {
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
cmd->OpCode = GDT_INFO;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd->u.cache64.DeviceNo = i;
|
|
|
|
else
|
|
|
|
cmd->u.cache.DeviceNo = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
rsc->hdr_list[i].bus = ha->virt_bus;
|
|
|
|
rsc->hdr_list[i].target = i;
|
|
|
|
rsc->hdr_list[i].lun = 0;
|
|
|
|
if (status != S_OK) {
|
|
|
|
ha->hdr[i].present = FALSE;
|
|
|
|
} else {
|
|
|
|
ha->hdr[i].present = TRUE;
|
|
|
|
ha->hdr[i].size = info;
|
|
|
|
/* evaluate mapping */
|
|
|
|
ha->hdr[i].size &= ~SECS32;
|
|
|
|
gdth_eval_mapping(ha->hdr[i].size,&cyls,&hds,&secs);
|
|
|
|
ha->hdr[i].heads = hds;
|
|
|
|
ha->hdr[i].secs = secs;
|
|
|
|
/* round size */
|
|
|
|
ha->hdr[i].size = cyls * hds * secs;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
if (status != S_OK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* extended info, if GDT_64BIT, for drives > 2 TB */
|
|
|
|
/* but we need ha->info2, not yet stored in scp->SCp */
|
|
|
|
|
|
|
|
/* devtype, cluster info, R/W attribs */
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
cmd->OpCode = GDT_DEVTYPE;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd->u.cache64.DeviceNo = i;
|
|
|
|
else
|
|
|
|
cmd->u.cache.DeviceNo = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[i].devtype = (status == S_OK ? (u16)info : 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
cmd->OpCode = GDT_CLUST_INFO;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd->u.cache64.DeviceNo = i;
|
|
|
|
else
|
|
|
|
cmd->u.cache.DeviceNo = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
ha->hdr[i].cluster_type =
|
2010-01-04 23:19:34 +08:00
|
|
|
((status == S_OK && !shared_access) ? (u16)info : 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type;
|
|
|
|
|
|
|
|
cmd->Service = CACHESERVICE;
|
|
|
|
cmd->OpCode = GDT_RW_ATTRIBS;
|
|
|
|
if (ha->cache_feat & GDT_64BIT)
|
|
|
|
cmd->u.cache64.DeviceNo = i;
|
|
|
|
else
|
|
|
|
cmd->u.cache.DeviceNo = i;
|
2006-06-10 02:34:29 +08:00
|
|
|
|
|
|
|
status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
2010-01-04 23:19:34 +08:00
|
|
|
ha->hdr[i].rw_attribs = (status == S_OK ? (u16)info : 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan)))
|
|
|
|
rc = -EFAULT;
|
|
|
|
else
|
2006-06-10 02:34:29 +08:00
|
|
|
rc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
free_fail:
|
|
|
|
kfree(rsc);
|
|
|
|
kfree(cmd);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-04-27 06:24:01 +08:00
|
|
|
static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
gdth_ha_str *ha;
|
2018-06-13 15:53:47 +08:00
|
|
|
struct scsi_cmnd *scp;
|
2010-01-04 23:19:34 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
char cmnd[MAX_COMMAND_SIZE];
|
|
|
|
void __user *argp = (void __user *)arg;
|
|
|
|
|
|
|
|
memset(cmnd, 0xff, 12);
|
|
|
|
|
|
|
|
TRACE(("gdth_ioctl() cmd 0x%x\n", cmd));
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case GDTIOCTL_CTRCNT:
|
|
|
|
{
|
|
|
|
int cnt = gdth_ctr_count;
|
|
|
|
if (put_user(cnt, (int __user *)argp))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_DRVERS:
|
|
|
|
{
|
|
|
|
int ver = (GDTH_VERSION<<8) | GDTH_SUBVERSION;
|
|
|
|
if (put_user(ver, (int __user *)argp))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_OSVERS:
|
|
|
|
{
|
|
|
|
gdth_ioctl_osvers osv;
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
osv.version = (u8)(LINUX_VERSION_CODE >> 16);
|
|
|
|
osv.subversion = (u8)(LINUX_VERSION_CODE >> 8);
|
|
|
|
osv.revision = (u16)(LINUX_VERSION_CODE & 0xff);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (copy_to_user(argp, &osv, sizeof(gdth_ioctl_osvers)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_CTRTYPE:
|
|
|
|
{
|
|
|
|
gdth_ioctl_ctrtype ctrt;
|
|
|
|
|
|
|
|
if (copy_from_user(&ctrt, argp, sizeof(gdth_ioctl_ctrtype)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
(NULL == (ha = gdth_find_ha(ctrt.ionode))))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
2007-10-03 05:11:24 +08:00
|
|
|
|
2018-12-12 15:41:21 +08:00
|
|
|
if (ha->type != GDT_PCIMPR) {
|
|
|
|
ctrt.type = (u8)((ha->stype<<4) + 6);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2018-12-12 15:41:21 +08:00
|
|
|
ctrt.type = (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe);
|
|
|
|
if (ha->stype >= 0x300)
|
|
|
|
ctrt.ext_type = 0x6000 | ha->pdev->subsystem_device;
|
|
|
|
else
|
|
|
|
ctrt.ext_type = 0x6000 | ha->stype;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2018-12-12 15:41:21 +08:00
|
|
|
ctrt.device_id = ha->pdev->device;
|
|
|
|
ctrt.sub_device_id = ha->pdev->subsystem_device;
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrt.info = ha->brd_phys;
|
|
|
|
ctrt.oem_id = ha->oem_id;
|
|
|
|
if (copy_to_user(argp, &ctrt, sizeof(gdth_ioctl_ctrtype)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_GENERAL:
|
|
|
|
return ioc_general(argp, cmnd);
|
|
|
|
|
|
|
|
case GDTIOCTL_EVENT:
|
|
|
|
return ioc_event(argp);
|
|
|
|
|
|
|
|
case GDTIOCTL_LOCKDRV:
|
|
|
|
return ioc_lockdrv(argp);
|
|
|
|
|
|
|
|
case GDTIOCTL_LOCKCHN:
|
|
|
|
{
|
|
|
|
gdth_ioctl_lockchn lchn;
|
2010-01-04 23:19:34 +08:00
|
|
|
u8 i, j;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_from_user(&lchn, argp, sizeof(gdth_ioctl_lockchn)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
(NULL == (ha = gdth_find_ha(lchn.ionode))))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
2007-10-03 05:11:24 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
i = lchn.channel;
|
|
|
|
if (i < ha->bus_cnt) {
|
|
|
|
if (lchn.lock) {
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
ha->raw[i].lock = 1;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2008-09-14 20:55:09 +08:00
|
|
|
for (j = 0; j < ha->tid_cnt; ++j)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_wait_completion(ha, i, j);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
spin_lock_irqsave(&ha->smp_lock, flags);
|
|
|
|
ha->raw[i].lock = 0;
|
|
|
|
spin_unlock_irqrestore(&ha->smp_lock, flags);
|
2008-09-14 20:55:09 +08:00
|
|
|
for (j = 0; j < ha->tid_cnt; ++j)
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_next(ha);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_RESCAN:
|
|
|
|
return ioc_rescan(argp, cmnd);
|
|
|
|
|
|
|
|
case GDTIOCTL_HDRLIST:
|
|
|
|
return ioc_hdrlist(argp, cmnd);
|
|
|
|
|
|
|
|
case GDTIOCTL_RESET_BUS:
|
|
|
|
{
|
|
|
|
gdth_ioctl_reset res;
|
2007-10-03 05:05:53 +08:00
|
|
|
int rval;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (copy_from_user(&res, argp, sizeof(gdth_ioctl_reset)) ||
|
2007-10-03 05:11:24 +08:00
|
|
|
(NULL == (ha = gdth_find_ha(res.ionode))))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
|
[SCSI] kmalloc + memset conversion to kzalloc
In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-08-11 16:13:24 +08:00
|
|
|
scp = kzalloc(sizeof(*scp), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!scp)
|
|
|
|
return -ENOMEM;
|
2006-06-10 02:34:29 +08:00
|
|
|
scp->device = ha->sdev;
|
2005-04-17 06:20:36 +08:00
|
|
|
scp->cmd_len = 12;
|
2007-10-03 04:59:53 +08:00
|
|
|
scp->device->channel = res.number;
|
2005-04-17 06:20:36 +08:00
|
|
|
rval = gdth_eh_bus_reset(scp);
|
|
|
|
res.status = (rval == SUCCESS ? S_OK : S_GENERR);
|
2006-06-10 02:34:29 +08:00
|
|
|
kfree(scp);
|
2007-10-03 04:54:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (copy_to_user(argp, &res, sizeof(gdth_ioctl_reset)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GDTIOCTL_RESET_DRV:
|
|
|
|
return ioc_resetdrv(argp, cmnd);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-27 06:24:01 +08:00
|
|
|
static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2010-06-02 20:28:52 +08:00
|
|
|
mutex_lock(&gdth_mutex);
|
2010-04-27 06:24:01 +08:00
|
|
|
ret = gdth_ioctl(file, cmd, arg);
|
2010-06-02 20:28:52 +08:00
|
|
|
mutex_unlock(&gdth_mutex);
|
2010-04-27 06:24:01 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* flush routine */
|
2007-10-03 05:05:53 +08:00
|
|
|
static void gdth_flush(gdth_ha_str *ha)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
gdth_cmd_str gdtcmd;
|
|
|
|
char cmnd[MAX_COMMAND_SIZE];
|
|
|
|
memset(cmnd, 0xff, MAX_COMMAND_SIZE);
|
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_flush() hanum %d\n", ha->hanum));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_HDRIVES; ++i) {
|
|
|
|
if (ha->hdr[i].present) {
|
|
|
|
gdtcmd.BoardNode = LOCALBOARD;
|
|
|
|
gdtcmd.Service = CACHESERVICE;
|
|
|
|
gdtcmd.OpCode = GDT_FLUSH;
|
|
|
|
if (ha->cache_feat & GDT_64BIT) {
|
|
|
|
gdtcmd.u.cache64.DeviceNo = i;
|
|
|
|
gdtcmd.u.cache64.BlockNo = 1;
|
|
|
|
gdtcmd.u.cache64.sg_canz = 0;
|
|
|
|
} else {
|
|
|
|
gdtcmd.u.cache.DeviceNo = i;
|
|
|
|
gdtcmd.u.cache.BlockNo = 1;
|
|
|
|
gdtcmd.u.cache.sg_canz = 0;
|
|
|
|
}
|
2007-10-03 05:05:53 +08:00
|
|
|
TRACE2(("gdth_flush(): flush ha %d drive %d\n", ha->hanum, i));
|
2006-06-10 02:34:29 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_execute(ha->shost, &gdtcmd, cmnd, 30, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-10 02:34:29 +08:00
|
|
|
/* configure lun */
|
|
|
|
static int gdth_slave_configure(struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
sdev->skip_ms_page_3f = 1;
|
|
|
|
sdev->skip_ms_page_8 = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
static struct scsi_host_template gdth_template = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.name = "GDT SCSI Disk Array Controller",
|
|
|
|
.info = gdth_info,
|
|
|
|
.queuecommand = gdth_queuecommand,
|
|
|
|
.eh_bus_reset_handler = gdth_eh_bus_reset,
|
2007-10-03 04:57:58 +08:00
|
|
|
.slave_configure = gdth_slave_configure,
|
2005-04-17 06:20:36 +08:00
|
|
|
.bios_param = gdth_bios_param,
|
2013-03-31 12:52:08 +08:00
|
|
|
.show_info = gdth_show_info,
|
|
|
|
.write_info = gdth_set_info,
|
2008-09-14 20:55:09 +08:00
|
|
|
.eh_timed_out = gdth_timed_out,
|
2007-10-03 04:57:58 +08:00
|
|
|
.proc_name = "gdth",
|
2005-04-17 06:20:36 +08:00
|
|
|
.can_queue = GDTH_MAXCMDS,
|
|
|
|
.this_id = -1,
|
|
|
|
.sg_tablesize = GDTH_MAXSG,
|
|
|
|
.cmd_per_lun = GDTH_MAXC_P_L,
|
|
|
|
.unchecked_isa_dma = 1,
|
2013-10-23 18:25:40 +08:00
|
|
|
.no_write_same = 1,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2012-12-22 05:08:55 +08:00
|
|
|
static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out)
|
2007-10-03 04:51:06 +08:00
|
|
|
{
|
|
|
|
struct Scsi_Host *shp;
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
dma_addr_t scratch_dma_handle = 0;
|
2007-10-03 05:11:24 +08:00
|
|
|
int error, i;
|
2008-02-16 10:35:26 +08:00
|
|
|
struct pci_dev *pdev = pcistr->pdev;
|
2007-10-03 04:51:06 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
*ha_out = NULL;
|
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str));
|
2007-10-03 04:51:06 +08:00
|
|
|
if (!shp)
|
|
|
|
return -ENOMEM;
|
2007-10-03 05:05:53 +08:00
|
|
|
ha = shost_priv(shp);
|
2007-10-03 04:51:06 +08:00
|
|
|
|
|
|
|
error = -ENODEV;
|
2008-02-16 10:35:26 +08:00
|
|
|
if (!gdth_init_pci(pdev, pcistr, ha))
|
2007-10-03 04:51:06 +08:00
|
|
|
goto out_host_put;
|
|
|
|
|
|
|
|
/* controller found and initialized */
|
|
|
|
printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
|
2008-02-16 10:35:26 +08:00
|
|
|
pdev->bus->number,
|
|
|
|
PCI_SLOT(pdev->devfn),
|
2007-10-03 04:51:06 +08:00
|
|
|
ha->irq);
|
|
|
|
|
|
|
|
error = request_irq(ha->irq, gdth_interrupt,
|
2014-03-05 13:09:41 +08:00
|
|
|
IRQF_SHARED, "gdth", ha);
|
2007-10-03 04:51:06 +08:00
|
|
|
if (error) {
|
|
|
|
printk("GDT-PCI: Unable to allocate IRQ\n");
|
|
|
|
goto out_host_put;
|
|
|
|
}
|
|
|
|
|
|
|
|
shp->unchecked_isa_dma = 0;
|
|
|
|
shp->irq = ha->irq;
|
|
|
|
shp->dma_channel = 0xff;
|
|
|
|
|
2007-10-03 05:11:24 +08:00
|
|
|
ha->hanum = gdth_ctr_count++;
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->shost = shp;
|
2007-10-03 04:51:06 +08:00
|
|
|
|
2007-10-03 05:05:53 +08:00
|
|
|
ha->pccb = &ha->cmdext;
|
2007-10-03 04:51:06 +08:00
|
|
|
ha->ccb_phys = 0L;
|
|
|
|
|
|
|
|
error = -ENOMEM;
|
|
|
|
|
2018-12-12 15:41:27 +08:00
|
|
|
ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH,
|
|
|
|
&scratch_dma_handle, GFP_KERNEL);
|
2007-10-03 04:51:06 +08:00
|
|
|
if (!ha->pscratch)
|
|
|
|
goto out_free_irq;
|
|
|
|
ha->scratch_phys = scratch_dma_handle;
|
|
|
|
|
2018-12-12 15:41:27 +08:00
|
|
|
ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
|
|
|
|
&scratch_dma_handle, GFP_KERNEL);
|
2007-10-03 04:51:06 +08:00
|
|
|
if (!ha->pmsg)
|
|
|
|
goto out_free_pscratch;
|
|
|
|
ha->msg_phys = scratch_dma_handle;
|
|
|
|
|
|
|
|
ha->scratch_busy = FALSE;
|
|
|
|
ha->req_first = NULL;
|
2008-02-16 10:35:26 +08:00
|
|
|
ha->tid_cnt = pdev->device >= 0x200 ? MAXID : MAX_HDRIVES;
|
2007-10-03 04:51:06 +08:00
|
|
|
if (max_ids > 0 && max_ids < ha->tid_cnt)
|
|
|
|
ha->tid_cnt = max_ids;
|
|
|
|
for (i = 0; i < GDTH_MAXCMDS; ++i)
|
|
|
|
ha->cmd_tab[i].cmnd = UNUSED_CMND;
|
|
|
|
ha->scan_mode = rescan ? 0x10 : 0;
|
|
|
|
|
|
|
|
error = -ENODEV;
|
2007-10-03 05:05:53 +08:00
|
|
|
if (!gdth_search_drives(ha)) {
|
|
|
|
printk("GDT-PCI %d: Error during device scan\n", ha->hanum);
|
2018-12-12 15:41:26 +08:00
|
|
|
goto out_free_pmsg;
|
2007-10-03 04:51:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr_channel < 0 || hdr_channel > ha->bus_cnt)
|
|
|
|
hdr_channel = ha->bus_cnt;
|
|
|
|
ha->virt_bus = hdr_channel;
|
|
|
|
|
|
|
|
/* 64-bit DMA only supported from FW >= x.43 */
|
|
|
|
if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) ||
|
|
|
|
!ha->dma64_support) {
|
2018-12-12 15:41:27 +08:00
|
|
|
if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
|
2007-10-03 04:51:06 +08:00
|
|
|
printk(KERN_WARNING "GDT-PCI %d: "
|
2007-10-03 05:05:53 +08:00
|
|
|
"Unable to set 32-bit DMA\n", ha->hanum);
|
2018-12-12 15:41:26 +08:00
|
|
|
goto out_free_pmsg;
|
2007-10-03 04:51:06 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
shp->max_cmd_len = 16;
|
2018-12-12 15:41:27 +08:00
|
|
|
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
|
2007-10-03 05:05:53 +08:00
|
|
|
printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum);
|
2018-12-12 15:41:27 +08:00
|
|
|
} else if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
|
2007-10-03 04:51:06 +08:00
|
|
|
printk(KERN_WARNING "GDT-PCI %d: "
|
2007-10-03 05:05:53 +08:00
|
|
|
"Unable to set 64/32-bit DMA\n", ha->hanum);
|
2018-12-12 15:41:26 +08:00
|
|
|
goto out_free_pmsg;
|
2007-10-03 04:51:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shp->max_id = ha->tid_cnt;
|
|
|
|
shp->max_lun = MAXLUN;
|
2007-10-03 04:59:53 +08:00
|
|
|
shp->max_channel = ha->bus_cnt;
|
2007-10-03 04:51:06 +08:00
|
|
|
|
|
|
|
spin_lock_init(&ha->smp_lock);
|
2007-10-03 05:05:53 +08:00
|
|
|
gdth_enable_int(ha);
|
2007-10-03 05:09:56 +08:00
|
|
|
|
2008-02-16 10:35:26 +08:00
|
|
|
error = scsi_add_host(shp, &pdev->dev);
|
2007-10-03 05:09:56 +08:00
|
|
|
if (error)
|
2018-12-12 15:41:26 +08:00
|
|
|
goto out_free_pmsg;
|
2007-10-03 05:09:56 +08:00
|
|
|
list_add_tail(&ha->list, &gdth_instances);
|
2008-02-13 01:35:22 +08:00
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
pci_set_drvdata(ha->pdev, ha);
|
2008-05-05 11:34:49 +08:00
|
|
|
gdth_timer_init();
|
2008-02-16 11:20:09 +08:00
|
|
|
|
2008-02-13 01:35:22 +08:00
|
|
|
scsi_scan_host(shp);
|
|
|
|
|
2008-02-16 11:20:09 +08:00
|
|
|
*ha_out = ha;
|
|
|
|
|
2007-10-03 04:51:06 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_pmsg:
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
|
2007-10-03 04:51:06 +08:00
|
|
|
ha->pmsg, ha->msg_phys);
|
|
|
|
out_free_pscratch:
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH,
|
2007-10-03 04:51:06 +08:00
|
|
|
ha->pscratch, ha->scratch_phys);
|
|
|
|
out_free_irq:
|
|
|
|
free_irq(ha->irq, ha);
|
|
|
|
gdth_ctr_count--;
|
|
|
|
out_host_put:
|
2007-10-03 05:09:56 +08:00
|
|
|
scsi_host_put(shp);
|
2007-10-03 04:51:06 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
static void gdth_remove_one(gdth_ha_str *ha)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shp = ha->shost;
|
|
|
|
|
|
|
|
TRACE2(("gdth_remove_one()\n"));
|
|
|
|
|
|
|
|
scsi_remove_host(shp);
|
|
|
|
|
2008-02-28 07:27:16 +08:00
|
|
|
gdth_flush(ha);
|
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
if (ha->sdev) {
|
|
|
|
scsi_free_host_dev(ha->sdev);
|
|
|
|
ha->sdev = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shp->irq)
|
|
|
|
free_irq(shp->irq,ha);
|
|
|
|
|
|
|
|
if (ha->pscratch)
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH,
|
2007-10-03 05:09:56 +08:00
|
|
|
ha->pscratch, ha->scratch_phys);
|
|
|
|
if (ha->pmsg)
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
|
2007-10-03 05:09:56 +08:00
|
|
|
ha->pmsg, ha->msg_phys);
|
|
|
|
if (ha->ccb_phys)
|
2018-12-12 15:41:27 +08:00
|
|
|
dma_unmap_single(&ha->pdev->dev, ha->ccb_phys,
|
|
|
|
sizeof(gdth_cmd_str), DMA_BIDIRECTIONAL);
|
2007-10-03 05:09:56 +08:00
|
|
|
|
|
|
|
scsi_host_put(shp);
|
|
|
|
}
|
|
|
|
|
2010-01-04 23:19:34 +08:00
|
|
|
static int gdth_halt(struct notifier_block *nb, unsigned long event, void *buf)
|
2008-02-28 07:27:16 +08:00
|
|
|
{
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
|
|
|
TRACE2(("gdth_halt() event %d\n", (int)event));
|
|
|
|
if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF)
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
|
|
|
|
list_for_each_entry(ha, &gdth_instances, list)
|
|
|
|
gdth_flush(ha);
|
|
|
|
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block gdth_notifier = {
|
|
|
|
gdth_halt, NULL, 0
|
|
|
|
};
|
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
static int __init gdth_init(void)
|
|
|
|
{
|
|
|
|
if (disable) {
|
|
|
|
printk("GDT-HA: Controller driver disabled from"
|
|
|
|
" command line !\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",
|
|
|
|
GDTH_VERSION_STR);
|
|
|
|
|
|
|
|
/* initializations */
|
|
|
|
gdth_polling = TRUE;
|
|
|
|
gdth_clear_events();
|
2017-10-12 08:17:42 +08:00
|
|
|
timer_setup(&gdth_timer, gdth_timeout, 0);
|
2007-10-03 05:09:56 +08:00
|
|
|
|
|
|
|
/* scanning for PCI controllers */
|
2008-05-05 11:35:58 +08:00
|
|
|
if (pci_register_driver(&gdth_pci_driver)) {
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
|
|
|
list_for_each_entry(ha, &gdth_instances, list)
|
|
|
|
gdth_remove_one(ha);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2007-10-03 05:09:56 +08:00
|
|
|
|
|
|
|
TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
|
2007-10-16 03:46:16 +08:00
|
|
|
|
2007-10-03 05:09:56 +08:00
|
|
|
major = register_chrdev(0,"gdth", &gdth_fops);
|
|
|
|
register_reboot_notifier(&gdth_notifier);
|
|
|
|
gdth_polling = FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit gdth_exit(void)
|
|
|
|
{
|
|
|
|
gdth_ha_str *ha;
|
|
|
|
|
2008-02-28 07:27:16 +08:00
|
|
|
unregister_chrdev(major, "gdth");
|
|
|
|
unregister_reboot_notifier(&gdth_notifier);
|
2007-10-03 05:09:56 +08:00
|
|
|
|
|
|
|
#ifdef GDTH_STATISTICS
|
2008-02-28 07:27:16 +08:00
|
|
|
del_timer_sync(&gdth_timer);
|
2007-10-03 05:09:56 +08:00
|
|
|
#endif
|
2008-02-28 07:27:16 +08:00
|
|
|
|
2008-05-05 11:35:58 +08:00
|
|
|
pci_unregister_driver(&gdth_pci_driver);
|
2008-02-16 11:20:09 +08:00
|
|
|
|
2008-02-28 07:27:16 +08:00
|
|
|
list_for_each_entry(ha, &gdth_instances, list)
|
|
|
|
gdth_remove_one(ha);
|
2007-10-03 05:09:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(gdth_init);
|
|
|
|
module_exit(gdth_exit);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifndef MODULE
|
|
|
|
__setup("gdth=", option_setup);
|
|
|
|
#endif
|