From b5e1a4e2869af5ffaa102535ad63d184d86e66ec Mon Sep 17 00:00:00 2001 From: Aristeu Rozanski Date: Fri, 25 Jan 2008 22:17:04 +0100 Subject: ide-io: set REQ_FAILED when drive is dead Currently it's possible to ide-cd to set an incorrect blocksize by reading garbage if the drive is dead: ide_cd_probe() -> cdrom_read_toc() -> cdrom_read_capacity() -> cdrom_queue_packet_command() -> ide_do_drive_cmd() -> ide_do_request() -> start_request() on start_request(): /* bail early if we've exceeded max_failures */ if (drive->max_failures && (drive->failures > drive->max_failures)) { goto kill_rq; } (...) kill_rq: ide_kill_rq(drive, rq); return ide_stopped; ide_kill_rq() and the next calls won't set REQ_FAILED on rq->cmd_flags and thus cdrom_queue_packet_command() won't return an error. then: stat = cdrom_queue_packet_command(drive, &req); if (stat == 0) { *capacity = 1 + be32_to_cpu(capbuf.lba); *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; } cdrom_read_capacity() ends believing capbuf is valid but in fact it's just uninitialized data. back to cdrom_read_toc(): /* Try to get the total cdrom capacity and sector size. */ stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, sense); if (stat) toc->capacity = 0x1fffff; set_capacity(info->disk, toc->capacity * sectors_per_frame); /* Save a private copy of te TOC capacity for error handling */ drive->probed_capacity = toc->capacity * sectors_per_frame; blk_queue_hardsect_size(drive->queue, sectors_per_frame << SECTOR_BITS); that will set drive->queue->hardsect_size to be the random value. hardsect_size is used to calculate inode->i_blkbits. later on, on a read path: void create_empty_buffers(struct page *page, unsigned long blocksize, unsigned long b_state) { struct buffer_head *bh, *head, *tail; head = alloc_page_buffers(page, blocksize, 1); bh = head; do { bh->b_state |= b_state; tail = bh; bh = bh->b_this_page; } while (bh); tail->b_this_page = head; alloc_page_buffers() will return NULL if blocksize > 4096. blocksize is calculed based on inode->i_blkbits. that will trigger a null dereference on create_empty_buffers(). Signed-off-by: Aristeu Rozanski Cc: Borislav Petkov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index bef781f..bb1b0a8 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1003,6 +1003,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) /* bail early if we've exceeded max_failures */ if (drive->max_failures && (drive->failures > drive->max_failures)) { + rq->cmd_flags |= REQ_FAILED; goto kill_rq; } -- cgit v0.10.2 From ceb1b2c583a9503e3ae68c4e7c652637971e3768 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Fri, 25 Jan 2008 22:17:04 +0100 Subject: hpt366: change timing register masks Since PIO autotuning is now done always, there's no need anymore to program the taskfile timings also on DMA modes, so change the IDE timing register masks accordingly, "inverting the polarity" of the masks while at it... Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 9fce25b..edb267c 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/hpt366.c Version 1.22 Dec 4, 2007 + * linux/drivers/ide/pci/hpt366.c Version 1.23 Dec 7, 2007 * * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. @@ -689,19 +689,17 @@ static void hpt36x_set_mode(ide_drive_t *drive, const u8 speed) struct hpt_info *info = pci_get_drvdata(dev); u8 itr_addr = drive->dn ? 0x44 : 0x40; u32 old_itr = 0; - u32 itr_mask, new_itr; - - itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 : - (speed < XFER_UDMA_0 ? 0xc0070000 : 0xc03800ff); - - new_itr = get_speed_setting(speed, info); + u32 new_itr = get_speed_setting(speed, info); + u32 itr_mask = speed < XFER_MW_DMA_0 ? 0xc1f8ffff : + (speed < XFER_UDMA_0 ? 0x303800ff : + 0x30070000); + pci_read_config_dword(dev, itr_addr, &old_itr); + new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask); /* * Disable on-chip PIO FIFO/buffer (and PIO MST mode as well) * to avoid problems handling I/O errors later */ - pci_read_config_dword(dev, itr_addr, &old_itr); - new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask); new_itr &= ~0xc0000000; pci_write_config_dword(dev, itr_addr, new_itr); @@ -714,16 +712,14 @@ static void hpt37x_set_mode(ide_drive_t *drive, const u8 speed) struct hpt_info *info = pci_get_drvdata(dev); u8 itr_addr = 0x40 + (drive->dn * 4); u32 old_itr = 0; - u32 itr_mask, new_itr; - - itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 : - (speed < XFER_UDMA_0 ? 0xc03c0000 : 0xc1c001ff); - - new_itr = get_speed_setting(speed, info); + u32 new_itr = get_speed_setting(speed, info); + u32 itr_mask = speed < XFER_MW_DMA_0 ? 0xcfc3ffff : + (speed < XFER_UDMA_0 ? 0x31c001ff : + 0x303c0000); pci_read_config_dword(dev, itr_addr, &old_itr); - new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask); - + new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask); + if (speed < XFER_MW_DMA_0) new_itr &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */ pci_write_config_dword(dev, itr_addr, new_itr); -- cgit v0.10.2 From a488f34e0dc7180f35fe48a60596fc82fe69d3ef Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Fri, 25 Jan 2008 22:17:05 +0100 Subject: hpt366: kill set_dma_mode() method wrapper There's no reason to keep the set_dma_mode() method wrapper for two different chip families, so get rid of it... Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index edb267c..faf77fd 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/hpt366.c Version 1.23 Dec 7, 2007 + * linux/drivers/ide/pci/hpt366.c Version 1.24 Dec 8, 2007 * * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. @@ -725,20 +725,9 @@ static void hpt37x_set_mode(ide_drive_t *drive, const u8 speed) pci_write_config_dword(dev, itr_addr, new_itr); } -static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) -{ - ide_hwif_t *hwif = HWIF(drive); - struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); - - if (info->chip_type >= HPT370) - hpt37x_set_mode(drive, speed); - else /* hpt368: hpt_minimum_revision(dev, 2) */ - hpt36x_set_mode(drive, speed); -} - static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) { - hpt3xx_set_mode(drive, XFER_PIO_0 + pio); + HWIF(drive)->set_dma_mode(drive, XFER_PIO_0 + pio); } static int hpt3xx_quirkproc(ide_drive_t *drive) @@ -1315,7 +1304,11 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->select_data = hwif->channel ? 0x54 : 0x50; hwif->set_pio_mode = &hpt3xx_set_pio_mode; - hwif->set_dma_mode = &hpt3xx_set_mode; + if (chip_type >= HPT370) + hwif->set_dma_mode = &hpt37x_set_mode; + else + hwif->set_dma_mode = &hpt36x_set_mode; + hwif->quirkproc = &hpt3xx_quirkproc; hwif->intrproc = &hpt3xx_intrproc; hwif->maskproc = &hpt3xx_maskproc; -- cgit v0.10.2 From 866664d79f6a920af07e6503f64366f4c5b2d41f Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Fri, 25 Jan 2008 22:17:05 +0100 Subject: hpt366: merge set_dma_mode() methods Group the array of pointers to the timing tables with the timing register masks which allows us to merge HPT36x/HPT37x set_dma_mode() methods into one. Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index faf77fd..df14d69 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/hpt366.c Version 1.24 Dec 8, 2007 + * linux/drivers/ide/pci/hpt366.c Version 1.30 Dec 12, 2007 * * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. @@ -88,7 +88,7 @@ * - rename all the register related variables consistently * - move all the interrupt twiddling code from the speedproc handlers into * init_hwif_hpt366(), also grouping all the DMA related code together there - * - merge two HPT37x speedproc handlers, fix the PIO timing register mask and + * - merge HPT36x/HPT37x speedproc handlers, fix PIO timing register mask and * separate the UltraDMA and MWDMA masks there to avoid changing PIO timings * when setting an UltraDMA mode * - fix hpt3xx_tune_drive() to set the PIO mode requested, not always select @@ -458,6 +458,13 @@ enum ata_clock { NUM_ATA_CLOCKS }; +struct hpt_timings { + u32 pio_mask; + u32 dma_mask; + u32 ultra_mask; + u32 *clock_table[NUM_ATA_CLOCKS]; +}; + /* * Hold all the HighPoint chip information in one place. */ @@ -468,7 +475,8 @@ struct hpt_info { u8 udma_mask; /* Allowed UltraDMA modes mask. */ u8 dpll_clk; /* DPLL clock in MHz */ u8 pci_clk; /* PCI clock in MHz */ - u32 **settings; /* Chipset settings table */ + struct hpt_timings *timings; /* Chipset timing data */ + u8 clock; /* ATA clock selected */ }; /* Supported HighPoint chips */ @@ -486,20 +494,30 @@ enum { HPT371N }; -static u32 *hpt36x_settings[NUM_ATA_CLOCKS] = { - twenty_five_base_hpt36x, - thirty_three_base_hpt36x, - forty_base_hpt36x, - NULL, - NULL +static struct hpt_timings hpt36x_timings = { + .pio_mask = 0xc1f8ffff, + .dma_mask = 0x303800ff, + .ultra_mask = 0x30070000, + .clock_table = { + [ATA_CLOCK_25MHZ] = twenty_five_base_hpt36x, + [ATA_CLOCK_33MHZ] = thirty_three_base_hpt36x, + [ATA_CLOCK_40MHZ] = forty_base_hpt36x, + [ATA_CLOCK_50MHZ] = NULL, + [ATA_CLOCK_66MHZ] = NULL + } }; -static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = { - NULL, - thirty_three_base_hpt37x, - NULL, - fifty_base_hpt37x, - sixty_six_base_hpt37x +static struct hpt_timings hpt37x_timings = { + .pio_mask = 0xcfc3ffff, + .dma_mask = 0x31c001ff, + .ultra_mask = 0x303c0000, + .clock_table = { + [ATA_CLOCK_25MHZ] = NULL, + [ATA_CLOCK_33MHZ] = thirty_three_base_hpt37x, + [ATA_CLOCK_40MHZ] = NULL, + [ATA_CLOCK_50MHZ] = fifty_base_hpt37x, + [ATA_CLOCK_66MHZ] = sixty_six_base_hpt37x + } }; static const struct hpt_info hpt36x __devinitdata = { @@ -507,7 +525,7 @@ static const struct hpt_info hpt36x __devinitdata = { .chip_type = HPT36x, .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, .dpll_clk = 0, /* no DPLL */ - .settings = hpt36x_settings + .timings = &hpt36x_timings }; static const struct hpt_info hpt370 __devinitdata = { @@ -515,7 +533,7 @@ static const struct hpt_info hpt370 __devinitdata = { .chip_type = HPT370, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, .dpll_clk = 48, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt370a __devinitdata = { @@ -523,7 +541,7 @@ static const struct hpt_info hpt370a __devinitdata = { .chip_type = HPT370A, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, .dpll_clk = 48, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt374 __devinitdata = { @@ -531,7 +549,7 @@ static const struct hpt_info hpt374 __devinitdata = { .chip_type = HPT374, .udma_mask = ATA_UDMA5, .dpll_clk = 48, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt372 __devinitdata = { @@ -539,7 +557,7 @@ static const struct hpt_info hpt372 __devinitdata = { .chip_type = HPT372, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 55, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt372a __devinitdata = { @@ -547,7 +565,7 @@ static const struct hpt_info hpt372a __devinitdata = { .chip_type = HPT372A, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 66, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt302 __devinitdata = { @@ -555,7 +573,7 @@ static const struct hpt_info hpt302 __devinitdata = { .chip_type = HPT302, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 66, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt371 __devinitdata = { @@ -563,7 +581,7 @@ static const struct hpt_info hpt371 __devinitdata = { .chip_type = HPT371, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 66, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt372n __devinitdata = { @@ -571,7 +589,7 @@ static const struct hpt_info hpt372n __devinitdata = { .chip_type = HPT372N, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 77, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt302n __devinitdata = { @@ -579,7 +597,7 @@ static const struct hpt_info hpt302n __devinitdata = { .chip_type = HPT302N, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 77, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static const struct hpt_info hpt371n __devinitdata = { @@ -587,7 +605,7 @@ static const struct hpt_info hpt371n __devinitdata = { .chip_type = HPT371N, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, .dpll_clk = 77, - .settings = hpt37x_settings + .timings = &hpt37x_timings }; static int check_in_drive_list(ide_drive_t *drive, const char **list) @@ -675,24 +693,21 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info) for (i = 0; i < ARRAY_SIZE(xfer_speeds) - 1; i++) if (xfer_speeds[i] == speed) break; - /* - * NOTE: info->settings only points to the pointer - * to the list of the actual register values - */ - return (*info->settings)[i]; + + return info->timings->clock_table[info->clock][i]; } -static void hpt36x_set_mode(ide_drive_t *drive, const u8 speed) +static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) { - ide_hwif_t *hwif = HWIF(drive); - struct pci_dev *dev = hwif->pci_dev; + struct pci_dev *dev = HWIF(drive)->pci_dev; struct hpt_info *info = pci_get_drvdata(dev); - u8 itr_addr = drive->dn ? 0x44 : 0x40; + struct hpt_timings *t = info->timings; + u8 itr_addr = 0x40 + (drive->dn * 4); u32 old_itr = 0; u32 new_itr = get_speed_setting(speed, info); - u32 itr_mask = speed < XFER_MW_DMA_0 ? 0xc1f8ffff : - (speed < XFER_UDMA_0 ? 0x303800ff : - 0x30070000); + u32 itr_mask = speed < XFER_MW_DMA_0 ? t->pio_mask : + (speed < XFER_UDMA_0 ? t->dma_mask : + t->ultra_mask); pci_read_config_dword(dev, itr_addr, &old_itr); new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask); @@ -705,29 +720,9 @@ static void hpt36x_set_mode(ide_drive_t *drive, const u8 speed) pci_write_config_dword(dev, itr_addr, new_itr); } -static void hpt37x_set_mode(ide_drive_t *drive, const u8 speed) -{ - ide_hwif_t *hwif = HWIF(drive); - struct pci_dev *dev = hwif->pci_dev; - struct hpt_info *info = pci_get_drvdata(dev); - u8 itr_addr = 0x40 + (drive->dn * 4); - u32 old_itr = 0; - u32 new_itr = get_speed_setting(speed, info); - u32 itr_mask = speed < XFER_MW_DMA_0 ? 0xcfc3ffff : - (speed < XFER_UDMA_0 ? 0x31c001ff : - 0x303c0000); - - pci_read_config_dword(dev, itr_addr, &old_itr); - new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask); - - if (speed < XFER_MW_DMA_0) - new_itr &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */ - pci_write_config_dword(dev, itr_addr, new_itr); -} - static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) { - HWIF(drive)->set_dma_mode(drive, XFER_PIO_0 + pio); + hpt3xx_set_mode(drive, XFER_PIO_0 + pio); } static int hpt3xx_quirkproc(ide_drive_t *drive) @@ -1195,7 +1190,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha * We also don't like using the DPLL because this causes glitches * on PRST-/SRST- when the state engine gets reset... */ - if (chip_type >= HPT374 || info->settings[clock] == NULL) { + if (chip_type >= HPT374 || info->timings->clock_table[clock] == NULL) { u16 f_low, delta = pci_clk < 50 ? 2 : 4; int adjust; @@ -1211,7 +1206,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha clock = ATA_CLOCK_50MHZ; } - if (info->settings[clock] == NULL) { + if (info->timings->clock_table[clock] == NULL) { printk(KERN_ERR "%s: unknown bus timing!\n", name); kfree(info); return -EIO; @@ -1252,15 +1247,10 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha printk("%s: using %d MHz PCI clock\n", name, pci_clk); } - /* - * Advance the table pointer to a slot which points to the list - * of the register values settings matching the clock being used. - */ - info->settings += clock; - /* Store the clock frequencies. */ info->dpll_clk = dpll_clk; info->pci_clk = pci_clk; + info->clock = clock; /* Point to this chip's own instance of the hpt_info structure. */ pci_set_drvdata(dev, info); @@ -1304,10 +1294,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->select_data = hwif->channel ? 0x54 : 0x50; hwif->set_pio_mode = &hpt3xx_set_pio_mode; - if (chip_type >= HPT370) - hwif->set_dma_mode = &hpt37x_set_mode; - else - hwif->set_dma_mode = &hpt36x_set_mode; + hwif->set_dma_mode = &hpt3xx_set_mode; hwif->quirkproc = &hpt3xx_quirkproc; hwif->intrproc = &hpt3xx_intrproc; -- cgit v0.10.2 From 1c029fd658baa2442e8e51dc9c819301cad95777 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:05 +0100 Subject: ide: remove ->dma_master field from ide_hwif_t (take 5) * Convert cmd64x, hpt366 and pdc202xx_old host drivers to use pci_resource_start(hwif->pci_dev, 4) instead of hwif->dma_master. * Remove no longer needed ->dma_master field from ide_hwif_t. v2: * Use the more readable 'hwif->dma_base - (hwif->channel * 8)' instead of pci_resource_start(hwif->pci_dev, 4). v3: * Use hwif->extra_base in hpt366/pdc20xx_old + some cosmetic fixups over v2 (suggested by Sergei). v4: * Correct offsets in hpt3xxn_set_clock(). v5: * Use hwif->extra_base in hpt366 for _real_ this time. (Noticed by Sergei) Acked-by: Sergei Shtylyov Cc: Jeff Garzik Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 4703837..7568c3e 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -968,11 +968,6 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) hwif->dma_base = base; - if (hwif->mate) - hwif->dma_master = hwif->channel ? hwif->mate->dma_base : base; - else - hwif->dma_master = base; - if (!(hwif->dma_command)) hwif->dma_command = hwif->dma_base; if (!(hwif->dma_vendor1)) @@ -1014,8 +1009,6 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "pio"); } printk("\n"); - - BUG_ON(!hwif->dma_master); } EXPORT_SYMBOL_GPL(ide_setup_dma); diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 54943da..9ab5458 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -468,7 +468,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) #endif hwif->dma_base = tmp_hwif->dma_base; - hwif->dma_master = tmp_hwif->dma_master; hwif->dma_command = tmp_hwif->dma_command; hwif->dma_vendor1 = tmp_hwif->dma_vendor1; hwif->dma_status = tmp_hwif->dma_status; @@ -602,7 +601,6 @@ void ide_unregister(unsigned int index) (void) ide_release_dma(hwif); hwif->dma_base = 0; - hwif->dma_master = 0; hwif->dma_command = 0; hwif->dma_vendor1 = 0; hwif->dma_status = 0; diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index bc55333..f3613ba 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -333,14 +333,15 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) static int cmd648_ide_dma_end (ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); + unsigned long base = hwif->dma_base - (hwif->channel * 8); int err = __ide_dma_end(drive); u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : MRDMODE_INTR_CH0; - u8 mrdmode = inb(hwif->dma_master + 0x01); + u8 mrdmode = inb(base + 1); /* clear the interrupt bit */ outb((mrdmode & ~(MRDMODE_INTR_CH0 | MRDMODE_INTR_CH1)) | irq_mask, - hwif->dma_master + 0x01); + base + 1); return err; } @@ -365,10 +366,11 @@ static int cmd64x_ide_dma_end (ide_drive_t *drive) static int cmd648_ide_dma_test_irq (ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); + unsigned long base = hwif->dma_base - (hwif->channel * 8); u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : MRDMODE_INTR_CH0; u8 dma_stat = inb(hwif->dma_status); - u8 mrdmode = inb(hwif->dma_master + 0x01); + u8 mrdmode = inb(base + 1); #ifdef DEBUG printk("%s: dma_stat: 0x%02x mrdmode: 0x%02x irq_mask: 0x%02x\n", diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index df14d69..d3826a6 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -894,32 +894,33 @@ static int hpt374_ide_dma_end(ide_drive_t *drive) static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) { - u8 scr2 = inb(hwif->dma_master + 0x7b); + unsigned long base = hwif->extra_base; + u8 scr2 = inb(base + 0x6b); if ((scr2 & 0x7f) == mode) return; /* Tristate the bus */ - outb(0x80, hwif->dma_master + 0x73); - outb(0x80, hwif->dma_master + 0x77); + outb(0x80, base + 0x63); + outb(0x80, base + 0x67); /* Switch clock and reset channels */ - outb(mode, hwif->dma_master + 0x7b); - outb(0xc0, hwif->dma_master + 0x79); + outb(mode, base + 0x6b); + outb(0xc0, base + 0x69); /* * Reset the state machines. * NOTE: avoid accidentally enabling the disabled channels. */ - outb(inb(hwif->dma_master + 0x70) | 0x32, hwif->dma_master + 0x70); - outb(inb(hwif->dma_master + 0x74) | 0x32, hwif->dma_master + 0x74); + outb(inb(base + 0x60) | 0x32, base + 0x60); + outb(inb(base + 0x64) | 0x32, base + 0x64); /* Complete reset */ - outb(0x00, hwif->dma_master + 0x79); + outb(0x00, base + 0x69); /* Reconnect channels to bus */ - outb(0x00, hwif->dma_master + 0x73); - outb(0x00, hwif->dma_master + 0x77); + outb(0x00, base + 0x63); + outb(0x00, base + 0x67); } /** diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index e09742e..22c7a75 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -162,7 +162,7 @@ static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) */ static void pdc_old_enable_66MHz_clock(ide_hwif_t *hwif) { - unsigned long clock_reg = hwif->dma_master + 0x11; + unsigned long clock_reg = hwif->extra_base + 0x01; u8 clock = inb(clock_reg); outb(clock | (hwif->channel ? 0x08 : 0x02), clock_reg); @@ -170,7 +170,7 @@ static void pdc_old_enable_66MHz_clock(ide_hwif_t *hwif) static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif) { - unsigned long clock_reg = hwif->dma_master + 0x11; + unsigned long clock_reg = hwif->extra_base + 0x01; u8 clock = inb(clock_reg); outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); @@ -193,7 +193,7 @@ static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) if (drive->media != ide_disk || drive->addressing == 1) { struct request *rq = HWGROUP(drive)->rq; ide_hwif_t *hwif = HWIF(drive); - unsigned long high_16 = hwif->dma_master; + unsigned long high_16 = hwif->extra_base - 16; unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); u32 word_count = 0; u8 clock = inb(high_16 + 0x11); @@ -212,7 +212,7 @@ static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) { if (drive->media != ide_disk || drive->addressing == 1) { ide_hwif_t *hwif = HWIF(drive); - unsigned long high_16 = hwif->dma_master; + unsigned long high_16 = hwif->extra_base - 16; unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); u8 clock = 0; @@ -228,7 +228,7 @@ static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) static int pdc202xx_old_ide_dma_test_irq(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); - unsigned long high_16 = hwif->dma_master; + unsigned long high_16 = hwif->extra_base - 16; u8 dma_stat = inb(hwif->dma_status); u8 sc1d = inb(high_16 + 0x001d); @@ -271,7 +271,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive) static void pdc202xx_reset_host (ide_hwif_t *hwif) { - unsigned long high_16 = hwif->dma_master; + unsigned long high_16 = hwif->extra_base - 16; u8 udma_speed_flag = inb(high_16 | 0x001f); outb(udma_speed_flag | 0x10, high_16 | 0x001f); diff --git a/include/linux/ide.h b/include/linux/ide.h index 9a6a41e..1fb03b6 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -766,7 +766,6 @@ typedef struct hwif_s { int rqsize; /* max sectors per request */ int irq; /* our irq number */ - unsigned long dma_master; /* reference base addr dmabase */ unsigned long dma_base; /* base addr for dma ports */ unsigned long dma_command; /* dma command register */ unsigned long dma_vendor1; /* dma vendor 1 register */ -- cgit v0.10.2 From cd2a2d969761c26542095c01324201ca0b3ee896 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:06 +0100 Subject: ide: remove task_ioreg_t typedef (take 2) Remove task_ioreg_t typedef from the kernel code (but leave it in for #ifndef/#endif __KERNEL__ case). While at it also move sata_ioreg_t typedef under #ifndef/#endif __KERNEL__. v2: Remove name of the second parameter from ide_execute_command() declaration. (Noticed by Sergei). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index b178190..322c469 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -138,7 +138,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ide_hwif_t *hwif = HWIF(drive); unsigned int dma = drive->using_dma; u8 lba48 = (drive->addressing == 1) ? 1 : 0; - task_ioreg_t command = WIN_NOP; + u8 command = WIN_NOP; ata_nsector_t nsectors; nsectors.all = (u16) rq->nr_sectors; @@ -162,7 +162,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, if (drive->select.b.lba) { if (lba48) { - task_ioreg_t tasklets[10]; + u8 tasklets[10]; pr_debug("%s: LBA=0x%012llx\n", drive->name, (unsigned long long)block); @@ -171,16 +171,16 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tasklets[1] = 0; tasklets[2] = nsectors.b.low; tasklets[3] = nsectors.b.high; - tasklets[4] = (task_ioreg_t) block; - tasklets[5] = (task_ioreg_t) (block>>8); - tasklets[6] = (task_ioreg_t) (block>>16); - tasklets[7] = (task_ioreg_t) (block>>24); + tasklets[4] = (u8) block; + tasklets[5] = (u8)(block >> 8); + tasklets[6] = (u8)(block >> 16); + tasklets[7] = (u8)(block >> 24); if (sizeof(block) == 4) { - tasklets[8] = (task_ioreg_t) 0; - tasklets[9] = (task_ioreg_t) 0; + tasklets[8] = 0; + tasklets[9] = 0; } else { - tasklets[8] = (task_ioreg_t)((u64)block >> 32); - tasklets[9] = (task_ioreg_t)((u64)block >> 40); + tasklets[8] = (u8)((u64)block >> 32); + tasklets[9] = (u8)((u64)block >> 40); } #ifdef DEBUG printk("%s: 0x%02x%02x 0x%02x%02x%02x%02x%02x%02x\n", diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index bb9693d..f4e8a0c 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -902,8 +902,9 @@ EXPORT_SYMBOL(ide_set_handler); * handler and IRQ setup do not race. All IDE command kick off * should go via this function or do equivalent locking. */ - -void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *handler, unsigned timeout, ide_expiry_t *expiry) + +void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, + unsigned timeout, ide_expiry_t *expiry) { unsigned long flags; ide_hwgroup_t *hwgroup = HWGROUP(drive); diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 2b60f1b0..91948a4 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -519,8 +519,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ide_task_t args; u8 *outbuf = NULL; u8 *inbuf = NULL; - task_ioreg_t *argsptr = args.tfRegister; - task_ioreg_t *hobsptr = args.hobRegister; + u8 *argsptr = args.tfRegister; + u8 *hobsptr = args.hobRegister; int err = 0; int tasksize = sizeof(struct ide_task_request_s); unsigned int taskin = 0; diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index 818c6af..3bcb885 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -87,10 +87,10 @@ #ifndef __KERNEL__ #define IDE_TASKFILE_STD_OUT_FLAGS 0xFE #define IDE_HOB_STD_OUT_FLAGS 0x3C -#endif typedef unsigned char task_ioreg_t; typedef unsigned long sata_ioreg_t; +#endif typedef union ide_reg_valid_s { unsigned all : 16; @@ -116,8 +116,8 @@ typedef union ide_reg_valid_s { } ide_reg_valid_t; typedef struct ide_task_request_s { - task_ioreg_t io_ports[8]; - task_ioreg_t hob_ports[8]; + __u8 io_ports[8]; + __u8 hob_ports[8]; ide_reg_valid_t out_flags; ide_reg_valid_t in_flags; int data_phase; @@ -133,32 +133,32 @@ typedef struct ide_ioctl_request_s { } ide_ioctl_request_t; struct hd_drive_cmd_hdr { - task_ioreg_t command; - task_ioreg_t sector_number; - task_ioreg_t feature; - task_ioreg_t sector_count; + __u8 command; + __u8 sector_number; + __u8 feature; + __u8 sector_count; }; typedef struct hd_drive_task_hdr { - task_ioreg_t data; - task_ioreg_t feature; - task_ioreg_t sector_count; - task_ioreg_t sector_number; - task_ioreg_t low_cylinder; - task_ioreg_t high_cylinder; - task_ioreg_t device_head; - task_ioreg_t command; + __u8 data; + __u8 feature; + __u8 sector_count; + __u8 sector_number; + __u8 low_cylinder; + __u8 high_cylinder; + __u8 device_head; + __u8 command; } task_struct_t; typedef struct hd_drive_hob_hdr { - task_ioreg_t data; - task_ioreg_t feature; - task_ioreg_t sector_count; - task_ioreg_t sector_number; - task_ioreg_t low_cylinder; - task_ioreg_t high_cylinder; - task_ioreg_t device_head; - task_ioreg_t control; + __u8 data; + __u8 feature; + __u8 sector_count; + __u8 sector_number; + __u8 low_cylinder; + __u8 high_cylinder; + __u8 device_head; + __u8 control; } hob_struct_t; #define TASKFILE_INVALID 0x7fff diff --git a/include/linux/ide.h b/include/linux/ide.h index 1fb03b6..66a38f1 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1019,7 +1019,8 @@ int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); -extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *); +void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int, + ide_expiry_t *); ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); @@ -1068,8 +1069,8 @@ typedef struct ide_task_s { * struct hd_drive_hob_hdr hobf; * hob_struct_t hobf; */ - task_ioreg_t tfRegister[8]; - task_ioreg_t hobRegister[8]; + u8 tfRegister[8]; + u8 hobRegister[8]; ide_reg_valid_t tf_out_flags; ide_reg_valid_t tf_in_flags; int data_phase; -- cgit v0.10.2 From 650d841d9e053a618dd8ce753422f91b493cf2f6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:06 +0100 Subject: ide: add struct ide_taskfile (take 2) * Don't set write-only ide_task_t.hobRegister[6] and ide_task_t.hobRegister[7] in idedisk_set_max_address_ext(). * Add struct ide_taskfile and use it in ide_task_t instead of tfRegister[] and hobRegister[]. * Remove no longer needed IDE_CONTROL_OFFSET_HOB define. * Add #ifndef/#endif __KERNEL__ around definitions of {task,hob}_struct_t. While at it: * Use ATA_LBA define for LBA bit (0x40) as suggested by Tejun Heo. v2: * Add missing newlines. (Noticed by Sergei) * Use ~ATA_LBA instead of 0xBF. (Noticed by Sergei) * Use unnamed unions for error/feature and status/command. (Suggested by Sergei). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Cc: Tejun Heo Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 899d565..747c518 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c @@ -388,13 +388,7 @@ static int taskfile_load_raw(ide_drive_t *drive, args.handler = &task_no_data_intr; /* convert gtf to IDE Taskfile */ - args.tfRegister[1] = gtf->tfa[0]; /* 0x1f1 */ - args.tfRegister[2] = gtf->tfa[1]; /* 0x1f2 */ - args.tfRegister[3] = gtf->tfa[2]; /* 0x1f3 */ - args.tfRegister[4] = gtf->tfa[3]; /* 0x1f4 */ - args.tfRegister[5] = gtf->tfa[4]; /* 0x1f5 */ - args.tfRegister[6] = gtf->tfa[5]; /* 0x1f6 */ - args.tfRegister[7] = gtf->tfa[6]; /* 0x1f7 */ + memcpy(&args.tf_array[7], >f->tfa, 7); if (ide_noacpitfs) { DEBPRINT("_GTF execution disabled\n"); diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 322c469..a4c4d43 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -310,23 +310,22 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; unsigned long addr = 0; /* Create IDE/ATA command request structure */ memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_SELECT_OFFSET] = 0x40; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX; + tf->device = ATA_LBA; + tf->command = WIN_READ_NATIVE_MAX; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ ide_raw_taskfile(drive, &args, NULL); /* if OK, compute maximum address value */ - if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { - addr = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) - | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) - | ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8) - | ((args.tfRegister[IDE_SECTOR_OFFSET] )); + if ((tf->status & 0x01) == 0) { + addr = ((tf->device & 0xf) << 24) | + (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr++; /* since the return value is (maxlba - 1), we add 1 */ } return addr; @@ -335,26 +334,24 @@ static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; unsigned long long addr = 0; /* Create IDE/ATA command request structure */ memset(&args, 0, sizeof(ide_task_t)); - - args.tfRegister[IDE_SELECT_OFFSET] = 0x40; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX_EXT; + tf->device = ATA_LBA; + tf->command = WIN_READ_NATIVE_MAX_EXT; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ ide_raw_taskfile(drive, &args, NULL); /* if OK, compute maximum address value */ - if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { - u32 high = (args.hobRegister[IDE_HCYL_OFFSET] << 16) | - (args.hobRegister[IDE_LCYL_OFFSET] << 8) | - args.hobRegister[IDE_SECTOR_OFFSET]; - u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | - ((args.tfRegister[IDE_LCYL_OFFSET])<<8) | - (args.tfRegister[IDE_SECTOR_OFFSET]); + if ((tf->status & 0x01) == 0) { + u32 high, low; + + high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal; + low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr = ((__u64)high << 24) | low; addr++; /* since the return value is (maxlba - 1), we add 1 */ } @@ -368,26 +365,25 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long addr_req) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; unsigned long addr_set = 0; addr_req--; /* Create IDE/ATA command request structure */ memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff); - args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >> 8) & 0xff); - args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >> 16) & 0xff); - args.tfRegister[IDE_SELECT_OFFSET] = ((addr_req >> 24) & 0x0f) | 0x40; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX; + tf->lbal = (addr_req >> 0) & 0xff; + tf->lbam = (addr_req >> 8) & 0xff; + tf->lbah = (addr_req >> 16) & 0xff; + tf->device = ((addr_req >> 24) & 0x0f) | ATA_LBA; + tf->command = WIN_SET_MAX; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ ide_raw_taskfile(drive, &args, NULL); /* if OK, read new maximum address value */ - if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { - addr_set = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) - | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) - | ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8) - | ((args.tfRegister[IDE_SECTOR_OFFSET] )); + if ((tf->status & 0x01) == 0) { + addr_set = ((tf->device & 0xf) << 24) | + (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr_set++; } return addr_set; @@ -396,33 +392,30 @@ static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long a static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsigned long long addr_req) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; unsigned long long addr_set = 0; addr_req--; /* Create IDE/ATA command request structure */ memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff); - args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >>= 8) & 0xff); - args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >>= 8) & 0xff); - args.tfRegister[IDE_SELECT_OFFSET] = 0x40; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX_EXT; - args.hobRegister[IDE_SECTOR_OFFSET] = (addr_req >>= 8) & 0xff; - args.hobRegister[IDE_LCYL_OFFSET] = (addr_req >>= 8) & 0xff; - args.hobRegister[IDE_HCYL_OFFSET] = (addr_req >>= 8) & 0xff; - args.hobRegister[IDE_SELECT_OFFSET] = 0x40; - args.hobRegister[IDE_CONTROL_OFFSET_HOB]= (drive->ctl|0x80); + tf->lbal = (addr_req >> 0) & 0xff; + tf->lbam = (addr_req >>= 8) & 0xff; + tf->lbah = (addr_req >>= 8) & 0xff; + tf->device = ATA_LBA; + tf->command = WIN_SET_MAX_EXT; + tf->hob_lbal = (addr_req >>= 8) & 0xff; + tf->hob_lbam = (addr_req >>= 8) & 0xff; + tf->hob_lbah = (addr_req >>= 8) & 0xff; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ ide_raw_taskfile(drive, &args, NULL); /* if OK, compute maximum address value */ - if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { - u32 high = (args.hobRegister[IDE_HCYL_OFFSET] << 16) | - (args.hobRegister[IDE_LCYL_OFFSET] << 8) | - args.hobRegister[IDE_SECTOR_OFFSET]; - u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | - ((args.tfRegister[IDE_LCYL_OFFSET])<<8) | - (args.tfRegister[IDE_SECTOR_OFFSET]); + if ((tf->status & 0x01) == 0) { + u32 high, low; + + high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal; + low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr_set = ((__u64)high << 24) | low; addr_set++; } @@ -556,12 +549,13 @@ static sector_t idedisk_capacity (ide_drive_t *drive) static int smart_enable(ide_drive_t *drive) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_FEATURE_OFFSET] = SMART_ENABLE; - args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; - args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART; + tf->feature = SMART_ENABLE; + tf->lbam = SMART_LCYL_PASS; + tf->lbah = SMART_HCYL_PASS; + tf->command = WIN_SMART; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; return ide_raw_taskfile(drive, &args, NULL); @@ -570,13 +564,14 @@ static int smart_enable(ide_drive_t *drive) static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) { ide_task_t args; + struct ide_taskfile *tf = &args.tf; memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_FEATURE_OFFSET] = sub_cmd; - args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; - args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; - args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART; + tf->feature = sub_cmd; + tf->nsect = 0x01; + tf->lbam = SMART_LCYL_PASS; + tf->lbah = SMART_HCYL_PASS; + tf->command = WIN_SMART; args.command_type = IDE_DRIVE_TASK_IN; args.data_phase = TASKFILE_IN; args.handler = &task_in_intr; @@ -753,9 +748,9 @@ static int write_cache(ide_drive_t *drive, int arg) if (ide_id_has_flush_cache(drive->id)) { memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? + args.tf.feature = arg ? SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; + args.tf.command = WIN_SETFEATURES; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; err = ide_raw_taskfile(drive, &args, NULL); @@ -774,9 +769,9 @@ static int do_idedisk_flushcache (ide_drive_t *drive) memset(&args, 0, sizeof(ide_task_t)); if (ide_id_has_flush_cache_ext(drive->id)) - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE_EXT; + args.tf.command = WIN_FLUSH_CACHE_EXT; else - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE; + args.tf.command = WIN_FLUSH_CACHE; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; return ide_raw_taskfile(drive, &args, NULL); @@ -790,10 +785,9 @@ static int set_acoustic (ide_drive_t *drive, int arg) return -EINVAL; memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? SETFEATURES_EN_AAM : - SETFEATURES_DIS_AAM; - args.tfRegister[IDE_NSECTOR_OFFSET] = arg; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; + args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; + args.tf.nsect = arg; + args.tf.command = WIN_SETFEATURES; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; ide_raw_taskfile(drive, &args, NULL); @@ -1057,7 +1051,7 @@ static int idedisk_open(struct inode *inode, struct file *filp) if (drive->removable && idkp->openers == 1) { ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK; + args.tf.command = WIN_DOORLOCK; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; check_disk_change(inode->i_bdev); @@ -1084,7 +1078,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) if (drive->removable && idkp->openers == 1) { ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORUNLOCK; + args.tf.command = WIN_DOORUNLOCK; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index bb1b0a8..dc984c5 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -189,15 +189,15 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * return ide_stopped; } if (ide_id_has_flush_cache_ext(drive->id)) - args->tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE_EXT; + args->tf.command = WIN_FLUSH_CACHE_EXT; else - args->tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE; + args->tf.command = WIN_FLUSH_CACHE; args->command_type = IDE_DRIVE_TASK_NO_DATA; args->handler = &task_no_data_intr; return do_rw_taskfile(drive, args); case idedisk_pm_standby: /* Suspend step 2 (standby) */ - args->tfRegister[IDE_COMMAND_OFFSET] = WIN_STANDBYNOW1; + args->tf.command = WIN_STANDBYNOW1; args->command_type = IDE_DRIVE_TASK_NO_DATA; args->handler = &task_no_data_intr; return do_rw_taskfile(drive, args); @@ -214,7 +214,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * return ide_stopped; case idedisk_pm_idle: /* Resume step 2 (idle) */ - args->tfRegister[IDE_COMMAND_OFFSET] = WIN_IDLEIMMEDIATE; + args->tf.command = WIN_IDLEIMMEDIATE; args->command_type = IDE_DRIVE_TASK_NO_DATA; args->handler = task_no_data_intr; return do_rw_taskfile(drive, args); @@ -354,28 +354,31 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT); if (args) { + struct ide_taskfile *tf = &args->tf; + if (args->tf_in_flags.b.data) { - u16 data = hwif->INW(IDE_DATA_REG); - args->tfRegister[IDE_DATA_OFFSET] = (data) & 0xFF; - args->hobRegister[IDE_DATA_OFFSET] = (data >> 8) & 0xFF; + u16 data = hwif->INW(IDE_DATA_REG); + + tf->data = data & 0xff; + tf->hob_data = (data >> 8) & 0xff; } - args->tfRegister[IDE_ERROR_OFFSET] = err; + tf->error = err; /* be sure we're looking at the low order bits */ hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); - args->tfRegister[IDE_NSECTOR_OFFSET] = hwif->INB(IDE_NSECTOR_REG); - args->tfRegister[IDE_SECTOR_OFFSET] = hwif->INB(IDE_SECTOR_REG); - args->tfRegister[IDE_LCYL_OFFSET] = hwif->INB(IDE_LCYL_REG); - args->tfRegister[IDE_HCYL_OFFSET] = hwif->INB(IDE_HCYL_REG); - args->tfRegister[IDE_SELECT_OFFSET] = hwif->INB(IDE_SELECT_REG); - args->tfRegister[IDE_STATUS_OFFSET] = stat; + tf->nsect = hwif->INB(IDE_NSECTOR_REG); + tf->lbal = hwif->INB(IDE_SECTOR_REG); + tf->lbam = hwif->INB(IDE_LCYL_REG); + tf->lbah = hwif->INB(IDE_HCYL_REG); + tf->device = hwif->INB(IDE_SELECT_REG); + tf->status = stat; if (drive->addressing == 1) { hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); - args->hobRegister[IDE_FEATURE_OFFSET] = hwif->INB(IDE_FEATURE_REG); - args->hobRegister[IDE_NSECTOR_OFFSET] = hwif->INB(IDE_NSECTOR_REG); - args->hobRegister[IDE_SECTOR_OFFSET] = hwif->INB(IDE_SECTOR_REG); - args->hobRegister[IDE_LCYL_OFFSET] = hwif->INB(IDE_LCYL_REG); - args->hobRegister[IDE_HCYL_OFFSET] = hwif->INB(IDE_HCYL_REG); + tf->hob_feature = hwif->INB(IDE_FEATURE_REG); + tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); + tf->hob_lbal = hwif->INB(IDE_SECTOR_REG); + tf->hob_lbam = hwif->INB(IDE_LCYL_REG); + tf->hob_lbah = hwif->INB(IDE_HCYL_REG); } } } else if (blk_pm_request(rq)) { @@ -675,28 +678,28 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive) static void ide_init_specify_cmd(ide_drive_t *drive, ide_task_t *task) { - task->tfRegister[IDE_NSECTOR_OFFSET] = drive->sect; - task->tfRegister[IDE_SECTOR_OFFSET] = drive->sect; - task->tfRegister[IDE_LCYL_OFFSET] = drive->cyl; - task->tfRegister[IDE_HCYL_OFFSET] = drive->cyl>>8; - task->tfRegister[IDE_SELECT_OFFSET] = ((drive->head-1)|drive->select.all)&0xBF; - task->tfRegister[IDE_COMMAND_OFFSET] = WIN_SPECIFY; + task->tf.nsect = drive->sect; + task->tf.lbal = drive->sect; + task->tf.lbam = drive->cyl; + task->tf.lbah = drive->cyl >> 8; + task->tf.device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; + task->tf.command = WIN_SPECIFY; task->handler = &set_geometry_intr; } static void ide_init_restore_cmd(ide_drive_t *drive, ide_task_t *task) { - task->tfRegister[IDE_NSECTOR_OFFSET] = drive->sect; - task->tfRegister[IDE_COMMAND_OFFSET] = WIN_RESTORE; + task->tf.nsect = drive->sect; + task->tf.command = WIN_RESTORE; task->handler = &recal_intr; } static void ide_init_setmult_cmd(ide_drive_t *drive, ide_task_t *task) { - task->tfRegister[IDE_NSECTOR_OFFSET] = drive->mult_req; - task->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETMULT; + task->tf.nsect = drive->mult_req; + task->tf.command = WIN_SETMULT; task->handler = &set_multmode_intr; } diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index f4e8a0c..4aac1cc 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -642,9 +642,9 @@ no_80w: int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) { - if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) && - (args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) && - (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) { + if (args->tf.command == WIN_SETFEATURES && + args->tf.lbal > XFER_UDMA_2 && + args->tf.feature == SETFEATURES_XFER) { if (eighty_ninty_three(drive) == 0) { printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot " "be set\n", drive->name); @@ -662,9 +662,9 @@ int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) */ int set_transfer (ide_drive_t *drive, ide_task_t *args) { - if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) && - (args->tfRegister[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) && - (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) && + if (args->tf.command == WIN_SETFEATURES && + args->tf.lbal >= XFER_SW_DMA_0 && + args->tf.feature == SETFEATURES_XFER && (drive->id->dma_ultra || drive->id->dma_mword || drive->id->dma_1word)) diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 062d3bc..6dbf2af 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -468,8 +468,7 @@ static void ide_dump_opcode(ide_drive_t *drive) } else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *args = rq->special; if (args) { - task_struct_t *tf = (task_struct_t *) args->tfRegister; - opcode = tf->command; + opcode = args->tf.command; found = 1; } } diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 91948a4..5a1a9f7 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -66,12 +66,13 @@ static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount) int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) { ide_task_t args; + memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; + args.tf.nsect = 0x01; if (drive->media == ide_disk) - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_IDENTIFY; + args.tf.command = WIN_IDENTIFY; else - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_PIDENTIFY; + args.tf.command = WIN_PIDENTIFY; args.command_type = IDE_DRIVE_TASK_IN; args.data_phase = TASKFILE_IN; args.handler = &task_in_intr; @@ -81,8 +82,7 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); - task_struct_t *taskfile = (task_struct_t *) task->tfRegister; - hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister; + struct ide_taskfile *tf = &task->tf; u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF; /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */ @@ -93,35 +93,35 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) SELECT_MASK(drive, 0); if (drive->addressing == 1) { - hwif->OUTB(hobfile->feature, IDE_FEATURE_REG); - hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG); - hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG); - hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG); - hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG); + hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); + hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); + hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); } - hwif->OUTB(taskfile->feature, IDE_FEATURE_REG); - hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG); - hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG); - hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG); - hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG); + hwif->OUTB(tf->feature, IDE_FEATURE_REG); + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->lbam, IDE_LCYL_REG); + hwif->OUTB(tf->lbah, IDE_HCYL_REG); - hwif->OUTB((taskfile->device_head & HIHI) | drive->select.all, IDE_SELECT_REG); + hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); if (task->handler != NULL) { if (task->prehandler != NULL) { - hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); ndelay(400); /* FIXME */ return task->prehandler(drive, task->rq); } - ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); + ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); return ide_started; } if (!drive->using_dma) return ide_stopped; - switch (taskfile->command) { + switch (tf->command) { case WIN_WRITEDMA_ONCE: case WIN_WRITEDMA: case WIN_WRITEDMA_EXT: @@ -130,7 +130,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) case WIN_READDMA_EXT: case WIN_IDENTIFY_DMA: if (!hwif->dma_setup(drive)) { - hwif->dma_exec_cmd(drive, taskfile->command); + hwif->dma_exec_cmd(drive, tf->command); hwif->dma_start(drive); return ide_started; } @@ -483,7 +483,7 @@ static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long */ if (args->command_type != IDE_DRIVE_TASK_NO_DATA) { if (data_size == 0) - rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET]; + rq.nr_sectors = (args->tf.hob_nsect << 8) | args->tf.nsect; else rq.nr_sectors = data_size / SECTOR_SIZE; @@ -519,8 +519,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ide_task_t args; u8 *outbuf = NULL; u8 *inbuf = NULL; - u8 *argsptr = args.tfRegister; - u8 *hobsptr = args.hobRegister; int err = 0; int tasksize = sizeof(struct ide_task_request_s); unsigned int taskin = 0; @@ -572,9 +570,9 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) } memset(&args, 0, sizeof(ide_task_t)); - memcpy(argsptr, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); - memcpy(hobsptr, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE); + memcpy(&args.tf_array[0], req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2); + memcpy(&args.tf_array[6], req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); args.tf_in_flags = req_task->in_flags; args.tf_out_flags = req_task->out_flags; args.data_phase = req_task->data_phase; @@ -628,8 +626,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) goto abort; } - memcpy(req_task->io_ports, &(args.tfRegister), HDIO_DRIVE_TASK_HDR_SIZE); - memcpy(req_task->hob_ports, &(args.hobRegister), HDIO_DRIVE_HOB_HDR_SIZE); + memcpy(req_task->hob_ports, &args.tf_array[0], HDIO_DRIVE_HOB_HDR_SIZE - 2); + memcpy(req_task->io_ports, &args.tf_array[6], HDIO_DRIVE_TASK_HDR_SIZE); req_task->in_flags = args.tf_in_flags; req_task->out_flags = args.tf_out_flags; @@ -688,6 +686,7 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) u8 xfer_rate = 0; int argsize = 4; ide_task_t tfargs; + struct ide_taskfile *tf = &tfargs.tf; if (NULL == (void *) arg) { struct request rq; @@ -699,13 +698,10 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) return -EFAULT; memset(&tfargs, 0, sizeof(ide_task_t)); - tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2]; - tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3]; - tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1]; - tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00; - tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00; - tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00; - tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0]; + tf->feature = args[2]; + tf->nsect = args[3]; + tf->lbal = args[1]; + tf->command = args[0]; if (args[3]) { argsize = 4 + (SECTOR_WORDS * 4 * args[3]); @@ -767,8 +763,7 @@ int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); - task_struct_t *taskfile = (task_struct_t *) task->tfRegister; - hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister; + struct ide_taskfile *tf = &task->tf; if (task->data_phase == TASKFILE_MULTI_IN || task->data_phase == TASKFILE_MULTI_OUT) { @@ -798,34 +793,32 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) hwif->OUTB(drive->ctl, IDE_CONTROL_REG); SELECT_MASK(drive, 0); - if (task->tf_out_flags.b.data) { - u16 data = taskfile->data + (hobfile->data << 8); - hwif->OUTW(data, IDE_DATA_REG); - } + if (task->tf_out_flags.b.data) + hwif->OUTW((tf->hob_data << 8) | tf->data, IDE_DATA_REG); /* (ks) send hob registers first */ if (task->tf_out_flags.b.nsector_hob) - hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG); + hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); if (task->tf_out_flags.b.sector_hob) - hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG); + hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); if (task->tf_out_flags.b.lcyl_hob) - hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG); + hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); if (task->tf_out_flags.b.hcyl_hob) - hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG); + hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); /* (ks) Send now the standard registers */ if (task->tf_out_flags.b.error_feature) - hwif->OUTB(taskfile->feature, IDE_FEATURE_REG); + hwif->OUTB(tf->feature, IDE_FEATURE_REG); /* refers to number of sectors to transfer */ if (task->tf_out_flags.b.nsector) - hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG); + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); /* refers to sector offset or start sector */ if (task->tf_out_flags.b.sector) - hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG); + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); if (task->tf_out_flags.b.lcyl) - hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG); + hwif->OUTB(tf->lbam, IDE_LCYL_REG); if (task->tf_out_flags.b.hcyl) - hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG); + hwif->OUTB(tf->lbah, IDE_HCYL_REG); /* * (ks) In the flagged taskfile approch, we will use all specified @@ -833,7 +826,7 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) * select bit (master/slave) in the drive_head register. We must make * sure that the desired drive is selected. */ - hwif->OUTB(taskfile->device_head | drive->select.all, IDE_SELECT_REG); + hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG); switch(task->data_phase) { case TASKFILE_OUT_DMAQ: @@ -844,7 +837,7 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) break; if (!hwif->dma_setup(drive)) { - hwif->dma_exec_cmd(drive, taskfile->command); + hwif->dma_exec_cmd(drive, tf->command); hwif->dma_start(drive); return ide_started; } @@ -856,11 +849,11 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) /* Issue the command */ if (task->prehandler) { - hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); ndelay(400); /* FIXME */ return task->prehandler(drive, task->rq); } - ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); + ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); return ide_started; } diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index 3bcb885..df17bf7 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -117,7 +117,7 @@ typedef union ide_reg_valid_s { typedef struct ide_task_request_s { __u8 io_ports[8]; - __u8 hob_ports[8]; + __u8 hob_ports[8]; /* bytes 6 and 7 are unused */ ide_reg_valid_t out_flags; ide_reg_valid_t in_flags; int data_phase; @@ -139,6 +139,7 @@ struct hd_drive_cmd_hdr { __u8 sector_count; }; +#ifndef __KERNEL__ typedef struct hd_drive_task_hdr { __u8 data; __u8 feature; @@ -160,6 +161,7 @@ typedef struct hd_drive_hob_hdr { __u8 device_head; __u8 control; } hob_struct_t; +#endif #define TASKFILE_INVALID 0x7fff #define TASKFILE_48 0x8000 diff --git a/include/linux/ide.h b/include/linux/ide.h index 66a38f1..69b78bb 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -103,8 +103,6 @@ typedef unsigned char byte; /* used everywhere */ #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET -#define IDE_CONTROL_OFFSET_HOB (7) - #define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) #define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) #define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) @@ -1062,15 +1060,40 @@ extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); */ extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *); +struct ide_taskfile { + u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ + + u8 hob_feature; /* 1-5: additional data to support LBA48 */ + u8 hob_nsect; + u8 hob_lbal; + u8 hob_lbam; + u8 hob_lbah; + + u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ + + union { /*  7: */ + u8 error; /* read: error */ + u8 feature; /* write: feature */ + }; + + u8 nsect; /* 8: number of sectors */ + u8 lbal; /* 9: LBA low */ + u8 lbam; /* 10: LBA mid */ + u8 lbah; /* 11: LBA high */ + + u8 device; /* 12: device select */ + + union { /* 13: */ + u8 status; /*  read: status  */ + u8 command; /* write: command */ + }; +}; + typedef struct ide_task_s { -/* - * struct hd_drive_task_hdr tf; - * task_struct_t tf; - * struct hd_drive_hob_hdr hobf; - * hob_struct_t hobf; - */ - u8 tfRegister[8]; - u8 hobRegister[8]; + union { + struct ide_taskfile tf; + u8 tf_array[14]; + }; ide_reg_valid_t tf_out_flags; ide_reg_valid_t tf_in_flags; int data_phase; -- cgit v0.10.2 From 7a3b7512d0d7e78353e99f4538eb6d3354019d92 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:06 +0100 Subject: ide-disk: merge LBA28 and LBA48 Host Protected Area support code (take 2) * Merge idedisk_{read_native,set}_max_address_ext() into idedisk_{read_native,set}_max_address(). v2: * Remove LBA48 code leftover from idedisk_read_native_max_address() ('high' variable initialization). (Noticed by Sergei). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index a4c4d43..88c270f 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -307,16 +307,19 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s * Queries for true maximum capacity of the drive. * Returns maximum LBA address (> 0) of the drive, 0 if failed. */ -static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) +static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) { ide_task_t args; struct ide_taskfile *tf = &args.tf; - unsigned long addr = 0; + u64 addr = 0; /* Create IDE/ATA command request structure */ memset(&args, 0, sizeof(ide_task_t)); + if (lba48) + tf->command = WIN_READ_NATIVE_MAX_EXT; + else + tf->command = WIN_READ_NATIVE_MAX; tf->device = ATA_LBA; - tf->command = WIN_READ_NATIVE_MAX; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ @@ -324,33 +327,13 @@ static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) /* if OK, compute maximum address value */ if ((tf->status & 0x01) == 0) { - addr = ((tf->device & 0xf) << 24) | - (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; - addr++; /* since the return value is (maxlba - 1), we add 1 */ - } - return addr; -} - -static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive) -{ - ide_task_t args; - struct ide_taskfile *tf = &args.tf; - unsigned long long addr = 0; - - /* Create IDE/ATA command request structure */ - memset(&args, 0, sizeof(ide_task_t)); - tf->device = ATA_LBA; - tf->command = WIN_READ_NATIVE_MAX_EXT; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - /* submit command request */ - ide_raw_taskfile(drive, &args, NULL); - - /* if OK, compute maximum address value */ - if ((tf->status & 0x01) == 0) { u32 high, low; - high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal; + if (lba48) + high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | + tf->hob_lbal; + else + high = tf->device & 0xf; low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr = ((__u64)high << 24) | low; addr++; /* since the return value is (maxlba - 1), we add 1 */ @@ -362,38 +345,11 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive * Sets maximum virtual LBA address of the drive. * Returns new maximum virtual LBA address (> 0) or 0 on failure. */ -static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long addr_req) +static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) { ide_task_t args; struct ide_taskfile *tf = &args.tf; - unsigned long addr_set = 0; - - addr_req--; - /* Create IDE/ATA command request structure */ - memset(&args, 0, sizeof(ide_task_t)); - tf->lbal = (addr_req >> 0) & 0xff; - tf->lbam = (addr_req >> 8) & 0xff; - tf->lbah = (addr_req >> 16) & 0xff; - tf->device = ((addr_req >> 24) & 0x0f) | ATA_LBA; - tf->command = WIN_SET_MAX; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - /* submit command request */ - ide_raw_taskfile(drive, &args, NULL); - /* if OK, read new maximum address value */ - if ((tf->status & 0x01) == 0) { - addr_set = ((tf->device & 0xf) << 24) | - (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; - addr_set++; - } - return addr_set; -} - -static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsigned long long addr_req) -{ - ide_task_t args; - struct ide_taskfile *tf = &args.tf; - unsigned long long addr_set = 0; + u64 addr_set = 0; addr_req--; /* Create IDE/ATA command request structure */ @@ -401,11 +357,16 @@ static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsign tf->lbal = (addr_req >> 0) & 0xff; tf->lbam = (addr_req >>= 8) & 0xff; tf->lbah = (addr_req >>= 8) & 0xff; - tf->device = ATA_LBA; - tf->command = WIN_SET_MAX_EXT; - tf->hob_lbal = (addr_req >>= 8) & 0xff; - tf->hob_lbam = (addr_req >>= 8) & 0xff; - tf->hob_lbah = (addr_req >>= 8) & 0xff; + if (lba48) { + tf->hob_lbal = (addr_req >>= 8) & 0xff; + tf->hob_lbam = (addr_req >>= 8) & 0xff; + tf->hob_lbah = (addr_req >>= 8) & 0xff; + tf->command = WIN_SET_MAX_EXT; + } else { + tf->device = (addr_req >>= 8) & 0x0f; + tf->command = WIN_SET_MAX; + } + tf->device |= ATA_LBA; args.command_type = IDE_DRIVE_TASK_NO_DATA; args.handler = &task_no_data_intr; /* submit command request */ @@ -414,7 +375,11 @@ static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsign if ((tf->status & 0x01) == 0) { u32 high, low; - high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal; + if (lba48) + high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | + tf->hob_lbal; + else + high = tf->device & 0xf; low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; addr_set = ((__u64)high << 24) | low; addr_set++; @@ -464,10 +429,8 @@ static void idedisk_check_hpa(ide_drive_t *drive) int lba48 = idedisk_supports_lba48(drive->id); capacity = drive->capacity64; - if (lba48) - set_max = idedisk_read_native_max_address_ext(drive); - else - set_max = idedisk_read_native_max_address(drive); + + set_max = idedisk_read_native_max_address(drive, lba48); if (ide_in_drive_list(drive->id, hpa_list)) { /* @@ -488,10 +451,8 @@ static void idedisk_check_hpa(ide_drive_t *drive) capacity, sectors_to_MB(capacity), set_max, sectors_to_MB(set_max)); - if (lba48) - set_max = idedisk_set_max_address_ext(drive, set_max); - else - set_max = idedisk_set_max_address(drive, set_max); + set_max = idedisk_set_max_address(drive, set_max, lba48); + if (set_max) { drive->capacity64 = set_max; printk(KERN_INFO "%s: Host Protected Area disabled.\n", -- cgit v0.10.2 From d00e42dd26bbda6a39aead6a47c59221e03a08f8 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:06 +0100 Subject: ide-disk: fix taskfile registers loading order in __ide_do_rw_disk() Load IDE_SECTOR_REG after IDE_FEATURE_REG and IDE_NSECTOR_REG when using CHS. This patch is basically a preparation for the next one which converts __ide_do_rw_disk() to use struct ide_taskfile. It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 88c270f..9b63e15 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -212,7 +212,6 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, unsigned int sect,head,cyl,track; track = (int)block / drive->sect; sect = (int)block % drive->sect + 1; - hwif->OUTB(sect, IDE_SECTOR_REG); head = track % drive->head; cyl = track / drive->head; @@ -220,6 +219,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, hwif->OUTB(0x00, IDE_FEATURE_REG); hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG); + hwif->OUTB(sect, IDE_SECTOR_REG); hwif->OUTB(cyl, IDE_LCYL_REG); hwif->OUTB(cyl>>8, IDE_HCYL_REG); hwif->OUTB(head|drive->select.all,IDE_SELECT_REG); -- cgit v0.10.2 From 2bd06b23e2a099abbf550202f62cd433e01f83e7 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:06 +0100 Subject: ide-disk: use struct ide_taskfile in __ide_do_rw_disk() Based on the earlier work by Tejun Heo. There should be no functionality changes caused by this patch. Cc: Tejun Heo Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 9b63e15..20d357e 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -140,6 +140,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, u8 lba48 = (drive->addressing == 1) ? 1 : 0; u8 command = WIN_NOP; ata_nsector_t nsectors; + struct ide_taskfile ltf, *tf = <f; nsectors.all = (u16) rq->nr_sectors; @@ -160,53 +161,36 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, /* FIXME: SELECT_MASK(drive, 0) ? */ + memset(tf, 0, sizeof(*tf)); + if (drive->select.b.lba) { if (lba48) { - u8 tasklets[10]; - pr_debug("%s: LBA=0x%012llx\n", drive->name, (unsigned long long)block); - tasklets[0] = 0; - tasklets[1] = 0; - tasklets[2] = nsectors.b.low; - tasklets[3] = nsectors.b.high; - tasklets[4] = (u8) block; - tasklets[5] = (u8)(block >> 8); - tasklets[6] = (u8)(block >> 16); - tasklets[7] = (u8)(block >> 24); - if (sizeof(block) == 4) { - tasklets[8] = 0; - tasklets[9] = 0; - } else { - tasklets[8] = (u8)((u64)block >> 32); - tasklets[9] = (u8)((u64)block >> 40); + tf->hob_nsect = nsectors.b.high; + tf->hob_lbal = (u8)(block >> 24); + if (sizeof(block) != 4) { + tf->hob_lbam = (u8)((u64)block >> 32); + tf->hob_lbah = (u8)((u64)block >> 40); } + + tf->nsect = nsectors.b.low; + tf->lbal = (u8) block; + tf->lbam = (u8)(block >> 8); + tf->lbah = (u8)(block >> 16); #ifdef DEBUG printk("%s: 0x%02x%02x 0x%02x%02x%02x%02x%02x%02x\n", - drive->name, tasklets[3], tasklets[2], - tasklets[9], tasklets[8], tasklets[7], - tasklets[6], tasklets[5], tasklets[4]); + drive->name, tf->hob_nsect, tf->nsect, + tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, + tf->lbah, tf->lbam, tf->lbal); #endif - hwif->OUTB(tasklets[1], IDE_FEATURE_REG); - hwif->OUTB(tasklets[3], IDE_NSECTOR_REG); - hwif->OUTB(tasklets[7], IDE_SECTOR_REG); - hwif->OUTB(tasklets[8], IDE_LCYL_REG); - hwif->OUTB(tasklets[9], IDE_HCYL_REG); - - hwif->OUTB(tasklets[0], IDE_FEATURE_REG); - hwif->OUTB(tasklets[2], IDE_NSECTOR_REG); - hwif->OUTB(tasklets[4], IDE_SECTOR_REG); - hwif->OUTB(tasklets[5], IDE_LCYL_REG); - hwif->OUTB(tasklets[6], IDE_HCYL_REG); - hwif->OUTB(0x00|drive->select.all,IDE_SELECT_REG); } else { - hwif->OUTB(0x00, IDE_FEATURE_REG); - hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG); - hwif->OUTB(block, IDE_SECTOR_REG); - hwif->OUTB(block>>=8, IDE_LCYL_REG); - hwif->OUTB(block>>=8, IDE_HCYL_REG); - hwif->OUTB(((block>>8)&0x0f)|drive->select.all,IDE_SELECT_REG); + tf->nsect = nsectors.b.low; + tf->lbal = block; + tf->lbam = block >>= 8; + tf->lbah = block >>= 8; + tf->device = (block >> 8) & 0xf; } } else { unsigned int sect,head,cyl,track; @@ -217,14 +201,29 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect); - hwif->OUTB(0x00, IDE_FEATURE_REG); - hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG); - hwif->OUTB(sect, IDE_SECTOR_REG); - hwif->OUTB(cyl, IDE_LCYL_REG); - hwif->OUTB(cyl>>8, IDE_HCYL_REG); - hwif->OUTB(head|drive->select.all,IDE_SELECT_REG); + tf->nsect = nsectors.b.low; + tf->lbal = sect; + tf->lbam = cyl; + tf->lbah = cyl >> 8; + tf->device = head; } + if (drive->select.b.lba && lba48) { + hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); + hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); + hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); + } + + hwif->OUTB(tf->feature, IDE_FEATURE_REG); + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->lbam, IDE_LCYL_REG); + hwif->OUTB(tf->lbah, IDE_HCYL_REG); + + hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG); + if (dma) { if (!hwif->dma_setup(drive)) { if (rq_data_dir(rq)) { -- cgit v0.10.2 From 9e42237f26cf517a3f682505f03a3a8d89b3b35d Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:07 +0100 Subject: ide: add ide_tf_load() helper Based on the earlier work by Tejun Heo. * Add 'tf_flags' field (for taskfile flags) to ide_task_t. * Add IDE_TFLAG_LBA48 taskfile flag for LBA48 taskfiles. * Add IDE_TFLAG_NO_SELECT_MASK taskfile flag for __ide_do_rw_disk() which doesn't use SELECT_MASK() (looks like a bug but it requires some more investigation). * Split off ide_tf_load() helper from do_rw_taskfile(). * Convert __ide_do_rw_disk() to use ide_tf_load(). There should be no functionality changes caused by this patch. Cc: Tejun Heo Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 20d357e..6387222 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -140,7 +140,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, u8 lba48 = (drive->addressing == 1) ? 1 : 0; u8 command = WIN_NOP; ata_nsector_t nsectors; - struct ide_taskfile ltf, *tf = <f; + ide_task_t task; + struct ide_taskfile *tf = &task.tf; nsectors.all = (u16) rq->nr_sectors; @@ -156,12 +157,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ide_map_sg(drive, rq); } - if (IDE_CONTROL_REG) - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - - /* FIXME: SELECT_MASK(drive, 0) ? */ - - memset(tf, 0, sizeof(*tf)); + memset(&task, 0, sizeof(task)); + task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ if (drive->select.b.lba) { if (lba48) { @@ -185,6 +182,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, tf->lbah, tf->lbam, tf->lbal); #endif + task.tf_flags |= IDE_TFLAG_LBA48; } else { tf->nsect = nsectors.b.low; tf->lbal = block; @@ -208,21 +206,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->device = head; } - if (drive->select.b.lba && lba48) { - hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); - hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); - hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - } - - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - hwif->OUTB(tf->lbah, IDE_HCYL_REG); - - hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG); + ide_tf_load(drive, &task); if (dma) { if (!hwif->dma_setup(drive)) { diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 5a1a9f7..a79150e 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -63,6 +63,37 @@ static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount) } } +void ide_tf_load(ide_drive_t *drive, ide_task_t *task) +{ + ide_hwif_t *hwif = drive->hwif; + struct ide_taskfile *tf = &task->tf; + u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; + + if (IDE_CONTROL_REG) + hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ + + if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0) + SELECT_MASK(drive, 0); + + if (task->tf_flags & IDE_TFLAG_LBA48) { + hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); + hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); + hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); + } + + hwif->OUTB(tf->feature, IDE_FEATURE_REG); + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->lbam, IDE_LCYL_REG); + hwif->OUTB(tf->lbah, IDE_HCYL_REG); + + hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); +} + +EXPORT_SYMBOL_GPL(ide_tf_load); + int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) { ide_task_t args; @@ -83,30 +114,11 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); struct ide_taskfile *tf = &task->tf; - u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF; - /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */ - if (IDE_CONTROL_REG) { - /* clear nIEN */ - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - } - SELECT_MASK(drive, 0); + if (drive->addressing == 1) + task->tf_flags |= IDE_TFLAG_LBA48; - if (drive->addressing == 1) { - hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); - hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); - hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - } - - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - hwif->OUTB(tf->lbah, IDE_HCYL_REG); - - hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); + ide_tf_load(drive, task); if (task->handler != NULL) { if (task->prehandler != NULL) { diff --git a/include/linux/ide.h b/include/linux/ide.h index 69b78bb..e25fd0b 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1060,6 +1060,11 @@ extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); */ extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *); +enum { + IDE_TFLAG_LBA48 = (1 << 0), + IDE_TFLAG_NO_SELECT_MASK = (1 << 1), +}; + struct ide_taskfile { u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ @@ -1094,6 +1099,7 @@ typedef struct ide_task_s { struct ide_taskfile tf; u8 tf_array[14]; }; + u8 tf_flags; ide_reg_valid_t tf_out_flags; ide_reg_valid_t tf_in_flags; int data_phase; @@ -1104,6 +1110,8 @@ typedef struct ide_task_s { void *special; /* valid_t generally */ } ide_task_t; +void ide_tf_load(ide_drive_t *, ide_task_t *); + extern u32 ide_read_24(ide_drive_t *); extern void SELECT_DRIVE(ide_drive_t *); -- cgit v0.10.2 From 9a3c49be5c5f7388eefb712be9a383904140532e Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:07 +0100 Subject: ide: add ide_no_data_taskfile() helper * Add ide_no_data_taskfile() helper and convert ide_raw_taskfile() w/ NO DATA protocol users to use it instead. * Set ->data_phase explicitly in ide_no_data_taskfile() (TASKFILE_NO_DATA is defined as 0x0000). * Unexport task_no_data_intr(). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 747c518..f0a6a3d 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c @@ -383,9 +383,6 @@ static int taskfile_load_raw(ide_drive_t *drive, gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]); memset(&args, 0, sizeof(ide_task_t)); - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.data_phase = TASKFILE_NO_DATA; - args.handler = &task_no_data_intr; /* convert gtf to IDE Taskfile */ memcpy(&args.tf_array[7], >f->tfa, 7); @@ -395,9 +392,9 @@ static int taskfile_load_raw(ide_drive_t *drive, return err; } - err = ide_raw_taskfile(drive, &args, NULL); + err = ide_no_data_taskfile(drive, &args); if (err) - printk(KERN_ERR "%s: ide_raw_taskfile failed: %u\n", + printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", __FUNCTION__, err); return err; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 6387222..b534fe9 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -303,10 +303,8 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) else tf->command = WIN_READ_NATIVE_MAX; tf->device = ATA_LBA; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; /* submit command request */ - ide_raw_taskfile(drive, &args, NULL); + ide_no_data_taskfile(drive, &args); /* if OK, compute maximum address value */ if ((tf->status & 0x01) == 0) { @@ -350,10 +348,8 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) tf->command = WIN_SET_MAX; } tf->device |= ATA_LBA; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; /* submit command request */ - ide_raw_taskfile(drive, &args, NULL); + ide_no_data_taskfile(drive, &args); /* if OK, compute maximum address value */ if ((tf->status & 0x01) == 0) { u32 high, low; @@ -500,9 +496,7 @@ static int smart_enable(ide_drive_t *drive) tf->lbam = SMART_LCYL_PASS; tf->lbah = SMART_HCYL_PASS; tf->command = WIN_SMART; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - return ide_raw_taskfile(drive, &args, NULL); + return ide_no_data_taskfile(drive, &args); } static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) @@ -695,9 +689,7 @@ static int write_cache(ide_drive_t *drive, int arg) args.tf.feature = arg ? SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; args.tf.command = WIN_SETFEATURES; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - err = ide_raw_taskfile(drive, &args, NULL); + err = ide_no_data_taskfile(drive, &args); if (err == 0) drive->wcache = arg; } @@ -716,9 +708,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive) args.tf.command = WIN_FLUSH_CACHE_EXT; else args.tf.command = WIN_FLUSH_CACHE; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - return ide_raw_taskfile(drive, &args, NULL); + return ide_no_data_taskfile(drive, &args); } static int set_acoustic (ide_drive_t *drive, int arg) @@ -732,9 +722,7 @@ static int set_acoustic (ide_drive_t *drive, int arg) args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; args.tf.nsect = arg; args.tf.command = WIN_SETFEATURES; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - ide_raw_taskfile(drive, &args, NULL); + ide_no_data_taskfile(drive, &args); drive->acoustic = arg; return 0; } @@ -996,15 +984,13 @@ static int idedisk_open(struct inode *inode, struct file *filp) ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); args.tf.command = WIN_DOORLOCK; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; check_disk_change(inode->i_bdev); /* * Ignore the return code from door_lock, * since the open() has already succeeded, * and the door_lock is irrelevant at this point. */ - if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) + if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) drive->doorlocking = 0; } return 0; @@ -1023,9 +1009,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); args.tf.command = WIN_DOORUNLOCK; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; - if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) + if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) drive->doorlocking = 0; } diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index a79150e..7cb674f 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -229,8 +229,6 @@ ide_startstop_t task_no_data_intr (ide_drive_t *drive) return ide_stopped; } -EXPORT_SYMBOL(task_no_data_intr); - static u8 wait_drive_not_busy(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); @@ -524,6 +522,16 @@ int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf) EXPORT_SYMBOL(ide_raw_taskfile); +int ide_no_data_taskfile(ide_drive_t *drive, ide_task_t *task) +{ + task->command_type = IDE_DRIVE_TASK_NO_DATA; + task->data_phase = TASKFILE_NO_DATA; + task->handler = task_no_data_intr; + + return ide_raw_taskfile(drive, task, NULL); +} +EXPORT_SYMBOL_GPL(ide_no_data_taskfile); + #ifdef CONFIG_IDE_TASK_IOCTL int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) { diff --git a/include/linux/ide.h b/include/linux/ide.h index e25fd0b..11bfbc4 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1140,6 +1140,8 @@ extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *); +int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); + int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); -- cgit v0.10.2 From 74095a91ed02f6727b62d4416be00a041f2d7436 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:07 +0100 Subject: ide: use do_rw_taskfile() in flagged_taskfile() Based on the earlier work by Tejun Heo. * Move setting IDE_TFLAG_LBA48 taskfile flag from do_rw_taskfile() function to the callers. * Add IDE_TFLAG_FLAGGED taskfile flag for flagged taskfiles coming from ide_taskfile_ioctl(). Check it instead of ->tf_out_flags.all. * Add IDE_TFLAG_OUT_DATA taskfile flag to indicate the need to load IDE data register in ide_tf_load(). * Add IDE_TFLAG_OUT_* taskfile flags to indicate the need to load particular IDE taskfile registers in ide_tf_load(). * Update do_rw_taskfile() and ide_tf_load() users to set respective IDE_TFLAG_OUT_* taksfile flags. * Add task_dma_ok() helper. * Use IDE_TFLAG_FLAGGED taskfile flag to select HIHI mask in ide_tf_load(). * Use do_rw_taskfile() in flagged_taskfile(). * Remove no longer needed 'tf_out_flags' field from ide_task_t. There should be no functionality changes caused by this patch. Cc: Tejun Heo Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index b534fe9..6182c23 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -159,6 +159,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, memset(&task, 0, sizeof(task)); task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ + task.tf_flags |= IDE_TFLAG_OUT_TF; if (drive->select.b.lba) { if (lba48) { @@ -182,7 +183,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, tf->lbah, tf->lbam, tf->lbal); #endif - task.tf_flags |= IDE_TFLAG_LBA48; + task.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); } else { tf->nsect = nsectors.b.low; tf->lbal = block; diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index dc984c5..33458fe 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -192,15 +192,11 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * args->tf.command = WIN_FLUSH_CACHE_EXT; else args->tf.command = WIN_FLUSH_CACHE; - args->command_type = IDE_DRIVE_TASK_NO_DATA; - args->handler = &task_no_data_intr; - return do_rw_taskfile(drive, args); + goto out_do_tf; case idedisk_pm_standby: /* Suspend step 2 (standby) */ args->tf.command = WIN_STANDBYNOW1; - args->command_type = IDE_DRIVE_TASK_NO_DATA; - args->handler = &task_no_data_intr; - return do_rw_taskfile(drive, args); + goto out_do_tf; case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */ ide_set_max_pio(drive); @@ -215,9 +211,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * case idedisk_pm_idle: /* Resume step 2 (idle) */ args->tf.command = WIN_IDLEIMMEDIATE; - args->command_type = IDE_DRIVE_TASK_NO_DATA; - args->handler = task_no_data_intr; - return do_rw_taskfile(drive, args); + goto out_do_tf; case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */ /* @@ -236,6 +230,14 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * } pm->pm_step = ide_pm_state_completed; return ide_stopped; + +out_do_tf: + args->tf_flags = IDE_TFLAG_OUT_TF; + if (drive->addressing == 1) + args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); + args->command_type = IDE_DRIVE_TASK_NO_DATA; + args->handler = task_no_data_intr; + return do_rw_taskfile(drive, args); } /** @@ -730,6 +732,10 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) return ide_stopped; } + args.tf_flags = IDE_TFLAG_OUT_TF; + if (drive->addressing == 1) + args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); + do_rw_taskfile(drive, &args); return ide_started; @@ -883,8 +889,13 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, break; } - if (args->tf_out_flags.all != 0) + if (args->tf_flags & IDE_TFLAG_FLAGGED) return flagged_taskfile(drive, args); + + args->tf_flags |= IDE_TFLAG_OUT_TF; + if (drive->addressing == 1) + args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); + return do_rw_taskfile(drive, args); } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { u8 *args = rq->buffer; diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 7cb674f..a7668b4 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -69,25 +69,39 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) struct ide_taskfile *tf = &task->tf; u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; + if (task->tf_flags & IDE_TFLAG_FLAGGED) + HIHI = 0xFF; + if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0) SELECT_MASK(drive, 0); - if (task->tf_flags & IDE_TFLAG_LBA48) { + if (task->tf_flags & IDE_TFLAG_OUT_DATA) + hwif->OUTW((tf->hob_data << 8) | tf->data, IDE_DATA_REG); + + if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); + if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); + if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); + if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); + if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - } - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - hwif->OUTB(tf->lbah, IDE_HCYL_REG); + if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) + hwif->OUTB(tf->feature, IDE_FEATURE_REG); + if (task->tf_flags & IDE_TFLAG_OUT_NSECT) + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); + if (task->tf_flags & IDE_TFLAG_OUT_LBAL) + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); + if (task->tf_flags & IDE_TFLAG_OUT_LBAM) + hwif->OUTB(tf->lbam, IDE_LCYL_REG); + if (task->tf_flags & IDE_TFLAG_OUT_LBAH) + hwif->OUTB(tf->lbah, IDE_HCYL_REG); hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); } @@ -110,14 +124,30 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) return ide_raw_taskfile(drive, &args, buf); } +static int inline task_dma_ok(ide_task_t *task) +{ + if (task->tf_flags & IDE_TFLAG_FLAGGED) + return 1; + + switch (task->tf.command) { + case WIN_WRITEDMA_ONCE: + case WIN_WRITEDMA: + case WIN_WRITEDMA_EXT: + case WIN_READDMA_ONCE: + case WIN_READDMA: + case WIN_READDMA_EXT: + case WIN_IDENTIFY_DMA: + return 1; + } + + return 0; +} + ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); struct ide_taskfile *tf = &task->tf; - if (drive->addressing == 1) - task->tf_flags |= IDE_TFLAG_LBA48; - ide_tf_load(drive, task); if (task->handler != NULL) { @@ -130,26 +160,10 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) return ide_started; } - if (!drive->using_dma) - return ide_stopped; - - switch (tf->command) { - case WIN_WRITEDMA_ONCE: - case WIN_WRITEDMA: - case WIN_WRITEDMA_EXT: - case WIN_READDMA_ONCE: - case WIN_READDMA: - case WIN_READDMA_EXT: - case WIN_IDENTIFY_DMA: - if (!hwif->dma_setup(drive)) { - hwif->dma_exec_cmd(drive, tf->command); - hwif->dma_start(drive); - return ide_started; - } - break; - default: - if (task->handler == NULL) - return ide_stopped; + if (task_dma_ok(task) && drive->using_dma && !hwif->dma_setup(drive)) { + hwif->dma_exec_cmd(drive, tf->command); + hwif->dma_start(drive); + return ide_started; } return ide_stopped; @@ -373,7 +387,7 @@ static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *task = rq->special; - if (task->tf_out_flags.all) { + if (task->tf_flags & IDE_TFLAG_FLAGGED) { u8 err = drive->hwif->INB(IDE_ERROR_REG); ide_end_drive_cmd(drive, stat, err); return; @@ -594,10 +608,36 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) memcpy(&args.tf_array[0], req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(&args.tf_array[6], req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); args.tf_in_flags = req_task->in_flags; - args.tf_out_flags = req_task->out_flags; args.data_phase = req_task->data_phase; args.command_type = req_task->req_cmd; + if (req_task->out_flags.all) { + args.tf_flags |= IDE_TFLAG_FLAGGED; + + if (req_task->out_flags.b.data) + args.tf_flags |= IDE_TFLAG_OUT_DATA; + + if (req_task->out_flags.b.nsector_hob) + args.tf_flags |= IDE_TFLAG_OUT_HOB_NSECT; + if (req_task->out_flags.b.sector_hob) + args.tf_flags |= IDE_TFLAG_OUT_HOB_LBAL; + if (req_task->out_flags.b.lcyl_hob) + args.tf_flags |= IDE_TFLAG_OUT_HOB_LBAM; + if (req_task->out_flags.b.hcyl_hob) + args.tf_flags |= IDE_TFLAG_OUT_HOB_LBAH; + + if (req_task->out_flags.b.error_feature) + args.tf_flags |= IDE_TFLAG_OUT_FEATURE; + if (req_task->out_flags.b.nsector) + args.tf_flags |= IDE_TFLAG_OUT_NSECT; + if (req_task->out_flags.b.sector) + args.tf_flags |= IDE_TFLAG_OUT_LBAL; + if (req_task->out_flags.b.lcyl) + args.tf_flags |= IDE_TFLAG_OUT_LBAM; + if (req_task->out_flags.b.hcyl) + args.tf_flags |= IDE_TFLAG_OUT_LBAH; + } + drive->io_32bit = 0; switch(req_task->data_phase) { case TASKFILE_OUT_DMAQ: @@ -649,7 +689,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) memcpy(req_task->hob_ports, &args.tf_array[0], HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(req_task->io_ports, &args.tf_array[6], HDIO_DRIVE_TASK_HDR_SIZE); req_task->in_flags = args.tf_in_flags; - req_task->out_flags = args.tf_out_flags; if (copy_to_user(buf, req_task, tasksize)) { err = -EFAULT; @@ -782,9 +821,6 @@ int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) */ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) { - ide_hwif_t *hwif = HWIF(drive); - struct ide_taskfile *tf = &task->tf; - if (task->data_phase == TASKFILE_MULTI_IN || task->data_phase == TASKFILE_MULTI_OUT) { if (!drive->mult_count) { @@ -807,75 +843,5 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) task->tf_in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8); } - /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */ - if (IDE_CONTROL_REG) - /* clear nIEN */ - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - SELECT_MASK(drive, 0); - - if (task->tf_out_flags.b.data) - hwif->OUTW((tf->hob_data << 8) | tf->data, IDE_DATA_REG); - - /* (ks) send hob registers first */ - if (task->tf_out_flags.b.nsector_hob) - hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); - if (task->tf_out_flags.b.sector_hob) - hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); - if (task->tf_out_flags.b.lcyl_hob) - hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); - if (task->tf_out_flags.b.hcyl_hob) - hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - - /* (ks) Send now the standard registers */ - if (task->tf_out_flags.b.error_feature) - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - /* refers to number of sectors to transfer */ - if (task->tf_out_flags.b.nsector) - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - /* refers to sector offset or start sector */ - if (task->tf_out_flags.b.sector) - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - if (task->tf_out_flags.b.lcyl) - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - if (task->tf_out_flags.b.hcyl) - hwif->OUTB(tf->lbah, IDE_HCYL_REG); - - /* - * (ks) In the flagged taskfile approch, we will use all specified - * registers and the register value will not be changed, except the - * select bit (master/slave) in the drive_head register. We must make - * sure that the desired drive is selected. - */ - hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG); - switch(task->data_phase) { - - case TASKFILE_OUT_DMAQ: - case TASKFILE_OUT_DMA: - case TASKFILE_IN_DMAQ: - case TASKFILE_IN_DMA: - if (!drive->using_dma) - break; - - if (!hwif->dma_setup(drive)) { - hwif->dma_exec_cmd(drive, tf->command); - hwif->dma_start(drive); - return ide_started; - } - break; - - default: - if (task->handler == NULL) - return ide_stopped; - - /* Issue the command */ - if (task->prehandler) { - hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); - ndelay(400); /* FIXME */ - return task->prehandler(drive, task->rq); - } - ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); - return ide_started; - } - - return ide_stopped; + return do_rw_taskfile(drive, task); } diff --git a/include/linux/ide.h b/include/linux/ide.h index 11bfbc4..6dfee2a 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1063,6 +1063,28 @@ extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *); enum { IDE_TFLAG_LBA48 = (1 << 0), IDE_TFLAG_NO_SELECT_MASK = (1 << 1), + IDE_TFLAG_FLAGGED = (1 << 2), + IDE_TFLAG_OUT_DATA = (1 << 3), + IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), + IDE_TFLAG_OUT_HOB_NSECT = (1 << 5), + IDE_TFLAG_OUT_HOB_LBAL = (1 << 6), + IDE_TFLAG_OUT_HOB_LBAM = (1 << 7), + IDE_TFLAG_OUT_HOB_LBAH = (1 << 8), + IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE | + IDE_TFLAG_OUT_HOB_NSECT | + IDE_TFLAG_OUT_HOB_LBAL | + IDE_TFLAG_OUT_HOB_LBAM | + IDE_TFLAG_OUT_HOB_LBAH, + IDE_TFLAG_OUT_FEATURE = (1 << 9), + IDE_TFLAG_OUT_NSECT = (1 << 10), + IDE_TFLAG_OUT_LBAL = (1 << 11), + IDE_TFLAG_OUT_LBAM = (1 << 12), + IDE_TFLAG_OUT_LBAH = (1 << 13), + IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE | + IDE_TFLAG_OUT_NSECT | + IDE_TFLAG_OUT_LBAL | + IDE_TFLAG_OUT_LBAM | + IDE_TFLAG_OUT_LBAH, }; struct ide_taskfile { @@ -1099,8 +1121,7 @@ typedef struct ide_task_s { struct ide_taskfile tf; u8 tf_array[14]; }; - u8 tf_flags; - ide_reg_valid_t tf_out_flags; + u16 tf_flags; ide_reg_valid_t tf_in_flags; int data_phase; int command_type; -- cgit v0.10.2 From d26805fd025abe1ab8785b23a7942cfb6ceffd75 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:07 +0100 Subject: ide-pmac: fix pmac_ide_init_hwif_ports() * pmac_ide_init_hwif_ports() can be called by ide_init_hwif_ports() (through ppc_ide_md.ide_init_hwif hook) for non IDE PMAC interfaces. If this is the case the hw->io_ports[] should be already setup by ide_init_hwif_ports()->ide_std_init_ports() so remove redundant code from pmac_ide_init_hwif_ports(). As side-effect this change fixes ctl_addr == 0 special handling in ide_init_hwif_ports(). * Fix misleading comment while at it. Cc: Benjamin Herrenschmidt Cc: Alan Cox Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 7f7a598..4559e29 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -438,13 +438,8 @@ pmac_ide_init_hwif_ports(hw_regs_t *hw, if (data_port == pmac_ide[ix].regbase) break; - if (ix >= MAX_HWIFS) { - /* Probably a PCI interface... */ - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; ++i) - hw->io_ports[i] = data_port + i - IDE_DATA_OFFSET; - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - return; - } + if (ix >= MAX_HWIFS) + return; /* not an IDE PMAC interface */ for (i = 0; i < 8; ++i) hw->io_ports[i] = data_port + i * 0x10; -- cgit v0.10.2 From 7b5da4be3718c6b4cd771fb82e3e481b04790f0e Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:08 +0100 Subject: ide: remove IRQF_DISABLED from IRQ flags for IDE IRQ handler IRQF_DISABLED is not needed because the first thing that ide_intr() (IDE IRQ handler) does is calling spin_lock_irqsave() which disables local IRQs (IRQ unmasking is later handled by drive->unmask). kernel/irq/handle.c: irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action) ... if (!(action->flags & IRQF_DISABLED)) local_irq_enable_in_hardirq(); do { ret = action->handler(irq, action->dev_id); if (ret == IRQ_HANDLED) status |= action->flags; retval |= ret; action = action->next; } while (action); ... drivers/ide/ide-io.c: irqreturn_t ide_intr (int irq, void *dev_id) ... spin_lock_irqsave(&ide_lock, flags); ... spin_unlock(&ide_lock); ... if (drive->unmask) local_irq_enable_in_hardirq(); ... Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 0cb3d2b..0dda7ac 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -968,11 +968,6 @@ static int ide_init_queue(ide_drive_t *drive) * Much of the code is for correctly detecting/handling irq sharing * and irq serialization situations. This is somewhat complex because * it handles static as well as dynamic (PCMCIA) IDE interfaces. - * - * The IRQF_DISABLED in sa_flags means ide_intr() is always entered with - * interrupts completely disabled. This can be bad for interrupt latency, - * but anything else has led to problems on some machines. We re-enable - * interrupts as much as we can safely do in most places. */ static int init_irq (ide_hwif_t *hwif) { @@ -1055,17 +1050,13 @@ static int init_irq (ide_hwif_t *hwif) * Allocate the irq, if not already obtained for another hwif */ if (!match || match->irq != hwif->irq) { - int sa = IRQF_DISABLED; + int sa = 0; #if defined(__mc68000__) || defined(CONFIG_APUS) sa = IRQF_SHARED; #endif /* __mc68000__ || CONFIG_APUS */ - if (IDE_CHIPSET_IS_PCI(hwif->chipset)) { + if (IDE_CHIPSET_IS_PCI(hwif->chipset)) sa = IRQF_SHARED; -#ifndef CONFIG_IDEPCI_SHARE_IRQ - sa |= IRQF_DISABLED; -#endif /* CONFIG_IDEPCI_SHARE_IRQ */ - } if (hwif->io_ports[IDE_CONTROL_OFFSET]) /* clear nIEN */ -- cgit v0.10.2 From f1ca6d37f991347b87d86430db42e2ab139d1b1d Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:08 +0100 Subject: ide: remove CONFIG_IDEPCI_SHARE_IRQ config option We can safely remove CONFIG_IDEPCI_SHARE_IRQ and always support PCI IRQ sharing. Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index fb06555..ee01e27 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -374,17 +374,6 @@ comment "PCI IDE chipsets support" config BLK_DEV_IDEPCI bool -config IDEPCI_SHARE_IRQ - bool "Sharing PCI IDE interrupts support" - depends on BLK_DEV_IDEPCI - help - Some ATA/IDE chipsets have hardware support which allows for - sharing a single IRQ with other cards. To enable support for - this in the ATA/IDE driver, say Y here. - - It is safe to say Y to this question, in most cases. - If unsure, say N. - config IDEPCI_PCIBUS_ORDER def_bool BLK_DEV_IDE=y && BLK_DEV_IDEPCI @@ -707,7 +696,6 @@ config BLK_DEV_SVWKS config BLK_DEV_SGIIOC4 tristate "Silicon Graphics IOC4 chipset ATA/ATAPI support" depends on (IA64_SGI_SN2 || IA64_GENERIC) && SGI_IOC4 - select IDEPCI_SHARE_IRQ select BLK_DEV_IDEDMA_PCI help This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4 diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 4aac1cc..6a6d1c1 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -449,7 +449,6 @@ int drive_is_ready (ide_drive_t *drive) udelay(1); #endif -#ifdef CONFIG_IDEPCI_SHARE_IRQ /* * We do a passive status test under shared PCI interrupts on * cards that truly share the ATA side interrupt, but may also share @@ -459,7 +458,6 @@ int drive_is_ready (ide_drive_t *drive) if (IDE_CONTROL_REG) stat = hwif->INB(IDE_ALTSTATUS_REG); else -#endif /* CONFIG_IDEPCI_SHARE_IRQ */ /* Note: this may clear a pending IRQ!! */ stat = hwif->INB(IDE_STATUS_REG); -- cgit v0.10.2 From 4ee06b7e677da4c75f2fcc5fd850543852d18bf2 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:08 +0100 Subject: ide: remove stale ide.h "configuration options" Remove stale ide.h "configuration options": * INITIAL_MULT_COUNT - always defined to 0 * SUPPORT_SLOW_DATA_PORTS - unused * OK_TO_RESET_CONTROLLER - always defined to 1 * DISABLE_IRQ_NOSYNC - always defined to 0 Leave SUPPORT_VLB_SYNC (defined to 0 for CRIS and FRV, otherwise to 1) for now but disallow overriding it by . There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 33458fe..4ea8419 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1469,12 +1469,8 @@ void ide_timer_expiry (unsigned long data) */ spin_unlock(&ide_lock); hwif = HWIF(drive); -#if DISABLE_IRQ_NOSYNC - disable_irq_nosync(hwif->irq); -#else /* disable_irq_nosync ?? */ disable_irq(hwif->irq); -#endif /* DISABLE_IRQ_NOSYNC */ /* local CPU only, * as if we were handling an interrupt */ local_irq_disable(); diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 6a6d1c1..6178880 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -1050,8 +1050,7 @@ static void ide_disk_pre_reset(ide_drive_t *drive) drive->special.all = 0; drive->special.b.set_geometry = legacy; drive->special.b.recalibrate = legacy; - if (OK_TO_RESET_CONTROLLER) - drive->mult_count = 0; + drive->mult_count = 0; if (!drive->keep_settings && !drive->using_dma) drive->mult_req = 0; if (drive->mult_req != drive->mult_count) @@ -1136,7 +1135,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) for (unit = 0; unit < MAX_DRIVES; ++unit) pre_reset(&hwif->drives[unit]); -#if OK_TO_RESET_CONTROLLER if (!IDE_CONTROL_REG) { spin_unlock_irqrestore(&ide_lock, flags); return ide_stopped; @@ -1173,11 +1171,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) * state when the disks are reset this way. At least, the Winbond * 553 documentation says that */ - if (hwif->resetproc != NULL) { + if (hwif->resetproc) hwif->resetproc(drive); - } - -#endif /* OK_TO_RESET_CONTROLLER */ spin_unlock_irqrestore(&ide_lock, flags); return ide_started; diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 0dda7ac..8e5d8dd 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -95,10 +95,10 @@ static void ide_disk_init_mult_count(ide_drive_t *drive) #ifdef CONFIG_IDEDISK_MULTI_MODE id->multsect = ((id->max_multsect/2) > 1) ? id->max_multsect : 0; id->multsect_valid = id->multsect ? 1 : 0; - drive->mult_req = id->multsect_valid ? id->max_multsect : INITIAL_MULT_COUNT; + drive->mult_req = id->multsect_valid ? id->max_multsect : 0; drive->special.b.set_multmode = drive->mult_req ? 1 : 0; #else /* original, pre IDE-NFG, per request of AC */ - drive->mult_req = INITIAL_MULT_COUNT; + drive->mult_req = 0; if (drive->mult_req > id->max_multsect) drive->mult_req = id->max_multsect; if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect)) diff --git a/include/asm-cris/arch-v10/ide.h b/include/asm-cris/arch-v10/ide.h index 78b301e..ea34e0d 100644 --- a/include/asm-cris/arch-v10/ide.h +++ b/include/asm-cris/arch-v10/ide.h @@ -89,11 +89,6 @@ static inline void ide_init_default_hwifs(void) } } -/* some configuration options we don't need */ - -#undef SUPPORT_VLB_SYNC -#define SUPPORT_VLB_SYNC 0 - #endif /* __KERNEL__ */ #endif /* __ASMCRIS_IDE_H */ diff --git a/include/asm-cris/arch-v32/ide.h b/include/asm-cris/arch-v32/ide.h index 1129617..fb9c362 100644 --- a/include/asm-cris/arch-v32/ide.h +++ b/include/asm-cris/arch-v32/ide.h @@ -48,11 +48,6 @@ static inline unsigned long ide_default_io_base(int index) return REG_TYPE_CONV(unsigned long, reg_ata_rw_ctrl2, ctrl2); } -/* some configuration options we don't need */ - -#undef SUPPORT_VLB_SYNC -#define SUPPORT_VLB_SYNC 0 - #define IDE_ARCH_ACK_INTR #define ide_ack_intr(hwif) ((hwif)->ack_intr(hwif)) diff --git a/include/asm-frv/ide.h b/include/asm-frv/ide.h index f0bd2cb..8c9a540 100644 --- a/include/asm-frv/ide.h +++ b/include/asm-frv/ide.h @@ -18,12 +18,6 @@ #include #include -#undef SUPPORT_SLOW_DATA_PORTS -#define SUPPORT_SLOW_DATA_PORTS 0 - -#undef SUPPORT_VLB_SYNC -#define SUPPORT_VLB_SYNC 0 - #ifndef MAX_HWIFS #define MAX_HWIFS 8 #endif diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h index fd7f5a4..6d50310 100644 --- a/include/asm-powerpc/ide.h +++ b/include/asm-powerpc/ide.h @@ -42,9 +42,6 @@ struct ide_machdep_calls { extern struct ide_machdep_calls ppc_ide_md; -#undef SUPPORT_SLOW_DATA_PORTS -#define SUPPORT_SLOW_DATA_PORTS 0 - #define IDE_ARCH_OBSOLETE_DEFAULTS static __inline__ int ide_default_irq(unsigned long base) diff --git a/include/linux/ide.h b/include/linux/ide.h index 6dfee2a..0b088f1 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -27,25 +27,10 @@ #include #include -/****************************************************************************** - * IDE driver configuration options (play with these as desired): - * - * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary - */ -#define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */ - -#ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */ -#define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */ -#endif -#ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */ -#define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */ -#endif -#ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */ -#define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */ -#endif - -#ifndef DISABLE_IRQ_NOSYNC -#define DISABLE_IRQ_NOSYNC 0 +#if defined(CRIS) || defined(FRV) +# define SUPPORT_VLB_SYNC 0 +#else +# define SUPPORT_VLB_SYNC 1 #endif /* @@ -55,10 +40,6 @@ #define IDE_NO_IRQ (-1) -/* - * "No user-serviceable parts" beyond this point :) - *****************************************************************************/ - typedef unsigned char byte; /* used everywhere */ /* -- cgit v0.10.2 From d3bb03438c58b2a00f07a59175d4156a9952d825 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:08 +0100 Subject: ide-tape: remove dead USE_IOTRACE code Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 1495792..90e902d 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -615,16 +615,6 @@ typedef struct os_dat_s { /*************************** End of tunable parameters ***********************/ /* - * Debugging/Performance analysis - * - * I/O trace support - */ -#define USE_IOTRACE 0 -#if USE_IOTRACE -#define IO_IDETAPE_FIFO 500 -#endif - -/* * Read/Write error simulation */ #define SIMULATE_ERRORS 0 @@ -2502,9 +2492,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, } if (rq->cmd[0] & REQ_IDETAPE_READ) { tape->buffer_head++; -#if USE_IOTRACE - IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); -#endif tape->postpone_cnt = 0; pc = idetape_next_pc_storage(drive); idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); @@ -2512,9 +2499,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, } if (rq->cmd[0] & REQ_IDETAPE_WRITE) { tape->buffer_head++; -#if USE_IOTRACE - IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); -#endif tape->postpone_cnt = 0; pc = idetape_next_pc_storage(drive); idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); @@ -3241,9 +3225,6 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) idetape_switch_buffers(tape, new_stage); idetape_add_stage_tail(drive, new_stage); tape->pipeline_head++; -#if USE_IOTRACE - IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); -#endif calculate_speeds(drive); /* @@ -3493,9 +3474,6 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) idetape_remove_stage_head(drive); spin_unlock_irqrestore(&tape->spinlock, flags); tape->pipeline_head++; -#if USE_IOTRACE - IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); -#endif calculate_speeds(drive); } #if IDETAPE_DEBUG_BUGS -- cgit v0.10.2 From 46f26c362d5109459f04f99e93fc0413d88516c8 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:09 +0100 Subject: ide: fix registers loading order for WIN_SMART in execute_drive_cmd() Fix registers loading order for REQ_TYPE_ATA_CMD request with WIN_SMART command in execute_drive_cmd() (load IDE_FEATURE_REG and IDE_SECTOR_REG before loading IDE_LCYL_REG and IDE_HCYL_REG). It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 4ea8419..c616c9f 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -932,10 +932,10 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, printk("xx=0x%02x\n", args[3]); #endif if (args[0] == WIN_SMART) { - hwif->OUTB(0x4f, IDE_LCYL_REG); - hwif->OUTB(0xc2, IDE_HCYL_REG); hwif->OUTB(args[2],IDE_FEATURE_REG); hwif->OUTB(args[1],IDE_SECTOR_REG); + hwif->OUTB(0x4f, IDE_LCYL_REG); + hwif->OUTB(0xc2, IDE_HCYL_REG); ide_cmd(drive, args[0], args[3], &drive_cmd_intr); return ide_started; } -- cgit v0.10.2 From 6dd87233bccc6416dac3b78ac912fd017918efe6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:09 +0100 Subject: ide: fix registers loading order for IDE_NSECTOR_REG in execute_drive_cmd() Move loading of IDE_NSECTOR_REG from ide_cmd() to execute_drive_cmd() (load the IDE_NSECTOR_REG just after IDE_FEATURE_REG). This also allows us to drop 'nsect' argument from ide_cmd() and simplify execute_drive_cmd() code for REQ_TYPE_ATA_CMD case a bit. It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index c616c9f..c5d81df 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -624,21 +624,18 @@ ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg) * ide_cmd - issue a simple drive command * @drive: drive the command is for * @cmd: command byte - * @nsect: sector byte * @handler: handler for the command completion * * Issue a simple drive command with interrupts. * The drive must be selected beforehand. */ -static void ide_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, - ide_handler_t *handler) +static void ide_cmd(ide_drive_t *drive, u8 cmd, ide_handler_t *handler) { ide_hwif_t *hwif = HWIF(drive); if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl,IDE_CONTROL_REG); /* clear nIEN */ SELECT_MASK(drive,0); - hwif->OUTB(nsect,IDE_NSECTOR_REG); ide_execute_command(drive, cmd, handler, WAIT_CMD, NULL); } @@ -913,11 +910,12 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, printk("sel=0x%02x\n", args[6]); #endif hwif->OUTB(args[1], IDE_FEATURE_REG); + hwif->OUTB(args[2], IDE_NSECTOR_REG); hwif->OUTB(args[3], IDE_SECTOR_REG); hwif->OUTB(args[4], IDE_LCYL_REG); hwif->OUTB(args[5], IDE_HCYL_REG); hwif->OUTB((args[6] & 0xEF)|drive->select.all, IDE_SELECT_REG); - ide_cmd(drive, args[0], args[2], &drive_cmd_intr); + ide_cmd(drive, args[0], &drive_cmd_intr); return ide_started; } else if (rq->cmd_type == REQ_TYPE_ATA_CMD) { u8 *args = rq->buffer; @@ -931,16 +929,15 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, printk("fr=0x%02x ", args[2]); printk("xx=0x%02x\n", args[3]); #endif + hwif->OUTB(args[2], IDE_FEATURE_REG); if (args[0] == WIN_SMART) { - hwif->OUTB(args[2],IDE_FEATURE_REG); + hwif->OUTB(args[3],IDE_NSECTOR_REG); hwif->OUTB(args[1],IDE_SECTOR_REG); hwif->OUTB(0x4f, IDE_LCYL_REG); hwif->OUTB(0xc2, IDE_HCYL_REG); - ide_cmd(drive, args[0], args[3], &drive_cmd_intr); - return ide_started; - } - hwif->OUTB(args[2],IDE_FEATURE_REG); - ide_cmd(drive, args[0], args[1], &drive_cmd_intr); + } else + hwif->OUTB(args[1], IDE_NSECTOR_REG); + ide_cmd(drive, args[0], &drive_cmd_intr); return ide_started; } -- cgit v0.10.2 From 21d535c91362a1a3bbb299b2e7214c1a6971ef95 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:09 +0100 Subject: ide: execute_drive_cmd() cleanup * Rename 'args' variable in 'if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)' block to 'task'. * execute_drive_cmd() is used only for REQ_TYPE_ATA_{CMD,TASK,TASKFILE} so we can move the common code out from 'if (rq->cmd_type == REQ_TYPE_ATA_CMD)' and 'if (rq->cmd_type == REQ_TYPE_ATA_TASK)' blocks. There should be no functionality changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index c5d81df..98aafc5 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -867,13 +867,15 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, struct request *rq) { ide_hwif_t *hwif = HWIF(drive); + u8 *args = rq->buffer; + if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { - ide_task_t *args = rq->special; + ide_task_t *task = rq->special; - if (!args) + if (task == NULL) goto done; - hwif->data_phase = args->data_phase; + hwif->data_phase = task->data_phase; switch (hwif->data_phase) { case TASKFILE_MULTI_OUT: @@ -886,19 +888,20 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, break; } - if (args->tf_flags & IDE_TFLAG_FLAGGED) - return flagged_taskfile(drive, args); + if (task->tf_flags & IDE_TFLAG_FLAGGED) + return flagged_taskfile(drive, task); - args->tf_flags |= IDE_TFLAG_OUT_TF; + task->tf_flags |= IDE_TFLAG_OUT_TF; if (drive->addressing == 1) - args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); + task->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); - return do_rw_taskfile(drive, args); - } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { - u8 *args = rq->buffer; - - if (!args) - goto done; + return do_rw_taskfile(drive, task); + } + + if (args == NULL) + goto done; + + if (rq->cmd_type == REQ_TYPE_ATA_TASK) { #ifdef DEBUG printk("%s: DRIVE_TASK_CMD ", drive->name); printk("cmd=0x%02x ", args[0]); @@ -915,13 +918,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, hwif->OUTB(args[4], IDE_LCYL_REG); hwif->OUTB(args[5], IDE_HCYL_REG); hwif->OUTB((args[6] & 0xEF)|drive->select.all, IDE_SELECT_REG); - ide_cmd(drive, args[0], &drive_cmd_intr); - return ide_started; - } else if (rq->cmd_type == REQ_TYPE_ATA_CMD) { - u8 *args = rq->buffer; - - if (!args) - goto done; + } else { /* rq->cmd_type == REQ_TYPE_ATA_CMD */ #ifdef DEBUG printk("%s: DRIVE_CMD ", drive->name); printk("cmd=0x%02x ", args[0]); @@ -937,10 +934,11 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, hwif->OUTB(0xc2, IDE_HCYL_REG); } else hwif->OUTB(args[1], IDE_NSECTOR_REG); - ide_cmd(drive, args[0], &drive_cmd_intr); - return ide_started; } + ide_cmd(drive, args[0], &drive_cmd_intr); + return ide_started; + done: /* * NULL is actually a valid way of waiting for -- cgit v0.10.2 From 54688aa372cbc83c4361bfb9236f9bfe02168e19 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:09 +0100 Subject: ide: remove ide_cmd() helper * Remove ide_cmd() helper. * Clear nIEN and call SELECT_MASK() before writing taskfile registers. Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 98aafc5..c5a7b3a 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -621,25 +621,6 @@ ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg) } /** - * ide_cmd - issue a simple drive command - * @drive: drive the command is for - * @cmd: command byte - * @handler: handler for the command completion - * - * Issue a simple drive command with interrupts. - * The drive must be selected beforehand. - */ - -static void ide_cmd(ide_drive_t *drive, u8 cmd, ide_handler_t *handler) -{ - ide_hwif_t *hwif = HWIF(drive); - if (IDE_CONTROL_REG) - hwif->OUTB(drive->ctl,IDE_CONTROL_REG); /* clear nIEN */ - SELECT_MASK(drive,0); - ide_execute_command(drive, cmd, handler, WAIT_CMD, NULL); -} - -/** * drive_cmd_intr - drive command completion interrupt * @drive: drive the completion interrupt occurred on * @@ -901,6 +882,11 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, if (args == NULL) goto done; + if (IDE_CONTROL_REG) + hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ + + SELECT_MASK(drive, 0); + if (rq->cmd_type == REQ_TYPE_ATA_TASK) { #ifdef DEBUG printk("%s: DRIVE_TASK_CMD ", drive->name); @@ -936,7 +922,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, hwif->OUTB(args[1], IDE_NSECTOR_REG); } - ide_cmd(drive, args[0], &drive_cmd_intr); + ide_execute_command(drive, args[0], &drive_cmd_intr, WAIT_CMD, NULL); return ide_started; done: -- cgit v0.10.2 From 807e35d695690011faa1ce3ad67dfc23c1e39bdc Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:10 +0100 Subject: ide: use ide_tf_load() in execute_drive_cmd() * Add IDE_TFLAG_OUT_DEVICE taskfile flag to indicate the need of writing the Device register and handle it in ide_tf_load(). Update ide_tf_load() and {do_rw,flagged}_taskfile() users accordingly. * Use struct ide_taskfile and ide_tf_load() in execute_drive_cmd(). * Make the debugging code dump all taskfile registers for both REQ_ATA_TYPE_{CMD,TASK} requests and move it to ide_tf_load() so it also covers REQ_ATA_TYPE_TASKFILE requests. There should be no functionality changes caused by this patch (unless DEBUG is defined). Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 6182c23..3e03d0c 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -159,7 +159,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, memset(&task, 0, sizeof(task)); task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ - task.tf_flags |= IDE_TFLAG_OUT_TF; + task.tf_flags |= (IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE); if (drive->select.b.lba) { if (lba48) { diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index c5a7b3a..9ffab8c 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -232,7 +232,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * return ide_stopped; out_do_tf: - args->tf_flags = IDE_TFLAG_OUT_TF; + args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; if (drive->addressing == 1) args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); args->command_type = IDE_DRIVE_TASK_NO_DATA; @@ -710,7 +710,7 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) return ide_stopped; } - args.tf_flags = IDE_TFLAG_OUT_TF; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; if (drive->addressing == 1) args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); @@ -849,6 +849,8 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, { ide_hwif_t *hwif = HWIF(drive); u8 *args = rq->buffer; + ide_task_t ltask; + struct ide_taskfile *tf = <ask.tf; if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *task = rq->special; @@ -869,6 +871,8 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, break; } + task->tf_flags |= IDE_TFLAG_OUT_DEVICE; + if (task->tf_flags & IDE_TFLAG_FLAGGED) return flagged_taskfile(drive, task); @@ -882,46 +886,32 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, if (args == NULL) goto done; - if (IDE_CONTROL_REG) - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ - - SELECT_MASK(drive, 0); - + memset(<ask, 0, sizeof(ltask)); if (rq->cmd_type == REQ_TYPE_ATA_TASK) { #ifdef DEBUG - printk("%s: DRIVE_TASK_CMD ", drive->name); - printk("cmd=0x%02x ", args[0]); - printk("fr=0x%02x ", args[1]); - printk("ns=0x%02x ", args[2]); - printk("sc=0x%02x ", args[3]); - printk("lcyl=0x%02x ", args[4]); - printk("hcyl=0x%02x ", args[5]); - printk("sel=0x%02x\n", args[6]); + printk("%s: DRIVE_TASK_CMD\n", drive->name); #endif - hwif->OUTB(args[1], IDE_FEATURE_REG); - hwif->OUTB(args[2], IDE_NSECTOR_REG); - hwif->OUTB(args[3], IDE_SECTOR_REG); - hwif->OUTB(args[4], IDE_LCYL_REG); - hwif->OUTB(args[5], IDE_HCYL_REG); - hwif->OUTB((args[6] & 0xEF)|drive->select.all, IDE_SELECT_REG); + memcpy(<ask.tf_array[7], &args[1], 6); + ltask.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; } else { /* rq->cmd_type == REQ_TYPE_ATA_CMD */ #ifdef DEBUG - printk("%s: DRIVE_CMD ", drive->name); - printk("cmd=0x%02x ", args[0]); - printk("sc=0x%02x ", args[1]); - printk("fr=0x%02x ", args[2]); - printk("xx=0x%02x\n", args[3]); + printk("%s: DRIVE_CMD\n", drive->name); #endif - hwif->OUTB(args[2], IDE_FEATURE_REG); - if (args[0] == WIN_SMART) { - hwif->OUTB(args[3],IDE_NSECTOR_REG); - hwif->OUTB(args[1],IDE_SECTOR_REG); - hwif->OUTB(0x4f, IDE_LCYL_REG); - hwif->OUTB(0xc2, IDE_HCYL_REG); - } else - hwif->OUTB(args[1], IDE_NSECTOR_REG); + tf->feature = args[2]; + if (args[0] == WIN_SMART) { + tf->nsect = args[3]; + tf->lbal = args[1]; + tf->lbam = 0x4f; + tf->lbah = 0xc2; + ltask.tf_flags = IDE_TFLAG_OUT_TF; + } else { + tf->nsect = args[1]; + ltask.tf_flags = IDE_TFLAG_OUT_FEATURE | + IDE_TFLAG_OUT_NSECT; + } } - + tf->command = args[0]; + ide_tf_load(drive, <ask); ide_execute_command(drive, args[0], &drive_cmd_intr, WAIT_CMD, NULL); return ide_started; diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index a7668b4..8a5a10f 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -72,6 +72,13 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) if (task->tf_flags & IDE_TFLAG_FLAGGED) HIHI = 0xFF; +#ifdef DEBUG + printk("%s: tf: feat 0x%02x nsect 0x%02x lbal 0x%02x " + "lbam 0x%02x lbah 0x%02x dev 0x%02x cmd 0x%02x\n", + drive->name, tf->feature, tf->nsect, tf->lbal, + tf->lbam, tf->lbah, tf->device, tf->command); +#endif + if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ @@ -103,7 +110,8 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) if (task->tf_flags & IDE_TFLAG_OUT_LBAH) hwif->OUTB(tf->lbah, IDE_HCYL_REG); - hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); + if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) + hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); } EXPORT_SYMBOL_GPL(ide_tf_load); diff --git a/include/linux/ide.h b/include/linux/ide.h index 0b088f1..e1f652c 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1066,6 +1066,7 @@ enum { IDE_TFLAG_OUT_LBAL | IDE_TFLAG_OUT_LBAM | IDE_TFLAG_OUT_LBAH, + IDE_TFLAG_OUT_DEVICE = (1 << 14), }; struct ide_taskfile { -- cgit v0.10.2 From 868e672ac8db650dde695a5707a6caf5a757e7d9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:10 +0100 Subject: ide: use IDE_TFLAG_LBA48 for REQ_TYPE_ATA_TASKFILE requests * Use IDE_TFLAG_LBA48 for REQ_TYPE_ATA_TASKFILE requests in ide_end_drive_cmd() to decide whether we need to read HOB taskfile registers. * Update execute_drive_cmd() accordingly. This is a preparation for the next patch which removes unnecessary writes to HOB taskfile registers for some ATA commands. Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 9ffab8c..859cf7f 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -374,7 +374,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) tf->device = hwif->INB(IDE_SELECT_REG); tf->status = stat; - if (drive->addressing == 1) { + if (args->tf_flags & IDE_TFLAG_LBA48) { hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); tf->hob_feature = hwif->INB(IDE_FEATURE_REG); tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); @@ -872,13 +872,15 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, } task->tf_flags |= IDE_TFLAG_OUT_DEVICE; + if (drive->addressing == 1) + task->tf_flags |= IDE_TFLAG_LBA48; if (task->tf_flags & IDE_TFLAG_FLAGGED) return flagged_taskfile(drive, task); task->tf_flags |= IDE_TFLAG_OUT_TF; - if (drive->addressing == 1) - task->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); + if (task->tf_flags & IDE_TFLAG_LBA48) + task->tf_flags |= IDE_TFLAG_OUT_HOB; return do_rw_taskfile(drive, task); } -- cgit v0.10.2 From a3bbb9d882dc94fe3a1361596ab9ce55d84059ea Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:10 +0100 Subject: ide: remove unnecessary writes to HOB taskfile registers * Set taskfile flags for REQ_TYPE_ATA_TASKFILE requests before adding the request to the queue. * Cleanup execute_drive_cmd(). * Remove unnecessary writes to HOB taskfile registers when using LBA48 disk for the following cases: - Power Management requests (WIN_FLUSH_CACHE[_EXT], WIN_STANDBYNOW1, WIN_IDLEIMMEDIATE commands) - special commands (WIN_SPECIFY, WIN_RESTORE, WIN_SETMULT) - Host Protected Area support (WIN_READ_NATIVE_MAX, WIN_SET_MAX) - /proc/ide/ SMART support (WIN_SMART with SMART_ENABLE, SMART_READ_VALUES and SMART_READ_THRESHOLDS subcommands) - write cache enabling/disabling in ide-disk (WIN_SETFEATURES with SETFEATURES_{EN,DIS}_WCACHE) - write cache flushing in ide-disk (WIN_FLUSH_CACHE[_EXT]) - acoustic management in ide-disk (WIN_SETFEATURES with SETFEATURES_{EN,DIS}_AAM) - door (un)locking in ide-disk (WIN_DOORLOCK, WIN_DOORUNLOCK) - /proc/ide/hd?/identify support (WIN_IDENTIFY) - ACPI _GTF taskfiles Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index f0a6a3d..e0bb0cf 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c @@ -386,6 +386,7 @@ static int taskfile_load_raw(ide_drive_t *drive, /* convert gtf to IDE Taskfile */ memcpy(&args.tf_array[7], >f->tfa, 7); + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; if (ide_noacpitfs) { DEBPRINT("_GTF execution disabled\n"); diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 3e03d0c..fc785e7 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -304,6 +304,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) else tf->command = WIN_READ_NATIVE_MAX; tf->device = ATA_LBA; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + if (lba48) + args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); /* submit command request */ ide_no_data_taskfile(drive, &args); @@ -349,6 +352,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) tf->command = WIN_SET_MAX; } tf->device |= ATA_LBA; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + if (lba48) + args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); /* submit command request */ ide_no_data_taskfile(drive, &args); /* if OK, compute maximum address value */ @@ -497,6 +503,7 @@ static int smart_enable(ide_drive_t *drive) tf->lbam = SMART_LCYL_PASS; tf->lbah = SMART_HCYL_PASS; tf->command = WIN_SMART; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; return ide_no_data_taskfile(drive, &args); } @@ -511,6 +518,7 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) tf->lbam = SMART_LCYL_PASS; tf->lbah = SMART_HCYL_PASS; tf->command = WIN_SMART; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args.command_type = IDE_DRIVE_TASK_IN; args.data_phase = TASKFILE_IN; args.handler = &task_in_intr; @@ -690,6 +698,7 @@ static int write_cache(ide_drive_t *drive, int arg) args.tf.feature = arg ? SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; args.tf.command = WIN_SETFEATURES; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; err = ide_no_data_taskfile(drive, &args); if (err == 0) drive->wcache = arg; @@ -709,6 +718,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive) args.tf.command = WIN_FLUSH_CACHE_EXT; else args.tf.command = WIN_FLUSH_CACHE; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; return ide_no_data_taskfile(drive, &args); } @@ -723,6 +733,7 @@ static int set_acoustic (ide_drive_t *drive, int arg) args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; args.tf.nsect = arg; args.tf.command = WIN_SETFEATURES; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; ide_no_data_taskfile(drive, &args); drive->acoustic = arg; return 0; @@ -985,6 +996,7 @@ static int idedisk_open(struct inode *inode, struct file *filp) ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); args.tf.command = WIN_DOORLOCK; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; check_disk_change(inode->i_bdev); /* * Ignore the return code from door_lock, @@ -1010,6 +1022,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); args.tf.command = WIN_DOORUNLOCK; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) drive->doorlocking = 0; } diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 859cf7f..1526d79 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -233,8 +233,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * out_do_tf: args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - if (drive->addressing == 1) - args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); args->command_type = IDE_DRIVE_TASK_NO_DATA; args->handler = task_no_data_intr; return do_rw_taskfile(drive, args); @@ -711,8 +709,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) } args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - if (drive->addressing == 1) - args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); do_rw_taskfile(drive, &args); @@ -871,17 +867,9 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, break; } - task->tf_flags |= IDE_TFLAG_OUT_DEVICE; - if (drive->addressing == 1) - task->tf_flags |= IDE_TFLAG_LBA48; - if (task->tf_flags & IDE_TFLAG_FLAGGED) return flagged_taskfile(drive, task); - task->tf_flags |= IDE_TFLAG_OUT_TF; - if (task->tf_flags & IDE_TFLAG_LBA48) - task->tf_flags |= IDE_TFLAG_OUT_HOB; - return do_rw_taskfile(drive, task); } diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 8a5a10f..7ae4a42 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -126,6 +126,7 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) args.tf.command = WIN_IDENTIFY; else args.tf.command = WIN_PIDENTIFY; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args.command_type = IDE_DRIVE_TASK_IN; args.data_phase = TASKFILE_IN; args.handler = &task_in_intr; @@ -619,6 +620,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) args.data_phase = req_task->data_phase; args.command_type = req_task->req_cmd; + args.tf_flags = IDE_TFLAG_OUT_DEVICE; + if (drive->addressing == 1) + args.tf_flags |= IDE_TFLAG_LBA48; + if (req_task->out_flags.all) { args.tf_flags |= IDE_TFLAG_FLAGGED; @@ -644,6 +649,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) args.tf_flags |= IDE_TFLAG_OUT_LBAM; if (req_task->out_flags.b.hcyl) args.tf_flags |= IDE_TFLAG_OUT_LBAH; + } else { + args.tf_flags |= IDE_TFLAG_OUT_TF; + if (args.tf_flags & IDE_TFLAG_LBA48) + args.tf_flags |= IDE_TFLAG_OUT_HOB; } drive->io_32bit = 0; -- cgit v0.10.2 From 1f2564b8b56b305ab9acf5d387abca950180dff6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:10 +0100 Subject: ide: extend timeout for REQ_TYPE_ATA_{CMD,TASK} requests Extend timeout for REQ_TYPE_ATA_{CMD,TASK} requests from WAIT_CMD (10sec) to WAIT_WORSTCASE (30sec, already used for REQ_TYPE_ATA_TASKFILE). Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1526d79..73e0212 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -902,7 +902,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, } tf->command = args[0]; ide_tf_load(drive, <ask); - ide_execute_command(drive, args[0], &drive_cmd_intr, WAIT_CMD, NULL); + ide_execute_command(drive, args[0], &drive_cmd_intr, WAIT_WORSTCASE, NULL); return ide_started; done: -- cgit v0.10.2 From 813a0eb233ee67d7166241a8b389b6a76f2247f9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:10 +0100 Subject: ide: switch idedisk_prepare_flush() to use REQ_TYPE_ATA_TASKFILE requests Based on the earlier work by Tejun Heo. There should be no functionality changes caused by this patch. Cc: Tejun Heo Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index fc785e7..ffff96e 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -601,19 +601,21 @@ static ide_proc_entry_t idedisk_proc[] = { static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) { ide_drive_t *drive = q->queuedata; + ide_task_t task; - memset(rq->cmd, 0, sizeof(rq->cmd)); - + memset(&task, 0, sizeof(task)); if (ide_id_has_flush_cache_ext(drive->id) && (drive->capacity64 >= (1UL << 28))) - rq->cmd[0] = WIN_FLUSH_CACHE_EXT; + task.tf.command = WIN_FLUSH_CACHE_EXT; else - rq->cmd[0] = WIN_FLUSH_CACHE; - + task.tf.command = WIN_FLUSH_CACHE; + task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + task.command_type = IDE_DRIVE_TASK_NO_DATA; + task.handler = task_no_data_intr; - rq->cmd_type = REQ_TYPE_ATA_TASK; + rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_flags |= REQ_SOFTBARRIER; - rq->buffer = rq->cmd; + rq->special = &task; } /* -- cgit v0.10.2 From 14b89ef9814614f18a1fcae51e601e7e16a82ef7 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:11 +0100 Subject: ide: switch ide_task_ioctl() to use REQ_TYPE_ATA_TASKFILE requests Based on the earlier work by Tejun Heo. There should be no functionality changes caused by this patch. Cc: Tejun Heo Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 7ae4a42..7c8e980 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -806,28 +806,29 @@ abort: return err; } -static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf) -{ - struct request rq; - - ide_init_drive_cmd(&rq); - rq.cmd_type = REQ_TYPE_ATA_TASK; - rq.buffer = buf; - return ide_do_drive_cmd(drive, &rq, ide_wait); -} - int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) { void __user *p = (void __user *)arg; int err = 0; - u8 args[7], *argbuf = args; - int argsize = 7; + u8 args[7]; + ide_task_t task; if (copy_from_user(args, p, 7)) return -EFAULT; - err = ide_wait_cmd_task(drive, argbuf); - if (copy_to_user(p, argbuf, argsize)) + + memset(&task, 0, sizeof(task)); + memcpy(&task.tf_array[7], &args[1], 6); + task.tf.command = args[0]; + task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + + err = ide_no_data_taskfile(drive, &task); + + args[0] = task.tf.command; + memcpy(&args[1], &task.tf_array[7], 6); + + if (copy_to_user(p, args, 7)) err = -EFAULT; + return err; } -- cgit v0.10.2 From 29ed2a5f8c4380959f18e9cbaff13bc61e09889c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:11 +0100 Subject: ide: remove REQ_TYPE_ATA_TASK Based on the earlier work by Tejun Heo. All users are gone so we can finally remove it. Cc: Tejun Heo Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 73e0212..d36df77 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -332,22 +332,6 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) args[1] = err; args[2] = hwif->INB(IDE_NSECTOR_REG); } - } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { - u8 *args = (u8 *) rq->buffer; - if (rq->errors == 0) - rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT); - - if (args) { - args[0] = stat; - args[1] = err; - /* be sure we're looking at the low order bits */ - hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); - args[2] = hwif->INB(IDE_NSECTOR_REG); - args[3] = hwif->INB(IDE_SECTOR_REG); - args[4] = hwif->INB(IDE_LCYL_REG); - args[5] = hwif->INB(IDE_HCYL_REG); - args[6] = hwif->INB(IDE_SELECT_REG); - } } else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *args = (ide_task_t *) rq->special; if (rq->errors == 0) @@ -877,13 +861,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, goto done; memset(<ask, 0, sizeof(ltask)); - if (rq->cmd_type == REQ_TYPE_ATA_TASK) { -#ifdef DEBUG - printk("%s: DRIVE_TASK_CMD\n", drive->name); -#endif - memcpy(<ask.tf_array[7], &args[1], 6); - ltask.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - } else { /* rq->cmd_type == REQ_TYPE_ATA_CMD */ + if (rq->cmd_type == REQ_TYPE_ATA_CMD) { #ifdef DEBUG printk("%s: DRIVE_CMD\n", drive->name); #endif @@ -1011,7 +989,6 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ide_config_drive_speed(drive, drive->desired_speed); if (rq->cmd_type == REQ_TYPE_ATA_CMD || - rq->cmd_type == REQ_TYPE_ATA_TASK || rq->cmd_type == REQ_TYPE_ATA_TASKFILE) return execute_drive_cmd(drive, rq); else if (blk_pm_request(rq)) { diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 6dbf2af..3bae2c4 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -458,8 +458,7 @@ static void ide_dump_opcode(ide_drive_t *drive) spin_unlock(&ide_lock); if (!rq) return; - if (rq->cmd_type == REQ_TYPE_ATA_CMD || - rq->cmd_type == REQ_TYPE_ATA_TASK) { + if (rq->cmd_type == REQ_TYPE_ATA_CMD) { char *args = rq->buffer; if (args) { opcode = args[0]; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d18ee67..40ee170 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -144,7 +144,6 @@ enum rq_cmd_type_bits { * private REQ_LB opcodes to differentiate what type of request this is */ REQ_TYPE_ATA_CMD, - REQ_TYPE_ATA_TASK, REQ_TYPE_ATA_TASKFILE, REQ_TYPE_ATA_PC, }; -- cgit v0.10.2 From 918337a85366ad0f1c4c08ebe45e4fb1e3a3c15f Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:11 +0100 Subject: ide-floppy: remove dead code Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 04a3578..53f9025 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -369,27 +369,6 @@ typedef struct ide_floppy_obj { #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 -#if 0 -/* - * Special requests for our block device strategy routine. - */ -#define IDEFLOPPY_FIRST_RQ 90 - -/* - * IDEFLOPPY_PC_RQ is used to queue a packet command in the request queue. - */ -#define IDEFLOPPY_PC_RQ 90 - -#define IDEFLOPPY_LAST_RQ 90 - -/* - * A macro which can be used to check if a given request command - * originated in the driver or in the buffer cache layer. - */ -#define IDEFLOPPY_RQ_CMD(cmd) ((cmd >= IDEFLOPPY_FIRST_RQ) && (cmd <= IDEFLOPPY_LAST_RQ)) - -#endif - /* * Error codes which are returned in rq->errors to the higher part * of the driver. @@ -1045,18 +1024,6 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p atapi_bcount_t bcount; ide_handler_t *pkt_xfer_routine; -#if 0 /* Accessing floppy->pc is not valid here, the previous pc may be gone - and have lived on another thread's stack; that stack may have become - unmapped meanwhile (CONFIG_DEBUG_PAGEALLOC). */ -#if IDEFLOPPY_DEBUG_BUGS - if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD && - pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) { - printk(KERN_ERR "ide-floppy: possible ide-floppy.c bug - " - "Two request sense in serial were issued\n"); - } -#endif /* IDEFLOPPY_DEBUG_BUGS */ -#endif - if (floppy->failed_pc == NULL && pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD) floppy->failed_pc = pc; -- cgit v0.10.2 From 6a2144146aa2e0eb60e48ba73ac0e1c51346edf6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:11 +0100 Subject: ide: CPU endianness doesn't matter for special_t special_t is used only internally by the IDE subsystem (it isn't related to hardware registers and isn't exported to the user-space). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/include/linux/ide.h b/include/linux/ide.h index e1f652c..c6ffc20 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -306,23 +306,12 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw, typedef union { unsigned all : 8; struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned set_geometry : 1; unsigned recalibrate : 1; unsigned set_multmode : 1; unsigned set_tune : 1; unsigned serviced : 1; unsigned reserved : 3; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned reserved : 3; - unsigned serviced : 1; - unsigned set_tune : 1; - unsigned set_multmode : 1; - unsigned recalibrate : 1; - unsigned set_geometry : 1; -#else -#error "Please fix " -#endif } b; } special_t; -- cgit v0.10.2 From 22c525b976778cce5bb6f8fdcc70046168c54b1a Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:11 +0100 Subject: ide: remove ata_status_t and atapi_status_t Remove ata_status_t (unused) and atapi_status_t. While at it: * replace 'HWIF(drive)' by 'drive->hwif' (or just 'hwif' where possible) Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 53f9025..7b94c7a 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -788,12 +788,12 @@ static void idefloppy_retry_pc (ide_drive_t *drive) static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; - atapi_status_t status; atapi_bcount_t bcount; atapi_ireason_t ireason; idefloppy_pc_t *pc = floppy->pc; struct request *rq = pc->rq; unsigned int temp; + u8 stat; debug_log(KERN_INFO "ide-floppy: Reached %s interrupt handler\n", __FUNCTION__); @@ -809,16 +809,16 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) } /* Clear the interrupt */ - status.all = HWIF(drive)->INB(IDE_STATUS_REG); + stat = drive->hwif->INB(IDE_STATUS_REG); - if (!status.b.drq) { /* No more interrupts */ + if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ debug_log(KERN_INFO "Packet command completed, %d bytes " "transferred\n", pc->actually_transferred); clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); local_irq_enable_in_hardirq(); - if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) { + if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { /* Error detected */ debug_log(KERN_INFO "ide-floppy: %s: I/O error\n", drive->name); @@ -1632,14 +1632,14 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) /* Else assume format_unit has finished, and we're ** at 0x10000 */ } else { - atapi_status_t status; unsigned long flags; + u8 stat; local_irq_save(flags); - status.all = HWIF(drive)->INB(IDE_STATUS_REG); + stat = drive->hwif->INB(IDE_STATUS_REG); local_irq_restore(flags); - progress_indication = !status.b.dsc ? 0 : 0x10000; + progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; } if (put_user(progress_indication, arg)) return (-EFAULT); diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 3bae2c4..dc7e539 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -562,27 +562,24 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) { unsigned long flags; - - atapi_status_t status; atapi_error_t error; - status.all = stat; error.all = 0; local_irq_save(flags); printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); - if (status.b.bsy) + if (stat & BUSY_STAT) printk("Busy "); else { - if (status.b.drdy) printk("DriveReady "); - if (status.b.df) printk("DeviceFault "); - if (status.b.dsc) printk("SeekComplete "); - if (status.b.drq) printk("DataRequest "); - if (status.b.corr) printk("CorrectedError "); - if (status.b.idx) printk("Index "); - if (status.b.check) printk("Error "); + if (stat & READY_STAT) printk("DriveReady "); + if (stat & WRERR_STAT) printk("DeviceFault "); + if (stat & SEEK_STAT) printk("SeekComplete "); + if (stat & DRQ_STAT) printk("DataRequest "); + if (stat & ECC_STAT) printk("CorrectedError "); + if (stat & INDEX_STAT) printk("Index "); + if (stat & ERR_STAT) printk("Error "); } printk("}\n"); - if (status.b.check && !status.b.bsy) { + if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { error.all = HWIF(drive)->INB(IDE_ERROR_REG); printk("%s: %s: error=0x%02x { ", drive->name, msg, error.all); if (error.b.ili) printk("IllegalLengthIndication "); diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 90e902d..c910395 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1848,15 +1848,14 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; idetape_tape_t *tape = drive->driver_data; - atapi_status_t status; atapi_bcount_t bcount; atapi_ireason_t ireason; idetape_pc_t *pc = tape->pc; - unsigned int temp; #if SIMULATE_ERRORS static int error_sim_count = 0; #endif + u8 stat; #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 4) @@ -1865,10 +1864,10 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) #endif /* IDETAPE_DEBUG_LOG */ /* Clear the interrupt */ - status.all = HWIF(drive)->INB(IDE_STATUS_REG); + stat = hwif->INB(IDE_STATUS_REG); if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { - if (HWIF(drive)->ide_dma_end(drive) || status.b.check) { + if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { /* * A DMA error is sometimes expected. For example, * if the tape is crossing a filemark during a @@ -1902,7 +1901,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) } /* No more interrupts */ - if (!status.b.drq) { + if ((stat & DRQ_STAT) == 0) { #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 2) printk(KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred); @@ -1917,12 +1916,13 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) (++error_sim_count % 100) == 0) { printk(KERN_INFO "ide-tape: %s: simulating error\n", tape->name); - status.b.check = 1; + stat |= ERR_STAT; } #endif - if (status.b.check && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) - status.b.check = 0; - if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) { /* Error detected */ + if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) + stat &= ~ERR_STAT; + if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { + /* Error detected */ #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 1) printk(KERN_INFO "ide-tape: %s: I/O error\n", @@ -1941,7 +1941,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) } pc->error = 0; if (test_bit(PC_WAIT_FOR_DSC, &pc->flags) && - !status.b.dsc) { + (stat & SEEK_STAT) == 0) { /* Media access command */ tape->dsc_polling_start = jiffies; tape->dsc_polling_frequency = IDETAPE_DSC_MA_FAST; @@ -2285,11 +2285,11 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) { idetape_tape_t *tape = drive->driver_data; idetape_pc_t *pc = tape->pc; - atapi_status_t status; + u8 stat; - status.all = HWIF(drive)->INB(IDE_STATUS_REG); - if (status.b.dsc) { - if (status.b.check) { + stat = drive->hwif->INB(IDE_STATUS_REG); + if (stat & SEEK_STAT) { + if (stat & ERR_STAT) { /* Error detected */ if (pc->c[0] != IDETAPE_TEST_UNIT_READY_CMD) printk(KERN_ERR "ide-tape: %s: I/O error, ", @@ -2407,7 +2407,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, idetape_tape_t *tape = drive->driver_data; idetape_pc_t *pc = NULL; struct request *postponed_rq = tape->postponed_rq; - atapi_status_t status; + u8 stat; #if IDETAPE_DEBUG_LOG #if 0 @@ -2455,7 +2455,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, * If the tape is still busy, postpone our request and service * the other device meanwhile. */ - status.all = HWIF(drive)->INB(IDE_STATUS_REG); + stat = drive->hwif->INB(IDE_STATUS_REG); if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) set_bit(IDETAPE_IGNORE_DSC, &tape->flags); @@ -2471,7 +2471,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); calculate_speeds(drive); if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && - !status.b.dsc) { + (stat & SEEK_STAT) == 0) { if (postponed_rq == NULL) { tape->dsc_polling_start = jiffies; tape->dsc_polling_frequency = tape->best_dsc_rw_frequency; diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 9706de9..bd2b569 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -398,11 +398,10 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) idescsi_pc_t *pc=scsi->pc; struct request *rq = pc->rq; atapi_bcount_t bcount; - atapi_status_t status; atapi_ireason_t ireason; atapi_feature_t feature; - unsigned int temp; + u8 stat; #if IDESCSI_DEBUG_LOG printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n"); @@ -427,14 +426,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) feature.all = 0; /* Clear the interrupt */ - status.all = HWIF(drive)->INB(IDE_STATUS_REG); + stat = drive->hwif->INB(IDE_STATUS_REG); - if (!status.b.drq) { + if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) printk (KERN_INFO "Packet command completed, %d bytes transferred\n", pc->actually_transferred); local_irq_enable_in_hardirq(); - if (status.b.check) + if (stat & ERR_STAT) rq->errors++; idescsi_end_request (drive, 1, 0); return ide_stopped; diff --git a/include/linux/ide.h b/include/linux/ide.h index c6ffc20..921cf71 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -366,50 +366,6 @@ typedef union { } select_t, ata_select_t; /* - * The ATA-IDE Status Register. - * The ATAPI Status Register. - * - * check : Error occurred - * idx : Index Error - * corr : Correctable error occurred - * drq : Data is request by the device - * dsc : Disk Seek Complete : ata - * : Media access command finished : atapi - * df : Device Fault : ata - * : Reserved : atapi - * drdy : Ready, Command Mode Capable : ata - * : Ignored for ATAPI commands : atapi - * bsy : Disk is Busy - * : The device has access to the command block - */ -typedef union { - unsigned all :8; - struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned check :1; - unsigned idx :1; - unsigned corr :1; - unsigned drq :1; - unsigned dsc :1; - unsigned df :1; - unsigned drdy :1; - unsigned bsy :1; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned bsy :1; - unsigned drdy :1; - unsigned df :1; - unsigned dsc :1; - unsigned drq :1; - unsigned corr :1; - unsigned idx :1; - unsigned check :1; -#else -#error "Please fix " -#endif - } b; -} ata_status_t, atapi_status_t; - -/* * ATAPI Feature Register * * dma : Using DMA or PIO -- cgit v0.10.2 From 0e38a66a1e69821ab57a06d5a7b11f0df9275bf4 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:12 +0100 Subject: ide: remove atapi_error_t (take 2) Remove atapi_error_t. While at it: * replace 'HWIF(drive)' by 'drive->hwif' v2: * Add {ILI,EOM,LFS}_ERR defines to . Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 7b94c7a..2a37a08 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -772,9 +772,8 @@ static void idefloppy_retry_pc (ide_drive_t *drive) { idefloppy_pc_t *pc; struct request *rq; - atapi_error_t error; - error.all = HWIF(drive)->INB(IDE_ERROR_REG); + (void)drive->hwif->INB(IDE_ERROR_REG); pc = idefloppy_next_pc_storage(drive); rq = idefloppy_next_rq_storage(drive); idefloppy_create_request_sense_cmd(pc); diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index dc7e539..562f5ef 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -562,9 +562,8 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) { unsigned long flags; - atapi_error_t error; + u8 err = 0; - error.all = 0; local_irq_save(flags); printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); if (stat & BUSY_STAT) @@ -580,19 +579,19 @@ static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) } printk("}\n"); if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { - error.all = HWIF(drive)->INB(IDE_ERROR_REG); - printk("%s: %s: error=0x%02x { ", drive->name, msg, error.all); - if (error.b.ili) printk("IllegalLengthIndication "); - if (error.b.eom) printk("EndOfMedia "); - if (error.b.abrt) printk("AbortedCommand "); - if (error.b.mcr) printk("MediaChangeRequested "); - if (error.b.sense_key) printk("LastFailedSense=0x%02x ", - error.b.sense_key); + err = drive->hwif->INB(IDE_ERROR_REG); + printk("%s: %s: error=0x%02x { ", drive->name, msg, err); + if (err & ILI_ERR) printk("IllegalLengthIndication "); + if (err & EOM_ERR) printk("EndOfMedia "); + if (err & ABRT_ERR) printk("AbortedCommand "); + if (err & MCR_ERR) printk("MediaChangeRequested "); + if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", + (err & LFS_ERR) >> 4); printk("}\n"); } ide_dump_opcode(drive); local_irq_restore(flags); - return error.all; + return err; } /** diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index c910395..2c03f46 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1808,9 +1808,8 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) idetape_tape_t *tape = drive->driver_data; idetape_pc_t *pc; struct request *rq; - atapi_error_t error; - error.all = HWIF(drive)->INB(IDE_ERROR_REG); + (void)drive->hwif->INB(IDE_ERROR_REG); pc = idetape_next_pc_storage(drive); rq = idetape_next_rq_storage(drive); idetape_create_request_sense_cmd(pc); diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index df17bf7..0521f12 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -44,7 +44,9 @@ /* Bits for HD_ERROR */ #define MARK_ERR 0x01 /* Bad address mark */ +#define ILI_ERR 0x01 /* Illegal Length Indication (ATAPI) */ #define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define EOM_ERR 0x02 /* End Of Media (ATAPI) */ #define ABRT_ERR 0x04 /* Command aborted */ #define MCR_ERR 0x08 /* media change request */ #define ID_ERR 0x10 /* ID field not found */ @@ -52,6 +54,7 @@ #define ECC_ERR 0x40 /* Uncorrectable ECC error */ #define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ #define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ +#define LFS_ERR 0xf0 /* Last Failed Sense (ATAPI) */ /* Bits of HD_NSECTOR */ #define CD 0x01 diff --git a/include/linux/ide.h b/include/linux/ide.h index 921cf71..0c1b0aa 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -417,36 +417,6 @@ typedef union { } atapi_ireason_t; /* - * The ATAPI error register. - * - * ili : Illegal Length Indication - * eom : End Of Media Detected - * abrt : Aborted command - As defined by ATA - * mcr : Media Change Requested - As defined by ATA - * sense_key : Sense key of the last failed packet command - */ -typedef union { - unsigned all :8; - struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned ili :1; - unsigned eom :1; - unsigned abrt :1; - unsigned mcr :1; - unsigned sense_key :4; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned sense_key :4; - unsigned mcr :1; - unsigned abrt :1; - unsigned eom :1; - unsigned ili :1; -#else -#error "Please fix " -#endif - } b; -} atapi_error_t; - -/* * Status returned from various ide_ functions */ typedef enum { -- cgit v0.10.2 From e5f9f5a89a01abc2b9c09747452aeb9218d6bffd Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:12 +0100 Subject: ide: remove atapi_feature_t Remove atapi_feature_t. While at it: * replace 'HWIF(drive)' by 'hwif' Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 2a37a08..95e3027 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1019,9 +1019,9 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p { idefloppy_floppy_t *floppy = drive->driver_data; ide_hwif_t *hwif = drive->hwif; - atapi_feature_t feature; atapi_bcount_t bcount; ide_handler_t *pkt_xfer_routine; + u8 dma; if (floppy->failed_pc == NULL && pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD) @@ -1064,20 +1064,20 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) ide_dma_off(drive); - feature.all = 0; + dma = 0; if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) - feature.b.dma = !hwif->dma_setup(drive); + dma = !hwif->dma_setup(drive); if (IDE_CONTROL_REG) HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); /* Use PIO/DMA */ - HWIF(drive)->OUTB(feature.all, IDE_FEATURE_REG); + hwif->OUTB(dma, IDE_FEATURE_REG); HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG); HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG); HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); - if (feature.b.dma) { /* Begin DMA, if necessary */ + if (dma) { /* Begin DMA, if necessary */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); hwif->dma_start(drive); } diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index bd2b569..c009f23 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -399,7 +399,6 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) struct request *rq = pc->rq; atapi_bcount_t bcount; atapi_ireason_t ireason; - atapi_feature_t feature; unsigned int temp; u8 stat; @@ -424,7 +423,6 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) (void) HWIF(drive)->ide_dma_end(drive); } - feature.all = 0; /* Clear the interrupt */ stat = drive->hwif->INB(IDE_STATUS_REG); @@ -572,18 +570,17 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) { idescsi_scsi_t *scsi = drive_to_idescsi(drive); ide_hwif_t *hwif = drive->hwif; - atapi_feature_t feature; atapi_bcount_t bcount; + u8 dma = 0; scsi->pc=pc; /* Set the current packet command */ pc->actually_transferred=0; /* We haven't transferred any data yet */ pc->current_position=pc->buffer; bcount.all = min(pc->request_transfer, 63 * 1024); /* Request to transfer the entire buffer at once */ - feature.all = 0; if (drive->using_dma && !idescsi_map_sg(drive, pc)) { hwif->sg_mapped = 1; - feature.b.dma = !hwif->dma_setup(drive); + dma = !hwif->dma_setup(drive); hwif->sg_mapped = 0; } @@ -591,11 +588,11 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) if (IDE_CONTROL_REG) HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); - HWIF(drive)->OUTB(feature.all, IDE_FEATURE_REG); + hwif->OUTB(dma, IDE_FEATURE_REG); HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG); HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG); - if (feature.b.dma) + if (dma) set_bit(PC_DMA_OK, &pc->flags); if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { diff --git a/include/linux/ide.h b/include/linux/ide.h index 0c1b0aa..a638dde 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -366,33 +366,6 @@ typedef union { } select_t, ata_select_t; /* - * ATAPI Feature Register - * - * dma : Using DMA or PIO - * reserved321 : Reserved - * reserved654 : Reserved (Tag Type) - * reserved7 : Reserved - */ -typedef union { - unsigned all :8; - struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned dma :1; - unsigned reserved321 :3; - unsigned reserved654 :3; - unsigned reserved7 :1; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned reserved7 :1; - unsigned reserved654 :3; - unsigned reserved321 :3; - unsigned dma :1; -#else -#error "Please fix " -#endif - } b; -} atapi_feature_t; - -/* * ATAPI Interrupt Reason Register. * * cod : Information transferred is command (1) or data (0) -- cgit v0.10.2 From 790d1239898d4f893112280decd344d90f43ee96 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:12 +0100 Subject: ide: remove ata_nsector_t, ata_data_t and atapi_bcount_t Remove ata_nsector_t, ata_data_t (unused) and atapi_bcount_t. While at it: * replace 'HWIF(drive)' by 'hwif' Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index ffff96e..747dc60 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -137,14 +137,12 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, { ide_hwif_t *hwif = HWIF(drive); unsigned int dma = drive->using_dma; + u16 nsectors = (u16)rq->nr_sectors; u8 lba48 = (drive->addressing == 1) ? 1 : 0; u8 command = WIN_NOP; - ata_nsector_t nsectors; ide_task_t task; struct ide_taskfile *tf = &task.tf; - nsectors.all = (u16) rq->nr_sectors; - if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) { if (block + rq->nr_sectors > 1ULL << 28) dma = 0; @@ -166,14 +164,14 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, pr_debug("%s: LBA=0x%012llx\n", drive->name, (unsigned long long)block); - tf->hob_nsect = nsectors.b.high; + tf->hob_nsect = (nsectors >> 8) & 0xff; tf->hob_lbal = (u8)(block >> 24); if (sizeof(block) != 4) { tf->hob_lbam = (u8)((u64)block >> 32); tf->hob_lbah = (u8)((u64)block >> 40); } - tf->nsect = nsectors.b.low; + tf->nsect = nsectors & 0xff; tf->lbal = (u8) block; tf->lbam = (u8)(block >> 8); tf->lbah = (u8)(block >> 16); @@ -185,7 +183,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, #endif task.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); } else { - tf->nsect = nsectors.b.low; + tf->nsect = nsectors & 0xff; tf->lbal = block; tf->lbam = block >>= 8; tf->lbah = block >>= 8; @@ -200,7 +198,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect); - tf->nsect = nsectors.b.low; + tf->nsect = nsectors & 0xff; tf->lbal = sect; tf->lbam = cyl; tf->lbah = cyl >> 8; diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 95e3027..239aebc 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -787,11 +787,12 @@ static void idefloppy_retry_pc (ide_drive_t *drive) static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; - atapi_bcount_t bcount; + ide_hwif_t *hwif = drive->hwif; atapi_ireason_t ireason; idefloppy_pc_t *pc = floppy->pc; struct request *rq = pc->rq; unsigned int temp; + u16 bcount; u8 stat; debug_log(KERN_INFO "ide-floppy: Reached %s interrupt handler\n", @@ -848,8 +849,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) } /* Get the number of bytes to transfer */ - bcount.b.high = HWIF(drive)->INB(IDE_BCOUNTH_REG); - bcount.b.low = HWIF(drive)->INB(IDE_BCOUNTL_REG); + bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | + hwif->INB(IDE_BCOUNTL_REG); /* on this interrupt */ ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); @@ -867,13 +868,13 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) } if (!test_bit(PC_WRITING, &pc->flags)) { /* Reading - Check that we have enough space */ - temp = pc->actually_transferred + bcount.all; + temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { 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); + idefloppy_discard_data(drive, bcount); BUG_ON(HWGROUP(drive)->handler != NULL); ide_set_handler(drive, &idefloppy_pc_intr, @@ -889,23 +890,21 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) if (test_bit(PC_WRITING, &pc->flags)) { if (pc->buffer != NULL) /* Write the current buffer */ - HWIF(drive)->atapi_output_bytes(drive, - pc->current_position, - bcount.all); + hwif->atapi_output_bytes(drive, pc->current_position, + bcount); else - idefloppy_output_buffers(drive, pc, bcount.all); + idefloppy_output_buffers(drive, pc, bcount); } else { if (pc->buffer != NULL) /* Read the current buffer */ - HWIF(drive)->atapi_input_bytes(drive, - pc->current_position, - bcount.all); + hwif->atapi_input_bytes(drive, pc->current_position, + bcount); else - idefloppy_input_buffers(drive, pc, bcount.all); + idefloppy_input_buffers(drive, pc, bcount); } /* Update the current position */ - pc->actually_transferred += bcount.all; - pc->current_position += bcount.all; + pc->actually_transferred += bcount; + pc->current_position += bcount; BUG_ON(HWGROUP(drive)->handler != NULL); ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */ @@ -1019,8 +1018,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p { idefloppy_floppy_t *floppy = drive->driver_data; ide_hwif_t *hwif = drive->hwif; - atapi_bcount_t bcount; ide_handler_t *pkt_xfer_routine; + u16 bcount; u8 dma; if (floppy->failed_pc == NULL && @@ -1059,7 +1058,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p /* We haven't transferred any data yet */ pc->actually_transferred = 0; pc->current_position = pc->buffer; - bcount.all = min(pc->request_transfer, 63 * 1024); + bcount = min(pc->request_transfer, 63 * 1024); if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) ide_dma_off(drive); @@ -1073,8 +1072,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); /* Use PIO/DMA */ hwif->OUTB(dma, IDE_FEATURE_REG); - HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG); - HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); + hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); if (dma) { /* Begin DMA, if necessary */ diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 2c03f46..4c24e18 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1847,13 +1847,13 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; idetape_tape_t *tape = drive->driver_data; - atapi_bcount_t bcount; atapi_ireason_t ireason; idetape_pc_t *pc = tape->pc; unsigned int temp; #if SIMULATE_ERRORS static int error_sim_count = 0; #endif + u16 bcount; u8 stat; #if IDETAPE_DEBUG_LOG @@ -1962,8 +1962,8 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) return ide_do_reset(drive); } /* Get the number of bytes to transfer on this interrupt. */ - bcount.b.high = hwif->INB(IDE_BCOUNTH_REG); - bcount.b.low = hwif->INB(IDE_BCOUNTL_REG); + bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | + hwif->INB(IDE_BCOUNTL_REG); ireason.all = hwif->INB(IDE_IREASON_REG); @@ -1981,11 +1981,11 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) } if (!test_bit(PC_WRITING, &pc->flags)) { /* Reading - Check that we have enough space */ - temp = pc->actually_transferred + bcount.all; + temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { 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); + idetape_discard_data(drive, bcount); ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); return ide_started; } @@ -1997,23 +1997,26 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) } if (test_bit(PC_WRITING, &pc->flags)) { if (pc->bh != NULL) - idetape_output_buffers(drive, pc, bcount.all); + idetape_output_buffers(drive, pc, bcount); else /* Write the current buffer */ - HWIF(drive)->atapi_output_bytes(drive, pc->current_position, bcount.all); + hwif->atapi_output_bytes(drive, pc->current_position, + bcount); } else { if (pc->bh != NULL) - idetape_input_buffers(drive, pc, bcount.all); + idetape_input_buffers(drive, pc, bcount); else /* Read the current buffer */ - HWIF(drive)->atapi_input_bytes(drive, pc->current_position, bcount.all); + hwif->atapi_input_bytes(drive, pc->current_position, + bcount); } /* Update the current position */ - pc->actually_transferred += bcount.all; - pc->current_position += bcount.all; + pc->actually_transferred += bcount; + pc->current_position += bcount; #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 2) - printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes on that interrupt\n", pc->c[0], bcount.all); + printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes " + "on that interrupt\n", pc->c[0], bcount); #endif /* And set the interrupt handler again */ ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); @@ -2109,8 +2112,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape { ide_hwif_t *hwif = drive->hwif; idetape_tape_t *tape = drive->driver_data; - atapi_bcount_t bcount; int dma_ok = 0; + u16 bcount; #if IDETAPE_DEBUG_BUGS if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && @@ -2159,7 +2162,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape pc->actually_transferred = 0; pc->current_position = pc->buffer; /* Request to transfer the entire buffer at once */ - bcount.all = pc->request_transfer; + bcount = pc->request_transfer; if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) { printk(KERN_WARNING "ide-tape: DMA disabled, " @@ -2172,8 +2175,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl, IDE_CONTROL_REG); hwif->OUTB(dma_ok ? 1 : 0, IDE_FEATURE_REG); /* Use PIO/DMA */ - hwif->OUTB(bcount.b.high, IDE_BCOUNTH_REG); - hwif->OUTB(bcount.b.low, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); + hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); hwif->OUTB(drive->select.all, IDE_SELECT_REG); if (dma_ok) /* Will begin DMA later */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index c009f23..77e8a81 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -395,11 +395,12 @@ static int idescsi_expiry(ide_drive_t *drive) static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) { idescsi_scsi_t *scsi = drive_to_idescsi(drive); - idescsi_pc_t *pc=scsi->pc; + ide_hwif_t *hwif = drive->hwif; + idescsi_pc_t *pc = scsi->pc; struct request *rq = pc->rq; - atapi_bcount_t bcount; atapi_ireason_t ireason; unsigned int temp; + u16 bcount; u8 stat; #if IDESCSI_DEBUG_LOG @@ -436,8 +437,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) idescsi_end_request (drive, 1, 0); return ide_stopped; } - bcount.b.low = HWIF(drive)->INB(IDE_BCOUNTL_REG); - bcount.b.high = HWIF(drive)->INB(IDE_BCOUNTH_REG); + bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | + hwif->INB(IDE_BCOUNTL_REG); ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); if (ireason.b.cod) { @@ -445,7 +446,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) return ide_do_reset (drive); } if (ireason.b.io) { - temp = pc->actually_transferred + bcount.all; + temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { if (temp > pc->buffer_size) { printk(KERN_ERR "ide-scsi: The scsi wants to " @@ -458,11 +459,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) idescsi_input_buffers(drive, pc, temp); else drive->hwif->atapi_input_bytes(drive, pc->current_position, temp); - printk(KERN_ERR "ide-scsi: transferred %d of %d bytes\n", temp, bcount.all); + printk(KERN_ERR "ide-scsi: transferred" + " %d of %d bytes\n", + temp, bcount); } pc->actually_transferred += temp; pc->current_position += temp; - idescsi_discard_data(drive, bcount.all - temp); + idescsi_discard_data(drive, bcount - temp); ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); return ide_started; } @@ -474,19 +477,21 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) if (ireason.b.io) { clear_bit(PC_WRITING, &pc->flags); if (pc->sg) - idescsi_input_buffers(drive, pc, bcount.all); + idescsi_input_buffers(drive, pc, bcount); else - HWIF(drive)->atapi_input_bytes(drive, pc->current_position, bcount.all); + hwif->atapi_input_bytes(drive, pc->current_position, + bcount); } else { set_bit(PC_WRITING, &pc->flags); if (pc->sg) - idescsi_output_buffers (drive, pc, bcount.all); + idescsi_output_buffers(drive, pc, bcount); else - HWIF(drive)->atapi_output_bytes(drive, pc->current_position, bcount.all); + hwif->atapi_output_bytes(drive, pc->current_position, + bcount); } /* Update the current position */ - pc->actually_transferred += bcount.all; - pc->current_position += bcount.all; + pc->actually_transferred += bcount; + pc->current_position += bcount; /* And set the interrupt handler again */ ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); @@ -570,13 +575,14 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) { idescsi_scsi_t *scsi = drive_to_idescsi(drive); ide_hwif_t *hwif = drive->hwif; - atapi_bcount_t bcount; + u16 bcount; u8 dma = 0; scsi->pc=pc; /* Set the current packet command */ pc->actually_transferred=0; /* We haven't transferred any data yet */ pc->current_position=pc->buffer; - bcount.all = min(pc->request_transfer, 63 * 1024); /* Request to transfer the entire buffer at once */ + /* Request to transfer the entire buffer at once */ + bcount = min(pc->request_transfer, 63 * 1024); if (drive->using_dma && !idescsi_map_sg(drive, pc)) { hwif->sg_mapped = 1; @@ -589,8 +595,8 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); hwif->OUTB(dma, IDE_FEATURE_REG); - HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG); - HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); + hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); if (dma) set_bit(PC_DMA_OK, &pc->flags); diff --git a/include/linux/ide.h b/include/linux/ide.h index a638dde..cf1a5aa 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -316,26 +316,6 @@ typedef union { } special_t; /* - * ATA DATA Register Special. - * ATA NSECTOR Count Register(). - * ATAPI Byte Count Register. - */ -typedef union { - unsigned all :16; - struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned low :8; /* LSB */ - unsigned high :8; /* MSB */ -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned high :8; /* MSB */ - unsigned low :8; /* LSB */ -#else -#error "Please fix " -#endif - } b; -} ata_nsector_t, ata_data_t, atapi_bcount_t; - -/* * ATA-IDE Select Register, aka Device-Head * * head : always zeros here -- cgit v0.10.2 From 8e7657ae0f56c14882e53ffdae8055c2b1624de1 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:12 +0100 Subject: ide: remove atapi_ireason_t (take 3) Remove atapi_ireason_t. While at it: * replace 'HWIF(drive)' by 'drive->hwif' (or just 'hwif' where possible) v2: * v1 had CD and IO bits reversed in many places. * Use CD and IO defines from . v3: * Fix incorrect "(ireason & IO) == test_bit()". (Noticed by Sergei) Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 239aebc..830186f 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -788,12 +788,11 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; ide_hwif_t *hwif = drive->hwif; - atapi_ireason_t ireason; idefloppy_pc_t *pc = floppy->pc; struct request *rq = pc->rq; unsigned int temp; u16 bcount; - u8 stat; + u8 stat, ireason; debug_log(KERN_INFO "ide-floppy: Reached %s interrupt handler\n", __FUNCTION__); @@ -852,18 +851,18 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | hwif->INB(IDE_BCOUNTL_REG); /* on this interrupt */ - ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); + ireason = hwif->INB(IDE_IREASON_REG); - if (ireason.b.cod) { + if (ireason & CD) { printk(KERN_ERR "ide-floppy: CoD != 0 in idefloppy_pc_intr\n"); return ide_do_reset(drive); } - if (ireason.b.io == test_bit(PC_WRITING, &pc->flags)) { + if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { /* Hopefully, we will never get here */ printk(KERN_ERR "ide-floppy: We wanted to %s, ", - ireason.b.io ? "Write":"Read"); + (ireason & IO) ? "Write" : "Read"); printk(KERN_ERR "but the floppy wants us to %s !\n", - ireason.b.io ? "Read":"Write"); + (ireason & IO) ? "Read" : "Write"); return ide_do_reset(drive); } if (!test_bit(PC_WRITING, &pc->flags)) { @@ -920,15 +919,15 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) { ide_startstop_t startstop; idefloppy_floppy_t *floppy = drive->driver_data; - atapi_ireason_t ireason; + u8 ireason; if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { printk(KERN_ERR "ide-floppy: Strange, packet command " "initiated yet DRQ isn't asserted\n"); return startstop; } - ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); - if (!ireason.b.cod || ireason.b.io) { + ireason = drive->hwif->INB(IDE_IREASON_REG); + if ((ireason & CD) == 0 || (ireason & IO)) { printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " "issuing a packet command\n"); return ide_do_reset(drive); @@ -968,15 +967,15 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) { idefloppy_floppy_t *floppy = drive->driver_data; ide_startstop_t startstop; - atapi_ireason_t ireason; + u8 ireason; if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { printk(KERN_ERR "ide-floppy: Strange, packet command " "initiated yet DRQ isn't asserted\n"); return startstop; } - ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); - if (!ireason.b.cod || ireason.b.io) { + ireason = drive->hwif->INB(IDE_IREASON_REG); + if ((ireason & CD) == 0 || (ireason & IO)) { printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " "while issuing a packet command\n"); return ide_do_reset(drive); diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 4c24e18..3539131 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1847,14 +1847,13 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; idetape_tape_t *tape = drive->driver_data; - atapi_ireason_t ireason; idetape_pc_t *pc = tape->pc; unsigned int temp; #if SIMULATE_ERRORS static int error_sim_count = 0; #endif u16 bcount; - u8 stat; + u8 stat, ireason; #if IDETAPE_DEBUG_LOG if (tape->debug_level >= 4) @@ -1965,18 +1964,18 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | hwif->INB(IDE_BCOUNTL_REG); - ireason.all = hwif->INB(IDE_IREASON_REG); + ireason = hwif->INB(IDE_IREASON_REG); - if (ireason.b.cod) { + if (ireason & CD) { printk(KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n"); return ide_do_reset(drive); } - if (ireason.b.io == test_bit(PC_WRITING, &pc->flags)) { + if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { /* Hopefully, we will never get here */ printk(KERN_ERR "ide-tape: We wanted to %s, ", - ireason.b.io ? "Write":"Read"); + (ireason & IO) ? "Write" : "Read"); printk(KERN_ERR "ide-tape: but the tape wants us to %s !\n", - ireason.b.io ? "Read":"Write"); + (ireason & IO) ? "Read" : "Write"); return ide_do_reset(drive); } if (!test_bit(PC_WRITING, &pc->flags)) { @@ -2070,28 +2069,28 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) ide_hwif_t *hwif = drive->hwif; idetape_tape_t *tape = drive->driver_data; idetape_pc_t *pc = tape->pc; - atapi_ireason_t ireason; int retries = 100; ide_startstop_t startstop; + u8 ireason; if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { printk(KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n"); return startstop; } - ireason.all = hwif->INB(IDE_IREASON_REG); - while (retries-- && (!ireason.b.cod || ireason.b.io)) { + ireason = hwif->INB(IDE_IREASON_REG); + while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " "a packet command, retrying\n"); udelay(100); - ireason.all = hwif->INB(IDE_IREASON_REG); + ireason = hwif->INB(IDE_IREASON_REG); if (retries == 0) { printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " "issuing a packet command, ignoring\n"); - ireason.b.cod = 1; - ireason.b.io = 0; + ireason |= CD; + ireason &= ~IO; } } - if (!ireason.b.cod || ireason.b.io) { + if ((ireason & CD) == 0 || (ireason & IO)) { printk(KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing " "a packet command\n"); return ide_do_reset(drive); diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 77e8a81..ab7e864 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -398,10 +398,9 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ide_hwif_t *hwif = drive->hwif; idescsi_pc_t *pc = scsi->pc; struct request *rq = pc->rq; - atapi_ireason_t ireason; unsigned int temp; u16 bcount; - u8 stat; + u8 stat, ireason; #if IDESCSI_DEBUG_LOG printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n"); @@ -439,13 +438,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) } bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | hwif->INB(IDE_BCOUNTL_REG); - ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); + ireason = hwif->INB(IDE_IREASON_REG); - if (ireason.b.cod) { + if (ireason & CD) { printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n"); return ide_do_reset (drive); } - if (ireason.b.io) { + if (ireason & IO) { temp = pc->actually_transferred + bcount; if (temp > pc->request_transfer) { if (temp > pc->buffer_size) { @@ -474,7 +473,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) #endif /* IDESCSI_DEBUG_LOG */ } } - if (ireason.b.io) { + if (ireason & IO) { clear_bit(PC_WRITING, &pc->flags); if (pc->sg) idescsi_input_buffers(drive, pc, bcount); @@ -503,16 +502,16 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) ide_hwif_t *hwif = drive->hwif; idescsi_scsi_t *scsi = drive_to_idescsi(drive); idescsi_pc_t *pc = scsi->pc; - atapi_ireason_t ireason; ide_startstop_t startstop; + u8 ireason; if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { printk(KERN_ERR "ide-scsi: Strange, packet command " "initiated yet DRQ isn't asserted\n"); return startstop; } - ireason.all = HWIF(drive)->INB(IDE_IREASON_REG); - if (!ireason.b.cod || ireason.b.io) { + ireason = hwif->INB(IDE_IREASON_REG); + if ((ireason & CD) == 0 || (ireason & IO)) { printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while " "issuing a packet command\n"); return ide_do_reset (drive); diff --git a/include/linux/ide.h b/include/linux/ide.h index cf1a5aa..790ffa7 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -346,30 +346,6 @@ typedef union { } select_t, ata_select_t; /* - * ATAPI Interrupt Reason Register. - * - * cod : Information transferred is command (1) or data (0) - * io : The device requests us to read (1) or write (0) - * reserved : Reserved - */ -typedef union { - unsigned all :8; - struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned cod :1; - unsigned io :1; - unsigned reserved :6; -#elif defined(__BIG_ENDIAN_BITFIELD) - unsigned reserved :6; - unsigned io :1; - unsigned cod :1; -#else -#error "Please fix " -#endif - } b; -} atapi_ireason_t; - -/* * Status returned from various ide_ functions */ typedef enum { -- cgit v0.10.2 From 3a6a3549afe7dfe212b6384106bec957bb393f3a Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:13 +0100 Subject: ide-cd: fix register loading order in cdrom_start_packet_command() Load IDE_CONTROL_REG before other registers in cdrom_start_packet_command(). It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). While at it move misplaced FIXME comment in the right place. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index c7d77f0..855a23c 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -917,19 +917,19 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) return startstop; + /* FIXME: for Virtual DMA we must check harder */ if (info->dma) info->dma = !hwif->dma_setup(drive); /* Set up the controller registers. */ - /* FIXME: for Virtual DMA we must check harder */ + if (IDE_CONTROL_REG) + HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); HWIF(drive)->OUTB(info->dma, IDE_FEATURE_REG); HWIF(drive)->OUTB(0, IDE_IREASON_REG); HWIF(drive)->OUTB(0, IDE_SECTOR_REG); HWIF(drive)->OUTB(xferlen & 0xff, IDE_BCOUNTL_REG); HWIF(drive)->OUTB(xferlen >> 8 , IDE_BCOUNTH_REG); - if (IDE_CONTROL_REG) - HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) { /* waiting for CDB interrupt, not DMA yet. */ -- cgit v0.10.2 From 932aead6d21b631b2058255981824008a6eae32e Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:13 +0100 Subject: ide-{floppy,tape,scsi}: fix register loading order when issuing packet command Load IDE_BCOUNTL_REG before IDE_BCOUNTH_REG when issuing packet command. It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 830186f..d4fd064 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1071,8 +1071,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); /* Use PIO/DMA */ hwif->OUTB(dma, IDE_FEATURE_REG); - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); if (dma) { /* Begin DMA, if necessary */ diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 3539131..d1f2446 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -2174,8 +2174,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl, IDE_CONTROL_REG); hwif->OUTB(dma_ok ? 1 : 0, IDE_FEATURE_REG); /* Use PIO/DMA */ - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); hwif->OUTB(drive->select.all, IDE_SELECT_REG); if (dma_ok) /* Will begin DMA later */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index ab7e864..76f0ccd 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -594,8 +594,8 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); hwif->OUTB(dma, IDE_FEATURE_REG); - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); + hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); if (dma) set_bit(PC_DMA_OK, &pc->flags); -- cgit v0.10.2 From 2fc573881957337c4ea1c84b92d2f27d076cad57 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:13 +0100 Subject: ide: add ide_pktcmd_tf_load() helper Add ide_pktcmd_tf_load() helper and convert ATAPI device drivers to use it. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 855a23c..44b033e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -922,14 +922,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, info->dma = !hwif->dma_setup(drive); /* Set up the controller registers. */ - if (IDE_CONTROL_REG) - HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); - HWIF(drive)->OUTB(info->dma, IDE_FEATURE_REG); - HWIF(drive)->OUTB(0, IDE_IREASON_REG); - HWIF(drive)->OUTB(0, IDE_SECTOR_REG); - - HWIF(drive)->OUTB(xferlen & 0xff, IDE_BCOUNTL_REG); - HWIF(drive)->OUTB(xferlen >> 8 , IDE_BCOUNTH_REG); + ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | + IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) { /* waiting for CDB interrupt, not DMA yet. */ diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index d4fd064..ff8232e 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1067,13 +1067,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) dma = !hwif->dma_setup(drive); - if (IDE_CONTROL_REG) - HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); - /* Use PIO/DMA */ - hwif->OUTB(dma, IDE_FEATURE_REG); - hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); - HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); + ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | + IDE_TFLAG_OUT_DEVICE, bcount, dma); if (dma) { /* Begin DMA, if necessary */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index d36df77..1ed7a86 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1734,3 +1734,19 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio } EXPORT_SYMBOL(ide_do_drive_cmd); + +void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) +{ + ide_task_t task; + + memset(&task, 0, sizeof(task)); + task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM | + IDE_TFLAG_OUT_FEATURE | tf_flags; + task.tf.feature = dma; /* Use PIO/DMA */ + task.tf.lbam = bcount & 0xff; + task.tf.lbah = (bcount >> 8) & 0xff; + + ide_tf_load(drive, &task); +} + +EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load); diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index d1f2446..3cbca3f 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -2171,12 +2171,9 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) dma_ok = !hwif->dma_setup(drive); - if (IDE_CONTROL_REG) - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - hwif->OUTB(dma_ok ? 1 : 0, IDE_FEATURE_REG); /* Use PIO/DMA */ - hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); - hwif->OUTB(drive->select.all, IDE_SELECT_REG); + ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | + IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); + if (dma_ok) /* Will begin DMA later */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 76f0ccd..02e9189 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -590,12 +590,8 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) } SELECT_DRIVE(drive); - if (IDE_CONTROL_REG) - HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); - hwif->OUTB(dma, IDE_FEATURE_REG); - hwif->OUTB(bcount & 0xff, IDE_BCOUNTL_REG); - hwif->OUTB((bcount >> 8) & 0xff, IDE_BCOUNTH_REG); + ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma); if (dma) set_bit(PC_DMA_OK, &pc->flags); diff --git a/include/linux/ide.h b/include/linux/ide.h index 790ffa7..20969eb 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -968,6 +968,8 @@ extern void QUIRK_LIST(ide_drive_t *); extern int drive_is_ready(ide_drive_t *); +void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); + /* * taskfile io for disks for now...and builds request from ide_ioctl */ -- cgit v0.10.2 From cd3dbc99da337f2130f3cb2691fbb65c8bf22337 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:13 +0100 Subject: ide: remove QUIRK_LIST() Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 6178880..b6983b7 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -189,12 +189,6 @@ void SELECT_MASK (ide_drive_t *drive, int mask) HWIF(drive)->maskproc(drive, mask); } -void QUIRK_LIST (ide_drive_t *drive) -{ - if (HWIF(drive)->quirkproc) - drive->quirk_list = HWIF(drive)->quirkproc(drive); -} - /* * Some localbus EIDE interfaces require a special access sequence * when using 32-bit I/O instructions to transfer data. We call this diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 8e5d8dd..33e62d2 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -234,7 +234,10 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) drive->media = ide_disk; printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" ); - QUIRK_LIST(drive); + + if (hwif->quirkproc) + drive->quirk_list = hwif->quirkproc(drive); + return; err_misc: diff --git a/include/linux/ide.h b/include/linux/ide.h index 20969eb..7a144c9 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -964,7 +964,6 @@ extern u32 ide_read_24(ide_drive_t *); extern void SELECT_DRIVE(ide_drive_t *); extern void SELECT_INTERRUPT(ide_drive_t *); extern void SELECT_MASK(ide_drive_t *, int); -extern void QUIRK_LIST(ide_drive_t *); extern int drive_is_ready(ide_drive_t *); -- cgit v0.10.2 From f919790f8c929ab1b392ad1a0c2e1b53337b5071 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:13 +0100 Subject: ide: remove SELECT_INTERRUPT() Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1ed7a86..6b70ab9 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1201,7 +1201,10 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) hwif != hwgroup->hwif && hwif->io_ports[IDE_CONTROL_OFFSET]) { /* set nIEN for previous hwif */ - SELECT_INTERRUPT(drive); + if (hwif->intrproc) + hwif->intrproc(drive); + else + hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG); } hwgroup->hwif = hwif; hwgroup->drive = drive; diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index b6983b7..1064542 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -175,14 +175,6 @@ void SELECT_DRIVE (ide_drive_t *drive) EXPORT_SYMBOL(SELECT_DRIVE); -void SELECT_INTERRUPT (ide_drive_t *drive) -{ - if (HWIF(drive)->intrproc) - HWIF(drive)->intrproc(drive); - else - HWIF(drive)->OUTB(drive->ctl|2, IDE_CONTROL_REG); -} - void SELECT_MASK (ide_drive_t *drive, int mask) { if (HWIF(drive)->maskproc) diff --git a/include/linux/ide.h b/include/linux/ide.h index 7a144c9..e803518 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -962,7 +962,6 @@ void ide_tf_load(ide_drive_t *, ide_task_t *); extern u32 ide_read_24(ide_drive_t *); extern void SELECT_DRIVE(ide_drive_t *); -extern void SELECT_INTERRUPT(ide_drive_t *); extern void SELECT_MASK(ide_drive_t *, int); extern int drive_is_ready(ide_drive_t *); -- cgit v0.10.2 From 7299a3918442dc9a5abb71b9f65b1dd17637c8c0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:14 +0100 Subject: ide: remove hwif->intrproc Given that: * hpt366.c::hpt3xx_intrproc() is the only user of hwif->intrproc * hpt366.c::hpt3xx_quirkproc() sets drive->quirk_list to 1 for quirky drives which is a value unique to hpt366 host driver we can remove hwif->intproc and just check for drive->quirk_list == 1 in ide_do_request(). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 6b70ab9..6ee7458 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1200,10 +1200,11 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) if (hwgroup->hwif->sharing_irq && hwif != hwgroup->hwif && hwif->io_ports[IDE_CONTROL_OFFSET]) { - /* set nIEN for previous hwif */ - if (hwif->intrproc) - hwif->intrproc(drive); - else + /* + * set nIEN for previous hwif, drives in the + * quirk_list may not like intr setups/cleanups + */ + if (drive->quirk_list != 1) hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG); } hwgroup->hwif = hwif; diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 9ab5458..4acd87e 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -424,7 +424,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) hwif->reset_poll = tmp_hwif->reset_poll; hwif->pre_reset = tmp_hwif->pre_reset; hwif->resetproc = tmp_hwif->resetproc; - hwif->intrproc = tmp_hwif->intrproc; hwif->maskproc = tmp_hwif->maskproc; hwif->quirkproc = tmp_hwif->quirkproc; hwif->busproc = tmp_hwif->busproc; diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index d3826a6..24d6457 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -736,15 +736,6 @@ static int hpt3xx_quirkproc(ide_drive_t *drive) return 0; } -static void hpt3xx_intrproc(ide_drive_t *drive) -{ - if (drive->quirk_list) - return; - - /* drives in the quirk_list may not like intr setups/cleanups */ - outb(drive->ctl | 2, IDE_CONTROL_REG); -} - static void hpt3xx_maskproc(ide_drive_t *drive, int mask) { ide_hwif_t *hwif = HWIF(drive); @@ -1298,7 +1289,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->set_dma_mode = &hpt3xx_set_mode; hwif->quirkproc = &hpt3xx_quirkproc; - hwif->intrproc = &hpt3xx_intrproc; hwif->maskproc = &hpt3xx_maskproc; hwif->busproc = &hpt3xx_busproc; diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index de820aa..7e9dade 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c @@ -582,7 +582,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif) hwif->pre_reset = NULL; /* No HBA specific pre_set needed */ hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine, clear interrupts */ - hwif->intrproc = NULL; /* Enable or Disable interrupt from drive */ hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */ hwif->quirkproc = NULL; hwif->busproc = NULL; diff --git a/include/linux/ide.h b/include/linux/ide.h index e803518..90f83b6 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -524,8 +524,6 @@ typedef struct hwif_s { void (*pre_reset)(ide_drive_t *); /* routine to reset controller after a disk reset */ void (*resetproc)(ide_drive_t *); - /* special interrupt handling for shared pci interrupts */ - void (*intrproc)(ide_drive_t *); /* special host masking for drive selection */ void (*maskproc)(ide_drive_t *, int); /* check host's drive quirk list */ -- cgit v0.10.2 From ac026ff254b32915bb14ba97a23b4019d137f181 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:14 +0100 Subject: ide: remove 'command_type' field from ide_task_t * Add 'data_buf' and 'nsect' variables in ide_taskfile_ioctl() to cache data buffer pointer and number of sectors to transfer (this allows us to have only one ide_diag_taskfile() call). * Add IDE_TFLAG_WRITE taskfile flag and use it to check whether the REQ_RW request flag should be set. * Move ->command_type handling from ide_diag_taskfile() to ide_taskfile_ioctl() and use ->req_cmd instead of ->command_type. * Add 'nsect' parameter to ide_raw_taskfile(). * Merge ide_diag_taskfile() into ide_raw_taskfile(). * Initialize ->data_phase explicitly in idedisk_prepare_flush(), ide_start_power_step() and ide_disk_special(). * Remove no longer needed 'command_type' field from ide_task_t. * Add #ifndef/#endif __KERNEL__ to around no longer used by kernel IDE_DRIVE_TASK_* and TASKFILE_* defines. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 747dc60..d9a4fe2 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -516,12 +516,11 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) tf->lbam = SMART_LCYL_PASS; tf->lbah = SMART_HCYL_PASS; tf->command = WIN_SMART; - args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - args.command_type = IDE_DRIVE_TASK_IN; - args.data_phase = TASKFILE_IN; - args.handler = &task_in_intr; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + args.data_phase = TASKFILE_IN; + args.handler = task_in_intr; (void) smart_enable(drive); - return ide_raw_taskfile(drive, &args, buf); + return ide_raw_taskfile(drive, &args, buf, 1); } static int proc_idedisk_read_cache @@ -607,9 +606,9 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) task.tf.command = WIN_FLUSH_CACHE_EXT; else task.tf.command = WIN_FLUSH_CACHE; - task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - task.command_type = IDE_DRIVE_TASK_NO_DATA; - task.handler = task_no_data_intr; + task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + task.data_phase = TASKFILE_NO_DATA; + task.handler = task_no_data_intr; rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_flags |= REQ_SOFTBARRIER; diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 6ee7458..f4f7e3d 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -232,9 +232,9 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * return ide_stopped; out_do_tf: - args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - args->command_type = IDE_DRIVE_TASK_NO_DATA; - args->handler = task_no_data_intr; + args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + args->data_phase = TASKFILE_NO_DATA; + args->handler = task_no_data_intr; return do_rw_taskfile(drive, args); } @@ -672,7 +672,7 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) ide_task_t args; memset(&args, 0, sizeof(ide_task_t)); - args.command_type = IDE_DRIVE_TASK_NO_DATA; + args.data_phase = TASKFILE_NO_DATA; if (s->b.set_geometry) { s->b.set_geometry = 0; diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 7c8e980..ff28449 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -126,11 +126,10 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) args.tf.command = WIN_IDENTIFY; else args.tf.command = WIN_PIDENTIFY; - args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; - args.command_type = IDE_DRIVE_TASK_IN; - args.data_phase = TASKFILE_IN; - args.handler = &task_in_intr; - return ide_raw_taskfile(drive, &args, buf); + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + args.data_phase = TASKFILE_IN; + args.handler = task_in_intr; + return ide_raw_taskfile(drive, &args, buf, 1); } static int inline task_dma_ok(ide_task_t *task) @@ -499,7 +498,7 @@ ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq) } EXPORT_SYMBOL(pre_task_out_intr); -static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf) +int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) { struct request rq; @@ -514,44 +513,26 @@ static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long * if we would find a solution to transfer any size. * To support special commands like READ LONG. */ - if (args->command_type != IDE_DRIVE_TASK_NO_DATA) { - if (data_size == 0) - rq.nr_sectors = (args->tf.hob_nsect << 8) | args->tf.nsect; - else - rq.nr_sectors = data_size / SECTOR_SIZE; - - if (!rq.nr_sectors) { - printk(KERN_ERR "%s: in/out command without data\n", - drive->name); - return -EFAULT; - } + rq.hard_nr_sectors = rq.nr_sectors = nsect; + rq.hard_cur_sectors = rq.current_nr_sectors = nsect; - rq.hard_nr_sectors = rq.nr_sectors; - rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors; + if (task->tf_flags & IDE_TFLAG_WRITE) + rq.cmd_flags |= REQ_RW; - if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE) - rq.cmd_flags |= REQ_RW; - } + rq.special = task; + task->rq = &rq; - rq.special = args; - args->rq = &rq; return ide_do_drive_cmd(drive, &rq, ide_wait); } -int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf) -{ - return ide_diag_taskfile(drive, args, 0, buf); -} - EXPORT_SYMBOL(ide_raw_taskfile); int ide_no_data_taskfile(ide_drive_t *drive, ide_task_t *task) { - task->command_type = IDE_DRIVE_TASK_NO_DATA; - task->data_phase = TASKFILE_NO_DATA; - task->handler = task_no_data_intr; + task->data_phase = TASKFILE_NO_DATA; + task->handler = task_no_data_intr; - return ide_raw_taskfile(drive, task, NULL); + return ide_raw_taskfile(drive, task, NULL, 0); } EXPORT_SYMBOL_GPL(ide_no_data_taskfile); @@ -562,10 +543,12 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ide_task_t args; u8 *outbuf = NULL; u8 *inbuf = NULL; + u8 *data_buf = NULL; int err = 0; int tasksize = sizeof(struct ide_task_request_s); unsigned int taskin = 0; unsigned int taskout = 0; + u16 nsect = 0; u8 io_32bit = drive->io_32bit; char __user *buf = (char __user *)arg; @@ -618,7 +601,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) memcpy(&args.tf_array[6], req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); args.tf_in_flags = req_task->in_flags; args.data_phase = req_task->data_phase; - args.command_type = req_task->req_cmd; args.tf_flags = IDE_TFLAG_OUT_DEVICE; if (drive->addressing == 1) @@ -657,14 +639,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) drive->io_32bit = 0; switch(req_task->data_phase) { - case TASKFILE_OUT_DMAQ: - case TASKFILE_OUT_DMA: - err = ide_diag_taskfile(drive, &args, taskout, outbuf); - break; - case TASKFILE_IN_DMAQ: - case TASKFILE_IN_DMA: - err = ide_diag_taskfile(drive, &args, taskin, inbuf); - break; case TASKFILE_MULTI_OUT: if (!drive->mult_count) { /* (hs): give up if multcount is not set */ @@ -678,7 +652,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) case TASKFILE_OUT: args.prehandler = &pre_task_out_intr; args.handler = &task_out_intr; - err = ide_diag_taskfile(drive, &args, taskout, outbuf); + /* fall through */ + case TASKFILE_OUT_DMAQ: + case TASKFILE_OUT_DMA: + nsect = taskout / SECTOR_SIZE; + data_buf = outbuf; break; case TASKFILE_MULTI_IN: if (!drive->mult_count) { @@ -692,17 +670,38 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) /* fall through */ case TASKFILE_IN: args.handler = &task_in_intr; - err = ide_diag_taskfile(drive, &args, taskin, inbuf); + /* fall through */ + case TASKFILE_IN_DMAQ: + case TASKFILE_IN_DMA: + nsect = taskin / SECTOR_SIZE; + data_buf = inbuf; break; case TASKFILE_NO_DATA: args.handler = &task_no_data_intr; - err = ide_diag_taskfile(drive, &args, 0, NULL); break; default: err = -EFAULT; goto abort; } + if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA) + nsect = 0; + else if (!nsect) { + nsect = (args.tf.hob_nsect << 8) | args.tf.nsect; + + if (!nsect) { + printk(KERN_ERR "%s: in/out command without data\n", + drive->name); + err = -EFAULT; + goto abort; + } + } + + if (req_task->req_cmd == IDE_DRIVE_TASK_RAW_WRITE) + args.tf_flags |= IDE_TFLAG_WRITE; + + err = ide_raw_taskfile(drive, &args, data_buf, nsect); + memcpy(req_task->hob_ports, &args.tf_array[0], HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(req_task->io_ports, &args.tf_array[6], HDIO_DRIVE_TASK_HDR_SIZE); req_task->in_flags = args.tf_in_flags; diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index 0521f12..ff43f8d 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -73,13 +73,13 @@ #define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8)) #define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8)) -#define IDE_DRIVE_TASK_INVALID -1 #define IDE_DRIVE_TASK_NO_DATA 0 +#ifndef __KERNEL__ +#define IDE_DRIVE_TASK_INVALID -1 #define IDE_DRIVE_TASK_SET_XFER 1 - #define IDE_DRIVE_TASK_IN 2 - #define IDE_DRIVE_TASK_OUT 3 +#endif #define IDE_DRIVE_TASK_RAW_WRITE 4 /* @@ -166,9 +166,6 @@ typedef struct hd_drive_hob_hdr { } hob_struct_t; #endif -#define TASKFILE_INVALID 0x7fff -#define TASKFILE_48 0x8000 - #define TASKFILE_NO_DATA 0x0000 #define TASKFILE_IN 0x0001 @@ -183,12 +180,16 @@ typedef struct hd_drive_hob_hdr { #define TASKFILE_IN_DMAQ 0x0080 #define TASKFILE_OUT_DMAQ 0x0100 +#ifndef __KERNEL__ #define TASKFILE_P_IN 0x0200 #define TASKFILE_P_OUT 0x0400 #define TASKFILE_P_IN_DMA 0x0800 #define TASKFILE_P_OUT_DMA 0x1000 #define TASKFILE_P_IN_DMAQ 0x2000 #define TASKFILE_P_OUT_DMAQ 0x4000 +#define TASKFILE_48 0x8000 +#define TASKFILE_INVALID 0x7fff +#endif /* ATA/ATAPI Commands pre T13 Spec */ #define WIN_NOP 0x00 diff --git a/include/linux/ide.h b/include/linux/ide.h index 90f83b6..7485fc7 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -909,6 +909,7 @@ enum { IDE_TFLAG_OUT_LBAM | IDE_TFLAG_OUT_LBAH, IDE_TFLAG_OUT_DEVICE = (1 << 14), + IDE_TFLAG_WRITE = (1 << 15), }; struct ide_taskfile { @@ -948,7 +949,6 @@ typedef struct ide_task_s { u16 tf_flags; ide_reg_valid_t tf_in_flags; int data_phase; - int command_type; ide_pre_handler_t *prehandler; ide_handler_t *handler; struct request *rq; /* copy of request */ @@ -983,8 +983,7 @@ extern ide_startstop_t task_no_data_intr(ide_drive_t *); extern ide_startstop_t task_in_intr(ide_drive_t *); extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); -extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *); - +int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); -- cgit v0.10.2 From 866e2ec9ce525de0e7c10d02ead8d85af27adffd Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:14 +0100 Subject: ide: remove 'tf_in_flags' field from ide_task_t * Add IDE_TFLAG_IN_DATA taskfile flag to indicate the need of reading IDE_DATA_REG in ide_end_drive_cmd(). Set the new flag in ide_taskfile_ioctl() if ->in_flags.b.data is set. * Add IDE_TFLAG_FLAGGED_SET_IN_FLAGS taskfile flag to indicate the need of modifying ->in_flags in ide_taskfile_ioctl(). Set the new flag in flagged_taskfile() and move the code modifying ->tf_in_flags to ide_taskfile_ioctl(). While at it remove the bogus comment: ->tf_in_flags (except .b.data) have no effect on selection of registers to read. * Remove no longer needed 'tf_in_flags' field from ide_task_t. As the result we finally have the internals of HDIO_DRIVE_TASKFILE ioctl separated from the core IDE code. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index f4f7e3d..1112d8b 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -340,7 +340,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) if (args) { struct ide_taskfile *tf = &args->tf; - if (args->tf_in_flags.b.data) { + if (args->tf_flags & IDE_TFLAG_IN_DATA) { u16 data = hwif->INW(IDE_DATA_REG); tf->data = data & 0xff; diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index ff28449..03c4a0c 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -599,8 +599,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) memcpy(&args.tf_array[0], req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(&args.tf_array[6], req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); - args.tf_in_flags = req_task->in_flags; - args.data_phase = req_task->data_phase; + + args.data_phase = req_task->data_phase; args.tf_flags = IDE_TFLAG_OUT_DEVICE; if (drive->addressing == 1) @@ -637,6 +637,9 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) args.tf_flags |= IDE_TFLAG_OUT_HOB; } + if (req_task->in_flags.b.data) + args.tf_flags |= IDE_TFLAG_IN_DATA; + drive->io_32bit = 0; switch(req_task->data_phase) { case TASKFILE_MULTI_OUT: @@ -704,7 +707,13 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) memcpy(req_task->hob_ports, &args.tf_array[0], HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(req_task->io_ports, &args.tf_array[6], HDIO_DRIVE_TASK_HDR_SIZE); - req_task->in_flags = args.tf_in_flags; + + if ((args.tf_flags & IDE_TFLAG_FLAGGED_SET_IN_FLAGS) && + req_task->in_flags.all == 0) { + req_task->in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; + if (drive->addressing == 1) + req_task->in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8); + } if (copy_to_user(buf, req_task, tasksize)) { err = -EFAULT; @@ -846,19 +855,7 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) } } - /* - * (ks) Check taskfile in flags. - * If set, then execute as it is defined. - * If not set, then define default settings. - * The default values are: - * read all taskfile registers (except data) - * read the hob registers (sector, nsector, lcyl, hcyl) - */ - if (task->tf_in_flags.all == 0) { - task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; - if (drive->addressing == 1) - task->tf_in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8); - } + task->tf_flags |= IDE_TFLAG_FLAGGED_SET_IN_FLAGS; return do_rw_taskfile(drive, task); } diff --git a/include/linux/ide.h b/include/linux/ide.h index 7485fc7..c23ef2d 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -910,6 +910,8 @@ enum { IDE_TFLAG_OUT_LBAH, IDE_TFLAG_OUT_DEVICE = (1 << 14), IDE_TFLAG_WRITE = (1 << 15), + IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), + IDE_TFLAG_IN_DATA = (1 << 17), }; struct ide_taskfile { @@ -946,8 +948,7 @@ typedef struct ide_task_s { struct ide_taskfile tf; u8 tf_array[14]; }; - u16 tf_flags; - ide_reg_valid_t tf_in_flags; + u32 tf_flags; int data_phase; ide_pre_handler_t *prehandler; ide_handler_t *handler; -- cgit v0.10.2 From 7c0e26661dd104aaeb1391063cc986ddc0ac4aa4 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:14 +0100 Subject: sc1200: remove pointless hwif lookup loop Save PCI regs values for both IDE ports in one buffer, in order to eliminate a needless and ugly loop across all hwifs, searching for our PCI device. Partially based on the previous patch by Jeff Garzik. Cc: Jeff Garzik Cc: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 707d5ff..f0029b3 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c @@ -260,66 +260,39 @@ static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) } #ifdef CONFIG_PM -static ide_hwif_t *lookup_pci_dev (ide_hwif_t *prev, struct pci_dev *dev) -{ - int h; - - for (h = 0; h < MAX_HWIFS; h++) { - ide_hwif_t *hwif = &ide_hwifs[h]; - if (prev) { - if (hwif == prev) - prev = NULL; // found previous, now look for next match - } else { - if (hwif && hwif->pci_dev == dev) - return hwif; // found next match - } - } - return NULL; // not found -} - -typedef struct sc1200_saved_state_s { - __u32 regs[4]; -} sc1200_saved_state_t; - +struct sc1200_saved_state { + u32 regs[8]; +}; static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) { - ide_hwif_t *hwif = NULL; - printk("SC1200: suspend(%u)\n", state.event); + /* + * we only save state when going from full power to less + */ if (state.event == PM_EVENT_ON) { - // we only save state when going from full power to less - - // - // Loop over all interfaces that are part of this PCI device: - // - while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) { - sc1200_saved_state_t *ss; - unsigned int basereg, r; - // - // allocate a permanent save area, if not already allocated - // - ss = (sc1200_saved_state_t *)hwif->config_data; - if (ss == NULL) { - ss = kmalloc(sizeof(sc1200_saved_state_t), GFP_KERNEL); - if (ss == NULL) - return -ENOMEM; - hwif->config_data = (unsigned long)ss; - } - ss = (sc1200_saved_state_t *)hwif->config_data; - // - // Save timing registers: this may be unnecessary if - // BIOS also does it - // - basereg = hwif->channel ? 0x50 : 0x40; - for (r = 0; r < 4; ++r) { - pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]); - } + struct sc1200_saved_state *ss; + unsigned int r; + + /* + * allocate a permanent save area, if not already allocated + */ + ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); + if (ss == NULL) { + ss = kmalloc(sizeof(*ss), GFP_KERNEL); + if (ss == NULL) + return -ENOMEM; + pci_set_drvdata(dev, ss); } - } - /* You don't need to iterate over disks -- sysfs should have done that for you already */ + /* + * save timing registers + * (this may be unnecessary if BIOS also does it) + */ + for (r = 0; r < 8; r++) + pci_read_config_dword(dev, 0x40 + r * 4, &ss->regs[r]); + } pci_disable_device(dev); pci_set_power_state(dev, pci_choose_state(dev, state)); @@ -328,30 +301,25 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) static int sc1200_resume (struct pci_dev *dev) { - ide_hwif_t *hwif = NULL; - int i; + struct sc1200_saved_state *ss; + unsigned int r; + int i; i = pci_enable_device(dev); if (i) return i; - // - // loop over all interfaces that are part of this pci device: - // - while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) { - unsigned int basereg, r; - sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data; - - // - // Restore timing registers: this may be unnecessary if BIOS also does it - // - basereg = hwif->channel ? 0x50 : 0x40; - if (ss != NULL) { - for (r = 0; r < 4; ++r) { - pci_write_config_dword(hwif->pci_dev, basereg + (r<<2), ss->regs[r]); - } - } + ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); + + /* + * restore timing registers + * (this may be unnecessary if BIOS also does it) + */ + if (ss) { + for (r = 0; r < 8; r++) + pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]); } + return 0; } #endif -- cgit v0.10.2 From cf77249ee1a37aab37f39ea1dde9a53c23693655 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:15 +0100 Subject: ide-disk: fix __ide_do_rw_disk() to use ->OUTBSYNC Fix __ide_do_rw_disk() to use ->OUTBSYNC instead of ->OUTB (needed for pmac and scc_pata host drivers). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index d9a4fe2..7b4f677 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -247,8 +247,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, command = lba48 ? WIN_WRITE_EXT : WIN_WRITE; } - /* FIXME: ->OUTBSYNC ? */ - hwif->OUTB(command, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, command, IDE_COMMAND_REG); return pre_task_out_intr(drive, rq); } -- cgit v0.10.2 From a7bbd20b50fb12b3a604c396b3d8a3449a43edcc Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:15 +0100 Subject: ide-disk: guarantee 400ns delay after writing command register Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 7b4f677..424207e 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -248,6 +248,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, } hwif->OUTBSYNC(drive, command, IDE_COMMAND_REG); + ndelay(400); /* FIXME */ return pre_task_out_intr(drive, rq); } -- cgit v0.10.2 From 1edee60e9d994f2b9a79b1333be39790683541fe Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:15 +0100 Subject: ide: merge flagged_taskfile() into do_rw_taskfile() Based on the earlier work by Tejun Heo. task->data_phase == TASKFILE_MULTI_{IN,OUT} vs drive->mult_count == 0 check is needed also for ide_taskfile_ioctl() requests that don't have IDE_TFLAG_FLAGGED taskfile flag set. Cc: Tejun Heo Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1112d8b..1af2cc4 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -851,9 +851,6 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, break; } - if (task->tf_flags & IDE_TFLAG_FLAGGED) - return flagged_taskfile(drive, task); - return do_rw_taskfile(drive, task); } diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 03c4a0c..1a34edb 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -156,6 +156,18 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) ide_hwif_t *hwif = HWIF(drive); struct ide_taskfile *tf = &task->tf; + if (task->data_phase == TASKFILE_MULTI_IN || + task->data_phase == TASKFILE_MULTI_OUT) { + if (!drive->mult_count) { + printk(KERN_ERR "%s: multimode not set!\n", + drive->name); + return ide_stopped; + } + } + + if (task->tf_flags & IDE_TFLAG_FLAGGED) + task->tf_flags |= IDE_TFLAG_FLAGGED_SET_IN_FLAGS; + ide_tf_load(drive, task); if (task->handler != NULL) { @@ -839,23 +851,3 @@ int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) return err; } - -/* - * NOTICE: This is additions from IBM to provide a discrete interface, - * for selective taskregister access operations. Nice JOB Klaus!!! - * Glad to be able to work and co-develop this with you and IBM. - */ -ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) -{ - if (task->data_phase == TASKFILE_MULTI_IN || - task->data_phase == TASKFILE_MULTI_OUT) { - if (!drive->mult_count) { - printk(KERN_ERR "%s: multimode not set!\n", drive->name); - return ide_stopped; - } - } - - task->tf_flags |= IDE_TFLAG_FLAGGED_SET_IN_FLAGS; - - return do_rw_taskfile(drive, task); -} diff --git a/include/linux/ide.h b/include/linux/ide.h index c23ef2d..8494475 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -972,11 +972,6 @@ void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); */ extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); -/* - * Special Flagged Register Validation Caller - */ -extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *); - extern ide_startstop_t set_multmode_intr(ide_drive_t *); extern ide_startstop_t set_geometry_intr(ide_drive_t *); extern ide_startstop_t recal_intr(ide_drive_t *); -- cgit v0.10.2 From 10d90157c83d4b6743c9063c36f9e7f27aa254b6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide: convert do_rw_taskfile() to use ->data_phase * Use task->data_phase in do_rw_taskfile() to decide what to do. * task->prehandler is only used by TASKFILE[_MULTI]_OUT so just use pre_task_out_intr() directly and remove no longer needed 'prehandler' field from ide_task_t. * Remove no longer needed ide_pre_handler_t type. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 1a34edb..5f6d01a 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -170,23 +170,25 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) ide_tf_load(drive, task); - if (task->handler != NULL) { - if (task->prehandler != NULL) { - hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); - ndelay(400); /* FIXME */ - return task->prehandler(drive, task->rq); - } + switch (task->data_phase) { + case TASKFILE_MULTI_OUT: + case TASKFILE_OUT: + hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); + ndelay(400); /* FIXME */ + return pre_task_out_intr(drive, task->rq); + case TASKFILE_MULTI_IN: + case TASKFILE_IN: + case TASKFILE_NO_DATA: ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); return ide_started; - } - - if (task_dma_ok(task) && drive->using_dma && !hwif->dma_setup(drive)) { + default: + if (task_dma_ok(task) == 0 || drive->using_dma == 0 || + hwif->dma_setup(drive)) + return ide_stopped; hwif->dma_exec_cmd(drive, tf->command); hwif->dma_start(drive); return ide_started; } - - return ide_stopped; } /* @@ -665,7 +667,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) } /* fall through */ case TASKFILE_OUT: - args.prehandler = &pre_task_out_intr; args.handler = &task_out_intr; /* fall through */ case TASKFILE_OUT_DMAQ: diff --git a/include/linux/ide.h b/include/linux/ide.h index 8494475..2c28fb7 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -626,7 +626,6 @@ typedef struct hwif_s { /* * internal ide interrupt handler type */ -typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *); typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); typedef int (ide_expiry_t)(ide_drive_t *); @@ -950,7 +949,6 @@ typedef struct ide_task_s { }; u32 tf_flags; int data_phase; - ide_pre_handler_t *prehandler; ide_handler_t *handler; struct request *rq; /* copy of request */ void *special; /* valid_t generally */ -- cgit v0.10.2 From 1192e528e064ebb9a578219731d2b0f78ca3c1ec Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide: use ->data_phase to set ->handler in do_rw_taskfile() * Use ->data_phase to set ->handler in do_rw_taskfile() instead of setting ->handler in callers of ide_raw_taskfile()/do_rw_taskfile(). * Unexport task_no_data_intr() and make it static. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 424207e..a063957 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -518,7 +518,6 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) tf->command = WIN_SMART; args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args.data_phase = TASKFILE_IN; - args.handler = task_in_intr; (void) smart_enable(drive); return ide_raw_taskfile(drive, &args, buf, 1); } @@ -608,7 +607,6 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) task.tf.command = WIN_FLUSH_CACHE; task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; task.data_phase = TASKFILE_NO_DATA; - task.handler = task_no_data_intr; rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_flags |= REQ_SOFTBARRIER; diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1af2cc4..18ac1bd 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -234,7 +234,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * out_do_tf: args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args->data_phase = TASKFILE_NO_DATA; - args->handler = task_no_data_intr; return do_rw_taskfile(drive, args); } diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 5f6d01a..835465d 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -128,7 +128,6 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) args.tf.command = WIN_PIDENTIFY; args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args.data_phase = TASKFILE_IN; - args.handler = task_in_intr; return ide_raw_taskfile(drive, &args, buf, 1); } @@ -151,6 +150,9 @@ static int inline task_dma_ok(ide_task_t *task) return 0; } +static ide_startstop_t task_no_data_intr(ide_drive_t *); +static ide_startstop_t task_out_intr(ide_drive_t *); + ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); @@ -173,12 +175,18 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) switch (task->data_phase) { case TASKFILE_MULTI_OUT: case TASKFILE_OUT: + task->handler = task_out_intr; hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); ndelay(400); /* FIXME */ return pre_task_out_intr(drive, task->rq); case TASKFILE_MULTI_IN: case TASKFILE_IN: + task->handler = task_in_intr; + /* fall-through */ case TASKFILE_NO_DATA: + /* WIN_{SPECIFY,RESTORE,SETMULT} use custom handlers */ + if (task->handler == NULL) + task->handler = task_no_data_intr; ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); return ide_started; default: @@ -248,7 +256,7 @@ 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) +static ide_startstop_t task_no_data_intr(ide_drive_t *drive) { ide_task_t *args = HWGROUP(drive)->rq->special; ide_hwif_t *hwif = HWIF(drive); @@ -544,7 +552,6 @@ EXPORT_SYMBOL(ide_raw_taskfile); int ide_no_data_taskfile(ide_drive_t *drive, ide_task_t *task) { task->data_phase = TASKFILE_NO_DATA; - task->handler = task_no_data_intr; return ide_raw_taskfile(drive, task, NULL, 0); } @@ -667,7 +674,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) } /* fall through */ case TASKFILE_OUT: - args.handler = &task_out_intr; /* fall through */ case TASKFILE_OUT_DMAQ: case TASKFILE_OUT_DMA: @@ -685,7 +691,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) } /* fall through */ case TASKFILE_IN: - args.handler = &task_in_intr; /* fall through */ case TASKFILE_IN_DMAQ: case TASKFILE_IN_DMA: @@ -693,7 +698,6 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) data_buf = inbuf; break; case TASKFILE_NO_DATA: - args.handler = &task_no_data_intr; break; default: err = -EFAULT; diff --git a/include/linux/ide.h b/include/linux/ide.h index 2c28fb7..5d675f1 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -973,7 +973,6 @@ extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); extern ide_startstop_t set_multmode_intr(ide_drive_t *); extern ide_startstop_t set_geometry_intr(ide_drive_t *); extern ide_startstop_t recal_intr(ide_drive_t *); -extern ide_startstop_t task_no_data_intr(ide_drive_t *); extern ide_startstop_t task_in_intr(ide_drive_t *); extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); -- cgit v0.10.2 From 57d7366b78b74a9eef873e8212c03d8c2033a764 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide: remove 'handler' field from ide_task_t (take 2) * Add IDE_TFLAG_CUSTOM_HANDLER taskfile flag and use it for internal requests which require custom handlers. Check the flag in do_rw_taskfile() and set handler accordingly. * Cleanup ide_init_{specify,restore,setmult}_cmd() and rename it to ide_tf_set_{specify,restore,setmult}_cmd(). * Make {set_geometry,recal,set_multmode}_intr() static. * Remove no longer needed 'handler' field from ide_task_t. v2: * 'handler' in do_rw_taskfile() must be set to NULL initially. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 18ac1bd..48c38b6 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -637,32 +637,26 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive) return ide_stopped; } -static void ide_init_specify_cmd(ide_drive_t *drive, ide_task_t *task) +static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) { - task->tf.nsect = drive->sect; - task->tf.lbal = drive->sect; - task->tf.lbam = drive->cyl; - task->tf.lbah = drive->cyl >> 8; - task->tf.device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; - task->tf.command = WIN_SPECIFY; - - task->handler = &set_geometry_intr; + tf->nsect = drive->sect; + tf->lbal = drive->sect; + tf->lbam = drive->cyl; + tf->lbah = drive->cyl >> 8; + tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; + tf->command = WIN_SPECIFY; } -static void ide_init_restore_cmd(ide_drive_t *drive, ide_task_t *task) +static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf) { - task->tf.nsect = drive->sect; - task->tf.command = WIN_RESTORE; - - task->handler = &recal_intr; + tf->nsect = drive->sect; + tf->command = WIN_RESTORE; } -static void ide_init_setmult_cmd(ide_drive_t *drive, ide_task_t *task) +static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) { - task->tf.nsect = drive->mult_req; - task->tf.command = WIN_SETMULT; - - task->handler = &set_multmode_intr; + tf->nsect = drive->mult_req; + tf->command = WIN_SETMULT; } static ide_startstop_t ide_disk_special(ide_drive_t *drive) @@ -675,15 +669,15 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) if (s->b.set_geometry) { s->b.set_geometry = 0; - ide_init_specify_cmd(drive, &args); + ide_tf_set_specify_cmd(drive, &args.tf); } else if (s->b.recalibrate) { s->b.recalibrate = 0; - ide_init_restore_cmd(drive, &args); + ide_tf_set_restore_cmd(drive, &args.tf); } else if (s->b.set_multmode) { s->b.set_multmode = 0; if (drive->mult_req > drive->id->max_multsect) drive->mult_req = drive->id->max_multsect; - ide_init_setmult_cmd(drive, &args); + ide_tf_set_setmult_cmd(drive, &args.tf); } else if (s->all) { int special = s->all; s->all = 0; @@ -691,7 +685,8 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) return ide_stopped; } - args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; + args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | + IDE_TFLAG_CUSTOM_HANDLER; do_rw_taskfile(drive, &args); diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 835465d..236f91f 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -151,12 +151,15 @@ static int inline task_dma_ok(ide_task_t *task) } static ide_startstop_t task_no_data_intr(ide_drive_t *); -static ide_startstop_t task_out_intr(ide_drive_t *); +static ide_startstop_t set_geometry_intr(ide_drive_t *); +static ide_startstop_t recal_intr(ide_drive_t *); +static ide_startstop_t set_multmode_intr(ide_drive_t *); ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); struct ide_taskfile *tf = &task->tf; + ide_handler_t *handler = NULL; if (task->data_phase == TASKFILE_MULTI_IN || task->data_phase == TASKFILE_MULTI_OUT) { @@ -175,19 +178,26 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) switch (task->data_phase) { case TASKFILE_MULTI_OUT: case TASKFILE_OUT: - task->handler = task_out_intr; hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); ndelay(400); /* FIXME */ return pre_task_out_intr(drive, task->rq); case TASKFILE_MULTI_IN: case TASKFILE_IN: - task->handler = task_in_intr; + handler = task_in_intr; /* fall-through */ case TASKFILE_NO_DATA: + if (handler == NULL) + handler = task_no_data_intr; /* WIN_{SPECIFY,RESTORE,SETMULT} use custom handlers */ - if (task->handler == NULL) - task->handler = task_no_data_intr; - ide_execute_command(drive, tf->command, task->handler, WAIT_WORSTCASE, NULL); + if (task->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) { + switch (tf->command) { + case WIN_SPECIFY: handler = set_geometry_intr; break; + case WIN_RESTORE: handler = recal_intr; break; + case WIN_SETMULT: handler = set_multmode_intr; break; + } + } + ide_execute_command(drive, tf->command, handler, + WAIT_WORSTCASE, NULL); return ide_started; default: if (task_dma_ok(task) == 0 || drive->using_dma == 0 || @@ -202,7 +212,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) /* * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd. */ -ide_startstop_t set_multmode_intr (ide_drive_t *drive) +static ide_startstop_t set_multmode_intr(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); u8 stat; @@ -220,7 +230,7 @@ ide_startstop_t set_multmode_intr (ide_drive_t *drive) /* * set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd. */ -ide_startstop_t set_geometry_intr (ide_drive_t *drive) +static ide_startstop_t set_geometry_intr(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); int retries = 5; @@ -243,7 +253,7 @@ ide_startstop_t set_geometry_intr (ide_drive_t *drive) /* * recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd. */ -ide_startstop_t recal_intr (ide_drive_t *drive) +static ide_startstop_t recal_intr(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); u8 stat; diff --git a/include/linux/ide.h b/include/linux/ide.h index 5d675f1..721c9d8 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -911,6 +911,7 @@ enum { IDE_TFLAG_WRITE = (1 << 15), IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), IDE_TFLAG_IN_DATA = (1 << 17), + IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), }; struct ide_taskfile { @@ -949,7 +950,6 @@ typedef struct ide_task_s { }; u32 tf_flags; int data_phase; - ide_handler_t *handler; struct request *rq; /* copy of request */ void *special; /* valid_t generally */ } ide_task_t; @@ -970,9 +970,6 @@ void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); */ extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); -extern ide_startstop_t set_multmode_intr(ide_drive_t *); -extern ide_startstop_t set_geometry_intr(ide_drive_t *); -extern ide_startstop_t recal_intr(ide_drive_t *); extern ide_startstop_t task_in_intr(ide_drive_t *); extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); -- cgit v0.10.2 From c52ea915d7fdc96819964b32eb124b5ccd22b9af Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide-disk: extend timeout for PIO-in commands s/WAIT_CMD/WAIT_WORSTCASE/ to make the timeout the same as in do_rw_taskfile() Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index a063957..851374e 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -236,7 +236,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, command = lba48 ? WIN_READ_EXT : WIN_READ; } - ide_execute_command(drive, command, &task_in_intr, WAIT_CMD, NULL); + ide_execute_command(drive, command, &task_in_intr, + WAIT_WORSTCASE, NULL); return ide_started; } else { if (drive->mult_count) { -- cgit v0.10.2 From ba76ae3883ad9faa32a6b35271c6a407d6c96ca9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide-disk: add ide_tf_set_cmd() helper * Add ide_tf_set_cmd() helper for selecting/setting command and data phase (note: DMA data phases are there for completness, they are not required ATM). * Set IDE_TFLAG_WRITE taskfile flag for write requests in __ide_do_rw_disk(). * Convert __ide_do_rw_disk() to use the new ide_tf_set_cmd() helper. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 851374e..97abc91 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -129,6 +129,50 @@ static int lba_capacity_is_ok (struct hd_driveid *id) return 0; /* lba_capacity value may be bad */ } +static const u8 ide_rw_cmds[] = { + WIN_MULTREAD, + WIN_MULTWRITE, + WIN_MULTREAD_EXT, + WIN_MULTWRITE_EXT, + WIN_READ, + WIN_WRITE, + WIN_READ_EXT, + WIN_WRITE_EXT, + WIN_READDMA, + WIN_WRITEDMA, + WIN_READDMA_EXT, + WIN_WRITEDMA_EXT, +}; + +static const u8 ide_data_phases[] = { + TASKFILE_MULTI_IN, + TASKFILE_MULTI_OUT, + TASKFILE_IN, + TASKFILE_OUT, + TASKFILE_IN_DMA, + TASKFILE_OUT_DMA, +}; + +static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma) +{ + u8 index, lba48, write; + + lba48 = (task->tf_flags & IDE_TFLAG_LBA48) ? 2 : 0; + write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; + + if (dma) + index = drive->vdma ? 4 : 8; + else + index = drive->mult_count ? 0 : 4; + + task->tf.command = ide_rw_cmds[index + lba48 + write]; + + if (dma) + index = 8; /* fixup index */ + + task->data_phase = ide_data_phases[index / 2 + write]; +} + /* * __ide_do_rw_disk() issues READ and WRITE commands to a disk, * using LBA if supported, or CHS otherwise, to address sectors. @@ -139,7 +183,6 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, unsigned int dma = drive->using_dma; u16 nsectors = (u16)rq->nr_sectors; u8 lba48 = (drive->addressing == 1) ? 1 : 0; - u8 command = WIN_NOP; ide_task_t task; struct ide_taskfile *tf = &task.tf; @@ -205,50 +248,32 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->device = head; } + if (rq_data_dir(rq)) + task.tf_flags |= IDE_TFLAG_WRITE; + + ide_tf_set_cmd(drive, &task, dma); + ide_tf_load(drive, &task); if (dma) { if (!hwif->dma_setup(drive)) { - if (rq_data_dir(rq)) { - command = lba48 ? WIN_WRITEDMA_EXT : WIN_WRITEDMA; - if (drive->vdma) - command = lba48 ? WIN_WRITE_EXT: WIN_WRITE; - } else { - command = lba48 ? WIN_READDMA_EXT : WIN_READDMA; - if (drive->vdma) - command = lba48 ? WIN_READ_EXT: WIN_READ; - } - hwif->dma_exec_cmd(drive, command); + hwif->dma_exec_cmd(drive, tf->command); hwif->dma_start(drive); return ide_started; } /* fallback to PIO */ + ide_tf_set_cmd(drive, &task, 0); ide_init_sg_cmd(drive, rq); } - if (rq_data_dir(rq) == READ) { - - if (drive->mult_count) { - hwif->data_phase = TASKFILE_MULTI_IN; - command = lba48 ? WIN_MULTREAD_EXT : WIN_MULTREAD; - } else { - hwif->data_phase = TASKFILE_IN; - command = lba48 ? WIN_READ_EXT : WIN_READ; - } + hwif->data_phase = task.data_phase; - ide_execute_command(drive, command, &task_in_intr, + if (rq_data_dir(rq) == READ) { + ide_execute_command(drive, tf->command, &task_in_intr, WAIT_WORSTCASE, NULL); return ide_started; } else { - if (drive->mult_count) { - hwif->data_phase = TASKFILE_MULTI_OUT; - command = lba48 ? WIN_MULTWRITE_EXT : WIN_MULTWRITE; - } else { - hwif->data_phase = TASKFILE_OUT; - command = lba48 ? WIN_WRITE_EXT : WIN_WRITE; - } - - hwif->OUTBSYNC(drive, command, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); ndelay(400); /* FIXME */ return pre_task_out_intr(drive, rq); -- cgit v0.10.2 From f6e29e35cc0f9facf2eb0b0454f9b09021b5aa6f Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:16 +0100 Subject: ide-disk: use do_rw_taskfile() (take 2) * Add IDE_TFLAG_DMA_PIO_FALLBACK taskfile flag to indicate the need to skip loading taskfile registers in do_rw_taskfile(). * Export do_rw_taskfile(). * Convert __ide_do_rw_disk() to use do_rw_taskfile(). * Unexport ide_tf_load(). * Unexport {pre_task_out,task_in}_intr() and make it static. * Remove incorrect comment about do_rw_taskfile() from . There should be no functionality changes caused by this patch. v2: * Add missing blk_fs_request() check to task_dma_ok() (for VDMA). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 97abc91..3d7127b 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -185,6 +185,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, u8 lba48 = (drive->addressing == 1) ? 1 : 0; ide_task_t task; struct ide_taskfile *tf = &task.tf; + ide_startstop_t rc; if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) { if (block + rq->nr_sectors > 1ULL << 28) @@ -252,32 +253,22 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, task.tf_flags |= IDE_TFLAG_WRITE; ide_tf_set_cmd(drive, &task, dma); + if (!dma) + hwif->data_phase = task.data_phase; + task.rq = rq; - ide_tf_load(drive, &task); + rc = do_rw_taskfile(drive, &task); - if (dma) { - if (!hwif->dma_setup(drive)) { - hwif->dma_exec_cmd(drive, tf->command); - hwif->dma_start(drive); - return ide_started; - } + if (rc == ide_stopped && dma) { /* fallback to PIO */ + task.tf_flags |= IDE_TFLAG_DMA_PIO_FALLBACK; ide_tf_set_cmd(drive, &task, 0); + hwif->data_phase = task.data_phase; ide_init_sg_cmd(drive, rq); + rc = do_rw_taskfile(drive, &task); } - hwif->data_phase = task.data_phase; - - if (rq_data_dir(rq) == READ) { - ide_execute_command(drive, tf->command, &task_in_intr, - WAIT_WORSTCASE, NULL); - return ide_started; - } else { - hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); - ndelay(400); /* FIXME */ - - return pre_task_out_intr(drive, rq); - } + return rc; } /* diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 236f91f..2d63ea9 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -114,8 +114,6 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); } -EXPORT_SYMBOL_GPL(ide_tf_load); - int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) { ide_task_t args; @@ -133,7 +131,7 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) static int inline task_dma_ok(ide_task_t *task) { - if (task->tf_flags & IDE_TFLAG_FLAGGED) + if (blk_fs_request(task->rq) || (task->tf_flags & IDE_TFLAG_FLAGGED)) return 1; switch (task->tf.command) { @@ -154,6 +152,8 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *); static ide_startstop_t set_geometry_intr(ide_drive_t *); static ide_startstop_t recal_intr(ide_drive_t *); static ide_startstop_t set_multmode_intr(ide_drive_t *); +static ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); +static ide_startstop_t task_in_intr(ide_drive_t *); ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { @@ -173,7 +173,8 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) if (task->tf_flags & IDE_TFLAG_FLAGGED) task->tf_flags |= IDE_TFLAG_FLAGGED_SET_IN_FLAGS; - ide_tf_load(drive, task); + if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) + ide_tf_load(drive, task); switch (task->data_phase) { case TASKFILE_MULTI_OUT: @@ -208,6 +209,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) return ide_started; } } +EXPORT_SYMBOL_GPL(do_rw_taskfile); /* * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd. @@ -446,7 +448,7 @@ static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) /* * Handler for command with PIO data-in phase (Read/Read Multiple). */ -ide_startstop_t task_in_intr (ide_drive_t *drive) +static ide_startstop_t task_in_intr(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; struct request *rq = HWGROUP(drive)->rq; @@ -477,7 +479,6 @@ ide_startstop_t task_in_intr (ide_drive_t *drive) return ide_started; } -EXPORT_SYMBOL(task_in_intr); /* * Handler for command with PIO data-out phase (Write/Write Multiple). @@ -507,7 +508,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) return ide_started; } -ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq) +static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq) { ide_startstop_t startstop; @@ -528,7 +529,6 @@ ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq) return ide_started; } -EXPORT_SYMBOL(pre_task_out_intr); int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) { diff --git a/include/linux/ide.h b/include/linux/ide.h index 721c9d8..c333a75 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -912,6 +912,7 @@ enum { IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16), IDE_TFLAG_IN_DATA = (1 << 17), IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), + IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), }; struct ide_taskfile { @@ -965,13 +966,7 @@ extern int drive_is_ready(ide_drive_t *); void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); -/* - * taskfile io for disks for now...and builds request from ide_ioctl - */ -extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); - -extern ide_startstop_t task_in_intr(ide_drive_t *); -extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); +ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); -- cgit v0.10.2 From d32444771b154c3ec37ebf6439004653560c2411 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide: fix registers loading order in ide_dump_ata_status() Fix registers loading order in ide_dump_ata_status()/ide_read_24(). Load registers in this order: * IDE_SECTOR_REG * IDE_LCYL_REG * IDE_HCYL_REG * IDE_SELECT_REG It shouldn't affect anything (just a usual paranoia to separate changes which change the way in which hardware is accessed from code cleanups). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 1064542..38d6b15 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -160,9 +160,9 @@ EXPORT_SYMBOL(default_hwif_mmiops); u32 ide_read_24 (ide_drive_t *drive) { - u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG); - u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG); u8 sect = HWIF(drive)->INB(IDE_SECTOR_REG); + u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG); + u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG); return (hcyl<<16)|(lcyl<<8)|sect; } diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 562f5ef..0010858 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -524,19 +524,24 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) (unsigned long long) sectors, high, low); } else { - u8 cur = hwif->INB(IDE_SELECT_REG); + u8 sector, lcyl, hcyl, cur; + + sector = hwif->INB(IDE_SECTOR_REG); + lcyl = hwif->INB(IDE_LCYL_REG); + hcyl = hwif->INB(IDE_HCYL_REG); + cur = hwif->INB(IDE_SELECT_REG); + if (cur & 0x40) { /* using LBA? */ printk(", LBAsect=%ld", (unsigned long) - ((cur&0xf)<<24) - |(hwif->INB(IDE_HCYL_REG)<<16) - |(hwif->INB(IDE_LCYL_REG)<<8) - | hwif->INB(IDE_SECTOR_REG)); + ((cur & 0xf) << 24) | + (hcyl << 16) | + (lcyl << 8) | + sector); } else { printk(", CHS=%d/%d/%d", - (hwif->INB(IDE_HCYL_REG)<<8) + - hwif->INB(IDE_LCYL_REG), - cur & 0xf, - hwif->INB(IDE_SECTOR_REG)); + (hcyl << 8) + lcyl, + cur & 0xf, + sector); } } if (HWGROUP(drive) && HWGROUP(drive)->rq) -- cgit v0.10.2 From c2b57cdc1d2976444d451a2a2e43e11b61ed0638 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide: add ide_tf_read() helper * Factor out code reading taskfile registers from ide_end_drive_cmd() to the new ide_tf_read() helper. * Add IDE_TFLAG_IN_* taskfile flags to indicate the need to load particular IDE taskfile register in ide_tf_read(). * Update ide_end_drive_cmd() to set respective IDE_TFLAG_IN_* taksfile flags. * Add ide_get_lba_addr() for getting LBA sector address from taskfile struct. * Factor out code getting sector address from ide_dump_ata_status() to the new ide_dump_sector() function. * Convert ide_dump_sector() to use ide_tf_read() and ide_get_lba_addr(). * Remove no longer needed ide_read_24(). The only change in functionality caused by this patch is that ide_dump_ata_status() no longer prints "high"/"low" parts of LBA48 sector address (of course LBA48 sector address is still printed). Cc: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 48c38b6..e053e00 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -297,6 +297,48 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq) spin_unlock_irqrestore(&ide_lock, flags); } +void ide_tf_read(ide_drive_t *drive, ide_task_t *task) +{ + ide_hwif_t *hwif = drive->hwif; + struct ide_taskfile *tf = &task->tf; + + if (task->tf_flags & IDE_TFLAG_IN_DATA) { + u16 data = hwif->INW(IDE_DATA_REG); + + tf->data = data & 0xff; + tf->hob_data = (data >> 8) & 0xff; + } + + /* be sure we're looking at the low order bits */ + hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); + + if (task->tf_flags & IDE_TFLAG_IN_NSECT) + tf->nsect = hwif->INB(IDE_NSECTOR_REG); + if (task->tf_flags & IDE_TFLAG_IN_LBAL) + tf->lbal = hwif->INB(IDE_SECTOR_REG); + if (task->tf_flags & IDE_TFLAG_IN_LBAM) + tf->lbam = hwif->INB(IDE_LCYL_REG); + if (task->tf_flags & IDE_TFLAG_IN_LBAH) + tf->lbah = hwif->INB(IDE_HCYL_REG); + if (task->tf_flags & IDE_TFLAG_IN_DEVICE) + tf->device = hwif->INB(IDE_SELECT_REG); + + if (task->tf_flags & IDE_TFLAG_LBA48) { + hwif->OUTB(drive->ctl | 0x80, IDE_CONTROL_REG); + + if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) + tf->hob_feature = hwif->INB(IDE_FEATURE_REG); + if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) + tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); + if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) + tf->hob_lbal = hwif->INB(IDE_SECTOR_REG); + if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) + tf->hob_lbam = hwif->INB(IDE_LCYL_REG); + if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) + tf->hob_lbah = hwif->INB(IDE_HCYL_REG); + } +} + /** * ide_end_drive_cmd - end an explicit drive command * @drive: command @@ -339,30 +381,14 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) if (args) { struct ide_taskfile *tf = &args->tf; - if (args->tf_flags & IDE_TFLAG_IN_DATA) { - u16 data = hwif->INW(IDE_DATA_REG); - - tf->data = data & 0xff; - tf->hob_data = (data >> 8) & 0xff; - } tf->error = err; - /* be sure we're looking at the low order bits */ - hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); - tf->nsect = hwif->INB(IDE_NSECTOR_REG); - tf->lbal = hwif->INB(IDE_SECTOR_REG); - tf->lbam = hwif->INB(IDE_LCYL_REG); - tf->lbah = hwif->INB(IDE_HCYL_REG); - tf->device = hwif->INB(IDE_SELECT_REG); tf->status = stat; - if (args->tf_flags & IDE_TFLAG_LBA48) { - hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); - tf->hob_feature = hwif->INB(IDE_FEATURE_REG); - tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); - tf->hob_lbal = hwif->INB(IDE_SECTOR_REG); - tf->hob_lbam = hwif->INB(IDE_LCYL_REG); - tf->hob_lbah = hwif->INB(IDE_HCYL_REG); - } + args->tf_flags |= (IDE_TFLAG_IN_TF|IDE_TFLAG_IN_DEVICE); + if (args->tf_flags & IDE_TFLAG_LBA48) + args->tf_flags |= IDE_TFLAG_IN_HOB; + + ide_tf_read(drive, args); } } else if (blk_pm_request(rq)) { struct request_pm_state *pm = rq->data; diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 38d6b15..c97c071 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -158,14 +158,6 @@ void default_hwif_mmiops (ide_hwif_t *hwif) EXPORT_SYMBOL(default_hwif_mmiops); -u32 ide_read_24 (ide_drive_t *drive) -{ - u8 sect = HWIF(drive)->INB(IDE_SECTOR_REG); - u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG); - u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG); - return (hcyl<<16)|(lcyl<<8)|sect; -} - void SELECT_DRIVE (ide_drive_t *drive) { if (HWIF(drive)->selectproc) diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 0010858..15736d4 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -479,6 +479,42 @@ static void ide_dump_opcode(ide_drive_t *drive) printk("0x%02x\n", opcode); } +static u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48) +{ + u32 high, low; + + if (lba48) + high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | + tf->hob_lbal; + else + high = tf->device & 0xf; + low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; + + return ((u64)high << 24) | low; +} + +static void ide_dump_sector(ide_drive_t *drive) +{ + ide_task_t task; + struct ide_taskfile *tf = &task.tf; + int lba48 = (drive->addressing == 1) ? 1 : 0; + + memset(&task, 0, sizeof(task)); + if (lba48) + task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_HOB_LBA | + IDE_TFLAG_LBA48; + else + task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE; + + ide_tf_read(drive, &task); + + if (lba48 || (tf->device & ATA_LBA)) + printk(", LBAsect=%llu", ide_get_lba_addr(tf, lba48)); + else + printk(", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam, + tf->device & 0xf, tf->lbal); +} + static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) { ide_hwif_t *hwif = HWIF(drive); @@ -512,38 +548,7 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) printk("}"); if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || (err & (ECC_ERR|ID_ERR|MARK_ERR))) { - if (drive->addressing == 1) { - __u64 sectors = 0; - u32 low = 0, high = 0; - hwif->OUTB(drive->ctl&~0x80, IDE_CONTROL_REG); - low = ide_read_24(drive); - hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); - high = ide_read_24(drive); - sectors = ((__u64)high << 24) | low; - printk(", LBAsect=%llu, high=%d, low=%d", - (unsigned long long) sectors, - high, low); - } else { - u8 sector, lcyl, hcyl, cur; - - sector = hwif->INB(IDE_SECTOR_REG); - lcyl = hwif->INB(IDE_LCYL_REG); - hcyl = hwif->INB(IDE_HCYL_REG); - cur = hwif->INB(IDE_SELECT_REG); - - if (cur & 0x40) { /* using LBA? */ - printk(", LBAsect=%ld", (unsigned long) - ((cur & 0xf) << 24) | - (hcyl << 16) | - (lcyl << 8) | - sector); - } else { - printk(", CHS=%d/%d/%d", - (hcyl << 8) + lcyl, - cur & 0xf, - sector); - } - } + ide_dump_sector(drive); if (HWGROUP(drive) && HWGROUP(drive)->rq) printk(", sector=%llu", (unsigned long long)HWGROUP(drive)->rq->sector); diff --git a/include/linux/ide.h b/include/linux/ide.h index c333a75..67f98c0 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -913,6 +913,27 @@ enum { IDE_TFLAG_IN_DATA = (1 << 17), IDE_TFLAG_CUSTOM_HANDLER = (1 << 18), IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19), + IDE_TFLAG_IN_HOB_FEATURE = (1 << 20), + IDE_TFLAG_IN_HOB_NSECT = (1 << 21), + IDE_TFLAG_IN_HOB_LBAL = (1 << 22), + IDE_TFLAG_IN_HOB_LBAM = (1 << 23), + IDE_TFLAG_IN_HOB_LBAH = (1 << 24), + IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL | + IDE_TFLAG_IN_HOB_LBAM | + IDE_TFLAG_IN_HOB_LBAH, + IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE | + IDE_TFLAG_IN_HOB_NSECT | + IDE_TFLAG_IN_HOB_LBA, + IDE_TFLAG_IN_NSECT = (1 << 25), + IDE_TFLAG_IN_LBAL = (1 << 26), + IDE_TFLAG_IN_LBAM = (1 << 27), + IDE_TFLAG_IN_LBAH = (1 << 28), + IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL | + IDE_TFLAG_IN_LBAM | + IDE_TFLAG_IN_LBAH, + IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT | + IDE_TFLAG_IN_LBA, + IDE_TFLAG_IN_DEVICE = (1 << 29), }; struct ide_taskfile { @@ -956,8 +977,7 @@ typedef struct ide_task_s { } ide_task_t; void ide_tf_load(ide_drive_t *, ide_task_t *); - -extern u32 ide_read_24(ide_drive_t *); +void ide_tf_read(ide_drive_t *, ide_task_t *); extern void SELECT_DRIVE(ide_drive_t *); extern void SELECT_MASK(ide_drive_t *, int); -- cgit v0.10.2 From 1c904fcfbb0d8eef92ef42b1da378b4714143e46 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide: printk fix power4: drivers/ide/ide-lib.c: In function `ide_dump_sector': drivers/ide/ide-lib.c:516: warning: long long unsigned int format, u64 arg (arg 2) We don't know what type is used to implement u64 hence it must always be cast when printed. Signed-off-by: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 15736d4..d7503c4 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -509,7 +509,8 @@ static void ide_dump_sector(ide_drive_t *drive) ide_tf_read(drive, &task); if (lba48 || (tf->device & ATA_LBA)) - printk(", LBAsect=%llu", ide_get_lba_addr(tf, lba48)); + printk(", LBAsect=%llu", + (unsigned long long)ide_get_lba_addr(tf, lba48)); else printk(", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam, tf->device & 0xf, tf->lbal); -- cgit v0.10.2 From a501633c7d44087e806597d3a213d735346edd51 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide-disk: use ide_get_lba_addr() * Export ide_get_lba_addr(). * Convert idedisk_{read_native,set}_max_address() to use ide_get_lba_addr(). * Remove incorrect comment from idedisk_read_native_max_address() (noticed by Sergei). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 3d7127b..d8fdd86 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -326,18 +326,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) ide_no_data_taskfile(drive, &args); /* if OK, compute maximum address value */ - if ((tf->status & 0x01) == 0) { - u32 high, low; + if ((tf->status & 0x01) == 0) + addr = ide_get_lba_addr(tf, lba48) + 1; - if (lba48) - high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | - tf->hob_lbal; - else - high = tf->device & 0xf; - low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; - addr = ((__u64)high << 24) | low; - addr++; /* since the return value is (maxlba - 1), we add 1 */ - } return addr; } @@ -373,18 +364,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) /* submit command request */ ide_no_data_taskfile(drive, &args); /* if OK, compute maximum address value */ - if ((tf->status & 0x01) == 0) { - u32 high, low; + if ((tf->status & 0x01) == 0) + addr_set = ide_get_lba_addr(tf, lba48) + 1; - if (lba48) - high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | - tf->hob_lbal; - else - high = tf->device & 0xf; - low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; - addr_set = ((__u64)high << 24) | low; - addr_set++; - } return addr_set; } diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index d7503c4..6b2e810 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -479,7 +479,7 @@ static void ide_dump_opcode(ide_drive_t *drive) printk("0x%02x\n", opcode); } -static u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48) +u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48) { u32 high, low; @@ -492,6 +492,7 @@ static u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48) return ((u64)high << 24) | low; } +EXPORT_SYMBOL_GPL(ide_get_lba_addr); static void ide_dump_sector(ide_drive_t *drive) { diff --git a/include/linux/ide.h b/include/linux/ide.h index 67f98c0..ecaa96e 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1238,6 +1238,7 @@ static inline int ide_dev_is_sata(struct hd_driveid *id) return 0; } +u64 ide_get_lba_addr(struct ide_taskfile *, int); u8 ide_dump_status(ide_drive_t *, const char *, u8); typedef struct ide_pio_timings_s { -- cgit v0.10.2 From e62925dd26ef9594b8e4b9380b3211f6dae4ab96 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide: kill duplicate code in ide_dump_{ata,atapi}_status() * Move the common code from ide_dump_{ata,atapi}_status() to ide_dump_status(). * ide_dump_{ata,atapi}_status() -> ide_dump_{ata,atapi}_error(). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 6b2e810..8649db3 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -517,61 +517,51 @@ static void ide_dump_sector(ide_drive_t *drive) tf->device & 0xf, tf->lbal); } -static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) +static void ide_dump_ata_error(ide_drive_t *drive, u8 err) { - ide_hwif_t *hwif = HWIF(drive); - unsigned long flags; - u8 err = 0; - - local_irq_save(flags); - printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); - if (stat & BUSY_STAT) - printk("Busy "); - else { - if (stat & READY_STAT) printk("DriveReady "); - if (stat & WRERR_STAT) printk("DeviceFault "); - if (stat & SEEK_STAT) printk("SeekComplete "); - if (stat & DRQ_STAT) printk("DataRequest "); - if (stat & ECC_STAT) printk("CorrectedError "); - if (stat & INDEX_STAT) printk("Index "); - if (stat & ERR_STAT) printk("Error "); + printk("{ "); + if (err & ABRT_ERR) printk("DriveStatusError "); + if (err & ICRC_ERR) + printk((err & ABRT_ERR) ? "BadCRC " : "BadSector "); + if (err & ECC_ERR) printk("UncorrectableError "); + if (err & ID_ERR) printk("SectorIdNotFound "); + if (err & TRK0_ERR) printk("TrackZeroNotFound "); + if (err & MARK_ERR) printk("AddrMarkNotFound "); + printk("}"); + if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || + (err & (ECC_ERR|ID_ERR|MARK_ERR))) { + ide_dump_sector(drive); + if (HWGROUP(drive) && HWGROUP(drive)->rq) + printk(", sector=%llu", + (unsigned long long)HWGROUP(drive)->rq->sector); } + printk("\n"); +} + +static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) +{ + printk("{ "); + if (err & ILI_ERR) printk("IllegalLengthIndication "); + if (err & EOM_ERR) printk("EndOfMedia "); + if (err & ABRT_ERR) printk("AbortedCommand "); + if (err & MCR_ERR) printk("MediaChangeRequested "); + if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", + (err & LFS_ERR) >> 4); printk("}\n"); - if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { - err = hwif->INB(IDE_ERROR_REG); - printk("%s: %s: error=0x%02x { ", drive->name, msg, err); - if (err & ABRT_ERR) printk("DriveStatusError "); - if (err & ICRC_ERR) - printk((err & ABRT_ERR) ? "BadCRC " : "BadSector "); - if (err & ECC_ERR) printk("UncorrectableError "); - if (err & ID_ERR) printk("SectorIdNotFound "); - if (err & TRK0_ERR) printk("TrackZeroNotFound "); - if (err & MARK_ERR) printk("AddrMarkNotFound "); - printk("}"); - if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || - (err & (ECC_ERR|ID_ERR|MARK_ERR))) { - ide_dump_sector(drive); - if (HWGROUP(drive) && HWGROUP(drive)->rq) - printk(", sector=%llu", - (unsigned long long)HWGROUP(drive)->rq->sector); - } - printk("\n"); - } - ide_dump_opcode(drive); - local_irq_restore(flags); - return err; } /** - * ide_dump_atapi_status - print human readable atapi status + * ide_dump_status - translate ATA/ATAPI error * @drive: drive that status applies to * @msg: text message to print * @stat: status byte to decode * * Error reporting, in human readable form (luxurious, but a memory hog). + * Combines the drive name, message and status byte to provide a + * user understandable explanation of the device error. */ -static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) +u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) { unsigned long flags; u8 err = 0; @@ -592,36 +582,15 @@ static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) printk("}\n"); if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { err = drive->hwif->INB(IDE_ERROR_REG); - printk("%s: %s: error=0x%02x { ", drive->name, msg, err); - if (err & ILI_ERR) printk("IllegalLengthIndication "); - if (err & EOM_ERR) printk("EndOfMedia "); - if (err & ABRT_ERR) printk("AbortedCommand "); - if (err & MCR_ERR) printk("MediaChangeRequested "); - if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", - (err & LFS_ERR) >> 4); - printk("}\n"); + printk("%s: %s: error=0x%02x ", drive->name, msg, err); + if (drive->media == ide_disk) + ide_dump_ata_error(drive, err); + else + ide_dump_atapi_error(drive, err); } ide_dump_opcode(drive); local_irq_restore(flags); return err; } -/** - * ide_dump_status - translate ATA/ATAPI error - * @drive: drive the error occured on - * @msg: information string - * @stat: status byte - * - * Error reporting, in human readable form (luxurious, but a memory hog). - * Combines the drive name, message and status byte to provide a - * user understandable explanation of the device error. - */ - -u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) -{ - if (drive->media == ide_disk) - return ide_dump_ata_status(drive, msg, stat); - return ide_dump_atapi_status(drive, msg, stat); -} - EXPORT_SYMBOL(ide_dump_status); -- cgit v0.10.2 From 3071a9d00b8684899d93f368e670c4de0293df29 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:17 +0100 Subject: ide: make 'extra' field in struct ide_port_info u8 The maximum value used currently for 'extra' field in struct ide_port_info is 240. Make 'extra' u8 so it packs nicely together with enablebits[] and 'chipset' fields (ide_pci_enablebit_t is 3 bytes and hwif_chipset_t is 1 byte). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/include/linux/ide.h b/include/linux/ide.h index ecaa96e..6f5b6b5 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1111,7 +1111,7 @@ struct ide_port_info { void (*fixup)(ide_hwif_t *); ide_pci_enablebit_t enablebits[2]; hwif_chipset_t chipset; - unsigned int extra; + u8 extra; u32 host_flags; u8 pio_mask; u8 swdma_mask; -- cgit v0.10.2 From ad4ba7dcef285c92a6856e0dd9feb780c1a79b87 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:18 +0100 Subject: pdc202xx_new: move PIO programming code to pdcnew_set_pio_mode() * Move PIO programming code from pdcnew_set_mode() to pdcnew_set_pio_mode(). * Rename pdcnew_set_mode() to pdcnew_set_dma_mode(). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 2b4f44e..79ba8ef 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c @@ -146,7 +146,7 @@ static struct udma_timing { { 0x1a, 0x01, 0xcb }, /* UDMA mode 6 */ }; -static void pdcnew_set_mode(ide_drive_t *drive, const u8 speed) +static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) { ide_hwif_t *hwif = HWIF(drive); u8 adj = (drive->dn & 1) ? 0x08 : 0x00; @@ -177,7 +177,6 @@ static void pdcnew_set_mode(ide_drive_t *drive, const u8 speed) set_indexed_reg(hwif, 0x12 + adj, udma_timings[mode].reg12); break; - case XFER_MW_DMA_2: case XFER_MW_DMA_1: case XFER_MW_DMA_0: @@ -186,18 +185,6 @@ static void pdcnew_set_mode(ide_drive_t *drive, const u8 speed) set_indexed_reg(hwif, 0x0f + adj, mwdma_timings[mode].reg0f); break; - case XFER_PIO_4: - case XFER_PIO_3: - case XFER_PIO_2: - case XFER_PIO_1: - case XFER_PIO_0: - set_indexed_reg(hwif, 0x0c + adj, - pio_timings[mode].reg0c); - set_indexed_reg(hwif, 0x0d + adj, - pio_timings[mode].reg0d); - set_indexed_reg(hwif, 0x13 + adj, - pio_timings[mode].reg13); - break; default: printk(KERN_ERR "pdc202xx_new: " "Unknown speed %d ignored\n", speed); @@ -212,7 +199,14 @@ static void pdcnew_set_mode(ide_drive_t *drive, const u8 speed) static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) { - pdcnew_set_mode(drive, XFER_PIO_0 + pio); + ide_hwif_t *hwif = drive->hwif; + u8 adj = (drive->dn & 1) ? 0x08 : 0x00; + + if (max_dma_rate(hwif->pci_dev) == 4) { + set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); + set_indexed_reg(hwif, 0x0d + adj, pio_timings[pio].reg0d); + set_indexed_reg(hwif, 0x13 + adj, pio_timings[pio].reg13); + } } static u8 pdcnew_cable_detect(ide_hwif_t *hwif) @@ -466,7 +460,7 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) { hwif->set_pio_mode = &pdcnew_set_pio_mode; - hwif->set_dma_mode = &pdcnew_set_mode; + hwif->set_dma_mode = &pdcnew_set_dma_mode; hwif->quirkproc = &pdcnew_quirkproc; hwif->resetproc = &pdcnew_reset; -- cgit v0.10.2 From 428c6440ef933a3d9df5adfeb2cbb3ea7ebb6a68 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:18 +0100 Subject: sis5513: factor out UDMA programming code * Factor out UDMA programming code from sis_set_dma_mode() to per chipset family helpers: sis_{ata33,ata133}_program_udma_timings(). * Add sis_program_udma_timings() helper. * Remove unneeded casts to 'unsigned long'. * Minor cleanups. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index d90b429..3f35386 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -305,11 +305,52 @@ static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) sis_program_timings(drive, XFER_PIO_0 + pio); } -static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) +static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) { - ide_hwif_t *hwif = HWIF(drive); - struct pci_dev *dev = hwif->pci_dev; + struct pci_dev *dev = drive->hwif->pci_dev; + u32 regdw = 0; + u8 drive_pci = sis_ata133_get_base(drive), clk, idx; + + pci_read_config_dword(dev, drive_pci, ®dw); + + regdw |= 0x04; + regdw &= 0xfffff00f; + /* check if ATA133 enable */ + clk = (regdw & 0x08) ? ATA_133 : ATA_100; + idx = mode - XFER_UDMA_0; + regdw |= cycle_time_value[clk][idx] << 4; + regdw |= cvs_time_value[clk][idx] << 8; + + pci_write_config_dword(dev, drive_pci, regdw); +} + +static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) +{ + struct pci_dev *dev = drive->hwif->pci_dev; + u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; + + pci_read_config_byte(dev, drive_pci + 1, ®); + /* force the UDMA bit on if we want to use UDMA */ + reg |= 0x80; + /* clean reg cycle time bits */ + reg &= ~((0xff >> (8 - cycle_time_range[i])) << cycle_time_offset[i]); + /* set reg cycle time bits */ + reg |= cycle_time_value[i][mode - XFER_UDMA_0] << cycle_time_offset[i]; + + pci_write_config_byte(dev, drive_pci + 1, reg); +} + +static void sis_program_udma_timings(ide_drive_t *drive, const u8 mode) +{ + if (chipset_family >= ATA_133) /* ATA_133 */ + sis_ata133_program_udma_timings(drive, mode); + else /* ATA_33/66/100a/100/133a */ + sis_ata33_program_udma_timings(drive, mode); +} + +static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) +{ /* Config chip for mode */ switch(speed) { case XFER_UDMA_6: @@ -319,36 +360,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) case XFER_UDMA_2: case XFER_UDMA_1: case XFER_UDMA_0: - if (chipset_family >= ATA_133) { - u32 regdw = 0; - u8 drive_pci = sis_ata133_get_base(drive); - - pci_read_config_dword(dev, drive_pci, ®dw); - regdw |= 0x04; - regdw &= 0xfffff00f; - /* check if ATA133 enable */ - if (regdw & 0x08) { - regdw |= (unsigned long)cycle_time_value[ATA_133][speed-XFER_UDMA_0] << 4; - regdw |= (unsigned long)cvs_time_value[ATA_133][speed-XFER_UDMA_0] << 8; - } else { - regdw |= (unsigned long)cycle_time_value[ATA_100][speed-XFER_UDMA_0] << 4; - regdw |= (unsigned long)cvs_time_value[ATA_100][speed-XFER_UDMA_0] << 8; - } - pci_write_config_dword(dev, (unsigned long)drive_pci, regdw); - } else { - u8 drive_pci = 0x40 + drive->dn * 2, reg = 0; - - pci_read_config_byte(dev, drive_pci+1, ®); - /* Force the UDMA bit on if we want to use UDMA */ - reg |= 0x80; - /* clean reg cycle time bits */ - reg &= ~((0xFF >> (8 - cycle_time_range[chipset_family])) - << cycle_time_offset[chipset_family]); - /* set reg cycle time bits */ - reg |= cycle_time_value[chipset_family][speed-XFER_UDMA_0] - << cycle_time_offset[chipset_family]; - pci_write_config_byte(dev, drive_pci+1, reg); - } + sis_program_udma_timings(drive, speed); break; case XFER_MW_DMA_2: case XFER_MW_DMA_1: -- cgit v0.10.2 From 4db90a145292327b95b03f6dcd3352327235cc36 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:18 +0100 Subject: ide: add IDE_HFLAG_ABUSE_SET_DMA_MODE host flag * Add IDE_HFLAG_ABUSE_SET_DMA_MODE host flag and use it to decide what to do with transfer modes < XFER_PIO_0 in ide_set_xfer_rate(). * Set IDE_HFLAG_ABUSE_SET_DMA_MODE in host drivers that need it (aec62xx, amd74xx, cs5520, cs5535, hpt34x, hpt366, pdc202xx_old, serverworks, tc86c001 and via82cxxx) and cleanup ->set_dma_mode methods in host drivers that don't (IDE core code guarantees that ->set_dma_mode will be called only for modes which are present in SWDMA/MWDMA/UDMA masks). While at it: * Add IDE_HFLAGS_HPT34X/HPT3XX/PDC202XX/SVWKS define in hpt34x/hpt366/pdc202xx_old/serverworks host driver. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 93f71fc..673402f 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c @@ -272,8 +272,6 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) case XFER_SW_DMA_0: cycle_time = 480; break; - default: - return; } /* diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 476e0d6..325e608 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c @@ -747,8 +747,6 @@ static void cris_set_dma_mode(ide_drive_t *drive, const u8 speed) strobe = ATA_DMA2_STROBE; hold = ATA_DMA2_HOLD; break; - default: - return; } if (speed >= XFER_UDMA_0) diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 8649db3..a3bd8e8 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -441,6 +441,12 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) * case could happen iff the transfer mode has already been set on * the device by ide-proc.c::set_xfer_rate()). */ + if (rate < XFER_PIO_0) { + if (hwif->host_flags & IDE_HFLAG_ABUSE_SET_DMA_MODE) + return ide_set_dma_mode(drive, rate); + else + return ide_config_drive_speed(drive, rate); + } return ide_set_dma_mode(drive, rate); } diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index a4ce3ba..a4d0d4c 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c @@ -198,8 +198,6 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed) break; #endif - default: - return; } au_writel(mem_sttime,MEM_STTIME2); diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 4426850..7f4d185 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c @@ -202,6 +202,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_ATAPI_DMA | + IDE_HFLAG_ABUSE_SET_DMA_MODE | IDE_HFLAG_OFF_BOARD, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, @@ -211,6 +212,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { .init_chipset = init_chipset_aec62xx, .init_hwif = init_hwif_aec62xx, .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | + IDE_HFLAG_ABUSE_SET_DMA_MODE | IDE_HFLAG_OFF_BOARD, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, @@ -220,7 +222,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { .init_chipset = init_chipset_aec62xx, .init_hwif = init_hwif_aec62xx, .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA, + .host_flags = IDE_HFLAG_NO_ATAPI_DMA | + IDE_HFLAG_ABUSE_SET_DMA_MODE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA4, @@ -228,7 +231,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { .name = "AEC6280", .init_chipset = init_chipset_aec62xx, .init_hwif = init_hwif_aec62xx, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAG_NO_ATAPI_DMA | + IDE_HFLAG_ABUSE_SET_DMA_MODE | + IDE_HFLAG_OFF_BOARD, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, @@ -237,7 +242,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { .init_chipset = init_chipset_aec62xx, .init_hwif = init_hwif_aec62xx, .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAG_NO_ATAPI_DMA | + IDE_HFLAG_ABUSE_SET_DMA_MODE | + IDE_HFLAG_OFF_BOARD, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index ce29393..49aa82e 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -402,9 +402,6 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) u8 tmpbyte = 0x00; int m5229_udma = (hwif->channel) ? 0x57 : 0x56; - if (speed < XFER_PIO_0) - return; - if (speed == XFER_UDMA_6) speed1 = 0x47; diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 8d4125e..cee51fd 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c @@ -266,6 +266,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) #define IDE_HFLAGS_AMD \ (IDE_HFLAG_PIO_NO_BLACKLIST | \ IDE_HFLAG_PIO_NO_DOWNGRADE | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE | \ IDE_HFLAG_POST_SET_MODE | \ IDE_HFLAG_IO_32BIT | \ IDE_HFLAG_UNMASK_IRQS | \ diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index ef8e016..5ae2656 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c @@ -133,9 +133,6 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) u32 tmp32; u16 tmp16; - if (speed < XFER_MW_DMA_0) - return; - spin_lock_irqsave(&atiixp_lock, flags); save_mdma_mode[drive->dn] = 0; diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index f3613ba..0b1e947 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -322,8 +322,6 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) case XFER_MW_DMA_0: program_cycle_times(drive, 480, 215); break; - default: - return; } if (speed >= XFER_SW_DMA_0) diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 0466462..d1a91bc 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c @@ -137,6 +137,7 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) IDE_HFLAG_CS5520 | \ IDE_HFLAG_VDMA | \ IDE_HFLAG_NO_ATAPI_DMA | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE |\ IDE_HFLAG_BOOTABLE, \ .pio_mask = ATA_PIO4, \ } diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index 5476903..df5966b 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c @@ -116,8 +116,6 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) case XFER_MW_DMA_0: timings = 0x00077771; break; case XFER_MW_DMA_1: timings = 0x00012121; break; case XFER_MW_DMA_2: timings = 0x00002020; break; - default: - return; } basereg = CS5530_BASEREG(drive->hwif); reg = inl(basereg + 4); /* get drive0 config register */ diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index ddcbeba..50b3d77 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c @@ -190,7 +190,7 @@ static const struct ide_port_info cs5535_chipset __devinitdata = { .name = "CS5535", .init_hwif = init_hwif_cs5535, .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | - IDE_HFLAG_BOOTABLE, + IDE_HFLAG_ABUSE_SET_DMA_MODE | IDE_HFLAG_BOOTABLE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA4, diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index ae6307f..dfba0d1 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c @@ -129,14 +129,18 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) hwif->set_dma_mode = &hpt34x_set_mode; } +#define IDE_HFLAGS_HPT34X \ + (IDE_HFLAG_NO_ATAPI_DMA | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE | \ + IDE_HFLAG_NO_AUTODMA) + static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { { /* 0 */ .name = "HPT343", .init_chipset = init_chipset_hpt34x, .init_hwif = init_hwif_hpt34x, .extra = 16, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | - IDE_HFLAG_NO_AUTODMA, + .host_flags = IDE_HFLAGS_HPT34X, .pio_mask = ATA_PIO5, }, { /* 1 */ @@ -144,9 +148,7 @@ static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { .init_chipset = init_chipset_hpt34x, .init_hwif = init_hwif_hpt34x, .extra = 16, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | - IDE_HFLAG_NO_AUTODMA | - IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, .pio_mask = ATA_PIO5, #ifdef CONFIG_HPT34X_AUTODMA .swdma_mask = ATA_SWDMA2, diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 24d6457..3777fb8 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1461,6 +1461,11 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) return 0; } +#define IDE_HFLAGS_HPT3XX \ + (IDE_HFLAG_NO_ATAPI_DMA | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE | \ + IDE_HFLAG_OFF_BOARD) + static const struct ide_port_info hpt366_chipsets[] __devinitdata = { { /* 0 */ .name = "HPT36x", @@ -1475,9 +1480,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { */ .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, .extra = 240, - .host_flags = IDE_HFLAG_SINGLE | - IDE_HFLAG_NO_ATAPI_DMA | - IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, },{ /* 1 */ @@ -1487,7 +1490,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { .init_dma = init_dma_hpt366, .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .extra = 240, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, },{ /* 2 */ @@ -1497,7 +1500,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { .init_dma = init_dma_hpt366, .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .extra = 240, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, },{ /* 3 */ @@ -1507,7 +1510,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { .init_dma = init_dma_hpt366, .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .extra = 240, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, },{ /* 4 */ @@ -1518,7 +1521,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .udma_mask = ATA_UDMA5, .extra = 240, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, },{ /* 5 */ @@ -1528,7 +1531,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { .init_dma = init_dma_hpt366, .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .extra = 240, - .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_HPT3XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, } diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 90b52ed..2a0f45c 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c @@ -101,24 +101,11 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) pci_read_config_byte(dev, 0x54, ®54); pci_read_config_byte(dev, 0x55, ®55); - switch(speed) { - case XFER_UDMA_6: - case XFER_UDMA_4: - case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break; - case XFER_UDMA_5: - case XFER_UDMA_3: - case XFER_UDMA_1: u_speed = 1 << (drive->dn * 4); break; - case XFER_UDMA_0: u_speed = 0 << (drive->dn * 4); break; - break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_SW_DMA_2: - break; - default: - return; - } - if (speed >= XFER_UDMA_0) { + u8 udma = speed - XFER_UDMA_0; + + u_speed = min_t(u8, 2 - (udma & 1), udma) << (drive->dn * 4); + if (!(reg48 & u_flag)) pci_write_config_byte(dev, 0x48, reg48 | u_flag); if (speed >= XFER_UDMA_5) { diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 79ba8ef..ef4a99b 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c @@ -162,32 +162,18 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) if (max_dma_rate(hwif->pci_dev) == 4) { u8 mode = speed & 0x07; - switch (speed) { - case XFER_UDMA_6: - case XFER_UDMA_5: - case XFER_UDMA_4: - case XFER_UDMA_3: - case XFER_UDMA_2: - case XFER_UDMA_1: - case XFER_UDMA_0: - set_indexed_reg(hwif, 0x10 + adj, - udma_timings[mode].reg10); - set_indexed_reg(hwif, 0x11 + adj, - udma_timings[mode].reg11); - set_indexed_reg(hwif, 0x12 + adj, - udma_timings[mode].reg12); - break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_MW_DMA_0: - set_indexed_reg(hwif, 0x0e + adj, - mwdma_timings[mode].reg0e); - set_indexed_reg(hwif, 0x0f + adj, - mwdma_timings[mode].reg0f); - break; - default: - printk(KERN_ERR "pdc202xx_new: " - "Unknown speed %d ignored\n", speed); + if (speed >= XFER_UDMA_0) { + set_indexed_reg(hwif, 0x10 + adj, + udma_timings[mode].reg10); + set_indexed_reg(hwif, 0x11 + adj, + udma_timings[mode].reg11); + set_indexed_reg(hwif, 0x12 + adj, + udma_timings[mode].reg12); + } else { + set_indexed_reg(hwif, 0x0e + adj, + mwdma_timings[mode].reg0e); + set_indexed_reg(hwif, 0x0f + adj, + mwdma_timings[mode].reg0f); } } else if (speed == XFER_UDMA_2) { /* Set tHOLD bit to 0 if using UDMA mode 2 */ diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 22c7a75..67b2781 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -375,6 +375,11 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, } } +#define IDE_HFLAGS_PDC202XX \ + (IDE_HFLAG_ERROR_STOPS_FIFO | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE | \ + IDE_HFLAG_OFF_BOARD) + #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ { \ .name = name_str, \ @@ -382,9 +387,7 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, .init_hwif = init_hwif_pdc202xx, \ .init_dma = init_dma_pdc202xx, \ .extra = 48, \ - .host_flags = IDE_HFLAG_ERROR_STOPS_FIFO | \ - extra_flags | \ - IDE_HFLAG_OFF_BOARD, \ + .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ .pio_mask = ATA_PIO4, \ .mwdma_mask = ATA_MWDMA2, \ .udma_mask = udma, \ @@ -397,8 +400,7 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { .init_hwif = init_hwif_pdc202xx, .init_dma = init_dma_pdc202xx, .extra = 16, - .host_flags = IDE_HFLAG_ERROR_STOPS_FIFO | - IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAGS_PDC202XX, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA2, diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 27781d2..bd6d3f7 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -203,20 +203,11 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) pci_read_config_byte(dev, 0x54, ®54); pci_read_config_byte(dev, 0x55, ®55); - switch(speed) { - case XFER_UDMA_4: - case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break; - case XFER_UDMA_5: - case XFER_UDMA_3: - case XFER_UDMA_1: u_speed = 1 << (drive->dn * 4); break; - case XFER_UDMA_0: u_speed = 0 << (drive->dn * 4); break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_SW_DMA_2: break; - default: return; - } - if (speed >= XFER_UDMA_0) { + u8 udma = speed - XFER_UDMA_0; + + u_speed = min_t(u8, 2 - (udma & 1), udma) << (drive->dn * 4); + if (!(reg48 & u_flag)) pci_write_config_byte(dev, 0x48, reg48 | u_flag); if (speed == XFER_UDMA_5) { diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index f0029b3..569a8fe 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c @@ -185,8 +185,6 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) case PCI_CLK_66: timings = 0x00015151; break; } break; - default: - return; } if (unit == 0) { /* are we configuring drive0? */ diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index ebb7132..24a85bb 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c @@ -254,19 +254,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) offset = 0; /* 100MHz */ } - switch (speed) { - case XFER_UDMA_6: - case XFER_UDMA_5: - case XFER_UDMA_4: - case XFER_UDMA_3: - case XFER_UDMA_2: - case XFER_UDMA_1: - case XFER_UDMA_0: - idx = speed - XFER_UDMA_0; - break; - default: - return; - } + idx = speed - XFER_UDMA_0; jcactsel = JCACTSELtbl[offset][idx]; if (is_slave) { diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index a728031..e9bd269 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -366,12 +366,17 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif) } } +#define IDE_HFLAGS_SVWKS \ + (IDE_HFLAG_LEGACY_IRQS | \ + IDE_HFLAG_ABUSE_SET_DMA_MODE | \ + IDE_HFLAG_BOOTABLE) + static const struct ide_port_info serverworks_chipsets[] __devinitdata = { { /* 0 */ .name = "SvrWks OSB4", .init_chipset = init_chipset_svwks, .init_hwif = init_hwif_svwks, - .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE, + .host_flags = IDE_HFLAGS_SVWKS, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ @@ -379,7 +384,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { .name = "SvrWks CSB5", .init_chipset = init_chipset_svwks, .init_hwif = init_hwif_svwks, - .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE, + .host_flags = IDE_HFLAGS_SVWKS, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, @@ -387,7 +392,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { .name = "SvrWks CSB6", .init_chipset = init_chipset_svwks, .init_hwif = init_hwif_svwks, - .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_BOOTABLE, + .host_flags = IDE_HFLAGS_SVWKS, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, @@ -395,8 +400,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { .name = "SvrWks CSB6", .init_chipset = init_chipset_svwks, .init_hwif = init_hwif_svwks, - .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_SINGLE | - IDE_HFLAG_BOOTABLE, + .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, @@ -404,8 +408,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { .name = "SvrWks HT1000", .init_chipset = init_chipset_svwks, .init_hwif = init_hwif_svwks, - .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_SINGLE | - IDE_HFLAG_BOOTABLE, + .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA5, diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 5709c25..7b45eaf 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c @@ -278,27 +278,14 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) scsc = is_sata(hwif) ? 1 : scsc; - switch(speed) { - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_MW_DMA_0: - multi = dma[speed - XFER_MW_DMA_0]; - mode |= ((unit) ? 0x20 : 0x02); - break; - case XFER_UDMA_6: - case XFER_UDMA_5: - case XFER_UDMA_4: - case XFER_UDMA_3: - case XFER_UDMA_2: - case XFER_UDMA_1: - case XFER_UDMA_0: - multi = dma[2]; - ultra |= ((scsc) ? (ultra6[speed - XFER_UDMA_0]) : - (ultra5[speed - XFER_UDMA_0])); - mode |= ((unit) ? 0x30 : 0x03); - break; - default: - return; + if (speed >= XFER_UDMA_0) { + multi = dma[2]; + ultra |= (scsc ? ultra6[speed - XFER_UDMA_0] : + ultra5[speed - XFER_UDMA_0]); + mode |= (unit ? 0x30 : 0x03); + } else { + multi = dma[speed - XFER_MW_DMA_0]; + mode |= (unit ? 0x20 : 0x02); } if (hwif->mmio) { diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 3f35386..85d3699 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -351,25 +351,10 @@ static void sis_program_udma_timings(ide_drive_t *drive, const u8 mode) static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) { - /* Config chip for mode */ - switch(speed) { - case XFER_UDMA_6: - case XFER_UDMA_5: - case XFER_UDMA_4: - case XFER_UDMA_3: - case XFER_UDMA_2: - case XFER_UDMA_1: - case XFER_UDMA_0: - sis_program_udma_timings(drive, speed); - break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_MW_DMA_0: - sis_program_timings(drive, speed); - break; - default: - break; - } + if (speed >= XFER_UDMA_0) + sis_program_udma_timings(drive, speed); + else + sis_program_timings(drive, speed); } static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 147d783..069f104 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c @@ -115,32 +115,24 @@ static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed) DBG(("sl82c105_tune_chipset(drive:%s, speed:%s)\n", drive->name, ide_xfer_verbose(speed))); - switch (speed) { - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_MW_DMA_0: - drv_ctrl = mwdma_timings[speed - XFER_MW_DMA_0]; + drv_ctrl = mwdma_timings[speed - XFER_MW_DMA_0]; - /* - * Store the DMA timings so that we can actually program - * them when DMA will be turned on... - */ - drive->drive_data &= 0x0000ffff; - drive->drive_data |= (unsigned long)drv_ctrl << 16; + /* + * Store the DMA timings so that we can actually program + * them when DMA will be turned on... + */ + drive->drive_data &= 0x0000ffff; + drive->drive_data |= (unsigned long)drv_ctrl << 16; - /* - * If we are already using DMA, we just reprogram - * the drive control register. - */ - if (drive->using_dma) { - struct pci_dev *dev = HWIF(drive)->pci_dev; - int reg = 0x44 + drive->dn * 4; - - pci_write_config_word(dev, reg, drv_ctrl); - } - break; - default: - return; + /* + * If we are already using DMA, we just reprogram + * the drive control register. + */ + if (drive->using_dma) { + struct pci_dev *dev = HWIF(drive)->pci_dev; + int reg = 0x44 + drive->dn * 4; + + pci_write_config_word(dev, reg, drv_ctrl); } } diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index eb4445b..dbbb468 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c @@ -91,19 +91,9 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) pci_read_config_word(dev, 0x48, ®48); pci_read_config_word(dev, 0x4a, ®4a); - switch(speed) { - case XFER_UDMA_4: u_speed = 4 << (drive->dn * 4); break; - case XFER_UDMA_3: u_speed = 3 << (drive->dn * 4); break; - case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break; - case XFER_UDMA_1: u_speed = 1 << (drive->dn * 4); break; - case XFER_UDMA_0: u_speed = 0 << (drive->dn * 4); break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_SW_DMA_2: break; - default: return; - } - if (speed >= XFER_UDMA_0) { + u_speed = (speed - XFER_UDMA_0) << (drive->dn * 4); + if (!(reg48 & u_flag)) pci_write_config_word(dev, 0x48, reg48|u_flag); /* FIXME: (reg4a & a_speed) ? */ diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index a66ebd1..e1faf6c 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c @@ -222,7 +222,8 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = { .name = "TC86C001", .init_chipset = init_chipset_tc86c001, .init_hwif = init_hwif_tc86c001, - .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD, + .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | + IDE_HFLAG_ABUSE_SET_DMA_MODE, .pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, .udma_mask = ATA_UDMA4, diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index a227c41..ae52a96 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c @@ -81,8 +81,6 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed) case XFER_PIO_0: timing = 0x0808; break; - default: - return; } triflex_timings &= ~(0xFFFF << (16 * unit)); diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index a0d3c16..4b32c90 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c @@ -439,6 +439,7 @@ static const struct ide_port_info via82cxxx_chipset __devinitdata = { .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | IDE_HFLAG_PIO_NO_DOWNGRADE | + IDE_HFLAG_ABUSE_SET_DMA_MODE | IDE_HFLAG_POST_SET_MODE | IDE_HFLAG_IO_32BIT | IDE_HFLAG_BOOTABLE, diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 4559e29..3dce800 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -828,38 +828,20 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) tl[0] = *timings; tl[1] = *timings2; - switch(speed) { #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC - case XFER_UDMA_6: - case XFER_UDMA_5: - case XFER_UDMA_4: - case XFER_UDMA_3: - case XFER_UDMA_2: - case XFER_UDMA_1: - case XFER_UDMA_0: - if (pmif->kind == controller_kl_ata4) - ret = set_timings_udma_ata4(&tl[0], speed); - else if (pmif->kind == controller_un_ata6 - || pmif->kind == controller_k2_ata6) - ret = set_timings_udma_ata6(&tl[0], &tl[1], speed); - else if (pmif->kind == controller_sh_ata6) - ret = set_timings_udma_shasta(&tl[0], &tl[1], speed); - else - ret = 1; - break; - case XFER_MW_DMA_2: - case XFER_MW_DMA_1: - case XFER_MW_DMA_0: - set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed); - break; - case XFER_SW_DMA_2: - case XFER_SW_DMA_1: - case XFER_SW_DMA_0: - return; + if (speed >= XFER_UDMA_0) { + if (pmif->kind == controller_kl_ata4) + ret = set_timings_udma_ata4(&tl[0], speed); + else if (pmif->kind == controller_un_ata6 + || pmif->kind == controller_k2_ata6) + ret = set_timings_udma_ata6(&tl[0], &tl[1], speed); + else if (pmif->kind == controller_sh_ata6) + ret = set_timings_udma_shasta(&tl[0], &tl[1], speed); + else + ret = -1; + } else + set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed); #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ - default: - ret = 1; - } if (ret) return; diff --git a/include/linux/ide.h b/include/linux/ide.h index 6f5b6b5..1e44099 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1094,6 +1094,7 @@ enum { IDE_HFLAG_IO_32BIT = (1 << 24), /* unmask IRQs */ IDE_HFLAG_UNMASK_IRQS = (1 << 25), + IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), }; #ifdef CONFIG_BLK_DEV_OFFBOARD -- cgit v0.10.2 From 4eed504d140319d6c1c7e0a5b7a9bf41dabf7cea Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:18 +0100 Subject: sc1200: move DMA timings to timing tables Based on pata_sc1200.c. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 569a8fe..fef20bd 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c @@ -135,57 +135,29 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) unsigned short pci_clock; unsigned int basereg = hwif->channel ? 0x50 : 0x40; + static const u32 udma_timing[3][3] = { + { 0x00921250, 0x00911140, 0x00911030 }, + { 0x00932470, 0x00922260, 0x00922140 }, + { 0x009436a1, 0x00933481, 0x00923261 }, + }; + + static const u32 mwdma_timing[3][3] = { + { 0x00077771, 0x00012121, 0x00002020 }, + { 0x000bbbb2, 0x00024241, 0x00013131 }, + { 0x000ffff3, 0x00035352, 0x00015151 }, + }; + pci_clock = sc1200_get_pci_clock(); /* * Note that each DMA mode has several timings associated with it. * The correct timing depends on the fast PCI clock freq. */ - timings = 0; - switch (mode) { - case XFER_UDMA_0: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00921250; break; - case PCI_CLK_48: timings = 0x00932470; break; - case PCI_CLK_66: timings = 0x009436a1; break; - } - break; - case XFER_UDMA_1: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00911140; break; - case PCI_CLK_48: timings = 0x00922260; break; - case PCI_CLK_66: timings = 0x00933481; break; - } - break; - case XFER_UDMA_2: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00911030; break; - case PCI_CLK_48: timings = 0x00922140; break; - case PCI_CLK_66: timings = 0x00923261; break; - } - break; - case XFER_MW_DMA_0: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00077771; break; - case PCI_CLK_48: timings = 0x000bbbb2; break; - case PCI_CLK_66: timings = 0x000ffff3; break; - } - break; - case XFER_MW_DMA_1: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00012121; break; - case PCI_CLK_48: timings = 0x00024241; break; - case PCI_CLK_66: timings = 0x00035352; break; - } - break; - case XFER_MW_DMA_2: - switch (pci_clock) { - case PCI_CLK_33: timings = 0x00002020; break; - case PCI_CLK_48: timings = 0x00013131; break; - case PCI_CLK_66: timings = 0x00015151; break; - } - break; - } + + if (mode >= XFER_UDMA_0) + timings = udma_timing[pci_clock][mode - XFER_UDMA_0]; + else + timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; if (unit == 0) { /* are we configuring drive0? */ pci_read_config_dword(hwif->pci_dev, basereg+4, ®); -- cgit v0.10.2 From 23b1bd459c9e8a925381960f0b69ac85468c3af1 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:19 +0100 Subject: ide: remove redundant ->ide_dma_on call from set_using_dma() ide_set_dma() calls ->ide_dma_on method itself and returns zero only if ->ide_dma_on call succeeded. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 4acd87e..00ef6ec 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -852,7 +852,7 @@ int set_using_dma(ide_drive_t *drive, int arg) if (arg) { hwif->dma_off_quietly(drive); - if (ide_set_dma(drive) || hwif->ide_dma_on(drive)) + if (ide_set_dma(drive)) err = -EIO; } else ide_dma_off(drive); -- cgit v0.10.2 From 7b905994ce0bd332afc5ebc30ce9afa60d23c6e2 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:19 +0100 Subject: ide: cleanup ide_set_dma() * ->dma_off_quietly is always called before ide_set_dma() so the call can be moved inside ide_set_dma(). * ide_dma_check() doesn't touch hardware so ->dma_off_quietly call for 'rc == -1' case is redundant, remove it. * '0' and '-1' are the only values returned by ide_dma_check() so remove dead code for other cases. There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 7568c3e..0103630 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -827,22 +827,19 @@ int ide_set_dma(ide_drive_t *drive) ide_hwif_t *hwif = drive->hwif; int rc; - rc = ide_dma_check(drive); + /* + * Force DMAing for the beginning of the check. + * Some chipsets appear to do interesting + * things, if not checked and cleared. + * PARANOIA!!! + */ + hwif->dma_off_quietly(drive); - switch(rc) { - case -1: /* DMA needs to be disabled */ - hwif->dma_off_quietly(drive); - return -1; - case 0: /* DMA needs to be enabled */ - return hwif->ide_dma_on(drive); - case 1: /* DMA setting cannot be changed */ - break; - default: - BUG(); - break; - } + rc = ide_dma_check(drive); + if (rc) + return rc; - return rc; + return hwif->ide_dma_on(drive); } #ifdef CONFIG_BLK_DEV_IDEDMA_PCI diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index e053e00..2711b5a 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -221,7 +221,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * */ if (drive->hwif->ide_dma_on == NULL) break; - drive->hwif->dma_off_quietly(drive); /* * TODO: respect ->using_dma setting */ diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 33e62d2..0379d1f 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -833,16 +833,8 @@ static void probe_hwif(ide_hwif_t *hwif) drive->nice1 = 1; - if (hwif->ide_dma_on) { - /* - * Force DMAing for the beginning of the check. - * Some chipsets appear to do interesting - * things, if not checked and cleared. - * PARANOIA!!! - */ - hwif->dma_off_quietly(drive); + if (hwif->ide_dma_on) ide_set_dma(drive); - } } } diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 00ef6ec..c6d4f63 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -851,7 +851,6 @@ int set_using_dma(ide_drive_t *drive, int arg) err = 0; if (arg) { - hwif->dma_off_quietly(drive); if (ide_set_dma(drive)) err = -EIO; } else -- cgit v0.10.2 From 61a368c216897aa3bbee35b3f2e6db76ec73fad0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 25 Jan 2008 22:17:19 +0100 Subject: ide: remove redundant DMA blacklist check from __ide_dma_on() ->ide_dma_on method is called only after successful ide_dma_check() call (ide_dma_check()->ide_tune_dma() checks DMA blacklist) or if drive->using_dma has been previously enabled for a given device (->ide_dma_on is the only place which sets drive->using_dma to '1'). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 0103630..18c78ad 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -491,10 +491,6 @@ EXPORT_SYMBOL(ide_dma_host_on); int __ide_dma_on (ide_drive_t *drive) { - /* consult the list of known "bad" drives */ - if (__ide_dma_bad_drive(drive)) - return 1; - drive->using_dma = 1; ide_toggle_bounce(drive, 1); -- cgit v0.10.2