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.h175
1 files changed, 25 insertions, 150 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index c401537067b6..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,14 +403,10 @@ 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
426typedef enum {
427 AHC_INQ_VALID = 0x02,
428} ahc_linux_targ_flags;
429
430struct ahc_linux_target { 410struct ahc_linux_target {
431 struct ahc_linux_device *devices[AHC_NUM_LUNS]; 411 struct ahc_linux_device *devices[AHC_NUM_LUNS];
432 int channel; 412 int channel;
@@ -434,8 +414,6 @@ struct ahc_linux_target {
434 int refcount; 414 int refcount;
435 struct ahc_transinfo last_tinfo; 415 struct ahc_transinfo last_tinfo;
436 struct ahc_softc *ahc; 416 struct ahc_softc *ahc;
437 ahc_linux_targ_flags flags;
438 struct scsi_inquiry_data *inq_data;
439}; 417};
440 418
441/********************* Definitions Required by the Core ***********************/ 419/********************* Definitions Required by the Core ***********************/
@@ -445,32 +423,16 @@ struct ahc_linux_target {
445 * 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
446 * unrestricted. 424 * unrestricted.
447 */ 425 */
448#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
449/*
450 * We dynamically adjust the number of segments in pre-2.5 kernels to
451 * avoid fragmentation issues in the SCSI mid-layer's private memory
452 * allocator. See aic7xxx_osm.c ahc_linux_size_nseg() for details.
453 */
454extern u_int ahc_linux_nseg;
455#define AHC_NSEG ahc_linux_nseg
456#define AHC_LINUX_MIN_NSEG 64
457#else
458#define AHC_NSEG 128 426#define AHC_NSEG 128
459#endif
460 427
461/* 428/*
462 * Per-SCB OSM storage. 429 * Per-SCB OSM storage.
463 */ 430 */
464typedef enum {
465 AHC_UP_EH_SEMAPHORE = 0x1
466} ahc_linux_scb_flags;
467
468struct scb_platform_data { 431struct scb_platform_data {
469 struct ahc_linux_device *dev; 432 struct ahc_linux_device *dev;
470 dma_addr_t buf_busaddr; 433 dma_addr_t buf_busaddr;
471 uint32_t xfer_len; 434 uint32_t xfer_len;
472 uint32_t sense_resid; /* Auto-Sense residual */ 435 uint32_t sense_resid; /* Auto-Sense residual */
473 ahc_linux_scb_flags flags;
474}; 436};
475 437
476/* 438/*
@@ -479,39 +441,24 @@ struct scb_platform_data {
479 * alignment restrictions of the various platforms supported by 441 * alignment restrictions of the various platforms supported by
480 * this driver. 442 * this driver.
481 */ 443 */
482typedef enum {
483 AHC_RUN_CMPLT_Q_TIMER = 0x10
484} ahc_linux_softc_flags;
485
486TAILQ_HEAD(ahc_completeq, ahc_cmd);
487
488struct ahc_platform_data { 444struct ahc_platform_data {
489 /* 445 /*
490 * Fields accessed from interrupt context. 446 * Fields accessed from interrupt context.
491 */ 447 */
492 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 448 struct ahc_linux_target *targets[AHC_NUM_TARGETS];
493 TAILQ_HEAD(, ahc_linux_device) device_runq;
494 struct ahc_completeq completeq;
495 449
496 spinlock_t spin_lock; 450 spinlock_t spin_lock;
497 struct tasklet_struct runq_tasklet;
498 u_int qfrozen; 451 u_int qfrozen;
499 pid_t dv_pid;
500 struct timer_list completeq_timer;
501 struct timer_list reset_timer; 452 struct timer_list reset_timer;
502 struct semaphore eh_sem; 453 struct semaphore eh_sem;
503 struct semaphore dv_sem;
504 struct semaphore dv_cmd_sem; /* XXX This needs to be in
505 * the target struct
506 */
507 struct scsi_device *dv_scsi_dev;
508 struct Scsi_Host *host; /* pointer to scsi host */ 454 struct Scsi_Host *host; /* pointer to scsi host */
509#define AHC_LINUX_NOIRQ ((uint32_t)~0) 455#define AHC_LINUX_NOIRQ ((uint32_t)~0)
510 uint32_t irq; /* IRQ for this adapter */ 456 uint32_t irq; /* IRQ for this adapter */
511 uint32_t bios_address; 457 uint32_t bios_address;
512 uint32_t mem_busaddr; /* Mem Base Addr */ 458 uint32_t mem_busaddr; /* Mem Base Addr */
513 uint64_t hw_dma_mask; 459
514 ahc_linux_softc_flags flags; 460#define AHC_UP_EH_SEMAPHORE 0x1
461 uint32_t flags;
515}; 462};
516 463
517/************************** OS Utility Wrappers *******************************/ 464/************************** OS Utility Wrappers *******************************/
@@ -600,7 +547,7 @@ ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
600 547
601/**************************** Initialization **********************************/ 548/**************************** Initialization **********************************/
602int ahc_linux_register_host(struct ahc_softc *, 549int ahc_linux_register_host(struct ahc_softc *,
603 Scsi_Host_Template *); 550 struct scsi_host_template *);
604 551
605uint64_t ahc_linux_get_memsize(void); 552uint64_t ahc_linux_get_memsize(void);
606 553
@@ -621,17 +568,6 @@ static __inline void ahc_lockinit(struct ahc_softc *);
621static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 568static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
622static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 569static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
623 570
624/* Lock acquisition and release of the above lock in midlayer entry points. */
625static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *,
626 unsigned long *flags);
627static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *,
628 unsigned long *flags);
629
630/* Lock held during command compeletion to the upper layer */
631static __inline void ahc_done_lockinit(struct ahc_softc *);
632static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags);
633static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags);
634
635/* Lock held during ahc_list manipulation and ahc softc frees */ 571/* Lock held during ahc_list manipulation and ahc softc frees */
636extern spinlock_t ahc_list_spinlock; 572extern spinlock_t ahc_list_spinlock;
637static __inline void ahc_list_lockinit(void); 573static __inline void ahc_list_lockinit(void);
@@ -657,57 +593,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
657} 593}
658 594
659static __inline void 595static __inline void
660ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags)
661{
662 /*
663 * In 2.5.X and some 2.4.X versions, the midlayer takes our
664 * lock just before calling us, so we avoid locking again.
665 * For other kernel versions, the io_request_lock is taken
666 * just before our entry point is called. In this case, we
667 * trade the io_request_lock for our per-softc lock.
668 */
669#if AHC_SCSI_HAS_HOST_LOCK == 0
670 spin_unlock(&io_request_lock);
671 spin_lock(&ahc->platform_data->spin_lock);
672#endif
673}
674
675static __inline void
676ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags)
677{
678#if AHC_SCSI_HAS_HOST_LOCK == 0
679 spin_unlock(&ahc->platform_data->spin_lock);
680 spin_lock(&io_request_lock);
681#endif
682}
683
684static __inline void
685ahc_done_lockinit(struct ahc_softc *ahc)
686{
687 /*
688 * In 2.5.X, our own lock is held during completions.
689 * In previous versions, the io_request_lock is used.
690 * In either case, we can't initialize this lock again.
691 */
692}
693
694static __inline void
695ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
696{
697#if AHC_SCSI_HAS_HOST_LOCK == 0
698 spin_lock_irqsave(&io_request_lock, *flags);
699#endif
700}
701
702static __inline void
703ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
704{
705#if AHC_SCSI_HAS_HOST_LOCK == 0
706 spin_unlock_irqrestore(&io_request_lock, *flags);
707#endif
708}
709
710static __inline void
711ahc_list_lockinit(void) 596ahc_list_lockinit(void)
712{ 597{
713 spin_lock_init(&ahc_list_spinlock); 598 spin_lock_init(&ahc_list_spinlock);
@@ -773,12 +658,6 @@ typedef enum
773} ahc_power_state; 658} ahc_power_state;
774 659
775/**************************** VL/EISA Routines ********************************/ 660/**************************** VL/EISA Routines ********************************/
776#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \
777 && (defined(__i386__) || defined(__alpha__)) \
778 && (!defined(CONFIG_EISA)))
779#define CONFIG_EISA
780#endif
781
782#ifdef CONFIG_EISA 661#ifdef CONFIG_EISA
783extern uint32_t aic7xxx_probe_eisa_vl; 662extern uint32_t aic7xxx_probe_eisa_vl;
784int ahc_linux_eisa_init(void); 663int ahc_linux_eisa_init(void);
@@ -894,22 +773,18 @@ ahc_flush_device_writes(struct ahc_softc *ahc)
894} 773}
895 774
896/**************************** Proc FS Support *********************************/ 775/**************************** Proc FS Support *********************************/
897#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
898int ahc_linux_proc_info(char *, char **, off_t, int, int, int);
899#else
900int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 776int ahc_linux_proc_info(struct Scsi_Host *, char *, char **,
901 off_t, int, int); 777 off_t, int, int);
902#endif
903 778
904/*************************** Domain Validation ********************************/ 779/*************************** Domain Validation ********************************/
905/*********************** Transaction Access Wrappers *************************/ 780/*********************** Transaction Access Wrappers *************************/
906static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 781static __inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t);
907static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 782static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
908static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 783static __inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t);
909static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 784static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
910static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd); 785static __inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd);
911static __inline uint32_t ahc_get_transaction_status(struct scb *); 786static __inline uint32_t ahc_get_transaction_status(struct scb *);
912static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd); 787static __inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd);
913static __inline uint32_t ahc_get_scsi_status(struct scb *); 788static __inline uint32_t ahc_get_scsi_status(struct scb *);
914static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 789static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
915static __inline u_long ahc_get_transfer_length(struct scb *); 790static __inline u_long ahc_get_transfer_length(struct scb *);
@@ -928,7 +803,7 @@ static __inline void ahc_platform_scb_free(struct ahc_softc *ahc,
928static __inline void ahc_freeze_scb(struct scb *scb); 803static __inline void ahc_freeze_scb(struct scb *scb);
929 804
930static __inline 805static __inline
931void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 806void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status)
932{ 807{
933 cmd->result &= ~(CAM_STATUS_MASK << 16); 808 cmd->result &= ~(CAM_STATUS_MASK << 16);
934 cmd->result |= status << 16; 809 cmd->result |= status << 16;
@@ -941,7 +816,7 @@ void ahc_set_transaction_status(struct scb *scb, uint32_t status)
941} 816}
942 817
943static __inline 818static __inline
944void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 819void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
945{ 820{
946 cmd->result &= ~0xFFFF; 821 cmd->result &= ~0xFFFF;
947 cmd->result |= status; 822 cmd->result |= status;
@@ -954,7 +829,7 @@ void ahc_set_scsi_status(struct scb *scb, uint32_t status)
954} 829}
955 830
956static __inline 831static __inline
957uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd) 832uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd)
958{ 833{
959 return ((cmd->result >> 16) & CAM_STATUS_MASK); 834 return ((cmd->result >> 16) & CAM_STATUS_MASK);
960} 835}
@@ -966,7 +841,7 @@ uint32_t ahc_get_transaction_status(struct scb *scb)
966} 841}
967 842
968static __inline 843static __inline
969uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd) 844uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd)
970{ 845{
971 return (cmd->result & 0xFFFF); 846 return (cmd->result & 0xFFFF);
972} 847}