Commit 4a58bd1a authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.11 IDE 46

- Remove the specific CONFIG_IDEDMA_PCI_WIP in favor of using the generic
   CONFIG_EXPERIMENTAL tag. (Pointed out by Vojtech Pavlik).

- Change the signature of the IRQ handler to take the request directly as a
   parameter. This doesn't blow the code up but makes it much more obvious and
   finally it's reducing the number of side effects of the hwgroup->rq field.

- A second sharp look after the above change allowed us to remove the wrq field
   from the hwgroup struct. It's just not used at all.

- Change the signature of the end_request member of struct ata_operations to
   take the request as a second argument. Similar for __ide_end_request()
   and ide_end_request().

- Remove BUG_ON() items just before ide_set_handler(). The check in
   ide_set_handler is clever enough now.

- Remove the rq subfield from ide-scsi packet structure. We have now the
   request context always in place. Same for floppy.

- Let the timer expiry function take the request as a direct argument.

Yes I know those changes are extensive. But they are a necessary step
in between for the following purposes:

- Consolidate the whole ATA/ATAPI stuff on passing a single unified request
   handling object. Because after eliminating those side effects it's far easier
   to see what's passed where.

- Minimizing the amount of side effects in the overall code. That's a good
   thing anyway and it *doesn't* cost us neither performance nor space, since
   the stack depths are small anyway here.

