aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-06-28 10:50:40 -0400
committerJames Bottomley <jejb@titanic.(none)>2005-07-11 13:47:47 -0400
commit2a40342e0e72a2ba89aaa9e6c9a9eceb04741b24 (patch)
treecda0577cc5348df8e4662b9615af7941852be3a3 /drivers/scsi/aic7xxx
parentdfd287f6ee9be1e3ae8fe1160c185aac6ca83c6a (diff)
[SCSI] aic7xxx: remove ahc_tailq
now that we do normal PCI probing there's no need to keep a list of all HBAs. Rejections fixed up and Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aic7xxx')
-rw-r--r--drivers/scsi/aic7xxx/aic7770.c9
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h7
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c59
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c152
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h28
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c4
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.c8
7 files changed, 6 insertions, 261 deletions
diff --git a/drivers/scsi/aic7xxx/aic7770.c b/drivers/scsi/aic7xxx/aic7770.c
index 92703bb35982..00f3bd1e181e 100644
--- a/drivers/scsi/aic7xxx/aic7770.c
+++ b/drivers/scsi/aic7xxx/aic7770.c
@@ -254,19 +254,12 @@ aic7770_config(struct ahc_softc *ahc, struct aic7770_identity *entry, u_int io)
254 if (error != 0) 254 if (error != 0)
255 return (error); 255 return (error);
256 256
257 ahc_list_lock(&l); 257 ahc->init_level++;
258 /*
259 * Link this softc in with all other ahc instances.
260 */
261 ahc_softc_insert(ahc);
262 258
263 /* 259 /*
264 * Enable the board's BUS drivers 260 * Enable the board's BUS drivers
265 */ 261 */
266 ahc_outb(ahc, BCTL, ENABLE); 262 ahc_outb(ahc, BCTL, ENABLE);
267
268 ahc_list_unlock(&l);
269
270 return (0); 263 return (0);
271} 264}
272 265
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index 0948d50ae75c..088cbc23743d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -1023,9 +1023,6 @@ struct ahc_softc {
1023 struct cs *critical_sections; 1023 struct cs *critical_sections;
1024 u_int num_critical_sections; 1024 u_int num_critical_sections;
1025 1025
1026 /* Links for chaining softcs */
1027 TAILQ_ENTRY(ahc_softc) links;
1028
1029 /* Channel Names ('A', 'B', etc.) */ 1026 /* Channel Names ('A', 'B', etc.) */
1030 char channel; 1027 char channel;
1031 char channel_b; 1028 char channel_b;
@@ -1110,9 +1107,6 @@ struct ahc_softc {
1110 uint16_t user_tagenable;/* Tagged Queuing allowed */ 1107 uint16_t user_tagenable;/* Tagged Queuing allowed */
1111}; 1108};
1112 1109
1113TAILQ_HEAD(ahc_softc_tailq, ahc_softc);
1114extern struct ahc_softc_tailq ahc_tailq;
1115
1116/************************ Active Device Information ***************************/ 1110/************************ Active Device Information ***************************/
1117typedef enum { 1111typedef enum {
1118 ROLE_UNKNOWN, 1112 ROLE_UNKNOWN,
@@ -1198,7 +1192,6 @@ void ahc_intr_enable(struct ahc_softc *ahc, int enable);
1198void ahc_pause_and_flushwork(struct ahc_softc *ahc); 1192void ahc_pause_and_flushwork(struct ahc_softc *ahc);
1199int ahc_suspend(struct ahc_softc *ahc); 1193int ahc_suspend(struct ahc_softc *ahc);
1200int ahc_resume(struct ahc_softc *ahc); 1194int ahc_resume(struct ahc_softc *ahc);
1201void ahc_softc_insert(struct ahc_softc *);
1202void ahc_set_unit(struct ahc_softc *, int); 1195void ahc_set_unit(struct ahc_softc *, int);
1203void ahc_set_name(struct ahc_softc *, char *); 1196void ahc_set_name(struct ahc_softc *, char *);
1204void ahc_alloc_scbs(struct ahc_softc *ahc); 1197void ahc_alloc_scbs(struct ahc_softc *ahc);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 8a2bb6f8d77b..7bc01e41bcce 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -52,9 +52,6 @@
52#include <dev/aic7xxx/aicasm/aicasm_insformat.h> 52#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
53#endif 53#endif
54 54
55/****************************** Softc Data ************************************/
56struct ahc_softc_tailq ahc_tailq = TAILQ_HEAD_INITIALIZER(ahc_tailq);
57
58/***************************** Lookup Tables **********************************/ 55/***************************** Lookup Tables **********************************/
59char *ahc_chip_names[] = 56char *ahc_chip_names[] =
60{ 57{
@@ -3879,62 +3876,6 @@ ahc_softc_init(struct ahc_softc *ahc)
3879} 3876}
3880 3877
3881void 3878void
3882ahc_softc_insert(struct ahc_softc *ahc)
3883{
3884 struct ahc_softc *list_ahc;
3885
3886#if AHC_PCI_CONFIG > 0
3887 /*
3888 * Second Function PCI devices need to inherit some
3889 * settings from function 0.
3890 */
3891 if ((ahc->chip & AHC_BUS_MASK) == AHC_PCI
3892 && (ahc->features & AHC_MULTI_FUNC) != 0) {
3893 TAILQ_FOREACH(list_ahc, &ahc_tailq, links) {
3894 ahc_dev_softc_t list_pci;
3895 ahc_dev_softc_t pci;
3896
3897 list_pci = list_ahc->dev_softc;
3898 pci = ahc->dev_softc;
3899 if (ahc_get_pci_slot(list_pci) == ahc_get_pci_slot(pci)
3900 && ahc_get_pci_bus(list_pci) == ahc_get_pci_bus(pci)) {
3901 struct ahc_softc *master;
3902 struct ahc_softc *slave;
3903
3904 if (ahc_get_pci_function(list_pci) == 0) {
3905 master = list_ahc;
3906 slave = ahc;
3907 } else {
3908 master = ahc;
3909 slave = list_ahc;
3910 }
3911 slave->flags &= ~AHC_BIOS_ENABLED;
3912 slave->flags |=
3913 master->flags & AHC_BIOS_ENABLED;
3914 slave->flags &= ~AHC_PRIMARY_CHANNEL;
3915 slave->flags |=
3916 master->flags & AHC_PRIMARY_CHANNEL;
3917 break;
3918 }
3919 }
3920 }
3921#endif
3922
3923 /*
3924 * Insertion sort into our list of softcs.
3925 */
3926 list_ahc = TAILQ_FIRST(&ahc_tailq);
3927 while (list_ahc != NULL
3928 && ahc_softc_comp(ahc, list_ahc) <= 0)
3929 list_ahc = TAILQ_NEXT(list_ahc, links);
3930 if (list_ahc != NULL)
3931 TAILQ_INSERT_BEFORE(list_ahc, ahc, links);
3932 else
3933 TAILQ_INSERT_TAIL(&ahc_tailq, ahc, links);
3934 ahc->init_level++;
3935}
3936
3937void
3938ahc_set_unit(struct ahc_softc *ahc, int unit) 3879ahc_set_unit(struct ahc_softc *ahc, int unit)
3939{ 3880{
3940 ahc->unit = unit; 3881 ahc->unit = unit;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index f94a67be0be4..116d0f51ca2c 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -136,10 +136,6 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL;
136#include <linux/blkdev.h> /* For block_size() */ 136#include <linux/blkdev.h> /* For block_size() */
137#include <linux/delay.h> /* For ssleep/msleep */ 137#include <linux/delay.h> /* For ssleep/msleep */
138 138
139/*
140 * Lock protecting manipulation of the ahc softc list.
141 */
142spinlock_t ahc_list_spinlock;
143 139
144/* 140/*
145 * Set this to the delay in seconds after SCSI bus reset. 141 * Set this to the delay in seconds after SCSI bus reset.
@@ -292,25 +288,6 @@ ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
292static uint32_t aic7xxx_no_reset; 288static uint32_t aic7xxx_no_reset;
293 289
294/* 290/*
295 * Certain PCI motherboards will scan PCI devices from highest to lowest,
296 * others scan from lowest to highest, and they tend to do all kinds of
297 * strange things when they come into contact with PCI bridge chips. The
298 * net result of all this is that the PCI card that is actually used to boot
299 * the machine is very hard to detect. Most motherboards go from lowest
300 * PCI slot number to highest, and the first SCSI controller found is the
301 * one you boot from. The only exceptions to this are when a controller
302 * has its BIOS disabled. So, we by default sort all of our SCSI controllers
303 * from lowest PCI slot number to highest PCI slot number. We also force
304 * all controllers with their BIOS disabled to the end of the list. This
305 * works on *almost* all computers. Where it doesn't work, we have this
306 * option. Setting this option to non-0 will reverse the order of the sort
307 * to highest first, then lowest, but will still leave cards with their BIOS
308 * disabled at the very end. That should fix everyone up unless there are
309 * really strange cirumstances.
310 */
311static uint32_t aic7xxx_reverse_scan;
312
313/*
314 * Should we force EXTENDED translation on a controller. 291 * Should we force EXTENDED translation on a controller.
315 * 0 == Use whatever is in the SEEPROM or default to off 292 * 0 == Use whatever is in the SEEPROM or default to off
316 * 1 == Use whatever is in the SEEPROM or default to on 293 * 1 == Use whatever is in the SEEPROM or default to on
@@ -416,7 +393,9 @@ static int ahc_linux_run_command(struct ahc_softc*,
416static void ahc_linux_setup_tag_info_global(char *p); 393static void ahc_linux_setup_tag_info_global(char *p);
417static aic_option_callback_t ahc_linux_setup_tag_info; 394static aic_option_callback_t ahc_linux_setup_tag_info;
418static int aic7xxx_setup(char *s); 395static int aic7xxx_setup(char *s);
419static int ahc_linux_next_unit(void); 396
397static int ahc_linux_unit;
398
420 399
421/********************************* Inlines ************************************/ 400/********************************* Inlines ************************************/
422static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 401static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*);
@@ -911,99 +890,6 @@ ahc_dmamap_unload(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
911 return (0); 890 return (0);
912} 891}
913 892
914/********************* Platform Dependent Functions ***************************/
915/*
916 * Compare "left hand" softc with "right hand" softc, returning:
917 * < 0 - lahc has a lower priority than rahc
918 * 0 - Softcs are equal
919 * > 0 - lahc has a higher priority than rahc
920 */
921int
922ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc)
923{
924 int value;
925 int rvalue;
926 int lvalue;
927
928 /*
929 * Under Linux, cards are ordered as follows:
930 * 1) VLB/EISA BIOS enabled devices sorted by BIOS address.
931 * 2) PCI devices with BIOS enabled sorted by bus/slot/func.
932 * 3) All remaining VLB/EISA devices sorted by ioport.
933 * 4) All remaining PCI devices sorted by bus/slot/func.
934 */
935 value = (lahc->flags & AHC_BIOS_ENABLED)
936 - (rahc->flags & AHC_BIOS_ENABLED);
937 if (value != 0)
938 /* Controllers with BIOS enabled have a *higher* priority */
939 return (value);
940
941 /*
942 * Same BIOS setting, now sort based on bus type.
943 * EISA and VL controllers sort together. EISA/VL
944 * have higher priority than PCI.
945 */
946 rvalue = (rahc->chip & AHC_BUS_MASK);
947 if (rvalue == AHC_VL)
948 rvalue = AHC_EISA;
949 lvalue = (lahc->chip & AHC_BUS_MASK);
950 if (lvalue == AHC_VL)
951 lvalue = AHC_EISA;
952 value = rvalue - lvalue;
953 if (value != 0)
954 return (value);
955
956 /* Still equal. Sort by BIOS address, ioport, or bus/slot/func. */
957 switch (rvalue) {
958#ifdef CONFIG_PCI
959 case AHC_PCI:
960 {
961 char primary_channel;
962
963 if (aic7xxx_reverse_scan != 0)
964 value = ahc_get_pci_bus(lahc->dev_softc)
965 - ahc_get_pci_bus(rahc->dev_softc);
966 else
967 value = ahc_get_pci_bus(rahc->dev_softc)
968 - ahc_get_pci_bus(lahc->dev_softc);
969 if (value != 0)
970 break;
971 if (aic7xxx_reverse_scan != 0)
972 value = ahc_get_pci_slot(lahc->dev_softc)
973 - ahc_get_pci_slot(rahc->dev_softc);
974 else
975 value = ahc_get_pci_slot(rahc->dev_softc)
976 - ahc_get_pci_slot(lahc->dev_softc);
977 if (value != 0)
978 break;
979 /*
980 * On multi-function devices, the user can choose
981 * to have function 1 probed before function 0.
982 * Give whichever channel is the primary channel
983 * the highest priority.
984 */
985 primary_channel = (lahc->flags & AHC_PRIMARY_CHANNEL) + 'A';
986 value = -1;
987 if (lahc->channel == primary_channel)
988 value = 1;
989 break;
990 }
991#endif
992 case AHC_EISA:
993 if ((rahc->flags & AHC_BIOS_ENABLED) != 0) {
994 value = rahc->platform_data->bios_address
995 - lahc->platform_data->bios_address;
996 } else {
997 value = rahc->bsh.ioport
998 - lahc->bsh.ioport;
999 }
1000 break;
1001 default:
1002 panic("ahc_softc_sort: invalid bus type");
1003 }
1004 return (value);
1005}
1006
1007static void 893static void
1008ahc_linux_setup_tag_info_global(char *p) 894ahc_linux_setup_tag_info_global(char *p)
1009{ 895{
@@ -1055,7 +941,6 @@ aic7xxx_setup(char *s)
1055#ifdef AHC_DEBUG 941#ifdef AHC_DEBUG
1056 { "debug", &ahc_debug }, 942 { "debug", &ahc_debug },
1057#endif 943#endif
1058 { "reverse_scan", &aic7xxx_reverse_scan },
1059 { "periodic_otag", &aic7xxx_periodic_otag }, 944 { "periodic_otag", &aic7xxx_periodic_otag },
1060 { "pci_parity", &aic7xxx_pci_parity }, 945 { "pci_parity", &aic7xxx_pci_parity },
1061 { "seltime", &aic7xxx_seltime }, 946 { "seltime", &aic7xxx_seltime },
@@ -1130,7 +1015,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1130 host->max_lun = AHC_NUM_LUNS; 1015 host->max_lun = AHC_NUM_LUNS;
1131 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0; 1016 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
1132 host->sg_tablesize = AHC_NSEG; 1017 host->sg_tablesize = AHC_NSEG;
1133 ahc_set_unit(ahc, ahc_linux_next_unit()); 1018 ahc_set_unit(ahc, ahc_linux_unit++);
1134 sprintf(buf, "scsi%d", host->host_no); 1019 sprintf(buf, "scsi%d", host->host_no);
1135 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); 1020 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
1136 if (new_name != NULL) { 1021 if (new_name != NULL) {
@@ -1159,29 +1044,6 @@ ahc_linux_get_memsize(void)
1159} 1044}
1160 1045
1161/* 1046/*
1162 * Find the smallest available unit number to use
1163 * for a new device. We don't just use a static
1164 * count to handle the "repeated hot-(un)plug"
1165 * scenario.
1166 */
1167static int
1168ahc_linux_next_unit(void)
1169{
1170 struct ahc_softc *ahc;
1171 int unit;
1172
1173 unit = 0;
1174retry:
1175 TAILQ_FOREACH(ahc, &ahc_tailq, links) {
1176 if (ahc->unit == unit) {
1177 unit++;
1178 goto retry;
1179 }
1180 }
1181 return (unit);
1182}
1183
1184/*
1185 * Place the SCSI bus into a known state by either resetting it, 1047 * Place the SCSI bus into a known state by either resetting it,
1186 * or forcing transfer negotiations on the next command to any 1048 * or forcing transfer negotiations on the next command to any
1187 * target. 1049 * target.
@@ -2685,12 +2547,6 @@ ahc_linux_init(void)
2685 scsi_transport_reserve_device(ahc_linux_transport_template, 2547 scsi_transport_reserve_device(ahc_linux_transport_template,
2686 sizeof(struct ahc_linux_device)); 2548 sizeof(struct ahc_linux_device));
2687 2549
2688 /*
2689 * Initialize our softc list lock prior to
2690 * probing for any adapters.
2691 */
2692 ahc_list_lockinit();
2693
2694 ahc_linux_pci_init(); 2550 ahc_linux_pci_init();
2695 ahc_linux_eisa_init(); 2551 ahc_linux_eisa_init();
2696 return 0; 2552 return 0;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index 5c0c9f9725b2..0e47ac217549 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -509,15 +509,6 @@ void ahc_format_transinfo(struct info_str *info,
509 509
510/******************************** Locking *************************************/ 510/******************************** Locking *************************************/
511/* Lock protecting internal data structures */ 511/* Lock protecting internal data structures */
512static __inline void ahc_lockinit(struct ahc_softc *);
513static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
514static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
515
516/* Lock held during ahc_list manipulation and ahc softc frees */
517extern spinlock_t ahc_list_spinlock;
518static __inline void ahc_list_lockinit(void);
519static __inline void ahc_list_lock(unsigned long *flags);
520static __inline void ahc_list_unlock(unsigned long *flags);
521 512
522static __inline void 513static __inline void
523ahc_lockinit(struct ahc_softc *ahc) 514ahc_lockinit(struct ahc_softc *ahc)
@@ -537,24 +528,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
537 spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags); 528 spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags);
538} 529}
539 530
540static __inline void
541ahc_list_lockinit(void)
542{
543 spin_lock_init(&ahc_list_spinlock);
544}
545
546static __inline void
547ahc_list_lock(unsigned long *flags)
548{
549 spin_lock_irqsave(&ahc_list_spinlock, *flags);
550}
551
552static __inline void
553ahc_list_unlock(unsigned long *flags)
554{
555 spin_unlock_irqrestore(&ahc_list_spinlock, *flags);
556}
557
558/******************************* PCI Definitions ******************************/ 531/******************************* PCI Definitions ******************************/
559/* 532/*
560 * PCIM_xxx: mask to locate subfield in register 533 * PCIM_xxx: mask to locate subfield in register
@@ -891,7 +864,6 @@ int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
891irqreturn_t 864irqreturn_t
892 ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs); 865 ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
893void ahc_platform_flushwork(struct ahc_softc *ahc); 866void ahc_platform_flushwork(struct ahc_softc *ahc);
894int ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
895void ahc_done(struct ahc_softc*, struct scb*); 867void ahc_done(struct ahc_softc*, struct scb*);
896void ahc_send_async(struct ahc_softc *, char channel, 868void ahc_send_async(struct ahc_softc *, char channel,
897 u_int target, u_int lun, ac_code, void *); 869 u_int target, u_int lun, ac_code, void *);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index 45ad438c9943..9d318ce2c993 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -143,10 +143,6 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev)
143 struct ahc_softc *ahc = pci_get_drvdata(pdev); 143 struct ahc_softc *ahc = pci_get_drvdata(pdev);
144 u_long s; 144 u_long s;
145 145
146 ahc_list_lock(&s);
147 TAILQ_REMOVE(&ahc_tailq, ahc, links);
148 ahc_list_unlock(&s);
149
150 ahc_lock(ahc, &s); 146 ahc_lock(ahc, &s);
151 ahc_intr_enable(ahc, FALSE); 147 ahc_intr_enable(ahc, FALSE);
152 ahc_unlock(ahc, &s); 148 ahc_unlock(ahc, &s);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
index 7ddcc97fb243..b3b2e2237eb3 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -704,7 +704,6 @@ ahc_find_pci_device(ahc_dev_softc_t pci)
704int 704int
705ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry) 705ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
706{ 706{
707 u_long l;
708 u_int command; 707 u_int command;
709 u_int our_id; 708 u_int our_id;
710 u_int sxfrctl1; 709 u_int sxfrctl1;
@@ -964,12 +963,7 @@ ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
964 if (error != 0) 963 if (error != 0)
965 return (error); 964 return (error);
966 965
967 ahc_list_lock(&l); 966 ahc->init_level++;
968 /*
969 * Link this softc in with all other ahc instances.
970 */
971 ahc_softc_insert(ahc);
972 ahc_list_unlock(&l);
973 return (0); 967 return (0);
974} 968}
975 969