Commit 87689e36 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.8 IDE 36

- Consolidate ide_choose_drive() and choose_drive() in to one function.

- Remove sector data byteswpapping support. Byte-swapping the data is supported
   on the file-system level where applicable.  Byte-swapped interfaces are
   supported on a lower level anyway. And finally it was used inconsistently.

- Eliminate taskfile_input_data() and taskfile_output_data(). This allowed us
   to split up ideproc and eliminate the ugly action switch as well as the
   corresponding defines.

- Remove tons of unnecessary typedefs from ide.h

- Prepate the PIO read write code for soon overhaul.

- Misc small bits here and there :-).
parent 5202f40d
......@@ -272,13 +272,17 @@ init_e100_ide (void)
printk("ide: ETRAX 100LX built-in ATA DMA controller\n");
/* first initialize the channel interface data */
for(h = 0; h < MAX_HWIFS; h++) {
struct ata_channel *hwif = &ide_hwifs[h];
hwif->chipset = ide_etrax100;
hwif->tuneproc = &tune_e100_ide;
hwif->dmaproc = &e100_dmaproc;
hwif->ideproc = &e100_ideproc;
hwif->ata_read = e100_ide_input_data;
hwif->ata_write = e100_ide_input_data;
hwif->atapi_read = e100_atapi_read;
hwif->atapi_write = e100_atapi_write;
}
/* actually reset and configure the etrax100 ide/ata interface */
......@@ -375,12 +379,12 @@ static etrax_dma_descr mydescr;
* so if an odd bytecount is specified, be sure that there's at least one
* extra byte allocated for the buffer.
*/
static void
e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
static void
e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
{
ide_ioreg_t data_reg = IDE_DATA_REG;
D(printk("atapi_input_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
D(printk("atapi_read, dreg 0x%x, buffer 0x%x, count %d\n",
data_reg, buffer, bytecount));
if(bytecount & 1) {
......@@ -454,12 +458,12 @@ e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount
#endif
}
static void
e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
static void
e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
{
ide_ioreg_t data_reg = IDE_DATA_REG;
D(printk("atapi_output_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
D(printk("atapi_write, dreg 0x%x, buffer 0x%x, count %d\n",
data_reg, buffer, bytecount));
if(bytecount & 1) {
......@@ -544,7 +548,7 @@ e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecoun
static void
e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
{
e100_atapi_input_bytes(drive, buffer, wcount << 2);
e100_atapi_read(drive, buffer, wcount << 2);
}
/*
......@@ -553,7 +557,7 @@ e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
static void
e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
{
e100_atapi_output_bytes(drive, buffer, wcount << 2);
e100_atapi_write(drive, buffer, wcount << 2);
}
/*
......@@ -570,11 +574,11 @@ e100_ideproc (ide_ide_action_t func, ide_drive_t *drive,
case ideproc_ide_output_data:
e100_ide_input_data(drive, buffer, length);
break;
case ideproc_atapi_input_bytes:
e100_atapi_input_bytes(drive, buffer, length);
case ideproc_atapi_read:
e100_atapi_read(drive, buffer, length);
break;
case ideproc_atapi_output_bytes:
e100_atapi_output_bytes(drive, buffer, length);
case ideproc_atapi_write:
e100_atapi_write(drive, buffer, length);
break;
default:
printk("e100_ideproc: unsupported func %d!\n", func);
......
......@@ -791,7 +791,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
ide_set_handler(drive, handler, timeout, cdrom_timer_expiry);
/* Send the command to the device. */
atapi_output_bytes(drive, cmd, CDROM_PACKET_SIZE);
atapi_write(drive, cmd, CDROM_PACKET_SIZE);
return ide_started;
}
......@@ -830,7 +830,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
/* Read the data into the buffer. */
dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE;
while (sectors_to_buffer > 0) {
atapi_input_bytes (drive, dest, SECTOR_SIZE);
atapi_read(drive, dest, SECTOR_SIZE);
--sectors_to_buffer;
--sectors_to_transfer;
++info->nsectors_buffered;
......@@ -840,7 +840,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
/* Throw away any remaining data. */
while (sectors_to_transfer > 0) {
char dum[SECTOR_SIZE];
atapi_input_bytes (drive, dum, sizeof (dum));
atapi_read(drive, dum, sizeof (dum));
--sectors_to_transfer;
}
}
......@@ -866,7 +866,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
and quit this request. */
while (len > 0) {
int dum = 0;
atapi_output_bytes (drive, &dum, sizeof (dum));
atapi_write(drive, &dum, sizeof (dum));
len -= sizeof (dum);
}
} else if (ireason == 1) {
......@@ -963,7 +963,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
while (nskip > 0) {
/* We need to throw away a sector. */
char dum[SECTOR_SIZE];
atapi_input_bytes (drive, dum, sizeof (dum));
atapi_read(drive, dum, SECTOR_SIZE);
--rq->current_nr_sectors;
--nskip;
......@@ -994,7 +994,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
/* Read this_transfer sectors
into the current buffer. */
while (this_transfer > 0) {
atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE);
atapi_read(drive, rq->buffer, SECTOR_SIZE);
rq->buffer += SECTOR_SIZE;
--rq->nr_sectors;
--rq->current_nr_sectors;
......@@ -1290,13 +1290,14 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
/* The drive wants to be written to. */
if ((ireason & 3) == 0) {
/* Transfer the data. */
atapi_output_bytes (drive, pc->buffer, thislen);
atapi_write(drive, pc->buffer, thislen);
/* If we haven't moved enough data to satisfy the drive,
add some padding. */
while (len > thislen) {
int dum = 0;
atapi_output_bytes (drive, &dum, sizeof (dum));
atapi_write(drive, &dum, sizeof (dum));
len -= sizeof (dum);
}
......@@ -1307,15 +1308,14 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
/* Same drill for reading. */
else if ((ireason & 3) == 2) {
/* Transfer the data. */
atapi_input_bytes (drive, pc->buffer, thislen);
atapi_read(drive, pc->buffer, thislen);
/* If we haven't moved enough data to satisfy the drive,
add some padding. */
while (len > thislen) {
int dum = 0;
atapi_input_bytes (drive, &dum, sizeof (dum));
atapi_read(drive, &dum, sizeof (dum));
len -= sizeof (dum);
}
......@@ -1458,7 +1458,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire
and quit this request. */
while (len > 0) {
int dum = 0;
atapi_output_bytes(drive, &dum, sizeof(dum));
atapi_write(drive, &dum, sizeof(dum));
len -= sizeof(dum);
}
} else {
......@@ -1549,7 +1549,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
this_transfer = MIN(sectors_to_transfer,rq->current_nr_sectors);
while (this_transfer > 0) {
atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE);
atapi_write(drive, rq->buffer, SECTOR_SIZE);
rq->buffer += SECTOR_SIZE;
--rq->nr_sectors;
--rq->current_nr_sectors;
......
......@@ -1051,7 +1051,6 @@ static void idedisk_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "bios_head", SETTING_RW, -1, -1, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL);
ide_add_setting(drive, "bios_sect", SETTING_RW, -1, -1, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL);
ide_add_setting(drive, "address", SETTING_RW, HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, TYPE_INTA, 0, 2, 1, 1, &drive->addressing, set_lba_addressing);
ide_add_setting(drive, "bswap", SETTING_READ, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->bswap, NULL);
ide_add_setting(drive, "multcount", id ? SETTING_RW : SETTING_READ, HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, TYPE_BYTE, 0, id ? id->max_multsect : 0, 1, 1, &drive->mult_count, set_multcount);
ide_add_setting(drive, "nowerr", SETTING_RW, HDIO_GET_NOWERR, HDIO_SET_NOWERR, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr);
ide_add_setting(drive, "lun", SETTING_RW, -1, -1, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL);
......@@ -1198,11 +1197,11 @@ static void idedisk_setup(ide_drive_t *drive)
if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
(!drive->forced_geom) && drive->bios_sect && drive->bios_head)
drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
printk (KERN_INFO "%s: %ld sectors", drive->name, capacity);
printk(KERN_INFO "%s: %ld sectors", drive->name, capacity);
/* Give size in megabytes (MB), not mebibytes (MiB). */
/* We compute the exact rounded value, avoiding overflow. */
printk (" (%ld MB)", (capacity - capacity/625 + 974)/1950);
printk(" (%ld MB)", (capacity - capacity/625 + 974)/1950);
/* Only print cache size when it was specified */
if (id->buf_size)
......@@ -1213,7 +1212,7 @@ static void idedisk_setup(ide_drive_t *drive)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (drive->using_dma)
(void) drive->channel->dmaproc(ide_dma_verbose, drive);
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif
printk("\n");
drive->mult_count = 0;
......@@ -1223,15 +1222,17 @@ static void idedisk_setup(ide_drive_t *drive)
id->multsect_valid = id->multsect ? 1 : 0;
drive->mult_req = id->multsect_valid ? id->max_multsect : INITIAL_MULT_COUNT;
drive->special.b.set_multmode = drive->mult_req ? 1 : 0;
#else /* original, pre IDE-NFG, per request of AC */
#else
/* original, pre IDE-NFG, per request of AC */
drive->mult_req = INITIAL_MULT_COUNT;
if (drive->mult_req > id->max_multsect)
drive->mult_req = id->max_multsect;
if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect))
drive->special.b.set_multmode = 1;
#endif /* CONFIG_IDEDISK_MULTI_MODE */
#endif
}
drive->no_io_32bit = id->dword_io ? 1 : 0;
if (drive->id->cfs_enable_2 & 0x3000)
write_cache(drive, (id->cfs_enable_2 & 0x3000));
probe_lba_addressing(drive, 1);
......
......@@ -130,8 +130,8 @@ int ide_driveid_update (ide_drive_t *drive)
__restore_flags(flags); /* local CPU only */
return 0;
}
ata_input_data(drive, id, SECTOR_WORDS);
(void) GET_STAT(); /* clear drive IRQ */
ata_read(drive, id, SECTOR_WORDS);
GET_STAT(); /* clear drive IRQ */
ide__sti(); /* local CPU only */
__restore_flags(flags); /* local CPU only */
ide_fix_driveid(id);
......@@ -285,7 +285,7 @@ int ide_config_drive_speed (ide_drive_t *drive, byte speed)
enable_irq(hwif->irq);
if (error) {
(void) ide_dump_status(drive, "set_drive_speed_status", stat);
ide_dump_status(drive, "set_drive_speed_status", stat);
return error;
}
......
......@@ -717,7 +717,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
return;
}
count = IDEFLOPPY_MIN (bio->bi_size - pc->b_count, bcount);
atapi_input_bytes (drive, bio_data(bio) + pc->b_count, count);
atapi_read(drive, bio_data(bio) + pc->b_count, count);
bcount -= count; pc->b_count += count;
}
}
......@@ -744,7 +744,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
return;
}
count = IDEFLOPPY_MIN (pc->b_count, bcount);
atapi_output_bytes (drive, pc->b_data, count);
atapi_write(drive, pc->b_data, count);
bcount -= count; pc->b_data += count; pc->b_count -= count;
}
}
......@@ -979,12 +979,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
}
if (test_bit (PC_WRITING, &pc->flags)) {
if (pc->buffer != NULL)
atapi_output_bytes (drive,pc->current_position,bcount.all); /* Write the current buffer */
atapi_write(drive,pc->current_position,bcount.all); /* Write the current buffer */
else
idefloppy_output_buffers (drive, pc, bcount.all);
} else {
if (pc->buffer != NULL)
atapi_input_bytes (drive,pc->current_position,bcount.all); /* Read the current buffer */
atapi_read(drive,pc->current_position,bcount.all); /* Read the current buffer */
else
idefloppy_input_buffers (drive, pc, bcount.all);
}
......@@ -1020,7 +1020,7 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* Set the interrupt routine */
atapi_output_bytes (drive, floppy->pc->c, 12); /* Send the actual packet */
atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */
return ide_started;
}
......@@ -1042,7 +1042,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive)
{
idefloppy_floppy_t *floppy = drive->driver_data;
atapi_output_bytes (drive, floppy->pc->c, 12); /* Send the actual packet */
atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */
return IDEFLOPPY_WAIT_CMD; /* Timeout for the packet command */
}
......
......@@ -57,9 +57,18 @@ static inline void do_identify (ide_drive_t *drive, byte cmd)
printk(KERN_WARNING "(ide-probe::do_identify) Out of memory.\n");
goto err_kmalloc;
}
/* read 512 bytes of id info */
/* Read 512 bytes of id info.
*
* Please note that it is well known that some *very* old drives are
* able to provide only 256 of them, since this was the amount read by
* DOS.
*
* However let's try to get away with this...
*/
#if 1
ata_input_data(drive, id, SECTOR_WORDS); /* read 512 bytes of id info */
ata_read(drive, id, SECTOR_WORDS);
#else
{
unsigned long *ptr = (unsigned long *)id ;
......@@ -580,10 +589,10 @@ static void probe_hwif(struct ata_channel *hwif)
__restore_flags(flags); /* local CPU only */
for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
if (drive->present) {
ide_tuneproc_t *tuneproc = drive->channel->tuneproc;
if (tuneproc != NULL && drive->autotune == 1)
tuneproc(drive, 255); /* auto-tune PIO mode */
if (drive->present && (drive->autotune == 1)) {
if (drive->channel->tuneproc != NULL)
drive->channel->tuneproc(drive, 255); /* auto-tune PIO mode */
}
}
}
......
......@@ -422,7 +422,6 @@ void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
static void create_proc_ide_drives(struct ata_channel *hwif)
{
int d;
struct proc_dir_entry *ent;
struct proc_dir_entry *parent = hwif->proc;
char name[64];
......
......@@ -1503,9 +1503,9 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne
idetape_discard_data (drive, bcount);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
#endif
count = min(bio->bi_size - pc->b_count, bcount);
atapi_input_bytes (drive, bio_data(bio) + pc->b_count, count);
atapi_read(drive, bio_data(bio) + pc->b_count, count);
bcount -= count;
pc->b_count += bio->bi_size;
if (pc->b_count == bio->bi_size) {
......@@ -1530,7 +1530,7 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign
}
#endif /* IDETAPE_DEBUG_BUGS */
count = min(pc->b_count, bcount);
atapi_output_bytes (drive, bio_data(bio), count);
atapi_write(drive, bio_data(bio), count);
bcount -= count;
pc->b_data += count;
pc->b_count -= count;
......@@ -2169,12 +2169,12 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (pc->bio != NULL)
idetape_output_buffers (drive, pc, bcount.all);
else
atapi_output_bytes (drive,pc->current_position,bcount.all); /* Write the current buffer */
atapi_write(drive,pc->current_position,bcount.all); /* Write the current buffer */
} else {
if (pc->bio != NULL)
idetape_input_buffers (drive, pc, bcount.all);
else
atapi_input_bytes (drive,pc->current_position,bcount.all); /* Read the current buffer */
atapi_read(drive,pc->current_position,bcount.all); /* Read the current buffer */
}
pc->actually_transferred += bcount.all; /* Update the current position */
pc->current_position+=bcount.all;
......@@ -2259,7 +2259,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
tape->cmd_start_time = jiffies;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* Set the interrupt routine */
atapi_output_bytes (drive,pc->c,12); /* Send the actual packet */
atapi_write(drive,pc->c,12); /* Send the actual packet */
return ide_started;
}
......
This diff is collapsed.
......@@ -383,7 +383,7 @@ void ide_end_queued_request(ide_drive_t *drive, int uptodate, struct request *rq
spin_lock_irqsave(&ide_lock, flags);
if ((jiffies - ar->ar_time > ATA_AR_MAX_TURNAROUND) && drive->queue_depth > 1) {
printk("%s: exceeded max command turn-around time (%d seconds)\n", drive->name, ATA_AR_MAX_TURNAROUND / HZ);
printk(KERN_INFO "%s: exceeded max command turn-around time (%d seconds)\n", drive->name, ATA_AR_MAX_TURNAROUND / HZ);
drive->queue_depth >>= 1;
}
......@@ -474,7 +474,7 @@ void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
spin_unlock_irqrestore(&ide_lock, flags);
}
static void ata_pre_reset (ide_drive_t *drive)
static void ata_pre_reset(ide_drive_t *drive)
{
if (ata_ops(drive) && ata_ops(drive)->pre_reset)
ata_ops(drive)->pre_reset(drive);
......@@ -528,10 +528,9 @@ static ide_startstop_t ata_special (ide_drive_t *drive)
printk("%s: ata_special: 0x%02x\n", drive->name, s->all);
#endif
if (s->b.set_tune) {
ide_tuneproc_t *tuneproc = drive->channel->tuneproc;
s->b.set_tune = 0;
if (tuneproc != NULL)
tuneproc(drive, drive->tune_req);
if (drive->channel->tuneproc != NULL)
drive->channel->tuneproc(drive, drive->tune_req);
} else if (drive->driver != NULL) {
if (ata_ops(drive)->special)
return ata_ops(drive)->special(drive);
......@@ -899,23 +898,24 @@ byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat)
}
/*
* try_to_flush_leftover_data() is invoked in response to a drive
* unexpectedly having its DRQ_STAT bit set. As an alternative to
* resetting the drive, this routine tries to clear the condition
* by read a sector's worth of data from the drive. Of course,
* This gets invoked in response to a drive unexpectedly having its DRQ_STAT
* bit set. As an alternative to resetting the drive, it tries to clear the
* condition by reading a sector's worth of data from the drive. Of course,
* this may not help if the drive is *waiting* for data from *us*.
*/
static void try_to_flush_leftover_data (ide_drive_t *drive)
{
int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS;
int i = (drive->mult_count ? drive->mult_count : 1);
if (drive->type != ATA_DISK)
return;
while (i > 0) {
u32 buffer[16];
unsigned int wcount = (i > 16) ? 16 : i;
i -= wcount;
ata_input_data (drive, buffer, wcount);
u32 buffer[SECTOR_WORDS];
unsigned int count = (i > 1) ? 1 : i;
ata_read(drive, buffer, count * SECTOR_WORDS);
i -= count;
}
}
......@@ -1002,16 +1002,18 @@ void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler)
static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
{
struct request *rq = HWGROUP(drive)->rq;
byte *args = (byte *) rq->buffer;
byte stat = GET_STAT();
u8 *args = rq->buffer;
u8 stat = GET_STAT();
int retries = 10;
ide__sti(); /* local CPU only */
if ((stat & DRQ_STAT) && args && args[3]) {
byte io_32bit = drive->io_32bit;
int io_32bit = drive->io_32bit;
drive->io_32bit = 0;
ata_input_data(drive, &args[4], args[3] * SECTOR_WORDS);
ata_read(drive, &args[4], args[3] * SECTOR_WORDS);
drive->io_32bit = io_32bit;
while (((stat = GET_STAT()) & BUSY_STAT) && retries--)
udelay(100);
}
......@@ -1019,6 +1021,7 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
if (!OK_STAT(stat, READY_STAT, BAD_STAT))
return ide_error(drive, "drive_cmd", stat); /* calls ide_end_drive_cmd */
ide_end_drive_cmd (drive, stat, GET_ERR());
return ide_stopped;
}
......@@ -1266,31 +1269,26 @@ void ide_stall_queue(ide_drive_t *drive, unsigned long timeout)
/*
* Select the next drive which will be serviced.
*/
static inline ide_drive_t *choose_drive(ide_hwgroup_t *hwgroup)
static ide_drive_t *choose_drive(ide_hwgroup_t *hwgroup)
{
ide_drive_t *drive, *best;
ide_drive_t *tmp;
ide_drive_t *drive = NULL;
unsigned long sleep = 0;
best = NULL;
drive = hwgroup->drive;
tmp = hwgroup->drive;
do {
if (!list_empty(&drive->queue.queue_head)
&& (!drive->PADAM_sleep || time_after_eq(drive->PADAM_sleep, jiffies))) {
if (!best
|| (drive->PADAM_sleep && (!best->PADAM_sleep || time_after(best->PADAM_sleep, drive->PADAM_sleep)))
|| (!best->PADAM_sleep && time_after(best->PADAM_service_start + 2 * best->PADAM_service_time, drive->PADAM_service_start + 2 * drive->PADAM_service_time)))
if (!list_empty(&tmp->queue.queue_head)
&& (!tmp->PADAM_sleep || time_after_eq(tmp->PADAM_sleep, jiffies))) {
if (!drive
|| (tmp->PADAM_sleep && (!drive->PADAM_sleep || time_after(drive->PADAM_sleep, tmp->PADAM_sleep)))
|| (!drive->PADAM_sleep && time_after(drive->PADAM_service_start + 2 * drive->PADAM_service_time, tmp->PADAM_service_start + 2 * tmp->PADAM_service_time)))
{
if (!blk_queue_plugged(&drive->queue))
best = drive;
if (!blk_queue_plugged(&tmp->queue))
drive = tmp;
}
}
} while ((drive = drive->next) != hwgroup->drive);
return best;
}
static ide_drive_t *ide_choose_drive(ide_hwgroup_t *hwgroup)
{
ide_drive_t *drive = choose_drive(hwgroup);
unsigned long sleep = 0;
tmp = tmp->next;
} while (tmp != hwgroup->drive);
if (drive)
return drive;
......@@ -1495,7 +1493,7 @@ static void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq)
/*
* will clear IDE_BUSY, if appropriate
*/
if ((drive = ide_choose_drive(hwgroup)) == NULL)
if ((drive = choose_drive(hwgroup)) == NULL)
break;
hwif = drive->channel;
......@@ -2298,7 +2296,10 @@ void ide_unregister(struct ata_channel *channel)
channel->maskproc = old_hwif.maskproc;
channel->quirkproc = old_hwif.quirkproc;
channel->rwproc = old_hwif.rwproc;
channel->ideproc = old_hwif.ideproc;
channel->ata_read = old_hwif.ata_read;
channel->ata_write = old_hwif.ata_write;
channel->atapi_read = old_hwif.atapi_read;
channel->atapi_write = old_hwif.atapi_write;
channel->dmaproc = old_hwif.dmaproc;
channel->busproc = old_hwif.busproc;
channel->bus_state = old_hwif.bus_state;
......@@ -2565,13 +2566,17 @@ int ide_write_setting (ide_drive_t *drive, ide_settings_t *setting, int val)
return 0;
}
static int set_io_32bit(ide_drive_t *drive, int arg)
static int set_io_32bit(struct ata_device *drive, int arg)
{
if (drive->no_io_32bit)
return -EIO;
drive->io_32bit = arg;
#ifdef CONFIG_BLK_DEV_DTC2278
if (drive->channel->chipset == ide_dtc2278)
drive->channel->drives[!drive->select.b.unit].io_32bit = arg;
#endif /* CONFIG_BLK_DEV_DTC2278 */
#endif
return 0;
}
......@@ -3018,8 +3023,6 @@ static int __init match_parm (char *s, const char *keywords[], int vals[], int m
* "hdx=slow" : insert a huge pause after each access to the data
* port. Should be used only as a last resort.
*
* "hdx=swapdata" : when the drive is a disk, byte swap all data
* "hdx=bswap" : same as above..........
* "hdxlun=xx" : set the drive last logical unit.
* "hdx=flash" : allows for more than one ata_flash disk to be
* registered. In most cases, only one device
......@@ -3127,8 +3130,7 @@ int __init ide_setup (char *s)
if (!strncmp(s, "hd", 2) && s[2] >= 'a' && s[2] <= max_drive) {
const char *hd_words[] = {"none", "noprobe", "nowerr", "cdrom",
"serialize", "autotune", "noautotune",
"slow", "swapdata", "bswap", "flash",
"remap", "noremap", "scsi", NULL};
"slow", "flash", "remap", "noremap", "scsi", NULL};
unit = s[2] - 'a';
hw = unit / MAX_DRIVES;
unit = unit % MAX_DRIVES;
......@@ -3178,20 +3180,16 @@ int __init ide_setup (char *s)
case -8: /* "slow" */
drive->slow = 1;
goto done;
case -9: /* "swapdata" or "bswap" */
case -10:
drive->bswap = 1;
goto done;
case -11: /* "flash" */
case -9: /* "flash" */
drive->ata_flash = 1;
goto done;
case -12: /* "remap" */
case -10: /* "remap" */
drive->remap_0_to_1 = 1;
goto done;
case -13: /* "noremap" */
case -11: /* "noremap" */
drive->remap_0_to_1 = 2;
goto done;
case -14: /* "scsi" */
case -12: /* "scsi" */
#if defined(CONFIG_BLK_DEV_IDESCSI) && defined(CONFIG_SCSI)
drive->scsi = 1;
goto done;
......
......@@ -1270,9 +1270,10 @@ void __init ide_init_pdc202xx(struct ata_channel *hwif)
#ifdef CONFIG_PDC202XX_32_UNMASK
hwif->drives[0].io_32bit = 1;
hwif->drives[1].io_32bit = 1;
hwif->drives[0].unmask = 1;
hwif->drives[1].unmask = 1;
#endif /* CONFIG_PDC202XX_32_UNMASK */
#endif
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
......@@ -1285,9 +1286,9 @@ void __init ide_init_pdc202xx(struct ata_channel *hwif)
hwif->drives[1].autotune = 1;
hwif->autodma = 0;
}
#else /* !CONFIG_BLK_DEV_IDEDMA */
#else
hwif->drives[0].autotune = 1;
hwif->drives[1].autotune = 1;
hwif->autodma = 0;
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif
}
......@@ -183,7 +183,7 @@ int __init setup_pdc4030(struct ata_channel *hwif)
"%s: Failed Promise read config!\n",hwif->name);
return 0;
}
ata_input_data(drive, &ident, SECTOR_WORDS);
ata_read(drive, &ident, SECTOR_WORDS);
if (ident.id[1] != 'P' || ident.id[0] != 'T') {
return 0;
}
......@@ -332,7 +332,7 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
nsect = sectors_avail;
sectors_avail -= nsect;
to = bio_kmap_irq(rq->bio, &flags) + ide_rq_offset(rq);
ata_input_data(drive, to, nsect * SECTOR_WORDS);
ata_read(drive, to, nsect * SECTOR_WORDS);
#ifdef DEBUG_READ
printk(KERN_DEBUG "%s: promise_read: sectors(%ld-%ld), "
"buf=0x%08lx, rem=%ld\n", drive->name, rq->sector,
......@@ -460,7 +460,7 @@ int promise_multwrite (ide_drive_t *drive, unsigned int mcount)
* Ok, we're all setup for the interrupt
* re-entering us on the last transfer.
*/
taskfile_output_data(drive, buffer, nsect<<7);
ata_write(drive, buffer, nsect << 7);
bio_kunmap_irq(buffer, &flags);
} while (mcount);
......
......@@ -140,7 +140,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
}
count = min(pc->sg->length - pc->b_count, bcount);
buf = page_address(pc->sg->page) + pc->sg->offset;
atapi_input_bytes (drive, buf + pc->b_count, count);
atapi_read(drive, buf + pc->b_count, count);
bcount -= count; pc->b_count += count;
if (pc->b_count == pc->sg->length) {
pc->sg++;
......@@ -162,7 +162,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
}
count = min(pc->sg->length - pc->b_count, bcount);
buf = page_address(pc->sg->page) + pc->sg->offset;
atapi_output_bytes (drive, buf + pc->b_count, count);
atapi_write(drive, buf + pc->b_count, count);
bcount -= count; pc->b_count += count;
if (pc->b_count == pc->sg->length) {
pc->sg++;
......@@ -363,7 +363,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
if (pc->sg)
idescsi_input_buffers(drive, pc, temp);
else
atapi_input_bytes(drive, pc->current_position, temp);
atapi_read(drive, pc->current_position, temp);
printk(KERN_ERR "ide-scsi: transferred %d of %d bytes\n", temp, bcount);
}
pc->actually_transferred += temp;
......@@ -382,13 +382,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
if (pc->sg)
idescsi_input_buffers (drive, pc, bcount);
else
atapi_input_bytes (drive,pc->current_position,bcount);
atapi_read(drive,pc->current_position,bcount);
} else {
set_bit(PC_WRITING, &pc->flags);
if (pc->sg)
idescsi_output_buffers (drive, pc, bcount);
else
atapi_output_bytes (drive,pc->current_position,bcount);
atapi_write(drive,pc->current_position,bcount);
}
pc->actually_transferred+=bcount; /* Update the current position */
pc->current_position+=bcount;
......@@ -414,7 +414,7 @@ static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive)
return ide_stopped;
}
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), NULL); /* Set the interrupt routine */
atapi_output_bytes (drive, scsi->pc->c, 12); /* Send the actual packet */
atapi_write(drive, scsi->pc->c, 12); /* Send the actual packet */
return ide_started;
}
......
......@@ -313,9 +313,11 @@ typedef struct ide_tag_info_s {
#define IDE_CUR_AR(drive) (HWGROUP((drive))->rq->special)
struct ide_settings_s;
typedef struct ide_drive_s {
struct ata_channel *channel; /* parent pointer to the channel we are attached to */
/* structure describing an ATA/ATAPI device */
typedef
struct ata_device {
struct ata_channel * channel;
char name[6]; /* device name */
unsigned int usage; /* current "open()" count for drive */
char type; /* distingiush different devices: disk, cdrom, tape, floppy, ... */
......@@ -324,11 +326,11 @@ typedef struct ide_drive_s {
* could move this to the channel and many sync problems would
* magically just go away.
*/
request_queue_t queue; /* per device request queue */
request_queue_t queue; /* per device request queue */
struct list_head free_req; /* free ata requests */
struct list_head free_req; /* free ata requests */
struct ide_drive_s *next; /* circular list of hwgroup drives */
struct ata_device *next; /* circular list of hwgroup drives */
/* Those are directly injected jiffie values. They should go away and
* we should use generic timers instead!!!
......@@ -346,8 +348,6 @@ typedef struct ide_drive_s {
byte retry_pio; /* retrying dma capable host in pio */
byte state; /* retry state */
byte unmask; /* flag: okay to unmask other irqs */
byte slow; /* flag: slow data port */
byte bswap; /* flag: byte swap data */
byte dsc_overlap; /* flag: DSC overlap */
unsigned waiting_for_dma: 1; /* dma currently in progress */
......@@ -359,7 +359,6 @@ typedef struct ide_drive_s {
unsigned removable : 1; /* 1 if need to do check_media_change */
unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
unsigned no_unmask : 1; /* disallow setting unmask bit */
unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
unsigned nobios : 1; /* flag: do not probe bios for drive */
unsigned revalidate : 1; /* request revalidation */
unsigned atapi_overlap : 1; /* flag: ATAPI overlap (not supported) */
......@@ -376,7 +375,6 @@ typedef struct ide_drive_s {
byte mult_count; /* current multiple sector setting */
byte mult_req; /* requested multiple sector setting */
byte tune_req; /* requested drive tuning setting */
byte io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
byte bad_wstat; /* used for ignoring WRERR_STAT */
byte nowerr; /* used for ignoring WRERR_STAT */
byte sect0; /* offset of first sector for DM6:DDO */
......@@ -390,12 +388,18 @@ typedef struct ide_drive_s {
unsigned long long capacity48; /* total number of sectors */
unsigned int drive_data; /* for use by tuneproc/selectproc as needed */
/* FIXME: Those are properties of a channel and not a drive! Move them
* later there.
*/
byte slow; /* flag: slow data port */
unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
byte io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
wait_queue_head_t wqueue; /* used to wait for drive in open() */
struct hd_driveid *id; /* drive model identification info */
struct hd_struct *part; /* drive partition table */
char name[6]; /* drive name, such as "hda" */
struct ata_operations *driver;
void *driver_data; /* extra driver data */
......@@ -447,47 +451,6 @@ typedef enum { ide_dma_read, ide_dma_write, ide_dma_begin,
typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *);
/*
* An ide_ideproc_t() performs CPU-polled transfers to/from a drive.
* Arguments are: the drive, the buffer pointer, and the length (in bytes or
* words depending on if it's an IDE or ATAPI call).
*
* If it is not defined for a controller, standard-code is used from ide.c.
*
* Controllers which are not memory-mapped in the standard way need to
* override that mechanism using this function to work.
*
*/
typedef enum { ideproc_ide_input_data, ideproc_ide_output_data,
ideproc_atapi_input_bytes, ideproc_atapi_output_bytes
} ide_ide_action_t;
typedef void (ide_ideproc_t)(ide_ide_action_t, ide_drive_t *, void *, unsigned int);
/*
* An ide_tuneproc_t() is used to set the speed of an IDE interface
* to a particular PIO mode. The "byte" parameter is used
* to select the PIO mode by number (0,1,2,3,4,5), and a value of 255
* indicates that the interface driver should "auto-tune" the PIO mode
* according to the drive capabilities in drive->id;
*
* Not all interface types support tuning, and not all of those
* support all possible PIO settings. They may silently ignore
* or round values as they see fit.
*/
typedef void (ide_tuneproc_t) (ide_drive_t *, byte);
typedef int (ide_speedproc_t) (ide_drive_t *, byte);
/*
* This is used to provide support for strange interfaces
*/
typedef void (ide_selectproc_t) (ide_drive_t *);
typedef void (ide_resetproc_t) (ide_drive_t *);
typedef int (ide_quirkproc_t) (ide_drive_t *);
typedef void (ide_intrproc_t) (ide_drive_t *);
typedef void (ide_maskproc_t) (ide_drive_t *, int);
typedef void (ide_rw_proc_t) (ide_drive_t *, ide_dma_action_t);
enum {
ATA_PRIMARY = 0,
ATA_SECONDARY = 1
......@@ -507,15 +470,40 @@ struct ata_channel {
#endif
ide_drive_t drives[MAX_DRIVES]; /* drive info */
struct gendisk *gd; /* gendisk structure */
ide_tuneproc_t *tuneproc; /* routine to tune PIO mode for drives */
ide_speedproc_t *speedproc; /* routine to retune DMA modes for drives */
ide_selectproc_t *selectproc; /* tweaks hardware to select drive */
ide_resetproc_t *resetproc; /* routine to reset controller after a disk reset */
ide_intrproc_t *intrproc; /* special interrupt handling for shared pci interrupts */
ide_maskproc_t *maskproc; /* special host masking for drive selection */
ide_quirkproc_t *quirkproc; /* check host's drive quirk list */
ide_rw_proc_t *rwproc; /* adjust timing based upon rq->cmd direction */
ide_ideproc_t *ideproc; /* CPU-polled transfer routine */
/*
* Routines to tune PIO and DMA mode for drives.
*
* A value of 255 indicates that the function should choose the optimal
* mode itself.
*/
void (*tuneproc) (ide_drive_t *, byte pio);
int (*speedproc) (ide_drive_t *, byte pio);
/* tweaks hardware to select drive */
void (*selectproc) (ide_drive_t *);
/* routine to reset controller after a disk reset */
void (*resetproc) (ide_drive_t *);
/* special interrupt handling for shared pci interrupts */
void (*intrproc) (ide_drive_t *);
/* special host masking for drive selection */
void (*maskproc) (ide_drive_t *, int);
/* adjust timing based upon rq->cmd direction */
void (*rwproc) (ide_drive_t *, ide_dma_action_t);
/* check host's drive quirk list */
int (*quirkproc) (ide_drive_t *);
/* CPU-polled transfer routines */
void (*ata_read)(ide_drive_t *, void *, unsigned int);
void (*ata_write)(ide_drive_t *, void *, unsigned int);
void (*atapi_read)(ide_drive_t *, void *, unsigned int);
void (*atapi_write)(ide_drive_t *, void *, unsigned int);
ide_dmaproc_t *dmaproc; /* dma read/write/abort routine */
unsigned long dma_base; /* base addr for dma ports */
unsigned dma_extra; /* extra addr for dma ports */
......@@ -829,7 +817,7 @@ struct ata_taskfile {
*/
struct ata_request {
struct request *ar_rq; /* real request */
struct ide_drive_s *ar_drive; /* associated drive */
struct ata_device *ar_drive; /* associated drive */
unsigned long ar_flags; /* ATA_AR_* flags */
int ar_tag; /* tag number, if any */
struct list_head ar_queue; /* pending list */
......@@ -848,12 +836,11 @@ struct ata_request {
#define AR_TASK_CMD(ar) ((ar)->ar_task.taskfile.command)
void ata_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
void ata_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
void taskfile_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
void taskfile_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
extern void ata_read(ide_drive_t *drive, void *buffer, unsigned int wcount);
extern void ata_write(ide_drive_t *drive, void *buffer, unsigned int wcount);
extern void atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount);
extern void atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount);
extern ide_startstop_t ata_taskfile(ide_drive_t *drive,
struct ata_taskfile *args, struct request *rq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment