Commit 8f0e343b authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.12 IDE 49

- Fix compilation of piix.c

- Remove the PADAM_ prefix from sleep hwgroup member.

- Fix Pacific Digital host chip driver API.

- Fix Tekram host chip driver API.

- Fold hwif_unregister() directly in to channel code.
parent 2c66783a
......@@ -270,16 +270,15 @@ static int build_sglist(struct ata_channel *ch, struct request *rq)
}
/*
* ide_build_dmatable() prepares a dma request.
* Returns 0 if all went okay, returns 1 otherwise.
* May also be invoked from trm290.c
* This prepares a dma request. Returns 0 if all went okay, returns 1
* otherwise. May also be invoked from trm290.c
*/
int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func)
int ide_build_dmatable(struct ata_device *drive, ide_dma_action_t func)
{
struct ata_channel *hwif = drive->channel;
unsigned int *table = hwif->dmatable_cpu;
struct ata_channel *ch = drive->channel;
unsigned int *table = ch->dmatable_cpu;
#ifdef CONFIG_BLK_DEV_TRM290
unsigned int is_trm290_chipset = (hwif->chipset == ide_trm290);
unsigned int is_trm290_chipset = (ch->chipset == ide_trm290);
#else
const int is_trm290_chipset = 0;
#endif
......@@ -287,11 +286,11 @@ int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func)
int i;
struct scatterlist *sg;
hwif->sg_nents = i = build_sglist(hwif, HWGROUP(drive)->rq);
ch->sg_nents = i = build_sglist(ch, HWGROUP(drive)->rq);
if (!i)
return 0;
sg = hwif->sg_table;
sg = ch->sg_table;
while (i) {
u32 cur_addr;
u32 cur_len;
......@@ -309,8 +308,8 @@ int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func)
u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff);
if (count++ >= PRD_ENTRIES) {
printk("ide-dma: req %p\n", HWGROUP(drive)->rq);
printk("count %d, sg_nents %d, cur_len %d, cur_addr %u\n", count, hwif->sg_nents, cur_len, cur_addr);
printk("ide-dma: count %d, sg_nents %d, cur_len %d, cur_addr %u\n",
count, ch->sg_nents, cur_len, cur_addr);
BUG();
}
......@@ -328,9 +327,9 @@ int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func)
* the 64KB entry into two 32KB entries instead.
*/
if (count++ >= PRD_ENTRIES) {
pci_unmap_sg(hwif->pci_dev, sg,
hwif->sg_nents,
hwif->sg_dma_direction);
pci_unmap_sg(ch->pci_dev, sg,
ch->sg_nents,
ch->sg_dma_direction);
return 0;
}
......
......@@ -745,7 +745,7 @@ static int init_irq(struct ata_channel *ch)
#else
printk("%s at %p on irq 0x%08x", ch->name,
ch->io_ports[IDE_DATA_OFFSET], ch->irq);
#endif /* __mc68000__ && CONFIG_APUS */
#endif
if (match)
printk(" (%sed with %s)",
ch->sharing_irq ? "shar" : "serializ", match->name);
......
......@@ -1187,12 +1187,12 @@ void ide_stall_queue(ide_drive_t *drive, unsigned long timeout)
{
if (timeout > WAIT_WORSTCASE)
timeout = WAIT_WORSTCASE;
drive->PADAM_sleep = timeout + jiffies;
drive->sleep = timeout + jiffies;
}
/*
* Determine the longes sleep time for the devices in our hwgroup.
* Determine the longest sleep time for the devices at this channel.
*/
static unsigned long longest_sleep(struct ata_channel *channel)
{
......@@ -1218,8 +1218,8 @@ static unsigned long longest_sleep(struct ata_channel *channel)
/* This device is sleeping and waiting to be serviced
* later than any other device we checked thus far.
*/
if (drive->PADAM_sleep && (!sleep || time_after(sleep, drive->PADAM_sleep)))
sleep = drive->PADAM_sleep;
if (drive->sleep && (!sleep || time_after(sleep, drive->sleep)))
sleep = drive->sleep;
}
}
......@@ -1256,16 +1256,15 @@ static struct ata_device *choose_urgent_device(struct ata_channel *channel)
if (list_empty(&drive->queue.queue_head))
continue;
/* This device still want's to remain idle.
/* This device still wants to remain idle.
*/
if (drive->PADAM_sleep && time_after(jiffies, drive->PADAM_sleep))
if (drive->sleep && time_after(jiffies, drive->sleep))
continue;
/* Take this device, if there is no device choosen thus far or
* it's more urgent.
*/
if (!choice || (drive->PADAM_sleep && (!choice->PADAM_sleep || time_after(choice->PADAM_sleep, drive->PADAM_sleep))))
{
if (!choice || (drive->sleep && (!choice->sleep || time_after(choice->sleep, drive->sleep)))) {
if (!blk_queue_plugged(&drive->queue))
choice = drive;
}
......@@ -1315,7 +1314,6 @@ static struct ata_device *choose_urgent_device(struct ata_channel *channel)
* Feed commands to a drive until it barfs. Called with ide_lock/DRIVE_LOCK
* held and busy channel.
*/
static void queue_commands(struct ata_device *drive, int masked_irq)
{
ide_hwgroup_t *hwgroup = drive->channel->hwgroup;
......@@ -1325,7 +1323,7 @@ static void queue_commands(struct ata_device *drive, int masked_irq)
struct request *rq = NULL;
if (!test_bit(IDE_BUSY, &hwgroup->flags))
printk(KERN_ERR"%s: hwgroup not busy while queueing\n", drive->name);
printk(KERN_ERR"%s: error: not busy while queueing!\n", drive->name);
/* Abort early if we can't queue another command. for non
* tcq, ata_can_queue is always 1 since we never get here
......@@ -1337,7 +1335,7 @@ static void queue_commands(struct ata_device *drive, int masked_irq)
break;
}
drive->PADAM_sleep = 0;
drive->sleep = 0;
if (test_bit(IDE_DMA, &hwgroup->flags)) {
printk("ide_do_request: DMA in progress...\n");
......@@ -1825,10 +1823,9 @@ void ide_init_drive_cmd(struct request *rq)
* completed. This is again intended for careful use by the ATAPI tape/cdrom
* driver code.
*/
int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t action)
int ide_do_drive_cmd(struct ata_device *drive, struct request *rq, ide_action_t action)
{
unsigned long flags;
ide_hwgroup_t *hwgroup = HWGROUP(drive);
unsigned int major = drive->channel->major;
request_queue_t *q = &drive->queue;
struct list_head *queue_head = &q->queue_head;
......@@ -1846,7 +1843,7 @@ int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t action
spin_lock_irqsave(&ide_lock, flags);
if (blk_queue_empty(&drive->queue) || action == ide_preempt) {
if (action == ide_preempt)
hwgroup->rq = NULL;
HWGROUP(drive)->rq = NULL;
} else {
if (action == ide_wait || action == ide_end)
queue_head = queue_head->prev;
......@@ -1873,21 +1870,22 @@ int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t action
* usage == 1 (we need an open channel to use an ioctl :-), so this
* is our limit.
*/
int ide_revalidate_disk (kdev_t i_rdev)
int ide_revalidate_disk(kdev_t i_rdev)
{
ide_drive_t *drive;
ide_hwgroup_t *hwgroup;
struct ata_device *drive;
unsigned long flags;
int res;
if ((drive = get_info_ptr(i_rdev)) == NULL)
return -ENODEV;
hwgroup = HWGROUP(drive);
spin_lock_irqsave(&ide_lock, flags);
if (drive->busy || (drive->usage > 1)) {
spin_unlock_irqrestore(&ide_lock, flags);
return -EBUSY;
}
drive->busy = 1;
MOD_INC_USE_COUNT;
spin_unlock_irqrestore(&ide_lock, flags);
......@@ -2032,71 +2030,18 @@ ide_proc_entry_t generic_subdriver_entries[] = {
};
#endif
/*
* Note that we only release the standard ports, and do not even try to handle
* any extra ports allocated for weird IDE interface chipsets.
*/
static void hwif_unregister(struct ata_channel *ch)
{
int i;
ide_hwgroup_t *hwgroup = ch->hwgroup;
/*
* Free the irq if we were the only channel using it.
*/
int n = 0;
for (i = 0; i < MAX_HWIFS; ++i) {
struct ata_channel *tmp = &ide_hwifs[i];
if (!tmp->present)
continue;
if (tmp->irq == ch->irq)
++n;
}
if (n == 1)
free_irq(ch->irq, hwgroup);
if (ch->straight8) {
release_region(ch->io_ports[IDE_DATA_OFFSET], 8);
} else {
if (ch->io_ports[IDE_DATA_OFFSET])
release_region(ch->io_ports[IDE_DATA_OFFSET], 1);
if (ch->io_ports[IDE_ERROR_OFFSET])
release_region(ch->io_ports[IDE_ERROR_OFFSET], 1);
if (ch->io_ports[IDE_NSECTOR_OFFSET])
release_region(ch->io_ports[IDE_NSECTOR_OFFSET], 1);
if (ch->io_ports[IDE_SECTOR_OFFSET])
release_region(ch->io_ports[IDE_SECTOR_OFFSET], 1);
if (ch->io_ports[IDE_LCYL_OFFSET])
release_region(ch->io_ports[IDE_LCYL_OFFSET], 1);
if (ch->io_ports[IDE_HCYL_OFFSET])
release_region(ch->io_ports[IDE_HCYL_OFFSET], 1);
if (ch->io_ports[IDE_SELECT_OFFSET])
release_region(ch->io_ports[IDE_SELECT_OFFSET], 1);
if (ch->io_ports[IDE_STATUS_OFFSET])
release_region(ch->io_ports[IDE_STATUS_OFFSET], 1);
}
if (ch->io_ports[IDE_CONTROL_OFFSET])
release_region(ch->io_ports[IDE_CONTROL_OFFSET], 1);
#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
if (ch->io_ports[IDE_IRQ_OFFSET])
release_region(ch->io_ports[IDE_IRQ_OFFSET], 1);
#endif
}
void ide_unregister(struct ata_channel *ch)
{
struct gendisk *gd;
struct ata_device *d;
ide_hwgroup_t *hwgroup;
int unit, i;
int unit;
int i;
unsigned long flags;
unsigned int p, minor;
struct ata_channel old;
int n = 0;
int n_irq;
int n_ch;
spin_lock_irqsave(&ide_lock, flags);
......@@ -2146,10 +2091,40 @@ void ide_unregister(struct ata_channel *ch)
#endif
spin_lock_irqsave(&ide_lock, flags);
hwif_unregister(ch);
/*
* Note that we only release the standard ports, and do not even try to
* handle any extra ports allocated for weird IDE interface chipsets.
*/
if (ch->straight8) {
release_region(ch->io_ports[IDE_DATA_OFFSET], 8);
} else {
if (ch->io_ports[IDE_DATA_OFFSET])
release_region(ch->io_ports[IDE_DATA_OFFSET], 1);
if (ch->io_ports[IDE_ERROR_OFFSET])
release_region(ch->io_ports[IDE_ERROR_OFFSET], 1);
if (ch->io_ports[IDE_NSECTOR_OFFSET])
release_region(ch->io_ports[IDE_NSECTOR_OFFSET], 1);
if (ch->io_ports[IDE_SECTOR_OFFSET])
release_region(ch->io_ports[IDE_SECTOR_OFFSET], 1);
if (ch->io_ports[IDE_LCYL_OFFSET])
release_region(ch->io_ports[IDE_LCYL_OFFSET], 1);
if (ch->io_ports[IDE_HCYL_OFFSET])
release_region(ch->io_ports[IDE_HCYL_OFFSET], 1);
if (ch->io_ports[IDE_SELECT_OFFSET])
release_region(ch->io_ports[IDE_SELECT_OFFSET], 1);
if (ch->io_ports[IDE_STATUS_OFFSET])
release_region(ch->io_ports[IDE_STATUS_OFFSET], 1);
}
if (ch->io_ports[IDE_CONTROL_OFFSET])
release_region(ch->io_ports[IDE_CONTROL_OFFSET], 1);
#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
if (ch->io_ports[IDE_IRQ_OFFSET])
release_region(ch->io_ports[IDE_IRQ_OFFSET], 1);
#endif
/*
* Remove us from the hwgroup
* Remove us from the hwgroup.
*/
hwgroup = ch->hwgroup;
......@@ -2177,20 +2152,30 @@ void ide_unregister(struct ata_channel *ch)
if (d->present)
hwgroup->XXX_drive = d;
/* Free the hwgroup if we were the only member.
/*
* Free the irq if we were the only channel using it.
*
* Free the hwgroup if we were the only member.
*/
n = 0;
n_irq = n_ch = 0;
for (i = 0; i < MAX_HWIFS; ++i) {
struct ata_channel *tmp = &ide_hwifs[i];
if (!tmp->present)
continue;
if (tmp->irq == ch->irq)
++n_irq;
if (tmp->hwgroup == ch->hwgroup)
++n;
++n_ch;
}
if (n == 1)
if (n_irq == 1)
free_irq(ch->irq, ch->hwgroup);
if (n_ch == 1) {
kfree(ch->hwgroup);
ch->hwgroup = NULL;
}
#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
ide_release_dma(ch);
......
......@@ -47,18 +47,18 @@ static int pdcadma_get_info (char *buffer, char **addr, off_t offset, int count)
return p-buffer; /* => must be less than 4k! */
}
#endif /* defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS) */
#endif
byte pdcadma_proc = 0;
extern char *ide_xfer_verbose (byte xfer_rate);
#ifdef CONFIG_BLK_DEV_IDEDMA
/*
* pdcadma_dmaproc() initiates/aborts (U)DMA read/write operations on a drive.
* This initiates/aborts (U)DMA read/write operations on a drive.
*/
int pdcadma_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
int pdcadma_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
switch (func) {
case ide_dma_check:
......@@ -66,9 +66,9 @@ int pdcadma_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
unsigned int __init pci_init_pdcadma(struct pci_dev *dev)
{
......@@ -76,9 +76,9 @@ unsigned int __init pci_init_pdcadma(struct pci_dev *dev)
if (!pdcadma_proc) {
pdcadma_proc = 1;
bmide_dev = dev;
pdcadma_display_info = &pdcadma_get_info;
pdcadma_display_info = pdcadma_get_info;
}
#endif /* DISPLAY_PDCADMA_TIMINGS && CONFIG_PROC_FS */
#endif
return 0;
}
......
......@@ -471,7 +471,9 @@ unsigned int __init pci_init_piix(struct pci_dev *dev, const char *name)
break;
}
#ifndef CONFIG_BLK_DEV_PIIX_TRY133
case PIIX_UDMA_100:
#endif
case PIIX_UDMA_133:
pci_read_config_dword(dev, PIIX_IDECFG, &u);
piix_80w = ((u & 0x30) ? 1 : 0) | ((u & 0xc0) ? 2 : 0);
......@@ -484,7 +486,7 @@ unsigned int __init pci_init_piix(struct pci_dev *dev, const char *name)
if (piix_config->flags & PIIX_PINGPONG) {
pci_read_config_dword(dev, PIIX_IDECFG, &u);
u |= 0x400;
u |= 0x400;
pci_write_config_dword(dev, PIIX_IDECFG, u);
}
......
......@@ -173,7 +173,7 @@ static void trm290_selectproc (ide_drive_t *drive)
}
#ifdef CONFIG_BLK_DEV_IDEDMA
static int trm290_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
static int trm290_dmaproc (ide_dma_action_t func, struct ata_device *drive, struct request *rq)
{
struct ata_channel *hwif = drive->channel;
unsigned int count, reading = 2, writing = 0;
......@@ -206,12 +206,12 @@ static int trm290_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
case ide_dma_test_irq:
return (inw(hwif->dma_base+2) == 0x00ff);
default:
return ide_dmaproc(func, drive);
return ide_dmaproc(func, drive, rq);
}
trm290_prepare_drive(drive, 0); /* select PIO xfer */
return 1;
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
#endif
/*
* Invoked from ide-dma.c at boot time.
......@@ -263,8 +263,8 @@ void __init ide_init_trm290(struct ata_channel *hwif)
ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->unit ? 0x0080 : 0x0000), 3);
#ifdef CONFIG_BLK_DEV_IDEDMA
hwif->dmaproc = &trm290_dmaproc;
#endif /* CONFIG_BLK_DEV_IDEDMA */
hwif->udma = trm290_dmaproc;
#endif
hwif->selectproc = &trm290_selectproc;
hwif->autodma = 0; /* play it safe for now */
......
......@@ -283,10 +283,8 @@ struct ata_device {
*/
request_queue_t queue; /* per device request queue */
/* Those are directly injected jiffie values. They should go away and
* we should use generic timers instead!!!
*/
unsigned long PADAM_sleep; /* sleep until this time */
unsigned long sleep; /* sleep until this time */
/* Flags requesting/indicating one of the following special commands
* executed on the request queue.
......
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