From edafcf73dca2f9531c78eec130df84a8c9654b3b Mon Sep 17 00:00:00 2001 From: Grant Grundler Date: Wed, 8 Apr 2009 14:12:49 +0200 Subject: ide: remove wmb() from ide-dma-sff.c and scc_pata.c This patch: o replaces "mask" variable in ide_dma_end() with #define. o removes use of wmb() in ide-dma-sff.c and scc_pata.c. o is not tested - I don't have (or want) the HW. Signed-off-by: Grant Grundler Cc: KOBAYASHI Yoshitake Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 6d8dbd9c10b..55e48db7d1b 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -337,7 +337,6 @@ static void scc_dma_start(ide_drive_t *drive) /* start DMA */ scc_ide_outb(dma_cmd | 1, hwif->dma_base); - wmb(); } static int __scc_dma_end(ide_drive_t *drive) @@ -354,7 +353,6 @@ static int __scc_dma_end(ide_drive_t *drive) /* clear the INTR & ERROR bits */ scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); /* verify good DMA status */ - wmb(); return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; } -- cgit v1.2.3 From 60f85019c6c8c1aebf3485a313e0da094bc95d07 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:01 +0200 Subject: ide: replace IDE_TFLAG_* flags by IDE_VALID_* Replace IDE_TFLAG_{IN|OUT}_* flags meaning to the taskfile register validity on input/output by the IDE_VALID_* flags and introduce 4 symmetric 8-bit register validity indicator subfields, 'valid.{input/output}.{tf|hob}', into the 'struct ide_cmd' instead of using the 'tf_flags' field for that purpose (this field can then be turned from 32-bit into 8-bit one). Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 55e48db7d1b..38a715e293d 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -649,34 +649,37 @@ static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_taskfile *tf = &cmd->tf; + u8 valid = cmd->valid.out.hob; u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED) HIHI = 0xFF; - if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) + if (valid & IDE_VALID_FEATURE) scc_ide_outb(tf->hob_feature, io_ports->feature_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) + if (valid & IDE_VALID_NSECT) scc_ide_outb(tf->hob_nsect, io_ports->nsect_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) + if (valid & IDE_VALID_LBAL) scc_ide_outb(tf->hob_lbal, io_ports->lbal_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) + if (valid & IDE_VALID_LBAM) scc_ide_outb(tf->hob_lbam, io_ports->lbam_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) + if (valid & IDE_VALID_LBAH) scc_ide_outb(tf->hob_lbah, io_ports->lbah_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE) + valid = cmd->valid.out.tf; + + if (valid & IDE_VALID_FEATURE) scc_ide_outb(tf->feature, io_ports->feature_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT) + if (valid & IDE_VALID_NSECT) scc_ide_outb(tf->nsect, io_ports->nsect_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL) + if (valid & IDE_VALID_LBAL) scc_ide_outb(tf->lbal, io_ports->lbal_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM) + if (valid & IDE_VALID_LBAM) scc_ide_outb(tf->lbam, io_ports->lbam_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH) + if (valid & IDE_VALID_LBAH) scc_ide_outb(tf->lbah, io_ports->lbah_addr); - if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE) + if (valid & IDE_VALID_DEVICE) scc_ide_outb((tf->device & HIHI) | drive->select, io_ports->device_addr); } @@ -685,35 +688,38 @@ static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_taskfile *tf = &cmd->tf; + u8 valid = cmd->valid.in.tf; /* be sure we're looking at the low order bits */ scc_ide_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_ERROR) + if (valid & IDE_VALID_ERROR) tf->error = scc_ide_inb(io_ports->feature_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_NSECT) + if (valid & IDE_VALID_NSECT) tf->nsect = scc_ide_inb(io_ports->nsect_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_LBAL) + if (valid & IDE_VALID_LBAL) tf->lbal = scc_ide_inb(io_ports->lbal_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_LBAM) + if (valid & IDE_VALID_LBAM) tf->lbam = scc_ide_inb(io_ports->lbam_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_LBAH) + if (valid & IDE_VALID_LBAH) tf->lbah = scc_ide_inb(io_ports->lbah_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE) + if (valid & IDE_VALID_DEVICE) tf->device = scc_ide_inb(io_ports->device_addr); if (cmd->tf_flags & IDE_TFLAG_LBA48) { scc_ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR) + valid = cmd->valid.in.hob; + + if (valid & IDE_VALID_ERROR) tf->hob_error = scc_ide_inb(io_ports->feature_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT) + if (valid & IDE_VALID_NSECT) tf->hob_nsect = scc_ide_inb(io_ports->nsect_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL) + if (valid & IDE_VALID_LBAL) tf->hob_lbal = scc_ide_inb(io_ports->lbal_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM) + if (valid & IDE_VALID_LBAM) tf->hob_lbam = scc_ide_inb(io_ports->lbam_addr); - if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH) + if (valid & IDE_VALID_LBAH) tf->hob_lbah = scc_ide_inb(io_ports->lbah_addr); } } -- cgit v1.2.3 From 745483f10c6cefb303007c6873e2bfce54efa8ed Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:02 +0200 Subject: ide: simplify 'struct ide_taskfile' Make 'struct ide_taskfile' cover only 8 register values and thus put two such fields ('tf' and 'hob') into 'struct ide_cmd', dropping unnecessary 'tf_array' field from it. This required changing the prototype of ide_get_lba_addr() and ide_tf_dump(). Signed-off-by: Sergei Shtylyov [bart: fix setting of ATA_LBA bit for LBA48 commands in __ide_do_rw_disk()] Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 38a715e293d..1238d556197 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -648,7 +648,7 @@ static int __devinit init_setup_scc(struct pci_dev *dev, static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; - struct ide_taskfile *tf = &cmd->tf; + struct ide_taskfile *tf = &cmd->hob; u8 valid = cmd->valid.out.hob; u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; @@ -656,16 +656,17 @@ static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) HIHI = 0xFF; if (valid & IDE_VALID_FEATURE) - scc_ide_outb(tf->hob_feature, io_ports->feature_addr); + scc_ide_outb(tf->feature, io_ports->feature_addr); if (valid & IDE_VALID_NSECT) - scc_ide_outb(tf->hob_nsect, io_ports->nsect_addr); + scc_ide_outb(tf->nsect, io_ports->nsect_addr); if (valid & IDE_VALID_LBAL) - scc_ide_outb(tf->hob_lbal, io_ports->lbal_addr); + scc_ide_outb(tf->lbal, io_ports->lbal_addr); if (valid & IDE_VALID_LBAM) - scc_ide_outb(tf->hob_lbam, io_ports->lbam_addr); + scc_ide_outb(tf->lbam, io_ports->lbam_addr); if (valid & IDE_VALID_LBAH) - scc_ide_outb(tf->hob_lbah, io_ports->lbah_addr); + scc_ide_outb(tf->lbah, io_ports->lbah_addr); + tf = &cmd->tf; valid = cmd->valid.out.tf; if (valid & IDE_VALID_FEATURE) @@ -709,18 +710,19 @@ static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) if (cmd->tf_flags & IDE_TFLAG_LBA48) { scc_ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr); + tf = &cmd->hob; valid = cmd->valid.in.hob; if (valid & IDE_VALID_ERROR) - tf->hob_error = scc_ide_inb(io_ports->feature_addr); + tf->error = scc_ide_inb(io_ports->feature_addr); if (valid & IDE_VALID_NSECT) - tf->hob_nsect = scc_ide_inb(io_ports->nsect_addr); + tf->nsect = scc_ide_inb(io_ports->nsect_addr); if (valid & IDE_VALID_LBAL) - tf->hob_lbal = scc_ide_inb(io_ports->lbal_addr); + tf->lbal = scc_ide_inb(io_ports->lbal_addr); if (valid & IDE_VALID_LBAM) - tf->hob_lbam = scc_ide_inb(io_ports->lbam_addr); + tf->lbam = scc_ide_inb(io_ports->lbam_addr); if (valid & IDE_VALID_LBAH) - tf->hob_lbah = scc_ide_inb(io_ports->lbah_addr); + tf->lbah = scc_ide_inb(io_ports->lbah_addr); } } -- cgit v1.2.3 From 4109d19af73826aa6fee1a1b951670381be88f8b Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:02 +0200 Subject: ide: move common code out of tf_load() method Move device register masking (and setting drive->select) out of tf_load() method and into the only function that needs to use this code, do_rw_taskfile()... Signed-off-by: Sergei Shtylyov [bart: fix whitespace error] Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 1238d556197..f5a6fa0a8be 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -650,10 +650,6 @@ static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_taskfile *tf = &cmd->hob; u8 valid = cmd->valid.out.hob; - u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; - - if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED) - HIHI = 0xFF; if (valid & IDE_VALID_FEATURE) scc_ide_outb(tf->feature, io_ports->feature_addr); @@ -679,10 +675,8 @@ static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) scc_ide_outb(tf->lbam, io_ports->lbam_addr); if (valid & IDE_VALID_LBAH) scc_ide_outb(tf->lbah, io_ports->lbah_addr); - if (valid & IDE_VALID_DEVICE) - scc_ide_outb((tf->device & HIHI) | drive->select, - io_ports->device_addr); + scc_ide_outb(tf->device, io_ports->device_addr); } static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) -- cgit v1.2.3 From 30881b9ac91e7c23e0ceb8414ab7de1961809bdd Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:02 +0200 Subject: ide: call write_devctl() method from tf_read() method Use write_devctl() method to clear/set the HOB bit in tf_read() method. Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index f5a6fa0a8be..feabf548704 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -686,7 +686,7 @@ static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) u8 valid = cmd->valid.in.tf; /* be sure we're looking at the low order bits */ - scc_ide_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr); + scc_write_devctl(hwif, ATA_DEVCTL_OBS); if (valid & IDE_VALID_ERROR) tf->error = scc_ide_inb(io_ports->feature_addr); @@ -702,7 +702,7 @@ static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) tf->device = scc_ide_inb(io_ports->device_addr); if (cmd->tf_flags & IDE_TFLAG_LBA48) { - scc_ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr); + scc_write_devctl(hwif, ATA_HOB | ATA_DEVCTL_OBS); tf = &cmd->hob; valid = cmd->valid.in.hob; -- cgit v1.2.3 From c9ff9e7b64138d87023b733e618f29a1d58543f7 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:03 +0200 Subject: ide: refactor tf_load() method Simplify tf_load() method, making it deal only with 'struct ide_taskfile' and the validity flags that the upper layer passes, and moving the code that deals with the high order bytes into the only function interested, do_rw_taskfile(). This should stop the needless code duplication in this method and so make it about twice smaller than it was; along with simplifying the setup for the method call, this should save both time and space... Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index feabf548704..5ecb70cf29d 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -645,25 +645,9 @@ static int __devinit init_setup_scc(struct pci_dev *dev, return rc; } -static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) +static void scc_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; - struct ide_taskfile *tf = &cmd->hob; - u8 valid = cmd->valid.out.hob; - - if (valid & IDE_VALID_FEATURE) - scc_ide_outb(tf->feature, io_ports->feature_addr); - if (valid & IDE_VALID_NSECT) - scc_ide_outb(tf->nsect, io_ports->nsect_addr); - if (valid & IDE_VALID_LBAL) - scc_ide_outb(tf->lbal, io_ports->lbal_addr); - if (valid & IDE_VALID_LBAM) - scc_ide_outb(tf->lbam, io_ports->lbam_addr); - if (valid & IDE_VALID_LBAH) - scc_ide_outb(tf->lbah, io_ports->lbah_addr); - - tf = &cmd->tf; - valid = cmd->valid.out.tf; if (valid & IDE_VALID_FEATURE) scc_ide_outb(tf->feature, io_ports->feature_addr); -- cgit v1.2.3 From 3153c26b54230d025c6d536e8d3015def4524906 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 8 Apr 2009 14:13:03 +0200 Subject: ide: refactor tf_read() method Simplify tf_read() method, making it deal only with 'struct ide_taskfile' and the validity flags that the upper layer passes, and factoring out the code that deals with the high order bytes into ide_tf_readback() to be called from the only two functions interested, ide_complete_cmd() and ide_dump_sector(). This should stop the needless code duplication in this method and so make it about twice smaller than it was; along with simplifying the setup for the method call, this should save both time and space... Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/scc_pata.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'drivers/ide/scc_pata.c') diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 5ecb70cf29d..5be41f25204 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c @@ -663,14 +663,9 @@ static void scc_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) scc_ide_outb(tf->device, io_ports->device_addr); } -static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) +static void scc_tf_read(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) { struct ide_io_ports *io_ports = &drive->hwif->io_ports; - struct ide_taskfile *tf = &cmd->tf; - u8 valid = cmd->valid.in.tf; - - /* be sure we're looking at the low order bits */ - scc_write_devctl(hwif, ATA_DEVCTL_OBS); if (valid & IDE_VALID_ERROR) tf->error = scc_ide_inb(io_ports->feature_addr); @@ -684,24 +679,6 @@ static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) tf->lbah = scc_ide_inb(io_ports->lbah_addr); if (valid & IDE_VALID_DEVICE) tf->device = scc_ide_inb(io_ports->device_addr); - - if (cmd->tf_flags & IDE_TFLAG_LBA48) { - scc_write_devctl(hwif, ATA_HOB | ATA_DEVCTL_OBS); - - tf = &cmd->hob; - valid = cmd->valid.in.hob; - - if (valid & IDE_VALID_ERROR) - tf->error = scc_ide_inb(io_ports->feature_addr); - if (valid & IDE_VALID_NSECT) - tf->nsect = scc_ide_inb(io_ports->nsect_addr); - if (valid & IDE_VALID_LBAL) - tf->lbal = scc_ide_inb(io_ports->lbal_addr); - if (valid & IDE_VALID_LBAM) - tf->lbam = scc_ide_inb(io_ports->lbam_addr); - if (valid & IDE_VALID_LBAH) - tf->lbah = scc_ide_inb(io_ports->lbah_addr); - } } static void scc_input_data(ide_drive_t *drive, struct ide_cmd *cmd, -- cgit v1.2.3