aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aic7xxx_osm.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aic7xxx/aic7xxx_osm.h')
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h169
1 files changed, 25 insertions, 144 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index ed9027bd8a40..30c200d5bcd5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -59,6 +59,7 @@
59#ifndef _AIC7XXX_LINUX_H_ 59#ifndef _AIC7XXX_LINUX_H_
60#define _AIC7XXX_LINUX_H_ 60#define _AIC7XXX_LINUX_H_
61 61
62#include <linux/config.h>
62#include <linux/types.h> 63#include <linux/types.h>
63#include <linux/blkdev.h> 64#include <linux/blkdev.h>
64#include <linux/delay.h> 65#include <linux/delay.h>
@@ -66,18 +67,21 @@
66#include <linux/pci.h> 67#include <linux/pci.h>
67#include <linux/smp_lock.h> 68#include <linux/smp_lock.h>
68#include <linux/version.h> 69#include <linux/version.h>
70#include <linux/interrupt.h>
69#include <linux/module.h> 71#include <linux/module.h>
72#include <linux/slab.h>
70#include <asm/byteorder.h> 73#include <asm/byteorder.h>
71#include <asm/io.h> 74#include <asm/io.h>
72 75
73#include <linux/interrupt.h> /* For tasklet support. */ 76#include <scsi/scsi.h>
74#include <linux/config.h> 77#include <scsi/scsi_cmnd.h>
75#include <linux/slab.h> 78#include <scsi/scsi_eh.h>
79#include <scsi/scsi_device.h>
80#include <scsi/scsi_host.h>
81#include <scsi/scsi_tcq.h>
76 82
77/* Core SCSI definitions */ 83/* Core SCSI definitions */
78#define AIC_LIB_PREFIX ahc 84#define AIC_LIB_PREFIX ahc
79#include "scsi.h"
80#include <scsi/scsi_host.h>
81 85
82/* Name space conflict with BSD queue macros */ 86/* Name space conflict with BSD queue macros */
83#ifdef LIST_HEAD 87#ifdef LIST_HEAD
@@ -106,7 +110,7 @@
106/************************* Forward Declarations *******************************/ 110/************************* Forward Declarations *******************************/
107struct ahc_softc; 111struct ahc_softc;
108typedef struct pci_dev *ahc_dev_softc_t; 112typedef struct pci_dev *ahc_dev_softc_t;
109typedef Scsi_Cmnd *ahc_io_ctx_t; 113typedef struct scsi_cmnd *ahc_io_ctx_t;
110 114
111/******************************* Byte Order ***********************************/ 115/******************************* Byte Order ***********************************/
112#define ahc_htobe16(x) cpu_to_be16(x) 116#define ahc_htobe16(x) cpu_to_be16(x)
@@ -144,7 +148,7 @@ typedef Scsi_Cmnd *ahc_io_ctx_t;
144extern u_int aic7xxx_no_probe; 148extern u_int aic7xxx_no_probe;
145extern u_int aic7xxx_allow_memio; 149extern u_int aic7xxx_allow_memio;
146extern int aic7xxx_detect_complete; 150extern int aic7xxx_detect_complete;
147extern Scsi_Host_Template aic7xxx_driver_template; 151extern struct scsi_host_template aic7xxx_driver_template;
148 152
149/***************************** Bus Space/DMA **********************************/ 153/***************************** Bus Space/DMA **********************************/
150 154
@@ -174,11 +178,7 @@ struct ahc_linux_dma_tag
174}; 178};
175typedef struct ahc_linux_dma_tag* bus_dma_tag_t; 179typedef struct ahc_linux_dma_tag* bus_dma_tag_t;
176 180
177struct ahc_linux_dmamap 181typedef dma_addr_t bus_dmamap_t;
178{
179 dma_addr_t bus_addr;
180};
181typedef struct ahc_linux_dmamap* bus_dmamap_t;
182 182
183typedef int bus_dma_filter_t(void*, dma_addr_t); 183typedef int bus_dma_filter_t(void*, dma_addr_t);
184typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); 184typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
@@ -281,12 +281,6 @@ ahc_scb_timer_reset(struct scb *scb, u_int usec)
281/***************************** SMP support ************************************/ 281/***************************** SMP support ************************************/
282#include <linux/spinlock.h> 282#include <linux/spinlock.h>
283 283
284#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
285#define AHC_SCSI_HAS_HOST_LOCK 1
286#else
287#define AHC_SCSI_HAS_HOST_LOCK 0
288#endif
289
290#define AIC7XXX_DRIVER_VERSION "6.2.36" 284#define AIC7XXX_DRIVER_VERSION "6.2.36"
291 285
292/**************************** Front End Queues ********************************/ 286/**************************** Front End Queues ********************************/
@@ -328,20 +322,15 @@ struct ahc_cmd {
328 */ 322 */
329TAILQ_HEAD(ahc_busyq, ahc_cmd); 323TAILQ_HEAD(ahc_busyq, ahc_cmd);
330typedef enum { 324typedef enum {
331 AHC_DEV_UNCONFIGURED = 0x01,
332 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 325 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */
333 AHC_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */
334 AHC_DEV_ON_RUN_LIST = 0x08, /* Queued to be run later */
335 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 326 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */
336 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 327 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */
337 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 328 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */
338 AHC_DEV_SLAVE_CONFIGURED = 0x80 /* slave_configure() has been called */
339} ahc_linux_dev_flags; 329} ahc_linux_dev_flags;
340 330
341struct ahc_linux_target; 331struct ahc_linux_target;
342struct ahc_linux_device { 332struct ahc_linux_device {
343 TAILQ_ENTRY(ahc_linux_device) links; 333 TAILQ_ENTRY(ahc_linux_device) links;
344 struct ahc_busyq busyq;
345 334
346 /* 335 /*
347 * The number of transactions currently 336 * The number of transactions currently
@@ -382,11 +371,6 @@ struct ahc_linux_device {
382 ahc_linux_dev_flags flags; 371 ahc_linux_dev_flags flags;
383 372
384 /* 373 /*
385 * Per device timer.
386 */
387 struct timer_list timer;
388
389 /*
390 * The high limit for the tags variable. 374 * The high limit for the tags variable.
391 */ 375 */
392 u_int maxtags; 376 u_int maxtags;
@@ -419,7 +403,7 @@ struct ahc_linux_device {
419#define AHC_OTAG_THRESH 500 403#define AHC_OTAG_THRESH 500
420 404
421 int lun; 405 int lun;
422 Scsi_Device *scsi_device; 406 struct scsi_device *scsi_device;
423 struct ahc_linux_target *target; 407 struct ahc_linux_target *target;
424}; 408};
425 409
@@ -439,32 +423,16 @@ struct ahc_linux_target {
439 * manner and are allocated below 4GB, the number of S/G segments is 423 * manner and are allocated below 4GB, the number of S/G segments is
440 * unrestricted. 424 * unrestricted.
441 */ 425 */
442#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
443/*
444 * We dynamically adjust the number of segments in pre-2.5 kernels to
445 * avoid fragmentation issues in the SCSI mid-layer's private memory
446 * allocator. See aic7xxx_osm.c ahc_linux_size_nseg() for details.
447 */
448extern u_int ahc_linux_nseg;
449#define AHC_NSEG ahc_linux_nseg
450#define AHC_LINUX_MIN_NSEG 64
451#else
452#define AHC_NSEG 128 426#define AHC_NSEG 128
453#endif
454 427
455/* 428/*
456 * Per-SCB OSM storage. 429 * Per-SCB OSM storage.
457 */ 430 */
458typedef enum {
459 AHC_UP_EH_SEMAPHORE = 0x1
460} ahc_linux_scb_flags;
461
462struct scb_platform_data { 431struct scb_platform_data {
463 struct ahc_linux_device *dev; 432 struct ahc_linux_device *dev;
464 dma_addr_t buf_busaddr; 433 dma_addr_t buf_busaddr;
465 uint32_t xfer_len; 434 uint32_t xfer_len;
466 uint32_t sense_resid; /* Auto-Sense residual */ 435 uint32_t sense_resid; /* Auto-Sense residual */
467 ahc_linux_scb_flags flags;
468}; 436};
469 437
470/* 438/*
@@ -473,39 +441,24 @@ struct scb_platform_data {
473 * alignment restrictions of the various platforms supported by 441 * alignment restrictions of the various platforms supported by
474 * this driver. 442 * this driver.
475 */ 443 */
476typedef enum {
477 AHC_RUN_CMPLT_Q_TIMER = 0x10
478} ahc_linux_softc_flags;
479
480TAILQ_HEAD(ahc_completeq, ahc_cmd);
481
482struct ahc_platform_data { 444struct ahc_platform_data {
483 /* 445 /*
484 * Fields accessed from interrupt context. 446 * Fields accessed from interrupt context.
485 */ 447 */
486 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 448 struct ahc_linux_target *targets[AHC_NUM_TARGETS];
487 TAILQ_HEAD(, ahc_linux_device) device_runq;
488 struct ahc_completeq completeq;
489 449
490 spinlock_t spin_lock; 450 spinlock_t spin_lock;
491 struct tasklet_struct runq_tasklet;
492 u_int qfrozen; 451 u_int qfrozen;
493 pid_t dv_pid;
494 struct timer_list completeq_timer;
495 struct timer_list reset_timer; 452 struct timer_list reset_timer;
496 struct semaphore eh_sem; 453 struct semaphore eh_sem;
497 struct semaphore dv_sem;
498 struct semaphore dv_cmd_sem; /* XXX This needs to be in
499 * the target struct
500 */
501 struct scsi_device *dv_scsi_dev;
502 struct Scsi_Host *host; /* pointer to scsi host */ 454 struct Scsi_Host *host; /* pointer to scsi host */
503#define AHC_LINUX_NOIRQ ((uint32_t)~0) 455#define AHC_LINUX_NOIRQ ((uint32_t)~0)
504 uint32_t irq; /* IRQ for this adapter */ 456 uint32_t irq; /* IRQ for this adapter */
505 uint32_t bios_address; 457 uint32_t bios_address;
506 uint32_t mem_busaddr; /* Mem Base Addr */ 458 uint32_t mem_busaddr; /* Mem Base Addr */
507 uint64_t hw_dma_mask; 459
508 ahc_linux_softc_flags flags; 460#define AHC_UP_EH_SEMAPHORE 0x1
461 uint32_t flags;
509}; 462};
510 463
511/************************** OS Utility Wrappers *******************************/ 464/************************** OS Utility Wrappers *******************************/
@@ -594,7 +547,7 @@ ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
594 547
595/**************************** Initialization **********************************/ 548/**************************** Initialization **********************************/
596int ahc_linux_register_host(struct ahc_softc *, 549int ahc_linux_register_host(struct ahc_softc *,
597 Scsi_Host_Template *); 550 struct scsi_host_template *);
598 551
599uint64_t ahc_linux_get_memsize(void); 552uint64_t ahc_linux_get_memsize(void);
600 553
@@ -615,17 +568,6 @@ static __inline void ahc_lockinit(struct ahc_softc *);
615static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 568static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
616static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 569static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
617 570
618/* Lock acquisition and release of the above lock in midlayer entry points. */
619static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *,
620 unsigned long *flags);
621static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *,
622 unsigned long *flags);
623
624/* Lock held during command compeletion to the upper layer */
625static __inline void ahc_done_lockinit(struct ahc_softc *);
626static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags);
627static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags);
628
629/* Lock held during ahc_list manipulation and ahc softc frees */ 571/* Lock held during ahc_list manipulation and ahc softc frees */
630extern spinlock_t ahc_list_spinlock; 572extern spinlock_t ahc_list_spinlock;
631static __inline void ahc_list_lockinit(void); 573static __inline void ahc_list_lockinit(void);
@@ -651,57 +593,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
651} 593}
652 594
653static __inline void 595static __inline void
654ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags)
655{
656 /*
657 * In 2.5.X and some 2.4.X versions, the midlayer takes our
658 * lock just before calling us, so we avoid locking again.
659 * For other kernel versions, the io_request_lock is taken
660 * just before our entry point is called. In this case, we
661 * trade the io_request_lock for our per-softc lock.
662 */
663#if AHC_SCSI_HAS_HOST_LOCK == 0
664 spin_unlock(&io_request_lock);
665 spin_lock(&ahc->platform_data->spin_lock);
666#endif
667}
668
669static __inline void
670ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags)
671{
672#if AHC_SCSI_HAS_HOST_LOCK == 0
673 spin_unlock(&ahc->platform_data->spin_lock);
674 spin_lock(&io_request_lock);
675#endif
676}
677
678static __inline void
679ahc_done_lockinit(struct ahc_softc *ahc)
680{
681 /*
682 * In 2.5.X, our own lock is held during completions.
683 * In previous versions, the io_request_lock is used.
684 * In either case, we can't initialize this lock again.
685 */
686}
687
688static __inline void
689ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
690{
691#if AHC_SCSI_HAS_HOST_LOCK == 0
692 spin_lock_irqsave(&io_request_lock, *flags);
693#endif
694}
695
696static __inline void
697ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
698{
699#if AHC_SCSI_HAS_HOST_LOCK == 0
700 spin_unlock_irqrestore(&io_request_lock, *flags);
701#endif
702}
703
704static __inline void
705ahc_list_lockinit(void) 596ahc_list_lockinit(void)
706{ 597{
707 spin_lock_init(&ahc_list_spinlock); 598 spin_lock_init(&ahc_list_spinlock);
@@ -767,12 +658,6 @@ typedef enum
767} ahc_power_state; 658} ahc_power_state;
768 659
769/**************************** VL/EISA Routines ********************************/ 660/**************************** VL/EISA Routines ********************************/
770#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \
771 && (defined(__i386__) || defined(__alpha__)) \
772 && (!defined(CONFIG_EISA)))
773#define CONFIG_EISA
774#endif
775
776#ifdef CONFIG_EISA 661#ifdef CONFIG_EISA
777extern uint32_t aic7xxx_probe_eisa_vl; 662extern uint32_t aic7xxx_probe_eisa_vl;
778int ahc_linux_eisa_init(void); 663int ahc_linux_eisa_init(void);
@@ -888,22 +773,18 @@ ahc_flush_device_writes(struct ahc_softc *ahc)
888} 773}
889 774
890/**************************** Proc FS Support *********************************/ 775/**************************** Proc FS Support *********************************/
891#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
892int ahc_linux_proc_info(char *, char **, off_t, int, int, int);
893#else
894int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 776int ahc_linux_proc_info(struct Scsi_Host *, char *, char **,
895 off_t, int, int); 777 off_t, int, int);
896#endif
897 778
898/*************************** Domain Validation ********************************/ 779/*************************** Domain Validation ********************************/
899/*********************** Transaction Access Wrappers *************************/ 780/*********************** Transaction Access Wrappers *************************/
900static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 781static __inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t);
901static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 782static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
902static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 783static __inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t);
903static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 784static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
904static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd); 785static __inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd);
905static __inline uint32_t ahc_get_transaction_status(struct scb *); 786static __inline uint32_t ahc_get_transaction_status(struct scb *);
906static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd); 787static __inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd);
907static __inline uint32_t ahc_get_scsi_status(struct scb *); 788static __inline uint32_t ahc_get_scsi_status(struct scb *);
908static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 789static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
909static __inline u_long ahc_get_transfer_length(struct scb *); 790static __inline u_long ahc_get_transfer_length(struct scb *);
@@ -922,7 +803,7 @@ static __inline void ahc_platform_scb_free(struct ahc_softc *ahc,
922static __inline void ahc_freeze_scb(struct scb *scb); 803static __inline void ahc_freeze_scb(struct scb *scb);
923 804
924static __inline 805static __inline
925void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 806void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status)
926{ 807{
927 cmd->result &= ~(CAM_STATUS_MASK << 16); 808 cmd->result &= ~(CAM_STATUS_MASK << 16);
928 cmd->result |= status << 16; 809 cmd->result |= status << 16;
@@ -935,7 +816,7 @@ void ahc_set_transaction_status(struct scb *scb, uint32_t status)
935} 816}
936 817
937static __inline 818static __inline
938void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 819void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
939{ 820{
940 cmd->result &= ~0xFFFF; 821 cmd->result &= ~0xFFFF;
941 cmd->result |= status; 822 cmd->result |= status;
@@ -948,7 +829,7 @@ void ahc_set_scsi_status(struct scb *scb, uint32_t status)
948} 829}
949 830
950static __inline 831static __inline
951uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd) 832uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd)
952{ 833{
953 return ((cmd->result >> 16) & CAM_STATUS_MASK); 834 return ((cmd->result >> 16) & CAM_STATUS_MASK);
954} 835}
@@ -960,7 +841,7 @@ uint32_t ahc_get_transaction_status(struct scb *scb)
960} 841}
961 842
962static __inline 843static __inline
963uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd) 844uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd)
964{ 845{
965 return (cmd->result & 0xFFFF); 846 return (cmd->result & 0xFFFF);
966} 847}