Re: [PATCH 1/4] gdth: Split out EISA and ISA register code

2007-07-21 Thread Christoph Hellwig
On Fri, Jul 20, 2007 at 10:20:32PM -0400, Jeff Garzik wrote:
 
 No code changes, only indentation and blank line additions, plus code to
 call the new split-out functions.

I have patches that do this and do a few things better (e.g. proper CONFIG_ISA
ifdefs instead of the ia64 hacks).  I'll send it out in a minute.

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] gdth: Isolate driver-global variables using helpers

2007-07-21 Thread Christoph Hellwig
On Fri, Jul 20, 2007 at 10:23:03PM -0400, Jeff Garzik wrote:
 [SCSI] gdth: Isolate driver-global variables using helpers
 
 Sanitizes access to some driver-global variables, in preparation for
 making them dynamic rather than statically-sized.
 
 This equivalent-transform style change blissfully ignores the fact that
 gdth_ctr_vtab[] is never used (only assigned), and that the driver
 itself seems to get a bit confused between gdth_ctr_count and
 gdth_ctr_vcount.  The whole virtual-controller stuff needs reviewing
 for edge cases.

NACK.  This crap should mostly go away entirely and not beeing isolated.
I have patches for that somewhere deep down in my patchqueue.  I can't
surprise to have them forward ported today, but I'll try.

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][13/37] Clean up duplicate includes in drivers/scsi/

2007-07-21 Thread Jesper Juhl
Hi,

This patch cleans up duplicate includes in
drivers/scsi/


Signed-off-by: Jesper Juhl [EMAIL PROTECTED]
---

diff --git a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
index 3a80897..e0f1991 100644
--- a/drivers/scsi/NCR_D700.c
+++ b/drivers/scsi/NCR_D700.c
@@ -97,7 +97,6 @@
 #include linux/kernel.h
 #include linux/module.h
 #include linux/mca.h
-#include linux/interrupt.h
 #include asm/io.h
 #include scsi/scsi_host.h
 #include scsi/scsi_device.h
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 673cfe1..039892c 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -43,7 +43,6 @@
 #include lpfc_crtn.h
 #include lpfc_vport.h
 #include lpfc_version.h
-#include lpfc_vport.h
 #include lpfc_debugfs.h
 
 #ifdef CONFIG_LPFC_DEBUG_FS
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 07bd0dc..3a51266 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -43,7 +43,6 @@
 #include lpfc_crtn.h
 #include lpfc_vport.h
 #include lpfc_version.h
-#include lpfc_vport.h
 
 static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int);
 static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] gdth: split out eisa probing

