From 3bd271cd260cdd0fa1849144f551f6f040d15dba Mon Sep 17 00:00:00 2001 From: Martin Dalecki Date: Tue, 30 Jul 2002 00:36:33 -0700 Subject: [PATCH] 2.5.29 IDE 108 - typedef unsigned char byte; is finally gone. Everything using it should be just ported to u8 if I missed some place where it still gets used. - Next round of parameter parsing cleanups by Gerald Champagne. Adjusted a bit to harmonize with hd.c. - Move IDE register bitfields declarations over from hdparm.h to ide.h. - Declare constants needed by hd.c directly there. Those are standard values not subject to change and we prefer a bit of code duplication in favour of making the two drivers independant from each other. - Move everything not ioctl related away from hdreg.h to ide.h. This header is in effect not private to the ATA code and should therefore not contain stuff only usefull there. --- include/linux/hdreg.h | 522 +------------------------------------------------- include/linux/ide.h | 485 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 486 insertions(+), 521 deletions(-) (limited to 'include/linux') diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index dcedacb849ea..5ed104e84e43 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -1,280 +1,19 @@ #ifndef _LINUX_HDREG_H #define _LINUX_HDREG_H -/* - * This file contains some defines for the AT-hd-controller. - * Various sources. - */ - -#define HD_IRQ 14 /* the standard disk interrupt */ - -/* ide.c has its own port definitions in "ide.h" */ - -/* Hd controller regs. Ref: IBM AT Bios-listing */ -#define HD_DATA 0x1f0 /* _CTL when writing */ -#define HD_ERROR 0x1f1 /* see err-bits */ -#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ -#define HD_SECTOR 0x1f3 /* starting sector */ -#define HD_LCYL 0x1f4 /* starting cylinder */ -#define HD_HCYL 0x1f5 /* high byte of starting cyl */ -#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ -#define HD_STATUS 0x1f7 /* see status-bits */ -#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */ -#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */ -#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ - -#define HD_CMD 0x3f6 /* used for resets */ -#define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */ - -/* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */ - -/* Bits of HD_STATUS */ -#define ERR_STAT 0x01 -#define INDEX_STAT 0x02 -#define ECC_STAT 0x04 /* Corrected error */ -#define DRQ_STAT 0x08 -#define SEEK_STAT 0x10 -#define SERVICE_STAT SEEK_STAT -#define WRERR_STAT 0x20 -#define READY_STAT 0x40 -#define BUSY_STAT 0x80 - -/* Bits for HD_ERROR */ -#define MARK_ERR 0x01 /* Bad address mark */ -#define TRK0_ERR 0x02 /* couldn't find track 0 */ -#define ABRT_ERR 0x04 /* Command aborted */ -#define MCR_ERR 0x08 /* media change request */ -#define ID_ERR 0x10 /* ID field not found */ -#define MC_ERR 0x20 /* media changed */ -#define ECC_ERR 0x40 /* Uncorrectable ECC error */ -#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ -#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ - -/* - * sector count bits - */ -#define NSEC_CD 0x01 -#define NSEC_IO 0x02 -#define NSEC_REL 0x04 - /* * Command Header sizes for IOCTL commands */ - #define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(u8)) #define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(u8)) -#define IDE_DRIVE_TASK_INVALID -1 -#define IDE_DRIVE_TASK_NO_DATA 0 -#define IDE_DRIVE_TASK_SET_XFER 1 - -#define IDE_DRIVE_TASK_IN 2 - -#define IDE_DRIVE_TASK_OUT 3 -#define IDE_DRIVE_TASK_RAW_WRITE 4 - -struct hd_drive_task_hdr { - u8 feature; - u8 sector_count; - u8 sector_number; - u8 low_cylinder; - u8 high_cylinder; - u8 device_head; -} __attribute__((packed)); - -/* - * Define standard taskfile in/out register - */ -#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE -#define IDE_TASKFILE_STD_IN_FLAGS 0xFE -#define IDE_HOB_STD_OUT_FLAGS 0xC0 -#define IDE_HOB_STD_IN_FLAGS 0xC0 - -#define TASKFILE_INVALID 0x7fff -#define TASKFILE_48 0x8000 - -#define TASKFILE_NO_DATA 0x0000 - -#define TASKFILE_IN 0x0001 -#define TASKFILE_MULTI_IN 0x0002 - -#define TASKFILE_OUT 0x0004 -#define TASKFILE_MULTI_OUT 0x0008 -#define TASKFILE_IN_OUT 0x0010 - -#define TASKFILE_IN_DMA 0x0020 -#define TASKFILE_OUT_DMA 0x0040 -#define TASKFILE_IN_DMAQ 0x0080 -#define TASKFILE_OUT_DMAQ 0x0100 - -#define TASKFILE_P_IN 0x0200 -#define TASKFILE_P_OUT 0x0400 -#define TASKFILE_P_IN_DMA 0x0800 -#define TASKFILE_P_OUT_DMA 0x1000 -#define TASKFILE_P_IN_DMAQ 0x2000 -#define TASKFILE_P_OUT_DMAQ 0x4000 - -/* ATA/ATAPI Commands pre T13 Spec */ -#define WIN_NOP 0x00 -#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */ -#define WIN_SRST 0x08 /* ATAPI soft reset command */ -#define WIN_DEVICE_RESET 0x08 -#define WIN_RESTORE 0x10 -#define WIN_READ 0x20 /* 28-Bit */ -#define WIN_READ_EXT 0x24 /* 48-Bit */ -#define WIN_READDMA_EXT 0x25 /* 48-Bit */ -#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */ -#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */ -#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */ -#define WIN_WRITE 0x30 /* 28-Bit */ -#define WIN_WRITE_EXT 0x34 /* 48-Bit */ -#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */ -#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */ -#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */ -#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */ -#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */ -#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */ -#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */ -#define WIN_VERIFY_EXT 0x42 /* 48-Bit */ -#define WIN_FORMAT 0x50 -#define WIN_INIT 0x60 -#define WIN_SEEK 0x70 -#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */ -#define WIN_DIAGNOSE 0x90 -#define WIN_SPECIFY 0x91 /* set drive geometry translation */ -#define WIN_DOWNLOAD_MICROCODE 0x92 -#define WIN_STANDBYNOW2 0x94 -#define WIN_SETIDLE2 0x97 -#define WIN_CHECKPOWERMODE2 0x98 -#define WIN_SLEEPNOW2 0x99 -#define WIN_PACKETCMD 0xA0 /* Send a packet command. */ -#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */ -#define WIN_QUEUED_SERVICE 0xA2 -#define WIN_SMART 0xB0 /* self-monitoring and reporting */ -#define CFA_ERASE_SECTORS 0xC0 -#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/ -#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */ -#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */ -#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */ -#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */ -#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */ -#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */ -#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */ -#define WIN_GETMEDIASTATUS 0xDA -#define WIN_DOORLOCK 0xDE /* lock door on removable drives */ -#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */ -#define WIN_STANDBYNOW1 0xE0 -#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */ -#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */ -#define WIN_SETIDLE1 0xE3 -#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */ -#define WIN_CHECKPOWERMODE1 0xE5 -#define WIN_SLEEPNOW1 0xE6 -#define WIN_FLUSH_CACHE 0xE7 -#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */ -#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */ -#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */ -#define WIN_MEDIAEJECT 0xED -#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */ -#define WIN_SETFEATURES 0xEF /* set special drive features */ -#define EXABYTE_ENABLE_NEST 0xF0 -#define WIN_SECURITY_SET_PASS 0xF1 -#define WIN_SECURITY_UNLOCK 0xF2 -#define WIN_SECURITY_ERASE_PREPARE 0xF3 -#define WIN_SECURITY_ERASE_UNIT 0xF4 -#define WIN_SECURITY_FREEZE_LOCK 0xF5 -#define WIN_SECURITY_DISABLE 0xF6 -#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */ -#define WIN_SET_MAX 0xF9 -#define DISABLE_SEAGATE 0xFB - -/* WIN_SMART sub-commands */ - -#define SMART_READ_VALUES 0xD0 -#define SMART_READ_THRESHOLDS 0xD1 -#define SMART_AUTOSAVE 0xD2 -#define SMART_SAVE 0xD3 -#define SMART_IMMEDIATE_OFFLINE 0xD4 -#define SMART_READ_LOG_SECTOR 0xD5 -#define SMART_WRITE_LOG_SECTOR 0xD6 -#define SMART_WRITE_THRESHOLDS 0xD7 -#define SMART_ENABLE 0xD8 -#define SMART_DISABLE 0xD9 -#define SMART_STATUS 0xDA -#define SMART_AUTO_OFFLINE 0xDB - -/* Password used in TF4 & TF5 executing SMART commands */ - -#define SMART_LCYL_PASS 0x4F -#define SMART_HCYL_PASS 0xC2 - -/* WIN_SETFEATURES sub-commands */ - -#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */ -#define SETFEATURES_XFER 0x03 /* Set transfer mode */ -# define XFER_UDMA_7 0x47 /* 0100|0111 */ -# define XFER_UDMA_6 0x46 /* 0100|0110 */ -# define XFER_UDMA_5 0x45 /* 0100|0101 */ -# define XFER_UDMA_4 0x44 /* 0100|0100 */ -# define XFER_UDMA_3 0x43 /* 0100|0011 */ -# define XFER_UDMA_2 0x42 /* 0100|0010 */ -# define XFER_UDMA_1 0x41 /* 0100|0001 */ -# define XFER_UDMA_0 0x40 /* 0100|0000 */ -# define XFER_MW_DMA_2 0x22 /* 0010|0010 */ -# define XFER_MW_DMA_1 0x21 /* 0010|0001 */ -# define XFER_MW_DMA_0 0x20 /* 0010|0000 */ -# define XFER_SW_DMA_2 0x12 /* 0001|0010 */ -# define XFER_SW_DMA_1 0x11 /* 0001|0001 */ -# define XFER_SW_DMA_0 0x10 /* 0001|0000 */ -# define XFER_PIO_4 0x0C /* 0000|1100 */ -# define XFER_PIO_3 0x0B /* 0000|1011 */ -# define XFER_PIO_2 0x0A /* 0000|1010 */ -# define XFER_PIO_1 0x09 /* 0000|1001 */ -# define XFER_PIO_0 0x08 /* 0000|1000 */ -# define XFER_PIO_SLOW 0x00 /* 0000|0000 */ -#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */ -#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */ -#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */ -#define SETFEATURES_EN_AAM 0x42 /* Enable Automatic Acoustic Management */ -#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */ -#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */ -#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */ -#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */ -#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */ -#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */ -#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */ -#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */ -#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */ -#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */ -#define SETFEATURES_DIS_AAM 0xC2 /* Disable Automatic Acoustic Management */ -#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */ -#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt */ -#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt */ - -/* WIN_SECURITY sub-commands */ - -#define SECURITY_SET_PASSWORD 0xBA -#define SECURITY_UNLOCK 0xBB -#define SECURITY_ERASE_PREPARE 0xBC -#define SECURITY_ERASE_UNIT 0xBD -#define SECURITY_FREEZE_LOCK 0xBE -#define SECURITY_DISABLE_PASSWORD 0xBF - struct hd_geometry { - u8 heads; - u8 sectors; - u16 cylinders; + __u8 heads; + __u8 sectors; + __u16 cylinders; unsigned long start; }; -/* BIG GEOMETRY - dying, used only by HDIO_GETGEO_BIG_RAW */ -struct hd_big_geometry { - u8 heads; - u8 sectors; - u32 cylinders; - unsigned long start; -}; - /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */ #define HDIO_GETGEO 0x0301 /* get device geometry */ #define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */ @@ -306,263 +45,8 @@ struct hd_big_geometry { #define HDIO_SET_QDMA 0x032e /* change use-qdma flag */ #define HDIO_SET_ADDRESS 0x032f /* change lba addressing modes */ -/* bus states */ -enum { - BUSSTATE_OFF = 0, - BUSSTATE_ON, - BUSSTATE_TRISTATE -}; - /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */ /* 0x330 is reserved - used to be HDIO_GETGEO_BIG */ #define HDIO_GETGEO_BIG_RAW 0x0331 /* */ -#define __NEW_HD_DRIVE_ID - -/* - * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec. - * - * If you change something here, please remember to update fix_driveid() in - * ide/probe.c. - */ -struct hd_driveid { - u16 config; /* lots of obsolete bit flags */ - u16 cyls; /* Obsolete, "physical" cyls */ - u16 reserved2; /* reserved (word 2) */ - u16 heads; /* Obsolete, "physical" heads */ - u16 track_bytes; /* unformatted bytes per track */ - u16 sector_bytes; /* unformatted bytes per sector */ - u16 sectors; /* Obsolete, "physical" sectors per track */ - u16 vendor0; /* vendor unique */ - u16 vendor1; /* vendor unique */ - u16 vendor2; /* Retired vendor unique */ - u8 serial_no[20]; /* 0 = not_specified */ - u16 buf_type; /* Retired */ - u16 buf_size; /* Retired, 512 byte increments - * 0 = not_specified - */ - u16 ecc_bytes; /* for r/w long cmds; 0 = not_specified */ - u8 fw_rev[8]; /* 0 = not_specified */ - char model[40]; /* 0 = not_specified */ - u8 max_multsect; /* 0=not_implemented */ - u8 vendor3; /* vendor unique */ - u16 dword_io; /* 0=not_implemented; 1=implemented */ - u8 vendor4; /* vendor unique */ - u8 capability; /* (upper byte of word 49) - * 3: IORDYsup - * 2: IORDYsw - * 1: LBA - * 0: DMA - */ - u16 reserved50; /* reserved (word 50) */ - u8 vendor5; /* Obsolete, vendor unique */ - u8 tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */ - u8 vendor6; /* Obsolete, vendor unique */ - u8 tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */ - u16 field_valid; /* (word 53) - * 2: ultra_ok word 88 - * 1: eide_ok words 64-70 - * 0: cur_ok words 54-58 - */ - u16 cur_cyls; /* Obsolete, logical cylinders */ - u16 cur_heads; /* Obsolete, l heads */ - u16 cur_sectors; /* Obsolete, l sectors per track */ - u16 cur_capacity0; /* Obsolete, l total sectors on drive */ - u16 cur_capacity1; /* Obsolete, (2 words, misaligned int) */ - u8 multsect; /* current multiple sector count */ - u8 multsect_valid; /* when (bit0==1) multsect is ok */ - u32 lba_capacity; /* Obsolete, total number of sectors */ - u16 dma_1word; /* Obsolete, single-word dma info */ - u16 dma_mword; /* multiple-word dma info */ - u16 eide_pio_modes; /* bits 0:mode3 1:mode4 */ - u16 eide_dma_min; /* min mword dma cycle time (ns) */ - u16 eide_dma_time; /* recommended mword dma cycle time (ns) */ - u16 eide_pio; /* min cycle time (ns), no IORDY */ - u16 eide_pio_iordy; /* min cycle time (ns), with IORDY */ - u16 words69_70[2]; /* reserved words 69-70 - * future command overlap and queuing - */ - /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */ - u16 words71_74[4]; /* reserved words 71-74 - * for IDENTIFY PACKET DEVICE command - */ - u16 queue_depth; /* (word 75) - * 15:5 reserved - * 4:0 Maximum queue depth -1 - */ - u16 words76_79[4]; /* reserved words 76-79 */ - u16 major_rev_num; /* (word 80) */ - u16 minor_rev_num; /* (word 81) */ - u16 command_set_1; /* (word 82) supported - * 15: Obsolete - * 14: NOP command - * 13: READ_BUFFER - * 12: WRITE_BUFFER - * 11: Obsolete - * 10: Host Protected Area - * 9: DEVICE Reset - * 8: SERVICE Interrupt - * 7: Release Interrupt - * 6: look-ahead - * 5: write cache - * 4: PACKET Command - * 3: Power Management Feature Set - * 2: Removable Feature Set - * 1: Security Feature Set - * 0: SMART Feature Set - */ - u16 command_set_2; /* (word 83) - * 15: Shall be ZERO - * 14: Shall be ONE - * 13: FLUSH CACHE EXT - * 12: FLUSH CACHE - * 11: Device Configuration Overlay - * 10: 48-bit Address Feature Set - * 9: Automatic Acoustic Management - * 8: SET MAX security - * 7: reserved 1407DT PARTIES - * 6: SetF sub-command Power-Up - * 5: Power-Up in Standby Feature Set - * 4: Removable Media Notification - * 3: APM Feature Set - * 2: CFA Feature Set - * 1: READ/WRITE DMA QUEUED - * 0: Download MicroCode - */ - u16 cfsse; /* (word 84) - * cmd set-feature supported extensions - * 15: Shall be ZERO - * 14: Shall be ONE - * 13:3 reserved - * 2: Media Serial Number Valid - * 1: SMART selt-test supported - * 0: SMART error logging - */ - u16 cfs_enable_1; /* (word 85) - * command set-feature enabled - * 15: Obsolete - * 14: NOP command - * 13: READ_BUFFER - * 12: WRITE_BUFFER - * 11: Obsolete - * 10: Host Protected Area - * 9: DEVICE Reset - * 8: SERVICE Interrupt - * 7: Release Interrupt - * 6: look-ahead - * 5: write cache - * 4: PACKET Command - * 3: Power Management Feature Set - * 2: Removable Feature Set - * 1: Security Feature Set - * 0: SMART Feature Set - */ - u16 cfs_enable_2; /* (word 86) - * command set-feature enabled - * 15: Shall be ZERO - * 14: Shall be ONE - * 13: FLUSH CACHE EXT - * 12: FLUSH CACHE - * 11: Device Configuration Overlay - * 10: 48-bit Address Feature Set - * 9: Automatic Acoustic Management - * 8: SET MAX security - * 7: reserved 1407DT PARTIES - * 6: SetF sub-command Power-Up - * 5: Power-Up in Standby Feature Set - * 4: Removable Media Notification - * 3: APM Feature Set - * 2: CFA Feature Set - * 1: READ/WRITE DMA QUEUED - * 0: Download MicroCode - */ - u16 csf_default; /* (word 87) - * command set-feature default - * 15: Shall be ZERO - * 14: Shall be ONE - * 13:3 reserved - * 2: Media Serial Number Valid - * 1: SMART selt-test supported - * 0: SMART error logging - */ - u16 dma_ultra; /* (word 88) */ - u16 word89; /* reserved (word 89) */ - u16 word90; /* reserved (word 90) */ - u16 CurAPMvalues; /* current APM values */ - u16 word92; /* reserved (word 92) */ - u16 hw_config; /* hardware config (word 93) - * 15: - * 14: - * 13: - * 12: - * 11: - * 10: - * 9: - * 8: - * 7: - * 6: - * 5: - * 4: - * 3: - * 2: - * 1: - * 0: - */ - u16 acoustic; /* (word 94) - * 15:8 Vendor's recommended value - * 7:0 current value - */ - u16 words95_99[5]; /* reserved words 95-99 */ - u64 lba_capacity_2; /* 48-bit total number of sectors */ - u16 words104_125[22];/* reserved words 104-125 */ - u16 last_lun; /* (word 126) */ - u16 word127; /* (word 127) Feature Set - * Removable Media Notification - * 15:2 reserved - * 1:0 00 = not supported - * 01 = supported - * 10 = reserved - * 11 = reserved - */ - u16 dlf; /* (word 128) - * device lock function - * 15:9 reserved - * 8 security level 1:max 0:high - * 7:6 reserved - * 5 enhanced erase - * 4 expire - * 3 frozen - * 2 locked - * 1 en/disabled - * 0 capability - */ - u16 csfo; /* (word 129) - * current set features options - * 15:4 reserved - * 3: auto reassign - * 2: reverting - * 1: read-look-ahead - * 0: write cache - */ - u16 words130_155[26];/* reserved vendor words 130-155 */ - u16 word156; /* reserved vendor word 156 */ - u16 words157_159[3];/* reserved vendor words 157-159 */ - u16 cfa_power; /* (word 160) CFA Power Mode - * 15 word 160 supported - * 14 reserved - * 13 - * 12 - * 11:0 - */ - u16 words161_175[14];/* Reserved for CFA */ - u16 words176_205[31];/* Current Media Serial Number */ - u16 words206_254[48];/* reserved words 206-254 */ - u16 integrity_word; /* (word 255) - * 15:8 Checksum - * 7:0 Signature - */ -} __attribute__((packed)); - -#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ - #endif diff --git a/include/linux/ide.h b/include/linux/ide.h index 8a41b3b2e74a..239e2a99105b 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,460 @@ * "No user-serviceable parts" beyond this point *****************************************************************************/ -typedef unsigned char byte; /* used everywhere */ + +/* ATA/ATAPI Commands pre T13 Spec */ +#define WIN_NOP 0x00 +#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */ +#define WIN_SRST 0x08 /* ATAPI soft reset command */ +#define WIN_DEVICE_RESET 0x08 +#define WIN_RESTORE 0x10 +#define WIN_READ 0x20 /* 28-Bit */ +#define WIN_READ_EXT 0x24 /* 48-Bit */ +#define WIN_READDMA_EXT 0x25 /* 48-Bit */ +#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */ +#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */ +#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */ +#define WIN_WRITE 0x30 /* 28-Bit */ +#define WIN_WRITE_EXT 0x34 /* 48-Bit */ +#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */ +#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */ +#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */ +#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */ +#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */ +#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */ +#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */ +#define WIN_VERIFY_EXT 0x42 /* 48-Bit */ +#define WIN_FORMAT 0x50 +#define WIN_INIT 0x60 +#define WIN_SEEK 0x70 +#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */ +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91 /* set drive geometry translation */ +#define WIN_DOWNLOAD_MICROCODE 0x92 +#define WIN_STANDBYNOW2 0x94 +#define WIN_SETIDLE2 0x97 +#define WIN_CHECKPOWERMODE2 0x98 +#define WIN_SLEEPNOW2 0x99 +#define WIN_PACKETCMD 0xA0 /* Send a packet command. */ +#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */ +#define WIN_QUEUED_SERVICE 0xA2 +#define WIN_SMART 0xB0 /* self-monitoring and reporting */ +#define CFA_ERASE_SECTORS 0xC0 +#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/ +#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */ +#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */ +#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */ +#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */ +#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */ +#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */ +#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */ +#define WIN_GETMEDIASTATUS 0xDA +#define WIN_DOORLOCK 0xDE /* lock door on removable drives */ +#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */ +#define WIN_STANDBYNOW1 0xE0 +#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */ +#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */ +#define WIN_SETIDLE1 0xE3 +#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */ +#define WIN_CHECKPOWERMODE1 0xE5 +#define WIN_SLEEPNOW1 0xE6 +#define WIN_FLUSH_CACHE 0xE7 +#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */ +#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */ +#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */ +#define WIN_MEDIAEJECT 0xED +#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */ +#define WIN_SETFEATURES 0xEF /* set special drive features */ +#define EXABYTE_ENABLE_NEST 0xF0 +#define WIN_SECURITY_SET_PASS 0xF1 +#define WIN_SECURITY_UNLOCK 0xF2 +#define WIN_SECURITY_ERASE_PREPARE 0xF3 +#define WIN_SECURITY_ERASE_UNIT 0xF4 +#define WIN_SECURITY_FREEZE_LOCK 0xF5 +#define WIN_SECURITY_DISABLE 0xF6 +#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */ +#define WIN_SET_MAX 0xF9 +#define DISABLE_SEAGATE 0xFB + +/* WIN_SMART sub-commands */ + +#define SMART_READ_VALUES 0xD0 +#define SMART_READ_THRESHOLDS 0xD1 +#define SMART_AUTOSAVE 0xD2 +#define SMART_SAVE 0xD3 +#define SMART_IMMEDIATE_OFFLINE 0xD4 +#define SMART_READ_LOG_SECTOR 0xD5 +#define SMART_WRITE_LOG_SECTOR 0xD6 +#define SMART_WRITE_THRESHOLDS 0xD7 +#define SMART_ENABLE 0xD8 +#define SMART_DISABLE 0xD9 +#define SMART_STATUS 0xDA +#define SMART_AUTO_OFFLINE 0xDB + +/* Password used in TF4 & TF5 executing SMART commands */ + +#define SMART_LCYL_PASS 0x4F +#define SMART_HCYL_PASS 0xC2 + +/* WIN_SETFEATURES sub-commands */ + +#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */ + +#define SETFEATURES_XFER 0x03 /* Set transfer mode */ +# define XFER_UDMA_7 0x47 /* 0100|0111 */ +# define XFER_UDMA_6 0x46 /* 0100|0110 */ +# define XFER_UDMA_5 0x45 /* 0100|0101 */ +# define XFER_UDMA_4 0x44 /* 0100|0100 */ +# define XFER_UDMA_3 0x43 /* 0100|0011 */ +# define XFER_UDMA_2 0x42 /* 0100|0010 */ +# define XFER_UDMA_1 0x41 /* 0100|0001 */ +# define XFER_UDMA_0 0x40 /* 0100|0000 */ +# define XFER_MW_DMA_2 0x22 /* 0010|0010 */ +# define XFER_MW_DMA_1 0x21 /* 0010|0001 */ +# define XFER_MW_DMA_0 0x20 /* 0010|0000 */ +# define XFER_SW_DMA_2 0x12 /* 0001|0010 */ +# define XFER_SW_DMA_1 0x11 /* 0001|0001 */ +# define XFER_SW_DMA_0 0x10 /* 0001|0000 */ +# define XFER_PIO_4 0x0C /* 0000|1100 */ +# define XFER_PIO_3 0x0B /* 0000|1011 */ +# define XFER_PIO_2 0x0A /* 0000|1010 */ +# define XFER_PIO_1 0x09 /* 0000|1001 */ +# define XFER_PIO_0 0x08 /* 0000|1000 */ +# define XFER_PIO_SLOW 0x00 /* 0000|0000 */ + +#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */ +#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */ +#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */ +#define SETFEATURES_EN_AAM 0x42 /* Enable Automatic Acoustic Management */ +#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */ +#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */ +#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */ +#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */ +#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */ +#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */ +#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */ +#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */ +#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */ +#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */ +#define SETFEATURES_DIS_AAM 0xC2 /* Disable Automatic Acoustic Management */ +#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */ +#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt */ +#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt */ + +/* WIN_SECURITY sub-commands */ + +#define SECURITY_SET_PASSWORD 0xBA +#define SECURITY_UNLOCK 0xBB +#define SECURITY_ERASE_PREPARE 0xBC +#define SECURITY_ERASE_UNIT 0xBD +#define SECURITY_FREEZE_LOCK 0xBE +#define SECURITY_DISABLE_PASSWORD 0xBF + + +/* Taskfile related constants. + */ +#define IDE_DRIVE_TASK_INVALID -1 +#define IDE_DRIVE_TASK_NO_DATA 0 +#define IDE_DRIVE_TASK_SET_XFER 1 + +#define IDE_DRIVE_TASK_IN 2 + +#define IDE_DRIVE_TASK_OUT 3 +#define IDE_DRIVE_TASK_RAW_WRITE 4 + +struct hd_drive_task_hdr { + u8 feature; + u8 sector_count; + u8 sector_number; + u8 low_cylinder; + u8 high_cylinder; + u8 device_head; +} __attribute__((packed)); + +/* + * Define standard taskfile in/out register + */ +#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE +#define IDE_TASKFILE_STD_IN_FLAGS 0xFE +#define IDE_HOB_STD_OUT_FLAGS 0xC0 +#define IDE_HOB_STD_IN_FLAGS 0xC0 + +#define TASKFILE_INVALID 0x7fff +#define TASKFILE_48 0x8000 + +#define TASKFILE_NO_DATA 0x0000 + +#define TASKFILE_IN 0x0001 +#define TASKFILE_MULTI_IN 0x0002 + +#define TASKFILE_OUT 0x0004 +#define TASKFILE_MULTI_OUT 0x0008 +#define TASKFILE_IN_OUT 0x0010 + +#define TASKFILE_IN_DMA 0x0020 +#define TASKFILE_OUT_DMA 0x0040 +#define TASKFILE_IN_DMAQ 0x0080 +#define TASKFILE_OUT_DMAQ 0x0100 + +#define TASKFILE_P_IN 0x0200 +#define TASKFILE_P_OUT 0x0400 +#define TASKFILE_P_IN_DMA 0x0800 +#define TASKFILE_P_OUT_DMA 0x1000 +#define TASKFILE_P_IN_DMAQ 0x2000 +#define TASKFILE_P_OUT_DMAQ 0x4000 + +/* bus states */ +enum { + BUSSTATE_OFF = 0, + BUSSTATE_ON, + BUSSTATE_TRISTATE +}; + +/* + * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec. + * + * If you change something here, please remember to update fix_driveid() in + * ide/probe.c. + */ +struct hd_driveid { + u16 config; /* lots of obsolete bit flags */ + u16 cyls; /* Obsolete, "physical" cyls */ + u16 reserved2; /* reserved (word 2) */ + u16 heads; /* Obsolete, "physical" heads */ + u16 track_bytes; /* unformatted bytes per track */ + u16 sector_bytes; /* unformatted bytes per sector */ + u16 sectors; /* Obsolete, "physical" sectors per track */ + u16 vendor0; /* vendor unique */ + u16 vendor1; /* vendor unique */ + u16 vendor2; /* Retired vendor unique */ + u8 serial_no[20]; /* 0 = not_specified */ + u16 buf_type; /* Retired */ + u16 buf_size; /* Retired, 512 byte increments + * 0 = not_specified + */ + u16 ecc_bytes; /* for r/w long cmds; 0 = not_specified */ + u8 fw_rev[8]; /* 0 = not_specified */ + char model[40]; /* 0 = not_specified */ + u8 max_multsect; /* 0=not_implemented */ + u8 vendor3; /* vendor unique */ + u16 dword_io; /* 0=not_implemented; 1=implemented */ + u8 vendor4; /* vendor unique */ + u8 capability; /* (upper byte of word 49) + * 3: IORDYsup + * 2: IORDYsw + * 1: LBA + * 0: DMA + */ + u16 reserved50; /* reserved (word 50) */ + u8 vendor5; /* Obsolete, vendor unique */ + u8 tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */ + u8 vendor6; /* Obsolete, vendor unique */ + u8 tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */ + u16 field_valid; /* (word 53) + * 2: ultra_ok word 88 + * 1: eide_ok words 64-70 + * 0: cur_ok words 54-58 + */ + u16 cur_cyls; /* Obsolete, logical cylinders */ + u16 cur_heads; /* Obsolete, l heads */ + u16 cur_sectors; /* Obsolete, l sectors per track */ + u16 cur_capacity0; /* Obsolete, l total sectors on drive */ + u16 cur_capacity1; /* Obsolete, (2 words, misaligned int) */ + u8 multsect; /* current multiple sector count */ + u8 multsect_valid; /* when (bit0==1) multsect is ok */ + u32 lba_capacity; /* Obsolete, total number of sectors */ + u16 dma_1word; /* Obsolete, single-word dma info */ + u16 dma_mword; /* multiple-word dma info */ + u16 eide_pio_modes; /* bits 0:mode3 1:mode4 */ + u16 eide_dma_min; /* min mword dma cycle time (ns) */ + u16 eide_dma_time; /* recommended mword dma cycle time (ns) */ + u16 eide_pio; /* min cycle time (ns), no IORDY */ + u16 eide_pio_iordy; /* min cycle time (ns), with IORDY */ + u16 words69_70[2]; /* reserved words 69-70 + * future command overlap and queuing + */ + /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */ + u16 words71_74[4]; /* reserved words 71-74 + * for IDENTIFY PACKET DEVICE command + */ + u16 queue_depth; /* (word 75) + * 15:5 reserved + * 4:0 Maximum queue depth -1 + */ + u16 words76_79[4]; /* reserved words 76-79 */ + u16 major_rev_num; /* (word 80) */ + u16 minor_rev_num; /* (word 81) */ + u16 command_set_1; /* (word 82) supported + * 15: Obsolete + * 14: NOP command + * 13: READ_BUFFER + * 12: WRITE_BUFFER + * 11: Obsolete + * 10: Host Protected Area + * 9: DEVICE Reset + * 8: SERVICE Interrupt + * 7: Release Interrupt + * 6: look-ahead + * 5: write cache + * 4: PACKET Command + * 3: Power Management Feature Set + * 2: Removable Feature Set + * 1: Security Feature Set + * 0: SMART Feature Set + */ + u16 command_set_2; /* (word 83) + * 15: Shall be ZERO + * 14: Shall be ONE + * 13: FLUSH CACHE EXT + * 12: FLUSH CACHE + * 11: Device Configuration Overlay + * 10: 48-bit Address Feature Set + * 9: Automatic Acoustic Management + * 8: SET MAX security + * 7: reserved 1407DT PARTIES + * 6: SetF sub-command Power-Up + * 5: Power-Up in Standby Feature Set + * 4: Removable Media Notification + * 3: APM Feature Set + * 2: CFA Feature Set + * 1: READ/WRITE DMA QUEUED + * 0: Download MicroCode + */ + u16 cfsse; /* (word 84) + * cmd set-feature supported extensions + * 15: Shall be ZERO + * 14: Shall be ONE + * 13:3 reserved + * 2: Media Serial Number Valid + * 1: SMART selt-test supported + * 0: SMART error logging + */ + u16 cfs_enable_1; /* (word 85) + * command set-feature enabled + * 15: Obsolete + * 14: NOP command + * 13: READ_BUFFER + * 12: WRITE_BUFFER + * 11: Obsolete + * 10: Host Protected Area + * 9: DEVICE Reset + * 8: SERVICE Interrupt + * 7: Release Interrupt + * 6: look-ahead + * 5: write cache + * 4: PACKET Command + * 3: Power Management Feature Set + * 2: Removable Feature Set + * 1: Security Feature Set + * 0: SMART Feature Set + */ + u16 cfs_enable_2; /* (word 86) + * command set-feature enabled + * 15: Shall be ZERO + * 14: Shall be ONE + * 13: FLUSH CACHE EXT + * 12: FLUSH CACHE + * 11: Device Configuration Overlay + * 10: 48-bit Address Feature Set + * 9: Automatic Acoustic Management + * 8: SET MAX security + * 7: reserved 1407DT PARTIES + * 6: SetF sub-command Power-Up + * 5: Power-Up in Standby Feature Set + * 4: Removable Media Notification + * 3: APM Feature Set + * 2: CFA Feature Set + * 1: READ/WRITE DMA QUEUED + * 0: Download MicroCode + */ + u16 csf_default; /* (word 87) + * command set-feature default + * 15: Shall be ZERO + * 14: Shall be ONE + * 13:3 reserved + * 2: Media Serial Number Valid + * 1: SMART selt-test supported + * 0: SMART error logging + */ + u16 dma_ultra; /* (word 88) */ + u16 word89; /* reserved (word 89) */ + u16 word90; /* reserved (word 90) */ + u16 CurAPMvalues; /* current APM values */ + u16 word92; /* reserved (word 92) */ + u16 hw_config; /* hardware config (word 93) + * 15: + * 14: + * 13: + * 12: + * 11: + * 10: + * 9: + * 8: + * 7: + * 6: + * 5: + * 4: + * 3: + * 2: + * 1: + * 0: + */ + u16 acoustic; /* (word 94) + * 15:8 Vendor's recommended value + * 7:0 current value + */ + u16 words95_99[5]; /* reserved words 95-99 */ + u64 lba_capacity_2; /* 48-bit total number of sectors */ + u16 words104_125[22];/* reserved words 104-125 */ + u16 last_lun; /* (word 126) */ + u16 word127; /* (word 127) Feature Set + * Removable Media Notification + * 15:2 reserved + * 1:0 00 = not supported + * 01 = supported + * 10 = reserved + * 11 = reserved + */ + u16 dlf; /* (word 128) + * device lock function + * 15:9 reserved + * 8 security level 1:max 0:high + * 7:6 reserved + * 5 enhanced erase + * 4 expire + * 3 frozen + * 2 locked + * 1 en/disabled + * 0 capability + */ + u16 csfo; /* (word 129) + * current set features options + * 15:4 reserved + * 3: auto reassign + * 2: reverting + * 1: read-look-ahead + * 0: write cache + */ + u16 words130_155[26];/* reserved vendor words 130-155 */ + u16 word156; /* reserved vendor word 156 */ + u16 words157_159[3];/* reserved vendor words 157-159 */ + u16 cfa_power; /* (word 160) CFA Power Mode + * 15 word 160 supported + * 14 reserved + * 13 + * 12 + * 11:0 + */ + u16 words161_175[14];/* Reserved for CFA */ + u16 words176_205[31];/* Current Media Serial Number */ + u16 words206_254[48];/* reserved words 206-254 */ + u16 integrity_word; /* (word 255) + * 15:8 Checksum + * 7:0 Signature + */ +} __attribute__((packed)); + +#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ /* * Probably not wise to fiddle with these @@ -105,6 +557,35 @@ enum { #define GET_ALTSTAT() IN_BYTE(drive->channel->io_ports[IDE_CONTROL_OFFSET]) #define GET_FEAT() IN_BYTE(IDE_NSECTOR_REG) +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define SERVICE_STAT SEEK_STAT +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* Command aborted */ +#define MCR_ERR 0x08 /* media change request */ +#define ID_ERR 0x10 /* ID field not found */ +#define MC_ERR 0x20 /* media changed */ +#define ECC_ERR 0x40 /* Uncorrectable ECC error */ +#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ +#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ + +/* + * sector count bits + */ +#define NSEC_CD 0x01 +#define NSEC_IO 0x02 +#define NSEC_REL 0x04 + #define BAD_R_STAT (BUSY_STAT | ERR_STAT) #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) #define BAD_STAT (BAD_R_STAT | DRQ_STAT) -- cgit v1.2.3 From c57f6caedf36f9849d2d77e074ae2f0c500f2b68 Mon Sep 17 00:00:00 2001 From: Martin Dalecki Date: Tue, 30 Jul 2002 00:37:06 -0700 Subject: [PATCH] 2.5.29 IDE 109 - Include first cut by Adam J. Richter on proper lock protection for tuning functions. - Rename ide_register_subdriver() to ata_register_device() and ide_unregister_subdriver() accordingly to ata_unregister_device(), since this is reflecting better what those functions are about. - Remove tons of "curicum vite" style useless documentation here and there. --- Documentation/ide.txt | 50 +++++- drivers/ide/ali14xx.c | 6 +- drivers/ide/dtc2278.c | 7 +- drivers/ide/ht6560b.c | 15 +- drivers/ide/ide-cd.c | 4 +- drivers/ide/ide-disk.c | 6 +- drivers/ide/ide-floppy.c | 6 +- drivers/ide/ide-tape.c | 409 ++--------------------------------------------- drivers/ide/it8172.c | 3 - drivers/ide/main.c | 25 +-- drivers/ide/opti621.c | 11 +- drivers/ide/qd65xx.c | 78 ++------- drivers/scsi/ide-scsi.c | 32 +--- include/linux/ide.h | 14 +- 14 files changed, 111 insertions(+), 555 deletions(-) (limited to 'include/linux') diff --git a/Documentation/ide.txt b/Documentation/ide.txt index 9da199ed4108..3adb7cabfbcd 100644 --- a/Documentation/ide.txt +++ b/Documentation/ide.txt @@ -1,9 +1,6 @@ - - Information regarding the Enhanced IDE drive in Linux 2.5 - ============================================================================== @@ -301,6 +298,53 @@ There may be more options than shown -- use the source, Luke! Everything else is rejected with a "BAD OPTION" message. +================================================================================ + +IDE ATAPI streaming tape driver +------------------------------- + +This driver is a part of the Linux ide driver and works in co-operation +with linux/drivers/block/ide.c. + +The driver, in co-operation with ide.c, basically traverses the +request-list for the block device interface. The character device +interface, on the other hand, creates new requests, adds them +to the request-list of the block device, and waits for their completion. + +Pipelined operation mode is now supported on both reads and writes. + +The block device major and minor numbers are determined from the +tape's relative position in the ide interfaces, as explained in ide.c. + +The character device interface consists of the following devices: + + ht0 major 37, minor 0 first IDE tape, rewind on close. + ht1 major 37, minor 1 second IDE tape, rewind on close. + ... + nht0 major 37, minor 128 first IDE tape, no rewind on close. + nht1 major 37, minor 129 second IDE tape, no rewind on close. + ... + +Run linux/scripts/MAKEDEV.ide to create the above entries. + +The general magnetic tape commands compatible interface, as defined by +include/linux/mtio.h, is accessible through the character device. + +General ide driver configuration options, such as the interrupt-unmask +flag, can be configured by issuing an ioctl to the block device interface, +as any other ide device. + +Our own ide-tape ioctl's can be issued to either the block device or +the character device interface. + +Maximal throughput with minimal bus load will usually be achieved in the +following scenario: + + 1. ide-tape is operating in the pipelined operation mode. + 2. No buffering is performed by the user backup program. + + + ================================================================================ Some Terminology diff --git a/drivers/ide/ali14xx.c b/drivers/ide/ali14xx.c index 9d2e97c47d36..bf0600ed7ede 100644 --- a/drivers/ide/ali14xx.c +++ b/drivers/ide/ali14xx.c @@ -107,13 +107,14 @@ static inline void out_reg(u8 data, u8 reg) * Set PIO mode for the specified drive. * This function computes timing parameters * and sets controller registers accordingly. + * It assumes IRQ's are disabled or at least that no other process will + * attempt to access the IDE registers concurrently. */ static void ali14xx_tune_drive(struct ata_device *drive, u8 pio) { int drive_num; int time1, time2; u8 param1, param2, param3, param4; - unsigned long flags; struct ata_timing *t; if (pio == 255) @@ -140,15 +141,12 @@ static void ali14xx_tune_drive(struct ata_device *drive, u8 pio) /* stuff timing parameters into controller registers */ drive_num = (drive->channel->index << 1) + drive->select.b.unit; - save_flags(flags); /* all CPUs */ - cli(); /* all CPUs */ outb_p(reg_on, base_port); out_reg(param1, reg_tab[drive_num].reg1); out_reg(param2, reg_tab[drive_num].reg2); out_reg(param3, reg_tab[drive_num].reg3); out_reg(param4, reg_tab[drive_num].reg4); outb_p(reg_off, base_port); - restore_flags(flags); /* all CPUs */ } /* diff --git a/drivers/ide/dtc2278.c b/drivers/ide/dtc2278.c index 8d947231d2ab..61583d9c8001 100644 --- a/drivers/ide/dtc2278.c +++ b/drivers/ide/dtc2278.c @@ -66,21 +66,18 @@ static void sub22 (char b, char c) } } +/* Assumes IRQ's are disabled or at least that no other process will + attempt to access the IDE registers concurrently. */ static void tune_dtc2278(struct ata_device *drive, u8 pio) { - unsigned long flags; - pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO) - XFER_PIO_0; if (pio >= 3) { - save_flags(flags); /* all CPUs */ - cli(); /* all CPUs */ /* * This enables PIO mode4 (3?) on the first interface */ sub22(1,0xc3); sub22(0,0xa0); - restore_flags(flags); /* all CPUs */ } else { /* we don't know how to set it back again.. */ } diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c index 34207cd5d911..4594368da382 100644 --- a/drivers/ide/ht6560b.c +++ b/drivers/ide/ht6560b.c @@ -249,12 +249,8 @@ static u8 ht_pio2timings(struct ata_device *drive, u8 pio) */ static void ht_set_prefetch(struct ata_device *drive, u8 state) { - unsigned long flags; int t = HT_PREFETCH_MODE << 8; - save_flags (flags); /* all CPUs */ - cli(); /* all CPUs */ - /* * Prefetch mode and unmask irq seems to conflict */ @@ -267,16 +263,16 @@ static void ht_set_prefetch(struct ata_device *drive, u8 state) drive->channel->no_unmask = 0; } - restore_flags (flags); /* all CPUs */ - #ifdef DEBUG printk("ht6560b: drive %s prefetch mode %sabled\n", drive->name, (state ? "en" : "dis")); #endif } +/* Assumes IRQ's are disabled or at least that no other process will attempt to + * access the IDE registers concurrently. + */ static void tune_ht6560b(struct ata_device *drive, u8 pio) { - unsigned long flags; u8 timing; switch (pio) { @@ -288,14 +284,9 @@ static void tune_ht6560b(struct ata_device *drive, u8 pio) timing = ht_pio2timings(drive, pio); - save_flags (flags); /* all CPUs */ - cli(); /* all CPUs */ - drive->drive_data &= 0xff00; drive->drive_data |= timing; - restore_flags (flags); /* all CPUs */ - #ifdef DEBUG printk("ht6560b: drive %s tuned to pio mode %#x timing=%#x\n", drive->name, pio, timing); #endif diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index bec62fc38f17..574895510c0e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -2915,7 +2915,7 @@ int ide_cdrom_cleanup(struct ata_device *drive) struct cdrom_info *info = drive->driver_data; struct cdrom_device_info *devinfo = &info->devinfo; - if (ide_unregister_subdriver (drive)) + if (ata_unregister_device(drive)) return 1; if (info->buffer != NULL) kfree(info->buffer); @@ -2974,7 +2974,7 @@ static void ide_cdrom_attach(struct ata_device *drive) printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); return; } - if (ide_register_subdriver (drive, &ide_cdrom_driver)) { + if (ata_register_device(drive, &ide_cdrom_driver)) { printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", drive->name); kfree (info); return; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 4070de3d2832..ccd271701974 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -1279,7 +1279,7 @@ static int idedisk_cleanup(struct ata_device *drive) printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", drive->name); } - ret = ide_unregister_subdriver(drive); + ret = ata_unregister_device(drive); /* FIXME: This is killing the kernel with BUG 185 at asm/spinlocks.h * horribly. Check whatever we did REGISTER the device properly @@ -1471,8 +1471,8 @@ static void idedisk_attach(struct ata_device *drive) if (req[0] != '\0' && strcmp(req, "ide-disk")) return; - if (ide_register_subdriver(drive, &idedisk_driver)) { - printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name); + if (ata_register_device(drive, &idedisk_driver)) { + printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", drive->name); return; } diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index b7a82140f6f5..4651a5319935 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1723,10 +1723,10 @@ static int idefloppy_cleanup(struct ata_device *drive) { idefloppy_floppy_t *floppy = drive->driver_data; - if (ide_unregister_subdriver (drive)) + if (ata_unregister_device(drive)) return 1; drive->driver_data = NULL; - kfree (floppy); + kfree(floppy); return 0; } @@ -1780,7 +1780,7 @@ static void idefloppy_attach(struct ata_device *drive) drive->name); return; } - if (ide_register_subdriver(drive, &idefloppy_driver)) { + if (ata_register_device(drive, &idefloppy_driver)) { printk(KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name); kfree (floppy); return; diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index be2abfe9c871..ab4ddba56fee 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -7,401 +7,18 @@ * * It is hereby placed under the terms of the GNU general public license. * (See linux/COPYING). - */ - -/* - * BIG FAT FIXME: clean tape->spinlock locking --bzolnier - */ - -/* - * IDE ATAPI streaming tape driver. - * - * This driver is a part of the Linux ide driver and works in co-operation - * with linux/drivers/block/ide.c. - * - * The driver, in co-operation with ide.c, basically traverses the - * request-list for the block device interface. The character device - * interface, on the other hand, creates new requests, adds them - * to the request-list of the block device, and waits for their completion. - * - * Pipelined operation mode is now supported on both reads and writes. - * - * The block device major and minor numbers are determined from the - * tape's relative position in the ide interfaces, as explained in ide.c. - * - * The character device interface consists of the following devices: - * - * ht0 major 37, minor 0 first IDE tape, rewind on close. - * ht1 major 37, minor 1 second IDE tape, rewind on close. - * ... - * nht0 major 37, minor 128 first IDE tape, no rewind on close. - * nht1 major 37, minor 129 second IDE tape, no rewind on close. - * ... - * - * Run linux/scripts/MAKEDEV.ide to create the above entries. - * - * The general magnetic tape commands compatible interface, as defined by - * include/linux/mtio.h, is accessible through the character device. - * - * General ide driver configuration options, such as the interrupt-unmask - * flag, can be configured by issuing an ioctl to the block device interface, - * as any other ide device. - * - * Our own ide-tape ioctl's can be issued to either the block device or - * the character device interface. - * - * Maximal throughput with minimal bus load will usually be achieved in the - * following scenario: - * - * 1. ide-tape is operating in the pipelined operation mode. - * 2. No buffering is performed by the user backup program. - * - * Testing was done with a 2 GB CONNER CTMA 4000 IDE ATAPI Streaming Tape Drive. - * - * Ver 0.1 Nov 1 95 Pre-working code :-) - * Ver 0.2 Nov 23 95 A short backup (few megabytes) and restore procedure - * was successful ! (Using tar cvf ... on the block - * device interface). - * A longer backup resulted in major swapping, bad - * overall Linux performance and eventually failed as - * we received non serial read-ahead requests from the - * buffer cache. - * Ver 0.3 Nov 28 95 Long backups are now possible, thanks to the - * character device interface. Linux's responsiveness - * and performance doesn't seem to be much affected - * from the background backup procedure. - * Some general mtio.h magnetic tape operations are - * now supported by our character device. As a result, - * popular tape utilities are starting to work with - * ide tapes :-) - * The following configurations were tested: - * 1. An IDE ATAPI TAPE shares the same interface - * and irq with an IDE ATAPI CDROM. - * 2. An IDE ATAPI TAPE shares the same interface - * and irq with a normal IDE disk. - * Both configurations seemed to work just fine ! - * However, to be on the safe side, it is meanwhile - * recommended to give the IDE TAPE its own interface - * and irq. - * The one thing which needs to be done here is to - * add a "request postpone" feature to ide.c, - * so that we won't have to wait for the tape to finish - * performing a long media access (DSC) request (such - * as a rewind) before we can access the other device - * on the same interface. This effect doesn't disturb - * normal operation most of the time because read/write - * requests are relatively fast, and once we are - * performing one tape r/w request, a lot of requests - * from the other device can be queued and ide.c will - * service all of them after this single tape request. - * Ver 1.0 Dec 11 95 Integrated into Linux 1.3.46 development tree. - * On each read / write request, we now ask the drive - * if we can transfer a constant number of bytes - * (a parameter of the drive) only to its buffers, - * without causing actual media access. If we can't, - * we just wait until we can by polling the DSC bit. - * This ensures that while we are not transferring - * more bytes than the constant referred to above, the - * interrupt latency will not become too high and - * we won't cause an interrupt timeout, as happened - * occasionally in the previous version. - * While polling for DSC, the current request is - * postponed and ide.c is free to handle requests from - * the other device. This is handled transparently to - * ide.c. The hwgroup locking method which was used - * in the previous version was removed. - * Use of new general features which are provided by - * ide.c for use with atapi devices. - * (Programming done by Mark Lord) - * Few potential bug fixes (Again, suggested by Mark) - * Single character device data transfers are now - * not limited in size, as they were before. - * We are asking the tape about its recommended - * transfer unit and send a larger data transfer - * as several transfers of the above size. - * For best results, use an integral number of this - * basic unit (which is shown during driver - * initialization). I will soon add an ioctl to get - * this important parameter. - * Our data transfer buffer is allocated on startup, - * rather than before each data transfer. This should - * ensure that we will indeed have a data buffer. - * Ver 1.1 Dec 14 95 Fixed random problems which occurred when the tape - * shared an interface with another device. - * (poll_for_dsc was a complete mess). - * Removed some old (non-active) code which had - * to do with supporting buffer cache originated - * requests. - * The block device interface can now be opened, so - * that general ide driver features like the unmask - * interrupts flag can be selected with an ioctl. - * This is the only use of the block device interface. - * New fast pipelined operation mode (currently only on - * writes). When using the pipelined mode, the - * throughput can potentially reach the maximum - * tape supported throughput, regardless of the - * user backup program. On my tape drive, it sometimes - * boosted performance by a factor of 2. Pipelined - * mode is enabled by default, but since it has a few - * downfalls as well, you may want to disable it. - * A short explanation of the pipelined operation mode - * is available below. - * Ver 1.2 Jan 1 96 Eliminated pipelined mode race condition. - * Added pipeline read mode. As a result, restores - * are now as fast as backups. - * Optimized shared interface behavior. The new behavior - * typically results in better IDE bus efficiency and - * higher tape throughput. - * Pre-calculation of the expected read/write request - * service time, based on the tape's parameters. In - * the pipelined operation mode, this allows us to - * adjust our polling frequency to a much lower value, - * and thus to dramatically reduce our load on Linux, - * without any decrease in performance. - * Implemented additional mtio.h operations. - * The recommended user block size is returned by - * the MTIOCGET ioctl. - * Additional minor changes. - * Ver 1.3 Feb 9 96 Fixed pipelined read mode bug which prevented the - * use of some block sizes during a restore procedure. - * The character device interface will now present a - * continuous view of the media - any mix of block sizes - * during a backup/restore procedure is supported. The - * driver will buffer the requests internally and - * convert them to the tape's recommended transfer - * unit, making performance almost independent of the - * chosen user block size. - * Some improvements in error recovery. - * By cooperating with ide-dma.c, bus mastering DMA can - * now sometimes be used with IDE tape drives as well. - * Bus mastering DMA has the potential to dramatically - * reduce the CPU's overhead when accessing the device, - * and can be enabled by using hdparm -d1 on the tape's - * block device interface. For more info, read the - * comments in ide-dma.c. - * Ver 1.4 Mar 13 96 Fixed serialize support. - * Ver 1.5 Apr 12 96 Fixed shared interface operation, broken in 1.3.85. - * Fixed pipelined read mode inefficiency. - * Fixed nasty null dereferencing bug. - * Ver 1.6 Aug 16 96 Fixed FPU usage in the driver. - * Fixed end of media bug. - * Ver 1.7 Sep 10 96 Minor changes for the CONNER CTT8000-A model. - * Ver 1.8 Sep 26 96 Attempt to find a better balance between good - * interactive response and high system throughput. - * Ver 1.9 Nov 5 96 Automatically cross encountered filemarks rather - * than requiring an explicit FSF command. - * Abort pending requests at end of media. - * MTTELL was sometimes returning incorrect results. - * Return the real block size in the MTIOCGET ioctl. - * Some error recovery bug fixes. - * Ver 1.10 Nov 5 96 Major reorganization. - * Reduced CPU overhead a bit by eliminating internal - * bounce buffers. - * Added module support. - * Added multiple tape drives support. - * Added partition support. - * Rewrote DSC handling. - * Some portability fixes. - * Removed ide-tape.h. - * Additional minor changes. - * Ver 1.11 Dec 2 96 Bug fix in previous DSC timeout handling. - * Use ide_stall_queue() for DSC overlap. - * Use the maximum speed rather than the current speed - * to compute the request service time. - * Ver 1.12 Dec 7 97 Fix random memory overwriting and/or last block data - * corruption, which could occur if the total number - * of bytes written to the tape was not an integral - * number of tape blocks. - * Add support for INTERRUPT DRQ devices. - * Ver 1.13 Jan 2 98 Add "speed == 0" work-around for HP COLORADO 5GB - * Ver 1.14 Dec 30 98 Partial fixes for the Sony/AIWA tape drives. - * Replace cli()/sti() with hwgroup spinlocks. - * Ver 1.15 Mar 25 99 Fix SMP race condition by replacing hwgroup - * spinlock with private per-tape spinlock. - * Ver 1.16 Sep 1 99 Add OnStream tape support. - * Abort read pipeline on EOD. - * Wait for the tape to become ready in case it returns - * "in the process of becoming ready" on open(). - * Fix zero padding of the last written block in - * case the tape block size is larger than PAGE_SIZE. - * Decrease the default disconnection time to tn. - * Ver 1.16e Oct 3 99 Minor fixes. - * Ver 1.16e1 Oct 13 99 Patches by Arnold Niessen, - * niessen@iae.nl / arnold.niessen@philips.com - * GO-1) Undefined code in idetape_read_position - * according to Gadi's email - * AJN-1) Minor fix asc == 11 should be asc == 0x11 - * in idetape_issue_packet_command (did effect - * debugging output only) - * AJN-2) Added more debugging output, and - * added ide-tape: where missing. I would also - * like to add tape->name where possible - * AJN-3) Added different debug_level's - * via /proc/ide/hdc/settings - * "debug_level" determines amount of debugging output; - * can be changed using /proc/ide/hdx/settings - * 0 : almost no debugging output - * 1 : 0+output errors only - * 2 : 1+output all sensekey/asc - * 3 : 2+follow all chrdev related procedures - * 4 : 3+follow all procedures - * 5 : 4+include pc_stack rq_stack info - * 6 : 5+USE_COUNT updates - * AJN-4) Fixed timeout for retension in idetape_queue_pc_tail - * from 5 to 10 minutes - * AJN-5) Changed maximum number of blocks to skip when - * reading tapes with multiple consecutive write - * errors from 100 to 1000 in idetape_get_logical_blk - * Proposed changes to code: - * 1) output "logical_blk_num" via /proc - * 2) output "current_operation" via /proc - * 3) Either solve or document the fact that `mt rewind' is - * required after reading from /dev/nhtx to be - * able to rmmod the idetape module; - * Also, sometimes an application finishes but the - * device remains `busy' for some time. Same cause ? - * Proposed changes to release-notes: - * 4) write a simple `quickstart' section in the - * release notes; I volunteer if you don't want to - * 5) include a pointer to video4linux in the doc - * to stimulate video applications - * 6) release notes lines 331 and 362: explain what happens - * if the application data rate is higher than 1100 KB/s; - * similar approach to lower-than-500 kB/s ? - * 7) 6.6 Comparison; wouldn't it be better to allow different - * strategies for read and write ? - * Wouldn't it be better to control the tape buffer - * contents instead of the bandwidth ? - * 8) line 536: replace will by would (if I understand - * this section correctly, a hypothetical and unwanted situation - * is being described) - * Ver 1.16f Dec 15 99 Change place of the secondary OnStream header frames. - * Ver 1.17 Nov 2000 / Jan 2001 Marcel Mol, marcel@mesa.nl - * - Add idetape_onstream_mode_sense_tape_parameter_page - * function to get tape capacity in frames: tape->capacity. - * - Add support for DI-50 drives( or any DI- drive). - * - 'workaround' for read error/blank block arround block 3000. - * - Implement Early warning for end of media for Onstream. - * - Cosmetic code changes for readability. - * - Idetape_position_tape should not use SKIP bit during - * Onstream read recovery. - * - Add capacity, logical_blk_num and first/last_frame_position - * to /proc/ide/hd?/settings. - * - Module use count was gone in the Linux 2.4 driver. - * Ver 1.17a Apr 2001 Willem Riede osst@riede.org - * - Get drive's actual block size from mode sense block descriptor - * - Limit size of pipeline - * - * Here are some words from the first releases of hd.c, which are quoted - * in ide.c and apply here as well: - * - * | Special care is recommended. Have Fun! - * - */ - -/* - * An overview of the pipelined operation mode. - * - * In the pipelined write mode, we will usually just add requests to our - * pipeline and return immediately, before we even start to service them. The - * user program will then have enough time to prepare the next request while - * we are still busy servicing previous requests. In the pipelined read mode, - * the situation is similar - we add read-ahead requests into the pipeline, - * before the user even requested them. - * - * The pipeline can be viewed as a "safety net" which will be activated when - * the system load is high and prevents the user backup program from keeping up - * with the current tape speed. At this point, the pipeline will get - * shorter and shorter but the tape will still be streaming at the same speed. - * Assuming we have enough pipeline stages, the system load will hopefully - * decrease before the pipeline is completely empty, and the backup program - * will be able to "catch up" and refill the pipeline again. - * - * When using the pipelined mode, it would be best to disable any type of - * buffering done by the user program, as ide-tape already provides all the - * benefits in the kernel, where it can be done in a more efficient way. - * As we will usually not block the user program on a request, the most - * efficient user code will then be a simple read-write-read-... cycle. - * Any additional logic will usually just slow down the backup process. - * - * Using the pipelined mode, I get a constant over 400 KBps throughput, - * which seems to be the maximum throughput supported by my tape. - * - * However, there are some downfalls: - * - * 1. We use memory (for data buffers) in proportional to the number - * of pipeline stages (each stage is about 26 KB with my tape). - * 2. In the pipelined write mode, we cheat and postpone error codes - * to the user task. In read mode, the actual tape position - * will be a bit further than the last requested block. - * - * Concerning (1): - * - * 1. We allocate stages dynamically only when we need them. When - * we don't need them, we don't consume additional memory. In - * case we can't allocate stages, we just manage without them - * (at the expense of decreased throughput) so when Linux is - * tight in memory, we will not pose additional difficulties. - * - * 2. The maximum number of stages (which is, in fact, the maximum - * amount of memory) which we allocate is limited by the compile - * time parameter IDETAPE_MAX_PIPELINE_STAGES. * - * 3. The maximum number of stages is a controlled parameter - We - * don't start from the user defined maximum number of stages - * but from the lower IDETAPE_MIN_PIPELINE_STAGES (again, we - * will not even allocate this amount of stages if the user - * program can't handle the speed). We then implement a feedback - * loop which checks if the pipeline is empty, and if it is, we - * increase the maximum number of stages as necessary until we - * reach the optimum value which just manages to keep the tape - * busy with minimum allocated memory or until we reach - * IDETAPE_MAX_PIPELINE_STAGES. + * Contributors: * - * Concerning (2): - * - * In pipelined write mode, ide-tape can not return accurate error codes - * to the user program since we usually just add the request to the - * pipeline without waiting for it to be serviced. In case an error - * occurs, I will report it on the next user request. - * - * In the pipelined read mode, subsequent read requests or forward - * filemark spacing will perform correctly, as we preserve all blocks - * and filemarks which we encountered during our excess read-ahead. - * - * For accurate tape positioning and error reporting, disabling - * pipelined mode might be the best option. - * - * You can enable/disable/tune the pipelined operation mode by adjusting - * the compile time parameters below. + * Oct 1999 Arnold Niessen, , + * Nov 2000, Jan 2001 Marcel Mol, + * Apr 2001 Willem Riede, */ /* - * Possible improvements. - * - * 1. Support for the ATAPI overlap protocol. - * - * In order to maximize bus throughput, we currently use the DSC - * overlap method which enables ide.c to service requests from the - * other device while the tape is busy executing a command. The - * DSC overlap method involves polling the tape's status register - * for the DSC bit, and servicing the other device while the tape - * isn't ready. - * - * In the current QIC development standard (December 1995), - * it is recommended that new tape drives will *in addition* - * implement the ATAPI overlap protocol, which is used for the - * same purpose - efficient use of the IDE bus, but is interrupt - * driven and thus has much less CPU overhead. - * - * ATAPI overlap is likely to be supported in most new ATAPI - * devices, including new ATAPI cdroms, and thus provides us - * a method by which we can achieve higher throughput when - * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. + * FIXME: clean tape->spinlock locking --bzolnier */ -#define IDETAPE_VERSION "1.17a" - #include #include #include @@ -446,6 +63,7 @@ #define OS_DATA_STARTFRAME1 20 #define OS_DATA_ENDFRAME1 2980 + /* * partition */ @@ -5893,18 +5511,17 @@ static int idetape_cleanup(struct ata_device *drive) int minor = tape->minor; unsigned long flags; - save_flags (flags); /* all CPUs (overkill?) */ - cli(); /* all CPUs (overkill?) */ + spin_lock_irqsave (&tape->spinlock, flags); /* overkill? */ if (test_bit (IDETAPE_BUSY, &tape->flags) || tape->first_stage != NULL || tape->merge_stage_size || drive->usage) { - restore_flags(flags); /* all CPUs (overkill?) */ + spin_unlock_irqrestore(&tape->spinlock, flags); return 1; } idetape_chrdevs[minor].drive = NULL; - restore_flags (flags); /* all CPUs (overkill?) */ + spin_unlock_irqrestore(&tape->spinlock, flags); MOD_DEC_USE_COUNT; - ide_unregister_subdriver (drive); + ata_unregister_device(drive); drive->driver_data = NULL; devfs_unregister (tape->de_r); devfs_unregister (tape->de_n); @@ -5993,11 +5610,11 @@ static void idetape_attach(struct ata_device *drive) } tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL); if (!tape) { - printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); + printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); return; } - if (ide_register_subdriver (drive, &idetape_driver)) { - printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name); + if (ata_register_device(drive, &idetape_driver)) { + printk(KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name); kfree (tape); return; } diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c index 838718764c4f..cc38ee5d8843 100644 --- a/drivers/ide/it8172.c +++ b/drivers/ide/it8172.c @@ -89,10 +89,7 @@ static void it8172_tune_drive (struct ata_device *drive, u8 pio) drive_enables |= 0x0006; } - save_flags(flags); - cli(); pci_write_config_word(dev, master_port, master_data); - restore_flags(flags); } #if defined(CONFIG_BLK_DEV_IDEDMA) && defined(CONFIG_IT8172_TUNING) diff --git a/drivers/ide/main.c b/drivers/ide/main.c index 13ad9816c5e0..5649e68fb97e 100644 --- a/drivers/ide/main.c +++ b/drivers/ide/main.c @@ -365,7 +365,7 @@ void ide_unregister(struct ata_channel *ch) if (ata_ops(drive)->cleanup(drive)) goto abort; } else - ide_unregister_subdriver(drive); + ata_unregister_device(drive); } } ch->present = 0; @@ -1037,10 +1037,7 @@ done: /****************************************************************************/ -/* - * This is in fact registering a device not a driver. - */ -int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driver) +int ata_register_device(struct ata_device *drive, struct ata_operations *driver) { unsigned long flags; @@ -1052,12 +1049,9 @@ int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driv return 1; } - /* FIXME: This will be pushed to the drivers! Thus allowing us to - * save one parameter here and to separate this out. - */ drive->driver = driver; - spin_unlock_irqrestore(&ide_lock, flags); + /* Default autotune or requested autotune */ if (drive->autotune != 2) { struct ata_channel *ch = drive->channel; @@ -1071,11 +1065,13 @@ int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driv * PARANOIA!!! */ + spin_lock_irqsave(ch->lock, flags); udma_enable(drive, 0, 0); ch->udma_setup(drive, ch->modes_map); #ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT udma_tcq_enable(drive, 1); #endif + spin_unlock_irqrestore(ch->lock, flags); } /* Only CD-ROMs and tape drives support DSC overlap. But only @@ -1103,13 +1099,8 @@ int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driv * * FIXME: Check whatever we maybe don't call it twice!. */ -int ide_unregister_subdriver(struct ata_device *drive) +int ata_unregister_device(struct ata_device *drive) { -#if 0 - if (__MOD_IN_USE(ata_ops(drive)->owner)) - return 1; -#endif - if (drive->usage || drive->busy || !ata_ops(drive)) return 1; @@ -1181,8 +1172,8 @@ EXPORT_SYMBOL(ide_lock); devfs_handle_t ide_devfs_handle; -EXPORT_SYMBOL(ide_register_subdriver); -EXPORT_SYMBOL(ide_unregister_subdriver); +EXPORT_SYMBOL(ata_register_device); +EXPORT_SYMBOL(ata_unregister_device); EXPORT_SYMBOL(ata_revalidate); EXPORT_SYMBOL(ide_register_hw); EXPORT_SYMBOL(ide_unregister); diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c index c141def6663d..723695b953f3 100644 --- a/drivers/ide/opti621.c +++ b/drivers/ide/opti621.c @@ -244,13 +244,15 @@ static void compute_clocks(int pio, pio_clocks_t *clks) } -/* Main tune procedure, called from tuneproc. */ +/* Main tune procedure, called from tuneproc. + Assumes IRQ's are disabled or at least that no other process will + attempt to access the IDE registers concurrently. +*/ static void opti621_tune_drive(struct ata_device *drive, u8 pio) { /* primary and secondary drives share some registers, * so we have to program both drives */ - unsigned long flags; u8 pio1, pio2; pio_clocks_t first, second; int ax, drdy; @@ -281,9 +283,6 @@ static void opti621_tune_drive(struct ata_device *drive, u8 pio) hwif->name, ax, second.data_time, second.recovery_time, drdy); #endif - save_flags(flags); /* all CPUs */ - cli(); /* all CPUs */ - reg_base = hwif->io_ports[IDE_DATA_OFFSET]; outb(0xc0, reg_base+CNTRL_REG); /* allow Register-B */ outb(0xff, reg_base+5); /* hmm, setupvic.exe does this ;-) */ @@ -306,8 +305,6 @@ static void opti621_tune_drive(struct ata_device *drive, u8 pio) write_reg(misc, MISC_REG); /* set address setup, DRDY timings, */ /* and read prefetch for both drives */ - - restore_flags(flags); /* all CPUs */ } /* diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c index 633a75950d60..3ed266424233 100644 --- a/drivers/ide/qd65xx.c +++ b/drivers/ide/qd65xx.c @@ -1,8 +1,6 @@ /* * Copyright (C) 1996-2001 Linus Torvalds & author (see below) - */ - -/* + * * Version 0.03 Cleaned auto-tune, added probe * Version 0.04 Added second channel tuning * Version 0.05 Enhanced tuning ; added qd6500 support @@ -81,36 +79,12 @@ * bit 5 : status, but of what ? * bit 6 : always set 1 by dos driver * bit 7 : set 1 for non-ATAPI devices on primary port - * (maybe read-ahead and post-write buffer ?) + * (maybe read-ahead and post-write buffer ?) */ static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ -static void qd_write_reg(u8 content, unsigned int reg) -{ - unsigned long flags; - - save_flags(flags); /* all CPUs */ - cli(); /* all CPUs */ - outb(content,reg); - restore_flags(flags); /* all CPUs */ -} - -static u8 __init qd_read_reg(unsigned int reg) -{ - unsigned long flags; - u8 read; - - save_flags(flags); /* all CPUs */ - cli(); /* all CPUs */ - read = inb(reg); - restore_flags(flags); /* all CPUs */ - return read; -} - /* - * qd_select: - * * This routine is invoked from ide.c to prepare for access to a given drive. */ @@ -120,12 +94,10 @@ static void qd_select(struct ata_device *drive) (QD_TIMREG(drive) & 0x02); if (timings[index] != QD_TIMING(drive)) - qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); + outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); } /* - * qd6500_compute_timing - * * computes the timing value where * lower nibble represents active time, in count of VLB clocks * upper nibble represents recovery time, in count of VLB clocks @@ -147,8 +119,6 @@ static u8 qd6500_compute_timing(struct ata_channel *hwif, int active_time, int r } /* - * qd6580_compute_timing - * * idem for qd6580 */ @@ -161,8 +131,6 @@ static u8 qd6580_compute_timing(int active_time, int recovery_time) } /* - * qd_find_disk_type - * * tries to find timing from dos driver's table */ @@ -187,8 +155,6 @@ static int qd_find_disk_type(struct ata_device *drive, } /* - * qd_timing_ok: - * * check whether timings don't conflict */ @@ -201,8 +167,6 @@ static int qd_timing_ok(struct ata_device drives[]) } /* - * qd_set_timing: - * * records the timing, and enables selectproc as needed */ @@ -221,10 +185,6 @@ static void qd_set_timing(struct ata_device *drive, u8 timing) printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); } -/* - * qd6500_tune_drive - */ - static void qd6500_tune_drive(struct ata_device *drive, u8 pio) { int active_time = 175; @@ -242,10 +202,6 @@ static void qd6500_tune_drive(struct ata_device *drive, u8 pio) qd_set_timing(drive, qd6500_compute_timing(drive->channel, active_time, recovery_time)); } -/* - * qd6580_tune_drive - */ - static void qd6580_tune_drive(struct ata_device *drive, u8 pio) { struct ata_timing *t; @@ -291,7 +247,7 @@ static void qd6580_tune_drive(struct ata_device *drive, u8 pio) } if (!drive->channel->unit && drive->type != ATA_DISK) { - qd_write_reg(0x5f, QD_CONTROL_PORT); + outb(0x5f, QD_CONTROL_PORT); printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO and post-write buffer on %s.\n", drive->name, drive->channel->name); } @@ -299,8 +255,6 @@ static void qd6580_tune_drive(struct ata_device *drive, u8 pio) } /* - * qd_testreg - * * tests if the given port is a register */ @@ -329,8 +283,6 @@ static int __init qd_testreg(int port) } /* - * qd_setup: - * * called to setup an ata channel : adjusts attributes & links for tuning */ @@ -349,8 +301,6 @@ void __init qd_setup(int unit, int base, int config, unsigned int data0, unsigne } /* - * qd_unsetup: - * * called to unsetup an ata channel : back to default values, unlinks tuning */ void __init qd_unsetup(int unit) { @@ -368,13 +318,13 @@ void __init qd_unsetup(int unit) { if (tuneproc == (void *) qd6500_tune_drive) { // will do it for both - qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); + outb(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); } else if (tuneproc == (void *) qd6580_tune_drive) { if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { - qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); - qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); + outb(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); + outb(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); } else { - qd_write_reg(unit?QD6580_DEF_DATA2:QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); + outb(unit ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); } } else { printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); @@ -383,8 +333,6 @@ void __init qd_unsetup(int unit) { } /* - * qd_probe: - * * looks at the specified baseport, and if qd found, registers & initialises it * return 1 if another qd may be probed */ @@ -394,7 +342,7 @@ int __init qd_probe(int base) u8 config; int unit; - config = qd_read_reg(QD_CONFIG_PORT); + config = inb(QD_CONFIG_PORT); if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) return 1; @@ -425,7 +373,7 @@ int __init qd_probe(int base) /* qd6580 found */ - control = qd_read_reg(QD_CONTROL_PORT); + control = inb(QD_CONTROL_PORT); printk(KERN_NOTICE "qd6580 at %#x\n", base); printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", config, control, QD_ID3); @@ -434,7 +382,7 @@ int __init qd_probe(int base) /* secondary disabled */ printk(KERN_INFO "%s: qd6580: single IDE board\n", ide_hwifs[unit].name); qd_setup(unit, base, config | (control << 8), QD6580_DEF_DATA, QD6580_DEF_DATA2, &qd6580_tune_drive); - qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT); + outb(QD_DEF_CONTR, QD_CONTROL_PORT); return 1; } else { @@ -443,7 +391,7 @@ int __init qd_probe(int base) qd_setup(ATA_PRIMARY, base, config | (control << 8), QD6580_DEF_DATA, QD6580_DEF_DATA, &qd6580_tune_drive); qd_setup(ATA_SECONDARY, base, config | (control << 8), QD6580_DEF_DATA2, QD6580_DEF_DATA2, &qd6580_tune_drive); - qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT); + outb(QD_DEF_CONTR, QD_CONTROL_PORT); return 0; /* no other qd65xx possible */ } @@ -454,8 +402,6 @@ int __init qd_probe(int base) #ifndef MODULE /* - * init_qd65xx: - * * called by ide.c when parsing command line */ diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index f05c5f37b1ed..fac559f73abe 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -1,33 +1,12 @@ /* * Copyright (C) 1996 - 1999 Gadi Oxman - */ -/* + * * Emulation of a SCSI host adapter for IDE ATAPI devices. * * With this driver, one can use the Linux SCSI drivers instead of the * native IDE ATAPI drivers. - * - * Ver 0.1 Dec 3 96 Initial version. - * Ver 0.2 Jan 26 97 Fixed bug in cleanup_module() and added emulation - * of MODE_SENSE_6/MODE_SELECT_6 for cdroms. Thanks - * to Janos Farkas for pointing this out. - * Avoid using bitfields in structures for m68k. - * Added Scatter/Gather and DMA support. - * Ver 0.4 Dec 7 97 Add support for ATAPI PD/CD drives. - * Use variable timeout for each command. - * Ver 0.5 Jan 2 98 Fix previous PD/CD support. - * Allow disabling of SCSI-6 to SCSI-10 transformation. - * Ver 0.6 Jan 27 98 Allow disabling of SCSI command translation layer - * for access through /dev/sg. - * Fix MODE_SENSE_6/MODE_SELECT_6/INQUIRY translation. - * Ver 0.7 Dec 04 98 Ignore commands where lun != 0 to avoid multiple - * detection of devices with CONFIG_SCSI_MULTI_LUN - * Ver 0.8 Feb 05 99 Optical media need translation too. Reverse 0.7. - * Ver 0.9 Jul 04 99 Fix a bug in SG_SET_TRANSFORM. */ -#define IDESCSI_VERSION "0.9" - #include #include #include @@ -495,9 +474,8 @@ static void idescsi_release(struct inode *inode, struct file *filp, struct ata_d static Scsi_Host_Template template; static int idescsi_cleanup (struct ata_device *drive) { - if (ide_unregister_subdriver (drive)) { + if (ata_unregister_device(drive)) return 1; - } scsi_unregister_host(&template); return 0; @@ -762,7 +740,7 @@ static void idescsi_attach(struct ata_device *drive) host = scsi_register(&template, sizeof(idescsi_scsi_t)); if (!host) { - printk (KERN_ERR + printk(KERN_ERR "ide-scsi: %s: Can't allocate a scsi host structure\n", drive->name); return; @@ -771,8 +749,8 @@ static void idescsi_attach(struct ata_device *drive) host->max_lun = drive->last_lun + 1; host->max_id = 1; - if (ide_register_subdriver(drive, &ata_ops)) { - printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name); + if (ata_register_device(drive, &ata_ops)) { + printk(KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name); scsi_unregister(host); return; } diff --git a/include/linux/ide.h b/include/linux/ide.h index 239e2a99105b..4dd795f055e6 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1146,23 +1146,23 @@ extern struct block_device_operations ide_fops[]; */ extern int ideprobe_init(void); #ifdef CONFIG_BLK_DEV_IDEDISK -extern int idedisk_init (void); +extern int idedisk_init(void); #endif #ifdef CONFIG_BLK_DEV_IDECD -extern int ide_cdrom_init (void); +extern int ide_cdrom_init(void); #endif #ifdef CONFIG_BLK_DEV_IDETAPE -extern int idetape_init (void); +extern int idetape_init(void); #endif #ifdef CONFIG_BLK_DEV_IDEFLOPPY -extern int idefloppy_init (void); +extern int idefloppy_init(void); #endif #ifdef CONFIG_BLK_DEV_IDESCSI -extern int idescsi_init (void); +extern int idescsi_init(void); #endif -extern int ide_register_subdriver(struct ata_device *, struct ata_operations *); -extern int ide_unregister_subdriver(struct ata_device *drive); +extern int ata_register_device(struct ata_device *, struct ata_operations *); +extern int ata_unregister_device(struct ata_device *drive); extern int ata_revalidate(kdev_t i_rdev); extern void ide_driver_module(void); -- cgit v1.2.3