Commit ffd630eb authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] kill drivers/ide TCQ support

Lets just remove it. It's been disabled some time ago, and there's no
chance of it ever getting resurrected. PATA TCQ has so many technical
short comings, that it was never really interesting I'm afraid.
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bb9cdaf2
......@@ -424,48 +424,6 @@ config BLK_DEV_IDEDMA_PCI
if BLK_DEV_IDEDMA_PCI
# TCQ is disabled for now
config BLK_DEV_IDE_TCQ
bool "ATA tagged command queueing (EXPERIMENTAL)"
depends on EXPERIMENTAL && n
help
Support for tagged command queueing on ATA disk drives. This enables
the IDE layer to have multiple in-flight requests on hardware that
supports it. For now this includes the IBM Deskstar series drives,
such as the 22GXP, 75GXP, 40GV, 60GXP, and 120GXP (ie any Deskstar made
in the last couple of years), and at least some of the Western
Digital drives in the Expert series (by nature of really being IBM
drives).
If you have such a drive, say Y here.
config BLK_DEV_IDE_TCQ_DEFAULT
bool "TCQ on by default"
depends on BLK_DEV_IDE_TCQ
---help---
Enable tagged command queueing unconditionally on drives that report
support for it. Regardless of the chosen value here, tagging can be
controlled at run time:
echo "using_tcq:32" > /proc/ide/hdX/settings
where any value between 1-32 selects chosen queue depth and enables
TCQ, and 0 disables it. hdparm version 4.7 an above also support
TCQ manipulations.
Generally say Y here.
config BLK_DEV_IDE_TCQ_DEPTH
int "Default queue depth"
depends on BLK_DEV_IDE_TCQ
default "8"
help
Maximum size of commands to enable per-drive. Any value between 1
and 32 is valid, with 32 being the maxium that the hardware supports.
You probably just want the default of 32 here. If you enter an invalid
number, the default value will be used.
config BLK_DEV_IDEDMA_FORCED
bool "Force enable legacy 2.0.X HOSTS to use DMA"
help
......
......@@ -120,20 +120,6 @@ static int lba_capacity_is_ok (struct hd_driveid *id)
return 0; /* lba_capacity value may be bad */
}
static int idedisk_start_tag(ide_drive_t *drive, struct request *rq)
{
unsigned long flags;
int ret = 1;
spin_lock_irqsave(&ide_lock, flags);
if (ata_pending_commands(drive) < drive->queue_depth)
ret = blk_queue_start_tag(drive->queue, rq);
spin_unlock_irqrestore(&ide_lock, flags);
return ret;
}
#ifndef CONFIG_IDE_TASKFILE_IO
/*
......@@ -369,18 +355,10 @@ ide_startstop_t __ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector
pr_debug("%s: LBA=0x%012llx\n", drive->name, block);
if (blk_rq_tagged(rq)) {
tasklets[0] = nsectors.b.low;
tasklets[1] = nsectors.b.high;
tasklets[2] = rq->tag << 3;
tasklets[3] = 0;
} else {
tasklets[0] = 0;
tasklets[1] = 0;
tasklets[2] = nsectors.b.low;
tasklets[3] = nsectors.b.high;
}
tasklets[0] = 0;
tasklets[1] = 0;
tasklets[2] = nsectors.b.low;
tasklets[3] = nsectors.b.high;
tasklets[4] = (task_ioreg_t) block;
tasklets[5] = (task_ioreg_t) (block>>8);
tasklets[6] = (task_ioreg_t) (block>>16);
......@@ -411,14 +389,8 @@ ide_startstop_t __ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector
hwif->OUTB(tasklets[6], IDE_HCYL_REG);
hwif->OUTB(0x00|drive->select.all,IDE_SELECT_REG);
} else {
if (blk_rq_tagged(rq)) {
hwif->OUTB(nsectors.b.low, IDE_FEATURE_REG);
hwif->OUTB(rq->tag << 3, IDE_NSECTOR_REG);
} else {
hwif->OUTB(0x00, IDE_FEATURE_REG);
hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
}
hwif->OUTB(0x00, IDE_FEATURE_REG);
hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
hwif->OUTB(block, IDE_SECTOR_REG);
hwif->OUTB(block>>=8, IDE_LCYL_REG);
hwif->OUTB(block>>=8, IDE_HCYL_REG);
......@@ -434,23 +406,14 @@ ide_startstop_t __ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector
pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect);
if (blk_rq_tagged(rq)) {
hwif->OUTB(nsectors.b.low, IDE_FEATURE_REG);
hwif->OUTB(rq->tag << 3, IDE_NSECTOR_REG);
} else {
hwif->OUTB(0x00, IDE_FEATURE_REG);
hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
}
hwif->OUTB(0x00, IDE_FEATURE_REG);
hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
hwif->OUTB(cyl, IDE_LCYL_REG);
hwif->OUTB(cyl>>8, IDE_HCYL_REG);
hwif->OUTB(head|drive->select.all,IDE_SELECT_REG);
}
if (rq_data_dir(rq) == READ) {
#ifdef CONFIG_BLK_DEV_IDE_TCQ
if (blk_rq_tagged(rq))
return __ide_dma_queued_read(drive);
#endif
if (drive->using_dma && !hwif->ide_dma_read(drive))
return ide_started;
......@@ -461,10 +424,7 @@ ide_startstop_t __ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector
return ide_started;
} else {
ide_startstop_t startstop;
#ifdef CONFIG_BLK_DEV_IDE_TCQ
if (blk_rq_tagged(rq))
return __ide_dma_queued_write(drive);
#endif
if (drive->using_dma && !(HWIF(drive)->ide_dma_write(drive)))
return ide_started;
......@@ -534,8 +494,6 @@ static u8 get_command(ide_drive_t *drive, int cmd, ide_task_t *task)
if (cmd == READ) {
task->command_type = IDE_DRIVE_TASK_IN;
if (drive->using_tcq)
return lba48 ? WIN_READDMA_QUEUED_EXT : WIN_READDMA_QUEUED;
if (drive->using_dma)
return lba48 ? WIN_READDMA_EXT : WIN_READDMA;
if (drive->mult_count) {
......@@ -546,8 +504,6 @@ static u8 get_command(ide_drive_t *drive, int cmd, ide_task_t *task)
return lba48 ? WIN_READ_EXT : WIN_READ;
} else {
task->command_type = IDE_DRIVE_TASK_RAW_WRITE;
if (drive->using_tcq)
return lba48 ? WIN_WRITEDMA_QUEUED_EXT : WIN_WRITEDMA_QUEUED;
if (drive->using_dma)
return lba48 ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
if (drive->mult_count) {
......@@ -579,12 +535,7 @@ static ide_startstop_t chs_rw_disk (ide_drive_t *drive, struct request *rq, unsi
sectors = (rq->nr_sectors == 256) ? 0x00 : rq->nr_sectors;
if (blk_rq_tagged(rq)) {
args.tfRegister[IDE_FEATURE_OFFSET] = sectors;
args.tfRegister[IDE_NSECTOR_OFFSET] = rq->tag << 3;
} else
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.tfRegister[IDE_SECTOR_OFFSET] = sect;
args.tfRegister[IDE_LCYL_OFFSET] = cyl;
args.tfRegister[IDE_HCYL_OFFSET] = (cyl>>8);
......@@ -608,12 +559,7 @@ static ide_startstop_t lba_28_rw_disk (ide_drive_t *drive, struct request *rq, u
sectors = (rq->nr_sectors == 256) ? 0x00 : rq->nr_sectors;
if (blk_rq_tagged(rq)) {
args.tfRegister[IDE_FEATURE_OFFSET] = sectors;
args.tfRegister[IDE_NSECTOR_OFFSET] = rq->tag << 3;
} else
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.tfRegister[IDE_SECTOR_OFFSET] = block;
args.tfRegister[IDE_LCYL_OFFSET] = (block>>=8);
args.tfRegister[IDE_HCYL_OFFSET] = (block>>=8);
......@@ -643,16 +589,8 @@ static ide_startstop_t lba_48_rw_disk (ide_drive_t *drive, struct request *rq, u
sectors = (rq->nr_sectors == 65536) ? 0 : rq->nr_sectors;
if (blk_rq_tagged(rq)) {
args.tfRegister[IDE_FEATURE_OFFSET] = sectors;
args.tfRegister[IDE_NSECTOR_OFFSET] = rq->tag << 3;
args.hobRegister[IDE_FEATURE_OFFSET] = sectors >> 8;
args.hobRegister[IDE_NSECTOR_OFFSET] = 0;
} else {
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.hobRegister[IDE_NSECTOR_OFFSET] = sectors >> 8;
}
args.tfRegister[IDE_NSECTOR_OFFSET] = sectors;
args.hobRegister[IDE_NSECTOR_OFFSET] = sectors >> 8;
args.tfRegister[IDE_SECTOR_OFFSET] = block; /* low lba */
args.tfRegister[IDE_LCYL_OFFSET] = (block>>=8); /* mid lba */
args.tfRegister[IDE_HCYL_OFFSET] = (block>>=8); /* hi lba */
......@@ -682,13 +620,6 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s
return ide_stopped;
}
if (drive->using_tcq && idedisk_start_tag(drive, rq)) {
if (!ata_pending_commands(drive))
BUG();
return ide_started;
}
pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n",
drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
block, rq->nr_sectors, (unsigned long)rq->buffer);
......@@ -1356,34 +1287,6 @@ static int set_acoustic (ide_drive_t *drive, int arg)
return 0;
}
#ifdef CONFIG_BLK_DEV_IDE_TCQ
static int set_using_tcq(ide_drive_t *drive, int arg)
{
int ret;
if (!drive->driver)
return -EPERM;
if (arg == drive->queue_depth && drive->using_tcq)
return 0;
/*
* set depth, but check also id for max supported depth
*/
drive->queue_depth = arg ? arg : 1;
if (drive->id) {
if (drive->queue_depth > drive->id->queue_depth + 1)
drive->queue_depth = drive->id->queue_depth + 1;
}
if (arg)
ret = __ide_dma_queued_on(drive);
else
ret = __ide_dma_queued_off(drive);
return ret ? -EIO : 0;
}
#endif
/*
* drive->addressing:
* 0: 28-bit
......@@ -1419,9 +1322,6 @@ static void idedisk_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "acoustic", SETTING_RW, HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, TYPE_BYTE, 0, 254, 1, 1, &drive->acoustic, set_acoustic);
ide_add_setting(drive, "failures", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->failures, NULL);
ide_add_setting(drive, "max_failures", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL);
#ifdef CONFIG_BLK_DEV_IDE_TCQ
ide_add_setting(drive, "using_tcq", SETTING_RW, HDIO_GET_QDMA, HDIO_SET_QDMA, TYPE_BYTE, 0, IDE_MAX_TAG, 1, 1, &drive->using_tcq, set_using_tcq);
#endif
}
/*
......@@ -1632,11 +1532,6 @@ static void idedisk_setup (ide_drive_t *drive)
drive->wcache = 1;
write_cache(drive, 1);
#ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT
if (drive->using_dma)
__ide_dma_queued_on(drive);
#endif
}
static void ide_cacheflush_p(ide_drive_t *drive)
......
......@@ -513,9 +513,7 @@ int __ide_dma_off_quietly (ide_drive_t *drive)
if (HWIF(drive)->ide_dma_host_off(drive))
return 1;
#ifdef CONFIG_BLK_DEV_IDE_TCQ
__ide_dma_queued_off(drive);
#endif
return 0;
}
......
......@@ -97,10 +97,7 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
if (!end_that_request_first(rq, uptodate, nr_sectors)) {
add_disk_randomness(rq->rq_disk);
if (!blk_rq_tagged(rq))
blkdev_dequeue_request(rq);
else
blk_queue_end_tag(drive->queue, rq);
blkdev_dequeue_request(rq);
HWGROUP(drive)->rq = NULL;
end_that_request_last(rq);
ret = 0;
......@@ -855,18 +852,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
drive->sleep = 0;
drive->service_start = jiffies;
queue_next:
if (!ata_can_queue(drive)) {
if (!ata_pending_commands(drive))
hwgroup->busy = 0;
break;
}
if (blk_queue_plugged(drive->queue)) {
if (drive->using_tcq)
break;
printk(KERN_ERR "ide: huh? queue was plugged!\n");
break;
}
......@@ -877,7 +863,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
*/
rq = elv_next_request(drive->queue);
if (!rq) {
hwgroup->busy = !!ata_pending_commands(drive);
hwgroup->busy = 0;
break;
}
......@@ -900,9 +886,6 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
break;
}
if (!rq->bio && ata_pending_commands(drive))
break;
hwgroup->rq = rq;
/*
......@@ -922,8 +905,6 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
spin_lock_irq(&ide_lock);
if (hwif->irq != masked_irq)
enable_irq(hwif->irq);
if (startstop == ide_released)
goto queue_next;
if (startstop == ide_stopped)
hwgroup->busy = 0;
}
......
......@@ -241,17 +241,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
drive->media = ide_disk;
printk("%s DISK drive\n", (drive->is_flash) ? "CFA" : "ATA" );
QUIRK_LIST(drive);
/* Initialize queue depth settings */
drive->queue_depth = 1;
#ifdef CONFIG_BLK_DEV_IDE_TCQ_DEPTH
drive->queue_depth = CONFIG_BLK_DEV_IDE_TCQ_DEPTH;
#else
drive->queue_depth = drive->id->queue_depth + 1;
#endif
if (drive->queue_depth < 1 || drive->queue_depth > IDE_MAX_TAG)
drive->queue_depth = IDE_MAX_TAG;
return;
err_misc:
......
......@@ -201,14 +201,6 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
if (!hwif->ide_dma_read(drive))
return ide_started;
break;
#ifdef CONFIG_BLK_DEV_IDE_TCQ
case WIN_READDMA_QUEUED:
case WIN_READDMA_QUEUED_EXT:
return __ide_dma_queued_read(drive);
case WIN_WRITEDMA_QUEUED:
case WIN_WRITEDMA_QUEUED_EXT:
return __ide_dma_queued_write(drive);
#endif
default:
if (task->handler == NULL)
return ide_stopped;
......
/*
* Copyright (C) 2001, 2002 Jens Axboe <axboe@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Support for the DMA queued protocol, which enables ATA disk drives to
* use tagged command queueing.
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ide.h>
#include <asm/io.h>
#include <asm/delay.h>
/*
* warning: it will be _very_ verbose if defined
*/
#undef IDE_TCQ_DEBUG
#ifdef IDE_TCQ_DEBUG
#define TCQ_PRINTK printk
#else
#define TCQ_PRINTK(x...)
#endif
/*
* use nIEN or not
*/
#undef IDE_TCQ_NIEN
/*
* we are leaving the SERVICE interrupt alone, IBM drives have it
* on per default and it can't be turned off. Doesn't matter, this
* is the sane config.
*/
#undef IDE_TCQ_FIDDLE_SI
/*
* bad drive blacklist, for drives that raport tcq capability but don't
* work reliably with the default config. initially from freebsd table.
*/
struct ide_tcq_blacklist {
char *model;
char works;
unsigned int max_sectors;
};
static struct ide_tcq_blacklist ide_tcq_blacklist[] = {
{
.model = "IBM-DTTA",
.works = 1,
.max_sectors = 128,
},
{
.model = "IBM-DJNA",
.works = 0,
},
{
.model = "WDC AC",
.works = 0,
},
{
.model = NULL,
},
};
ide_startstop_t ide_dmaq_intr(ide_drive_t *drive);
ide_startstop_t ide_service(ide_drive_t *drive);
static struct ide_tcq_blacklist *ide_find_drive_blacklist(ide_drive_t *drive)
{
struct ide_tcq_blacklist *itb;
int i = 0;
do {
itb = &ide_tcq_blacklist[i];
if (!itb->model)
break;
if (!strncmp(drive->id->model, itb->model, strlen(itb->model)))
return itb;
i++;
} while (1);
return NULL;
}
static inline void drive_ctl_nien(ide_drive_t *drive, int set)
{
#ifdef IDE_TCQ_NIEN
if (IDE_CONTROL_REG) {
int mask = set ? 0x02 : 0x00;
hwif->OUTB(drive->ctl | mask, IDE_CONTROL_REG);
}
#endif
}
static ide_startstop_t ide_tcq_nop_handler(ide_drive_t *drive)
{
ide_task_t *args = HWGROUP(drive)->rq->special;
ide_hwif_t *hwif = HWIF(drive);
int auto_poll_check = 0;
u8 stat, err;
if (args->tfRegister[IDE_FEATURE_OFFSET] & 0x01)
auto_poll_check = 1;
local_irq_enable();
stat = hwif->INB(IDE_STATUS_REG);
err = hwif->INB(IDE_ERROR_REG);
ide_end_drive_cmd(drive, stat, err);
/*
* do taskfile and check ABRT bit -- intelligent adapters will not
* pass NOP with sub-code 0x01 to device, so the command will not
* fail there
*/
if (auto_poll_check) {
if (!(args->tfRegister[IDE_FEATURE_OFFSET] & ABRT_ERR)) {
HWIF(drive)->auto_poll = 1;
printk("%s: NOP Auto-poll enabled\n",HWIF(drive)->name);
}
}
kfree(args);
return ide_stopped;
}
/*
* if we encounter _any_ error doing I/O to one of the tags, we must
* invalidate the pending queue. clear the software busy queue and requeue
* on the request queue for restart. issue a WIN_NOP to clear hardware queue
*/
static void ide_tcq_invalidate_queue(ide_drive_t *drive)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
request_queue_t *q = drive->queue;
struct request *rq;
unsigned long flags;
printk("%s: invalidating tag queue (%d commands)\n", drive->name, ata_pending_commands(drive));
/*
* first kill timer and block queue
*/
spin_lock_irqsave(&ide_lock, flags);
del_timer(&hwgroup->timer);
if (HWIF(drive)->dma)
HWIF(drive)->ide_dma_end(drive);
blk_queue_invalidate_tags(q);
drive->using_tcq = 0;
drive->queue_depth = 1;
hwgroup->busy = 0;
hwgroup->handler = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
/*
* now kill hardware queue with a NOP
*/
rq = &hwgroup->wrq;
ide_init_drive_cmd(rq);
rq->buffer = hwgroup->cmd_buf;
memset(rq->buffer, 0, sizeof(hwgroup->cmd_buf));
rq->buffer[0] = WIN_NOP;
ide_do_drive_cmd(drive, rq, ide_preempt);
}
void ide_tcq_intr_timeout(unsigned long data)
{
ide_drive_t *drive = (ide_drive_t *) data;
ide_hwgroup_t *hwgroup = HWGROUP(drive);
ide_hwif_t *hwif = HWIF(drive);
unsigned long flags;
printk(KERN_ERR "ide_tcq_intr_timeout: timeout waiting for %s interrupt\n", hwgroup->rq ? "completion" : "service");
spin_lock_irqsave(&ide_lock, flags);
if (!hwgroup->busy)
printk(KERN_ERR "ide_tcq_intr_timeout: hwgroup not busy\n");
if (hwgroup->handler == NULL)
printk(KERN_ERR "ide_tcq_intr_timeout: missing isr!\n");
hwgroup->busy = 1;
spin_unlock_irqrestore(&ide_lock, flags);
/*
* if pending commands, try service before giving up
*/
if (ata_pending_commands(drive)) {
u8 stat = hwif->INB(IDE_STATUS_REG);
if ((stat & SRV_STAT) && (ide_service(drive) == ide_started))
return;
}
if (drive)
ide_tcq_invalidate_queue(drive);
}
void __ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
{
/*
* always just bump the timer for now, the timeout handling will
* have to be changed to be per-command
*/
hwgroup->timer.function = ide_tcq_intr_timeout;
hwgroup->timer.data = (unsigned long) hwgroup->drive;
mod_timer(&hwgroup->timer, jiffies + 5 * HZ);
hwgroup->handler = handler;
}
void ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
{
unsigned long flags;
spin_lock_irqsave(&ide_lock, flags);
__ide_tcq_set_intr(hwgroup, handler);
spin_unlock_irqrestore(&ide_lock, flags);
}
/*
* wait 400ns, then poll for busy_mask to clear from alt status
*/
#define IDE_TCQ_WAIT (10000)
int ide_tcq_wait_altstat(ide_drive_t *drive, byte *stat, byte busy_mask)
{
ide_hwif_t *hwif = HWIF(drive);
int i = 0;
udelay(1);
do {
*stat = hwif->INB(IDE_ALTSTATUS_REG);
if (!(*stat & busy_mask))
break;
if (unlikely(i++ > IDE_TCQ_WAIT))
return 1;
udelay(10);
} while (1);
return 0;
}
/*
* issue SERVICE command to drive -- drive must have been selected first,
* and it must have reported a need for service (status has SRV_STAT set)
*
* Also, nIEN must be set as not to need protection against ide_dmaq_intr
*/
ide_startstop_t ide_service(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
unsigned long flags;
struct request *rq;
byte feat, stat;
int tag;
TCQ_PRINTK("%s: started service\n", drive->name);
/*
* could be called with IDE_DMA in-progress from invalidate
* handler, refuse to do anything
*/
if (hwif->dma)
return ide_stopped;
/*
* need to select the right drive first...
*/
if (drive != HWGROUP(drive)->drive) {
SELECT_DRIVE(drive);
udelay(10);
}
drive_ctl_nien(drive, 1);
/*
* send SERVICE, wait 400ns, wait for BUSY_STAT to clear
*/
hwif->OUTB(WIN_QUEUED_SERVICE, IDE_COMMAND_REG);
if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
printk(KERN_ERR "ide_service: BUSY clear took too long\n");
ide_dump_status(drive, "ide_service", stat);
ide_tcq_invalidate_queue(drive);
return ide_stopped;
}
drive_ctl_nien(drive, 0);
/*
* FIXME, invalidate queue
*/
if (stat & ERR_STAT) {
ide_dump_status(drive, "ide_service", stat);
ide_tcq_invalidate_queue(drive);
return ide_stopped;
}
/*
* should not happen, a buggy device could introduce loop
*/
feat = hwif->INB(IDE_NSECTOR_REG);
if (feat & REL) {
HWGROUP(drive)->rq = NULL;
printk(KERN_ERR "%s: release in service\n", drive->name);
return ide_stopped;
}
tag = feat >> 3;
TCQ_PRINTK("ide_service: stat %x, feat %x\n", stat, feat);
spin_lock_irqsave(&ide_lock, flags);
if ((rq = blk_queue_find_tag(drive->queue, tag))) {
HWGROUP(drive)->rq = rq;
/*
* we'll start a dma read or write, device will trigger
* interrupt to indicate end of transfer, release is not
* allowed
*/
TCQ_PRINTK("ide_service: starting command, stat=%x\n", stat);
spin_unlock_irqrestore(&ide_lock, flags);
return __ide_dma_queued_start(drive);
}
printk(KERN_ERR "ide_service: missing request for tag %d\n", tag);
spin_unlock_irqrestore(&ide_lock, flags);
return ide_stopped;
}
ide_startstop_t ide_check_service(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
byte stat;
TCQ_PRINTK("%s: ide_check_service\n", drive->name);
if (!ata_pending_commands(drive))
return ide_stopped;
stat = hwif->INB(IDE_STATUS_REG);
if (stat & SRV_STAT)
return ide_service(drive);
/*
* we have pending commands, wait for interrupt
*/
TCQ_PRINTK("%s: wait for service interrupt\n", drive->name);
ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
return ide_started;
}
ide_startstop_t ide_dmaq_complete(ide_drive_t *drive, struct request *rq, byte stat)
{
byte dma_stat;
/*
* transfer was in progress, stop DMA engine
*/
dma_stat = HWIF(drive)->ide_dma_end(drive);
/*
* must be end of I/O, check status and complete as necessary
*/
if (unlikely(!OK_STAT(stat, READY_STAT, drive->bad_wstat | DRQ_STAT))) {
printk(KERN_ERR "ide_dmaq_intr: %s: error status %x\n",drive->name,stat);
ide_dump_status(drive, "ide_dmaq_complete", stat);
ide_tcq_invalidate_queue(drive);
return ide_stopped;
}
if (dma_stat)
printk(KERN_WARNING "%s: bad DMA status (dma_stat=%x)\n", drive->name, dma_stat);
TCQ_PRINTK("ide_dmaq_complete: ending %p, tag %d\n", rq, rq->tag);
ide_end_request(drive, 1, rq->nr_sectors);
/*
* we completed this command, check if we can service a new command
*/
return ide_check_service(drive);
}
/*
* intr handler for queued dma operations. this can be entered for two
* reasons:
*
* 1) device has completed dma transfer
* 2) service request to start a command
*
* if the drive has an active tag, we first complete that request before
* processing any pending SERVICE.
*/
ide_startstop_t ide_dmaq_intr(ide_drive_t *drive)
{
struct request *rq = HWGROUP(drive)->rq;
ide_hwif_t *hwif = HWIF(drive);
byte stat = hwif->INB(IDE_STATUS_REG);
TCQ_PRINTK("ide_dmaq_intr: stat=%x\n", stat);
/*
* if a command completion interrupt is pending, do that first and
* check service afterwards
*/
if (rq) {
TCQ_PRINTK("ide_dmaq_intr: completion\n");
return ide_dmaq_complete(drive, rq, stat);
}
/*
* service interrupt
*/
if (stat & SRV_STAT) {
TCQ_PRINTK("ide_dmaq_intr: SERV (stat=%x)\n", stat);
return ide_service(drive);
}
printk("ide_dmaq_intr: stat=%x, not expected\n", stat);
return ide_check_service(drive);
}
/*
* check if the ata adapter this drive is attached to supports the
* NOP auto-poll for multiple tcq enabled drives on one channel
*/
static int ide_tcq_check_autopoll(ide_drive_t *drive)
{
ide_task_t *args;
int i, drives;
/*
* only need to probe if both drives on a channel support tcq
*/
for (i = 0, drives = 0; i < MAX_DRIVES; i++)
if (HWIF(drive)->drives[i].present && drive->media == ide_disk)
drives++;
if (drives <= 1)
return 0;
/*
* what a mess...
*/
args = kmalloc(sizeof(*args), GFP_ATOMIC);
if (!args)
return 1;
memset(args, 0, sizeof(*args));
args->tfRegister[IDE_FEATURE_OFFSET] = 0x01;
args->tfRegister[IDE_COMMAND_OFFSET] = WIN_NOP;
args->command_type = IDE_DRIVE_TASK_NO_DATA;
args->handler = ide_tcq_nop_handler;
return ide_raw_taskfile(drive, args, NULL);
}
/*
* configure the drive for tcq
*/
static int ide_tcq_configure(ide_drive_t *drive)
{
int tcq_mask = 1 << 1 | 1 << 14;
int tcq_bits = tcq_mask | 1 << 15;
ide_task_t *args;
/*
* bit 14 and 1 must be set in word 83 of the device id to indicate
* support for dma queued protocol, and bit 15 must be cleared
*/
if ((drive->id->command_set_2 & tcq_bits) ^ tcq_mask) {
printk(KERN_INFO "%s: TCQ not supported\n", drive->name);
return -EIO;
}
args = kmalloc(sizeof(*args), GFP_ATOMIC);
if (!args)
return -ENOMEM;
memset(args, 0, sizeof(ide_task_t));
args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_WCACHE;
args->command_type = IDE_DRIVE_TASK_NO_DATA;
args->handler = &task_no_data_intr;
if (ide_raw_taskfile(drive, args, NULL)) {
printk(KERN_WARNING "%s: failed to enable write cache\n", drive->name);
goto err;
}
/*
* disable RELease interrupt, it's quicker to poll this after
* having sent the command opcode
*/
memset(args, 0, sizeof(ide_task_t));
args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_DIS_RI;
args->command_type = IDE_DRIVE_TASK_NO_DATA;
args->handler = &task_no_data_intr;
if (ide_raw_taskfile(drive, args, NULL)) {
printk(KERN_ERR "%s: disabling release interrupt fail\n", drive->name);
goto err;
}
#ifdef IDE_TCQ_FIDDLE_SI
/*
* enable SERVICE interrupt
*/
memset(args, 0, sizeof(ide_task_t));
args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_SI;
args->command_type = IDE_DRIVE_TASK_NO_DATA;
args->handler = &task_no_data_intr;
if (ide_raw_taskfile(drive, args, NULL)) {
printk(KERN_ERR "%s: enabling service interrupt fail\n", drive->name);
goto err;
}
#endif
kfree(args);
return 0;
err:
kfree(args);
return -EIO;
}
/*
* for now assume that command list is always as big as we need and don't
* attempt to shrink it on tcq disable
*/
static int ide_enable_queued(ide_drive_t *drive, int on)
{
struct ide_tcq_blacklist *itb;
int depth = drive->using_tcq ? drive->queue_depth : 0;
/*
* disable or adjust queue depth
*/
if (!on) {
if (drive->using_tcq)
printk(KERN_INFO "%s: TCQ disabled\n", drive->name);
drive->using_tcq = 0;
return 0;
}
if (ide_tcq_configure(drive)) {
drive->using_tcq = 0;
return 1;
}
/*
* some drives need limited transfer size in tcq
*/
itb = ide_find_drive_blacklist(drive);
if (itb && itb->max_sectors) {
if (itb->max_sectors > HWIF(drive)->rqsize)
itb->max_sectors = HWIF(drive)->rqsize;
blk_queue_max_sectors(drive->queue, itb->max_sectors);
}
/*
* enable block tagging
*/
if (!blk_queue_tagged(drive->queue))
blk_queue_init_tags(drive->queue, IDE_MAX_TAG, NULL);
/*
* check auto-poll support
*/
ide_tcq_check_autopoll(drive);
if (depth != drive->queue_depth)
printk(KERN_INFO "%s: tagged command queueing enabled, command queue depth %d\n", drive->name, drive->queue_depth);
drive->using_tcq = 1;
return 0;
}
int ide_tcq_wait_dataphase(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
byte stat;
int i;
do {
stat = hwif->INB(IDE_STATUS_REG);
if (!(stat & BUSY_STAT))
break;
udelay(10);
} while (1);
if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
return 0;
i = 0;
udelay(1);
do {
stat = hwif->INB(IDE_STATUS_REG);
if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
break;
++i;
if (unlikely(i >= IDE_TCQ_WAIT))
return 1;
udelay(10);
} while (1);
return 0;
}
static int ide_tcq_check_blacklist(ide_drive_t *drive)
{
struct ide_tcq_blacklist *itb = ide_find_drive_blacklist(drive);
if (!itb)
return 0;
return !itb->works;
}
int __ide_dma_queued_on(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
if (drive->media != ide_disk)
return 1;
if (!drive->using_dma)
return 1;
if (hwif->chipset == ide_pdc4030)
return 1;
if (ide_tcq_check_blacklist(drive)) {
printk(KERN_WARNING "%s: tcq forbidden by blacklist\n",
drive->name);
return 1;
}
if (hwif->drives[0].present && hwif->drives[1].present) {
printk(KERN_WARNING "%s: only one drive on a channel supported"
" for tcq\n", drive->name);
return 1;
}
if (ata_pending_commands(drive)) {
printk(KERN_WARNING "ide-tcq; can't toggle tcq feature on "
"busy drive\n");
return 1;
}
return ide_enable_queued(drive, 1);
}
int __ide_dma_queued_off(ide_drive_t *drive)
{
if (drive->media != ide_disk)
return 1;
if (ata_pending_commands(drive)) {
printk("ide-tcq; can't toggle tcq feature on busy drive\n");
return 1;
}
return ide_enable_queued(drive, 0);
}
static ide_startstop_t ide_dma_queued_rw(ide_drive_t *drive, u8 command)
{
ide_hwif_t *hwif = HWIF(drive);
unsigned long flags;
byte stat, feat;
TCQ_PRINTK("%s: starting tag\n", drive->name);
/*
* set nIEN, tag start operation will enable again when
* it is safe
*/
drive_ctl_nien(drive, 1);
TCQ_PRINTK("%s: sending cmd=%x\n", drive->name, command);
hwif->OUTB(command, IDE_COMMAND_REG);
if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
printk("%s: alt stat timeout\n", drive->name);
goto err;
}
drive_ctl_nien(drive, 0);
if (stat & ERR_STAT)
goto err;
/*
* bus not released, start dma
*/
feat = hwif->INB(IDE_NSECTOR_REG);
if (!(feat & REL)) {
TCQ_PRINTK("IMMED in queued_start, feat=%x\n", feat);
return __ide_dma_queued_start(drive);
}
/*
* drive released the bus, clear active request and check for service
*/
spin_lock_irqsave(&ide_lock, flags);
HWGROUP(drive)->rq = NULL;
__ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
spin_unlock_irqrestore(&ide_lock, flags);
TCQ_PRINTK("REL in queued_start\n");
stat = hwif->INB(IDE_STATUS_REG);
if (stat & SRV_STAT)
return ide_service(drive);
return ide_released;
err:
ide_dump_status(drive, "rw_queued", stat);
ide_tcq_invalidate_queue(drive);
return ide_stopped;
}
ide_startstop_t __ide_dma_queued_read(ide_drive_t *drive)
{
u8 command = WIN_READDMA_QUEUED;
if (drive->addressing == 1)
command = WIN_READDMA_QUEUED_EXT;
return ide_dma_queued_rw(drive, command);
}
ide_startstop_t __ide_dma_queued_write(ide_drive_t *drive)
{
u8 command = WIN_WRITEDMA_QUEUED;
if (drive->addressing == 1)
command = WIN_WRITEDMA_QUEUED_EXT;
return ide_dma_queued_rw(drive, command);
}
ide_startstop_t __ide_dma_queued_start(ide_drive_t *drive)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
struct request *rq = hwgroup->rq;
ide_hwif_t *hwif = HWIF(drive);
unsigned int reading = 0;
TCQ_PRINTK("ide_dma: setting up queued tag=%d\n", rq->tag);
if (!hwgroup->busy)
printk(KERN_ERR "queued_rw: hwgroup not busy\n");
if (ide_tcq_wait_dataphase(drive)) {
printk(KERN_WARNING "timeout waiting for data phase\n");
return ide_stopped;
}
if (rq_data_dir(rq) == READ)
reading = 1 << 3;
if (ide_start_dma(hwif, drive, reading))
return ide_stopped;
ide_tcq_set_intr(hwgroup, ide_dmaq_intr);
if (!hwif->ide_dma_begin(drive))
return ide_started;
return ide_stopped;
}
......@@ -690,7 +690,6 @@ typedef union {
typedef enum {
ide_stopped, /* no drive operation was started */
ide_started, /* a drive operation was started, handler was set */
ide_released, /* as ide_started, but bus also released */
} ide_startstop_t;
struct ide_driver_s;
......@@ -724,7 +723,6 @@ typedef struct ide_drive_s {
u8 keep_settings; /* restore settings after drive reset */
u8 autodma; /* device can safely use dma on host */
u8 using_dma; /* disk is using dma for read/write */
u8 using_tcq; /* disk is using queueing */
u8 retry_pio; /* retrying dma capable host in pio */
u8 state; /* retry state */
u8 waiting_for_dma; /* dma currently in progress */
......@@ -782,7 +780,6 @@ typedef struct ide_drive_s {
u8 sect; /* "real" sectors per track */
u8 bios_head; /* BIOS/fdisk/LILO number of heads */
u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */
u8 queue_depth; /* max queue depth */
unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
unsigned int cyl; /* "real" number of cyls */
......@@ -1623,14 +1620,6 @@ extern int __ide_dma_lostirq(ide_drive_t *);
extern int __ide_dma_timeout(ide_drive_t *);
#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
#ifdef CONFIG_BLK_DEV_IDE_TCQ
extern int __ide_dma_queued_on(ide_drive_t *drive);
extern int __ide_dma_queued_off(ide_drive_t *drive);
extern ide_startstop_t __ide_dma_queued_read(ide_drive_t *drive);
extern ide_startstop_t __ide_dma_queued_write(ide_drive_t *drive);
extern ide_startstop_t __ide_dma_queued_start(ide_drive_t *drive);
#endif
#else
static inline int __ide_dma_off(ide_drive_t *drive) { return 0; }
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -1699,28 +1688,6 @@ extern struct semaphore ide_cfg_sem;
#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable(); } while (0)
#define IDE_MAX_TAG 32
#ifdef CONFIG_BLK_DEV_IDE_TCQ
static inline int ata_pending_commands(ide_drive_t *drive)
{
if (drive->using_tcq)
return blk_queue_tag_depth(drive->queue);
return 0;
}
static inline int ata_can_queue(ide_drive_t *drive)
{
if (drive->using_tcq)
return blk_queue_tag_queue(drive->queue);
return 1;
}
#else
#define ata_pending_commands(drive) (0)
#define ata_can_queue(drive) (1)
#endif
extern struct bus_type ide_bus_type;
#endif /* _IDE_H */
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