gdth: bring driver into this century
cover gdth: bring driver into this century
Hi all,
the gdth driver has long seen no updates, and has a very peculiar coding style.
Here's an attempt to (slowly) move it towards the linux coding style, and fixup some oddities within the driver itself.
Adaptec has been defunct for several years now, so I doubt the maintainer address is still working; so I'll leave it out for now. Achim, if you are still around, do speak up :-)
As usual, comments and reviews are welcome.
Hannes Reinecke (4):
gdth: reindent and whitespace cleanup
gdth: do not use struct scsi_cmnd as argument for bus reset
gdth: kill __gdth_execute()
gdth: stop abusing ->request pointer for completion
drivers/scsi/gdth.c | 6520 ++++++++++++++++++++++----------------------- drivers/scsi/gdth.h | 1377 +++++----- drivers/scsi/gdth_ioctl.h | 378 +-- drivers/scsi/gdth_proc.c | 1109 ++++---- drivers/scsi/gdth_proc.h | 8 +- 5 files changed, 4695 insertions(+), 4697 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/4 gdth: reindent and whitespace cleanup
Long overdue. No functional change.
--- drivers/scsi/gdth.c | 6522 +++++++++++++++++++++++---------------------- drivers/scsi/gdth.h | 1376 +++++----- drivers/scsi/gdth_ioctl.h | 378 +-- drivers/scsi/gdth_proc.c | 1109 ++++---- drivers/scsi/gdth_proc.h | 6 +- 5 files changed, 4705 insertions(+), 4686 deletions(-)
drivers/scsi/gdth.c +3272 -3250
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-or-later /************************************************************************ -* Linux driver for * +* Linux driver for * * ICP vortex GmbH: GDT PCI Disk Array Controllers * * Intel Corporation: Storage RAID Controllers * * *
@@ -23,25 +23,25 @@* This includes the PCI SCSI Disk Array Controllers and the * 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 +* +* 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., +* 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: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: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, +* shared_access:Y disable driver reserve/release protocol to +* access a shared resource from several nodes, * appropriate controller firmware required * shared_access:N enable driver reserve/release protocol * force_dma32:Y use only 32 bit DMA mode
@@ -51,13 +51,13 @@* max_ids:127,rescan:N,hdr_channel:0, * shared_access:Y,force_dma32:N". * 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. +* +* 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 +* 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 * max_ids=127 rescan=0 hdr_channel=0 shared_access=0 * force_dma32=0"
@@ -117,9 +117,9 @@ static void gdth_delay(int milliseconds);static void gdth_eval_mapping (u32 size,u32 *cyls,int *heads,int *secs);static irqreturn_t gdth_interrupt (int irq,void *dev_id);static irqreturn_t __gdth_interrupt (gdth_ha_str *ha, -int gdth_from_wait,int * pIndex); +int gdth_from_wait,int * pIndex);static int gdth_sync_event (gdth_ha_str *ha,int service,u8 index, -struct scsi_cmnd *scp); +struct scsi_cmnd *scp);static int gdth_async_event (gdth_ha_str *ha);static void gdth_log_event (gdth_evt_data *dvr,char *buffer);
@@ -128,14 +128,14 @@ static void gdth_next(gdth_ha_str *ha);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);static gdth_evt_str *gdth_store_event (gdth_ha_str *ha,u16 source, -u16 idx,gdth_evt_data *evt); +u16 idx,gdth_evt_data *evt);static int gdth_read_event (gdth_ha_str *ha,int handle,gdth_evt_str *estr); -static void gdth_readapp_event (gdth_ha_str *ha,u8 application, -gdth_evt_str *estr); +static void gdth_readapp_event (gdth_ha_str *ha,u8 application, +gdth_evt_str *estr);static void gdth_clear_events (void );static void gdth_copy_internal_data (gdth_ha_str *ha,struct scsi_cmnd *scp, -char *buffer,u16 count); +char *buffer,u16 count);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);
@@ -146,7 +146,7 @@ static int gdth_get_cmd_index(gdth_ha_str *ha);static void gdth_release_event (gdth_ha_str *ha);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); +u32 p1,u64 p2,u64 p3);static int gdth_search_drives (gdth_ha_str *ha);static int gdth_analyse_hdrive (gdth_ha_str *ha,u16 hdrive);
@@ -155,7 +155,7 @@ static const char *gdth_ctr_name(gdth_ha_str *ha);static int gdth_open (struct inode *inode,struct file *filep);static int gdth_close (struct inode *inode,struct file *filep);static long gdth_unlocked_ioctl (struct file *filep,unsigned int cmd, -unsigned long arg); +unsigned long arg);static void gdth_flush (gdth_ha_str *ha);static int gdth_queuecommand (struct Scsi_Host *h,struct scsi_cmnd *cmd);
@@ -186,48 +186,51 @@ static struct timer_list gdth_timer;#define BUS_L2P (a,b) ((b)>(a)->virt_bus ? (b-1):(b)) -static u8 gdth_polling;/* polling if TRUE */ -static int gdth_ctr_count =0 ;/* controller count */ -static LIST_HEAD (gdth_instances);/* controller list */ -static u8 gdth_write_through = FALSE;/* write through */ -static gdth_evt_str ebuffer[MAX_EVENTS ];/* event buffer */ +static u8 gdth_polling;/* polling if TRUE */ +static int gdth_ctr_count =0 ;/* controller count */ +static LIST_HEAD (gdth_instances);/* controller list */ +static u8 gdth_write_through = FALSE;/* write through */ +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 */ +#define DIN 1/* IN data direction */ +#define DOU 2/* OUT data direction */ +#define DNO DIN/* no data transfer */ +#define DUN DIN/* unknown data direction */ static u8 gdth_direction_tab[0x100 ] = { -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 +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 ; +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 }; +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 */
@@ -256,10 +259,10 @@ MODULE_LICENSE("GPL");/* ioctl interface */ static const struct file_operations gdth_fops = { - .unlocked_ioctl = gdth_unlocked_ioctl, - .open = gdth_open, - .release = gdth_close, - .llseek = noop_llseek, + .unlocked_ioctl = gdth_unlocked_ioctl, + .open = gdth_open, + .release = gdth_close, + .llseek = noop_llseek, };#include "gdth_proc.h"
@@ -306,11 +309,11 @@ static void gdth_put_cmndinfo(struct gdth_cmndinfo *priv)static void gdth_delay (int milliseconds) { -if (milliseconds ==0 ) { -udelay (1 ); - }else { -mdelay (milliseconds); - } +if (milliseconds ==0 ) { +udelay (1 ); + }else { +mdelay (milliseconds); + } }static void gdth_scsi_done (struct scsi_cmnd *scp)
@@ -332,73 +335,75 @@ static void gdth_scsi_done(struct scsi_cmnd *scp)static int __gdth_execute (struct scsi_device *sdev,gdth_cmd_str *gdtcmd,char *cmnd,int timeout,u32 *info) { -gdth_ha_str *ha =shost_priv (sdev->host); -struct scsi_cmnd *scp; -struct gdth_cmndinfo cmndinfo; -DECLARE_COMPLETION_ONSTACK (wait); -int rval; - - scp =kzalloc (sizeof (*scp),GFP_KERNEL ); -if (!scp) -return -ENOMEM ; - - scp->sense_buffer =kzalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL ); -if (!scp->sense_buffer) { +gdth_ha_str *ha =shost_priv (sdev->host); +struct scsi_cmnd *scp; +struct gdth_cmndinfo cmndinfo; +DECLARE_COMPLETION_ONSTACK (wait); +int rval; + + scp =kzalloc (sizeof (*scp),GFP_KERNEL ); +if (!scp) +return -ENOMEM ; + + scp->sense_buffer =kzalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL ); +if (!scp->sense_buffer) { +kfree (scp); +return -ENOMEM ; + } + + scp->device = sdev; +memset (&cmndinfo,0 ,sizeof (cmndinfo)); + +/* use request field to save the ptr. to completion struct. */ + scp->request = (struct request *)&wait; + scp->cmd_len =12 ; + scp->cmnd = cmnd; + cmndinfo.priority =IOCTL_PRI ; + cmndinfo.internal_cmd_str = gdtcmd; + cmndinfo.internal_command =1 ; + +TRACE (("__gdth_execute() cmd 0x%x\n" , scp->cmnd[0 ])); +__gdth_queuecommand (ha, scp, &cmndinfo); + +wait_for_completion (&wait); + + rval = cmndinfo.status; +if (info) + *info = cmndinfo.info; +kfree (scp->sense_buffer);kfree (scp); -return -ENOMEM ; - } - - scp->device = sdev; -memset (&cmndinfo,0 ,sizeof (cmndinfo)); - -/* use request field to save the ptr. to completion struct. */ - scp->request = (struct request *)&wait; - scp->cmd_len =12 ; - scp->cmnd = cmnd; - cmndinfo.priority =IOCTL_PRI ; - cmndinfo.internal_cmd_str = gdtcmd; - cmndinfo.internal_command =1 ; - -TRACE (("__gdth_execute() cmd 0x%x\n" , scp->cmnd[0 ])); -__gdth_queuecommand (ha, scp, &cmndinfo); - -wait_for_completion (&wait); - - rval = cmndinfo.status; -if (info) - *info = cmndinfo.info; -kfree (scp->sense_buffer); -kfree (scp); -return rval; +return rval; }int gdth_execute (struct Scsi_Host *shost,gdth_cmd_str *gdtcmd,char *cmnd, -int timeout,u32 *info) +int timeout,u32 *info) { -struct scsi_device *sdev =scsi_get_host_dev (shost); -int rval =__gdth_execute (sdev, gdtcmd, cmnd, timeout, 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; +scsi_free_host_dev (sdev); +return rval; }static void gdth_eval_mapping (u32 size,u32 *cyls,int *heads,int *secs) { - *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 ; - } - } + *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 ; + } + } }static bool gdth_search_vortex (u16 device)
@@ -457,7 +462,7 @@ static int gdth_pci_init_one(struct pci_dev *pdev,int rc;gdth_pci_str gdth_pcistr;gdth_ha_str *ha =NULL ; - +TRACE (("gdth_search_dev() cnt %d vendor %x device %x\n" , gdth_ctr_count, vendor, device));
@@ -473,25 +478,25 @@ static int gdth_pci_init_one(struct pci_dev *pdev,if (gdth_ctr_count >=MAXHA )return -EBUSY ; -/* GDT PCI controller found, resources are already in pdev */ +/* GDT PCI controller found, resources are already in pdev */ gdth_pcistr.pdev = pdev; - 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 )) -return -ENODEV ; - gdth_pcistr.dpmem =pci_resource_start (pdev,0 ); - }else {/* GDT6110, GDT6120, .. */ -if (!(base0 &IORESOURCE_MEM ) || - !(base2 &IORESOURCE_MEM ) || - !(base1 &IORESOURCE_IO )) -return -ENODEV ; - gdth_pcistr.dpmem =pci_resource_start (pdev,2 ); - gdth_pcistr.io =pci_resource_start (pdev,1 ); - } - TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", + 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 )) +return -ENODEV ; + gdth_pcistr.dpmem =pci_resource_start (pdev,0 ); + }else {/* GDT6110, GDT6120, .. */ +if (!(base0 &IORESOURCE_MEM ) || + !(base2 &IORESOURCE_MEM ) || + !(base1 &IORESOURCE_IO )) +return -ENODEV ; + gdth_pcistr.dpmem =pci_resource_start (pdev,2 ); + gdth_pcistr.io =pci_resource_start (pdev,1 ); + } + TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", gdth_pcistr.pdev->bus->number, PCI_SLOT(gdth_pcistr.pdev->devfn), gdth_pcistr.irq,
@@ -507,1027 +512,1027 @@ static int gdth_pci_init_one(struct pci_dev *pdev,static int gdth_init_pci (struct pci_dev *pdev,gdth_pci_str *pcistr,gdth_ha_str *ha) { - registergdt6_dpram_str __iomem *dp6_ptr; - registergdt6c_dpram_str __iomem *dp6c_ptr; - registergdt6m_dpram_str __iomem *dp6m_ptr; -u32 retries; -u8 prot_ver; -u16 command; -int i, found = FALSE; - -TRACE (("gdth_init_pci()\n" )); - -if (pdev->vendor ==PCI_VENDOR_ID_INTEL ) - ha->oem_id =OEM_ID_INTEL ; -else - ha->oem_id =OEM_ID_ICP ; - ha->brd_phys = (pdev->bus->number <<8 ) | (pdev->devfn &0xf8 ); - ha->stype = (u32 )pdev->device; - ha->irq = pdev->irq; - ha->pdev = pdev; - -if (ha->pdev->device <=PCI_DEVICE_ID_VORTEX_GDT6000B ) {/* GDT6000/B */ -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; -writel (DPMEM_MAGIC , &dp6_ptr->u); -if (readl (&dp6_ptr->u) !=DPMEM_MAGIC ) { -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); - ha->brd =ioremap (i,sizeof (u16)); -if (ha->brd ==NULL ) { -printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); -return 0 ; - } -if (readw (ha->brd) !=0xffff ) { -TRACE2 (("init_pci_old() address 0x%x busy\n" , i)); -continue ; - } -iounmap (ha->brd); -pci_write_config_dword (pdev,PCI_BASE_ADDRESS_0 , i); - 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; -writel (DPMEM_MAGIC , &dp6_ptr->u); -if (readl (&dp6_ptr->u) ==DPMEM_MAGIC ) { -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)); -if (readl (&dp6_ptr->u) !=0 ) { -printk ("GDT-PCI: Initialization error (DPMEM write error)\n" ); -iounmap (ha->brd); -return 0 ; - } - -/* disable board interrupts, deinit services */ -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); - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6_ptr->u.ic.S_Status) !=0xff ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } - prot_ver = (u8 )readl (&dp6_ptr->u.ic.S_Info[0 ]); -writeb (0 , &dp6_ptr->u.ic.S_Status); -writeb (0xff , &dp6_ptr->io.irqdel); -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 */ -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); - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6_ptr->u.ic.S_Status) !=0xfe ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } -writeb (0 , &dp6_ptr->u.ic.S_Status); -writeb (0xff , &dp6_ptr->io.irqdel); - - ha->dma64_support =0 ; - - }else if (ha->pdev->device <=PCI_DEVICE_ID_VORTEX_GDT6555 ) {/* GDT6110, ... */ - 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; -writel (DPMEM_MAGIC , &dp6c_ptr->u); -if (readl (&dp6c_ptr->u) !=DPMEM_MAGIC ) { -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); - ha->brd =ioremap (i,sizeof (u16)); -if (ha->brd ==NULL ) { -printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); -return 0 ; - } -if (readw (ha->brd) !=0xffff ) { -TRACE2 (("init_pci_plx() address 0x%x busy\n" , i)); -continue ; - } -iounmap (ha->brd); -pci_write_config_dword (pdev,PCI_BASE_ADDRESS_2 , i); - 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; -writel (DPMEM_MAGIC , &dp6c_ptr->u); -if (readl (&dp6c_ptr->u) ==DPMEM_MAGIC ) { -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)); -if (readl (&dp6c_ptr->u) !=0 ) { -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)); - -writeb (0x00 , &dp6c_ptr->u.ic.S_Status); -writeb (0x00 , &dp6c_ptr->u.ic.Cmd_Index); - -writel (pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0 ]); -writeb (0xff , &dp6c_ptr->u.ic.S_Cmd_Indx); - -outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); - - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6c_ptr->u.ic.S_Status) !=0xff ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } - prot_ver = (u8 )readl (&dp6c_ptr->u.ic.S_Info[0 ]); -writeb (0 , &dp6c_ptr->u.ic.Status); -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 */ -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); - -outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); - - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6c_ptr->u.ic.S_Status) !=0xfe ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } -writeb (0 , &dp6c_ptr->u.ic.S_Status); - - 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 */ -pci_read_config_word (pdev,PCI_COMMAND , &command); - command |=6 ; -pci_write_config_word (pdev,PCI_COMMAND , command); -gdth_delay (1 ); - - 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 */ -while ( ((int )readb (&dp6m_ptr->i960r.sema0_reg) ) &3 ) -gdth_delay (1 ); - -/* check and reset interface area */ -writel (DPMEM_MAGIC , &dp6m_ptr->u); -if (readl (&dp6m_ptr->u) !=DPMEM_MAGIC ) { -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); - ha->brd =ioremap (i,sizeof (u16)); -if (ha->brd ==NULL ) { -printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); -return 0 ; - } -if (readw (ha->brd) !=0xffff ) { -TRACE2 (("init_pci_mpr() address 0x%x busy\n" , i)); -continue ; - } -iounmap (ha->brd); -pci_write_config_dword (pdev,PCI_BASE_ADDRESS_0 , i); - 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; -writel (DPMEM_MAGIC , &dp6m_ptr->u); -if (readl (&dp6m_ptr->u) ==DPMEM_MAGIC ) { -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 */ -writeb (readb (&dp6m_ptr->i960r.edoor_en_reg) |4 , - &dp6m_ptr->i960r.edoor_en_reg); -writeb (0xff , &dp6m_ptr->i960r.edoor_reg); -writeb (0x00 , &dp6m_ptr->u.ic.S_Status); -writeb (0x00 , &dp6m_ptr->u.ic.Cmd_Index); - -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); - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6m_ptr->u.ic.S_Status) !=0xff ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } - prot_ver = (u8 )readl (&dp6m_ptr->u.ic.S_Info[0 ]); -writeb (0 , &dp6m_ptr->u.ic.S_Status); -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 */ -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); - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6m_ptr->u.ic.S_Status) !=0xfe ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } -writeb (0 , &dp6m_ptr->u.ic.S_Status); - -/* read FW version to detect 64-bit DMA support */ -writeb (0xfd , &dp6m_ptr->u.ic.S_Cmd_Indx); -writeb (1 , &dp6m_ptr->i960r.ldoor_reg); - retries =INIT_RETRIES ; -gdth_delay (20 ); -while (readb (&dp6m_ptr->u.ic.S_Status) !=0xfd ) { -if (--retries ==0 ) { -printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); -iounmap (ha->brd); -return 0 ; - } -gdth_delay (1 ); - } - prot_ver = (u8)(readl (&dp6m_ptr->u.ic.S_Info[0 ]) >>16 ); -writeb (0 , &dp6m_ptr->u.ic.S_Status); -if (prot_ver <0x2b )/* FW < x.43: no 64-bit DMA support */ - ha->dma64_support =0 ; -else - ha->dma64_support =1 ; - } - -return 1 ; + registergdt6_dpram_str __iomem *dp6_ptr; + registergdt6c_dpram_str __iomem *dp6c_ptr; + registergdt6m_dpram_str __iomem *dp6m_ptr; +u32 retries; +u8 prot_ver; +u16 command; +int i, found = FALSE; + +TRACE (("gdth_init_pci()\n" )); + +if (pdev->vendor ==PCI_VENDOR_ID_INTEL ) + ha->oem_id =OEM_ID_INTEL ; +else + ha->oem_id =OEM_ID_ICP ; + ha->brd_phys = (pdev->bus->number <<8 ) | (pdev->devfn &0xf8 ); + ha->stype = (u32 )pdev->device; + ha->irq = pdev->irq; + ha->pdev = pdev; + +if (ha->pdev->device <=PCI_DEVICE_ID_VORTEX_GDT6000B ) {/* GDT6000/B */ +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; +writel (DPMEM_MAGIC , &dp6_ptr->u); +if (readl (&dp6_ptr->u) !=DPMEM_MAGIC ) { +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); + ha->brd =ioremap (i,sizeof (u16)); +if (ha->brd ==NULL ) { +printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); +return 0 ; + } +if (readw (ha->brd) !=0xffff ) { +TRACE2 (("init_pci_old() address 0x%x busy\n" , i)); +continue ; + } +iounmap (ha->brd); +pci_write_config_dword (pdev,PCI_BASE_ADDRESS_0 , i); + 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; +writel (DPMEM_MAGIC , &dp6_ptr->u); +if (readl (&dp6_ptr->u) ==DPMEM_MAGIC ) { +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)); +if (readl (&dp6_ptr->u) !=0 ) { +printk ("GDT-PCI: Initialization error (DPMEM write error)\n" ); +iounmap (ha->brd); +return 0 ; + } + +/* disable board interrupts, deinit services */ +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); + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6_ptr->u.ic.S_Status) !=0xff ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } + prot_ver = (u8 )readl (&dp6_ptr->u.ic.S_Info[0 ]); +writeb (0 , &dp6_ptr->u.ic.S_Status); +writeb (0xff , &dp6_ptr->io.irqdel); +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 */ +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); + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6_ptr->u.ic.S_Status) !=0xfe ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } +writeb (0 , &dp6_ptr->u.ic.S_Status); +writeb (0xff , &dp6_ptr->io.irqdel); + + ha->dma64_support =0 ; + + }else if (ha->pdev->device <=PCI_DEVICE_ID_VORTEX_GDT6555 ) {/* GDT6110, ... */ + 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; +writel (DPMEM_MAGIC , &dp6c_ptr->u); +if (readl (&dp6c_ptr->u) !=DPMEM_MAGIC ) { +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); + ha->brd =ioremap (i,sizeof (u16)); +if (ha->brd ==NULL ) { +printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); +return 0 ; + } +if (readw (ha->brd) !=0xffff ) { +TRACE2 (("init_pci_plx() address 0x%x busy\n" , i)); +continue ; + } +iounmap (ha->brd); +pci_write_config_dword (pdev,PCI_BASE_ADDRESS_2 , i); + 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; +writel (DPMEM_MAGIC , &dp6c_ptr->u); +if (readl (&dp6c_ptr->u) ==DPMEM_MAGIC ) { +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)); +if (readl (&dp6c_ptr->u) !=0 ) { +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)); + +writeb (0x00 , &dp6c_ptr->u.ic.S_Status); +writeb (0x00 , &dp6c_ptr->u.ic.Cmd_Index); + +writel (pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0 ]); +writeb (0xff , &dp6c_ptr->u.ic.S_Cmd_Indx); + +outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); + + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6c_ptr->u.ic.S_Status) !=0xff ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } + prot_ver = (u8 )readl (&dp6c_ptr->u.ic.S_Info[0 ]); +writeb (0 , &dp6c_ptr->u.ic.Status); +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 */ +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); + +outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); + + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6c_ptr->u.ic.S_Status) !=0xfe ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } +writeb (0 , &dp6c_ptr->u.ic.S_Status); + + 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 */ +pci_read_config_word (pdev,PCI_COMMAND , &command); + command |=6 ; +pci_write_config_word (pdev,PCI_COMMAND , command); +gdth_delay (1 ); + + 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 */ +while ( ((int )readb (&dp6m_ptr->i960r.sema0_reg) ) &3 ) +gdth_delay (1 ); + +/* check and reset interface area */ +writel (DPMEM_MAGIC , &dp6m_ptr->u); +if (readl (&dp6m_ptr->u) !=DPMEM_MAGIC ) { +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); + ha->brd =ioremap (i,sizeof (u16)); +if (ha->brd ==NULL ) { +printk ("GDT-PCI: Initialization error (DPMEM remap error)\n" ); +return 0 ; + } +if (readw (ha->brd) !=0xffff ) { +TRACE2 (("init_pci_mpr() address 0x%x busy\n" , i)); +continue ; + } +iounmap (ha->brd); +pci_write_config_dword (pdev,PCI_BASE_ADDRESS_0 , i); + 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; +writel (DPMEM_MAGIC , &dp6m_ptr->u); +if (readl (&dp6m_ptr->u) ==DPMEM_MAGIC ) { +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 */ +writeb (readb (&dp6m_ptr->i960r.edoor_en_reg) |4 , + &dp6m_ptr->i960r.edoor_en_reg); +writeb (0xff , &dp6m_ptr->i960r.edoor_reg); +writeb (0x00 , &dp6m_ptr->u.ic.S_Status); +writeb (0x00 , &dp6m_ptr->u.ic.Cmd_Index); + +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); + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6m_ptr->u.ic.S_Status) !=0xff ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } + prot_ver = (u8 )readl (&dp6m_ptr->u.ic.S_Info[0 ]); +writeb (0 , &dp6m_ptr->u.ic.S_Status); +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 */ +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); + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6m_ptr->u.ic.S_Status) !=0xfe ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } +writeb (0 , &dp6m_ptr->u.ic.S_Status); + +/* read FW version to detect 64-bit DMA support */ +writeb (0xfd , &dp6m_ptr->u.ic.S_Cmd_Indx); +writeb (1 , &dp6m_ptr->i960r.ldoor_reg); + retries =INIT_RETRIES ; +gdth_delay (20 ); +while (readb (&dp6m_ptr->u.ic.S_Status) !=0xfd ) { +if (--retries ==0 ) { +printk ("GDT-PCI: Initialization error (DEINIT failed)\n" ); +iounmap (ha->brd); +return 0 ; + } +gdth_delay (1 ); + } + prot_ver = (u8)(readl (&dp6m_ptr->u.ic.S_Info[0 ]) >>16 ); +writeb (0 , &dp6m_ptr->u.ic.S_Status); +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 */ static void gdth_enable_int (gdth_ha_str *ha) { -unsigned long flags; -gdt6_dpram_str __iomem *dp6_ptr; -gdt6m_dpram_str __iomem *dp6m_ptr; - -TRACE (("gdth_enable_int() hanum %d\n" ,ha->hanum)); -spin_lock_irqsave (&ha->smp_lock, flags); - -if (ha->type ==GDT_PCI ) { - dp6_ptr = ha->brd; -writeb (1 , &dp6_ptr->io.irqdel); -writeb (0 , &dp6_ptr->u.ic.Cmd_Index); -writeb (1 , &dp6_ptr->io.irqen); - }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; -writeb (0xff , &dp6m_ptr->i960r.edoor_reg); -writeb (readb (&dp6m_ptr->i960r.edoor_en_reg) & ~4 , - &dp6m_ptr->i960r.edoor_en_reg); - } -spin_unlock_irqrestore (&ha->smp_lock, flags); +unsigned long flags; +gdt6_dpram_str __iomem *dp6_ptr; +gdt6m_dpram_str __iomem *dp6m_ptr; + +TRACE (("gdth_enable_int() hanum %d\n" ,ha->hanum)); +spin_lock_irqsave (&ha->smp_lock, flags); + +if (ha->type ==GDT_PCI ) { + dp6_ptr = ha->brd; +writeb (1 , &dp6_ptr->io.irqdel); +writeb (0 , &dp6_ptr->u.ic.Cmd_Index); +writeb (1 , &dp6_ptr->io.irqen); + }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; +writeb (0xff , &dp6m_ptr->i960r.edoor_reg); +writeb (readb (&dp6m_ptr->i960r.edoor_en_reg) & ~4 , + &dp6m_ptr->i960r.edoor_en_reg); + } +spin_unlock_irqrestore (&ha->smp_lock, flags); }/* return IStatus if interrupt was from this card else 0 */ static u8 gdth_get_status (gdth_ha_str *ha) { -u8 IStatus =0 ; +u8 IStatus =0 ; -TRACE (("gdth_get_status() irq %d ctr_count %d\n" , ha->irq, gdth_ctr_count)); +TRACE (("gdth_get_status() irq %d ctr_count %d\n" , ha->irq, gdth_ctr_count)); -if (ha->type ==GDT_PCI ) - IStatus = -readb (&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index); -else if (ha->type ==GDT_PCINEW ) - IStatus =inb (PTR2USHORT (&ha->plx->edoor_reg)); -else if (ha->type ==GDT_PCIMPR ) - IStatus = -readb (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg); +if (ha->type ==GDT_PCI ) + IStatus = +readb (&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index); +else if (ha->type ==GDT_PCINEW ) + IStatus =inb (PTR2USHORT (&ha->plx->edoor_reg)); +else if (ha->type ==GDT_PCIMPR ) + IStatus = +readb (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg); -return IStatus; +return IStatus; }static int gdth_test_busy (gdth_ha_str *ha) { - registerint gdtsema0 =0 ; + registerint gdtsema0 =0 ; -TRACE (("gdth_test_busy() hanum %d\n" , ha->hanum)); +TRACE (("gdth_test_busy() hanum %d\n" , ha->hanum)); -if (ha->type ==GDT_PCI ) - gdtsema0 = (int )readb (&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); -else if (ha->type ==GDT_PCINEW ) - gdtsema0 = (int )inb (PTR2USHORT (&ha->plx->sema0_reg)); -else if (ha->type ==GDT_PCIMPR ) - gdtsema0 = - (int )readb (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); +if (ha->type ==GDT_PCI ) + gdtsema0 = (int )readb (&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); +else if (ha->type ==GDT_PCINEW ) + gdtsema0 = (int )inb (PTR2USHORT (&ha->plx->sema0_reg)); +else if (ha->type ==GDT_PCIMPR ) + gdtsema0 = + (int )readb (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); -return (gdtsema0 &1 ); +return (gdtsema0 &1 ); }static int gdth_get_cmd_index (gdth_ha_str *ha) { -int i; - -TRACE (("gdth_get_cmd_index() hanum %d\n" , ha->hanum)); - -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; - ha->pccb->CommandIndex = (u32 )i+2 ; -return (i+2 ); - } - } -return 0 ; +int i; + +TRACE (("gdth_get_cmd_index() hanum %d\n" , ha->hanum)); + +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; + ha->pccb->CommandIndex = (u32 )i+2 ; +return (i+2 ); + } + } +return 0 ; }static void gdth_set_sema0 (gdth_ha_str *ha) { -TRACE (("gdth_set_sema0() hanum %d\n" , ha->hanum)); - -if (ha->type ==GDT_PCI ) { -writeb (1 , &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); - }else if (ha->type ==GDT_PCINEW ) { -outb (1 ,PTR2USHORT (&ha->plx->sema0_reg)); - }else if (ha->type ==GDT_PCIMPR ) { -writeb (1 , &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); - } +TRACE (("gdth_set_sema0() hanum %d\n" , ha->hanum)); + +if (ha->type ==GDT_PCI ) { +writeb (1 , &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); + }else if (ha->type ==GDT_PCINEW ) { +outb (1 ,PTR2USHORT (&ha->plx->sema0_reg)); + }else if (ha->type ==GDT_PCIMPR ) { +writeb (1 , &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); + } }static void gdth_copy_command (gdth_ha_str *ha) { - registergdth_cmd_str *cmd_ptr; - registergdt6m_dpram_str __iomem *dp6m_ptr; - registergdt6c_dpram_str __iomem *dp6c_ptr; -gdt6_dpram_str __iomem *dp6_ptr; -u16 cp_count,dp_offset,cmd_no; - -TRACE (("gdth_copy_command() hanum %d\n" , ha->hanum)); - - 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 */ -if (ha->type ==GDT_PCI ) { - dp6_ptr = ha->brd; -writew (dp_offset +DPMEM_COMMAND_OFFSET , - &dp6_ptr->u.ic.comm_queue[cmd_no].offset); -writew ((u16 )cmd_ptr->Service, - &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; -writew (dp_offset +DPMEM_COMMAND_OFFSET , - &dp6c_ptr->u.ic.comm_queue[cmd_no].offset); -writew ((u16 )cmd_ptr->Service, - &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; -writew (dp_offset +DPMEM_COMMAND_OFFSET , - &dp6m_ptr->u.ic.comm_queue[cmd_no].offset); -writew ((u16 )cmd_ptr->Service, - &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); - } + registergdth_cmd_str *cmd_ptr; + registergdt6m_dpram_str __iomem *dp6m_ptr; + registergdt6c_dpram_str __iomem *dp6c_ptr; +gdt6_dpram_str __iomem *dp6_ptr; +u16 cp_count,dp_offset,cmd_no; + +TRACE (("gdth_copy_command() hanum %d\n" , ha->hanum)); + + 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 */ +if (ha->type ==GDT_PCI ) { + dp6_ptr = ha->brd; +writew (dp_offset +DPMEM_COMMAND_OFFSET , + &dp6_ptr->u.ic.comm_queue[cmd_no].offset); +writew ((u16 )cmd_ptr->Service, + &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; +writew (dp_offset +DPMEM_COMMAND_OFFSET , + &dp6c_ptr->u.ic.comm_queue[cmd_no].offset); +writew ((u16 )cmd_ptr->Service, + &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; +writew (dp_offset +DPMEM_COMMAND_OFFSET , + &dp6m_ptr->u.ic.comm_queue[cmd_no].offset); +writew ((u16 )cmd_ptr->Service, + &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); + } }static void gdth_release_event (gdth_ha_str *ha) { -TRACE (("gdth_release_event() hanum %d\n" , ha->hanum)); +TRACE (("gdth_release_event() hanum %d\n" , ha->hanum));#ifdef GDTH_STATISTICS - { -u32 i,j; -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; -TRACE3 (("GDT: max_index = %d\n" ,(u16 )i)); - } - } + { +u32 i,j; +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; +TRACE3 (("GDT: max_index = %d\n" ,(u16 )i)); + } + }#endif -if (ha->pccb->OpCode ==GDT_INIT ) - ha->pccb->Service |=0x80 ; +if (ha->pccb->OpCode ==GDT_INIT ) + ha->pccb->Service |=0x80 ; -if (ha->type ==GDT_PCI ) { -writeb (0 , &((gdt6_dpram_str __iomem *)ha->brd)->io.event); - }else if (ha->type ==GDT_PCINEW ) { -outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); - }else if (ha->type ==GDT_PCIMPR ) { -writeb (1 , &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg); - } +if (ha->type ==GDT_PCI ) { +writeb (0 , &((gdt6_dpram_str __iomem *)ha->brd)->io.event); + }else if (ha->type ==GDT_PCINEW ) { +outb (1 ,PTR2USHORT (&ha->plx->ldoor_reg)); + }else if (ha->type ==GDT_PCIMPR ) { +writeb (1 , &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg); + } }static int gdth_wait (gdth_ha_str *ha,int index,u32 time) { -int answer_found = FALSE; -int wait_index =0 ; +int answer_found = FALSE; +int wait_index =0 ; -TRACE (("gdth_wait() hanum %d index %d time %d\n" , ha->hanum, index, time)); +TRACE (("gdth_wait() hanum %d index %d time %d\n" , ha->hanum, index, time)); -if (index ==0 ) -return 1 ;/* no wait required */ +if (index ==0 ) +return 1 ;/* no wait required */ -do { -__gdth_interrupt (ha, true, &wait_index); -if (wait_index == index) { - answer_found = TRUE; -break ; - } -gdth_delay (1 ); - }while (--time); +do { +__gdth_interrupt (ha, true, &wait_index); +if (wait_index == index) { + answer_found = TRUE; +break ; + } +gdth_delay (1 ); + }while (--time); -while (gdth_test_busy (ha)) -gdth_delay (0 ); +while (gdth_test_busy (ha)) +gdth_delay (0 ); -return (answer_found); +return (answer_found); }static int gdth_internal_cmd (gdth_ha_str *ha,u8 service,u16 opcode, -u32 p1,u64 p2,u64 p3) +u32 p1,u64 p2,u64 p3) { - registergdth_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 ; -if (!(index=gdth_get_cmd_index (ha))) { -TRACE (("GDT: No free command index found\n" )); -return 0 ; - } -gdth_set_sema0 (ha); - cmd_ptr->OpCode = opcode; - cmd_ptr->BoardNode =LOCALBOARD ; -if (service ==CACHESERVICE ) { -if (opcode ==GDT_IOCTL ) { - cmd_ptr->u.ioctl.subfunc = p1; - cmd_ptr->u.ioctl.channel = (u32 )p2; - cmd_ptr->u.ioctl.param_size = (u16 )p3; - cmd_ptr->u.ioctl.p_param = ha->scratch_phys; - }else { -if (ha->cache_feat &GDT_64BIT ) { - cmd_ptr->u.cache64.DeviceNo = (u16 )p1; - cmd_ptr->u.cache64.BlockNo = p2; - }else { - cmd_ptr->u.cache.DeviceNo = (u16 )p1; - cmd_ptr->u.cache.BlockNo = (u32 )p2; - } - } - }else if (service ==SCSIRAWSERVICE ) { -if (ha->raw_feat &GDT_64BIT ) { - cmd_ptr->u.raw64.direction = p1; - cmd_ptr->u.raw64.bus = (u8 )p2; - cmd_ptr->u.raw64.target = (u8 )p3; - cmd_ptr->u.raw64.lun = (u8)(p3 >>8 ); - }else { - cmd_ptr->u.raw.direction = p1; - cmd_ptr->u.raw.bus = (u8 )p2; - cmd_ptr->u.raw.target = (u8 )p3; - cmd_ptr->u.raw.lun = (u8)(p3 >>8 ); - } - }else if (service ==SCREENSERVICE ) { -if (opcode ==GDT_REALTIME ) { - *(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; - } - } - ha->cmd_len =sizeof (gdth_cmd_str); - ha->cmd_offs_dpmem =0 ; - ha->cmd_cnt =0 ; -gdth_copy_command (ha); -gdth_release_event (ha); -gdth_delay (20 ); -if (!gdth_wait (ha, index,INIT_TIMEOUT )) { -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 ); + registergdth_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 ; +if (!(index=gdth_get_cmd_index (ha))) { +TRACE (("GDT: No free command index found\n" )); +return 0 ; + } +gdth_set_sema0 (ha); + cmd_ptr->OpCode = opcode; + cmd_ptr->BoardNode =LOCALBOARD ; +if (service ==CACHESERVICE ) { +if (opcode ==GDT_IOCTL ) { + cmd_ptr->u.ioctl.subfunc = p1; + cmd_ptr->u.ioctl.channel = (u32 )p2; + cmd_ptr->u.ioctl.param_size = (u16 )p3; + cmd_ptr->u.ioctl.p_param = ha->scratch_phys; + }else { +if (ha->cache_feat &GDT_64BIT ) { + cmd_ptr->u.cache64.DeviceNo = (u16 )p1; + cmd_ptr->u.cache64.BlockNo = p2; + }else { + cmd_ptr->u.cache.DeviceNo = (u16 )p1; + cmd_ptr->u.cache.BlockNo = (u32 )p2; + } + } + }else if (service ==SCSIRAWSERVICE ) { +if (ha->raw_feat &GDT_64BIT ) { + cmd_ptr->u.raw64.direction = p1; + cmd_ptr->u.raw64.bus = (u8 )p2; + cmd_ptr->u.raw64.target = (u8 )p3; + cmd_ptr->u.raw64.lun = (u8)(p3 >>8 ); + }else { + cmd_ptr->u.raw.direction = p1; + cmd_ptr->u.raw.bus = (u8 )p2; + cmd_ptr->u.raw.target = (u8 )p3; + cmd_ptr->u.raw.lun = (u8)(p3 >>8 ); + } + }else if (service ==SCREENSERVICE ) { +if (opcode ==GDT_REALTIME ) { + *(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; + } + } + ha->cmd_len =sizeof (gdth_cmd_str); + ha->cmd_offs_dpmem =0 ; + ha->cmd_cnt =0 ; +gdth_copy_command (ha); +gdth_release_event (ha); +gdth_delay (20 ); +if (!gdth_wait (ha, index,INIT_TIMEOUT )) { +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 */ static int gdth_search_drives (gdth_ha_str *ha) { -u16 cdev_cnt, i; -int ok; -u32 bus_no, drv_cnt, drv_no, j; -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; - -TRACE (("gdth_search_drives() hanum %d\n" , ha->hanum)); - ok =0 ; - -/* initialize controller services, at first: screen service */ - ha->screen_feat =0 ; -if (!force_dma32) { - ok =gdth_internal_cmd (ha,SCREENSERVICE ,GDT_X_INIT_SCR ,0 ,0 ,0 ); -if (ok) - ha->screen_feat =GDT_64BIT ; - } -if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) - ok =gdth_internal_cmd (ha,SCREENSERVICE ,GDT_INIT ,0 ,0 ,0 ); -if (!ok) { -printk ("GDT-HA %d: Initialization error screen service (code %d)\n" , - ha->hanum, ha->status); -return 0 ; - } -TRACE2 (("gdth_search_drives(): SCREENSERVICE initialized\n" )); - -/* unfreeze all IOs */ -gdth_internal_cmd (ha,CACHESERVICE ,GDT_UNFREEZE_IO ,0 ,0 ,0 ); - -/* initialize cache service */ - ha->cache_feat =0 ; -if (!force_dma32) { - ok =gdth_internal_cmd (ha,CACHESERVICE ,GDT_X_INIT_HOST ,LINUX_OS , -0 ,0 ); -if (ok) - ha->cache_feat =GDT_64BIT ; - } -if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) - ok =gdth_internal_cmd (ha,CACHESERVICE ,GDT_INIT ,LINUX_OS ,0 ,0 ); -if (!ok) { -printk ("GDT-HA %d: Initialization error cache service (code %d)\n" , - ha->hanum, ha->status); -return 0 ; - } -TRACE2 (("gdth_search_drives(): CACHESERVICE initialized\n" )); - cdev_cnt = (u16 )ha->info; - 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 ]); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,IOCHAN_RAW_DESC , -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; -if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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" , - ha->hanum, ha->status); -return 0 ; - } -break ; - } -if (chn->siop_id <MAXID ) - ha->bus_id[bus_no] = chn->siop_id; -else - ha->bus_id[bus_no] =0xff ; - } - ha->bus_cnt = (u8 )bus_no; - } -TRACE2 (("gdth_search_drives() %d channels\n" ,ha->bus_cnt)); - -/* read cache configuration */ -if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_INFO , -INVALID_CHANNEL ,sizeof (gdth_cinfo_str))) { -printk ("GDT-HA %d: Initialization error cache service (code %d)\n" , - ha->hanum, ha->status); -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; -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,BOARD_INFO , -INVALID_CHANNEL ,sizeof (gdth_binfo_str))) { -memcpy (&ha->binfo, (gdth_binfo_str *)ha->pscratch, -sizeof (gdth_binfo_str)); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,BOARD_FEATURES , -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" )); -strcpy (ha->binfo.type_string,gdth_ctr_name (ha)); - } -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 ]); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,IOCHAN_DESC , -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; -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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; -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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 */ -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_DRV_CNT , -INVALID_CHANNEL ,sizeof (u32))) { - drv_cnt = *(u32 *)ha->pscratch; -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_DRV_LIST , -INVALID_CHANNEL ,drv_cnt *sizeof (u32))) { -for (j =0 ; j < drv_cnt; ++j) { - drv_no = ((u32 *)ha->pscratch)[j]; -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 ]); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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; - } - }else if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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) { - ok =gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_X_INIT_RAW ,0 ,0 ,0 ); -if (ok) - ha->raw_feat =GDT_64BIT ; - } -if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) - ok =gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_INIT ,0 ,0 ,0 ); -if (!ok) { -printk ("GDT-HA %d: Initialization error raw service (code %d)\n" , - ha->hanum, ha->status); -return 0 ; - } -TRACE2 (("gdth_search_drives(): RAWSERVICE initialized\n" )); - -/* set/get features raw service (scatter/gather) */ -if (gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_SET_FEAT ,SCATTER_GATHER , -0 ,0 )) { -TRACE2 (("gdth_search_drives(): set features RAWSERVICE OK\n" )); -if (gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_GET_FEAT ,0 ,0 ,0 )) { -TRACE2 (("gdth_search_dr(): get feat RAWSERVICE %d\n" , - ha->info)); - ha->raw_feat |= (u16 )ha->info; - } - } - -/* set/get features cache service (equal to raw service) */ -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_SET_FEAT ,0 , -SCATTER_GATHER ,0 )) { -TRACE2 (("gdth_search_drives(): set features CACHESERVICE OK\n" )); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_GET_FEAT ,0 ,0 ,0 )) { -TRACE2 (("gdth_search_dr(): get feat CACHESERV. %d\n" , - ha->info)); - ha->cache_feat |= (u16 )ha->info; - } - } - -/* reserve drives for raw service */ -if (reserve_mode !=0 ) { -gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_RESERVE_ALL , - 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 ) { -if (reserve_list[i] == ha->hanum && reserve_list[i+1 ] < ha->bus_cnt && - 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 ])); -if (!gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_RESERVE ,0 , - reserve_list[i+1 ], reserve_list[i+2 ] | - (reserve_list[i+3 ] <<8 ))) { -printk ("GDT-HA %d: Error raw service (RESERVE, code %d)\n" , - ha->hanum, ha->status); - } - } - } - -/* Determine OEM string using IOCTL */ - oemstr = (gdth_oem_str_ioctl *)ha->pscratch; - oemstr->params.ctl_version =0x01 ; - oemstr->params.buffer_size =sizeof (oemstr->text); -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , -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" , - ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string); -/* 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" , - ha->hanum, ha->binfo.type_string); -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) -gdth_analyse_hdrive (ha, i); - -TRACE (("gdth_search_drives() OK\n" )); -return 1 ; +u16 cdev_cnt, i; +int ok; +u32 bus_no, drv_cnt, drv_no, j; +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; + +TRACE (("gdth_search_drives() hanum %d\n" , ha->hanum)); + ok =0 ; + +/* initialize controller services, at first: screen service */ + ha->screen_feat =0 ; +if (!force_dma32) { + ok =gdth_internal_cmd (ha,SCREENSERVICE ,GDT_X_INIT_SCR ,0 ,0 ,0 ); +if (ok) + ha->screen_feat =GDT_64BIT ; + } +if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) + ok =gdth_internal_cmd (ha,SCREENSERVICE ,GDT_INIT ,0 ,0 ,0 ); +if (!ok) { +printk ("GDT-HA %d: Initialization error screen service (code %d)\n" , + ha->hanum, ha->status); +return 0 ; + } +TRACE2 (("gdth_search_drives(): SCREENSERVICE initialized\n" )); + +/* unfreeze all IOs */ +gdth_internal_cmd (ha,CACHESERVICE ,GDT_UNFREEZE_IO ,0 ,0 ,0 ); + +/* initialize cache service */ + ha->cache_feat =0 ; +if (!force_dma32) { + ok =gdth_internal_cmd (ha,CACHESERVICE ,GDT_X_INIT_HOST ,LINUX_OS , +0 ,0 ); +if (ok) + ha->cache_feat =GDT_64BIT ; + } +if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) + ok =gdth_internal_cmd (ha,CACHESERVICE ,GDT_INIT ,LINUX_OS ,0 ,0 ); +if (!ok) { +printk ("GDT-HA %d: Initialization error cache service (code %d)\n" , + ha->hanum, ha->status); +return 0 ; + } +TRACE2 (("gdth_search_drives(): CACHESERVICE initialized\n" )); + cdev_cnt = (u16 )ha->info; + 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 ]); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,IOCHAN_RAW_DESC , +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; +if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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" , + ha->hanum, ha->status); +return 0 ; + } +break ; + } +if (chn->siop_id <MAXID ) + ha->bus_id[bus_no] = chn->siop_id; +else + ha->bus_id[bus_no] =0xff ; + } + ha->bus_cnt = (u8 )bus_no; + } +TRACE2 (("gdth_search_drives() %d channels\n" ,ha->bus_cnt)); + +/* read cache configuration */ +if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_INFO , +INVALID_CHANNEL ,sizeof (gdth_cinfo_str))) { +printk ("GDT-HA %d: Initialization error cache service (code %d)\n" , + ha->hanum, ha->status); +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; +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,BOARD_INFO , +INVALID_CHANNEL ,sizeof (gdth_binfo_str))) { +memcpy (&ha->binfo, (gdth_binfo_str *)ha->pscratch, +sizeof (gdth_binfo_str)); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,BOARD_FEATURES , +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" )); +strcpy (ha->binfo.type_string,gdth_ctr_name (ha)); + } +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 ]); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,IOCHAN_DESC , +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; +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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; +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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 */ +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_DRV_CNT , +INVALID_CHANNEL ,sizeof (u32))) { + drv_cnt = *(u32 *)ha->pscratch; +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL ,CACHE_DRV_LIST , +INVALID_CHANNEL ,drv_cnt *sizeof (u32))) { +for (j =0 ; j < drv_cnt; ++j) { + drv_no = ((u32 *)ha->pscratch)[j]; +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 ]); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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; + } + }else if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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) { + ok =gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_X_INIT_RAW ,0 ,0 ,0 ); +if (ok) + ha->raw_feat =GDT_64BIT ; + } +if (force_dma32 || (!ok && ha->status == (u16 )S_NOFUNC )) + ok =gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_INIT ,0 ,0 ,0 ); +if (!ok) { +printk ("GDT-HA %d: Initialization error raw service (code %d)\n" , + ha->hanum, ha->status); +return 0 ; + } +TRACE2 (("gdth_search_drives(): RAWSERVICE initialized\n" )); + +/* set/get features raw service (scatter/gather) */ +if (gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_SET_FEAT ,SCATTER_GATHER , +0 ,0 )) { +TRACE2 (("gdth_search_drives(): set features RAWSERVICE OK\n" )); +if (gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_GET_FEAT ,0 ,0 ,0 )) { +TRACE2 (("gdth_search_dr(): get feat RAWSERVICE %d\n" , + ha->info)); + ha->raw_feat |= (u16 )ha->info; + } + } + +/* set/get features cache service (equal to raw service) */ +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_SET_FEAT ,0 , +SCATTER_GATHER ,0 )) { +TRACE2 (("gdth_search_drives(): set features CACHESERVICE OK\n" )); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_GET_FEAT ,0 ,0 ,0 )) { +TRACE2 (("gdth_search_dr(): get feat CACHESERV. %d\n" , + ha->info)); + ha->cache_feat |= (u16 )ha->info; + } + } + +/* reserve drives for raw service */ +if (reserve_mode !=0 ) { +gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_RESERVE_ALL , + 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 ) { +if (reserve_list[i] == ha->hanum && reserve_list[i+1 ] < ha->bus_cnt && + 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 ])); +if (!gdth_internal_cmd (ha,SCSIRAWSERVICE ,GDT_RESERVE ,0 , + reserve_list[i+1 ], reserve_list[i+2 ] | + (reserve_list[i+3 ] <<8 ))) { +printk ("GDT-HA %d: Error raw service (RESERVE, code %d)\n" , + ha->hanum, ha->status); + } + } + } + +/* Determine OEM string using IOCTL */ + oemstr = (gdth_oem_str_ioctl *)ha->pscratch; + oemstr->params.ctl_version =0x01 ; + oemstr->params.buffer_size =sizeof (oemstr->text); +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_IOCTL , +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" , + ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string); +/* 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" , + ha->hanum, ha->binfo.type_string); +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) +gdth_analyse_hdrive (ha, i); + +TRACE (("gdth_search_drives() OK\n" )); +return 1 ; }static int gdth_analyse_hdrive (gdth_ha_str *ha,u16 hdrive) { -u32 drv_cyls; -int drv_hds, drv_secs; - -TRACE (("gdth_analyse_hdrive() hanum %d drive %d\n" , ha->hanum, hdrive)); -if (hdrive >=MAX_HDRIVES ) -return 0 ; - -if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_INFO , hdrive,0 ,0 )) -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 ; - drv_cyls = (u32 )ha->hdr[hdrive].size / drv_hds / drv_secs; - } - ha->hdr[hdrive].heads = (u8 )drv_hds; - ha->hdr[hdrive].secs = (u8 )drv_secs; -/* round size */ - ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs; - -if (ha->cache_feat &GDT_64BIT ) { -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_X_INFO , hdrive,0 ,0 ) - && ha->info2 !=0 ) { - ha->hdr[hdrive].size = ((u64 )ha->info2 <<32 ) | ha->info; - } - } -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 */ -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_DEVTYPE , hdrive,0 ,0 )) { -TRACE2 (("gdth_search_dr() cache drive %d devtype %d\n" , - hdrive,ha->info)); - ha->hdr[hdrive].devtype = (u16 )ha->info; - } - -/* cluster info */ -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_CLUST_INFO , hdrive,0 ,0 )) { -TRACE2 (("gdth_search_dr() cache drive %d cluster info %d\n" , - hdrive,ha->info)); -if (!shared_access) - ha->hdr[hdrive].cluster_type = (u8 )ha->info; - } - -/* R/W attributes */ -if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_RW_ATTRIBS , hdrive,0 ,0 )) { -TRACE2 (("gdth_search_dr() cache drive %d r/w attrib. %d\n" , - hdrive,ha->info)); - ha->hdr[hdrive].rw_attribs = (u8 )ha->info; - } - -return 1 ; +u32 drv_cyls; +int drv_hds, drv_secs; + +TRACE (("gdth_analyse_hdrive() hanum %d drive %d\n" , ha->hanum, hdrive)); +if (hdrive >=MAX_HDRIVES ) +return 0 ; + +if (!gdth_internal_cmd (ha,CACHESERVICE ,GDT_INFO , hdrive,0 ,0 )) +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 ; + drv_cyls = (u32 )ha->hdr[hdrive].size / drv_hds / drv_secs; + } + ha->hdr[hdrive].heads = (u8 )drv_hds; + ha->hdr[hdrive].secs = (u8 )drv_secs; +/* round size */ + ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs; + +if (ha->cache_feat &GDT_64BIT ) { +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_X_INFO , hdrive,0 ,0 ) + && ha->info2 !=0 ) { + ha->hdr[hdrive].size = ((u64 )ha->info2 <<32 ) | ha->info; + } + } +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 */ +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_DEVTYPE , hdrive,0 ,0 )) { +TRACE2 (("gdth_search_dr() cache drive %d devtype %d\n" , + hdrive,ha->info)); + ha->hdr[hdrive].devtype = (u16 )ha->info; + } + +/* cluster info */ +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_CLUST_INFO , hdrive,0 ,0 )) { +TRACE2 (("gdth_search_dr() cache drive %d cluster info %d\n" , + hdrive,ha->info)); +if (!shared_access) + ha->hdr[hdrive].cluster_type = (u8 )ha->info; + } + +/* R/W attributes */ +if (gdth_internal_cmd (ha,CACHESERVICE ,GDT_RW_ATTRIBS , hdrive,0 ,0 )) { +TRACE2 (("gdth_search_dr() cache drive %d r/w attrib. %d\n" , + hdrive,ha->info)); + ha->hdr[hdrive].rw_attribs = (u8 )ha->info; + } + +return 1 ; }
@@ -1535,291 +1540,300 @@ static int gdth_analyse_hdrive(gdth_ha_str *ha, u16 hdrive)static void gdth_putq (gdth_ha_str *ha,struct scsi_cmnd *scp,u8 priority) { -struct gdth_cmndinfo *cmndinfo =gdth_cmnd_priv (scp); - registerstruct scsi_cmnd *pscp; - registerstruct scsi_cmnd *nscp; -unsigned long flags; - -TRACE (("gdth_putq() priority %d\n" ,priority)); -spin_lock_irqsave (&ha->smp_lock, flags); - -if (!cmndinfo->internal_command) - cmndinfo->priority = priority; - -if (ha->req_first==NULL ) { - ha->req_first = scp;/* queue was empty */ - scp->SCp.ptr =NULL ; - }else {/* queue not empty */ - pscp = ha->req_first; - nscp = (struct scsi_cmnd *)pscp->SCp.ptr; -/* priority: 0-highest,..,0xff-lowest */ -while (nscp &&gdth_cmnd_priv (nscp)->priority <= priority) { - pscp = nscp; - nscp = (struct scsi_cmnd *)pscp->SCp.ptr; - } - pscp->SCp.ptr = (char *)scp; - scp->SCp.ptr = (char *)nscp; - } -spin_unlock_irqrestore (&ha->smp_lock, flags); +struct gdth_cmndinfo *cmndinfo =gdth_cmnd_priv (scp); + registerstruct scsi_cmnd *pscp; + registerstruct scsi_cmnd *nscp; +unsigned long flags; + +TRACE (("gdth_putq() priority %d\n" ,priority)); +spin_lock_irqsave (&ha->smp_lock, flags); + +if (!cmndinfo->internal_command) + cmndinfo->priority = priority; + +if (ha->req_first==NULL ) { +/* queue was empty */ + ha->req_first = scp; + scp->SCp.ptr =NULL ; + }else { +/* queue not empty */ + pscp = ha->req_first; + nscp = (struct scsi_cmnd *)pscp->SCp.ptr; +/* priority: 0-highest,..,0xff-lowest */ +while (nscp &&gdth_cmnd_priv (nscp)->priority <= priority) { + pscp = nscp; + nscp = (struct scsi_cmnd *)pscp->SCp.ptr; + } + pscp->SCp.ptr = (char *)scp; + scp->SCp.ptr = (char *)nscp; + } +spin_unlock_irqrestore (&ha->smp_lock, flags);#ifdef GDTH_STATISTICS - flags =0 ; -for (nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd *)nscp->SCp.ptr) - ++flags; -if (max_rq < flags) { - max_rq = flags; -TRACE3 (("GDT: max_rq = %d\n" ,(u16 )max_rq)); - } + flags =0 ; +for (nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd *)nscp->SCp.ptr) + ++flags; +if (max_rq < flags) { + max_rq = flags; +TRACE3 (("GDT: max_rq = %d\n" ,(u16 )max_rq)); + }#endif }static void gdth_next (gdth_ha_str *ha) { - registerstruct scsi_cmnd *pscp; - registerstruct scsi_cmnd *nscp; -u8 b, t, l, firsttime; -u8 this_cmd, next_cmd; -unsigned long flags =0 ; -int cmd_index; - -TRACE (("gdth_next() hanum %d\n" , ha->hanum)); -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 ; - -for (nscp = pscp = ha->req_first; nscp; nscp = (struct scsi_cmnd *)nscp->SCp.ptr) { -struct gdth_cmndinfo *nscp_cmndinfo =gdth_cmnd_priv (nscp); -if (nscp != pscp && nscp != (struct scsi_cmnd *)pscp->SCp.ptr) - pscp = (struct scsi_cmnd *)pscp->SCp.ptr; -if (!nscp_cmndinfo->internal_command) { - b = nscp->device->channel; - t = nscp->device->id; - l = nscp->device->lun; -if (nscp_cmndinfo->priority >=DEFAULT_PRI ) { -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 ; - -if (firsttime) { -if (gdth_test_busy (ha)) {/* controller busy ? */ -TRACE (("gdth_next() controller %d busy !\n" , ha->hanum)); -if (!gdth_polling) { -spin_unlock_irqrestore (&ha->smp_lock, flags); -return ; - } -while (gdth_test_busy (ha)) -gdth_delay (1 ); - } - firsttime = FALSE; - } - -if (!nscp_cmndinfo->internal_command) { -if (nscp_cmndinfo->phase ==-1 ) { - nscp_cmndinfo->phase =CACHESERVICE ;/* default: cache svc. */ -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 ))) { - nscp_cmndinfo->OpCode =GDT_SCAN_START ; - nscp_cmndinfo->phase = ((ha->scan_mode &0x10 ?1 :0 ) <<8 ) - |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 ) { - nscp_cmndinfo->phase =SCSIRAWSERVICE ; - nscp_cmndinfo->OpCode =GDT_SCAN_END ; - 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! */ - nscp_cmndinfo->OpCode =GDT_CLUST_INFO ; - } - } - } - -if (nscp_cmndinfo->OpCode !=-1 ) { -if ((nscp_cmndinfo->phase &0xff ) ==CACHESERVICE ) { -if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) - this_cmd = FALSE; - next_cmd = FALSE; - }else if ((nscp_cmndinfo->phase &0xff ) ==SCSIRAWSERVICE ) { -if (!(cmd_index=gdth_fill_raw_cmd (ha, nscp,BUS_L2P (ha, b)))) - 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 ); -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); - } - }else if (gdth_cmnd_priv (nscp)->internal_command) { -if (!(cmd_index=gdth_special_cmd (ha, nscp))) - 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 || - !(cmd_index=gdth_fill_raw_cmd (ha, nscp,BUS_L2P (ha, b)))) - 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 ; -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); - }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 : -case SERVICE_ACTION_IN_16 : -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 ); -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); - }else if (gdth_internal_cache_cmd (ha, nscp)) -gdth_scsi_done (nscp); -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 ; -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); - }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 ])); -if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) - this_cmd = FALSE; - } -break ; - -case RESERVE : -case RELEASE : -TRACE2 (("cache cmd %s\n" ,nscp->cmnd[0 ] ==RESERVE ? -"RESERVE" :"RELEASE" )); -if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) - 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 ); -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); - }else if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) - 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" , - ha->hanum, nscp->cmnd[0 ]); - nscp->result =DID_ABORT <<16 ; -if (!nscp_cmndinfo->wait_for_completion) - nscp_cmndinfo->wait_for_completion++; -else -gdth_scsi_done (nscp); -break ; - } - } - -if (!this_cmd) -break ; -if (nscp == ha->req_first) - ha->req_first = pscp = (struct scsi_cmnd *)nscp->SCp.ptr; -else - pscp->SCp.ptr = nscp->SCp.ptr; -if (!next_cmd) -break ; - } - -if (ha->cmd_cnt >0 ) { -gdth_release_event (ha); - } - -if (!gdth_polling) -spin_unlock_irqrestore (&ha->smp_lock, flags); - -if (gdth_polling && ha->cmd_cnt >0 ) { -if (!gdth_wait (ha, cmd_index,POLL_TIMEOUT )) -printk ("GDT-HA %d: Command %d timed out !\n" , - ha->hanum, cmd_index); - } + registerstruct scsi_cmnd *pscp; + registerstruct scsi_cmnd *nscp; +u8 b, t, l, firsttime; +u8 this_cmd, next_cmd; +unsigned long flags =0 ; +int cmd_index; + +TRACE (("gdth_next() hanum %d\n" , ha->hanum)); +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 ; + +for (nscp = pscp = ha->req_first; nscp; + nscp = (struct scsi_cmnd *)nscp->SCp.ptr) { +struct gdth_cmndinfo *nscp_cmndinfo =gdth_cmnd_priv (nscp); +if (nscp != pscp && nscp != (struct scsi_cmnd *)pscp->SCp.ptr) + pscp = (struct scsi_cmnd *)pscp->SCp.ptr; +if (!nscp_cmndinfo->internal_command) { + b = nscp->device->channel; + t = nscp->device->id; + l = nscp->device->lun; +if (nscp_cmndinfo->priority >=DEFAULT_PRI ) { +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 ; + +if (firsttime) { +/* controller busy ? */ +if (gdth_test_busy (ha)) { +TRACE (("gdth_next() controller %d busy !\n" , + ha->hanum)); +if (!gdth_polling) { +spin_unlock_irqrestore (&ha->smp_lock, + flags); +return ; + } +while (gdth_test_busy (ha)) +gdth_delay (1 ); + } + firsttime = FALSE; + } + +if (!nscp_cmndinfo->internal_command) { +if (nscp_cmndinfo->phase ==-1 ) { +/* default: cache svc. */ + nscp_cmndinfo->phase =CACHESERVICE ; +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 ))) { + nscp_cmndinfo->OpCode =GDT_SCAN_START ; + nscp_cmndinfo->phase = ((ha->scan_mode &0x10 ?1 :0 ) <<8 ) + |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 ) { + nscp_cmndinfo->phase =SCSIRAWSERVICE ; + nscp_cmndinfo->OpCode =GDT_SCAN_END ; + 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! */ + nscp_cmndinfo->OpCode =GDT_CLUST_INFO ; + } + } + } + +if (nscp_cmndinfo->OpCode !=-1 ) { +if ((nscp_cmndinfo->phase &0xff ) ==CACHESERVICE ) { +if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) + this_cmd = FALSE; + next_cmd = FALSE; + }else if ((nscp_cmndinfo->phase &0xff ) ==SCSIRAWSERVICE ) { +if (!(cmd_index=gdth_fill_raw_cmd (ha, nscp,BUS_L2P (ha, b)))) + 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 ); +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); + } + }else if (gdth_cmnd_priv (nscp)->internal_command) { +if (!(cmd_index=gdth_special_cmd (ha, nscp))) + 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 || + !(cmd_index=gdth_fill_raw_cmd (ha, nscp,BUS_L2P (ha, b)))) + 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 ; +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); + }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 : +case SERVICE_ACTION_IN_16 : +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 ); +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); + }else if (gdth_internal_cache_cmd (ha, nscp)) +gdth_scsi_done (nscp); +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 ; +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); + }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 ])); +if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) + this_cmd = FALSE; + } +break ; + +case RESERVE : +case RELEASE : +TRACE2 (("cache cmd %s\n" ,nscp->cmnd[0 ] ==RESERVE ? +"RESERVE" :"RELEASE" )); +if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) + 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 ); +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); + }else if (!(cmd_index=gdth_fill_cache_cmd (ha, nscp, t))) + 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" , + ha->hanum, nscp->cmnd[0 ]); + nscp->result =DID_ABORT <<16 ; +if (!nscp_cmndinfo->wait_for_completion) + nscp_cmndinfo->wait_for_completion++; +else +gdth_scsi_done (nscp); +break ; + } + } + +if (!this_cmd) +break ; +if (nscp == ha->req_first) + ha->req_first = pscp = (struct scsi_cmnd *)nscp->SCp.ptr; +else + pscp->SCp.ptr = nscp->SCp.ptr; +if (!next_cmd) +break ; + } + +if (ha->cmd_cnt >0 ) { +gdth_release_event (ha); + } + +if (!gdth_polling) +spin_unlock_irqrestore (&ha->smp_lock, flags); + +if (gdth_polling && ha->cmd_cnt >0 ) { +if (!gdth_wait (ha, cmd_index,POLL_TIMEOUT )) +printk ("GDT-HA %d: Command %d timed out !\n" , + ha->hanum, cmd_index); + } }/*
@@ -1827,809 +1841,811 @@ static void gdth_next(gdth_ha_str *ha)* buffers, kmap_atomic() as needed. */ static void gdth_copy_internal_data (gdth_ha_str *ha,struct scsi_cmnd *scp, -char *buffer,u16 count) +char *buffer,u16 count) { -u16 cpcount,i, max_sg =scsi_sg_count (scp); -u16 cpsum,cpnow; -struct scatterlist *sl; -char *address; - - cpcount =min_t (u16, count,scsi_bufflen (scp)); - -if (cpcount) { - cpsum=0 ; -scsi_for_each_sg (scp, sl, max_sg, i) { -unsigned long flags; - cpnow = (u16 )sl->length; -TRACE (("copy_internal() now %d sum %d count %d %d\n" , - cpnow, cpsum, cpcount,scsi_bufflen (scp))); -if (cpsum+cpnow > cpcount) - cpnow = cpcount - cpsum; - cpsum += cpnow; -if (!sg_page (sl)) { -printk ("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n" , - ha->hanum); -return ; - } -local_irq_save (flags); - address =kmap_atomic (sg_page (sl)) + sl->offset; -memcpy (address, buffer, cpnow); -flush_dcache_page (sg_page (sl)); -kunmap_atomic (address); -local_irq_restore (flags); -if (cpsum == cpcount) -break ; - buffer += cpnow; - } - }else if (count) { -printk ("GDT-HA %d: SCSI command with no buffers but data transfer expected!\n" , - ha->hanum); -WARN_ON (1 ); - } +u16 cpcount,i, max_sg =scsi_sg_count (scp); +u16 cpsum,cpnow; +struct scatterlist *sl; +char *address;
Lines of this file are not shown. View the raw message.
drivers/scsi/gdth.h +688 -688
1,376 lines not on this page · raw message
drivers/scsi/gdth_ioctl.h +189 -189
378 lines not on this page · raw message
drivers/scsi/gdth_proc.c +553 -556
1,109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.16.4
Part of the diff is not shown here. View the raw message.
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 1 line · Hannes Reinecke
Long overdue. No functional change.
Did you test if compiler generates the same output? I don't think anyone wants to review this patch :)
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 6 lines · Daniel Wagner
Quoted 1 line · Hannes Reinecke
Long overdue. No functional change.
Did you test if compiler generates the same output? I don't think anyone wants to review this patch :)
Hmm. No. Lemme check what happens...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 9 lines · Hannes Reinecke
Quoted 6 lines · Daniel Wagner
Quoted 1 line · Hannes Reinecke
Long overdue. No functional change.
Did you test if compiler generates the same output? I don't think anyone wants to review this patch :)
Hmm. No. Lemme check what happens...
Phew. Just checked, and the disassembly is indeed identical.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 11 lines · Hannes Reinecke
Quoted 9 lines · Hannes Reinecke
Quoted 6 lines · Daniel Wagner
Quoted 1 line · Hannes Reinecke
Long overdue. No functional change.
Did you test if compiler generates the same output? I don't think anyone wants to review this patch :)
Hmm. No. Lemme check what happens...
Phew. Just checked, and the disassembly is indeed identical.
I am not really convienced it is a good idea to reformat the whole driver at this point. Sure, checkpatch.pl & friends will be more happy with new changes. Though, in 10 years there were only 44 changes and I don't think there will be a lot more in the coming years. Just my thoughts.
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 11 lines · Daniel Wagner
Quoted 10 lines · Hannes Reinecke
Quoted 9 lines · Hannes Reinecke
Quoted 6 lines · Daniel Wagner
Quoted 1 line · Hannes Reinecke
Long overdue. No functional change.
Did you test if compiler generates the same output? I don't think anyone wants to review this patch :)
Hmm. No. Lemme check what happens...
Quoted 8 lines
Quoted 1 line
Phew. Just checked, and the disassembly is indeed identical.
I am not really convienced it is a good idea to reformat the whole driver at this point. Sure, checkpatch.pl & friends will be more happy with new changes. Though, in 10 years there were only 44 changes and I don't think there will be a lot more in the coming years. Just my thoughts.
Says you.
6fa4468afcf73a3f53a70f0e76a63d0a03b641fc gdth: kill 'cmnd' argument from gdth_execute() 652d47aa4b4fcc9422d99727671af178323f231f gdth: merge gdth_proc.c into gdth.c aee96950cc505670d4befe9fb2f1faa0dfe179fb gdth: split off gdth_init_pci() 89d259c342c690d4110b04f3f21aa853f2e69ab7 gdth: convert TRACE macros to dynamic debug 70526df12feaa74c6fd487561fd52ac93e89e025 gdth: drop statistics during I/O submission 0e0c7414780dbfd86f19967f35481e3e99456551 gdth: replace blank printk() statements with dev_xxx variants db9e448aae664f4b702849d40fa7de563563f68e gdth: stop abusing ->request pointer for completion ac60bebd3a1d13a523e019440798f206e9cd83ce gdth: kill __gdth_execute() 4dded2800578c60e1c2b4dd6ee08b14bc9ef1181 gdth: do not use struct scsi_cmnd as argument for bus reset 6c599cfd05580969e13bdada8c54c0a643aa56f5 gdth: reindent and whitespace cleanup
As mentioned, the gdth driver is the only one using the scsi_host_dev feature, which I'll be improving/updating with my reserved tags for SCSI patchset.
And to avoid my eyes falling out everytime I need to look at the driver
I would very much prefer to have the reindent done.
Especially as it can be easily verified.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Do you actually have a gdth card? Do we know of other users? Maybe just dropping the driver might be a better option..
Re: [PATCH 1/4] gdth: reindent and whitespace cleanup
Quoted 3 lines · Christoph Hellwig
Do you actually have a gdth card? Do we know of other users? Maybe just dropping the driver might be a better option..
Yes, no, and possibly :-)
The gdth hardware is based on the i960 chip, and has borrowed quite some concepts for the now-defunct I2O design. Plus it's PCI and SCSI parallel only, so it took me quite some time to find a machine where I could fit both in.
So I do agree that this could be classified as obsolete, much like we did with the I2O subsystem some years back. Would actually save me quite some time, as the driver itself is really just too ugly to behold in its current state. And bringing it into this century would amount to basically a rewrite.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH 2/4 gdth: do not use struct scsi_cmnd as argument for bus reset
In reply to Hannes ReineckeBus reset just needs the number of the bus to reset as argument, so introduce a function gdth_bus_reset() and avoid allocating a temporary scsi command when bus reset is triggered via ioctl.
--- drivers/scsi/gdth.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/scsi/gdth.c +7 -14
@@ -3323,18 +3323,14 @@ static enum blk_eh_timer_return gdth_timed_out(struct scsi_cmnd *scp) } -static int gdth_eh_bus_reset (struct scsi_cmnd *scp) +static int gdth_bus_reset (gdth_ha_str *ha,u8 b) { -gdth_ha_str *ha =shost_priv (scp->device->host);int i;unsigned long flags;struct scsi_cmnd *cmnd; -u8 b;TRACE2 (("gdth_eh_bus_reset()\n" )); - b = scp->device->channel; -/* clear command tab */ spin_lock_irqsave (&ha->smp_lock, flags);for (i =0 ; i <GDTH_MAXCMDS ; ++i) {
@@ -3375,6 +3371,11 @@ static int gdth_eh_bus_reset(struct scsi_cmnd *scp)return SUCCESS ; } +static int gdth_eh_bus_reset (struct scsi_cmnd *scp) +{ +return gdth_bus_reset (shost_priv (scp->device->host), scp->device->channel); +} +static int gdth_bios_param (struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip) {
@@ -3897,7 +3898,6 @@ static int ioc_rescan(void __user *arg, char *cmnd)static int gdth_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) {gdth_ha_str *ha; -struct scsi_cmnd *scp;unsigned long flags;char cmnd[MAX_COMMAND_SIZE ];void __user *argp = (void __user *)arg;
@@ -4013,15 +4013,8 @@ static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) (NULL == (ha = gdth_find_ha(res.ionode))))return -EFAULT ; - scp =kzalloc (sizeof (*scp),GFP_KERNEL ); -if (!scp) -return -ENOMEM ; - scp->device = ha->sdev; - scp->cmd_len =12 ; - scp->device->channel = res.number; - rval =gdth_eh_bus_reset (scp); + rval =gdth_bus_reset (ha, res.number); res.status = (rval ==SUCCESS ?S_OK :S_GENERR ); -kfree (scp);if (copy_to_user (argp, &res,sizeof (gdth_ioctl_reset)))return -EFAULT ;
Signature · 1 line
2.16.4
Re: [PATCH 2/4] gdth: do not use struct scsi_cmnd as argument for bus reset
Quoted 5 lines · Hannes Reinecke
Bus reset just needs the number of the bus to reset as argument, so introduce a function
gdth_bus_reset()and avoid allocating a temporary scsi command when bus reset is triggered via ioctl.Signed-off-by Hannes Reinecke <[email protected]>
PATCH 3/4 gdth: kill __gdth_execute()
In reply to Hannes Reineckegdth_execute() is just a wrapper around __gdth_execute(), which tries to allocate the host device, too.
But the host device is required for other code paths, too, so we should allocate it during pci init, kill the original gdth_execute() and rename __gdth_execute() to gdth_execute().
--- drivers/scsi/gdth.c | 52 ++++++++++++++++++------------------------------ drivers/scsi/gdth_proc.c | 16 +++++++-------- drivers/scsi/gdth_proc.h | 2 +- 3 files changed, 28 insertions(+), 42 deletions(-)
drivers/scsi/gdth.c +19 -33
@@ -332,10 +332,9 @@ static void gdth_scsi_done(struct scsi_cmnd *scp) scp->scsi_done (scp); } -static int __gdth_execute (struct scsi_device *sdev,gdth_cmd_str *gdtcmd, -char *cmnd,int timeout,u32 *info) +int gdth_execute (gdth_ha_str *ha,gdth_cmd_str *gdtcmd,char *cmnd, +int timeout,u32 *info) { -gdth_ha_str *ha =shost_priv (sdev->host);struct scsi_cmnd *scp;struct gdth_cmndinfo cmndinfo;DECLARE_COMPLETION_ONSTACK (wait);
@@ -351,7 +350,7 @@ static int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd,return -ENOMEM ; } - scp->device = sdev; + scp->device = ha->sdev;memset (&cmndinfo,0 ,sizeof (cmndinfo));/* use request field to save the ptr. to completion struct. */
@@ -375,16 +374,6 @@ static int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd,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; -} -static void gdth_eval_mapping (u32 size,u32 *cyls,int *heads,int *secs) { *cyls = size /HEADS /SECS ;
@@ -3446,15 +3435,6 @@ static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,static int gdth_open (struct inode *inode,struct file *filep) { -gdth_ha_str *ha; - -mutex_lock (&gdth_mutex); -list_for_each_entry (ha, &gdth_instances, list) { -if (!ha->sdev) - ha->sdev =scsi_get_host_dev (ha->shost); - } -mutex_unlock (&gdth_mutex); -TRACE (("gdth_open()\n" ));return 0 ; }
@@ -3558,7 +3538,7 @@ static int ioc_resetdrv(void __user *arg, char *cmnd)else cmd.u.cache.DeviceNo = res.number; - rval =__gdth_execute (ha->sdev, &cmd, cmnd,30 ,NULL ); + rval =gdth_execute (ha, &cmd, cmnd,30 ,NULL );if (rval <0 )return rval; res.status = rval;
@@ -3690,8 +3670,8 @@ static int ioc_general(void __user *arg, char *cmnd) goto out_free_buf; } - rval =__gdth_execute (ha->sdev, &gen.command, cmnd, gen.timeout, - &gen.info); + rval =gdth_execute (ha, &gen.command, cmnd, gen.timeout, + &gen.info);if (rval <0 ) goto out_free_buf; gen.status = rval;
@@ -3749,7 +3729,8 @@ static int ioc_hdrlist(void __user *arg, char *cmnd) cmd->u.cache64.DeviceNo = i; else cmd->u.cache.DeviceNo = i; -if (__gdth_execute (ha->sdev, cmd, cmnd,30 , &cluster_type) ==S_OK ) +if (gdth_execute (ha, cmd, cmnd,30 , + &cluster_type) ==S_OK ) rsc->hdr_list[i].cluster_type = cluster_type; } }
@@ -3799,7 +3780,7 @@ static int ioc_rescan(void __user *arg, char *cmnd) cmd->u.cache.DeviceNo =LINUX_OS ; } - status =__gdth_execute (ha->sdev, cmd, cmnd,30 , &info); + status =gdth_execute (ha, cmd, cmnd,30 , &info); i =0 ; hdr_cnt = (status ==S_OK ? (u16 )info :0 ); }else {
@@ -3815,7 +3796,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)else cmd->u.cache.DeviceNo = i; - status =__gdth_execute (ha->sdev, cmd, cmnd,30 , &info); + status =gdth_execute (ha, cmd, cmnd,30 , &info);spin_lock_irqsave (&ha->smp_lock, flags); rsc->hdr_list[i].bus = ha->virt_bus;
@@ -3849,7 +3830,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)else cmd->u.cache.DeviceNo = i; - status =__gdth_execute (ha->sdev, cmd, cmnd,30 , &info); + status =gdth_execute (ha, cmd, cmnd,30 , &info);spin_lock_irqsave (&ha->smp_lock, flags); ha->hdr[i].devtype = (status ==S_OK ? (u16 )info :0 );
@@ -3862,7 +3843,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)else cmd->u.cache.DeviceNo = i; - status =__gdth_execute (ha->sdev, cmd, cmnd,30 , &info); + status =gdth_execute (ha, cmd, cmnd,30 , &info);spin_lock_irqsave (&ha->smp_lock, flags); ha->hdr[i].cluster_type =
@@ -3877,7 +3858,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)else cmd->u.cache.DeviceNo = i; - status =__gdth_execute (ha->sdev, cmd, cmnd,30 , &info); + status =gdth_execute (ha, cmd, cmnd,30 , &info);spin_lock_irqsave (&ha->smp_lock, flags); ha->hdr[i].rw_attribs = (status ==S_OK ? (u16 )info :0 );
@@ -4070,7 +4051,7 @@ static void gdth_flush(gdth_ha_str *ha)TRACE2 (("gdth_flush(): flush ha %d drive %d\n" , ha->hanum, i)); -gdth_execute (ha->shost, &gdtcmd, cmnd,30 ,NULL ); +gdth_execute (ha, &gdtcmd, cmnd,30 ,NULL ); } } }
@@ -4208,6 +4189,9 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out) goto out_free_pmsg;list_add_tail (&ha->list, &gdth_instances); + ha->sdev =scsi_get_host_dev (shp); +if (!ha->sdev) + goto out_unlink;pci_set_drvdata (ha->pdev, ha);gdth_timer_init ();
@@ -4217,6 +4201,8 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out)return 0 ; + out_unlink: +list_del_init (&ha->list); out_free_pmsg:dma_free_coherent (&ha->pdev->dev,sizeof (gdth_msg_str), ha->pmsg, ha->msg_phys);
drivers/scsi/gdth_proc.c +8 -8
@@ -71,7 +71,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, gdtcmd.u.cache.BlockNo =1 ; } -gdth_execute (host, &gdtcmd, cmnd,30 ,NULL ); +gdth_execute (ha, &gdtcmd, cmnd,30 ,NULL ); } }if (!found)
@@ -134,7 +134,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, gdtcmd.u.ioctl.channel =INVALID_CHANNEL ; pcpar->write_back = wb_mode==1 ?0 :1 ; -gdth_execute (host, &gdtcmd, cmnd,30 ,NULL ); +gdth_execute (ha, &gdtcmd, cmnd,30 ,NULL );spin_lock_irqsave (&ha->smp_lock, flags); ha->scratch_busy = FALSE;
@@ -254,7 +254,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)if (pds->entries > cnt) pds->entries = cnt; -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) !=S_OK ) +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) !=S_OK ) pds->count =0 ;/* other IOCTLs must fit into area GDTH_SCRATCH/4 */
@@ -271,7 +271,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) gdtcmd->u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) { +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) {strncpy (hrec,pdi->vendor,8 );strncpy (hrec+8 ,pdi->product,16 );strncpy (hrec+24 ,pdi->revision,4 );
@@ -318,7 +318,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) ha->raw[i].address | ha->raw[i].id_list[j]; pdef->sddc_type =0x08 ; -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) { +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) {seq_printf (m," Grown Defects:\t%d\n" , pdef->sddc_cnt);
@@ -350,7 +350,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) gdtcmd->u.ioctl.param_size =sizeof (gdth_cdrinfo_str); gdtcmd->u.ioctl.subfunc =CACHE_DRV_INFO ; gdtcmd->u.ioctl.channel = drv_no; -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) !=S_OK ) +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) !=S_OK )break ; pcdi->ld_dtype >>=16 ; j++;
@@ -427,7 +427,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) gdtcmd->u.ioctl.param_size =sizeof (gdth_arrayinf_str); gdtcmd->u.ioctl.subfunc =ARRAY_INFO |LA_CTRL_PATTERN ; gdtcmd->u.ioctl.channel = i; -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) { +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) {if (pai->ai_state ==0 )strcpy (hrec,"idle" );else if (pai->ai_state ==2 )
@@ -486,7 +486,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) gdtcmd->u.ioctl.channel = i; phg->entries =MAX_HDRIVES ; phg->offset =GDTOFFSOF (gdth_hget_str, entry[0 ]); -if (gdth_execute (host, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) { +if (gdth_execute (ha, gdtcmd, cmnd,30 ,NULL ) ==S_OK ) { ha->hdr[i].ldr_no = i; ha->hdr[i].rw_attribs =0 ; ha->hdr[i].start_sec =0 ;
drivers/scsi/gdth_proc.h +1 -1
@@ -6,7 +6,7 @@* $Id: gdth_proc.h,v 1.16 2004/01/14 13:09:01 achim Exp $ */ -int gdth_execute (struct Scsi_Host *shost,gdth_cmd_str *gdtcmd,char *cmnd, +int gdth_execute (gdth_ha_str *ha,gdth_cmd_str *gdtcmd,char *cmnd,int timeout,u32 *info); static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
Signature · 1 line
2.16.4
Re: [PATCH 3/4] gdth: kill __gdth_execute()
Quoted 7 lines · Hannes Reinecke
gdth_execute()is just a wrapper around__gdth_execute(), which tries to allocate the host device, too.
But the host device is required for other code paths, too, so we should allocate it during pci init, kill the originalgdth_execute()and rename__gdth_execute()togdth_execute().Signed-off-by Hannes Reinecke <[email protected]>
PATCH 4/4 gdth: stop abusing ->request pointer for completion
In reply to Hannes ReineckeDo not overload the request point for completion but rather use a dedicated field in the cmndinfo structure.
--- drivers/scsi/gdth.c | 5 ++--- drivers/scsi/gdth.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/gdth.c +2 -3
@@ -327,7 +327,7 @@ static void gdth_scsi_done(struct scsi_cmnd *scp) scp->host_scribble =NULL ;if (internal_command) -complete ((struct completion *)scp->request); +complete (cmndinfo->complete);else scp->scsi_done (scp); }
@@ -353,13 +353,12 @@ int gdth_execute(gdth_ha_str *ha, gdth_cmd_str *gdtcmd, char *cmnd, scp->device = ha->sdev;memset (&cmndinfo,0 ,sizeof (cmndinfo)); -/* use request field to save the ptr. to completion struct. */ - scp->request = (struct request *)&wait; scp->cmd_len =12 ; scp->cmnd = cmnd; cmndinfo.priority =IOCTL_PRI ; cmndinfo.internal_cmd_str = gdtcmd; cmndinfo.internal_command =1 ; + cmndinfo.complete = &wait;TRACE (("__gdth_execute() cmd 0x%x\n" , scp->cmnd[0 ]));__gdth_queuecommand (ha, scp, &cmndinfo);
drivers/scsi/gdth.h +1 -0
@@ -877,6 +877,7 @@ typedef struct {u8 priority;int timeout_count;/* # of timeout calls */ volatile int wait_for_completion; +struct completion *complete;u16 status;u32 info;enum dma_data_direction dma_dir;
Signature · 1 line
2.16.4
Re: [PATCH 4/4] gdth: stop abusing ->request pointer for completion
Quoted 4 lines · Hannes Reinecke
Do not overload the request point for completion but rather use a dedicated field in the cmndinfo structure.
Signed-off-by Hannes Reinecke <[email protected]>