ide: more core code housekeeping
cover ide: more core code housekeeping
SFF I/O code goes to ide-io-sff.c and error handling to ide-eh.c...
diffstat:
drivers/ide/Makefile | 5 drivers/ide/ide-atapi.c | 15 + drivers/ide/ide-eh.c | 427 +++++++++++++++++++++++++++++ drivers/ide/ide-io-sff.c | 314 +++++++++++++++++++++ drivers/ide/ide-io.c | 129 -------- drivers/ide/ide-iops.c | 691 ++--------------------------------------------- include/linux/ide.h | 13 7 files changed, 801 insertions(+), 793 deletions(-)
PATCH 1/6 ide: move ide_read_bcount_and_ireason() to ide-atapi.c
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: move ide_read_bcount_and_ireason() to ide-atapi.c
--- drivers/ide/ide-atapi.c | 15 +++++++++++++++ drivers/ide/ide-iops.c | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-)
drivers/ide/ide-atapi.c +15 -0
@@ -288,6 +288,21 @@ int ide_cd_get_xferlen(struct request *r }EXPORT_SYMBOL_GPL (ide_cd_get_xferlen); +void ide_read_bcount_and_ireason (ide_drive_t *drive,u16 *bcount,u8 *ireason) +{ +ide_task_t task; + +memset (&task,0 ,sizeof (task)); + task.tf_flags =IDE_TFLAG_IN_LBAH |IDE_TFLAG_IN_LBAM | +IDE_TFLAG_IN_NSECT ; + + drive->hwif->tp_ops->tf_read (drive, &task); + + *bcount = (task.tf.lbah <<8 ) | task.tf.lbam; + *ireason = task.tf.nsect &3 ; +} +EXPORT_SYMBOL_GPL (ide_read_bcount_and_ireason); +/* * This is the usual interrupt handler which will be called during a packet * command. We will transfer some of the data (as requested by the drive)
drivers/ide/ide-iops.c +0 -15
@@ -360,21 +360,6 @@ u8 ide_read_error(ide_drive_t *drive) }EXPORT_SYMBOL_GPL (ide_read_error); -void ide_read_bcount_and_ireason (ide_drive_t *drive,u16 *bcount,u8 *ireason) -{ -ide_task_t task; - -memset (&task,0 ,sizeof (task)); - task.tf_flags =IDE_TFLAG_IN_LBAH |IDE_TFLAG_IN_LBAM | -IDE_TFLAG_IN_NSECT ; - - drive->hwif->tp_ops->tf_read (drive, &task); - - *bcount = (task.tf.lbah <<8 ) | task.tf.lbam; - *ireason = task.tf.nsect &3 ; -} -EXPORT_SYMBOL_GPL (ide_read_bcount_and_ireason); -const struct ide_tp_ops default_tp_ops = { .exec_command = ide_exec_command, .read_status = ide_read_status,
PATCH 2/6 ide: move SFF I/O code to ide-io-sff.c
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: move SFF I/O code to ide-io-sff.c
--- drivers/ide/Makefile | 3 drivers/ide/ide-io-sff.c | 314 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-iops.c | 311 ---------------------------------------------- 3 files changed, 316 insertions(+), 312 deletions(-)
drivers/ide/Makefile +2 -1
@@ -5,7 +5,8 @@ EXTRA_CFLAGS += -Idrivers/ide ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ - ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o + ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ + ide-io-sff.o # core IDE code ide-core-$(CONFIG_IDE_XFER_MODE) += ide-pio-blacklist.o ide-xfer-mode.o
drivers/ide/ide-io-sff.c new file +314 -0
314 lines not on this page · raw message
drivers/ide/ide-iops.c +0 -311
329 lines not on this page · raw message
PATCH 3/6 ide: fix printk() levels in [atapi_]reset_pollfunc()
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: fix printk() levels in [atapi_]reset_pollfunc()
--- drivers/ide/ide-iops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/ide/ide-iops.c +5 -4
@@ -549,7 +549,7 @@ static ide_startstop_t atapi_reset_pollf stat = hwif->tp_ops->read_status (hwif);if (OK_STAT (stat,0 ,ATA_BUSY )) -printk ("%s: ATAPI reset complete\n" , drive->name); +printk (KERN_INFO "%s: ATAPI reset complete\n" , drive->name);else {if (time_before (jiffies, hwif->poll_timeout)) {ide_set_handler (drive, &atapi_reset_pollfunc,HZ /20 ,NULL );
@@ -558,8 +558,8 @@ static ide_startstop_t atapi_reset_pollf }/* end of polling */ hwif->polling =0 ; -printk ("%s: ATAPI reset timed-out, status=0x%02x\n" , - drive->name, stat); +printk (KERN_ERR "%s: ATAPI reset timed-out, status=0x%02x\n" , + drive->name, stat);/* do it the old fashioned way */ return do_reset1 (drive,1 ); }
@@ -618,7 +618,8 @@ static ide_startstop_t reset_pollfunc (i/* continue polling */ return ide_started; } -printk ("%s: reset timed-out, status=0x%02x\n" , hwif->name, tmp); +printk (KERN_ERR "%s: reset timed-out, status=0x%02x\n" , + hwif->name, tmp); drive->failures++; err = -EIO ; }else {
PATCH 4/6 ide: fix comments in ide_config_drive_speed()
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: fix comments in ide_config_drive_speed()
--- drivers/ide/ide-iops.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/ide/ide-iops.c +3 -6
@@ -369,18 +369,15 @@ int ide_config_drive_speed(ide_drive_t ** but for some reason these don't work at * this point (lost interrupt). */ -/* -* Select the drive, and issue the SETFEATURES command -*/ -disable_irq_nosync (hwif->irq); - +/* * FIXME: we race against the running IRQ here if * this is called from non IRQ context. If we use * disable_irq() we hang on the error path. Work * is needed. */ - +disable_irq_nosync (hwif->irq); +udelay (1 );SELECT_DRIVE (drive);SELECT_MASK (drive,1 );
PATCH 6/6 ide: move error handling code to ide-eh.c
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: move error handling code to ide-eh.c
Do some CodingStyle fixups in <linux/ide.h> while at it.
--- drivers/ide/Makefile | 2 drivers/ide/ide-eh.c | 427 +++++++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-io.c | 129 -------------- drivers/ide/ide-iops.c | 299 ---------------------------------- include/linux/ide.h | 13 - 5 files changed, 439 insertions(+), 431 deletions(-)
drivers/ide/Makefile +1 -1
@@ -6,7 +6,7 @@ EXTRA_CFLAGS += -Idrivers/ide ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ - ide-io-sff.o + ide-io-sff.o ide-eh.o # core IDE code ide-core-$(CONFIG_IDE_XFER_MODE) += ide-pio-blacklist.o ide-xfer-mode.o
drivers/ide/ide-eh.c new file +427 -0
427 lines not on this page · raw message
drivers/ide/ide-io.c +1 -128
141 lines not on this page · raw message
drivers/ide/ide-iops.c +2 -297
311 lines not on this page · raw message
include/linux/ide.h +8 -5
@@ -1144,11 +1144,14 @@ int generic_ide_ioctl(ide_drive_t *, strextern int ide_vlb_clk;extern int ide_pci_clk; -extern int ide_end_request (ide_drive_t *drive,int uptodate,int nrsecs); -int ide_end_dequeued_request (ide_drive_t *drive,struct request *rq, -int uptodate,int nr_sectors); - -extern void ide_set_handler (ide_drive_t *drive,ide_handler_t *handler,unsigned int timeout,ide_expiry_t *expiry); +int ide_end_request (ide_drive_t *,int ,int ); +int ide_end_dequeued_request (ide_drive_t *,struct request *,int ,int ); +void ide_kill_rq (ide_drive_t *,struct request *); + +void __ide_set_handler (ide_drive_t *,ide_handler_t *,unsigned int , +ide_expiry_t *); +void ide_set_handler (ide_drive_t *,ide_handler_t *,unsigned int , +ide_expiry_t *);void ide_execute_command (ide_drive_t *,u8 ,ide_handler_t *,unsigned int ,ide_expiry_t *);
PATCH 5/6 ide: checkpatch.pl fixes for ide-iops.c
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: checkpatch.pl fixes for ide-iops.c
Fix following checkpatch.pl warnings/errors:
- WARNING: space prohibited between function name and open parenthesis '('
- WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
- WARNING: line over 80 characters
- ERROR: trailing whitespace
- ERROR: space required before the open parenthesis '('
--- drivers/ide/ide-iops.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-)
drivers/ide/ide-iops.c +23 -25
@@ -27,7 +27,7 @@#include <asm/uaccess.h> #include <asm/io.h> -void SELECT_DRIVE (ide_drive_t *drive) +void SELECT_DRIVE (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif;const struct ide_port_ops *port_ops = hwif->port_ops;
@@ -84,7 +84,7 @@ void ide_fix_driveid(u16 *id)* returned by the ATA_CMD_ID_ATA[PI] commands. */ -void ide_fixstring (u8 *s,const int bytecount,const int byteswap) +void ide_fixstring (u8 *s,const int bytecount,const int byteswap) {u8 *p, *end = &s[bytecount & ~1 ];/* bytecount must be even */
@@ -107,7 +107,6 @@ void ide_fixstring (u8 *s, const int bytwhile (p != end) *p++ ='\0' ; } -EXPORT_SYMBOL (ide_fixstring);/*
@@ -121,7 +120,8 @@ EXPORT_SYMBOL(ide_fixstring);* setting a timer to wake up at half second intervals thereafter, * until timeout is achieved, before timing out. */ -static int __ide_wait_stat (ide_drive_t *drive,u8 good,u8 bad,unsigned long timeout,u8 *rstat) +static int __ide_wait_stat (ide_drive_t *drive,u8 good,u8 bad, +unsigned long timeout,u8 *rstat) {ide_hwif_t *hwif = drive->hwif;const struct ide_tp_ops *tp_ops = hwif->tp_ops;
@@ -179,7 +179,8 @@ static int __ide_wait_stat(ide_drive_t ** The caller should return the updated value of "startstop" in this case, * "startstop" is unchanged when the function returns 0. */ -int ide_wait_stat (ide_startstop_t *startstop,ide_drive_t *drive,u8 good,u8 bad,unsigned long timeout) +int ide_wait_stat (ide_startstop_t *startstop,ide_drive_t *drive,u8 good, +u8 bad,unsigned long timeout) {int err;u8 stat;
@@ -199,7 +200,6 @@ int ide_wait_stat(ide_startstop_t *startreturn err; } -EXPORT_SYMBOL (ide_wait_stat);/**
@@ -220,7 +220,6 @@ int ide_in_drive_list(u16 *id, const strreturn 1 ;return 0 ; } -EXPORT_SYMBOL_GPL (ide_in_drive_list);/*
@@ -245,7 +244,7 @@ static const struct drive_list_entry ivb* All hosts that use the 80c ribbon must use! * The name is derived from upper byte of word 93 and the 80c ribbon. */ -u8 eighty_ninty_three (ide_drive_t *drive) +u8 eighty_ninty_three (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif;u16 *id = drive->id;
@@ -470,9 +469,8 @@ void ide_set_handler (ide_drive_t *drive__ide_set_handler (drive, handler, timeout, expiry);spin_unlock_irqrestore (&hwif->lock, flags); } -EXPORT_SYMBOL (ide_set_handler); - +/** * ide_execute_command - execute an IDE command * @drive: IDE drive to issue the command against
@@ -482,7 +480,7 @@ EXPORT_SYMBOL(ide_set_handler);* @expiry: handler to run on timeout * * Helper function to issue an IDE command. This handles the -* atomicity requirements, command timing and ensures that the +* atomicity requirements, command timing and ensures that the * handler and IRQ setup do not race. All IDE command kick off * should go via this function or do equivalent locking. */
@@ -528,28 +526,29 @@ static inline void ide_complete_drive_re }/* needed below */ -static ide_startstop_t do_reset1 (ide_drive_t *,int ); +static ide_startstop_t do_reset1 (ide_drive_t *,int );/* -* atapi_reset_pollfunc() gets invoked to poll the interface for completion every 50ms -* during an atapi drive reset operation. If the drive has not yet responded, -* and we have not yet hit our maximum waiting time, then the timer is restarted -* for another 50ms. +* atapi_reset_pollfunc() gets invoked to poll the interface for completion +* every 50ms during an atapi drive reset operation. If the drive has not yet +* responded, and we have not yet hit our maximum waiting time, then the timer +* is restarted for another 50ms. */ -static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) +static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif;u8 stat;SELECT_DRIVE (drive); -udelay (10 ); +udelay (10 ); stat = hwif->tp_ops->read_status (hwif);if (OK_STAT (stat,0 ,ATA_BUSY ))printk (KERN_INFO "%s: ATAPI reset complete\n" , drive->name);else {if (time_before (jiffies, hwif->poll_timeout)) { -ide_set_handler (drive, &atapi_reset_pollfunc,HZ /20 ,NULL ); +ide_set_handler (drive, &atapi_reset_pollfunc,HZ /20 , +NULL );/* continue polling */ return ide_started; }
@@ -591,7 +590,7 @@ static void ide_reset_report_error(ide_h* and we have not yet hit our maximum waiting time, then the timer is restarted * for another 50ms. */ -static ide_startstop_t reset_pollfunc (ide_drive_t *drive) +static ide_startstop_t reset_pollfunc (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif;const struct ide_port_ops *port_ops = hwif->port_ops;
@@ -703,7 +702,7 @@ static void pre_reset(ide_drive_t *drive* (up to 30 seconds worstcase). So, instead of busy-waiting here for it, * we set a timer to poll at 50ms intervals. */ -static ide_startstop_t do_reset1 (ide_drive_t *drive,int do_not_try_atapi) +static ide_startstop_t do_reset1 (ide_drive_t *drive,int do_not_try_atapi) {ide_hwif_t *hwif = drive->hwif;struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -723,7 +722,7 @@ static ide_startstop_t do_reset1 (ide_drif (drive->media != ide_disk && !do_not_try_atapi) {pre_reset (drive);SELECT_DRIVE (drive); -udelay (20 ); +udelay (20 ); tp_ops->exec_command (hwif,ATA_CMD_DEV_RESET );ndelay (400 ); hwif->poll_timeout = jiffies +WAIT_WORSTCASE ;
@@ -807,11 +806,10 @@ static ide_startstop_t do_reset1 (ide_dr* ide_do_reset() is the entry point to the drive/interface reset code. */ -ide_startstop_t ide_do_reset (ide_drive_t *drive) +ide_startstop_t ide_do_reset (ide_drive_t *drive) {return do_reset1 (drive,0 ); } -EXPORT_SYMBOL (ide_do_reset);/*
@@ -822,7 +820,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, {u8 stat =0 ; -while (timeout--) { +while (timeout--) {/* * Turn this into a schedule() sleep once I'm sure * about locking issues (2.5 work ?).
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Bartlomiej ZolnierkiewiczQuoted 1 line · Bartlomiej Zolnierkiewicz
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
Gah, what in the world is that SFF I/O code?
Quoted 26 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +21
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/
drivers/ide/ide-io-sff.c line 31
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+ +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +} + +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}
Ah, I see. Can we finally stop abusing the SFF name? Or are we bound to
copy every mistake that libata has made? :-/
MBR, Sergei
Quoted 1 line · Bartlomiej Zolnierkiewicz
SFF I/O code goes to
ide-io-sff.cand error handling toide-eh.c...
There's no such thing as SFF I/O code I'm afraid -- whatever libata
authors might think...
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Sergei ShtylyovQuoted 37 lines · Sergei Shtylyov
Quoted 1 line · Bartlomiej Zolnierkiewicz
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Gah, what in the world is that SFF I/O code?
Quoted 31 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +26
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/ + +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +}
Quoted 8 lines
drivers/ide/ide-io-sff.c line 31
Quoted 5 lines
drivers/ide/ide-io-sff.c new file +5
-0+ +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}Ah, I see. Can we finally stop abusing the SFF name? Or are we bound to
copy every mistake that libata has made? :-/
Please suggest a better name. :)
[ I'm also not happy with the naming but couldn't think of a better one. ]
Re: [PATCH 4/6] ide: fix comments in ide_config_drive_speed()
In reply to Bartlomiej ZolnierkiewiczQuoted 1 line · Bartlomiej Zolnierkiewicz
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
Re: [PATCH 3/6] ide: fix printk() levels in [atapi_]reset_pollfunc()
In reply to Bartlomiej ZolnierkiewiczQuoted 1 line · Bartlomiej Zolnierkiewicz
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Bartlomiej ZolnierkiewiczQuoted 44 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines
Quoted 1 line
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Gah, what in the world is that SFF I/O code?
Quoted 31 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +26
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/ + +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +}Quoted 8 lines
drivers/ide/ide-io-sff.c line 31
Quoted 5 lines
drivers/ide/ide-io-sff.c new file +5
-0+ +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}Ah, I see. Can we finally stop abusing the SFF name? Or are we bound to
copy every mistake that libata has made? :-/
Quoted 3 lines
Please suggest a better name. :)
[ I'm also not happy with the naming but couldn't think of a better one. ]
Legacy perhaps?
WBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 44 lines · Hello, I wrote:
Quoted 43 lines
Quoted 43 lines
Quoted 1 line
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Gah, what in the world is that SFF I/O code?
Quoted 26 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +21
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/ drivers/ide/ide-io-sff.c line 31
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+ +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +} + +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}Ah, I see. Can we finally stop abusing the SFF name? Or are we
bound to copy every mistake that libata has made? :-/
Quoted 5 lines
Quoted 3 lines
Please suggest a better name. :)
[ I'm also not happy with the naming but couldn't think of a better one. ]
Legacy perhaps?
As in ide-io-legacy.c. I can also suggest ide-io-std.c,
ide-io-trad[itional].c...
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 48 lines · Sergei Shtylyov
Quoted 45 lines · Hello, I wrote:
Quoted 45 lines
Quoted 35 lines
Quoted 1 line
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Gah, what in the world is that SFF I/O code?
Quoted 31 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +26
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/ + +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +}Quoted 8 lines
drivers/ide/ide-io-sff.c line 31
Quoted 5 lines
drivers/ide/ide-io-sff.c new file +5
-0+ +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}Ah, I see. Can we finally stop abusing the SFF name? Or are we
bound to copy every mistake that libata has made? :-/Please suggest a better name. :)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
[ I'm also not happy with the naming but couldn't think of a better one. ]
Legacy perhaps?
As in
ide-io-legacy.c. I can also suggestide-io-std.c,
ide-io-trad[itional].c...
ide-io-std.c sounds good to me. I'll recast the patch before merging it.
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Bartlomiej ZolnierkiewiczQuoted 1 line · Bartlomiej Zolnierkiewicz
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
based on the promised file rename. :-)
Quoted 26 lines
Index:
b/drivers/ide/ide-io-sff.c
===================================================================drivers/ide/ide-io-sff.c new file +21
-0@@ -0,0 +1,314 @@ + +#include <linux/kernel.h> +#include <linux/ide.h> + +/* +* Conventional PIO operations for ATA devices +*/ + +static u8 ide_inb (unsigned long port) +{ +return (u8 )inb (port); +} + +static void ide_outb (u8 val,unsigned long port) +{ +outb (val, port); +} + +/* +* MMIO operations, typically used for SATA controllers +*/
drivers/ide/ide-io-sff.c line 31
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+ +static u8 ide_mm_inb (unsigned long port) +{ +return (u8 )readb ((void __iomem *) port); +} + +static void ide_mm_outb (u8 value,unsigned long port) +{ +writeb (value, (void __iomem *) port); +}
Inconsistent spacing in the type casts: space present everywhere above,
absent everywhere below...
Quoted 7 lines
drivers/ide/ide-io-sff.c new file +7
-0+void ide_set_irq (ide_hwif_t *hwif,int on) +{ +u8 ctl =ATA_DEVCTL_OBS ; + +if (on ==4 ) {/* hack for SRST */ + ctl |=4 ; + on &= ~4 ;
drivers/ide/ide-io-sff.c line 76
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+ } + + ctl |= on ?0 :2 ; + +if (hwif->host_flags &IDE_HFLAG_MMIO ) +writeb (ctl, (void __iomem *)hwif->io_ports.ctl_addr); +else +outb (ctl, hwif->io_ports.ctl_addr); +} +EXPORT_SYMBOL_GPL (ide_set_irq);
Ugh, I really need to convert set_irq() to write_devctl(), it's a pity I
hasn't done it still...
drivers/ide/ide-io-sff.c line 201
Quoted 8 lines
drivers/ide/ide-io-sff.c new file +8
-0+/* +* Some localbus EIDE interfaces require a special access sequence +* when using 32-bit I/O instructions to transfer data. We call this +* the "vlb_sync" sequence, which consists of three successive reads +* of the sector count register location, with interrupts disabled +* to ensure that the reads all happen together. +*/ +static void ata_vlb_sync (unsigned long port)
Not clear why this has ata_ prefix...
Quoted 24 lines
drivers/ide/ide-io-sff.c new file +24
-0+{ + (void )inb (port); + (void )inb (port); + (void )inb (port); +} + +/* +* This is used for most PIO data transfers *from* the IDE interface +* +* These routines will round up any request for an odd number of bytes, +* so if an odd len is specified, be sure that there's at least one +* extra byte allocated for the buffer. +*/ +void ide_input_data (ide_drive_t *drive,struct request *rq,void *buf, +unsigned int len) +{ +ide_hwif_t *hwif = drive->hwif; +struct ide_io_ports *io_ports = &hwif->io_ports; +unsigned long data_addr = io_ports->data_addr; +u8 io_32bit = drive->io_32bit; +u8 mmio = (hwif->host_flags &IDE_HFLAG_MMIO ) ?1 :0 ; + + len++; +
drivers/ide/ide-io-sff.c line 235
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+if (io_32bit) { +unsigned long uninitialized_var (flags ); + +if ((io_32bit &2 ) && !mmio) { +local_irq_save (flags); +ata_vlb_sync (io_ports->nsect_addr); + } + +if (mmio) +__ide_mm_insl ((void __iomem *)data_addr, buf, len /4 );
It's not clear why we're not using readsl()...
drivers/ide/ide-io-sff.c line 245
Quoted 10 lines
drivers/ide/ide-io-sff.c new file +10
-0+else +insl (data_addr, buf, len /4 ); + +if ((io_32bit &2 ) && !mmio) +local_irq_restore (flags); + +if ((len &3 ) >=2 ) { +if (mmio) +__ide_mm_insw ((void __iomem *)data_addr, + (u8 *)buf + (len & ~3 ),1 );
... ans readsw(). Ah, some archs do cache flushes around reads[wl]().
Besides, I doubt that the definitions in include/asm-generic/ide_iops.h are correct as they use read[wl]() in a loop which may not fly on BE...
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Sergei ShtylyovQuoted 3 lines
Quoted 1 line
[ I'm also not happy with the naming but couldn't think of a better one. ]
Legacy perhaps?
Legacy to most people means either ISA/VLB or the PCI legacy compatibility mode so that would be confusing.
BTW if you moved to ioreadX you could get rid of almost all the readb/inb special casing.
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Hello.
Quoted 6 lines · Alan Cox
Quoted 3 lines
Quoted 1 line
[ I'm also not happy with the naming but couldn't think of a better one. ]
Legacy perhaps?
Legacy to most people means either ISA/VLB or the PCI legacy compatibility mode so that would be confusing.
That's what this code is for (minus the MMIO accessors perhaps).
Quoted 2 lines
BTW if you moved to ioreadX you could get rid of almost all the readb/inb special casing.
And burden the driver code with function calls ISO in/out instructions, at
least on x86. It's somewhat arguable move.
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 5 lines
Quoted 2 lines
BTW if you moved to ioreadX you could get rid of almost all the readb/inb special casing.
And burden the driver code with function calls ISO in/out instructions, at
least on x86. It's somewhat arguable move.
And exactly how do you think the IDE accessors in the file get called ? It's already making function calls, without the benefit of inlining and sharing common paths across architectures that can handle more than just PIO v MMIO but also other addressing modes.
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 7 lines · Alan Cox
Quoted 5 lines
Quoted 2 lines
BTW if you moved to ioreadX you could get rid of almost all the readb/inb special casing.
And burden the driver code with function calls ISO in/out instructions, at
least on x86. It's somewhat arguable move.And exactly how do you think the IDE accessors in the file get called ?
Tried looking at how in*()/out*() are defined on x86?
Quoted 1 line
It's already making function calls, without the benefit of inlining and
I'm afraid you're wrong here.
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 1 line
Tried looking at how in*()/out*() are defined on x86?
Tried looking at how ide_mm_inb is defined on x86
Quoted 3 lines
Quoted 1 line
It's already making function calls, without the benefit of inlining and
I'm afraid you're wrong here.
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
Alan
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 3 lines · Alan Cox
Quoted 1 line
Tried looking at how in*()/out*() are defined on x86?
Tried looking at how
ide_mm_inbis defined on x86
That's a bogus argument because:
- MMIO isn't much used by the IDE drivers much (normally the inline ins*()/outs*() accessors are used;
- that's used only by generic IDE code, not by the drivers about which I'veargued;
I've already agreed that the generic code would probably win from using ioread*()/iowrite*().
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
It's already making function calls, without the benefit of inlining and
I'm afraid you're wrong here.
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
What IDE indirection you're talking about anyway?
Quoted 1 line
Alan
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Alan CoxQuoted 4 lines · Alan Cox
Quoted 1 line
Tried looking at how in*()/out*() are defined on x86?
Tried looking at how
ide_mm_inbis defined on x86
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
It's already making function calls, without the benefit of inlining and
I'm afraid you're wrong here.
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
I wish it would be so simple as I would have removed the said indirection long time ago. Unfortunately:
- not all archs support ioread() & co.
- there is still issue with cache aliasing on some CPUs
Once above deficiences get fixed we can look into ioread() conversion again.
[ IOW right now it is the correct thing to stick to ide_mm_*() indirection
since extra hardware coverage is more valuable than minor code cleanup. ]
Thanks,
Bart
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 13 lines · Bartlomiej Zolnierkiewicz
Quoted 4 lines
Quoted 1 line
Tried looking at how in*()/out*() are defined on x86?
Tried looking at how
ide_mm_inbis defined on x86Quoted 8 lines
Quoted 3 lines
Quoted 1 line
It's already making function calls, without the benefit of inlining and
I'm afraid you're wrong here.
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
Quoted 6 lines
I wish it would be so simple as I would have removed the said indirection long time ago. Unfortunately:
- not all archs support
ioread()& co.- there is still issue with cache aliasing on some CPUs
Yep, look at MIPS for an example.
Quoted 2 lines
Thanks,
Bart
MBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
In reply to Sergei ShtylyovQuoted 6 lines
Quoted 4 lines
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
What IDE indirection you're talking about anyway?
As I said earlier ide_mm_inb etc via the function pointers tf_inb/tf_outb etc.
Given how small those functions are it might even be worth rolling them into two different versions of the functions like ide_tf_read as surely it costs more to call them (in size) than to inline the two for those functions?
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Hello.
Quoted 11 lines · Alan Cox
Quoted 7 lines
Quoted 5 lines
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
What IDE indirection you're talking about anyway?
As I said earlier
ide_mm_inbetc via the function pointers tf_inb/tf_outb etc.
Ah... at least they don't have additional address checks that
ioread*()/iowrite*() have...
Quoted 5 lines
Given how small those functions are it might even be worth rolling them into two different versions of the functions like
ide_tf_readas surely it costs more to call them (in size) than to inline the two for those functions?
Indeed.
WBR, Sergei
Re: [PATCH 2/6] ide: move SFF I/O code to ide-io-sff.c
Quoted 8 lines · Hello, I wrote:
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
I'm afraid you are the one who is wrong. The IDE layer is duplicating a generic level of indirection with its own code - purely because IDE pre-dates that core functionality. The whole IDE layer indirection can go away because Linux has caught up with the needs of the IDE layer.
What IDE indirection you're talking about anyway?
Quoted 6 lines
Quoted 3 lines
As I said earlier
ide_mm_inbetc via the function pointers tf_inb/tf_outb etc.Ah... at least they don't have additional address checks that
ioread*()/iowrite*() have...
Somehow I was looling at __ide_mm_{ins|outs}*() calls in ide-iops.c
instead... it doesn't help to fix the USB code and argue about IDE at the same time. :-]
Quoted 7 lines
Quoted 4 lines
into two different versions of the functions like
ide_tf_readas surely it costs more to call them (in size) than to inline the two for those functions?Given how small those functions are it might even be worth rolling them
Indeed.
The calling fucntions aren't that small, so it's again arguable...
MBR, Sergei