- Minimizing the usage of hwgroup - which should go away if possible.
parent b960fa03
......@@ -252,7 +252,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -409,7 +409,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
CONFIG_BLK_DEV_OFFBOARD=y
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -460,7 +460,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -687,7 +687,7 @@ static int config_drive_for_dma (ide_drive_t *drive)
/*
* etrax_dma_intr() is the handler for disk read/write DMA interrupts
*/
static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
static ide_startstop_t etrax_dma_intr (struct ata_device *drive, struct request *rq)
{
int i, dma_stat;
byte stat;
......@@ -699,11 +699,9 @@ static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
stat = GET_STAT(); /* get drive status */
if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
if (!dma_stat) {
struct request *rq;
rq = HWGROUP(drive)->rq;
for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors;
ide_end_request(drive, 1);
ide_end_request(drive, rq, 1);
}
return ide_stopped;
}
......
......@@ -263,7 +263,6 @@ CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_BLK_DEV_IDE_TCQ is not set
# CONFIG_BLK_DEV_IDE_TCQ_DEFAULT is not set
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -233,7 +233,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_IDEDMA_PCI_AUTO is not set
# CONFIG_IDEDMA_ONLYDISK is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -212,7 +212,6 @@ CONFIG_BLK_DEV_ADMA=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -212,7 +212,6 @@ CONFIG_BLK_DEV_ADMA=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -227,7 +227,6 @@ CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
# CONFIG_BLK_DEV_IDEDMA is not set
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -292,7 +292,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -255,7 +255,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -238,7 +238,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -242,7 +242,6 @@ CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
# CONFIG_BLK_DEV_IDEDMA is not set
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -236,7 +236,6 @@ CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
# CONFIG_BLK_DEV_IDEDMA is not set
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -245,7 +245,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -249,7 +249,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -212,7 +212,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_IDEDMA_PCI_AUTO is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -255,7 +255,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -289,7 +289,6 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_IDEDMA_ONLYDISK=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -214,7 +214,6 @@ CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_BLK_DEV_IDE_TCQ is not set
# CONFIG_BLK_DEV_IDE_TCQ_DEFAULT is not set
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_AEC62XX_TUNING is not set
......
......@@ -299,13 +299,6 @@ CONFIG_IDEDMA_IVB
It is normally safe to answer Y; however, the default is N.
CONFIG_IDEDMA_PCI_WIP
If you enable this you will be able to use and test highly
developmental projects. If you say N, the configurator will
simply skip those options.
It is SAFEST to say N to this question.
CONFIG_BLK_DEV_PDC_ADMA
Please read the comments at the top of <file:drivers/ide/ide-pci.c>.
......
......@@ -47,18 +47,17 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
dep_bool ' Use PCI DMA by default when available' CONFIG_IDEDMA_PCI_AUTO $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Enable DMA only for disks ' CONFIG_IDEDMA_ONLYDISK $CONFIG_IDEDMA_PCI_AUTO
define_bool CONFIG_BLK_DEV_IDEDMA $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' ATA Work(s) In Progress (EXPERIMENTAL)' CONFIG_IDEDMA_PCI_WIP $CONFIG_BLK_DEV_IDEDMA_PCI $CONFIG_EXPERIMENTAL
dep_bool ' Good-Bad DMA Model-Firmware (WIP)' CONFIG_IDEDMA_NEW_DRIVE_LISTINGS $CONFIG_IDEDMA_PCI_WIP
dep_bool ' Good-Bad DMA Model-Firmware (EXPERIMENTAL)' CONFIG_IDEDMA_NEW_DRIVE_LISTINGS $CONFIG_EXPERIMENTAL
dep_bool ' AEC62XX chipset support' CONFIG_BLK_DEV_AEC62XX $CONFIG_BLK_DEV_IDEDMA_PCI
dep_mbool ' AEC62XX Tuning support' CONFIG_AEC62XX_TUNING $CONFIG_BLK_DEV_AEC62XX
dep_bool ' ALI M15x3 chipset support' CONFIG_BLK_DEV_ALI15X3 $CONFIG_BLK_DEV_IDEDMA_PCI
dep_mbool ' ALI M15x3 WDC support (DANGEROUS)' CONFIG_WDC_ALI15X3 $CONFIG_BLK_DEV_ALI15X3
dep_mbool ' ALI M15x3 WDC support (DANGEROUS)' CONFIG_WDC_ALI15X3 $CONFIG_BLK_DEV_ALI15X3 $CONFIG_EXPERIMENTAL
dep_bool ' AMD and nVidia chipset support' CONFIG_BLK_DEV_AMD74XX $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' CMD64X chipset support' CONFIG_BLK_DEV_CMD64X $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' CY82C693 chipset support' CONFIG_BLK_DEV_CY82C693 $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Cyrix CS5530 MediaGX chipset support' CONFIG_BLK_DEV_CS5530 $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' HPT34X chipset support' CONFIG_BLK_DEV_HPT34X $CONFIG_BLK_DEV_IDEDMA_PCI
dep_mbool ' HPT34X AUTODMA support (WIP)' CONFIG_HPT34X_AUTODMA $CONFIG_BLK_DEV_HPT34X $CONFIG_IDEDMA_PCI_WIP
dep_mbool ' HPT34X AUTODMA support (EXPERMENTAL)' CONFIG_HPT34X_AUTODMA $CONFIG_BLK_DEV_HPT34X $CONFIG_EXPERIMENTAL
dep_bool ' HPT366 chipset support' CONFIG_BLK_DEV_HPT366 $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Intel and Efar (SMsC) chipset support' CONFIG_BLK_DEV_PIIX $CONFIG_BLK_DEV_IDEDMA_PCI
if [ "$CONFIG_MIPS_ITE8172" = "y" -o "$CONFIG_MIPS_IVR" = "y" ]; then
......@@ -67,7 +66,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
fi
dep_bool ' NS87415 chipset support (EXPERIMENTAL)' CONFIG_BLK_DEV_NS87415 $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' OPTi 82C621 chipset enhanced support (EXPERIMENTAL)' CONFIG_BLK_DEV_OPTI621 $CONFIG_EXPERIMENTAL
dep_mbool ' Pacific Digital A-DMA support (EXPERIMENTAL)' CONFIG_BLK_DEV_PDC_ADMA $CONFIG_IDEDMA_PCI_WIP
dep_mbool ' Pacific Digital A-DMA support (EXPERIMENTAL)' CONFIG_BLK_DEV_PDC_ADMA $CONFIG_EXPERIMENTAL
dep_bool ' PROMISE PDC202{46|62|65|67|68|69|70} support' CONFIG_BLK_DEV_PDC202XX $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Special UDMA Feature' CONFIG_PDC202XX_BURST $CONFIG_BLK_DEV_PDC202XX
dep_bool ' Special FastTrak Feature' CONFIG_PDC202XX_FORCE $CONFIG_BLK_DEV_PDC202XX
......
......@@ -437,7 +437,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (id && (id->capability & 1) && drive->channel->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -459,7 +459,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -476,13 +476,13 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
no_dma_set:
aec62xx_tune_drive(drive, 5);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
/*
* aec62xx_dmaproc() initiates/aborts (U)DMA read/write operations on a drive.
*/
int aec62xx_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int aec62xx_dmaproc (ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -507,7 +507,7 @@ int aec62xx_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif /* CONFIG_AEC62XX_TUNING */
......@@ -542,17 +542,17 @@ unsigned int __init ata66_aec62xx(struct ata_channel *hwif)
void __init ide_init_aec62xx(struct ata_channel *hwif)
{
#ifdef CONFIG_AEC62XX_TUNING
hwif->tuneproc = &aec62xx_tune_drive;
hwif->speedproc = &aec62xx_tune_chipset;
#ifdef CONFIG_BLK_DEV_IDEDMA
hwif->tuneproc = aec62xx_tune_drive;
hwif->speedproc = aec62xx_tune_chipset;
# ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base)
hwif->dmaproc = &aec62xx_dmaproc;
hwif->udma = aec62xx_dmaproc;
hwif->highmem = 1;
#else /* !CONFIG_BLK_DEV_IDEDMA */
# else
hwif->drives[0].autotune = 1;
hwif->drives[1].autotune = 1;
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif /* CONFIG_AEC62XX_TUNING */
# endif
#endif
}
void __init ide_dmacapable_aec62xx(struct ata_channel *hwif, unsigned long dmabase)
......
......@@ -437,11 +437,11 @@ static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
byte can_ultra_dma = ali15x3_can_ultra(drive);
if ((m5229_revision<=0x20) && (drive->type != ATA_DISK))
return hwif->dmaproc(ide_dma_off_quietly, drive);
return hwif->udma(ide_dma_off_quietly, drive, NULL);
if ((id != NULL) && ((id->capability & 1) != 0) && hwif->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -463,7 +463,7 @@ static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -480,10 +480,10 @@ static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
no_dma_set:
config_chipset_for_pio(drive);
}
return hwif->dmaproc(dma_func, drive);
return hwif->udma(dma_func, drive, NULL);
}
static int ali15x3_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
static int ali15x3_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch(func) {
case ide_dma_check:
......@@ -495,7 +495,7 @@ static int ali15x3_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -672,14 +672,14 @@ void __init ide_init_ali15x3(struct ata_channel *hwif)
hwif->tuneproc = &ali15x3_tune_drive;
hwif->drives[0].autotune = 1;
hwif->drives[1].autotune = 1;
hwif->speedproc = &ali15x3_tune_chipset;
hwif->speedproc = ali15x3_tune_chipset;
#ifdef CONFIG_BLK_DEV_IDEDMA
if ((hwif->dma_base) && (m5229_revision >= 0x20)) {
/*
* M1543C or newer for DMAing
*/
hwif->dmaproc = &ali15x3_dmaproc;
hwif->udma = ali15x3_dmaproc;
hwif->autodma = 1;
}
......
......@@ -282,7 +282,7 @@ static void amd74xx_tune_drive(ide_drive_t *drive, unsigned char pio)
* else to the default ide_dmaproc().
*/
int amd74xx_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
int amd74xx_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
if (func == ide_dma_check) {
......@@ -301,7 +301,7 @@ int amd74xx_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
? ide_dma_on : ide_dma_off_quietly;
}
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -433,13 +433,13 @@ void __init ide_init_amd74xx(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
hwif->highmem = 1;
hwif->dmaproc = &amd74xx_dmaproc;
#ifdef CONFIG_IDEDMA_AUTO
hwif->udma = amd74xx_dmaproc;
# ifdef CONFIG_IDEDMA_AUTO
if (!noautodma)
hwif->autodma = 1;
#endif
# endif
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif
}
/*
......
......@@ -759,7 +759,7 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
ide_dma_action_t dma_func = ide_dma_on;
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
class_rev &= 0xff;
class_rev &= 0xff;
switch(dev->device) {
case PCI_DEVICE_ID_CMD_680:
......@@ -777,13 +777,13 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
can_ultra_100 = 0;
break;
default:
return hwif->dmaproc(ide_dma_off, drive);
return hwif->udma(ide_dma_off, drive, NULL);
}
if ((id != NULL) && ((id->capability & 1) != 0) &&
hwif->autodma && (drive->type == ATA_DISK)) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -805,7 +805,7 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -822,10 +822,10 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
no_dma_set:
config_chipset_for_pio(drive, 1);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
static int cmd680_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
static int cmd680_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -834,10 +834,10 @@ static int cmd680_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
break;
}
/* Other cases are done by generic IDE-DMA code. */
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
static int cmd64x_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
static int cmd64x_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
byte dma_stat = 0;
byte dma_alt_stat = 0;
......@@ -882,14 +882,14 @@ static int cmd64x_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
break;
}
/* Other cases are done by generic IDE-DMA code. */
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
/*
* ASUS P55T2P4D with CMD646 chipset revision 0x01 requires the old
* event order for DMA transfers.
*/
static int cmd646_1_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
static int cmd646_1_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
unsigned long dma_base = hwif->dma_base;
......@@ -910,7 +910,7 @@ static int cmd646_1_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
}
/* Other cases are done by generic IDE-DMA code. */
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -1125,7 +1125,7 @@ void __init ide_init_cmd64x(struct ata_channel *hwif)
switch(dev->device) {
case PCI_DEVICE_ID_CMD_680:
hwif->busproc = &cmd680_busproc;
hwif->dmaproc = &cmd680_dmaproc;
hwif->udma = &cmd680_dmaproc;
hwif->resetproc = &cmd680_reset;
hwif->speedproc = &cmd680_tune_chipset;
hwif->tuneproc = &cmd680_tuneproc;
......@@ -1133,16 +1133,16 @@ void __init ide_init_cmd64x(struct ata_channel *hwif)
case PCI_DEVICE_ID_CMD_649:
case PCI_DEVICE_ID_CMD_648:
case PCI_DEVICE_ID_CMD_643:
hwif->dmaproc = &cmd64x_dmaproc;
hwif->udma = &cmd64x_dmaproc;
hwif->tuneproc = &cmd64x_tuneproc;
hwif->speedproc = &cmd64x_tune_chipset;
break;
case PCI_DEVICE_ID_CMD_646:
hwif->chipset = ide_cmd646;
if (class_rev == 0x01) {
hwif->dmaproc = &cmd646_1_dmaproc;
hwif->udma = &cmd646_1_dmaproc;
} else {
hwif->dmaproc = &cmd64x_dmaproc;
hwif->udma = &cmd64x_dmaproc;
}
hwif->tuneproc = &cmd64x_tuneproc;
hwif->speedproc = &cmd64x_tune_chipset;
......
......@@ -144,7 +144,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
/*
* Default to DMA-off in case we run into trouble here.
*/
(void)hwif->dmaproc(ide_dma_off_quietly, drive); /* turn off DMA while we fiddle */
hwif->udma(ide_dma_off_quietly, drive, NULL);
outb(inb(hwif->dma_base+2)&~(unit?0x40:0x20), hwif->dma_base+2); /* clear DMA_capable bit */
/*
......@@ -158,7 +158,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
*/
if (mate->present) {
struct hd_driveid *mateid = mate->id;
if (mateid && (mateid->capability & 1) && !hwif->dmaproc(ide_dma_bad_drive, mate)) {
if (mateid && (mateid->capability & 1) && !hwif->udma(ide_dma_bad_drive, mate, NULL)) {
if ((mateid->field_valid & 4) && (mateid->dma_ultra & 7))
udma_ok = 1;
else if ((mateid->field_valid & 2) && (mateid->dma_mword & 7))
......@@ -172,7 +172,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
* Now see what the current drive is capable of,
* selecting UDMA only if the mate said it was ok.
*/
if (id && (id->capability & 1) && hwif->autodma && !hwif->dmaproc(ide_dma_bad_drive, drive)) {
if (id && (id->capability & 1) && hwif->autodma && !hwif->udma(ide_dma_bad_drive, drive, NULL)) {
if (udma_ok && (id->field_valid & 4) && (id->dma_ultra & 7)) {
if (id->dma_ultra & 4)
mode = XFER_UDMA_2;
......@@ -229,7 +229,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
/*
* Finally, turn DMA on in software, and exit.
*/
return hwif->dmaproc(ide_dma_on, drive); /* success */
return hwif->udma(ide_dma_on, drive, NULL); /* success */
}
/*
......@@ -237,7 +237,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
* We need it for our custom "ide_dma_check" function.
* All other requests are forwarded to the standard ide_dmaproc().
*/
int cs5530_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int cs5530_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -246,7 +246,7 @@ int cs5530_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
break;
}
/* Other cases are done by generic IDE-DMA code. */
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -353,7 +353,7 @@ void __init ide_init_cs5530(struct ata_channel *hwif)
unsigned int basereg, d0_timings;
#ifdef CONFIG_BLK_DEV_IDEDMA
hwif->dmaproc = &cs5530_dmaproc;
hwif->udma = cs5530_dmaproc;
hwif->highmem = 1;
#else
hwif->autodma = 0;
......
......@@ -234,7 +234,7 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
/*
* used to set DMA mode for CY82C693 (single and multi modes)
*/
static int cy82c693_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
static int cy82c693_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
/*
* if the function is dma on, set dma mode for drive everything
......@@ -247,14 +247,14 @@ static int cy82c693_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
printk (KERN_INFO "dma_on: %s\n", drive->name);
#endif /* CY82C693_DEBUG_INFO */
if (id != NULL) {
if (id != NULL) {
/* Enable DMA on any drive that has DMA (multi or single) enabled */
if (id->field_valid & 2) { /* regular DMA */
int mmode, smode;
mmode = id->dma_mword & (id->dma_mword >> 8);
smode = id->dma_1word & (id->dma_1word >> 8);
if (mmode != 0)
cy82c693_dma_enable(drive, (mmode >> 1), 0); /* enable multi */
else if (smode != 0)
......@@ -262,7 +262,7 @@ static int cy82c693_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
}
}
}
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -442,7 +442,7 @@ void __init ide_init_cy82c693(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
hwif->highmem = 1;
hwif->dmaproc = cy82c693_dmaproc;
hwif->udma = cy82c693_dmaproc;
if (!noautodma)
hwif->autodma = 1;
}
......
......@@ -334,7 +334,6 @@ int hpt34x_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
drive->waiting_for_dma = 1;
if (drive->type != ATA_DISK)
return 0;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL); /* issue cmd to drive */
OUT_BYTE((reading == 9) ? WIN_READDMA : WIN_WRITEDMA, IDE_COMMAND_REG);
return 0;
......
......@@ -750,7 +750,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (id && (id->capability & 1) && drive->channel->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -771,7 +771,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -789,7 +789,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
config_chipset_for_pio(drive);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
/*
......@@ -798,7 +798,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
* This is specific to the HPT366 UDMA bios chipset
* by HighPoint|Triones Technologies, Inc.
*/
int hpt366_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int hpt366_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
byte reg50h = 0, reg52h = 0, reg5ah = 0, dma_stat = 0;
unsigned long dma_base = drive->channel->dma_base;
......@@ -829,10 +829,10 @@ int hpt366_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
int hpt370_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int hpt370_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
unsigned long dma_base = hwif->dma_base;
......@@ -883,7 +883,7 @@ int hpt370_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -1185,9 +1185,9 @@ void __init ide_init_hpt366(struct ata_channel *hwif)
pci_read_config_byte(hwif->pci_dev, 0x5a, &reg5ah);
if (reg5ah & 0x10) /* interrupt force enable */
pci_write_config_byte(hwif->pci_dev, 0x5a, reg5ah & ~0x10);
hwif->dmaproc = &hpt370_dmaproc;
hwif->udma = hpt370_dmaproc;
} else {
hwif->dmaproc = &hpt366_dmaproc;
hwif->udma = hpt366_dmaproc;
}
if (!noautodma)
hwif->autodma = 1;
......
......@@ -327,7 +327,7 @@ icside_set_speed(ide_drive_t *drive, byte speed)
/*
* dma_intr() is the handler for disk read/write DMA interrupts
*/
static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
static ide_startstop_t icside_dmaintr(struct ata_device *drive, struct request *rq)
{
int i;
byte stat, dma_stat;
......@@ -336,15 +336,13 @@ static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
stat = GET_STAT(); /* get drive status */
if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
if (!dma_stat) {
struct request *rq = HWGROUP(drive)->rq;
rq = HWGROUP(drive)->rq;
for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors;
ide_end_request(drive, 1);
}
return ide_stopped;
}
printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
drive->name, dma_stat);
}
return ide_error(drive, "dma_intr", stat);
......@@ -443,8 +441,7 @@ icside_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
if (drive->type != ATA_DISK)
return 0;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &icside_dmaintr, WAIT_CMD, NULL);
ide_set_handler(drive, icside_dmaintr, WAIT_CMD, NULL);
OUT_BYTE(reading ? WIN_READDMA : WIN_WRITEDMA,
IDE_COMMAND_REG);
......
......@@ -548,26 +548,23 @@ static void cdrom_queue_request_sense(ide_drive_t *drive,
}
static void cdrom_end_request(ide_drive_t *drive, int uptodate)
static void cdrom_end_request(struct ata_device *drive, struct request *rq, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
if ((rq->flags & REQ_SENSE) && uptodate)
cdrom_analyze_sense_data(drive, rq);
if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors)
uptodate = 1;
ide_end_request(drive, uptodate);
ide_end_request(drive, rq, uptodate);
}
/* Returns 0 if the request should be continued.
Returns 1 if the request was ended. */
static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
static int cdrom_decode_status(ide_startstop_t *startstop, struct ata_device *drive, struct request *rq,
int good_stat, int *stat_ret)
{
struct request *rq = HWGROUP(drive)->rq;
int stat, err, sense_key;
struct packet_command *pc;
......@@ -583,7 +580,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
sense_key = err >> 4;
if (rq == NULL) {
printk("%s: missing rq in cdrom_decode_status\n", drive->name);
printk("%s: missing rq in %s\n", drive->name, __FUNCTION__);
*startstop = ide_stopped;
return 1;
}
......@@ -596,7 +593,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
/* FIXME --mdcki */
pc = (struct packet_command *) rq->special;
pc->stat = 1;
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
*startstop = ide_error (drive, "request sense failure", stat);
return 1;
......@@ -634,7 +631,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
}
pc->stat = 1;
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
/* FIXME: this is the only place where pc->sense get's used.
* Think hard about how to get rid of it...
......@@ -651,7 +648,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
/* Fail the request. */
printk ("%s: tray open\n", drive->name);
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
} else if (sense_key == UNIT_ATTENTION) {
/* Media change. */
cdrom_saw_media_change (drive);
......@@ -660,27 +657,27 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
But be sure to give up if we've retried
too many times. */
if (++rq->errors > ERROR_MAX)
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
} else if (sense_key == ILLEGAL_REQUEST ||
sense_key == DATA_PROTECT) {
/* No point in retrying after an illegal
request or data protect error.*/
ide_dump_status (drive, "command error", stat);
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
} else if (sense_key == MEDIUM_ERROR) {
/* No point in re-trying a zillion times on a bad
* sector. The error is not correctable at all.
*/
ide_dump_status (drive, "media error (bad sector)", stat);
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
} else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler
for other errors. */
*startstop = ide_error (drive, "cdrom_decode_status", stat);
*startstop = ide_error (drive, __FUNCTION__, stat);
return 1;
} else if ((++rq->errors > ERROR_MAX)) {
/* We've racked up too many retries. Abort. */
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
}
/* If we got a CHECK_CONDITION status,
......@@ -695,9 +692,8 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
return 1;
}
static int cdrom_timer_expiry(ide_drive_t *drive)
static int cdrom_timer_expiry(struct ata_device *drive, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
unsigned long wait = 0;
/*
......@@ -727,9 +723,10 @@ static int cdrom_timer_expiry(ide_drive_t *drive)
called when the interrupt from the drive arrives. Otherwise, HANDLER
will be called immediately after the drive is prepared for the transfer. */
static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
static ide_startstop_t cdrom_start_packet_command(struct ata_device *drive,
struct request *rq,
int xferlen,
ide_handler_t *handler)
ata_handler_t handler)
{
ide_startstop_t startstop;
struct cdrom_info *info = drive->driver_data;
......@@ -740,9 +737,9 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
if (info->dma) {
if (info->cmd == READ)
info->dma = !drive->channel->dmaproc(ide_dma_read, drive);
info->dma = !drive->channel->udma(ide_dma_read, drive, rq);
else if (info->cmd == WRITE)
info->dma = !drive->channel->dmaproc(ide_dma_write, drive);
info->dma = !drive->channel->udma(ide_dma_write, drive, rq);
else
printk("ide-cd: DMA set, but not allowed\n");
}
......@@ -758,16 +755,15 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
OUT_BYTE (drive->ctl, IDE_CONTROL_REG);
if (info->dma)
drive->channel->dmaproc(ide_dma_begin, drive);
drive->channel->udma(ide_dma_begin, drive, NULL);
if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, handler, WAIT_CMD, cdrom_timer_expiry);
ide_set_handler(drive, handler, WAIT_CMD, cdrom_timer_expiry);
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* packet command */
return ide_started;
} else {
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* packet command */
return (*handler) (drive);
return handler(drive, rq);
}
}
......@@ -776,9 +772,10 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
* already been prepared by cdrom_start_packet_command. "handler" is the
* interrupt handler to call when the command completes or there's data ready.
*/
static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
static ide_startstop_t cdrom_transfer_packet_command(struct ata_device *drive,
struct request *rq,
unsigned char *cmd, unsigned long timeout,
ide_handler_t *handler)
ata_handler_t handler)
{
ide_startstop_t startstop;
......@@ -788,7 +785,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
int stat_dum;
/* Check for errors. */
if (cdrom_decode_status(&startstop, drive, DRQ_STAT, &stat_dum))
if (cdrom_decode_status(&startstop, drive, rq, DRQ_STAT, &stat_dum))
return startstop;
} else {
/* Otherwise, we must wait for DRQ to get set. */
......@@ -797,7 +794,6 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
}
/* Arm the interrupt handler. */
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, handler, timeout, cdrom_timer_expiry);
/* Send the command to the device. */
......@@ -861,7 +857,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
* ok; nonzero if the request has been terminated.
*/
static inline
int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
int cdrom_read_check_ireason(struct ata_device *drive, struct request *rq, int len, int ireason)
{
ireason &= 3;
if (ireason == 2) return 0;
......@@ -891,14 +887,14 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
drive->name, ireason);
}
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
return -1;
}
/*
* Interrupt routine. Called when a read request has completed.
*/
static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
static ide_startstop_t cdrom_read_intr(struct ata_device *drive, struct request *rq)
{
int stat;
int ireason, len, sectors_to_transfer, nskip;
......@@ -906,21 +902,19 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
int dma = info->dma, dma_error = 0;
ide_startstop_t startstop;
struct request *rq = HWGROUP(drive)->rq;
/* Check for errors. */
if (dma) {
info->dma = 0;
if ((dma_error = drive->channel->dmaproc(ide_dma_end, drive)))
drive->channel->dmaproc(ide_dma_off, drive);
if ((dma_error = drive->channel->udma(ide_dma_end, drive, NULL)))
drive->channel->udma(ide_dma_off, drive, NULL);
}
if (cdrom_decode_status (&startstop, drive, 0, &stat))
if (cdrom_decode_status(&startstop, drive, rq, 0, &stat))
return startstop;
if (dma) {
if (!dma_error) {
__ide_end_request(drive, 1, rq->nr_sectors);
__ide_end_request(drive, rq, 1, rq->nr_sectors);
return ide_stopped;
} else
return ide_error (drive, "dma error", stat);
......@@ -937,14 +931,14 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
if (rq->current_nr_sectors > 0) {
printk ("%s: cdrom_read_intr: data underrun (%u blocks)\n",
drive->name, rq->current_nr_sectors);
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
} else
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
return ide_stopped;
}
/* Check that the drive is expecting to do the same thing we are. */
if (cdrom_read_check_ireason (drive, len, ireason))
if (cdrom_read_check_ireason(drive, rq, len, ireason))
return ide_stopped;
/* Assume that the drive will always provide data in multiples
......@@ -959,7 +953,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
printk (" Trying to limit transfer sizes\n");
CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
}
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -987,7 +981,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
/* If we've filled the present buffer but there's another
chained buffer after it, move on. */
if (rq->current_nr_sectors == 0 && rq->nr_sectors)
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
/* If the buffers are full, cache the rest of the data in our
internal buffer. */
......@@ -1015,10 +1009,8 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
}
}
/* Done moving data!
Wait for another interrupt. */
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &cdrom_read_intr, WAIT_CMD, NULL);
/* Done moving data! Wait for another interrupt. */
ide_set_handler(drive, cdrom_read_intr, WAIT_CMD, NULL);
return ide_started;
}
......@@ -1027,10 +1019,9 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
* Try to satisfy some of the current read request from our cached data.
* Returns nonzero if the request has been completed, zero otherwise.
*/
static int cdrom_read_from_buffer (ide_drive_t *drive)
static int cdrom_read_from_buffer(struct ata_device *drive, struct request *rq)
{
struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
/* Can't do anything if there's no buffer. */
if (info->buffer == NULL) return 0;
......@@ -1041,7 +1032,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
rq->sector >= info->sector_buffered &&
rq->sector < info->sector_buffered + info->nsectors_buffered) {
if (rq->current_nr_sectors == 0)
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
memcpy (rq->buffer,
info->buffer +
......@@ -1056,13 +1047,13 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
/* If we've satisfied the current request,
terminate it successfully. */
if (rq->nr_sectors == 0) {
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
return -1;
}
/* Move on to the next buffer if needed. */
if (rq->current_nr_sectors == 0)
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
/* If this condition does not hold, then the kluge i use to
represent the number of sectors to skip at the start of a transfer
......@@ -1070,9 +1061,9 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
paranoid and check. */
if (rq->current_nr_sectors < bio_sectors(rq->bio) &&
(rq->sector % SECTORS_PER_FRAME) != 0) {
printk ("%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
drive->name, rq->sector);
cdrom_end_request(drive, 0);
printk ("%s: %s: buffer botch (%ld)\n",
drive->name, __FUNCTION__, rq->sector);
cdrom_end_request(drive, rq, 0);
return -1;
}
......@@ -1084,9 +1075,8 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
* directly from cdrom_start_read. However, for drq_interrupt devices, it is
* called from an interrupt when the drive is ready to accept the command.
*/
static ide_startstop_t cdrom_start_read_continuation(ide_drive_t *drive)
static ide_startstop_t cdrom_start_read_continuation(struct ata_device *drive, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
int nsect, sector, nframes, frame, nskip;
/* Number of sectors to transfer. */
......@@ -1107,9 +1097,9 @@ static ide_startstop_t cdrom_start_read_continuation(ide_drive_t *drive)
/* Sanity check... */
if (rq->current_nr_sectors != bio_sectors(rq->bio) &&
(rq->sector % CD_FRAMESIZE != 0)) {
printk ("%s: cdrom_start_read_continuation: buffer botch (%u)\n",
drive->name, rq->current_nr_sectors);
cdrom_end_request(drive, 0);
printk ("%s: %s: buffer botch (%u)\n",
drive->name, __FUNCTION__, rq->current_nr_sectors);
cdrom_end_request(drive, rq, 0);
return ide_stopped;
}
sector -= nskip;
......@@ -1128,7 +1118,7 @@ static ide_startstop_t cdrom_start_read_continuation(ide_drive_t *drive)
(65534 / CD_FRAMESIZE) : 65535);
/* Send the command to the drive and return. */
return cdrom_transfer_packet_command(drive, rq->cmd, WAIT_CMD, &cdrom_read_intr);
return cdrom_transfer_packet_command(drive, rq, rq->cmd, WAIT_CMD, &cdrom_read_intr);
}
......@@ -1136,14 +1126,14 @@ static ide_startstop_t cdrom_start_read_continuation(ide_drive_t *drive)
#define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */
#define IDECD_SEEK_TIMEOUT WAIT_CMD /* 10 sec */
static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_seek_intr(struct ata_device *drive, struct request *rq)
{
struct cdrom_info *info = drive->driver_data;
int stat;
static int retry = 10;
ide_startstop_t startstop;
if (cdrom_decode_status (&startstop, drive, 0, &stat))
if (cdrom_decode_status (&startstop, drive, rq, 0, &stat))
return startstop;
CDROM_CONFIG_FLAGS(drive)->seeking = 1;
......@@ -1162,10 +1152,9 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
return ide_stopped;
}
static ide_startstop_t cdrom_start_seek_continuation(struct ata_device *drive)
static ide_startstop_t cdrom_start_seek_continuation(struct ata_device *drive, struct request *rq)
{
unsigned char cmd[CDROM_PACKET_SIZE];
struct request *rq = HWGROUP(drive)->rq;
sector_t sector;
int frame, nskip;
......@@ -1179,17 +1168,17 @@ static ide_startstop_t cdrom_start_seek_continuation(struct ata_device *drive)
cmd[0] = GPCMD_SEEK;
put_unaligned(cpu_to_be32(frame), (unsigned int *) &cmd[2]);
return cdrom_transfer_packet_command(drive, cmd, WAIT_CMD, &cdrom_seek_intr);
return cdrom_transfer_packet_command(drive, rq, cmd, WAIT_CMD, &cdrom_seek_intr);
}
static ide_startstop_t cdrom_start_seek(struct ata_device *drive, sector_t block)
static ide_startstop_t cdrom_start_seek(struct ata_device *drive, struct request *rq, sector_t block)
{
struct cdrom_info *info = drive->driver_data;
info->dma = 0;
info->cmd = 0;
info->start_seek = jiffies;
return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
return cdrom_start_packet_command(drive, rq, 0, cdrom_start_seek_continuation);
}
/*
......@@ -1214,15 +1203,14 @@ static void restore_request (struct request *rq)
/*
* Start a read request from the CD-ROM.
*/
static ide_startstop_t cdrom_start_read(struct ata_device *drive, sector_t block)
static ide_startstop_t cdrom_start_read(struct ata_device *drive, struct request *rq, sector_t block)
{
struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
restore_request(rq);
/* Satisfy whatever we can of this request from our cached sector. */
if (cdrom_read_from_buffer(drive))
if (cdrom_read_from_buffer(drive, rq))
return ide_stopped;
blk_attempt_remerge(&drive->queue, rq);
......@@ -1239,7 +1227,7 @@ static ide_startstop_t cdrom_start_read(struct ata_device *drive, sector_t block
info->cmd = READ;
/* Start sending the read request to the drive. */
return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation);
return cdrom_start_packet_command(drive, rq, 32768, cdrom_start_read_continuation);
}
/****************************************************************************
......@@ -1247,17 +1235,16 @@ static ide_startstop_t cdrom_start_read(struct ata_device *drive, sector_t block
*/
/* Interrupt routine for packet command completion. */
static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_pc_intr(struct ata_device *drive, struct request *rq)
{
int ireason, len, stat, thislen;
struct request *rq = HWGROUP(drive)->rq;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
ide_startstop_t startstop;
/* Check for errors. */
if (cdrom_decode_status (&startstop, drive, 0, &stat))
if (cdrom_decode_status (&startstop, drive, rq, 0, &stat))
return startstop;
/* Read the interrupt reason and the transfer length. */
......@@ -1279,7 +1266,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
}
if (pc->buflen == 0)
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
else {
/* Comment this out, because this always happens
right after a reset occurs, and it is annoying to
......@@ -1289,7 +1276,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
drive->name, pc->buflen);
*/
pc->stat = 1;
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
}
return ide_stopped;
}
......@@ -1341,15 +1328,13 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
}
/* Now we wait for another interrupt. */
ide_set_handler(drive, cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
return ide_started;
}
static ide_startstop_t cdrom_do_pc_continuation(ide_drive_t *drive)
static ide_startstop_t cdrom_do_pc_continuation(struct ata_device *drive, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
unsigned long timeout;
/* FIXME --mdcki */
......@@ -1361,13 +1346,12 @@ static ide_startstop_t cdrom_do_pc_continuation(ide_drive_t *drive)
timeout = WAIT_CMD;
/* Send the command to the drive and return. */
return cdrom_transfer_packet_command(drive, rq->cmd, timeout, &cdrom_pc_intr);
return cdrom_transfer_packet_command(drive, rq, rq->cmd, timeout, &cdrom_pc_intr);
}
static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
static ide_startstop_t cdrom_do_packet_command(struct ata_device *drive, struct request *rq)
{
int len;
struct request *rq = HWGROUP(drive)->rq;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
......@@ -1379,7 +1363,7 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
len = pc->buflen;
/* Start sending the command to the drive. */
return cdrom_start_packet_command (drive, len, cdrom_do_pc_continuation);
return cdrom_start_packet_command (drive, rq, len, cdrom_do_pc_continuation);
}
......@@ -1455,7 +1439,8 @@ int cdrom_queue_packet_command(ide_drive_t *drive, unsigned char *cmd,
/*
* Write handling
*/
static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason)
static inline int cdrom_write_check_ireason(struct ata_device *drive, struct request *rq,
int len, int ireason)
{
/* Two notes about IDE interrupt reason here - 0 means that
* the drive wants to receive data from us, 2 means that
......@@ -1481,29 +1466,27 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire
drive->name, ireason);
}
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
return 1;
}
static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
static ide_startstop_t cdrom_write_intr(struct ata_device *drive, struct request *rq)
{
int stat, ireason, len, sectors_to_transfer, uptodate;
struct cdrom_info *info = drive->driver_data;
int dma_error = 0, dma = info->dma;
ide_startstop_t startstop;
struct request *rq = HWGROUP(drive)->rq;
/* Check for errors. */
if (dma) {
info->dma = 0;
if ((dma_error = drive->channel->dmaproc(ide_dma_end, drive))) {
if ((dma_error = drive->channel->udma(ide_dma_end, drive, NULL))) {
printk("ide-cd: write dma error\n");
drive->channel->dmaproc(ide_dma_off, drive);
drive->channel->udma(ide_dma_off, drive, NULL);
}
}
if (cdrom_decode_status(&startstop, drive, 0, &stat)) {
if (cdrom_decode_status(&startstop, drive, rq, 0, &stat)) {
printk("ide-cd: write_intr decode_status bad\n");
return startstop;
}
......@@ -1515,8 +1498,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
if (dma_error)
return ide_error(drive, "dma error", stat);
rq = HWGROUP(drive)->rq;
__ide_end_request(drive, 1, rq->nr_sectors);
__ide_end_request(drive, rq, 1, rq->nr_sectors);
return ide_stopped;
}
......@@ -1535,13 +1517,13 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
drive->name, rq->current_nr_sectors);
uptodate = 0;
}
cdrom_end_request(drive, uptodate);
cdrom_end_request(drive, rq, uptodate);
return ide_stopped;
}
/* Check that the drive is expecting to do the same thing we are. */
if (ireason & 3)
if (cdrom_write_check_ireason(drive, len, ireason))
if (cdrom_write_check_ireason(drive, rq, len, ireason))
return ide_stopped;
sectors_to_transfer = len / SECTOR_SIZE;
......@@ -1576,23 +1558,21 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
* current buffer complete, move on
*/
if (rq->current_nr_sectors == 0 && rq->nr_sectors)
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
}
/* re-arm handler */
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &cdrom_write_intr, 5 * WAIT_CMD, NULL);
ide_set_handler(drive, cdrom_write_intr, 5 * WAIT_CMD, NULL);
return ide_started;
}
static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive)
static ide_startstop_t cdrom_start_write_cont(struct ata_device *drive, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
return cdrom_transfer_packet_command(drive, rq->cmd, 2 * WAIT_CMD, cdrom_write_intr);
return cdrom_transfer_packet_command(drive, rq, rq->cmd, 2 * WAIT_CMD, cdrom_write_intr);
}
static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
static ide_startstop_t cdrom_start_write(struct ata_device *drive, struct request *rq)
{
struct cdrom_info *info = drive->driver_data;
......@@ -1600,7 +1580,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
* writes *must* be 2kB frame aligned
*/
if ((rq->nr_sectors & 3) || (rq->sector & 3)) {
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -1620,7 +1600,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
info->cmd = WRITE;
/* Start sending the read request to the drive. */
return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont);
return cdrom_start_packet_command(drive, rq, 32768, cdrom_start_write_cont);
}
#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
......@@ -1649,17 +1629,17 @@ ide_cdrom_do_request(struct ata_device *drive, struct request *rq, sector_t bloc
CDROM_CONFIG_FLAGS(drive)->seeking = 0;
}
if (IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap)
action = cdrom_start_seek(drive, block);
action = cdrom_start_seek(drive, rq, block);
else {
if (rq_data_dir(rq) == READ)
action = cdrom_start_read(drive, block);
action = cdrom_start_read(drive, rq, block);
else
action = cdrom_start_write(drive, rq);
}
info->last_block = block;
return action;
} else if (rq->flags & (REQ_PC | REQ_SENSE)) {
return cdrom_do_packet_command(drive);
return cdrom_do_packet_command(drive, rq);
} else if (rq->flags & REQ_SPECIAL) {
/*
* FIXME: Kill REQ_SEPCIAL and replace it with commands queued
......@@ -1668,7 +1648,7 @@ ide_cdrom_do_request(struct ata_device *drive, struct request *rq, sector_t bloc
* right now this can only be a reset...
*/
cdrom_end_request(drive, 1);
cdrom_end_request(drive, rq, 1);
return ide_stopped;
} else if (rq->flags & REQ_BLOCK_PC) {
struct packet_command pc;
......@@ -1681,7 +1661,7 @@ ide_cdrom_do_request(struct ata_device *drive, struct request *rq, sector_t bloc
/* FIXME --mdcki */
rq->special = (char *) &pc;
startstop = cdrom_do_packet_command(drive);
startstop = cdrom_do_packet_command(drive, rq);
if (pc.stat)
++rq->errors;
......@@ -1689,7 +1669,7 @@ ide_cdrom_do_request(struct ata_device *drive, struct request *rq, sector_t bloc
}
blk_dump_rq_flags(rq, "ide-cd bad flags");
cdrom_end_request(drive, 0);
cdrom_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -2672,8 +2652,8 @@ int ide_cdrom_probe_capabilities (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 */
(void) drive->channel->udma(ide_dma_verbose, drive, NULL);
#endif
printk("\n");
return nslots;
......
......@@ -275,7 +275,7 @@ static ide_startstop_t idedisk_do_request(struct ata_device *drive, struct reque
if (!(rq->flags & REQ_CMD)) {
blk_dump_rq_flags(rq, "idedisk_do_request - bad command");
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -1050,7 +1050,7 @@ static void idedisk_setup(struct ata_device *drive)
drive->bios_cyl, drive->bios_head, drive->bios_sect);
#ifdef CONFIG_BLK_DEV_IDEDMA
if (drive->using_dma)
(void) drive->channel->dmaproc(ide_dma_verbose, drive);
(void) drive->channel->udma(ide_dma_verbose, drive, NULL);
#endif
printk("\n");
......
......@@ -5,7 +5,7 @@
* May be copied or modified under the terms of the GNU General Public License
*
* Special Thanks to Mark for his Six years of work.
*
*
* This module provides support for the bus-master IDE DMA functions
* of various PCI chipsets, including the Intel PIIX (i82371FB for
* the 430 FX chipset), the PIIX3 (i82371SB for the 430 HX/VX and
......@@ -194,17 +194,14 @@ const char *bad_dma_drives[] = {"WDC AC11000H",
/*
* dma_intr() is the handler for disk read/write DMA interrupts
*/
ide_startstop_t ide_dma_intr (ide_drive_t *drive)
ide_startstop_t ide_dma_intr(struct ata_device *drive, struct request *rq)
{
byte stat, dma_stat;
dma_stat = drive->channel->dmaproc(ide_dma_end, drive);
stat = GET_STAT(); /* get drive status */
if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
dma_stat = drive->channel->udma(ide_dma_end, drive, rq);
if (OK_STAT(stat = GET_STAT(),DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
if (!dma_stat) {
struct request *rq = HWGROUP(drive)->rq;
__ide_end_request(drive, 1, rq->nr_sectors);
__ide_end_request(drive, rq, 1, rq->nr_sectors);
return ide_stopped;
}
printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
......@@ -461,38 +458,39 @@ static int config_drive_for_dma (ide_drive_t *drive)
if (id && (id->capability & 1) && hwif->autodma && config_allows_dma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive))
return hwif->dmaproc(ide_dma_off, drive);
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL))
return hwif->udma(ide_dma_off, drive, NULL);
/* Enable DMA on any drive that has UltraDMA (mode 6/7/?) enabled */
if ((id->field_valid & 4) && (eighty_ninty_three(drive)))
if ((id->dma_ultra & (id->dma_ultra >> 14) & 2))
return hwif->dmaproc(ide_dma_on, drive);
return hwif->udma(ide_dma_on, drive, NULL);
/* Enable DMA on any drive that has UltraDMA (mode 3/4/5) enabled */
if ((id->field_valid & 4) && (eighty_ninty_three(drive)))
if ((id->dma_ultra & (id->dma_ultra >> 11) & 7))
return hwif->dmaproc(ide_dma_on, drive);
return hwif->udma(ide_dma_on, drive, NULL);
/* Enable DMA on any drive that has UltraDMA (mode 0/1/2) enabled */
if (id->field_valid & 4) /* UltraDMA */
if ((id->dma_ultra & (id->dma_ultra >> 8) & 7))
return hwif->dmaproc(ide_dma_on, drive);
return hwif->udma(ide_dma_on, drive, NULL);
/* Enable DMA on any drive that has mode2 DMA (multi or single) enabled */
if (id->field_valid & 2) /* regular DMA */
if ((id->dma_mword & 0x404) == 0x404 || (id->dma_1word & 0x404) == 0x404)
return hwif->dmaproc(ide_dma_on, drive);
return hwif->udma(ide_dma_on, drive, NULL);
/* Consult the list of known "good" drives */
if (ide_dmaproc(ide_dma_good_drive, drive))
return hwif->dmaproc(ide_dma_on, drive);
if (ide_dmaproc(ide_dma_good_drive, drive, NULL))
return hwif->udma(ide_dma_on, drive, NULL);
}
return hwif->dmaproc(ide_dma_off_quietly, drive);
return hwif->udma(ide_dma_off_quietly, drive, NULL);
}
/*
* 1 dma-ing, 2 error, 4 intr
*/
static int dma_timer_expiry(ide_drive_t *drive)
static int dma_timer_expiry(struct ata_device *drive, struct request *__rq)
{
byte dma_stat = inb(drive->channel->dma_base+2);
/* FIXME: What's that? */
u8 dma_stat = inb(drive->channel->dma_base+2);
#ifdef DEBUG
printk("%s: dma_timer_expiry: dma status == 0x%02x\n", drive->name, dma_stat);
......@@ -503,7 +501,7 @@ static int dma_timer_expiry(ide_drive_t *drive)
#endif
if (dma_stat & 2) { /* ERROR */
byte stat = GET_STAT();
u8 stat = GET_STAT();
return ide_error(drive, "dma_timer_expiry", stat);
}
if (dma_stat & 1) /* DMAing */
......@@ -526,7 +524,7 @@ static void ide_toggle_bounce(ide_drive_t *drive, int on)
}
/*
* ide_dmaproc() initiates/aborts DMA read/write operations on a drive.
* This initiates/aborts DMA read/write operations on a drive.
*
* The caller is assumed to have selected the drive and programmed the drive's
* sector address using CHS or LBA. All that remains is to prepare for DMA
......@@ -541,7 +539,7 @@ static void ide_toggle_bounce(ide_drive_t *drive, int on)
* the caller should revert to PIO for the current request.
* May also be invoked from trm290.c
*/
int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int ide_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
unsigned long dma_base = hwif->dma_base;
......@@ -579,11 +577,9 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
if (drive->type != ATA_DISK)
return 0;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, dma_timer_expiry); /* issue cmd to drive */
if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_ACB) &&
(drive->addressing == 1)) {
struct ata_taskfile *args = HWGROUP(drive)->rq->special;
ide_set_handler(drive, ide_dma_intr, WAIT_CMD, dma_timer_expiry); /* issue cmd to drive */
if ((rq->flags & REQ_DRIVE_ACB) && (drive->addressing == 1)) {
struct ata_taskfile *args = rq->special;
OUT_BYTE(args->taskfile.command, IDE_COMMAND_REG);
} else if (drive->addressing) {
......@@ -591,7 +587,7 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
} else {
OUT_BYTE(reading ? WIN_READDMA : WIN_WRITEDMA, IDE_COMMAND_REG);
}
return drive->channel->dmaproc(ide_dma_begin, drive);
return drive->channel->udma(ide_dma_begin, drive, NULL);
case ide_dma_begin:
/* Note that this is done *after* the cmd has
* been issued to the drive, as per the BM-IDE spec.
......@@ -685,7 +681,7 @@ void ide_setup_dma(struct ata_channel *hwif, unsigned long dma_base, unsigned in
goto dma_alloc_failure;
}
hwif->dmaproc = &ide_dmaproc;
hwif->udma = ide_dmaproc;
if (hwif->chipset != ide_trm290) {
byte dma_stat = inb(dma_base+2);
......
......@@ -152,10 +152,9 @@ typedef struct idefloppy_packet_command_s {
int buffer_size; /* Size of our data buffer */
char *b_data; /* Pointer which runs on the buffers */
int b_count; /* Missing/Available data on the current buffer */
struct request *rq; /* The corresponding request */
byte *buffer; /* Data buffer */
byte *current_position; /* Pointer into the above buffer */
void (*callback) (ide_drive_t *); /* Called when this packet command is completed */
void (*callback) (struct ata_device *, struct request *); /* Called when this packet command is completed */
byte pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
unsigned long flags; /* Status/Action bit flags: long for set_bit */
} idefloppy_pc_t;
......@@ -669,10 +668,9 @@ static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount)
* For read/write requests, we will call ide_end_request to pass to the
* next buffer.
*/
static int idefloppy_end_request(ide_drive_t *drive, int uptodate)
static int idefloppy_end_request(struct ata_device *drive, struct request *rq, int uptodate)
{
idefloppy_floppy_t *floppy = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
int error;
#if IDEFLOPPY_DEBUG_LOG
......@@ -690,7 +688,7 @@ static int idefloppy_end_request(ide_drive_t *drive, int uptodate)
if (!rq)
return 0;
if (!(rq->flags & IDEFLOPPY_RQ)) {
ide_end_request(drive, uptodate);
ide_end_request(drive, rq, uptodate);
return 0;
}
rq->errors = error;
......@@ -699,9 +697,9 @@ static int idefloppy_end_request(ide_drive_t *drive, int uptodate)
return 0;
}
static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
static void idefloppy_input_buffers(struct ata_device *drive, struct request *rq,
idefloppy_pc_t *pc, unsigned int bcount)
{
struct request *rq = pc->rq;
struct bio *bio = rq->bio;
int count;
......@@ -709,12 +707,12 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
if (pc->b_count == bio->bi_size) {
rq->sector += rq->current_nr_sectors;
rq->nr_sectors -= rq->current_nr_sectors;
idefloppy_end_request(drive, 1);
idefloppy_end_request(drive, rq, 1);
if ((bio = rq->bio) != NULL)
pc->b_count = 0;
}
if (bio == NULL) {
printk (KERN_ERR "%s: bio == NULL in idefloppy_input_buffers, bcount == %d\n", drive->name, bcount);
printk (KERN_ERR "%s: bio == NULL in %s, bcount == %d\n", drive->name, __FUNCTION__, bcount);
idefloppy_discard_data (drive, bcount);
return;
}
......@@ -724,17 +722,17 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
}
}
static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
static void idefloppy_output_buffers(struct ata_device *drive, struct request *rq,
idefloppy_pc_t *pc, unsigned int bcount)
{
struct request *rq = pc->rq;
struct bio *bio = rq->bio;
int count;
while (bcount) {
if (!pc->b_count) {
rq->sector += rq->current_nr_sectors;
rq->nr_sectors -= rq->current_nr_sectors;
idefloppy_end_request(drive, 1);
idefloppy_end_request(drive, rq, 1);
if ((bio = rq->bio) != NULL) {
pc->b_data = bio_data(bio);
pc->b_count = bio->bi_size;
......@@ -752,13 +750,13 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
}
#ifdef CONFIG_BLK_DEV_IDEDMA
static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
static void idefloppy_update_buffers (struct ata_device *drive, struct request *rq,
idefloppy_pc_t *pc)
{
struct request *rq = pc->rq;
struct bio *bio = rq->bio;
while ((bio = rq->bio) != NULL)
idefloppy_end_request(drive, 1);
idefloppy_end_request(drive, rq, 1);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -812,7 +810,7 @@ static void idefloppy_analyze_error (ide_drive_t *drive,idefloppy_request_sense_
#endif /* IDEFLOPPY_DEBUG_LOG */
}
static void idefloppy_request_sense_callback (ide_drive_t *drive)
static void idefloppy_request_sense_callback(struct ata_device *drive, struct request *rq)
{
idefloppy_floppy_t *floppy = drive->driver_data;
......@@ -821,25 +819,25 @@ static void idefloppy_request_sense_callback (ide_drive_t *drive)
#endif /* IDEFLOPPY_DEBUG_LOG */
if (!floppy->pc->error) {
idefloppy_analyze_error (drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer);
idefloppy_end_request(drive, 1);
idefloppy_end_request(drive, rq, 1);
} else {
printk (KERN_ERR "Error in REQUEST SENSE itself - Aborting request!\n");
idefloppy_end_request(drive, 0);
idefloppy_end_request(drive, rq, 0);
}
}
/*
* General packet command callback function.
*/
static void idefloppy_pc_callback (ide_drive_t *drive)
static void idefloppy_pc_callback(struct ata_device *drive, struct request *rq)
{
idefloppy_floppy_t *floppy = drive->driver_data;
#if IDEFLOPPY_DEBUG_LOG
printk (KERN_INFO "ide-floppy: Reached idefloppy_pc_callback\n");
#endif /* IDEFLOPPY_DEBUG_LOG */
idefloppy_end_request(drive, floppy->pc->error ? 0:1);
idefloppy_end_request(drive, rq, floppy->pc->error ? 0:1);
}
/*
......@@ -854,7 +852,7 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc)
pc->buffer = pc->pc_buffer;
pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
pc->b_data = NULL;
pc->callback = &idefloppy_pc_callback;
pc->callback = idefloppy_pc_callback;
}
static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc)
......@@ -888,33 +886,32 @@ static void idefloppy_retry_pc (ide_drive_t *drive)
* idefloppy_pc_intr is the usual interrupt handler which will be called
* during a packet command.
*/
static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
static ide_startstop_t idefloppy_pc_intr(struct ata_device *drive, struct request *rq)
{
idefloppy_floppy_t *floppy = drive->driver_data;
idefloppy_status_reg_t status;
idefloppy_bcount_reg_t bcount;
idefloppy_ireason_reg_t ireason;
idefloppy_pc_t *pc=floppy->pc;
struct request *rq = pc->rq;
unsigned int temp;
#if IDEFLOPPY_DEBUG_LOG
printk (KERN_INFO "ide-floppy: Reached idefloppy_pc_intr interrupt handler\n");
#endif /* IDEFLOPPY_DEBUG_LOG */
#endif
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
if (drive->channel->dmaproc(ide_dma_end, drive)) {
if (drive->channel->udma(ide_dma_end, drive, NULL)) {
set_bit (PC_DMA_ERROR, &pc->flags);
} else {
pc->actually_transferred=pc->request_transfer;
idefloppy_update_buffers (drive, pc);
idefloppy_update_buffers(drive, rq, pc);
}
#if IDEFLOPPY_DEBUG_LOG
# if IDEFLOPPY_DEBUG_LOG
printk (KERN_INFO "ide-floppy: DMA finished\n");
#endif /* IDEFLOPPY_DEBUG_LOG */
# endif
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif
status.all = GET_STAT(); /* Clear the interrupt */
......@@ -941,13 +938,13 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
pc->error = 0;
if (floppy->failed_pc == pc)
floppy->failed_pc=NULL;
pc->callback(drive); /* Command finished - Call the callback function */
pc->callback(drive, rq); /* Command finished - Call the callback function */
return ide_stopped;
}
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
printk (KERN_ERR "ide-floppy: The floppy wants to issue more interrupts in DMA mode\n");
drive->channel->dmaproc(ide_dma_off, drive);
drive->channel->udma(ide_dma_off, drive, NULL);
return ide_stopped;
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -970,8 +967,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
if (temp > pc->buffer_size) {
printk (KERN_ERR "ide-floppy: The floppy wants to send us more data than expected - discarding data\n");
idefloppy_discard_data (drive,bcount.all);
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive,&idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD, NULL);
ide_set_handler(drive, idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD, NULL);
return ide_started;
}
#if IDEFLOPPY_DEBUG_LOG
......@@ -983,18 +979,17 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
if (pc->buffer != NULL)
atapi_write(drive,pc->current_position,bcount.all); /* Write the current buffer */
else
idefloppy_output_buffers (drive, pc, bcount.all);
idefloppy_output_buffers(drive, rq, pc, bcount.all);
} else {
if (pc->buffer != NULL)
atapi_read(drive,pc->current_position,bcount.all); /* Read the current buffer */
else
idefloppy_input_buffers (drive, pc, bcount.all);
idefloppy_input_buffers (drive, rq, pc, bcount.all);
}
pc->actually_transferred+=bcount.all; /* Update the current position */
pc->current_position+=bcount.all;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive,&idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */
ide_set_handler(drive, idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */
return ide_started;
}
......@@ -1004,7 +999,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
* It fails at high speeds on the Iomega ZIP drive, so there's a slower version
* for that drive below. The algorithm is chosen based on drive type
*/
static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
static ide_startstop_t idefloppy_transfer_pc(struct ata_device *drive, struct request *rq)
{
ide_startstop_t startstop;
idefloppy_floppy_t *floppy = drive->driver_data;
......@@ -1020,8 +1015,7 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
return ide_stopped;
}
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* Set the interrupt routine */
ide_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 */
return ide_started;
......@@ -1040,7 +1034,7 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
* packet, we schedule the packet transfer to occur about 2-3 ticks
* later in transfer_pc2.
*/
static int idefloppy_transfer_pc2 (ide_drive_t *drive)
static int idefloppy_transfer_pc2(struct ata_device *drive, struct request *__rq)
{
idefloppy_floppy_t *floppy = drive->driver_data;
......@@ -1048,7 +1042,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive)
return IDEFLOPPY_WAIT_CMD; /* Timeout for the packet command */
}
static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
static ide_startstop_t idefloppy_transfer_pc1(struct ata_device *drive, struct request *__rq)
{
idefloppy_floppy_t *floppy = drive->driver_data;
ide_startstop_t startstop;
......@@ -1070,11 +1064,10 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
* 25msec is too short, 40 and 50msec work well. idefloppy_pc_intr will
* not be actually used until after the packet is moved in about 50 msec.
*/
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive,
&idefloppy_pc_intr, /* service routine for packet command */
ide_set_handler(drive,
idefloppy_pc_intr, /* service routine for packet command */
floppy->ticks, /* wait this long before "failing" */
&idefloppy_transfer_pc2); /* fail == transfer_pc2 */
idefloppy_transfer_pc2); /* fail == transfer_pc2 */
return ide_started;
}
......@@ -1082,12 +1075,12 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
/*
* Issue a packet command
*/
static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc)
static ide_startstop_t idefloppy_issue_pc(struct ata_device *drive, struct request *rq, idefloppy_pc_t *pc)
{
idefloppy_floppy_t *floppy = drive->driver_data;
idefloppy_bcount_reg_t bcount;
int dma_ok = 0;
ide_handler_t *pkt_xfer_routine;
ata_handler_t *pkt_xfer_routine;
#if IDEFLOPPY_DEBUG_BUGS
if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD && pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
......@@ -1113,7 +1106,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
pc->error = IDEFLOPPY_ERROR_GENERAL; /* Giving up */
}
floppy->failed_pc=NULL;
pc->callback(drive);
pc->callback(drive, rq);
return ide_stopped;
}
#if IDEFLOPPY_DEBUG_LOG
......@@ -1127,10 +1120,10 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_and_clear_bit (PC_DMA_ERROR, &pc->flags)) {
(void) drive->channel->dmaproc(ide_dma_off, drive);
(void) drive->channel->udma(ide_dma_off, drive, NULL);
}
if (test_bit (PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
dma_ok=!drive->channel->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
dma_ok=!drive->channel->udma(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive, rq);
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (IDE_CONTROL_REG)
......@@ -1143,7 +1136,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
#ifdef CONFIG_BLK_DEV_IDEDMA
if (dma_ok) { /* Begin DMA, if necessary */
set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
(void) drive->channel->dmaproc(ide_dma_begin, drive);
(void) drive->channel->udma(ide_dma_begin, drive, NULL);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -1155,23 +1148,22 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
}
if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, pkt_xfer_routine, IDEFLOPPY_WAIT_CMD, NULL);
ide_set_handler(drive, pkt_xfer_routine, IDEFLOPPY_WAIT_CMD, NULL);
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* Issue the packet command */
return ide_started;
} else {
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG);
return (*pkt_xfer_routine) (drive);
return pkt_xfer_routine(drive, rq);
}
}
static void idefloppy_rw_callback (ide_drive_t *drive)
static void idefloppy_rw_callback(struct ata_device *drive, struct request *rq)
{
#if IDEFLOPPY_DEBUG_LOG
printk (KERN_INFO "ide-floppy: Reached idefloppy_rw_callback\n");
#endif /* IDEFLOPPY_DEBUG_LOG */
idefloppy_end_request(drive, 1);
idefloppy_end_request(drive, rq, 1);
return;
}
......@@ -1266,7 +1258,7 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *
2 * test_bit (IDEFLOPPY_USE_READ12, &floppy->flags), block, blocks);
#endif /* IDEFLOPPY_DEBUG_LOG */
idefloppy_init_pc (pc);
idefloppy_init_pc(pc);
if (test_bit (IDEFLOPPY_USE_READ12, &floppy->flags)) {
pc->c[0] = cmd == READ ? IDEFLOPPY_READ12_CMD : IDEFLOPPY_WRITE12_CMD;
put_unaligned (htonl (blocks), (unsigned int *) &pc->c[6]);
......@@ -1275,8 +1267,7 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *
put_unaligned (htons (blocks), (unsigned short *) &pc->c[7]);
}
put_unaligned (htonl (block), (unsigned int *) &pc->c[2]);
pc->callback = &idefloppy_rw_callback;
pc->rq = rq;
pc->callback = idefloppy_rw_callback;
pc->b_data = rq->buffer;
pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
if (rq->flags & REQ_RW)
......@@ -1305,13 +1296,13 @@ static ide_startstop_t idefloppy_do_request(struct ata_device *drive, struct req
drive->name, floppy->failed_pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq);
else
printk (KERN_ERR "ide-floppy: %s: I/O error\n", drive->name);
idefloppy_end_request(drive, 0);
idefloppy_end_request(drive, rq, 0);
return ide_stopped;
}
if (rq->flags & REQ_CMD) {
if (rq->sector % floppy->bs_factor || rq->nr_sectors % floppy->bs_factor) {
printk ("%s: unsupported r/w request size\n", drive->name);
idefloppy_end_request(drive, 0);
idefloppy_end_request(drive, rq, 0);
return ide_stopped;
}
pc = idefloppy_next_pc_storage(drive);
......@@ -1320,11 +1311,11 @@ static ide_startstop_t idefloppy_do_request(struct ata_device *drive, struct req
pc = (idefloppy_pc_t *) rq->buffer;
} else {
blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue");
idefloppy_end_request(drive, 0);
idefloppy_end_request(drive, rq, 0);
return ide_stopped;
}
pc->rq = rq;
return idefloppy_issue_pc (drive, pc);
return idefloppy_issue_pc(drive, rq, pc);
}
/*
......
......@@ -1384,8 +1384,7 @@ int pmac_ide_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
drive->waiting_for_dma = 1;
if (drive->type != ATA_DISK)
return 0;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
ide_set_handler(drive, ide_dma_intr, WAIT_CMD, NULL);
if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_ACB) &&
(drive->addressing == 1)) {
struct ata_taskfile *args = HWGROUP(drive)->rq->special;
......
......@@ -726,7 +726,8 @@ typedef struct idetape_packet_command_s {
int b_count;
byte *buffer; /* Data buffer */
byte *current_position; /* Pointer into the above buffer */
ide_startstop_t (*callback) (ide_drive_t *); /* Called when this packet command is completed */
/* Called when this packet command is completed */
ide_startstop_t (*callback) (struct ata_device *, struct request *);
byte pc_buffer[IDETAPE_PC_BUFFER_SIZE]; /* Temporary buffer */
unsigned long flags; /* Status/Action bit flags: long for set_bit */
} idetape_pc_t;
......@@ -1835,9 +1836,8 @@ static void idetape_remove_stage_head (ide_drive_t *drive)
* idetape_end_request is used to finish servicing a request, and to
* insert a pending pipeline request into the main device queue.
*/
static int idetape_end_request(ide_drive_t *drive, int uptodate)
static int idetape_end_request(struct ata_device *drive, struct request *rq, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
idetape_tape_t *tape = drive->driver_data;
unsigned long flags;
int error;
......@@ -1935,7 +1935,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate)
return 0;
}
static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
static ide_startstop_t idetape_request_sense_callback(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
......@@ -1945,17 +1945,17 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
#endif /* IDETAPE_DEBUG_LOG */
if (!tape->pc->error) {
idetape_analyze_error (drive, (idetape_request_sense_result_t *) tape->pc->buffer);
idetape_end_request(drive, 1);
idetape_end_request(drive, rq, 1);
} else {
printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n");
idetape_end_request(drive, 0);
idetape_end_request(drive, rq, 0);
}
return ide_stopped;
}
static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
{
idetape_init_pc (pc);
idetape_init_pc (pc);
pc->c[0] = IDETAPE_REQUEST_SENSE_CMD;
pc->c[4] = 20;
pc->request_transfer = 18;
......@@ -2015,7 +2015,7 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive)
* ide.c will be able to service requests from another device on
* the same interface while we are polling for DSC.
*/
static void idetape_postpone_request (ide_drive_t *drive)
static void idetape_postpone_request(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
......@@ -2023,7 +2023,7 @@ static void idetape_postpone_request (ide_drive_t *drive)
if (tape->debug_level >= 4)
printk(KERN_INFO "ide-tape: idetape_postpone_request\n");
#endif
tape->postponed_rq = HWGROUP(drive)->rq;
tape->postponed_rq = rq;
ide_stall_queue(drive, tape->dsc_polling_frequency);
}
......@@ -2035,7 +2035,7 @@ static void idetape_postpone_request (ide_drive_t *drive)
* algorithm described before idetape_issue_packet_command.
*
*/
static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
static ide_startstop_t idetape_pc_intr(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
idetape_status_reg_t status;
......@@ -2058,7 +2058,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
if (drive->channel->dmaproc(ide_dma_end, drive)) {
if (drive->channel->udma(ide_dma_end, drive, NULL)) {
/*
* A DMA error is sometimes expected. For example,
* if the tape is crossing a filemark during a
......@@ -2121,18 +2121,18 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
tape->dsc_polling_start = jiffies;
tape->dsc_polling_frequency = IDETAPE_DSC_MA_FAST;
tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
idetape_postpone_request (drive); /* Allow ide.c to handle other requests */
idetape_postpone_request(drive, rq); /* Allow ide.c to handle other requests */
return ide_stopped;
}
if (tape->failed_pc == pc)
tape->failed_pc = NULL;
return pc->callback(drive); /* Command finished - Call the callback function */
return pc->callback(drive, rq); /* Command finished - Call the callback function */
}
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
printk (KERN_ERR "ide-tape: The tape wants to issue more interrupts in DMA mode\n");
printk (KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n");
drive->channel->dmaproc(ide_dma_off, drive);
drive->channel->udma(ide_dma_off, drive, NULL);
return ide_stopped;
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -2155,8 +2155,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (temp > pc->buffer_size) {
printk (KERN_ERR "ide-tape: The tape wants to send us more data than expected - discarding data\n");
idetape_discard_data (drive, bcount.all);
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
ide_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
return ide_started;
}
#if IDETAPE_DEBUG_LOG
......@@ -2182,8 +2181,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (tape->debug_level >= 2)
printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes on that interrupt\n", pc->c[0], bcount.all);
#endif
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* And set the interrupt handler again */
ide_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* And set the interrupt handler again */
return ide_started;
}
......@@ -2229,7 +2227,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
* we will handle the next request.
*
*/
static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct request *__rq)
{
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
......@@ -2257,13 +2255,12 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
return ide_stopped;
}
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 */
ide_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* Set the interrupt routine */
atapi_write(drive,pc->c,12); /* Send the actual packet */
return ide_started;
}
static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape_pc_t *pc)
static ide_startstop_t idetape_issue_packet_command(struct ata_device *drive, struct request *rq, idetape_pc_t *pc)
{
idetape_tape_t *tape = drive->driver_data;
idetape_bcount_reg_t bcount;
......@@ -2297,7 +2294,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
pc->error = IDETAPE_ERROR_GENERAL; /* Giving up */
}
tape->failed_pc = NULL;
return pc->callback(drive);
return pc->callback(drive, rq);
}
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
......@@ -2312,10 +2309,10 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_and_clear_bit (PC_DMA_ERROR, &pc->flags)) {
printk (KERN_WARNING "ide-tape: DMA disabled, reverting to PIO\n");
(void) drive->channel->dmaproc(ide_dma_off, drive);
(void) drive->channel->udma(ide_dma_off, drive, NULL);
}
if (test_bit (PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
dma_ok = !drive->channel->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
dma_ok = !drive->channel->udma(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive, rq);
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (IDE_CONTROL_REG)
......@@ -2327,24 +2324,23 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
#ifdef CONFIG_BLK_DEV_IDEDMA
if (dma_ok) { /* Begin DMA, if necessary */
set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
(void) drive->channel->dmaproc(ide_dma_begin, drive);
(void) drive->channel->udma(ide_dma_begin, drive, NULL);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL);
ide_set_handler(drive, idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL);
OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG);
return ide_started;
} else {
OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG);
return idetape_transfer_pc(drive);
return idetape_transfer_pc(drive, rq);
}
}
/*
* General packet command callback function.
*/
static ide_startstop_t idetape_pc_callback (ide_drive_t *drive)
static ide_startstop_t idetape_pc_callback(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
......@@ -2353,7 +2349,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive)
printk (KERN_INFO "ide-tape: Reached idetape_pc_callback\n");
#endif /* IDETAPE_DEBUG_LOG */
idetape_end_request(drive, tape->pc->error ? 0 : 1);
idetape_end_request(drive, rq, tape->pc->error ? 0 : 1);
return ide_stopped;
}
......@@ -2375,10 +2371,10 @@ static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, byte page_code)
pc->request_transfer = 24;
else
pc->request_transfer = 50;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static ide_startstop_t idetape_onstream_buffer_fill_callback (ide_drive_t *drive)
static ide_startstop_t idetape_onstream_buffer_fill_callback (struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
......@@ -2402,7 +2398,7 @@ static ide_startstop_t idetape_onstream_buffer_fill_callback (ide_drive_t *drive
if (tape->debug_level >= 1)
printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n", tape->cur_frames, tape->max_frames);
#endif
idetape_end_request(drive, tape->pc->error ? 0 : 1);
idetape_end_request(drive, rq, tape->pc->error ? 0 : 1);
return ide_stopped;
}
......@@ -2466,7 +2462,7 @@ static void calculate_speeds(ide_drive_t *drive)
tape->max_insert_speed = max(tape->max_insert_speed, 500);
}
static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
static ide_startstop_t idetape_media_access_finished(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
......@@ -2487,13 +2483,12 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
pc->error = IDETAPE_ERROR_GENERAL;
tape->failed_pc = NULL;
}
return pc->callback (drive);
return pc->callback(drive, rq);
}
static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
static ide_startstop_t idetape_rw_callback(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
int blocks = tape->pc->actually_transferred / tape->tape_block_size;
tape->avg_size += blocks * tape->tape_block_size;
......@@ -2522,9 +2517,9 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
rq->current_nr_sectors -= blocks;
if (!tape->pc->error)
idetape_end_request(drive, 1);
idetape_end_request(drive, rq, 1);
else
idetape_end_request(drive, tape->pc->error);
idetape_end_request(drive, rq, tape->pc->error);
return ide_stopped;
}
......@@ -2536,7 +2531,7 @@ static void idetape_create_read_cmd (idetape_tape_t *tape, idetape_pc_t *pc, uns
pc->c[0] = IDETAPE_READ_CMD;
put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
pc->callback = idetape_rw_callback;
pc->bio = bio;
bv->bv_len = 0;
pc->buffer = NULL;
......@@ -2569,7 +2564,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p
pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK;
pc->c[7] = size >> 8;
pc->c[8] = size & 0xff;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
pc->bio = bio;
atomic_set(&bio->bi_cnt, 0);
pc->buffer = NULL;
......@@ -2588,7 +2583,7 @@ static void idetape_create_write_cmd (idetape_tape_t *tape, idetape_pc_t *pc, un
pc->c[0] = IDETAPE_WRITE_CMD;
put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
pc->callback = idetape_rw_callback;
set_bit (PC_WRITING, &pc->flags);
if (tape->onstream) {
while (p) {
......@@ -2635,7 +2630,7 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
* 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);
ide_end_request(drive, 0); /* Let the common code handle it */
ide_end_request(drive, rq, 0); /* Let the common code handle it */
return ide_stopped;
}
......@@ -2643,13 +2638,13 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
* Retry a failed packet command
*/
if (tape->failed_pc != NULL && tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
return idetape_issue_packet_command (drive, tape->failed_pc);
return idetape_issue_packet_command(drive, rq, tape->failed_pc);
}
#if IDETAPE_DEBUG_BUGS
if (postponed_rq != NULL)
if (rq != postponed_rq) {
printk (KERN_ERR "ide-tape: ide-tape.c bug - Two DSC requests were queued\n");
idetape_end_request(drive, 0);
idetape_end_request(drive, rq, 0);
return ide_stopped;
}
#endif /* IDETAPE_DEBUG_BUGS */
......@@ -2726,14 +2721,14 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
} else if ((signed long) (jiffies - tape->dsc_timeout) > 0) {
printk (KERN_ERR "ide-tape: %s: DSC timeout\n", tape->name);
if (rq->flags == IDETAPE_PC_RQ2) {
idetape_media_access_finished (drive);
idetape_media_access_finished(drive, rq);
return ide_stopped;
} else {
return ide_stopped;
}
} else if (jiffies - tape->dsc_polling_start > IDETAPE_DSC_MA_THRESHOLD)
tape->dsc_polling_frequency = IDETAPE_DSC_MA_SLOW;
idetape_postpone_request (drive);
idetape_postpone_request(drive, rq);
return ide_stopped;
}
switch (rq->flags) {
......@@ -2777,7 +2772,7 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
break;
case IDETAPE_ABORTED_WRITE_RQ:
rq->flags = IDETAPE_WRITE_RQ;
idetape_end_request(drive, IDETAPE_ERROR_EOD);
idetape_end_request(drive, rq, IDETAPE_ERROR_EOD);
return ide_stopped;
case IDETAPE_ABORTED_READ_RQ:
#if IDETAPE_DEBUG_LOG
......@@ -2785,21 +2780,21 @@ static ide_startstop_t idetape_do_request(struct ata_device *drive, struct reque
printk(KERN_INFO "ide-tape: %s: detected aborted read rq\n", tape->name);
#endif
rq->flags = IDETAPE_READ_RQ;
idetape_end_request(drive, IDETAPE_ERROR_EOD);
idetape_end_request(drive, rq, IDETAPE_ERROR_EOD);
return ide_stopped;
case IDETAPE_PC_RQ1:
pc = (idetape_pc_t *) rq->buffer;
rq->flags = IDETAPE_PC_RQ2;
break;
case IDETAPE_PC_RQ2:
idetape_media_access_finished (drive);
idetape_media_access_finished(drive, rq);
return ide_stopped;
default:
printk (KERN_ERR "ide-tape: bug in IDETAPE_RQ_CMD macro\n");
idetape_end_request(drive, 0);
idetape_end_request(drive, rq, 0);
return ide_stopped;
}
return idetape_issue_packet_command (drive, pc);
return idetape_issue_packet_command(drive, rq, pc);
}
/*
......@@ -3102,7 +3097,7 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq)
spin_lock_irq(&tape->spinlock);
}
static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
static ide_startstop_t idetape_read_position_callback(struct ata_device *drive, struct request *rq)
{
idetape_tape_t *tape = drive->driver_data;
idetape_read_position_result_t *result;
......@@ -3123,7 +3118,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
if (result->bpu) {
printk (KERN_INFO "ide-tape: Block location is unknown to the tape\n");
clear_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request(drive, 0);
idetape_end_request(drive, rq, 0);
} else {
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
......@@ -3134,10 +3129,10 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
tape->last_frame_position = ntohl (result->last_block);
tape->blocks_in_buffer = result->blocks_in_buffer[2];
set_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request(drive, 1);
idetape_end_request(drive, rq, 1);
}
} else {
idetape_end_request(drive, 0);
idetape_end_request(drive, rq, 0);
}
return ide_stopped;
}
......@@ -3160,14 +3155,14 @@ static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t
pc->c[1] = 1; /* Immed bit */
pc->c[4] = write_filemark; /* not used for OnStream ?? */
set_bit (PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc)
{
idetape_init_pc(pc);
pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
/*
......@@ -3213,7 +3208,7 @@ static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc
pc->c[4] = 4;
}
set_bit (PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static int idetape_wait_ready (ide_drive_t *drive, unsigned long long timeout)
......@@ -3275,7 +3270,7 @@ static void idetape_create_read_position_cmd (idetape_pc_t *pc)
idetape_init_pc (pc);
pc->c[0] = IDETAPE_READ_POSITION_CMD;
pc->request_transfer = 20;
pc->callback = &idetape_read_position_callback;
pc->callback = idetape_read_position_callback;
}
static int idetape_read_position (ide_drive_t *drive)
......@@ -3331,7 +3326,7 @@ static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, uns
*/
pc->c[9] = skip << 7;
set_bit (PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent)
......@@ -3344,7 +3339,7 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int
idetape_init_pc(pc);
pc->c[0] = IDETAPE_PREVENT_CMD;
pc->c[4] = prevent;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
return 1;
}
......@@ -3603,7 +3598,7 @@ static void idetape_create_inquiry_cmd (idetape_pc_t *pc)
idetape_init_pc(pc);
pc->c[0] = IDETAPE_INQUIRY_CMD;
pc->c[4] = pc->request_transfer = 254;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc)
......@@ -3615,7 +3610,7 @@ static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc)
if (tape->onstream)
pc->c[1] = 1;
set_bit (PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length)
......@@ -3626,7 +3621,7 @@ static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length)
pc->c[1] = 0x10;
put_unaligned (htons(length), (unsigned short *) &pc->c[3]);
pc->request_transfer = 255;
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static void idetape_create_erase_cmd (idetape_pc_t *pc)
......@@ -3635,7 +3630,7 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc)
pc->c[0] = IDETAPE_ERASE_CMD;
pc->c[1] = 1;
set_bit (PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
pc->callback = idetape_pc_callback;
}
static void idetape_create_space_cmd (idetape_pc_t *pc,int count,byte cmd)
......
......@@ -260,7 +260,7 @@ int drive_is_ready(ide_drive_t *drive)
{
byte stat = 0;
if (drive->waiting_for_dma)
return drive->channel->dmaproc(ide_dma_test_irq, drive);
return drive->channel->udma(ide_dma_test_irq, drive, NULL);
#if 0
/* need to guarantee 400ns since last command was issued */
udelay(1);
......@@ -294,7 +294,6 @@ void ata_poll_drive_ready(ide_drive_t *drive)
{
int i;
if (drive_is_ready(drive))
return;
......@@ -306,30 +305,24 @@ void ata_poll_drive_ready(ide_drive_t *drive)
}
}
static ide_startstop_t pre_task_mulout_intr(ide_drive_t *drive, struct request *rq)
static ide_startstop_t pre_task_mulout_intr(struct ata_device *drive, struct request *rq)
{
struct ata_taskfile *args = rq->special;
ide_startstop_t startstop;
/*
* assign private copy for multi-write
*/
memcpy(&HWGROUP(drive)->wrq, rq, sizeof(struct request));
if (ide_wait_stat(&startstop, drive, DATA_READY, drive->bad_wstat, WAIT_DRQ))
return startstop;
ata_poll_drive_ready(drive);
return args->handler(drive);
return args->handler(drive, rq);
}
static ide_startstop_t task_mulout_intr (ide_drive_t *drive)
static ide_startstop_t task_mulout_intr(struct ata_device *drive, struct request *rq)
{
byte stat = GET_STAT();
struct request *rq = &HWGROUP(drive)->wrq;
ide_hwgroup_t *hwgroup = HWGROUP(drive);
int mcount = drive->mult_count;
u8 stat = GET_STAT();
ide_hwgroup_t *hwgroup = HWGROUP(drive);
int mcount = drive->mult_count;
ide_startstop_t startstop;
/*
......@@ -339,11 +332,11 @@ static ide_startstop_t task_mulout_intr (ide_drive_t *drive)
if (!rq->nr_sectors) {
if (stat & (ERR_STAT|DRQ_STAT)) {
startstop = ide_error(drive, "task_mulout_intr", stat);
memcpy(rq, HWGROUP(drive)->rq, sizeof(struct request));
return startstop;
}
__ide_end_request(drive, 1, rq->hard_nr_sectors);
__ide_end_request(drive, rq, 1, rq->hard_nr_sectors);
rq->bio = NULL;
return ide_stopped;
......@@ -352,7 +345,7 @@ static ide_startstop_t task_mulout_intr (ide_drive_t *drive)
if (!OK_STAT(stat, DATA_READY, BAD_R_STAT)) {
if (stat & (ERR_STAT | DRQ_STAT)) {
startstop = ide_error(drive, "task_mulout_intr", stat);
memcpy(rq, HWGROUP(drive)->rq, sizeof(struct request));
return startstop;
}
......@@ -425,7 +418,7 @@ ide_startstop_t ata_taskfile(ide_drive_t *drive,
else
printk(" rq-> = null\n");
#endif
/* (ks/hs): Moved to start, do not use for multiple out commands */
if (args->handler != task_mulout_intr) {
if (IDE_CONTROL_REG)
......@@ -465,9 +458,9 @@ ide_startstop_t ata_taskfile(ide_drive_t *drive,
} else {
/* for dma commands we down set the handler */
if (drive->using_dma &&
!(drive->channel->dmaproc(((args->taskfile.command == WIN_WRITEDMA)
!(drive->channel->udma(((args->taskfile.command == WIN_WRITEDMA)
|| (args->taskfile.command == WIN_WRITEDMA_EXT))
? ide_dma_write : ide_dma_read, drive)));
? ide_dma_write : ide_dma_read, drive, rq)));
}
return ide_started;
......@@ -476,11 +469,11 @@ ide_startstop_t ata_taskfile(ide_drive_t *drive,
/*
* This is invoked on completion of a WIN_SETMULT cmd.
*/
ide_startstop_t set_multmode_intr(struct ata_device *drive)
ide_startstop_t set_multmode_intr(struct ata_device *drive, struct request *__rq)
{
u8 stat;
if (OK_STAT(stat=GET_STAT(),READY_STAT,BAD_STAT)) {
if (OK_STAT(stat = GET_STAT(),READY_STAT,BAD_STAT)) {
drive->mult_count = drive->mult_req;
} else {
drive->mult_req = drive->mult_count = 0;
......@@ -493,9 +486,9 @@ ide_startstop_t set_multmode_intr(struct ata_device *drive)
/*
* This is invoked on completion of a WIN_SPECIFY cmd.
*/
ide_startstop_t set_geometry_intr (ide_drive_t *drive)
ide_startstop_t set_geometry_intr(struct ata_device *drive, struct request *__rq)
{
byte stat;
u8 stat;
if (OK_STAT(stat=GET_STAT(),READY_STAT,BAD_STAT))
return ide_stopped;
......@@ -503,18 +496,18 @@ ide_startstop_t set_geometry_intr (ide_drive_t *drive)
if (stat & (ERR_STAT|DRQ_STAT))
return ide_error(drive, "set_geometry_intr", stat);
ide_set_handler(drive, &set_geometry_intr, WAIT_CMD, NULL);
ide_set_handler(drive, set_geometry_intr, WAIT_CMD, NULL);
return ide_started;
}
/*
* This is invoked on completion of a WIN_RESTORE (recalibrate) cmd.
*/
ide_startstop_t recal_intr(ide_drive_t *drive)
ide_startstop_t recal_intr(struct ata_device *drive, struct request *__rq)
{
byte stat = GET_STAT();
u8 stat;
if (!OK_STAT(stat,READY_STAT,BAD_STAT))
if (!OK_STAT(stat = GET_STAT(),READY_STAT,BAD_STAT))
return ide_error(drive, "recal_intr", stat);
return ide_stopped;
}
......@@ -522,14 +515,14 @@ ide_startstop_t recal_intr(ide_drive_t *drive)
/*
* Handler for commands without a data phase
*/
ide_startstop_t task_no_data_intr (ide_drive_t *drive)
ide_startstop_t task_no_data_intr(struct ata_device *drive, struct request *rq)
{
struct ata_taskfile *args = HWGROUP(drive)->rq->special;
byte stat = GET_STAT();
u8 stat;
struct ata_taskfile *args = rq->special;
ide__sti(); /* local CPU only */
if (!OK_STAT(stat, READY_STAT, BAD_STAT))
if (!OK_STAT(stat = GET_STAT(), READY_STAT, BAD_STAT))
return ide_error(drive, "task_no_data_intr", stat);
/* calls ide_end_drive_cmd */
if (args)
......@@ -541,11 +534,10 @@ ide_startstop_t task_no_data_intr (ide_drive_t *drive)
/*
* Handler for command with PIO data-in phase
*/
static ide_startstop_t task_in_intr (ide_drive_t *drive)
static ide_startstop_t task_in_intr (struct ata_device *drive, struct request *rq)
{
byte stat = GET_STAT();
struct request *rq = HWGROUP(drive)->rq;
char *pBuf = NULL;
u8 stat = GET_STAT();
char *pBuf = NULL;
unsigned long flags;
if (!OK_STAT(stat,DATA_READY,BAD_R_STAT)) {
......@@ -554,7 +546,7 @@ static ide_startstop_t task_in_intr (ide_drive_t *drive)
}
if (!(stat & BUSY_STAT)) {
DTF("task_in_intr to Soon wait for next interrupt\n");
ide_set_handler(drive, &task_in_intr, WAIT_CMD, NULL);
ide_set_handler(drive, task_in_intr, WAIT_CMD, NULL);
return ide_started;
}
}
......@@ -572,18 +564,18 @@ static ide_startstop_t task_in_intr (ide_drive_t *drive)
*/
if (--rq->current_nr_sectors <= 0) {
DTF("Request Ended stat: %02x\n", GET_STAT());
if (!ide_end_request(drive, 1))
if (!ide_end_request(drive, rq, 1))
return ide_stopped;
}
/*
* still data left to transfer
*/
ide_set_handler(drive, &task_in_intr, WAIT_CMD, NULL);
ide_set_handler(drive, task_in_intr, WAIT_CMD, NULL);
return ide_started;
}
static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
static ide_startstop_t pre_task_out_intr(struct ata_device *drive, struct request *rq)
{
struct ata_taskfile *args = rq->special;
ide_startstop_t startstop;
......@@ -604,7 +596,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
ide_unmap_rq(rq, buf, &flags);
} else {
ata_poll_drive_ready(drive);
return args->handler(drive);
return args->handler(drive, rq);
}
return ide_started;
}
......@@ -612,22 +604,20 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
/*
* Handler for command with PIO data-out phase
*/
static ide_startstop_t task_out_intr(ide_drive_t *drive)
static ide_startstop_t task_out_intr(struct ata_device *drive, struct request *rq)
{
byte stat = GET_STAT();
struct request *rq = HWGROUP(drive)->rq;
char *pBuf = NULL;
u8 stat = GET_STAT();
char *pBuf = NULL;
unsigned long flags;
if (!OK_STAT(stat,DRIVE_READY,drive->bad_wstat))
return ide_error(drive, "task_out_intr", stat);
if (!rq->current_nr_sectors)
if (!ide_end_request(drive, 1))
if (!ide_end_request(drive, rq, 1))
return ide_stopped;
if ((rq->current_nr_sectors==1) ^ (stat & DRQ_STAT)) {
rq = HWGROUP(drive)->rq;
pBuf = ide_map_rq(rq, &flags);
DTF("write: %p, rq->current_nr_sectors: %d\n", pBuf, (int) rq->current_nr_sectors);
......@@ -644,15 +634,14 @@ static ide_startstop_t task_out_intr(ide_drive_t *drive)
/*
* Handler for command with Read Multiple
*/
static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
static ide_startstop_t task_mulin_intr(struct ata_device *drive, struct request *rq)
{
unsigned int msect, nsect;
byte stat = GET_STAT();
struct request *rq = HWGROUP(drive)->rq;
char *pBuf = NULL;
u8 stat;
char *pBuf = NULL;
unsigned int msect, nsect;
unsigned long flags;
if (!OK_STAT(stat,DATA_READY,BAD_R_STAT)) {
if (!OK_STAT(stat = GET_STAT(),DATA_READY,BAD_R_STAT)) {
if (stat & (ERR_STAT|DRQ_STAT)) {
return ide_error(drive, "task_mulin_intr", stat);
}
......@@ -679,7 +668,7 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
rq->current_nr_sectors -= nsect;
msect -= nsect;
if (!rq->current_nr_sectors) {
if (!ide_end_request(drive, 1))
if (!ide_end_request(drive, rq, 1))
return ide_stopped;
}
} while (msect);
......
......@@ -369,14 +369,12 @@ int drive_is_flashcard (ide_drive_t *drive)
return 0; /* no, it is not a flash memory card */
}
int __ide_end_request(struct ata_device *drive, int uptodate, int nr_secs)
int __ide_end_request(struct ata_device *drive, struct request *rq, int uptodate, int nr_secs)
{
struct request *rq;
unsigned long flags;
int ret = 1;
spin_lock_irqsave(&ide_lock, flags);
rq = HWGROUP(drive)->rq;
BUG_ON(!(rq->flags & REQ_STARTED));
......@@ -394,7 +392,7 @@ int __ide_end_request(struct ata_device *drive, int uptodate, int nr_secs)
if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) {
drive->state = 0;
drive->channel->dmaproc(ide_dma_on, drive);
drive->channel->udma(ide_dma_on, drive, rq);
}
if (!end_that_request_first(rq, uptodate, nr_secs)) {
......@@ -416,8 +414,8 @@ int __ide_end_request(struct ata_device *drive, int uptodate, int nr_secs)
* timer is started to prevent us from waiting forever in case
* something goes wrong (see the ide_timer_expiry() handler later on).
*/
void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
unsigned int timeout, ide_expiry_t *expiry)
void ide_set_handler(struct ata_device *drive, ata_handler_t handler,
unsigned long timeout, ata_expiry_t expiry)
{
unsigned long flags;
ide_hwgroup_t *hwgroup = HWGROUP(drive);
......@@ -434,7 +432,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(struct ata_device *drive)
{
if (ata_ops(drive) && ata_ops(drive)->pre_reset)
ata_ops(drive)->pre_reset(drive);
......@@ -444,13 +442,13 @@ static void ata_pre_reset(ide_drive_t *drive)
/* check the DMA crc count */
if (drive->crc_count) {
drive->channel->dmaproc(ide_dma_off_quietly, drive);
drive->channel->udma(ide_dma_off_quietly, drive, NULL);
if ((drive->channel->speedproc) != NULL)
drive->channel->speedproc(drive, ide_auto_reduce_xfer(drive));
if (drive->current_speed >= XFER_SW_DMA_0)
drive->channel->dmaproc(ide_dma_on, drive);
drive->channel->udma(ide_dma_on, drive, NULL);
} else
drive->channel->dmaproc(ide_dma_off, drive);
drive->channel->udma(ide_dma_off, drive, NULL);
}
/*
......@@ -536,7 +534,7 @@ static ide_startstop_t do_reset1(ide_drive_t *, int); /* needed below */
* operation. If the drive has not yet responded, and we have not yet hit our
* maximum waiting time, then the timer is restarted for another 50ms.
*/
static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
static ide_startstop_t atapi_reset_pollfunc(struct ata_device *drive, struct request *__rq)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
byte stat;
......@@ -548,8 +546,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
printk("%s: ATAPI reset complete\n", drive->name);
} else {
if (time_before(jiffies, hwgroup->poll_timeout)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &atapi_reset_pollfunc, HZ/20, NULL);
ide_set_handler (drive, atapi_reset_pollfunc, HZ/20, NULL);
return ide_started; /* continue polling */
}
hwgroup->poll_timeout = 0; /* end of polling */
......@@ -557,6 +554,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
return do_reset1 (drive, 1); /* do it the old fashioned way */
}
hwgroup->poll_timeout = 0; /* done polling */
return ide_stopped;
}
......@@ -565,7 +563,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
* If the drives have not yet responded, and we have not yet hit our maximum
* waiting time, then the timer is restarted for another 50ms.
*/
static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
static ide_startstop_t reset_pollfunc(struct ata_device *drive, struct request *__rq)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
struct ata_channel *hwif = drive->channel;
......@@ -573,8 +571,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
if (!OK_STAT(stat=GET_STAT(), 0, BUSY_STAT)) {
if (time_before(jiffies, hwgroup->poll_timeout)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &reset_pollfunc, HZ/20, NULL);
ide_set_handler(drive, reset_pollfunc, HZ/20, NULL);
return ide_started; /* continue polling */
}
printk("%s: reset timed-out, status=0x%02x\n", hwif->name, stat);
......@@ -589,7 +586,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
#if FANCY_STATUS_DUMPS
u8 val;
static const char *messages[5] = {
static char *messages[5] = {
" passed",
" formatter device",
" sector buffer",
......@@ -645,11 +642,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
ata_pre_reset(drive);
SELECT_DRIVE(hwif,drive);
udelay (20);
OUT_BYTE (WIN_SRST, IDE_COMMAND_REG);
OUT_BYTE(WIN_SRST, IDE_COMMAND_REG);
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &atapi_reset_pollfunc, HZ/20, NULL);
__restore_flags (flags); /* local CPU only */
ide_set_handler(drive, atapi_reset_pollfunc, HZ/20, NULL);
__restore_flags(flags); /* local CPU only */
return ide_started;
}
......@@ -682,8 +678,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
}
udelay(10); /* more than enough time */
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
ide_set_handler(drive, reset_pollfunc, HZ/20, NULL);
/*
* Some weird controller like resetting themselves to a strange
......@@ -912,9 +907,9 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, byte stat)
if (rq->errors >= ERROR_MAX) {
if (ata_ops(drive) && ata_ops(drive)->end_request)
ata_ops(drive)->end_request(drive, 0);
ata_ops(drive)->end_request(drive, rq, 0);
else
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
} else {
if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
++rq->errors;
......@@ -930,9 +925,8 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, byte stat)
/*
* Issue a simple drive command. The drive must be selected beforehand.
*/
void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler)
void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ata_handler_t handler)
{
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, handler, WAIT_CMD, NULL);
if (IDE_CONTROL_REG)
OUT_BYTE(drive->ctl,IDE_CONTROL_REG); /* clear nIEN */
......@@ -944,9 +938,8 @@ void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler)
/*
* Invoked on completion of a special DRIVE_CMD.
*/
static ide_startstop_t drive_cmd_intr(ide_drive_t *drive)
static ide_startstop_t drive_cmd_intr(struct ata_device *drive, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
u8 *args = rq->buffer;
u8 stat = GET_STAT();
int retries = 10;
......@@ -1135,7 +1128,7 @@ static ide_startstop_t start_request(ide_drive_t *drive, struct request *rq)
if (ata_ops(drive)->do_request)
return ata_ops(drive)->do_request(drive, rq, block);
else {
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
return ide_stopped;
}
}
......@@ -1149,9 +1142,9 @@ static ide_startstop_t start_request(ide_drive_t *drive, struct request *rq)
kill_rq:
if (ata_ops(drive) && ata_ops(drive)->end_request)
ata_ops(drive)->end_request(drive, 0);
ata_ops(drive)->end_request(drive, rq, 0);
else
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
return ide_stopped;
......@@ -1368,21 +1361,20 @@ void do_ide_request(request_queue_t *q)
* retry the current request in PIO mode instead of risking tossing it
* all away
*/
void ide_dma_timeout_retry(ide_drive_t *drive)
static void dma_timeout_retry(ide_drive_t *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
struct request *rq;
/*
* end current dma transaction
*/
hwif->dmaproc(ide_dma_end, drive);
hwif->udma(ide_dma_end, drive, rq);
/*
* complain a little, later we might remove some of this verbosity
*/
printk("%s: timeout waiting for DMA\n", drive->name);
hwif->dmaproc(ide_dma_timeout, drive);
hwif->udma(ide_dma_timeout, drive, rq);
/*
* Disable dma for now, but remember that we did so because of
......@@ -1391,13 +1383,12 @@ void ide_dma_timeout_retry(ide_drive_t *drive)
*/
drive->retry_pio++;
drive->state = DMA_PIO_RETRY;
hwif->dmaproc(ide_dma_off_quietly, drive);
hwif->udma(ide_dma_off_quietly, drive, rq);
/*
* un-busy drive etc (hwgroup->busy is cleared on return) and
* make sure request is sane
*/
rq = HWGROUP(drive)->rq;
HWGROUP(drive)->rq = NULL;
rq->errors = 0;
......@@ -1415,11 +1406,11 @@ void ide_dma_timeout_retry(ide_drive_t *drive)
*/
void ide_timer_expiry(unsigned long data)
{
ide_hwgroup_t *hwgroup = (ide_hwgroup_t *) data;
ide_handler_t *handler;
ide_expiry_t *expiry;
unsigned long flags;
unsigned long wait;
ide_hwgroup_t *hwgroup = (ide_hwgroup_t *) data;
ata_handler_t *handler;
ata_expiry_t *expiry;
unsigned long flags;
unsigned long wait;
/*
* A global lock protects timers etc -- shouldn't get contention
......@@ -1454,7 +1445,7 @@ void ide_timer_expiry(unsigned long data)
printk("%s: ide_timer_expiry: hwgroup was not busy??\n", drive->name);
if ((expiry = hwgroup->expiry) != NULL) {
/* continue */
if ((wait = expiry(drive)) != 0) {
if ((wait = expiry(drive, HWGROUP(drive)->rq)) != 0) {
/* reengage timer */
hwgroup->timer.expires = jiffies + wait;
add_timer(&hwgroup->timer);
......@@ -1477,17 +1468,17 @@ void ide_timer_expiry(unsigned long data)
#endif
__cli(); /* local CPU only, as if we were handling an interrupt */
if (hwgroup->poll_timeout != 0) {
startstop = handler(drive);
startstop = handler(drive, ch->hwgroup->rq);
} else if (drive_is_ready(drive)) {
if (drive->waiting_for_dma)
ch->dmaproc(ide_dma_lostirq, drive);
ch->udma(ide_dma_lostirq, drive, ch->hwgroup->rq);
(void) ide_ack_intr(ch);
printk("%s: lost interrupt\n", drive->name);
startstop = handler(drive);
startstop = handler(drive, ch->hwgroup->rq);
} else {
if (drive->waiting_for_dma) {
startstop = ide_stopped;
ide_dma_timeout_retry(drive);
dma_timeout_retry(drive, ch->hwgroup->rq);
} else
startstop = ide_error(drive, "irq timeout", GET_STAT());
}
......@@ -1559,7 +1550,7 @@ static void unexpected_irq(int irq)
}
/*
* entry point for all interrupts, caller does __cli() for us
* Entry point for all interrupts, caller does __cli() for us.
*/
void ata_irq_request(int irq, void *data, struct pt_regs *regs)
{
......@@ -1568,7 +1559,7 @@ void ata_irq_request(int irq, void *data, struct pt_regs *regs)
unsigned long flags;
struct ata_device *drive;
ide_handler_t *handler;
ata_handler_t *handler = hwgroup->handler;
ide_startstop_t startstop;
spin_lock_irqsave(&ide_lock, flags);
......@@ -1576,7 +1567,7 @@ void ata_irq_request(int irq, void *data, struct pt_regs *regs)
if (!ide_ack_intr(ch))
goto out_lock;
if ((handler = hwgroup->handler) == NULL || hwgroup->poll_timeout != 0) {
if (handler == NULL || hwgroup->poll_timeout != 0) {
#if 0
printk(KERN_INFO "ide: unexpected interrupt %d %d\n", ch->unit, irq);
#endif
......@@ -1636,7 +1627,9 @@ void ata_irq_request(int irq, void *data, struct pt_regs *regs)
if (ch->unmask)
ide__sti(); /* local CPU only */
startstop = handler(drive); /* service this interrupt, may set handler for next interrupt */
/* service this interrupt, may set handler for next interrupt */
startstop = handler(drive, hwgroup->rq);
spin_lock_irq(&ide_lock);
/*
......@@ -2123,7 +2116,7 @@ void ide_unregister(struct ata_channel *ch)
ch->ata_write = old_hwif.ata_write;
ch->atapi_read = old_hwif.atapi_read;
ch->atapi_write = old_hwif.atapi_write;
ch->dmaproc = old_hwif.dmaproc;
ch->udma = old_hwif.udma;
ch->busproc = old_hwif.busproc;
ch->bus_state = old_hwif.bus_state;
ch->dma_base = old_hwif.dma_base;
......@@ -2398,13 +2391,13 @@ static int set_io_32bit(struct ata_device *drive, int arg)
return 0;
}
static int set_using_dma (ide_drive_t *drive, int arg)
static int set_using_dma(ide_drive_t *drive, int arg)
{
if (!drive->driver)
return -EPERM;
if (!drive->id || !(drive->id->capability & 1) || !drive->channel->dmaproc)
if (!drive->id || !(drive->id->capability & 1) || !drive->channel->udma)
return -EPERM;
if (drive->channel->dmaproc(arg ? ide_dma_on : ide_dma_off, drive))
if (drive->channel->udma(arg ? ide_dma_on : ide_dma_off, drive, NULL))
return -EIO;
return 0;
}
......@@ -3122,9 +3115,9 @@ int __init ide_setup (char *s)
/****************************************************************************/
/* This is the default end request function as well */
int ide_end_request(ide_drive_t *drive, int uptodate)
int ide_end_request(struct ata_device *drive, struct request *rq, int uptodate)
{
return __ide_end_request(drive, uptodate, 0);
return __ide_end_request(drive, rq, uptodate, 0);
}
/*
......@@ -3173,7 +3166,7 @@ int ide_register_subdriver(ide_drive_t *drive, struct ata_operations *driver)
restore_flags(flags); /* all CPUs */
/* FIXME: Check what this magic number is supposed to be about? */
if (drive->autotune != 2) {
if (drive->channel->dmaproc != NULL) {
if (drive->channel->udma) {
/*
* Force DMAing for the beginning of the check. Some
......@@ -3183,8 +3176,8 @@ int ide_register_subdriver(ide_drive_t *drive, struct ata_operations *driver)
* PARANOIA!!!
*/
drive->channel->dmaproc(ide_dma_off_quietly, drive);
drive->channel->dmaproc(ide_dma_check, drive);
drive->channel->udma(ide_dma_off_quietly, drive, NULL);
drive->channel->udma(ide_dma_check, drive, NULL);
}
/* Only CD-ROMs and tape drives support DSC overlap. */
drive->dsc_overlap = (drive->next != drive
......
......@@ -82,7 +82,7 @@ static void ns87415_selectproc (ide_drive_t *drive)
}
#ifdef CONFIG_BLK_DEV_IDEDMA
static int ns87415_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
static int ns87415_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
byte dma_stat;
......@@ -98,16 +98,16 @@ static int ns87415_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
case ide_dma_write:
case ide_dma_read:
ns87415_prepare_drive(drive, 1); /* select DMA xfer */
if (!ide_dmaproc(func, drive)) /* use standard DMA stuff */
if (!ide_dmaproc(func, drive, rq)) /* use standard DMA stuff */
return 0;
ns87415_prepare_drive(drive, 0); /* DMA failed: select PIO xfer */
return 1;
case ide_dma_check:
if (drive->type != ATA_DISK)
return ide_dmaproc(ide_dma_off_quietly, drive);
return ide_dmaproc(ide_dma_off_quietly, drive, rq);
/* Fallthrough... */
default:
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -206,7 +206,7 @@ void __init ide_init_ns87415(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base)
hwif->dmaproc = &ns87415_dmaproc;
hwif->udma = ns87415_dmaproc;
#endif
hwif->selectproc = &ns87415_selectproc;
......
......@@ -929,7 +929,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (id && (id->capability & 1) && hwif->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -951,7 +951,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -969,7 +969,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
(void) config_chipset_for_pio(drive, 5);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
int pdc202xx_quirkproc (ide_drive_t *drive)
......@@ -980,7 +980,7 @@ int pdc202xx_quirkproc (ide_drive_t *drive)
/*
* pdc202xx_dmaproc() initiates/aborts (U)DMA read/write operations on a drive.
*/
int pdc202xx_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int pdc202xx_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
byte dma_stat = 0;
byte sc1d = 0;
......@@ -1060,7 +1060,7 @@ int pdc202xx_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -1268,7 +1268,7 @@ void __init ide_init_pdc202xx(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
hwif->dmaproc = &pdc202xx_dmaproc;
hwif->udma = pdc202xx_dmaproc;
hwif->highmem = 1;
if (!noautodma)
hwif->autodma = 1;
......
......@@ -306,13 +306,12 @@ void __init ide_probe_for_pdc4030(void)
/*
* promise_read_intr() is the handler for disk read/multread interrupts
*/
static ide_startstop_t promise_read_intr (ide_drive_t *drive)
static ide_startstop_t promise_read_intr(struct ata_device *drive, struct request *rq)
{
byte stat;
int total_remaining;
unsigned int sectors_left, sectors_avail, nsect;
unsigned long flags;
struct request *rq;
char *to;
if (!OK_STAT(stat=GET_STAT(),DATA_READY,BAD_R_STAT)) {
......@@ -324,13 +323,11 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
sectors_left = IN_BYTE(IDE_NSECTOR_REG);
IN_BYTE(IDE_SECTOR_REG);
} while (IN_BYTE(IDE_NSECTOR_REG) != sectors_left);
rq = HWGROUP(drive)->rq;
sectors_avail = rq->nr_sectors - sectors_left;
if (!sectors_avail)
goto read_again;
read_next:
rq = HWGROUP(drive)->rq;
nsect = rq->current_nr_sectors;
if (nsect > sectors_avail)
nsect = sectors_avail;
......@@ -348,7 +345,7 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
rq->nr_sectors -= nsect;
total_remaining = rq->nr_sectors;
if ((rq->current_nr_sectors -= nsect) <= 0) {
ide_end_request(drive, 1);
ide_end_request(drive, rq, 1);
}
/*
* Now the data has been read in, do the following:
......@@ -368,7 +365,7 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
if (stat & DRQ_STAT)
goto read_again;
if (stat & BUSY_STAT) {
ide_set_handler (drive, &promise_read_intr, WAIT_CMD, NULL);
ide_set_handler(drive, promise_read_intr, WAIT_CMD, NULL);
#ifdef DEBUG_READ
printk(KERN_DEBUG "%s: promise_read: waiting for"
"interrupt\n", drive->name);
......@@ -383,22 +380,19 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
}
/*
* promise_complete_pollfunc()
* This is the polling function for waiting (nicely!) until drive stops
* being busy. It is invoked at the end of a write, after the previous poll
* has finished.
*
* Once not busy, the end request is called.
*/
static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
static ide_startstop_t promise_complete_pollfunc(struct ata_device *drive, struct request *rq)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
struct request *rq = hwgroup->rq;
if (GET_STAT() & BUSY_STAT) {
if (time_before(jiffies, hwgroup->poll_timeout)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &promise_complete_pollfunc, HZ/100, NULL);
ide_set_handler(drive, promise_complete_pollfunc, HZ/100, NULL);
return ide_started; /* continue polling... */
}
hwgroup->poll_timeout = 0;
......@@ -411,7 +405,7 @@ static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
#ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name);
#endif
__ide_end_request(drive, 1, rq->nr_sectors);
__ide_end_request(drive, rq, 1, rq->nr_sectors);
return ide_stopped;
}
......@@ -427,11 +421,8 @@ static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
* full "mcount" number of sectors, so we must make sure we update the
* state _before_ we output the final part of the data!
*/
int promise_multwrite (ide_drive_t *drive, unsigned int mcount)
int promise_multwrite(struct ata_device *drive, struct request *rq, unsigned int mcount)
{
ide_hwgroup_t *hwgroup= HWGROUP(drive);
struct request *rq = &hwgroup->wrq;
do {
char *buffer;
int nsect = rq->current_nr_sectors;
......@@ -474,14 +465,13 @@ int promise_multwrite (ide_drive_t *drive, unsigned int mcount)
/*
* promise_write_pollfunc() is the handler for disk write completion polling.
*/
static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive)
static ide_startstop_t promise_write_pollfunc(struct ata_device *drive, struct request *rq)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
if (IN_BYTE(IDE_NSECTOR_REG) != 0) {
if (time_before(jiffies, hwgroup->poll_timeout)) {
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &promise_write_pollfunc, HZ/100, NULL);
ide_set_handler(drive, promise_write_pollfunc, HZ/100, NULL);
return ide_started; /* continue polling... */
}
hwgroup->poll_timeout = 0;
......@@ -492,10 +482,9 @@ static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive)
/*
* Now write out last 4 sectors and poll for not BUSY
*/
promise_multwrite(drive, 4);
promise_multwrite(drive, rq, 4);
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &promise_complete_pollfunc, HZ/100, NULL);
ide_set_handler(drive, promise_complete_pollfunc, HZ/100, NULL);
#ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: Done last 4 sectors - status = %02x\n",
drive->name, GET_STAT());
......@@ -510,10 +499,9 @@ static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive)
* before the final 4 sectors are transferred. There is no interrupt generated
* on writes (at least on the DC4030VL-2), we just have to poll for NOT BUSY.
*/
static ide_startstop_t promise_write (ide_drive_t *drive)
static ide_startstop_t promise_write(struct ata_device *drive, struct request *rq)
{
ide_hwgroup_t *hwgroup = HWGROUP(drive);
struct request *rq = &hwgroup->wrq;
#ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: promise_write: sectors(%ld-%ld), "
......@@ -526,22 +514,20 @@ static ide_startstop_t promise_write (ide_drive_t *drive)
* the polling strategy as defined above.
*/
if (rq->nr_sectors > 4) {
if (promise_multwrite(drive, rq->nr_sectors - 4))
if (promise_multwrite(drive, rq, rq->nr_sectors - 4))
return ide_stopped;
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, &promise_write_pollfunc, HZ/100, NULL);
ide_set_handler(drive, promise_write_pollfunc, HZ/100, NULL);
return ide_started;
} else {
/*
* There are 4 or fewer sectors to transfer, do them all in one go
* and wait for NOT BUSY.
*/
if (promise_multwrite(drive, rq->nr_sectors))
if (promise_multwrite(drive, rq, rq->nr_sectors))
return ide_stopped;
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &promise_complete_pollfunc, HZ/100, NULL);
ide_set_handler(drive, promise_complete_pollfunc, HZ/100, NULL);
#ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: promise_write: <= 4 sectors, "
"status = %02x\n", drive->name, GET_STAT());
......@@ -555,9 +541,8 @@ static ide_startstop_t promise_write (ide_drive_t *drive)
* already set up. It issues a READ or WRITE command to the Promise
* controller, assuming LBA has been used to set up the block number.
*/
ide_startstop_t do_pdc4030_io(ide_drive_t *drive, struct ata_taskfile *task)
ide_startstop_t do_pdc4030_io(struct ata_device *drive, struct ata_taskfile *task, struct request *rq)
{
struct request *rq = HWGROUP(drive)->rq;
struct hd_drive_task_hdr *taskfile = &task->taskfile;
unsigned long timeout;
byte stat;
......@@ -565,7 +550,7 @@ ide_startstop_t do_pdc4030_io(ide_drive_t *drive, struct ata_taskfile *task)
/* Check that it's a regular command. If not, bomb out early. */
if (!(rq->flags & REQ_CMD)) {
blk_dump_rq_flags(rq, "pdc4030 bad flags");
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -600,15 +585,14 @@ ide_startstop_t do_pdc4030_io(ide_drive_t *drive, struct ata_taskfile *task)
stat=GET_STAT();
if (stat & DRQ_STAT) {
udelay(1);
return promise_read_intr(drive);
return promise_read_intr(drive, rq);
}
if (IN_BYTE(IDE_SELECT_REG) & 0x01) {
#ifdef DEBUG_READ
printk(KERN_DEBUG "%s: read: waiting for "
"interrupt\n", drive->name);
#endif
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &promise_read_intr, WAIT_CMD, NULL);
ide_set_handler(drive, promise_read_intr, WAIT_CMD, NULL);
return ide_started;
}
udelay(1);
......@@ -634,39 +618,34 @@ ide_startstop_t do_pdc4030_io(ide_drive_t *drive, struct ata_taskfile *task)
}
if (!drive->channel->unmask)
__cli(); /* local CPU only */
HWGROUP(drive)->wrq = *rq; /* scratchpad */
return promise_write(drive);
return promise_write(drive, rq);
}
default:
printk(KERN_ERR "pdc4030: command not READ or WRITE! Huh?\n");
ide_end_request(drive, 0);
ide_end_request(drive, rq, 0);
return ide_stopped;
}
}
ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
ide_startstop_t promise_rw_disk(struct ata_device *drive, struct request *rq, sector_t block)
{
struct hd_drive_task_hdr taskfile;
struct ata_taskfile args;
memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&args, 0, sizeof(args));
/* The four drives on the two logical (one physical) interfaces
are distinguished by writing the drive number (0-3) to the
Feature register.
FIXME: Is promise_selectproc now redundant??
*/
taskfile.feature = (drive->channel->unit << 1) + drive->select.b.unit;
taskfile.sector_count = rq->nr_sectors;
taskfile.sector_number = block;
taskfile.low_cylinder = (block>>=8);
taskfile.high_cylinder = (block>>=8);
taskfile.device_head = ((block>>8)&0x0f)|drive->select.all;
taskfile.command = (rq_data_dir(rq)==READ)?PROMISE_READ:PROMISE_WRITE;
args.taskfile = taskfile;
memset(&args.hobfile, 0, sizeof(struct hd_drive_hob_hdr));
args.taskfile.feature = (drive->channel->unit << 1) + drive->select.b.unit;
args.taskfile.sector_count = rq->nr_sectors;
args.taskfile.sector_number = block;
args.taskfile.low_cylinder = (block>>=8);
args.taskfile.high_cylinder = (block>>=8);
args.taskfile.device_head = ((block>>8)&0x0f)|drive->select.all;
args.taskfile.command = (rq_data_dir(rq)==READ)?PROMISE_READ:PROMISE_WRITE;
ide_cmd_type_parser(&args);
/* We don't use the generic inerrupt handlers here? */
......@@ -674,6 +653,6 @@ ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, unsigne
args.handler = NULL;
rq->special = &args;
return do_pdc4030_io(drive, &args);
return do_pdc4030_io(drive, &args, rq);
}
......@@ -376,7 +376,7 @@ static void piix_tune_drive(ide_drive_t *drive, unsigned char pio)
* else to the default ide_dmaproc().
*/
int piix_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
int piix_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
if (func == ide_dma_check) {
......@@ -397,7 +397,7 @@ int piix_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
}
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -555,7 +555,7 @@ void __init ide_init_piix(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
hwif->highmem = 1;
hwif->dmaproc = &piix_dmaproc;
hwif->udma = piix_dmaproc;
#ifdef CONFIG_IDEDMA_AUTO
if (!noautodma)
hwif->autodma = 1;
......
......@@ -438,7 +438,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (id && (id->capability & 1) && drive->channel->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -460,7 +460,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
} else if (ide_dmaproc(ide_dma_good_drive, drive, NULL)) {
if (id->eide_dma_time > 150) {
goto no_dma_set;
}
......@@ -477,10 +477,10 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
no_dma_set:
config_chipset_for_pio(drive);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
static int svwks_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
static int svwks_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -489,10 +489,10 @@ static int svwks_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
{
struct ata_channel *hwif = drive->channel;
unsigned long dma_base = hwif->dma_base;
if(inb(dma_base+0x02)&1)
{
#if 0
#if 0
int i;
printk(KERN_ERR "Curious - OSB4 thinks the DMA is still running.\n");
for(i=0;i<10;i++)
......@@ -504,18 +504,18 @@ static int svwks_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
}
udelay(5);
}
#endif
#endif
printk(KERN_CRIT "Serverworks OSB4 in impossible state.\n");
printk(KERN_CRIT "Disable UDMA or if you are using Seagate then try switching disk types\n");
printk(KERN_CRIT "on this controller. Please report this event to osb4-bug@ide.cabal.tm\n");
#if 0
#if 0
/* Panic might sys_sync -> death by corrupt disk */
panic("OSB4: continuing might cause disk corruption.\n");
#else
printk(KERN_CRIT "OSB4: continuing might cause disk corruption.\n");
while(1)
cpu_relax();
#endif
#endif
}
/* and drop through */
}
......@@ -523,7 +523,7 @@ static int svwks_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
break;
}
/* Other cases are done by generic IDE-DMA code. */
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -645,7 +645,7 @@ void __init ide_init_svwks(struct ata_channel *hwif)
if (!noautodma)
hwif->autodma = 1;
#endif
hwif->dmaproc = &svwks_dmaproc;
hwif->udma = svwks_dmaproc;
hwif->highmem = 1;
} else {
hwif->autodma = 0;
......
......@@ -685,7 +685,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (id && (id->capability & 1) && drive->channel->autodma) {
/* Consult the list of known "bad" drives */
if (ide_dmaproc(ide_dma_bad_drive, drive)) {
if (ide_dmaproc(ide_dma_bad_drive, drive, NULL)) {
dma_func = ide_dma_off;
goto fast_ata_pio;
}
......@@ -707,7 +707,7 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
if (dma_func != ide_dma_on)
goto no_dma_set;
}
} else if ((ide_dmaproc(ide_dma_good_drive, drive)) &&
} else if ((ide_dmaproc(ide_dma_good_drive, drive, NULL)) &&
(id->eide_dma_time > 150)) {
/* Consult the list of known "good" drives */
dma_func = config_chipset_for_dma(drive, 0);
......@@ -723,11 +723,11 @@ static int config_drive_xfer_rate (ide_drive_t *drive)
(void) config_chipset_for_pio(drive, 5);
}
return drive->channel->dmaproc(dma_func, drive);
return drive->channel->udma(dma_func, drive, NULL);
}
/* initiates/aborts (U)DMA read/write operations on a drive. */
int sis5513_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int sis5513_dmaproc (ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -737,7 +737,7 @@ int sis5513_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
default:
break;
}
return ide_dmaproc(func, drive); /* use standard DMA stuff */
return ide_dmaproc(func, drive, rq); /* use standard DMA stuff */
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -852,7 +852,7 @@ void __init ide_init_sis5513(struct ata_channel *hwif)
if (chipset_family > ATA_16) {
hwif->autodma = noautodma ? 0 : 1;
hwif->highmem = 1;
hwif->dmaproc = &sis5513_dmaproc;
hwif->udma = sis5513_dmaproc;
} else {
#endif
hwif->autodma = 0;
......
......@@ -194,7 +194,6 @@ static int trm290_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
outw((count * 2) - 1, hwif->dma_base+2); /* start DMA */
if (drive->type != ATA_DISK)
return 0;
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
OUT_BYTE(reading ? WIN_READDMA : WIN_WRITEDMA, IDE_COMMAND_REG);
return 0;
......
......@@ -363,7 +363,7 @@ static void via82cxxx_tune_drive(ide_drive_t *drive, unsigned char pio)
* else to the default ide_dmaproc().
*/
int via82cxxx_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
int via82cxxx_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
if (func == ide_dma_check) {
......@@ -383,7 +383,7 @@ int via82cxxx_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
? ide_dma_on : ide_dma_off_quietly;
}
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
......@@ -546,7 +546,7 @@ void __init ide_init_via82cxxx(struct ata_channel *hwif)
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
hwif->highmem = 1;
hwif->dmaproc = &via82cxxx_dmaproc;
hwif->udma = &via82cxxx_dmaproc;
#ifdef CONFIG_IDEDMA_AUTO
if (!noautodma)
hwif->autodma = 1;
......
......@@ -59,7 +59,6 @@ typedef struct idescsi_pc_s {
int request_transfer; /* Bytes to transfer */
int actually_transferred; /* Bytes actually transferred */
int buffer_size; /* Size of our data buffer */
struct request *rq; /* The corresponding request */
byte *buffer; /* Data buffer */
byte *current_position; /* Pointer into the above buffer */
struct scatterlist *sg; /* Scatter gather table */
......@@ -259,10 +258,9 @@ static void hexdump(u8 *x, int len)
printk("]\n");
}
static int idescsi_end_request(ide_drive_t *drive, int uptodate)
static int idescsi_end_request(struct ata_device *drive, struct request *rq, int uptodate)
{
idescsi_scsi_t *scsi = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
idescsi_pc_t *pc = (idescsi_pc_t *) rq->special;
int log = test_bit(IDESCSI_LOG_CMD, &scsi->log);
struct Scsi_Host *host;
......@@ -270,7 +268,7 @@ static int idescsi_end_request(ide_drive_t *drive, int uptodate)
unsigned long flags;
if (!(rq->flags & REQ_SPECIAL)) {
ide_end_request(drive, uptodate);
ide_end_request(drive, rq, uptodate);
return 0;
}
ide_end_drive_cmd (drive, 0, 0);
......@@ -313,13 +311,12 @@ static inline unsigned long get_timeout(idescsi_pc_t *pc)
/*
* Our interrupt handler.
*/
static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
static ide_startstop_t idescsi_pc_intr(struct ata_device *drive, struct request *rq)
{
idescsi_scsi_t *scsi = drive->driver_data;
byte status, ireason;
int bcount;
idescsi_pc_t *pc=scsi->pc;
struct request *rq = pc->rq;
unsigned int temp;
#if IDESCSI_DEBUG_LOG
......@@ -331,7 +328,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk ("ide-scsi: %s: DMA complete\n", drive->name);
#endif /* IDESCSI_DEBUG_LOG */
pc->actually_transferred=pc->request_transfer;
(void) drive->channel->dmaproc(ide_dma_end, drive);
(void) drive->channel->udma(ide_dma_end, drive, NULL);
}
status = GET_STAT(); /* Clear the interrupt */
......@@ -342,7 +339,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
ide__sti();
if (status & ERR_STAT)
rq->errors++;
idescsi_end_request(drive, 1);
idescsi_end_request(drive, rq, 1);
return ide_stopped;
}
bcount = IN_BYTE (IDE_BCOUNTH_REG) << 8 | IN_BYTE (IDE_BCOUNTL_REG);
......@@ -369,7 +366,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
pc->actually_transferred += temp;
pc->current_position += temp;
idescsi_discard_data (drive,bcount - temp);
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), NULL);
ide_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL);
return ide_started;
}
#if IDESCSI_DEBUG_LOG
......@@ -393,11 +390,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
pc->actually_transferred+=bcount; /* Update the current position */
pc->current_position+=bcount;
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), NULL); /* And set the interrupt handler again */
ide_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL); /* And set the interrupt handler again */
return ide_started;
}
static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive)
static ide_startstop_t idescsi_transfer_pc(struct ata_device *drive, struct request *rq)
{
idescsi_scsi_t *scsi = drive->driver_data;
idescsi_pc_t *pc = scsi->pc;
......@@ -413,7 +410,7 @@ static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive)
printk (KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while issuing a packet command\n");
return ide_stopped;
}
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), NULL); /* Set the interrupt routine */
ide_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL); /* Set the interrupt routine */
atapi_write(drive, scsi->pc->c, 12); /* Send the actual packet */
return ide_started;
}
......@@ -421,11 +418,10 @@ static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive)
/*
* Issue a packet command
*/
static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
static ide_startstop_t idescsi_issue_pc(struct ata_device *drive, struct request *rq, idescsi_pc_t *pc)
{
idescsi_scsi_t *scsi = drive->driver_data;
int bcount;
struct request *rq = pc->rq;
int dma_ok = 0;
scsi->pc=pc; /* Set the current packet command */
......@@ -434,7 +430,7 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
bcount = min(pc->request_transfer, 63 * 1024); /* Request to transfer the entire buffer at once */
if (drive->using_dma && rq->bio)
dma_ok = !drive->channel->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
dma_ok = !drive->channel->udma(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive, rq);
SELECT_DRIVE(drive->channel, drive);
if (IDE_CONTROL_REG)
......@@ -445,15 +441,15 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
if (dma_ok) {
set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
(void) drive->channel->dmaproc(ide_dma_begin, drive);
(void) drive->channel->udma(ide_dma_begin, drive, NULL);
}
if (test_bit (IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
ide_set_handler (drive, &idescsi_transfer_pc, get_timeout(pc), NULL);
ide_set_handler(drive, idescsi_transfer_pc, get_timeout(pc), NULL);
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* Issue the packet command */
return ide_started;
} else {
OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG);
return idescsi_transfer_pc (drive);
return idescsi_transfer_pc(drive, rq);
}
}
......@@ -468,10 +464,10 @@ static ide_startstop_t idescsi_do_request(struct ata_device *drive, struct reque
#endif /* IDESCSI_DEBUG_LOG */
if (rq->flags & REQ_SPECIAL) {
return idescsi_issue_pc(drive, (idescsi_pc_t *) rq->special);
return idescsi_issue_pc(drive, rq, (idescsi_pc_t *) rq->special);
}
blk_dump_rq_flags(rq, "ide-scsi: unsup command");
idescsi_end_request(drive, 0);
idescsi_end_request(drive, rq, 0);
return ide_stopped;
}
......@@ -760,7 +756,6 @@ int idescsi_queue (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
memset (pc->c, 0, 12);
pc->flags = 0;
pc->rq = rq;
memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
if (cmd->use_sg) {
pc->buffer = NULL;
......
......@@ -374,7 +374,7 @@ struct ata_device {
} ide_drive_t;
/*
* An ide_dmaproc_t() initiates/aborts DMA read/write operations on a drive.
* This initiates/aborts DMA read/write operations on a drive.
*
* The caller is assumed to have selected the drive and programmed the drive's
* sector address using CHS or LBA. All that remains is to prepare for DMA
......@@ -392,8 +392,6 @@ typedef enum { ide_dma_read, ide_dma_write, ide_dma_begin,
ide_dma_lostirq, ide_dma_timeout
} ide_dma_action_t;
typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *);
enum {
ATA_PRIMARY = 0,
ATA_SECONDARY = 1
......@@ -446,7 +444,7 @@ struct ata_channel {
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 */
int (*udma)(ide_dma_action_t, struct ata_device *, struct request *); /* dma read/write/abort routine */
unsigned int *dmatable_cpu; /* dma physical region descriptor table (cpu view) */
dma_addr_t dmatable_dma; /* dma physical region descriptor table (dma view) */
struct scatterlist *sg_table; /* Scatter-gather list used to build the above */
......@@ -500,31 +498,25 @@ typedef enum {
} ide_startstop_t;
/*
* Interrupt handler types.
* Interrupt and timeout handler type.
*/
struct ata_taskfile;
typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
typedef ide_startstop_t (ata_handler_t)(struct ata_device *, struct request *);
typedef int (ata_expiry_t)(struct ata_device *, struct request *);
/*
* when ide_timer_expiry fires, invoke a handler of this type
* to decide what to do.
*/
typedef int (ide_expiry_t)(ide_drive_t *);
struct ata_taskfile;
#define IDE_BUSY 0 /* awaiting an interrupt */
#define IDE_SLEEP 1
#define IDE_DMA 2 /* DMA in progress */
typedef struct hwgroup_s {
ide_handler_t *handler; /* irq handler, if active */
ide_startstop_t (*handler)(struct ata_device *, struct request *); /* irq handler, if active */
unsigned long flags; /* BUSY, SLEEPING */
struct ata_device *drive; /* current drive */
struct request *rq; /* current request */
struct timer_list timer; /* failsafe timer */
struct request wrq; /* local copy of current write rq */
unsigned long poll_timeout; /* timeout value during long polls */
ide_expiry_t *expiry; /* queried upon timeouts */
int (*expiry)(struct ata_device *, struct request *); /* irq handler, if active */
} ide_hwgroup_t;
/* structure attached to the request for IDE_TASK_CMDS */
......@@ -616,7 +608,7 @@ struct ata_operations {
int (*cleanup)(struct ata_device *);
int (*standby)(struct ata_device *);
ide_startstop_t (*do_request)(struct ata_device *, struct request *, sector_t);
int (*end_request)(struct ata_device *, int);
int (*end_request)(struct ata_device *, struct request *, int);
int (*ioctl)(struct ata_device *, struct inode *, struct file *, unsigned int, unsigned long);
int (*open)(struct inode *, struct file *, struct ata_device *);
......@@ -663,14 +655,15 @@ extern int noautodma;
#define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
#include <linux/blk.h>
extern int __ide_end_request(ide_drive_t *drive, int uptodate, int nr_secs);
extern int ide_end_request(ide_drive_t *drive, int uptodate);
extern int __ide_end_request(struct ata_device *, struct request *, int, int);
extern int ide_end_request(struct ata_device *drive, struct request *, int);
/*
* This is used on exit from the driver, to designate the next irq handler
* and also to start the safety timer.
*/
void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);
extern void ide_set_handler(struct ata_device *drive, ata_handler_t handler,
unsigned long timeout, ata_expiry_t expiry);
/*
* Error reporting, in human readable form (luxurious, but a memory hog).
......@@ -687,7 +680,7 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
* Issue a simple drive command
* The drive must be selected beforehand.
*/
void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler);
void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ata_handler_t handler);
/*
* ide_fixstring() cleans up and (optionally) byte-swaps a text string,
......@@ -756,9 +749,9 @@ void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
struct ata_taskfile {
struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile;
int command_type;
ide_pre_handler_t *prehandler;
ide_handler_t *handler;
int command_type;
ide_startstop_t (*prehandler)(struct ata_device *, struct request *);
ide_startstop_t (*handler)(struct ata_device *, struct request *);
};
extern void ata_read(ide_drive_t *drive, void *buffer, unsigned int wcount);
......@@ -774,10 +767,10 @@ extern ide_startstop_t ata_taskfile(ide_drive_t *drive,
* Special Flagged Register Validation Caller
*/
extern ide_startstop_t recal_intr(ide_drive_t *drive);
extern ide_startstop_t set_geometry_intr(ide_drive_t *drive);
extern ide_startstop_t set_multmode_intr(ide_drive_t *drive);
extern ide_startstop_t task_no_data_intr(ide_drive_t *drive);
extern ide_startstop_t recal_intr(struct ata_device *, struct request *);
extern ide_startstop_t set_geometry_intr(struct ata_device *, struct request *);
extern ide_startstop_t set_multmode_intr(struct ata_device *, struct request *);
extern ide_startstop_t task_no_data_intr(struct ata_device *, struct request *);
/* This is setting up all fields in args, which depend upon the command type.
......@@ -871,9 +864,9 @@ void __init ide_scan_pcibus(int scan_direction);
#ifdef CONFIG_BLK_DEV_IDEDMA
int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func);
void ide_destroy_dmatable (ide_drive_t *drive);
ide_startstop_t ide_dma_intr (ide_drive_t *drive);
extern ide_startstop_t ide_dma_intr(struct ata_device *, struct request *);
int check_drive_lists (ide_drive_t *drive, int good_bad);
int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive);
int ide_dmaproc (ide_dma_action_t func, struct ata_device *drive, struct request *);
extern void ide_release_dma(struct ata_channel *hwif);
extern void ide_setup_dma(struct ata_channel *hwif,
unsigned long dmabase, unsigned int num_ports) __init;
......
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