Commit d861eb67 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.21 IDE 87

 - Sync with 2.5.21

 - Don't call put_device inside idedisk_cleanup(). This is apparently triggering
   some bug inside the handling of device trees. Or we don't register the device
   properly within the tree. Check this later.

 - Further work on the channel register file access locking.  Push the locking
   out from __ide_end_request to ide_end_request.  Rename those functions to
   respective __ata_end_request() and ata_end_request().

 - Move ide_wait_status to device.c rename it to ata_status_poll().

 - Further work on locking scope issues.

 - devfs showed us once again that it changed the policy from agnostic numbers
   to unpleasant string names.
parent 96ba040a
...@@ -79,8 +79,30 @@ void ata_mask(struct ata_device *drive) ...@@ -79,8 +79,30 @@ void ata_mask(struct ata_device *drive)
ch->maskproc(drive); ch->maskproc(drive);
} }
/*
* Spin until the drive is no longer busy.
*
* Not exported, since it's not used within any modules.
*/
int ata_busy_poll(struct ata_device *drive, unsigned long timeout)
{
/* spec allows drive 400ns to assert "BUSY" */
udelay(1);
if (!ata_status(drive, 0, BUSY_STAT)) {
timeout += jiffies;
while (!ata_status(drive, 0, BUSY_STAT)) {
if (time_after(jiffies, timeout))
return 1;
}
}
return 0;
}
/* /*
* Check the state of the status register. * Check the state of the status register.
*
* FIXME: Channel lock should be held.
*/ */
int ata_status(struct ata_device *drive, u8 good, u8 bad) int ata_status(struct ata_device *drive, u8 good, u8 bad)
{ {
...@@ -93,6 +115,57 @@ int ata_status(struct ata_device *drive, u8 good, u8 bad) ...@@ -93,6 +115,57 @@ int ata_status(struct ata_device *drive, u8 good, u8 bad)
EXPORT_SYMBOL(ata_status); EXPORT_SYMBOL(ata_status);
/*
* Busy-wait for the drive status to be not "busy". Check then the status for
* all of the "good" bits and none of the "bad" bits, and if all is okay it
* returns 0. All other cases return 1 after invoking error handler -- caller
* should just return.
*
* This routine should get fixed to not hog the cpu during extra long waits..
* That could be done by busy-waiting for the first jiffy or two, and then
* setting a timer to wake up at half second intervals thereafter, until
* timeout is achieved, before timing out.
*
* FIXME: Channel lock should be held.
*/
int ata_status_poll(struct ata_device *drive, u8 good, u8 bad,
unsigned long timeout,
struct request *rq, ide_startstop_t *startstop)
{
int i;
/* bail early if we've exceeded max_failures */
if (drive->max_failures && (drive->failures > drive->max_failures)) {
*startstop = ide_stopped;
return 1;
}
if (ata_busy_poll(drive, timeout)) {
*startstop = ata_error(drive, rq, "status timeout");
return 1;
}
/*
* Allow status to settle, then read it again. A few rare drives
* vastly violate the 400ns spec here, so we'll wait up to 10usec for a
* "good" status rather than expensively fail things immediately. This
* fix courtesy of Matthew Faupel & Niccolo Rigacci.
*/
for (i = 0; i < 10; i++) {
udelay(1);
if (ata_status(drive, good, bad))
return 0;
}
*startstop = ata_error(drive, rq, "status error");
return 1;
}
EXPORT_SYMBOL(ata_status_poll);
/* /*
* Handle the nIEN - negated Interrupt ENable of the drive. * Handle the nIEN - negated Interrupt ENable of the drive.
* This is controlling whatever the drive will acnowlenge commands * This is controlling whatever the drive will acnowlenge commands
...@@ -160,7 +233,7 @@ void ata_out_regfile(struct ata_device *drive, struct hd_drive_task_hdr *rf) ...@@ -160,7 +233,7 @@ void ata_out_regfile(struct ata_device *drive, struct hd_drive_task_hdr *rf)
} }
/* /*
* Output a complete register file. * Input a complete register file.
*/ */
void ata_in_regfile(struct ata_device *drive, struct hd_drive_task_hdr *rf) void ata_in_regfile(struct ata_device *drive, struct hd_drive_task_hdr *rf)
{ {
......
...@@ -556,7 +556,7 @@ static void cdrom_end_request(struct ata_device *drive, struct request *rq, int ...@@ -556,7 +556,7 @@ static void cdrom_end_request(struct ata_device *drive, struct request *rq, int
if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors) if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors)
uptodate = 1; uptodate = 1;
ide_end_request(drive, rq, uptodate); ata_end_request(drive, rq, uptodate);
} }
...@@ -734,7 +734,7 @@ static ide_startstop_t cdrom_start_packet_command(struct ata_device *drive, ...@@ -734,7 +734,7 @@ static ide_startstop_t cdrom_start_packet_command(struct ata_device *drive,
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
/* Wait for the controller to be idle. */ /* Wait for the controller to be idle. */
if (ide_wait_stat(&startstop, drive, rq, 0, BUSY_STAT, WAIT_READY)) if (ata_status_poll(drive, 0, BUSY_STAT, WAIT_READY, rq, &startstop))
return startstop; return startstop;
spin_lock_irqsave(ch->lock, flags); spin_lock_irqsave(ch->lock, flags);
...@@ -798,7 +798,8 @@ static ide_startstop_t cdrom_transfer_packet_command(struct ata_device *drive, ...@@ -798,7 +798,8 @@ static ide_startstop_t cdrom_transfer_packet_command(struct ata_device *drive,
return startstop; return startstop;
} else { } else {
/* Otherwise, we must wait for DRQ to get set. */ /* Otherwise, we must wait for DRQ to get set. */
if (ide_wait_stat(&startstop, drive, rq, DRQ_STAT, BUSY_STAT, WAIT_READY)) if (ata_status_poll(drive, DRQ_STAT, BUSY_STAT,
WAIT_READY, rq, &startstop))
return startstop; return startstop;
} }
...@@ -926,7 +927,14 @@ static ide_startstop_t cdrom_read_intr(struct ata_device *drive, struct request ...@@ -926,7 +927,14 @@ static ide_startstop_t cdrom_read_intr(struct ata_device *drive, struct request
if (dma) { if (dma) {
if (!dma_error) { if (!dma_error) {
__ide_end_request(drive, rq, 1, rq->nr_sectors); /* FIXME: this locking should encompass the above register
* file access too.
*/
spin_lock_irqsave(ch->lock, flags);
__ata_end_request(drive, rq, 1, rq->nr_sectors);
spin_unlock_irqrestore(ch->lock, flags);
return ide_stopped; return ide_stopped;
} else } else
return ata_error(drive, rq, "dma error"); return ata_error(drive, rq, "dma error");
...@@ -1518,7 +1526,14 @@ static ide_startstop_t cdrom_write_intr(struct ata_device *drive, struct request ...@@ -1518,7 +1526,14 @@ static ide_startstop_t cdrom_write_intr(struct ata_device *drive, struct request
if (dma_error) if (dma_error)
return ata_error(drive, rq, "dma error"); return ata_error(drive, rq, "dma error");
__ide_end_request(drive, rq, 1, rq->nr_sectors); /* FIXME: this locking should encompass the above register
* file access too.
*/
spin_lock_irqsave(ch->lock, flags);
__ata_end_request(drive, rq, 1, rq->nr_sectors);
spin_unlock_irqrestore(ch->lock, flags);
return ide_stopped; return ide_stopped;
} }
......
This diff is collapsed.
...@@ -608,7 +608,7 @@ typedef struct { ...@@ -608,7 +608,7 @@ typedef struct {
/* /*
* idefloppy_end_request is used to finish servicing a request. * idefloppy_end_request is used to finish servicing a request.
* *
* For read/write requests, we will call ide_end_request to pass to the * For read/write requests, we will call ata_end_request to pass to the
* next buffer. * next buffer.
*/ */
static int idefloppy_end_request(struct ata_device *drive, struct request *rq, int uptodate) static int idefloppy_end_request(struct ata_device *drive, struct request *rq, int uptodate)
...@@ -632,7 +632,7 @@ static int idefloppy_end_request(struct ata_device *drive, struct request *rq, i ...@@ -632,7 +632,7 @@ static int idefloppy_end_request(struct ata_device *drive, struct request *rq, i
return 0; return 0;
if (!(rq->flags & REQ_SPECIAL)) { if (!(rq->flags & REQ_SPECIAL)) {
ide_end_request(drive, rq, uptodate); ata_end_request(drive, rq, uptodate);
return 0; return 0;
} }
...@@ -956,9 +956,12 @@ static ide_startstop_t idefloppy_transfer_pc(struct ata_device *drive, struct re ...@@ -956,9 +956,12 @@ static ide_startstop_t idefloppy_transfer_pc(struct ata_device *drive, struct re
ide_startstop_t startstop; ide_startstop_t startstop;
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
idefloppy_ireason_reg_t ireason; idefloppy_ireason_reg_t ireason;
int ret;
if (ide_wait_stat (&startstop, drive, rq, DRQ_STAT, BUSY_STAT, WAIT_READY)) { if (ata_status_poll(drive, DRQ_STAT, BUSY_STAT,
WAIT_READY, rq, &startstop)) {
printk (KERN_ERR "ide-floppy: Strange, packet command initiated yet DRQ isn't asserted\n"); printk (KERN_ERR "ide-floppy: Strange, packet command initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
...@@ -968,18 +971,18 @@ static ide_startstop_t idefloppy_transfer_pc(struct ata_device *drive, struct re ...@@ -968,18 +971,18 @@ static ide_startstop_t idefloppy_transfer_pc(struct ata_device *drive, struct re
spin_lock_irqsave(ch->lock, flags); spin_lock_irqsave(ch->lock, flags);
ireason.all=IN_BYTE (IDE_IREASON_REG); ireason.all=IN_BYTE (IDE_IREASON_REG);
if (!ireason.b.cod || ireason.b.io) {
spin_unlock_irqrestore(ch->lock, flags);
if (!ireason.b.cod || ireason.b.io) {
printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while issuing a packet command\n"); printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while issuing a packet command\n");
return ide_stopped; ret = ide_stopped;
} } else {
ata_set_handler (drive, idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* Set the interrupt routine */ ata_set_handler (drive, idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* Set the interrupt routine */
atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */ atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */
ret = ide_started;
}
spin_unlock_irqrestore(ch->lock, flags); spin_unlock_irqrestore(ch->lock, flags);
return ide_started; return ret;
} }
...@@ -1010,23 +1013,25 @@ static ide_startstop_t idefloppy_transfer_pc1(struct ata_device *drive, struct r ...@@ -1010,23 +1013,25 @@ static ide_startstop_t idefloppy_transfer_pc1(struct ata_device *drive, struct r
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
ide_startstop_t startstop; ide_startstop_t startstop;
idefloppy_ireason_reg_t ireason; idefloppy_ireason_reg_t ireason;
int ret;
if (ide_wait_stat(&startstop, drive, rq, DRQ_STAT, BUSY_STAT, WAIT_READY)) { if (ata_status_poll(drive, DRQ_STAT, BUSY_STAT,
WAIT_READY, rq, &startstop)) {
printk (KERN_ERR "ide-floppy: Strange, packet command initiated yet DRQ isn't asserted\n"); printk (KERN_ERR "ide-floppy: Strange, packet command initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
/* FIXME: this locking should encompass the above register /* FIXME: this locking should encompass the above register
* file access too. * file access too.
*/ */
spin_lock_irqsave(ch->lock, flags); spin_lock_irqsave(ch->lock, flags);
ireason.all=IN_BYTE (IDE_IREASON_REG); ireason.all=IN_BYTE(IDE_IREASON_REG);
if (!ireason.b.cod || ireason.b.io) { if (!ireason.b.cod || ireason.b.io) {
spin_unlock_irqrestore(ch->lock, flags);
printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while issuing a packet command\n"); printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while issuing a packet command\n");
return ide_stopped; ret = ide_stopped;
} } else {
/* /*
* The following delay solves a problem with ATAPI Zip 100 drives where * The following delay solves a problem with ATAPI Zip 100 drives where
...@@ -1040,9 +1045,11 @@ static ide_startstop_t idefloppy_transfer_pc1(struct ata_device *drive, struct r ...@@ -1040,9 +1045,11 @@ static ide_startstop_t idefloppy_transfer_pc1(struct ata_device *drive, struct r
idefloppy_pc_intr, /* service routine for packet command */ idefloppy_pc_intr, /* service routine for packet command */
floppy->ticks, /* wait this long before "failing" */ floppy->ticks, /* wait this long before "failing" */
idefloppy_transfer_pc2); /* fail == transfer_pc2 */ idefloppy_transfer_pc2); /* fail == transfer_pc2 */
ret = ide_started;
}
spin_unlock_irqrestore(ch->lock, flags); spin_unlock_irqrestore(ch->lock, flags);
return ide_started; return ret;
} }
/* /*
......
...@@ -2196,9 +2196,12 @@ static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct requ ...@@ -2196,9 +2196,12 @@ static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct requ
idetape_ireason_reg_t ireason; idetape_ireason_reg_t ireason;
int retries = 100; int retries = 100;
ide_startstop_t startstop; ide_startstop_t startstop;
int ret;
if (ide_wait_stat(&startstop, drive, rq, DRQ_STAT, BUSY_STAT, WAIT_READY)) { if (ata_status_poll(drive, DRQ_STAT, BUSY_STAT,
WAIT_READY, rq, &startstop)) {
printk (KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n"); printk (KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
...@@ -2220,16 +2223,16 @@ static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct requ ...@@ -2220,16 +2223,16 @@ static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct requ
} }
if (!ireason.b.cod || ireason.b.io) { if (!ireason.b.cod || ireason.b.io) {
printk (KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing a packet command\n"); printk (KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing a packet command\n");
spin_unlock_irqrestore(ch->lock, flags); ret = ide_stopped;
} else {
return ide_stopped;
}
tape->cmd_start_time = jiffies; tape->cmd_start_time = jiffies;
ata_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* Set the interrupt routine */ ata_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* Set the interrupt routine */
atapi_write(drive,pc->c,12); /* Send the actual packet */ atapi_write(drive,pc->c,12); /* Send the actual packet */
ret = ide_started;
}
spin_unlock_irqrestore(ch->lock, flags); spin_unlock_irqrestore(ch->lock, flags);
return ide_started; return ret;
} }
static ide_startstop_t idetape_issue_packet_command(struct ata_device *drive, static ide_startstop_t idetape_issue_packet_command(struct ata_device *drive,
...@@ -2618,7 +2621,7 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque ...@@ -2618,7 +2621,7 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
* We do not support buffer cache originated requests. * We do not support buffer cache originated requests.
*/ */
printk (KERN_NOTICE "ide-tape: %s: Unsupported command in request queue (%ld)\n", drive->name, rq->flags); printk (KERN_NOTICE "ide-tape: %s: Unsupported command in request queue (%ld)\n", drive->name, rq->flags);
ide_end_request(drive, rq, 0); /* Let the common code handle it */ ata_end_request(drive, rq, 0); /* Let the common code handle it */
return ide_stopped; return ide_stopped;
} }
......
...@@ -233,7 +233,8 @@ ide_startstop_t ata_taskfile(struct ata_device *drive, ...@@ -233,7 +233,8 @@ ide_startstop_t ata_taskfile(struct ata_device *drive,
ar->cmd == WIN_MULTWRITE_EXT) { ar->cmd == WIN_MULTWRITE_EXT) {
ide_startstop_t startstop; ide_startstop_t startstop;
if (ide_wait_stat(&startstop, drive, rq, DATA_READY, drive->bad_wstat, WAIT_DRQ)) { if (ata_status_poll(drive, DATA_READY, drive->bad_wstat,
WAIT_DRQ, rq, &startstop)) {
printk(KERN_ERR "%s: no DRQ after issuing %s\n", printk(KERN_ERR "%s: no DRQ after issuing %s\n",
drive->name, drive->mult_count ? "MULTWRITE" : "WRITE"); drive->name, drive->mult_count ? "MULTWRITE" : "WRITE");
return startstop; return startstop;
......
This diff is collapsed.
...@@ -430,7 +430,7 @@ void ide_unregister(struct ata_channel *ch) ...@@ -430,7 +430,7 @@ void ide_unregister(struct ata_channel *ch)
struct ata_device *drive = &ch->drives[i]; struct ata_device *drive = &ch->drives[i];
if (drive->de) { if (drive->de) {
devfs_unregister (drive->de); devfs_unregister(drive->de);
drive->de = NULL; drive->de = NULL;
} }
if (!drive->present) if (!drive->present)
...@@ -1246,7 +1246,7 @@ static int ata_sys_notify(struct notifier_block *this, unsigned long event, void ...@@ -1246,7 +1246,7 @@ static int ata_sys_notify(struct notifier_block *this, unsigned long event, void
return NOTIFY_DONE; return NOTIFY_DONE;
} }
printk("flushing ide devices: "); printk(KERN_INFO "flushing ATA/ATAPI devices: ");
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
int unit; int unit;
...@@ -1264,9 +1264,10 @@ static int ata_sys_notify(struct notifier_block *this, unsigned long event, void ...@@ -1264,9 +1264,10 @@ static int ata_sys_notify(struct notifier_block *this, unsigned long event, void
/* set the drive to standby */ /* set the drive to standby */
printk("%s ", drive->name); printk("%s ", drive->name);
if (ata_ops(drive)) { if (ata_ops(drive)) {
if (event != SYS_RESTART) if (event != SYS_RESTART) {
if (ata_ops(drive)->standby && ata_ops(drive)->standby(drive)) if (ata_ops(drive)->standby && ata_ops(drive)->standby(drive))
continue; continue;
}
if (ata_ops(drive)->cleanup) if (ata_ops(drive)->cleanup)
ata_ops(drive)->cleanup(drive); ata_ops(drive)->cleanup(drive);
...@@ -1290,8 +1291,7 @@ static int __init ata_module_init(void) ...@@ -1290,8 +1291,7 @@ static int __init ata_module_init(void)
{ {
printk(KERN_INFO "ATA/ATAPI device driver v" VERSION "\n"); printk(KERN_INFO "ATA/ATAPI device driver v" VERSION "\n");
ide_devfs_handle = devfs_mk_dir(NULL, "ata", NULL); ide_devfs_handle = devfs_mk_dir(NULL, "ide", NULL);
devfs_mk_symlink(NULL, "ide", DEVFS_FL_DEFAULT, "ata", NULL, NULL);
/* /*
* Because most of the ATA adapters represent the timings in unit of * Because most of the ATA adapters represent the timings in unit of
......
...@@ -44,7 +44,17 @@ ide_startstop_t ide_dma_intr(struct ata_device *drive, struct request *rq) ...@@ -44,7 +44,17 @@ ide_startstop_t ide_dma_intr(struct ata_device *drive, struct request *rq)
if (ata_status(drive, DRIVE_READY, drive->bad_wstat | DRQ_STAT)) { if (ata_status(drive, DRIVE_READY, drive->bad_wstat | DRQ_STAT)) {
if (!dma_stat) { if (!dma_stat) {
__ide_end_request(drive, rq, 1, rq->nr_sectors); unsigned long flags;
struct ata_channel *ch = drive->channel;
/* FIXME: this locking should encompass the above register
* file access too.
*/
spin_lock_irqsave(ch->lock, flags);
__ata_end_request(drive, rq, 1, rq->nr_sectors);
spin_unlock_irqrestore(ch->lock, flags);
return ide_stopped; return ide_stopped;
} }
printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n",
......
...@@ -247,7 +247,8 @@ int __init setup_pdc4030(struct ata_channel *hwif) ...@@ -247,7 +247,8 @@ int __init setup_pdc4030(struct ata_channel *hwif)
if (pdc4030_cmd(drive, PROMISE_GET_CONFIG)) { if (pdc4030_cmd(drive, PROMISE_GET_CONFIG)) {
return 0; return 0;
} }
if (ide_wait_stat(&startstop, drive, NULL, DATA_READY,BAD_W_STAT,WAIT_DRQ)) { if (ata_status_poll(drive, DATA_READY, BAD_W_STAT,
WAIT_DRQ, NULL, &startstop)) {
printk(KERN_INFO printk(KERN_INFO
"%s: Failed Promise read config!\n",hwif->name); "%s: Failed Promise read config!\n",hwif->name);
return 0; return 0;
...@@ -407,7 +408,8 @@ static ide_startstop_t promise_read_intr(struct ata_device *drive, struct reques ...@@ -407,7 +408,8 @@ static ide_startstop_t promise_read_intr(struct ata_device *drive, struct reques
rq->nr_sectors -= nsect; rq->nr_sectors -= nsect;
total_remaining = rq->nr_sectors; total_remaining = rq->nr_sectors;
if ((rq->current_nr_sectors -= nsect) <= 0) { if ((rq->current_nr_sectors -= nsect) <= 0) {
ide_end_request(drive, rq, 1); /* FIXME: no queue locking above! */
ata_end_request(drive, rq, 1);
} }
/* /*
...@@ -461,13 +463,11 @@ static ide_startstop_t promise_read_intr(struct ata_device *drive, struct reques ...@@ -461,13 +463,11 @@ static ide_startstop_t promise_read_intr(struct ata_device *drive, struct reques
*/ */
static ide_startstop_t promise_complete_pollfunc(struct ata_device *drive, struct request *rq) static ide_startstop_t promise_complete_pollfunc(struct ata_device *drive, struct request *rq)
{ {
unsigned long flags;
struct ata_channel *ch = drive->channel; struct ata_channel *ch = drive->channel;
if (!ata_status(drive, 0, BUSY_STAT)) { if (!ata_status(drive, 0, BUSY_STAT)) {
if (time_before(jiffies, ch->poll_timeout)) { if (time_before(jiffies, ch->poll_timeout)) {
unsigned long flags;
struct ata_channel *ch = drive->channel;
/* FIXME: this locking should encompass the above /* FIXME: this locking should encompass the above
* register file access too. * register file access too.
*/ */
...@@ -488,7 +488,13 @@ static ide_startstop_t promise_complete_pollfunc(struct ata_device *drive, struc ...@@ -488,7 +488,13 @@ static ide_startstop_t promise_complete_pollfunc(struct ata_device *drive, struc
#ifdef DEBUG_WRITE #ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name); printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name);
#endif #endif
__ide_end_request(drive, rq, 1, rq->nr_sectors); /* FIXME: this locking should encompass the above
* register file access too.
*/
spin_lock_irqsave(ch->lock, flags);
__ata_end_request(drive, rq, 1, rq->nr_sectors);
spin_unlock_irqrestore(ch->lock, flags);
return ide_stopped; return ide_stopped;
} }
...@@ -653,7 +659,7 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg ...@@ -653,7 +659,7 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg
/* Check that it's a regular command. If not, bomb out early. */ /* Check that it's a regular command. If not, bomb out early. */
if (!(rq->flags & REQ_CMD)) { if (!(rq->flags & REQ_CMD)) {
blk_dump_rq_flags(rq, "pdc4030 bad flags"); blk_dump_rq_flags(rq, "pdc4030 bad flags");
ide_end_request(drive, rq, 0); ata_end_request(drive, rq, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -721,7 +727,8 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg ...@@ -721,7 +727,8 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg
* call the promise_write function to deal with writing the data out * call the promise_write function to deal with writing the data out
* NOTE: No interrupts are generated on writes. Write completion must be polled * NOTE: No interrupts are generated on writes. Write completion must be polled
*/ */
if (ide_wait_stat(&startstop, drive, rq, DATA_READY, drive->bad_wstat, WAIT_DRQ)) { if (ata_status_poll(drive, DATA_READY, drive->bad_wstat,
WAIT_DRQ, rq, &startstop )) {
printk(KERN_ERR "%s: no DRQ after issuing " printk(KERN_ERR "%s: no DRQ after issuing "
"PROMISE_WRITE\n", drive->name); "PROMISE_WRITE\n", drive->name);
return startstop; return startstop;
...@@ -733,7 +740,8 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg ...@@ -733,7 +740,8 @@ ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *arg
default: default:
printk(KERN_ERR "pdc4030: command not READ or WRITE! Huh?\n"); printk(KERN_ERR "pdc4030: command not READ or WRITE! Huh?\n");
ide_end_request(drive, rq, 0); /* FIXME: This should already run under the lock. */
ata_end_request(drive, rq, 0);
return ide_stopped; return ide_stopped;
} }
} }
......
...@@ -307,16 +307,7 @@ byte eighty_ninty_three(struct ata_device *drive) ...@@ -307,16 +307,7 @@ byte eighty_ninty_three(struct ata_device *drive)
(drive->id->hw_config & 0x6000)) ? 1 : 0); (drive->id->hw_config & 0x6000)) ? 1 : 0);
} }
/* /* FIXME: Channel lock should be held.
* Similar to ide_wait_stat(), except it never calls ata_error internally.
* This is a kludge to handle the new ide_config_drive_speed() function,
* and should not otherwise be used anywhere. Eventually, the tuneproc's
* should be updated to return ide_startstop_t, in which case we can get
* rid of this abomination again. :) -ml
*
* It is gone..........
*
* const char *msg == consider adding for verbose errors.
*/ */
int ide_config_drive_speed(struct ata_device *drive, byte speed) int ide_config_drive_speed(struct ata_device *drive, byte speed)
{ {
...@@ -329,12 +320,10 @@ int ide_config_drive_speed(struct ata_device *drive, byte speed) ...@@ -329,12 +320,10 @@ int ide_config_drive_speed(struct ata_device *drive, byte speed)
outb(inb(ch->dma_base + 2) & ~(1 << (5 + unit)), ch->dma_base + 2); outb(inb(ch->dma_base + 2) & ~(1 << (5 + unit)), ch->dma_base + 2);
#endif #endif
/* /* Don't use ide_wait_cmd here - it will attempt to set_geometry and
* Don't use ide_wait_cmd here - it will attempt to set_geometry and
* recalibrate, but for some reason these don't work at this point * recalibrate, but for some reason these don't work at this point
* (lost interrupt). * (lost interrupt).
*/ *
/*
* Select the drive, and issue the SETFEATURES command * Select the drive, and issue the SETFEATURES command
*/ */
disable_irq(ch->irq); /* disable_irq_nosync ?? */ disable_irq(ch->irq); /* disable_irq_nosync ?? */
...@@ -350,20 +339,7 @@ int ide_config_drive_speed(struct ata_device *drive, byte speed) ...@@ -350,20 +339,7 @@ int ide_config_drive_speed(struct ata_device *drive, byte speed)
ata_irq_enable(drive, 1); ata_irq_enable(drive, 1);
udelay(1); udelay(1);
/* ata_busy_poll(drive, WAIT_CMD);
* Wait for drive to become non-BUSY
*/
if (!ata_status(drive, 0, BUSY_STAT)) {
unsigned long flags, timeout;
__save_flags(flags); /* local CPU only */
ide__sti(); /* local CPU only -- for jiffies */
timeout = jiffies + WAIT_CMD;
while (!ata_status(drive, 0, BUSY_STAT)) {
if (time_after(jiffies, timeout))
break;
}
__restore_flags(flags); /* local CPU only */
}
/* /*
* Allow status to settle, then read it again. * Allow status to settle, then read it again.
......
...@@ -327,6 +327,8 @@ static ide_startstop_t check_service(struct ata_device *drive, struct request *r ...@@ -327,6 +327,8 @@ static ide_startstop_t check_service(struct ata_device *drive, struct request *r
static ide_startstop_t dmaq_complete(struct ata_device *drive, struct request *rq) static ide_startstop_t dmaq_complete(struct ata_device *drive, struct request *rq)
{ {
unsigned long flags;
struct ata_channel *ch = drive->channel;
u8 dma_stat; u8 dma_stat;
/* /*
...@@ -348,7 +350,14 @@ static ide_startstop_t dmaq_complete(struct ata_device *drive, struct request *r ...@@ -348,7 +350,14 @@ static ide_startstop_t dmaq_complete(struct ata_device *drive, struct request *r
printk("%s: bad DMA status (dma_stat=%x)\n", drive->name, dma_stat); printk("%s: bad DMA status (dma_stat=%x)\n", drive->name, dma_stat);
TCQ_PRINTK("%s: ending %p, tag %d\n", __FUNCTION__, rq, rq->tag); TCQ_PRINTK("%s: ending %p, tag %d\n", __FUNCTION__, rq, rq->tag);
__ide_end_request(drive, rq, !dma_stat, rq->nr_sectors);
/* FIXME: this locking should encompass the above register
* file access too.
*/
spin_lock_irqsave(ch->lock, flags);
__ata_end_request(drive, rq, !dma_stat, rq->nr_sectors);
spin_unlock_irqrestore(ch->lock, flags);
/* /*
* we completed this command, check if we can service a new command * we completed this command, check if we can service a new command
......
...@@ -244,7 +244,7 @@ static int idescsi_end_request(struct ata_device *drive, struct request *rq, int ...@@ -244,7 +244,7 @@ static int idescsi_end_request(struct ata_device *drive, struct request *rq, int
unsigned long flags; unsigned long flags;
if (!(rq->flags & REQ_PC)) { if (!(rq->flags & REQ_PC)) {
ide_end_request(drive, rq, uptodate); ata_end_request(drive, rq, uptodate);
return 0; return 0;
} }
...@@ -399,29 +399,33 @@ static ide_startstop_t idescsi_transfer_pc(struct ata_device *drive, struct requ ...@@ -399,29 +399,33 @@ static ide_startstop_t idescsi_transfer_pc(struct ata_device *drive, struct requ
struct Scsi_Host *host = drive->driver_data; struct Scsi_Host *host = drive->driver_data;
idescsi_scsi_t *scsi = idescsi_private(host); idescsi_scsi_t *scsi = idescsi_private(host);
struct atapi_packet_command *pc = scsi->pc; struct atapi_packet_command *pc = scsi->pc;
byte ireason; u8 ireason;
ide_startstop_t startstop; ide_startstop_t startstop;
int ret;
if (ide_wait_stat(&startstop, drive, rq, DRQ_STAT, BUSY_STAT, WAIT_READY)) { if (ata_status_poll(drive, DRQ_STAT, BUSY_STAT,
WAIT_READY, rq, &startstop)) {
printk (KERN_ERR "ide-scsi: Strange, packet command initiated yet DRQ isn't asserted\n"); printk (KERN_ERR "ide-scsi: Strange, packet command initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
ireason = IN_BYTE (IDE_IREASON_REG);
if ((ireason & (IDESCSI_IREASON_IO | IDESCSI_IREASON_COD)) != IDESCSI_IREASON_COD) {
printk (KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while issuing a packet command\n");
return ide_stopped;
}
/* FIXME: this locking should encompass the above register /* FIXME: this locking should encompass the above register
* file access too. * file access too.
*/ */
spin_lock_irqsave(ch->lock, flags); spin_lock_irqsave(ch->lock, flags);
ata_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL); /* Set the interrupt routine */ ireason = IN_BYTE(IDE_IREASON_REG);
if ((ireason & (IDESCSI_IREASON_IO | IDESCSI_IREASON_COD)) != IDESCSI_IREASON_COD) {
printk (KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while issuing a packet command\n");
ret = ide_stopped;
} else {
ata_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL);
atapi_write(drive, scsi->pc->c, 12);
ret = ide_started;
}
spin_unlock_irqrestore(ch->lock, flags); spin_unlock_irqrestore(ch->lock, flags);
atapi_write(drive, scsi->pc->c, 12); /* Send the actual packet */ return ret;
return ide_started;
} }
/* /*
......
...@@ -601,8 +601,9 @@ extern int noautodma; ...@@ -601,8 +601,9 @@ extern int noautodma;
#define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */ #define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
#include <linux/blk.h> #include <linux/blk.h>
extern int __ide_end_request(struct ata_device *, struct request *, int, unsigned int); /* Not locking and locking variant: */
extern int ide_end_request(struct ata_device *drive, struct request *, int); extern int __ata_end_request(struct ata_device *, struct request *, int, unsigned int);
extern int ata_end_request(struct ata_device *drive, struct request *, int);
extern void ata_set_handler(struct ata_device *drive, ata_handler_t handler, extern void ata_set_handler(struct ata_device *drive, ata_handler_t handler,
unsigned long timeout, ata_expiry_t expiry); unsigned long timeout, ata_expiry_t expiry);
...@@ -611,11 +612,6 @@ extern u8 ata_dump(struct ata_device *, struct request *, const char *); ...@@ -611,11 +612,6 @@ extern u8 ata_dump(struct ata_device *, struct request *, const char *);
extern ide_startstop_t ata_error(struct ata_device *, struct request *rq, const char *); extern ide_startstop_t ata_error(struct ata_device *, struct request *rq, const char *);
extern void ide_fixstring(char *s, const int bytecount, const int byteswap); extern void ide_fixstring(char *s, const int bytecount, const int byteswap);
extern int ide_wait_stat(ide_startstop_t *,
struct ata_device *, struct request *rq,
byte, byte, unsigned long);
extern int ide_wait_noerr(struct ata_device *, byte, byte, unsigned long); extern int ide_wait_noerr(struct ata_device *, byte, byte, unsigned long);
/* /*
...@@ -831,7 +827,11 @@ extern int drive_is_ready(struct ata_device *drive); ...@@ -831,7 +827,11 @@ extern int drive_is_ready(struct ata_device *drive);
extern void ata_select(struct ata_device *, unsigned long); extern void ata_select(struct ata_device *, unsigned long);
extern void ata_mask(struct ata_device *); extern void ata_mask(struct ata_device *);
extern int ata_busy_poll(struct ata_device *, unsigned long);
extern int ata_status(struct ata_device *, u8, u8); extern int ata_status(struct ata_device *, u8, u8);
extern int ata_status_poll( struct ata_device *, u8, u8,
unsigned long, struct request *rq, ide_startstop_t *);
extern int ata_irq_enable(struct ata_device *, int); extern int ata_irq_enable(struct ata_device *, int);
extern void ata_reset(struct ata_channel *); extern void ata_reset(struct ata_channel *);
extern void ata_out_regfile(struct ata_device *, struct hd_drive_task_hdr *); extern void ata_out_regfile(struct ata_device *, struct hd_drive_task_hdr *);
......
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