2007-07-21 Thread Christoph Hellwig
Split eisa probing into it's own helper, and do proper error unwinding.
Protect EISA probind by the proper CONFIG_EISA symbol.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/scsi/gdth.c
===
--- linux-2.6.orig/drivers/scsi/gdth.c  2007-07-21 12:16:55.0 +0200
+++ linux-2.6/drivers/scsi/gdth.c   2007-07-21 12:17:57.0 +0200
@@ -479,6 +479,9 @@ static void gdth_scsi_done(struct scsi_c
 #ifdef CONFIG_ISA
 static int gdth_isa_probe_one(struct scsi_host_template *, ulong32);
 #endif
+#ifdef CONFIG_EISA
+static int gdth_eisa_probe_one(struct scsi_host_template *, ushort);
+#endif
 
 #ifdef DEBUG_GDTH
 static unchar   DebugState = DEBUG_GDTH;
@@ -4335,129 +4338,14 @@ static int __init gdth_detect(Scsi_Host_
gdth_isa_probe_one(shtp, isa_bios);
}
 #endif
-
-for (eisa_slot=0x1000; eisa_slot=0x8000; eisa_slot+=0x1000) {
-dma_addr_t scratch_dma_handle;
-scratch_dma_handle = 0;
-
-if (gdth_ctr_count = MAXHA) 
-break;
-if (gdth_search_eisa(eisa_slot)) {  /* controller found */
-shp = scsi_register(shtp,sizeof(gdth_ext_str));
-if (shp == NULL)
-continue;  
-
-ha = HADATA(shp);
-if (!gdth_init_eisa(eisa_slot,ha)) {
-scsi_unregister(shp);
-continue;
-}
-/* controller found and initialized */
-printk(Configuring GDT-EISA HA at Slot %d IRQ %u\n,
-   eisa_slot12,ha-irq);
-
-if 
(request_irq(ha-irq,gdth_interrupt,IRQF_DISABLED,gdth,ha)) {
-printk(GDT-EISA: Unable to allocate IRQ\n);
-scsi_unregister(shp);
-continue;
-}
-shp-unchecked_isa_dma = 0;
-shp-irq = ha-irq;
-shp-dma_channel = 0xff;
-hanum = gdth_ctr_count;
-gdth_ctr_tab[gdth_ctr_count++] = shp;
-gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-
-NUMDATA(shp)-hanum = (ushort)hanum;
-NUMDATA(shp)-busnum= 0;
-TRACE2((EISA detect Bus 0: hanum %d\n,
-NUMDATA(shp)-hanum));
-
-ha-pccb = CMDDATA(shp);
-ha-ccb_phys = 0L; 
-
-ha-pdev = NULL;
-ha-pscratch = pci_alloc_consistent(ha-pdev, GDTH_SCRATCH, 
-scratch_dma_handle);
-ha-scratch_phys = scratch_dma_handle;
-ha-pmsg = pci_alloc_consistent(ha-pdev, 
sizeof(gdth_msg_str), 
-scratch_dma_handle);
-ha-msg_phys = scratch_dma_handle;
-#ifdef INT_COAL
-ha-coal_stat = (gdth_coal_status *)
-pci_alloc_consistent(ha-pdev, sizeof(gdth_coal_status) *
- MAXOFFSETS, scratch_dma_handle);
-ha-coal_stat_phys = scratch_dma_handle;
-#endif
-ha-ccb_phys = 
-pci_map_single(ha-pdev,ha-pccb,
-   sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
-ha-scratch_busy = FALSE;
-ha-req_first = NULL;
-ha-tid_cnt = MAX_HDRIVES;
-if (max_ids  0  max_ids  ha-tid_cnt)
-ha-tid_cnt = max_ids;
-for (i=0; iGDTH_MAXCMDS; ++i)
-ha-cmd_tab[i].cmnd = UNUSED_CMND;
-ha-scan_mode = rescan ? 0x10 : 0;
-
-if (ha-pscratch == NULL || ha-pmsg == NULL || 
-!gdth_search_drives(hanum)) {
-printk(GDT-EISA: Error during device scan\n);
---gdth_ctr_count;
---gdth_ctr_vcount;
-#ifdef INT_COAL
-if (ha-coal_stat)
-pci_free_consistent(ha-pdev, sizeof(gdth_coal_status) 
*
-MAXOFFSETS, ha-coal_stat,
-ha-coal_stat_phys);
-#endif
-if (ha-pscratch)
-pci_free_consistent(ha-pdev, GDTH_SCRATCH, 
-ha-pscratch, ha-scratch_phys);
-if (ha-pmsg)
-pci_free_consistent(ha-pdev, sizeof(gdth_msg_str), 
-ha-pmsg, ha-msg_phys);
-if (ha-ccb_phys)
-pci_unmap_single(ha-pdev,ha-ccb_phys,
-
sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
-free_irq(ha-irq,ha);
-scsi_unregister(shp);
-continue;
-}
-if 

[PATCH 3/7] gdth: split out pci probing

2007-07-21 Thread Christoph Hellwig
Split out per-device pci probing and put it under proper CONFIG_PCI.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/scsi/gdth.c
===
--- linux-2.6.orig/drivers/scsi/gdth.c  2007-07-21 12:17:57.0 +0200
+++ linux-2.6/drivers/scsi/gdth.c   2007-07-21 12:19:13.0 +0200
@@ -482,6 +482,9 @@ static int gdth_isa_probe_one(struct scs
 #ifdef CONFIG_EISA
 static int gdth_eisa_probe_one(struct scsi_host_template *, ushort);
 #endif
+#ifdef CONFIG_PCI
+static int gdth_pci_probe_one(struct scsi_host_template *, gdth_pci_str *, 
int);
+#endif
 
 #ifdef DEBUG_GDTH
 static unchar   DebugState = DEBUG_GDTH;
@@ -4290,12 +4293,10 @@ static int __init gdth_detect(struct scs
 static int __init gdth_detect(Scsi_Host_Template *shtp)
 #endif
 {
-struct Scsi_Host *shp;
 gdth_pci_str pcistr[MAXHA];
-gdth_ha_str *ha;
 ulong32 isa_bios;
 ushort eisa_slot;
-int i,hanum,cnt,ctr,err;
+int cnt,ctr;
 unchar b;
 
  
@@ -4347,143 +4348,17 @@ static int __init gdth_detect(Scsi_Host_
 }
 #endif
 
+#ifdef CONFIG_PCI
 /* scanning for PCI controllers */
 cnt = gdth_search_pci(pcistr);
 printk(GDT-HA: Found %d PCI Storage RAID Controllers\n,cnt);
 gdth_sort_pci(pcistr,cnt);
 for (ctr = 0; ctr  cnt; ++ctr) {
-dma_addr_t scratch_dma_handle;
-scratch_dma_handle = 0;
-
-if (gdth_ctr_count = MAXHA)
-break;
-shp = scsi_register(shtp,sizeof(gdth_ext_str));
-if (shp == NULL)
-continue;  
-
-ha = HADATA(shp);
-if (!gdth_init_pci(pcistr[ctr],ha)) {
-scsi_unregister(shp);
-continue;
-}
-/* controller found and initialized */
-printk(Configuring GDT-PCI HA at %d/%d IRQ %u\n,
-   pcistr[ctr].pdev-bus-number,
-  PCI_SLOT(pcistr[ctr].pdev-devfn), ha-irq);
-
-if (request_irq(ha-irq, gdth_interrupt,
-IRQF_DISABLED|IRQF_SHARED, gdth, ha))
-{
-printk(GDT-PCI: Unable to allocate IRQ\n);
-scsi_unregister(shp);
-continue;
-}
-shp-unchecked_isa_dma = 0;
-shp-irq = ha-irq;
-shp-dma_channel = 0xff;
-hanum = gdth_ctr_count;
-gdth_ctr_tab[gdth_ctr_count++] = shp;
-gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-
-NUMDATA(shp)-hanum = (ushort)hanum;
-NUMDATA(shp)-busnum= 0;
-
-ha-pccb = CMDDATA(shp);
-ha-ccb_phys = 0L;
-
-ha-pscratch = pci_alloc_consistent(ha-pdev, GDTH_SCRATCH, 
-scratch_dma_handle);
-ha-scratch_phys = scratch_dma_handle;
-ha-pmsg = pci_alloc_consistent(ha-pdev, sizeof(gdth_msg_str), 
-scratch_dma_handle);
-ha-msg_phys = scratch_dma_handle;
-#ifdef INT_COAL
-ha-coal_stat = (gdth_coal_status *)
-pci_alloc_consistent(ha-pdev, sizeof(gdth_coal_status) *
- MAXOFFSETS, scratch_dma_handle);
-ha-coal_stat_phys = scratch_dma_handle;
-#endif
-ha-scratch_busy = FALSE;
-ha-req_first = NULL;
-ha-tid_cnt = pcistr[ctr].pdev-device = 0x200 ? MAXID : MAX_HDRIVES;
-if (max_ids  0  max_ids  ha-tid_cnt)
-ha-tid_cnt = max_ids;
-for (i=0; iGDTH_MAXCMDS; ++i)
-ha-cmd_tab[i].cmnd = UNUSED_CMND;
-ha-scan_mode = rescan ? 0x10 : 0;
-
-err = FALSE;
-if (ha-pscratch == NULL || ha-pmsg == NULL || 
-!gdth_search_drives(hanum)) {
-err = TRUE;
-} else {
-if (hdr_channel  0 || hdr_channel  ha-bus_cnt)
-hdr_channel = ha-bus_cnt;
-ha-virt_bus = hdr_channel;
-
-
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,0)
-scsi_set_pci_device(shp, pcistr[ctr].pdev);
-#endif
-if (!(ha-cache_feat  ha-raw_feat  ha-screen_feat GDT_64BIT)||
-/* 64-bit DMA only supported from FW = x.43 */
-(!ha-dma64_support)) {
-if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) {
-printk(KERN_WARNING GDT-PCI %d: Unable to set 32-bit 
DMA\n, hanum);
-err = TRUE;
-}
-} else {
-shp-max_cmd_len = 16;
-if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) {
-printk(GDT-PCI %d: 64-bit DMA enabled\n, hanum);
-} else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) 
{
-printk(KERN_WARNING GDT-PCI %d: Unable to set 64/32-bit 
DMA\n, hanum);
-err = TRUE;
-}
-}
-}
-
-if (err) {
-printk(GDT-PCI %d: Error during device scan\n, hanum);
---gdth_ctr_count;
---gdth_ctr_vcount;
-#ifdef INT_COAL
-

[PATCH 1/7] gdth: split out isa probing

2007-07-21 Thread Christoph Hellwig
(note: this is ontop of Jeff's pci cleanup patch)

Split out isa probing into a helper of it's own.  Error handling is
cleaned up, but errors are not propagated yet.  Also enclose the isa
probe under the proper CONFIG_ISA symbol instead of the !IA64 hack.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/scsi/gdth.c
===
--- linux-2.6.orig/drivers/scsi/gdth.c  2007-07-11 17:34:31.0 +0200
+++ linux-2.6/drivers/scsi/gdth.c   2007-07-11 18:19:01.0 +0200
@@ -476,6 +476,9 @@ static void gdth_flush(int hanum);
 static int gdth_halt(struct notifier_block *nb, ulong event, void *buf);
 static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *));
 static void gdth_scsi_done(struct scsi_cmnd *scp);
+#ifdef CONFIG_ISA
+static int gdth_isa_probe_one(struct scsi_host_template *, ulong32);
+#endif
 
 #ifdef DEBUG_GDTH
 static unchar   DebugState = DEBUG_GDTH;
@@ -4282,6 +4285,7 @@ int __init option_setup(char *str)
 return 1;
 }
 
+
 #if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,0)
 static int __init gdth_detect(struct scsi_host_template *shtp)
 #else
@@ -4328,135 +4332,15 @@ static int __init gdth_detect(Scsi_Host_
 /* As default we do not probe for EISA or ISA controllers */
 if (probe_eisa_isa) {
 /* scanning for controllers, at first: ISA controller */
-for (isa_bios=0xc8000UL; isa_bios=0xd8000UL; isa_bios+=0x8000UL) {
-dma_addr_t scratch_dma_handle;
-scratch_dma_handle = 0;
-
-if (gdth_ctr_count = MAXHA) 
-break;
-if (gdth_search_isa(isa_bios)) {/* controller found */
-shp = scsi_register(shtp,sizeof(gdth_ext_str));
-if (shp == NULL)
-continue;  
-
-ha = HADATA(shp);
-if (!gdth_init_isa(isa_bios,ha)) {
-scsi_unregister(shp);
-continue;
-}
-#ifdef __ia64__
-break;
-#else
-/* controller found and initialized */
-printk(Configuring GDT-ISA HA at BIOS 0x%05X IRQ %u DRQ %u\n,
-   isa_bios,ha-irq,ha-drq);
-
-if 
(request_irq(ha-irq,gdth_interrupt,IRQF_DISABLED,gdth,ha)) {
-printk(GDT-ISA: Unable to allocate IRQ\n);
-scsi_unregister(shp);
-continue;
-}
-if (request_dma(ha-drq,gdth)) {
-printk(GDT-ISA: Unable to allocate DMA channel\n);
-free_irq(ha-irq,ha);
-scsi_unregister(shp);
-continue;
-}
-set_dma_mode(ha-drq,DMA_MODE_CASCADE);
-enable_dma(ha-drq);
-shp-unchecked_isa_dma = 1;
-shp-irq = ha-irq;
-shp-dma_channel = ha-drq;
-hanum = gdth_ctr_count; 
-gdth_ctr_tab[gdth_ctr_count++] = shp;
-gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-
-NUMDATA(shp)-hanum = (ushort)hanum;
-NUMDATA(shp)-busnum= 0;
-
-ha-pccb = CMDDATA(shp);
-ha-ccb_phys = 0L;
-ha-pdev = NULL;
-ha-pscratch = pci_alloc_consistent(ha-pdev, GDTH_SCRATCH, 
-scratch_dma_handle);
-ha-scratch_phys = scratch_dma_handle;
-ha-pmsg = pci_alloc_consistent(ha-pdev, 
sizeof(gdth_msg_str), 
-scratch_dma_handle);
-ha-msg_phys = scratch_dma_handle;
-#ifdef INT_COAL
-ha-coal_stat = (gdth_coal_status *)
-pci_alloc_consistent(ha-pdev, sizeof(gdth_coal_status) *
-MAXOFFSETS, scratch_dma_handle);
-ha-coal_stat_phys = scratch_dma_handle;
-#endif
-
-ha-scratch_busy = FALSE;
-ha-req_first = NULL;
-ha-tid_cnt = MAX_HDRIVES;
-if (max_ids  0  max_ids  ha-tid_cnt)
-ha-tid_cnt = max_ids;
-for (i=0; iGDTH_MAXCMDS; ++i)
-ha-cmd_tab[i].cmnd = UNUSED_CMND;
-ha-scan_mode = rescan ? 0x10 : 0;
-
-if (ha-pscratch == NULL || ha-pmsg == NULL || 
-!gdth_search_drives(hanum)) {
-printk(GDT-ISA: Error during device scan\n);
---gdth_ctr_count;
---gdth_ctr_vcount;
-
-#ifdef INT_COAL
-if (ha-coal_stat)
-pci_free_consistent(ha-pdev, sizeof(gdth_coal_status) 
*
-MAXOFFSETS, ha-coal_stat,
-ha-coal_stat_phys);
-#endif
-if (ha-pscratch)
-

[PATCH 4/7] gdth: Remove 2.4.x support, in-kernel changelog

2007-07-21 Thread Christoph Hellwig
This is Jeff's compat removal patch adjusted to apply after my previous
patches:

commit 095089554011aef3834fd7b7e35ce0c84349d9a9
Author: Jeff Garzik [EMAIL PROTECTED]
Date:   Fri Jul 20 21:17:45 2007 -0400

[SCSI] gdth: Remove 2.4.x support, in-kernel changelog

* Remove in-source changelog.  It's archived permanently in git and
  various kernel archives, and changelogs should exist purely in git.

* Remove 2.4.x kernel support.  It is an active obstacle to
  modernizing this driver, at this point.  This includes killing
  gdth_kcompat.h which is 100% redundant in modern kernels.

Signed-off-by: Jeff Garzik [EMAIL PROTECTED]

 drivers/scsi/gdth.c |  408 
 drivers/scsi/gdth.h |1 
 drivers/scsi/gdth_kcompat.h |   31 ---
 drivers/scsi/gdth_proc.c|   27 --
 4 files changed, 2 insertions(+), 465 deletions(-)

095089554011aef3834fd7b7e35ce0c84349d9a9
Index: linux-2.6/drivers/scsi/gdth.c
===
--- linux-2.6.orig/drivers/scsi/gdth.c  2007-07-21 12:19:13.0 +0200
+++ linux-2.6/drivers/scsi/gdth.c   2007-07-21 12:21:14.0 +0200
@@ -27,280 +27,8 @@
  * along with this kernel; if not, write to the Free Software   *
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*
  *  *
- * Linux kernel 2.4.x, 2.6.x supported  *
+ * Linux kernel 2.6.x supported
*
  *  *
- * $Log: gdth.c,v $
- * Revision 1.74  2006/04/10 13:44:47  achim
- * Community changes for 2.6.x
- * Kernel 2.2.x no longer supported
- * scsi_request interface removed, thanks to Christoph Hellwig
- *
- * Revision 1.73  2004/03/31 13:33:03  achim
- * Special command 0xfd implemented to detect 64-bit DMA support
- *
- * Revision 1.72  2004/03/17 08:56:04  achim
- * 64-bit DMA only enabled if FW = x.43
- *
- * Revision 1.71  2004/03/05 15:51:29  achim
- * Screen service: separate message buffer, bugfixes
- *
- * Revision 1.70  2004/02/27 12:19:07  achim
- * Bugfix: Reset bit in config (0xfe) call removed
- *
- * Revision 1.69  2004/02/20 09:50:24  achim
- * Compatibility changes for kernels  2.4.20
- * Bugfix screen service command size
- * pci_set_dma_mask() error handling added
- *
- * Revision 1.68  2004/02/19 15:46:54  achim
- * 64-bit DMA bugfixes
- * Drive size bugfix for drives  1TB
- *
- * Revision 1.67  2004/01/14 13:11:57  achim
- * Tool access over /proc no longer supported
- * Bugfixes IOCTLs
- *
- * Revision 1.66  2003/12/19 15:04:06  achim
- * Bugfixes support for drives  2TB
- *
- * Revision 1.65  2003/12/15 11:21:56  achim
- * 64-bit DMA support added
- * Support for drives  2 TB implemented
- * Kernels 2.2.x, 2.4.x, 2.6.x supported
- *
- * Revision 1.64  2003/09/17 08:30:26  achim
- * EISA/ISA controller scan disabled
- * Command line switch probe_eisa_isa added
- *
- * Revision 1.63  2003/07/12 14:01:00  Daniele Bellucci [EMAIL PROTECTED]
- * Minor cleanups in gdth_ioctl.
- *
- * Revision 1.62  2003/02/27 15:01:59  achim
- * Dynamic DMA mapping implemented
- * New (character device) IOCTL interface added
- * Other controller related changes made
- *
- * Revision 1.61  2002/11/08 13:09:52  boji
- * Added support for XSCALE based RAID Controllers
- * Fixed SCREENSERVICE initialization in SMP cases
- * Added checks for gdth_polling before GDTH_HA_LOCK
- *
- * Revision 1.60  2002/02/05 09:35:22  achim
- * MODULE_LICENSE only if kernel = 2.4.11
- *
- * Revision 1.59  2002/01/30 09:46:33  achim
- * Small changes
- *
- * Revision 1.58  2002/01/29 15:30:02  achim
- * Set default value of shared_access to Y
- * New status S_CACHE_RESERV for clustering added
- *
- * Revision 1.57  2001/08/21 11:16:35  achim
- * Bugfix free_irq()
- *
- * Revision 1.56  2001/08/09 11:19:39  achim
- * Scsi_Host_Template changes
- *
- * Revision 1.55  2001/08/09 10:11:28  achim
- * Command HOST_UNFREEZE_IO before cache service init.
- *
- * Revision 1.54  2001/07/20 13:48:12  achim
- * Expand: gdth_analyse_hdrive() removed
- *
- * Revision 1.53  2001/07/17 09:52:49  achim
- * Small OEM related change
- *
- * Revision 1.52  2001/06/19 15:06:20  achim
- * New host command GDT_UNFREEZE_IO added
- *
- * Revision 1.51  2001/05/22 06:42:37  achim
- * PCI: Subdevice ID added
- *
- * Revision 1.50  2001/05/17 13:42:16  achim
- * Support for Intel Storage RAID Controllers added
- *
- * Revision 1.50  2001/05/17 12:12:34  achim
- * Support for Intel Storage RAID Controllers added
- *
- * Revision 1.49  2001/03/15 15:07:17  achim
- * New __setup interface for boot command line options added
- *
- * Revision 1.48  2001/02/06 12:36:28  achim
- * Bugfix Cluster protocol
- *
- * Revision 1.47  2001/01/10 14:42:06  achim
- * New switch shared_access added
- *
- * 

[PATCH 5/7] gdth: kill virt_ctr option

2007-07-21 Thread Christoph Hellwig
The virt_ctr option allows to register a new scsi_host for each bus
on the raid controller.  This non-default option makes no sense with
the current scsi code and prevents cleaning up the host registration,
so remove it.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/scsi/gdth.c
===
--- linux-2.6.orig/drivers/scsi/gdth.c  2007-07-21 12:31:55.0 +0200
+++ linux-2.6/drivers/scsi/gdth.c   2007-07-21 12:41:00.0 +0200
@@ -56,8 +56,6 @@
  * max_ids:xx - target ID count per channel (1..MAXID)
  * rescan:Y rescan all channels/IDs 
  * rescan:N use all devices found until now
- * virt_ctr:Y   map every channel to a virtual controller 
- * virt_ctr:N   use multi channel support 
  * hdr_channel:xx - number of virtual bus for host drives
  * shared_access:Y  disable driver reserve/release protocol to 
  *  access a shared resource from several nodes, 
@@ -69,7 +67,7 @@
  * force_dma32:Nuse 64 bit DMA mode, if supported
  *
  * The default values are: gdth=disable:N,reserve_mode:1,reverse_scan:N,
- *  max_ids:127,rescan:N,virt_ctr:N,hdr_channel:0,
+ *  max_ids:127,rescan:N,hdr_channel:0,
  *  shared_access:Y,probe_eisa_isa:N,force_dma32:N.
  * Here is another example: gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y.
  * 
@@ -80,7 +78,7 @@
  * '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 virt_ctr=0 hdr_channel=0 shared_access=0 
+ *   max_ids=127 rescan=0 hdr_channel=0 shared_access=0
  *   probe_eisa_isa=0 force_dma32=0
  * The other example: modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1.
  */
@@ -316,10 +314,8 @@ static unchar   gdth_polling;   
 static unchar   gdth_from_wait  = FALSE;/* gdth_wait() */
 static int  wait_index,wait_hanum;  /* gdth_wait() */
 static int  gdth_ctr_count  = 0;/* controller count */
-static int  gdth_ctr_vcount = 0;/* virt. ctr. count */
 static int  gdth_ctr_released = 0;  /* gdth_release() */
 static struct Scsi_Host *gdth_ctr_tab[MAXHA];   /* controller table */
-static struct Scsi_Host *gdth_ctr_vtab[MAXHA*MAXBUS];   /* virt. ctr. table */
 static unchar   gdth_write_through = FALSE; /* write through */
 static gdth_evt_str ebuffer[MAX_EVENTS];/* event buffer */
 static int elastidx;
@@ -371,8 +367,6 @@ static int hdr_channel = 0;
 static int max_ids = MAXID;
 /* rescan all IDs */
 static int rescan = 0;
-/* map channels to virtual controllers */
-static int virt_ctr = 0;
 /* shared access */
 static int shared_access = 1;
 /* enable support for EISA and ISA controllers */
@@ -389,7 +383,6 @@ module_param(reverse_scan, int, 0);
 module_param(hdr_channel, int, 0);
 module_param(max_ids, int, 0);
 module_param(rescan, int, 0);
-module_param(virt_ctr, int, 0);
 module_param(shared_access, int, 0);
 module_param(probe_eisa_isa, int, 0);
 module_param(force_dma32, int, 0);
@@ -2019,7 +2012,7 @@ static void gdth_putq(int hanum,Scsi_Cmn
 
 if (scp-done != gdth_scsi_done) {
 scp-SCp.this_residual = (int)priority;
-b = virt_ctr ? NUMDATA(scp-device-host)-busnum:scp-device-channel;
+b = scp-device-channel;
 t = scp-device-id;
 if (priority = DEFAULT_PRI) {
 if ((b != ha-virt_bus  ha-raw[BUS_L2P(ha,b)].lock) ||
@@ -2081,8 +2074,7 @@ static void gdth_next(int hanum)
 if (nscp != pscp  nscp != (Scsi_Cmnd *)pscp-SCp.ptr)
 pscp = (Scsi_Cmnd *)pscp-SCp.ptr;
 if (nscp-done != gdth_scsi_done) {
-b = virt_ctr ?
-NUMDATA(nscp-device-host)-busnum : nscp-device-channel;
+b = nscp-device-channel;
 t = nscp-device-id;
 l = nscp-device-lun;
 if (nscp-SCp.this_residual = DEFAULT_PRI) {
@@ -3398,7 +3390,7 @@ static int gdth_sync_event(int hanum,int
 printk(\n);
 
 } else {
-b = virt_ctr ? NUMDATA(scp-device-host)-busnum : 
scp-device-channel;
+b = scp-device-channel;
 t = scp-device-id;
 if (scp-SCp.sent_command == -1  b != ha-virt_bus) {
 ha-raw[BUS_L2P(ha,b)].io_cnt[t]--;
@@ -3884,8 +3876,6 @@ static void __init internal_setup(char *
 max_ids = val;
 else if (!strncmp(argv, rescan:, 7))
 rescan = val;
-else if (!strncmp(argv, virt_ctr:, 9))
-virt_ctr = val;
 else if (!strncmp(argv, shared_access:, 14))
 shared_access = val;
 else if (!strncmp(argv, probe_eisa_isa:, 15))
@@ -4017,7 +4007,7 @@ static int 

[PATCH 6/7] gdth: clean up host private data

2007-07-21 Thread Christoph Hellwig
Get rid of all the indirection in the Scsi_Host private data and always
but the gdth_ha_str directly into it.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/scsi/gdth.h
===
--- linux-2.6.orig/drivers/scsi/gdth.h  2007-07-21 12:40:41.0 +0200
+++ linux-2.6/drivers/scsi/gdth.h   2007-07-21 18:50:15.0 +0200
@@ -853,6 +853,8 @@ typedef struct {
 
 /* controller information structure */
 typedef struct {
+struct Scsi_Host*shost;
+ushort hanum;
 ushort  oem_id; /* OEM */
 ushort  type;   /* controller class */
 ulong32 stype;  /* subtype (PCI: device ID) */
@@ -864,6 +866,7 @@ typedef struct {
 void __iomem*brd;   /* DPRAM address */
 ulong32 brd_phys;   /* slot number/BIOS address */
 gdt6c_plx_regs  *plx;   /* PLX regs (new PCI contr.) */
+gdth_cmd_strcmdext;
 gdth_cmd_str*pccb;  /* address command structure */
 ulong32 ccb_phys;   /* phys. address */
 #ifdef INT_COAL
@@ -937,19 +940,6 @@ typedef struct {
 struct scsi_device *sdev;
 } gdth_ha_str;
 
-/* structure for scsi_register(), SCSI bus != 0 */
-typedef struct {
-ushort  hanum;
-} gdth_num_str;
-
-/* structure for scsi_register() */
-typedef struct {
-gdth_num_strnumext; /* must be the first element */
-gdth_ha_str haext;
-gdth_cmd_strcmdext;
-} gdth_ext_str;
-
-
 /* INQUIRY data format */
 typedef struct {
 unchar  type_qual;
Index: linux-2.6/drivers/scsi/gdth_proc.c
===
--- linux-2.6.orig/drivers/scsi/gdth_proc.c 2007-07-21 12:40:41.0 
+0200
+++ linux-2.6/drivers/scsi/gdth_proc.c  2007-07-21 12:53:44.0 +0200
@@ -7,17 +7,15 @@
 int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t 
offset,int length,   
int inout)
 {
-int hanum;
+gdth_ha_str *ha = shost_priv(host);
 
 TRACE2((gdth_proc_info() length %d offs %d inout %d\n,
 length,(int)offset,inout));
 
-hanum = NUMDATA(host)-hanum;
-
 if (inout)
-return(gdth_set_info(buffer,length,host,hanum));
+return(gdth_set_info(buffer,length,host,ha-hanum));
 else
-return(gdth_get_info(buffer,start,offset,length,host,hanum));
+return(gdth_get_info(buffer,start,offset,length,host,ha-hanum));
 }
 
 static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
@@ -53,7 +51,7 @@ static int gdth_set_asc_info(struct Scsi
 memset(gdtcmd, 0, sizeof(gdth_cmd_str));
 
 TRACE2((gdth_set_asc_info() ha %d\n,hanum));
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 orig_length = length + 5;
 drive = -1;
 wb_mode = 0;
@@ -187,7 +185,7 @@ static int gdth_get_info(char *buffer,ch
 memset(gdtcmd, 0, sizeof(gdth_cmd_str));
 
 TRACE2((gdth_get_info() ha %d\n,hanum));
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 
 
 /* request is i.e. cat /proc/scsi/gdth/0 */ 
@@ -678,7 +676,7 @@ static char *gdth_ioctl_alloc(int hanum,
 if (size == 0)
 return NULL;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 if (!ha-scratch_busy  size = GDTH_SCRATCH) {
@@ -703,7 +701,7 @@ static void gdth_ioctl_free(int hanum, i
 gdth_ha_str *ha;
 ulong flags;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 if (buf == ha-pscratch) {
@@ -722,7 +720,7 @@ static int gdth_ioctl_check_bin(int hanu
 ulong flags;
 int ret_val;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 ret_val = FALSE;
@@ -743,7 +741,7 @@ static void gdth_wait_completion(int han
 Scsi_Cmnd *scp;
 unchar b, t;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 for (i = 0; i  GDTH_MAXCMDS; ++i) {
@@ -770,7 +768,7 @@ static void gdth_stop_timeout(int hanum,
 Scsi_Cmnd *scp;
 unchar b, t;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 for (scp = ha-req_first; scp; scp = (Scsi_Cmnd *)scp-SCp.ptr) {
@@ -793,7 +791,7 @@ static void gdth_start_timeout(int hanum
 Scsi_Cmnd *scp;
 unchar b, t;
 
-ha = HADATA(gdth_ctr_tab[hanum]);
+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 for (scp = ha-req_first; scp; scp = (Scsi_Cmnd 

Re: [PATCH 6/7] gdth: clean up host private data

2007-07-21 Thread Jeff Garzik

Christoph Hellwig wrote:

Get rid of all the indirection in the Scsi_Host private data and always
but the gdth_ha_str directly into it.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]



@@ -678,7 +676,7 @@ static char *gdth_ioctl_alloc(int hanum,
 if (size == 0)
 return NULL;
 
-ha = HADATA(gdth_ctr_tab[hanum]);

+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 if (!ha-scratch_busy  size = GDTH_SCRATCH) {

@@ -703,7 +701,7 @@ static void gdth_ioctl_free(int hanum, i
 gdth_ha_str *ha;
 ulong flags;
 
-ha = HADATA(gdth_ctr_tab[hanum]);

+ha = shost_priv(gdth_ctr_tab[hanum]);
 spin_lock_irqsave(ha-smp_lock, flags);
 
 if (buf == ha-pscratch) {


Major problem with this patch:  it still directly references statically 
sized gdth_ctr_tab[].


This patch should be rewritten to apply on top of gdth: Isolate 
driver-global variables using helpers.  That patch has the clear 
advantage of isolating the direct references to gdth_ctr_tab[], which 
means that it can be trivially replaced with a dynamically-sized 
implementation in a later cleanup, without affecting the code or procfs 
output at all.


IOW, the ha from hanum common operation should clearly have a wrapper.

Once that is complete, your patch here shrinks, since you merely have to 
update gdth_find_ha() once rather than each codesite.


Jeff


P.S.  Are you sure you got achim's email correct?  I was using 
[EMAIL PROTECTED] since that it what is in gdth.c and his most 
recent Acked-by entry in the kernel changelog.

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/7] gdth: kill virt_ctr option

2007-07-21 Thread Jeff Garzik

Christoph Hellwig wrote:

The virt_ctr option allows to register a new scsi_host for each bus
on the raid controller.  This non-default option makes no sense with
the current scsi code and prevents cleaning up the host registration,
so remove it.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]


I agree the virt_ctr stuff is annoying, but this change has the clear 
potential to cause breakage.


I disagree that it prevents cleaning up host registration, since I have 
done so even with virt_ctr :)


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7] gdth: switch to modern scsi host registration

2007-07-21 Thread Jeff Garzik


in general, is sane.  three problems...


Christoph Hellwig wrote:

+   /* As default we do not probe for EISA or ISA controllers */
+   if (probe_eisa_isa) {
+   /* scanning for controllers, at first: ISA controller */
+#ifdef CONFIG_ISA
+   for (isa_bios = 0xc8000UL; isa_bios = 0xd8000UL;
+isa_bios += 0x8000UL) {
+   if (gdth_ctr_count = MAXHA)
+   break;
+   gdth_isa_probe_one(isa_bios);
+   }
+#endif
+#ifdef CONFIG_EISA
+   for (eisa_slot = 0x1000; eisa_slot = 0x8000; eisa_slot += 
0x1000) {
+   if (gdth_ctr_count = MAXHA)
+   break;
+   gdth_eisa_probe_one(eisa_slot);
+   }
+   }
+#endif


1) endif should be above the brace



+static void __exit gdth_exit(void)
+{
+   gdth_ha_str *ha;
+
+   list_for_each_entry(ha, gdth_instances, list)
+   gdth_remove_one(ha);


2) I think it's nicer to have two loops:  scsi_remove_host() for all 
ha-attached devices, and then the cleanup.  More pragmatic:  gives 
hardware more time to settle before turning off DMA engines.  A safer 
approach, and one that scsi_module.c follows.


3) This introduces a modicum of confusion between the gdth_ctr_tab[] 
stuff and the gdth_instances list.  While not strictly broken, this 
separation creates a foundation where the two can easily get out of sync.


Jeff


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] more gdth patches for your amusement

2007-07-21 Thread Jeff Garzik

This is the rest of the stuff checked into the 'gdth' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git

As noted before, I'm fine with Christoph's gdth work superceding mine,
or whatever.  This was just me poking around.  Hopefully the patches
are useful for illustration, if nothing else.

1) [SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
2) [SCSI] gdth: Move probe-time error handling code to end of each function
3) [SCSI] gdth: make some virt ctrlr code common; shuffle SHT members
4) [SCSI] gdth: convert to modern SCSI host alloc/scan

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] gdth: kill gdth_{read,write}[bwl] wrappers

2007-07-21 Thread Jeff Garzik

commit 411b270459eef219c41674e454b111dab610113f
Author: Jeff Garzik [EMAIL PROTECTED]
Date:   Fri Jul 20 23:24:13 2007 -0400

[SCSI] gdth: kill gdth_{read,write}[bwl] wrappers

They are direct equivalents to {read,write}[bwl].

Signed-off-by: Jeff Garzik [EMAIL PROTECTED]

 drivers/scsi/gdth.c |  313 +---
 1 file changed, 153 insertions(+), 160 deletions(-)

411b270459eef219c41674e454b111dab610113f
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index a6636b8..4cdba0c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -294,13 +294,6 @@ static struct timer_list gdth_timer;
 
 #define BUS_L2P(a,b)((b)(a)-virt_bus ? (b-1):(b))
 
-#define gdth_readb(addr)readb(addr)
-#define gdth_readw(addr)readw(addr)
-#define gdth_readl(addr)readl(addr)
-#define gdth_writeb(b,addr) writeb((b),(addr))
-#define gdth_writew(b,addr) writew((b),(addr))
-#define gdth_writel(b,addr) writel((b),(addr))
-
 static unchar   gdth_drq_tab[4] = {5,6,7,7};/* DRQ table */
 static unchar   gdth_irq_tab[6] = {0,10,11,12,14,0};/* IRQ table */
 static unchar   gdth_polling;   /* polling if TRUE */
@@ -544,7 +537,7 @@ static int __init gdth_search_isa(ulong32 bios_adr)
 
 TRACE((gdth_search_isa() bios adr. %x\n,bios_adr));
 if ((addr = ioremap(bios_adr+BIOS_ID_OFFS, sizeof(ulong32))) != NULL) {
-id = gdth_readl(addr);
+id = readl(addr);
 iounmap(addr);
 if (id == GDT2_ID)  /* GDT2000 */
 return 1;
@@ -778,22 +771,22 @@ static int __init gdth_init_isa(ulong32 
bios_adr,gdth_ha_str *ha)
 return 0;
 }
 dp2_ptr = ha-brd;
-gdth_writeb(1, dp2_ptr-io.memlock); /* switch off write protection */
+writeb(1, dp2_ptr-io.memlock); /* switch off write protection */
 /* reset interface area */
 memset_io(dp2_ptr-u, 0, sizeof(dp2_ptr-u));
-if (gdth_readl(dp2_ptr-u) != 0) {
+if (readl(dp2_ptr-u) != 0) {
 printk(GDT-ISA: Initialization error (DPMEM write error)\n);
 iounmap(ha-brd);
 return 0;
 }
 
 /* disable board interrupts, read DRQ and IRQ */
-gdth_writeb(0xff, dp2_ptr-io.irqdel);
-gdth_writeb(0x00, dp2_ptr-io.irqen);
-gdth_writeb(0x00, dp2_ptr-u.ic.S_Status);
-gdth_writeb(0x00, dp2_ptr-u.ic.Cmd_Index);
+writeb(0xff, dp2_ptr-io.irqdel);
+writeb(0x00, dp2_ptr-io.irqen);
+writeb(0x00, dp2_ptr-u.ic.S_Status);
+writeb(0x00, dp2_ptr-u.ic.Cmd_Index);
 
-irq_drq = gdth_readb(dp2_ptr-io.rq);
+irq_drq = readb(dp2_ptr-io.rq);
 for (i=0; i3; ++i) {
 if ((irq_drq  1)==0)
 break;
@@ -801,7 +794,7 @@ static int __init gdth_init_isa(ulong32 
bios_adr,gdth_ha_str *ha)
 }
 ha-drq = gdth_drq_tab[i];
 
-irq_drq = gdth_readb(dp2_ptr-io.rq)  3;
+irq_drq = readb(dp2_ptr-io.rq)  3;
 for (i=1; i5; ++i) {
 if ((irq_drq  1)==0)
 break;
@@ -810,12 +803,12 @@ static int __init gdth_init_isa(ulong32 
bios_adr,gdth_ha_str *ha)
 ha-irq = gdth_irq_tab[i];
 
 /* deinitialize services */
-gdth_writel(bios_adr, dp2_ptr-u.ic.S_Info[0]);
-gdth_writeb(0xff, dp2_ptr-u.ic.S_Cmd_Indx);
-gdth_writeb(0, dp2_ptr-io.event);
+writel(bios_adr, dp2_ptr-u.ic.S_Info[0]);
+writeb(0xff, dp2_ptr-u.ic.S_Cmd_Indx);
+writeb(0, dp2_ptr-io.event);
 retries = INIT_RETRIES;
 gdth_delay(20);
-while (gdth_readb(dp2_ptr-u.ic.S_Status) != 0xff) {
+while (readb(dp2_ptr-u.ic.S_Status) != 0xff) {
 if (--retries == 0) {
 printk(GDT-ISA: Initialization error (DEINIT failed)\n);
 iounmap(ha-brd);
@@ -823,9 +816,9 @@ static int __init gdth_init_isa(ulong32 
bios_adr,gdth_ha_str *ha)
 }
 gdth_delay(1);
 }
-prot_ver = (unchar)gdth_readl(dp2_ptr-u.ic.S_Info[0]);
-gdth_writeb(0, dp2_ptr-u.ic.Status);
-gdth_writeb(0xff, dp2_ptr-io.irqdel);
+prot_ver = (unchar)readl(dp2_ptr-u.ic.S_Info[0]);
+writeb(0, dp2_ptr-u.ic.Status);
+writeb(0xff, dp2_ptr-io.irqdel);
 if (prot_ver != PROTOCOL_VERSION) {
 printk(GDT-ISA: Illegal protocol version\n);
 iounmap(ha-brd);
@@ -839,15 +832,15 @@ static int __init gdth_init_isa(ulong32 
bios_adr,gdth_ha_str *ha)
 ha-brd_phys = bios_adr  4;
 
 /* special request to controller BIOS */
-gdth_writel(0x00, dp2_ptr-u.ic.S_Info[0]);
-gdth_writel(0x00, dp2_ptr-u.ic.S_Info[1]);
-gdth_writel(0x01, dp2_ptr-u.ic.S_Info[2]);
-gdth_writel(0x00, dp2_ptr-u.ic.S_Info[3]);
-gdth_writeb(0xfe, dp2_ptr-u.ic.S_Cmd_Indx);
-gdth_writeb(0, dp2_ptr-io.event);
+writel(0x00, dp2_ptr-u.ic.S_Info[0]);
+writel(0x00, dp2_ptr-u.ic.S_Info[1]);
+writel(0x01, dp2_ptr-u.ic.S_Info[2]);
+writel(0x00, dp2_ptr-u.ic.S_Info[3]);
+writeb(0xfe, dp2_ptr-u.ic.S_Cmd_Indx);
+writeb(0, dp2_ptr-io.event);
 retries = INIT_RETRIES;
 

[PATCH 3/4] gdth: make some virt ctrlr code common; shuffle SHT members

2007-07-21 Thread Jeff Garzik

commit 7b45cff696331f7655b4b819c1ef5a9ac6387ac6
Author: Jeff Garzik [EMAIL PROTECTED]
Date:   Sat Jul 21 05:47:21 2007 -0400

[SCSI] gdth: make some virt ctrlr code common; shuffle SHT members

* New function gdth_register_virt() replaces the three
  basically-duplicate copies of virtual controller registration.

* shuffle scsi_host_template members such that they appear in the
  order in which they are defined in the header.  this makes is easier
  to verify when initializers are missing members.

Signed-off-by: Jeff Garzik [EMAIL PROTECTED]

 drivers/scsi/gdth.c |   90 +---
 1 file changed, 44 insertions(+), 46 deletions(-)

7b45cff696331f7655b4b819c1ef5a9ac6387ac6
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index a399420..7235b1e 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3954,6 +3954,44 @@ int __init option_setup(char *str)
 return 1;
 }
 
+static int __init gdth_register_virt(struct scsi_host_template *shtp,
+gdth_ha_str *ha, int hanum,
+struct device *dev, bool isa_dma)
+{
+   struct Scsi_Host *shp;
+   unchar b;
+   int done = 0;
+
+   if (!virt_ctr)
+   return 0;
+   
+   virt_ctr = 1;
+
+   /* register addit. SCSI channels as virtual controllers */
+   for (b = 1; b  ha-bus_cnt + 1; ++b) {
+   shp = scsi_register(shtp, sizeof(gdth_num_str));
+
+   if (isa_dma) {
+   shp-unchecked_isa_dma = 1;
+   shp-dma_channel = ha-drq;
+   } else {
+   shp-unchecked_isa_dma = 0;
+   shp-dma_channel = 0xff;
+   }
+
+   shp-irq = ha-irq;
+
+   gdth_push_vshp(shp);
+
+   NUMDATA(shp)-hanum = (ushort)hanum;
+   NUMDATA(shp)-busnum = b;
+
+   done++;
+   }
+
+   return done ? 0 : -ENODEV;
+}
+
 static int __init gdth_start_isa(struct scsi_host_template *shtp,
 ulong32 isa_bios)
 {
@@ -4038,21 +4076,8 @@ static int __init gdth_start_isa(struct 
scsi_host_template *shtp,
shp-max_id  = ha-tid_cnt;
shp-max_lun = MAXLUN;
shp-max_channel = virt_ctr ? 0 : ha-bus_cnt;
-   if (virt_ctr) {
-   unchar b;
 
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b  ha-bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp-unchecked_isa_dma = 1;
-   shp-irq = ha-irq;
-   shp-dma_channel = ha-drq;
-   gdth_push_vshp(shp);
-   NUMDATA(shp)-hanum = (ushort)hanum;
-   NUMDATA(shp)-busnum = b;
-   }
-   }  
+   gdth_register_virt(shtp, ha, hanum, NULL, true);
 
spin_lock_init(ha-smp_lock);
gdth_enable_int(hanum);
@@ -4165,21 +4190,8 @@ static int __init gdth_start_eisa(struct 
scsi_host_template *shtp,
shp-max_id  = ha-tid_cnt;
shp-max_lun = MAXLUN;
shp-max_channel = virt_ctr ? 0 : ha-bus_cnt;
-   if (virt_ctr) {
-   unchar b;
 
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b  ha-bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp-unchecked_isa_dma = 0;
-   shp-irq = ha-irq;
-   shp-dma_channel = 0xff;
-   gdth_push_vshp(shp);
-   NUMDATA(shp)-hanum = (ushort)hanum;
-   NUMDATA(shp)-busnum = b;
-   }
-   }  
+   gdth_register_virt(shtp, ha, hanum, NULL, false);
 
spin_lock_init(ha-smp_lock);
gdth_enable_int(hanum);
@@ -4306,21 +4318,7 @@ static int __init gdth_start_pci(struct 
scsi_host_template *shtp,
shp-max_lun = MAXLUN;
shp-max_channel = virt_ctr ? 0 : ha-bus_cnt;
 
-   if (virt_ctr) {
-   unchar b;
-
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b  ha-bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp-unchecked_isa_dma = 0;
-   shp-irq = ha-irq;
-   shp-dma_channel = 0xff;
-   gdth_push_vshp(shp);
-   NUMDATA(shp)-hanum = (ushort)hanum;
-   NUMDATA(shp)-busnum = b;
-   }
-   }  
+   gdth_register_virt(shtp, ha, hanum, pcistr[ctr].pdev-dev, false);
 
spin_lock_init(ha-smp_lock);

[PATCH 4/4] gdth: convert to modern SCSI host alloc/scan

2007-07-21 Thread Jeff Garzik

commit 3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
Author: Jeff Garzik [EMAIL PROTECTED]
Date:   Sat Jul 21 06:22:20 2007 -0400

[SCSI] gdth: convert to modern SCSI host alloc/scan

Signed-off-by: Jeff Garzik [EMAIL PROTECTED]

 drivers/scsi/gdth.c |  131 
 1 file changed, 101 insertions(+), 30 deletions(-)

3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 7235b1e..10b3bf8 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3960,7 +3960,7 @@ static int __init gdth_register_virt(struct 
scsi_host_template *shtp,
 {
struct Scsi_Host *shp;
unchar b;
-   int done = 0;
+   int rc, done = 0;
 
if (!virt_ctr)
return 0;
@@ -3969,7 +3969,7 @@ static int __init gdth_register_virt(struct 
scsi_host_template *shtp,
 
/* register addit. SCSI channels as virtual controllers */
for (b = 1; b  ha-bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp, sizeof(gdth_num_str));
+   shp = scsi_host_alloc(shtp, sizeof(gdth_num_str));
 
if (isa_dma) {
shp-unchecked_isa_dma = 1;
@@ -3981,12 +3981,17 @@ static int __init gdth_register_virt(struct 
scsi_host_template *shtp,
 
shp-irq = ha-irq;
 
-   gdth_push_vshp(shp);
+   rc = scsi_add_host(shp, dev);
+   if (rc)
+   scsi_host_put(shp);
+   else {
+   gdth_push_vshp(shp);
 
-   NUMDATA(shp)-hanum = (ushort)hanum;
-   NUMDATA(shp)-busnum = b;
+   NUMDATA(shp)-hanum = (ushort)hanum;
+   NUMDATA(shp)-busnum = b;
 
-   done++;
+   done++;
+   }
}
 
return done ? 0 : -ENODEV;
@@ -3997,10 +4002,10 @@ static int __init gdth_start_isa(struct 
scsi_host_template *shtp,
 {
struct Scsi_Host *shp;
gdth_ha_str *ha;
-   int i, hanum;
+   int i, hanum, rc;
dma_addr_t scratch_dma_handle = 0;
 
-   shp = scsi_register(shtp, sizeof(gdth_ext_str));
+   shp = scsi_host_alloc(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
goto err_out;
 
@@ -4009,6 +4014,8 @@ static int __init gdth_start_isa(struct 
scsi_host_template *shtp,
goto err_out_shp;
 
 #ifdef __ia64__
+   if (scsi_add_host(shp, NULL))
+   scsi_host_put(shp);
return 0;   /* end loop: success */
 #else
/* controller found and initialized */
@@ -4077,13 +4084,26 @@ static int __init gdth_start_isa(struct 
scsi_host_template *shtp,
shp-max_lun = MAXLUN;
shp-max_channel = virt_ctr ? 0 : ha-bus_cnt;
 
-   gdth_register_virt(shtp, ha, hanum, NULL, true);
-
spin_lock_init(ha-smp_lock);
+
+   rc = scsi_add_host(shp, NULL);
+   if (rc) {
+   printk(GDT-ISA: Error adding host\n);
+   goto err_out_ha;
+   }
+
+   rc = gdth_register_virt(shtp, ha, hanum, NULL, true);
+   if (rc) {
+   printk(GDT-ISA: Error adding virt controllers\n);
+   goto err_out_host;
+   }
+
gdth_enable_int(hanum);
 
return 1;   /* continue looping */
 
+err_out_host:
+   scsi_remove_host(shp);
 err_out_ha:
gdth_pop_shp();
 
@@ -4104,7 +4124,7 @@ err_out_irq:
free_irq(ha-irq, ha);
 #endif /* !__ia64__ */
 err_out_shp:
-   scsi_unregister(shp);
+   scsi_host_put(shp);
 err_out:
return 1;   /* continue looping */
 }
@@ -4114,10 +4134,10 @@ static int __init gdth_start_eisa(struct 
scsi_host_template *shtp,
 {
struct Scsi_Host *shp;
gdth_ha_str *ha;
-   int i, hanum;
+   int i, hanum, rc;
dma_addr_t scratch_dma_handle = 0;
 
-   shp = scsi_register(shtp,sizeof(gdth_ext_str));
+   shp = scsi_host_alloc(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
goto err_out;
 
@@ -4191,13 +4211,26 @@ static int __init gdth_start_eisa(struct 
scsi_host_template *shtp,
shp-max_lun = MAXLUN;
shp-max_channel = virt_ctr ? 0 : ha-bus_cnt;
 
-   gdth_register_virt(shtp, ha, hanum, NULL, false);
-
spin_lock_init(ha-smp_lock);
+
+   rc = scsi_add_host(shp, NULL);
+   if (rc) {
+   printk(GDT-EISA: Error adding host\n);
+   goto err_out_ha;
+   }
+
+   rc = gdth_register_virt(shtp, ha, hanum, NULL, false);
+   if (rc) {
+   printk(GDT-EISA: Error adding virt controllers\n);
+   goto err_out_host;
+   }
+
gdth_enable_int(hanum);
 
return 1;   /* continue looping */
 
+err_out_host:
+   scsi_remove_host(shp);
 err_out_ha:
gdth_pop_shp();
 
@@ -4218,7 +4251,7 @@ err_out_ha:
sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);

Re: [PATCH 0/4] more gdth patches for your amusement

2007-07-21 Thread Jeff Garzik

Jeff Garzik wrote:

This is the rest of the stuff checked into the 'gdth' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git

As noted before, I'm fine with Christoph's gdth work superceding mine,
or whatever.  This was just me poking around.  Hopefully the patches
are useful for illustration, if nothing else.


Illustrating, of course, a guarantee-nothing-breaks, bug-for-bug code 
movement approach to upgrading the driver.


It intentionally avoids cleanups along the way, other than those 
explicitly enumerated, to preserve as much behavior as possible (and 
thus reduce chances of breakage as much as possible).


Jeff



-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] gdth: Split out EISA and ISA register code

2007-07-21 Thread Andi Kleen
Jeff Garzik [EMAIL PROTECTED] writes:

 No code changes, only indentation and blank line additions, plus code to
 call the new split-out functions.

Could you put the ISA code into #ifdef CONFIG_ISA while you're on it? 

That would allow dropping it on x86-64 

-Andi
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] unexport sg v3 helper functions

2007-07-21 Thread FUJITA Tomonori
blk_fill_sghdr_rq, blk_unmap_sghdr_rq, and blk_complete_sghdr_rq were
exported for bsg, however bsg was changed to support only sg v4.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
---
 block/scsi_ioctl.c |   13 +
 include/linux/blkdev.h |5 -
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 71bdf88..d359a71 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -214,8 +214,8 @@ int blk_verify_command(unsigned char *cm
 }
 EXPORT_SYMBOL_GPL(blk_verify_command);
 
-int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq,
- struct sg_io_hdr *hdr, int has_write_perm)
+static int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq,
+struct sg_io_hdr *hdr, int has_write_perm)
 {
memset(rq-cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
 
@@ -238,22 +238,20 @@ int blk_fill_sghdr_rq(request_queue_t *q
 
return 0;
 }
-EXPORT_SYMBOL_GPL(blk_fill_sghdr_rq);
 
 /*
  * unmap a request that was previously mapped to this sg_io_hdr. handles
  * both sg and non-sg sg_io_hdr.
  */
-int blk_unmap_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr)
+static int blk_unmap_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr)
 {
blk_rq_unmap_user(rq-bio);
blk_put_request(rq);
return 0;
 }
-EXPORT_SYMBOL_GPL(blk_unmap_sghdr_rq);
 
-int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
- struct bio *bio)
+static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
+struct bio *bio)
 {
int r, ret = 0;
 
@@ -287,7 +285,6 @@ int blk_complete_sghdr_rq(struct request
 
return r;
 }
-EXPORT_SYMBOL_GPL(blk_complete_sghdr_rq);
 
 static int sg_io(struct file *file, request_queue_t *q,
struct gendisk *bd_disk, struct sg_io_hdr *hdr)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f78965f..695e349 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -698,11 +698,6 @@ extern int blk_execute_rq(request_queue_
  struct request *, int);
 extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *,
  struct request *, int, rq_end_io_fn *);
-extern int blk_fill_sghdr_rq(request_queue_t *, struct request *,
- struct sg_io_hdr *, int);
-extern int blk_unmap_sghdr_rq(struct request *, struct sg_io_hdr *);
-extern int blk_complete_sghdr_rq(struct request *, struct sg_io_hdr *,
- struct bio *);
 extern int blk_verify_command(unsigned char *, int);
 
 static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
-- 
1.4.3.2

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html