27 Jun, 2017

1 commit

  • VT6420 seems to have the same hotplug capability as VT6421.

    However, enabling hotplug needs to expose SCR registers which can cause
    problems. It works for me but might break elsewhere. So add a module
    parameter vt6420_hotplug to enable this feature.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Tejun Heo

    Ondrej Zary
     

13 Jun, 2017

1 commit


16 May, 2017

1 commit


11 Apr, 2017

1 commit

  • Commit 57e5568fda27 ("sata_via: Implement hotplug for VT6421") adds
    hotplug IRQ handler for VT6421 but enables hotplug on all chips. This
    is a bug because it causes "irq xx: nobody cared" error on VT6420 when
    hot-(un)plugging a drive:

    [ 381.839948] irq 20: nobody cared (try booting with the "irqpoll" option)
    [ 381.840014] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.10.0-rc5+ #148
    [ 381.840066] Hardware name: P4VM800/P4VM800, BIOS P1.60 05/29/2006
    [ 381.840117] Call Trace:
    [ 381.840167]
    [ 381.840225] ? dump_stack+0x44/0x58
    [ 381.840278] ? __report_bad_irq+0x14/0x97
    [ 381.840327] ? handle_edge_irq+0xa5/0xa5
    [ 381.840376] ? note_interrupt+0x155/0x1cf
    [ 381.840426] ? handle_edge_irq+0xa5/0xa5
    [ 381.840474] ? handle_irq_event_percpu+0x32/0x38
    [ 381.840524] ? handle_irq_event+0x1f/0x38
    [ 381.840573] ? handle_fasteoi_irq+0x69/0xb8
    [ 381.840625] ? handle_irq+0x4f/0x5d
    [ 381.840672]
    [ 381.840726] ? do_IRQ+0x2e/0x8b
    [ 381.840782] ? common_interrupt+0x2c/0x34
    [ 381.840836] ? mwait_idle+0x60/0x82
    [ 381.840892] ? arch_cpu_idle+0x6/0x7
    [ 381.840949] ? do_idle+0x96/0x18e
    [ 381.841002] ? cpu_startup_entry+0x16/0x1a
    [ 381.841057] ? start_kernel+0x319/0x31c
    [ 381.841111] ? startup_32_smp+0x166/0x168
    [ 381.841165] handlers:
    [ 381.841219] [] ata_bmdma_interrupt
    [ 381.841274] Disabling IRQ #20

    Seems that VT6420 can do hotplug too (there's no documentation) but the
    comments say that SCR register access (required for detecting hotplug
    events) can cause problems on these chips.

    For now, just keep hotplug disabled on anything other than VT6421.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Tejun Heo

    Ondrej Zary
     

26 Feb, 2016

2 commits

  • Enable IRQ on hotplug and add an interrupt handler to handle it.

    This allows hotplug to work:
    ata5: exception Emask 0x10 SAct 0x0 SErr 0x70000 action 0xe frozen
    ata5: SError: { PHYRdyChg PHYInt CommWake }
    ata5: hard resetting link
    ata5: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
    ata5.00: LPM support broken, forcing max_power
    ata5.00: ATA-7: WDC WD800JD-75MSA3, 10.01E04, max UDMA/133
    ata5.00: 156250000 sectors, multi 0: LBA48 NCQ (depth 0/32)
    ata5.00: LPM support broken, forcing max_power
    ata5.00: configured for UDMA/133
    ata5: EH complete
    scsi 4:0:0:0: Direct-Access ATA WDC WD800JD-75MS 1E04 PQ: 0 ANSI: 5
    sd 4:0:0:0: [sdb] 156250000 512-byte logical blocks: (80.0 GB/74.5 GiB)
    sd 4:0:0:0: [sdb] Write Protect is off
    sd 4:0:0:0: [sdb] Mode Sense: 00 3a 00 00
    sd 4:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
    sd 4:0:0:0: Attached scsi generic sg1 type 0
    sd 4:0:0:0: [sdb] Attached SCSI disk

    And also hot unplug:
    ata5: exception Emask 0x10 SAct 0x0 SErr 0x1b0000 action 0xe frozen
    ata5: SError: { PHYRdyChg PHYInt 10B8B Dispar }
    ata5: hard resetting link
    ata5: SATA link down (SStatus 0 SControl 310)
    ata5: hard resetting link
    ata5: SATA link down (SStatus 0 SControl 310)
    ata5: hard resetting link
    ata5: SATA link down (SStatus 0 SControl 310)
    ata5.00: disabled
    ata5: EH complete
    ata5.00: detaching (SCSI 4:0:0:0)
    sd 4:0:0:0: [sdb] Synchronizing SCSI cache
    sd 4:0:0:0: [sdb] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    sd 4:0:0:0: [sdb] Stopping disk
    sd 4:0:0:0: [sdb] Start/Stop Unit failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

    Signed-off-by: Ondrej Zary
    Signed-off-by: Tejun Heo

    Ondrej Zary
     
  • Currently, workaround for broken WD drives is applied always, slowing
    down all drives. And it has a bug - it's not applied after resume.

    Apply the workaround only if the error really appears
    (SErr == 0x1000500). This allows unaffected drives to run at full speed
    (provided that no affected drive is connected to the controller).
    Also make sure the workaround is re-applied on resume.

    Tested on VT6421.
    As SCR registers access is known to cause problems on VT6420 (and I
    don't have it to test), keep the workaround applied always on VT6420.

    Unaffected drive (Hitachi HDS721680PLA380):
    Before:
    $ hdparm -t --direct /dev/sdb
    /dev/sdb:
    Timing O_DIRECT disk reads: 160 MB in 3.01 seconds = 53.16 MB/sec

    After:
    $ hdparm -t --direct /dev/sdb
    /dev/sdb:
    Timing O_DIRECT disk reads: 200 MB in 3.01 seconds = 66.47 MB/sec

    Affected drive (WDC WD5003ABYX-18WERA0):
    Before:
    $ hdparm -t --direct /dev/sda

    /dev/sda:
    Timing O_DIRECT disk reads: 180 MB in 3.02 seconds = 59.51 MB/sec

    After:
    $ hdparm -t --direct /dev/sdb
    /dev/sdb:
    Timing O_DIRECT disk reads: 156 MB in 3.03 seconds = 51.48 MB/sec
    $ hdparm -t --direct /dev/sdb
    /dev/sdb:
    Timing O_DIRECT disk reads: 180 MB in 3.02 seconds = 59.64 MB/sec

    The first hdparm is slower because of the error:
    [ 50.408042] ata5: Incompatible drive: enabling workaround. This slows down transfer rate to ~60 MB/s
    [ 50.728052] ata5: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
    [ 50.744834] ata5.00: configured for UDMA/133

    Signed-off-by: Ondrej Zary
    Signed-off-by: Tejun Heo

    Ondrej Zary
     

08 Apr, 2015

1 commit

  • Replace occurences of the pci api by appropriate call to the dma api.

    A simplified version of the semantic patch that finds this problem is as
    follows: (http://coccinelle.lip6.fr)

    @deprecated@
    idexpression id;
    position p;
    @@

    (
    pci_dma_supported@p ( id, ...)
    |
    pci_alloc_consistent@p ( id, ...)
    )

    @bad1@
    idexpression id;
    position deprecated.p;
    @@
    ...when != &id->dev
    when != pci_get_drvdata ( id )
    when != pci_enable_device ( id )
    (
    pci_dma_supported@p ( id, ...)
    |
    pci_alloc_consistent@p ( id, ...)
    )

    @depends on !bad1@
    idexpression id;
    expression direction;
    position deprecated.p;
    @@

    (
    - pci_dma_supported@p ( id,
    + dma_supported ( &id->dev,
    ...
    + , GFP_ATOMIC
    )
    |
    - pci_alloc_consistent@p ( id,
    + dma_alloc_coherent ( &id->dev,
    ...
    + , GFP_ATOMIC
    )
    )

    Signed-off-by: Quentin Lambert
    Signed-off-by: Tejun Heo

    Quentin Lambert
     

10 May, 2014

1 commit

  • This patch fixes host drivers to use CONFIG_PM_SLEEP instead of CONFIG_PM
    where applicable. Benefits of this change:

    * unused code is not being compiled in for CONFIG_PM=y, CONFIG_PM_SLEEP=n
    and CONFIG_PM_RUNTIME=y configurations

    * easier transition to use struct dev_pm_ops and SIMPLE_DEV_PM_OPS() in
    the future

    * more consistent code (there are host drivers which are using the correct
    CONFIG_PM_SLEEP checks already)

    The patch leaves the core libata code and ->port_[suspend,resume] support
    in sata_[inic162x,nv,sil24].c alone for now.

    Signed-off-by: Bartlomiej Zolnierkiewicz
    Signed-off-by: Tejun Heo

    Bartlomiej Zolnierkiewicz
     

14 Feb, 2014

1 commit


15 May, 2013

1 commit


26 Jul, 2012

1 commit

  • This patch converts the drivers in drivers/ata/* to use module_pci_driver()
    macro which makes the code smaller and a bit simpler.

    Signed-off-by: Axel Lin
    Cc: Alan Cox
    Cc: Jeff Garzik
    Cc: Mikael Pettersson
    Cc: Mark Lord
    Cc: Jeremy Higdon
    Cc: Benjamin Herrenschmidt
    Signed-off-by: Jeff Garzik

    Axel Lin
     

24 Jul, 2011

4 commits

  • Use normal debugging path for dynamic debug capability.

    Convert dev_printk(KERN_DEBUG to dev_dbg(

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     
  • Use a single mechanism to show driver version.
    Reduces text a tiny bit too.

    Remove uses of static int printed_version
    Add and use ata_print_version(const struct device *, const char *ver)
    and ata_print_version_once.

    $ size drivers/ata/built-in.*
    text data bss dec hex filename
    544969 73893 116584 735446 b38d6 drivers/ata/built-in.allyesconfig.ata.o
    543870 73893 116592 734355 b34ad drivers/ata/built-in.allyesconfig.print_once.o
    141328 14689 4220 160237 271ed drivers/ata/built-in.defconfig.ata.o
    141212 14689 4220 160121 27179 drivers/ata/built-in.defconfig.print_once.o

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     
  • Saves text by removing nearly duplicated text format strings by
    creating ata__printk functions and printf extension %pV.

    ata defconfig size shrinks ~5% (~8KB), allyesconfig ~2.5% (~13KB)

    Format string duplication comes from:

    #define ata_link_printk(link, lv, fmt, args...) do { \
    if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
    printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
    (link)->pmp , ##args); \
    else \
    printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
    } while(0)

    Coalesce long formats.

    $ size drivers/ata/built-in.*
    text data bss dec hex filename
    544969 73893 116584 735446 b38d6 drivers/ata/built-in.allyesconfig.ata.o
    558429 73893 117864 750186 b726a drivers/ata/built-in.allyesconfig.dev_level.o
    141328 14689 4220 160237 271ed drivers/ata/built-in.defconfig.ata.o
    149567 14689 4220 168476 2921c drivers/ata/built-in.defconfig.dev_level.o

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     
  • Saves a bit of text as the call takes fewer args.

    Coalesce a few formats.
    Convert a few bare printks to pr_cont.

    $ size drivers/ata/built-in.o*
    text data bss dec hex filename
    558429 73893 117864 750186 b726a drivers/ata/built-in.o.allyesconfig.new
    559574 73893 117888 751355 b76fb drivers/ata/built-in.o.allyesconfig.old
    149567 14689 4220 168476 2921c drivers/ata/built-in.o.defconfig.new
    149851 14689 4220 168760 29338 drivers/ata/built-in.o.defconfig.old

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     

31 Mar, 2011

1 commit


02 Mar, 2011

1 commit

  • All checks of ATA_FLAG_NO_LEGACY have been removed by the commits
    c791c30670ea61f19eec390124128bf278e854fe ([libata] minor PCI IDE probe
    fixes and cleanups) and f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (libata:
    update libata core layer to use devres), so I think it's time to finally
    get rid of this flag...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Jeff Garzik

    Sergei Shtylyov
     

20 Nov, 2010

1 commit

  • vt6420 has the same FIFO overflow problem as vt6421 when combined with
    certain devices. This patch applies the magic fix to vt6420 too.

    Signed-off-by: Tejun Heo
    Reported-by: Martin Qvist
    Reported-by: Peter Zijlstra
    Cc: Joseph Chan
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

22 Oct, 2010

1 commit


08 Jun, 2010

1 commit


03 Jun, 2010

1 commit

  • vt6421 has problems talking to recent WD drives. It causes a lot of
    transmission errors while high bandwidth transfer as reported in the
    following bugzilla entry.

    https://bugzilla.kernel.org/show_bug.cgi?id=15173

    Joseph Chan provided the following fix. I don't have any idea what it
    does but I can verify the issue is gone with the patch applied.

    Signed-off-by: Tejun Heo
    Originally-from: Joseph Chan
    Reported-by: Jorrit Tijben
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

26 May, 2010

3 commits

  • Separate out ata_pci_bmdma_prepare_host() and ata_pci_bmdma_init_one()
    from their SFF counterparts. SFF ones no longer try to initialize
    BMDMA or set PCI master.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Separate out BMDMA irq handler from SFF irq handler. The misnamed
    host_intr() functions are renamed to ata_sff_port_intr() and
    ata_bmdma_port_intr(). Common parts are factored into
    __ata_sff_port_intr() and __ata_sff_interrupt() and used by sff and
    bmdma interrupt routines.

    All BMDMA drivers now use ata_bmdma_interrupt() or
    ata_bmdma_port_intr() while all non-BMDMA SFF ones use
    ata_sff_interrupt() or ata_sff_port_intr().

    For now, ata_pci_sff_init_one() uses ata_bmdma_interrupt() as it's
    used by both SFF and BMDMA drivers.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • ata_sff_irq_clear() is BMDMA specific. Rename it to
    ata_bmdma_irq_clear(), move it to ata_bmdma_port_ops and make
    ->sff_irq_clear() optional.

    Note: ata_bmdma_irq_clear() is actually only needed by ata_piix and
    possibly by sata_sil. This should be moved to respective low
    level drivers later.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

02 Mar, 2010

2 commits

  • When writing a disc on certain lite-on dvd-writers (also rebadged
    as optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends
    up in the datastream and on the disc, causing silent corruption.
    Delaying between sending the CDB and starting DMA seems to
    prevent this.

    I do not know if there are burners that do not suffer from
    this, but the patch should be safe for those as well.

    There are many reports of this issue, but AFAICT no solution was
    found before. For example:
    http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html

    Signed-off-by: Bart Hartgers
    Signed-off-by: Jeff Garzik

    Bart Hartgers
     
  • Before only the timings for master were set. Datasheet can be found
    here: ftp://ftp.vtbridge.org/Docs/Storage/DS_VT6421A_100_CCPL.PDF
    Surprisingly, a slave drive works without this patch. According to the
    datasheet, the controller by default derives the DMA mode from the
    Set Features command issued to a drive. Not sure about the PIO
    timings, though. The real problem is that the timings for the master
    effectively are the ones tuned for the slave. If these support
    different UDMA-settings, there is trouble, especially when the slave
    supports a higher UDMA than the master.

    Anyhow, using the same mechanism for both master and slave seems like
    a good idea.

    Signed-off-by: Bart Hartgers
    Acked-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Bart Hartgers
     

04 Nov, 2009

1 commit


13 Apr, 2009

1 commit


25 Mar, 2009

1 commit


16 Jan, 2009

1 commit


04 Nov, 2008

1 commit

  • commit b9d5b89b487517cbd4cb4702da829e07ef9e4432 (sata_via: fix support
    for 5287) accidently (?) removed vt*_prepare_host error handling - restore it

    catched by gcc:
    drivers/ata/sata_via.c: In function 'svia_init_one':
    drivers/ata/sata_via.c:567: warning: 'host' may be used uninitialized in this function

    Signed-off-by: Marcin Slusarz
    Cc: Tejun Heo
    Cc: Joseph Chan
    Cc: Jeff Garzik
    Signed-off-by: Jeff Garzik

    Marcin Slusarz
     

31 Oct, 2008

1 commit

  • 5287 used to be treated as vt6420 but it didn't work. It's new family
    of controllers called vt8251 which hosts four SATA ports as M/S of the
    two ATA ports. This configuration is rather peculiar in that although
    the M/S devices are on the same port, each have its own SCR (or
    equivalent link status/control) registers which screws up the
    port-link-device hierarchy assumed by libata. Another controller
    which falls into this category is ata_piix w/ SIDPR access.

    libata now has facility to deal with this class of controllers named
    slave_link. A low level driver for such controllers can just call
    ata_slave_link_init() on the respective ports and libata will handle
    all the difficult parts like following up with single SRST after
    hardresetting both ports.

    This patch creates new controller class vt8251, implements slave_link
    aware init sequence and config space based SCR access for it and moves
    5287 to the new class.

    This patch is based on Joseph Chan's larger patch which was created
    before slave_link was implemented in libata.

    http://thread.gmane.org/gmane.linux.kernel.commits.mm/40640

    Signed-off-by: Tejun Heo
    Cc: Joseph Chan
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

23 Oct, 2008

1 commit

  • VIA controllers clear DEVICE register when IEN changes. Make sure
    DEVICE is updated along with CTL.

    This change is separated from Joseph Chan's larger patch.

    http://thread.gmane.org/gmane.linux.kernel.commits.mm/40640

    Signed-off-by: Tejun Heo
    Cc: Joseph Chan
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

29 Sep, 2008

1 commit

  • Logically, SCR access ops should take @link; however, there was no
    compelling reason to convert all SCR access ops when adding @link
    abstraction as there's one-to-one mapping between a port and a non-PMP
    link. However, that assumption won't hold anymore with the scheduled
    addition of slave link.

    Make SCR access ops per-link.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

18 Apr, 2008

6 commits

  • Previously, post-softreset readiness is waited as follows.

    1. ata_sff_wait_after_reset() waits for 150ms and then for
    ATA_TMOUT_FF_WAIT if status is 0xff and other conditions meet.

    2. ata_bus_softreset() finishes with -ENODEV if status is still 0xff.
    If not, continue to #3.

    3. ata_bus_post_reset() waits readiness of dev0 and/or dev1 depending
    on devmask using ata_sff_wait_ready().

    And for post-hardreset readiness,

    1. ata_sff_wait_after_reset() waits for 150ms and then for
    ATA_TMOUT_FF_WAIT if status is 0xff and other conditions meet.

    2. sata_sff_hardreset waits for device readiness using
    ata_sff_wait_ready().

    This patch merges and unifies post-reset readiness waits into
    ata_sff_wait_ready() and ata_sff_wait_after_reset().

    ATA_TMOUT_FF_WAIT handling is merged into ata_sff_wait_ready(). If TF
    status is 0xff, link status is unknown and the port is SATA, it will
    continue polling till ATA_TMOUT_FF_WAIT.

    ata_sff_wait_after_reset() is updated to perform the following steps.

    1. waits for 150ms.

    2. waits for dev0 readiness using ata_sff_wait_ready(). Note that
    this is done regardless of devmask, as ata_sff_wait_ready() handles
    0xff status correctly, this preserves the original behavior except
    that it may wait longer after softreset if link is online but
    status is 0xff. This behavior change is very unlikely to cause any
    actual difference and is intended. It brings softreset behavior to
    that of hardreset.

    3. waits for dev1 readiness just the same way ata_bus_post_reset() did.

    Now both soft and hard resets call ata_sff_wait_after_reset() after
    reset to wait for readiness after resets. As
    ata_sff_wait_after_reset() contains calls to ->sff_dev_select(),
    explicit call near the end of sata_sff_hardreset() is removed.

    This change makes reset implementation simpler and more consistent.

    While at it, make the magical 150ms wait post-reset wait duration a
    constant and ata_sff_wait_ready() and ata_sff_wait_after_reset() take
    @link instead of @ap. This is to make them consistent with other
    reset helpers and ease core changes.

    pata_scc is updated accordingly.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Add sff_ prefix to SFF specific port ops.

    This rename is in preparation of separating SFF support out of libata
    core layer. This patch strictly renames ops and doesn't introduce any
    behavior difference.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • SFF functions have confusing names. Some have sff prefix, some have
    bmdma, some std, some pci and some none. Unify the naming by...

    * SFF functions which are common to both BMDMA and non-BMDMA are
    prefixed with ata_sff_.

    * SFF functions which are specific to BMDMA are prefixed with
    ata_bmdma_.

    * SFF functions which are specific to PCI but apply to both BMDMA and
    non-BMDMA are prefixed with ata_pci_sff_.

    * SFF functions which are specific to PCI and BMDMA are prefixed with
    ata_pci_bmdma_.

    * Drop generic prefixes from LLD specific routines. For example,
    bfin_std_dev_select -> bfin_dev_select.

    The following renames are noteworthy.

    ata_qc_issue_prot() -> ata_sff_qc_issue()
    ata_pci_default_filter() -> ata_bmdma_mode_filter()
    ata_dev_try_classify() -> ata_sff_dev_classify()

    This rename is in preparation of separating SFF support out of libata
    core layer. This patch strictly renames functions and doesn't
    introduce any behavior difference.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • ata_chk_status() just calls ops->check_status and it only adds
    confusion with other status functions. Kill it.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Currently reset methods are not specified directly in the
    ata_port_operations table. If a LLD wants to use custom reset
    methods, it should construct and use a error_handler which uses those
    reset methods. It's done this way for two reasons.

    First, the ops table already contained too many methods and adding
    four more of them would noticeably increase the amount of necessary
    boilerplate code all over low level drivers.

    Second, as ->error_handler uses those reset methods, it can get
    confusing. ie. By overriding ->error_handler, those reset ops can be
    made useless making layering a bit hazy.

    Now that ops table uses inheritance, the first problem doesn't exist
    anymore. The second isn't completely solved but is relieved by
    providing default values - most drivers can just override what it has
    implemented and don't have to concern itself about higher level
    callbacks. In fact, there currently is no driver which actually
    modifies error handling behavior. Drivers which override
    ->error_handler just wraps the standard error handler only to prepare
    the controller for EH. I don't think making ops layering strict has
    any noticeable benefit.

    This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
    their PMP counterparts propoer ops. Default ops are provided in the
    base ops tables and drivers are converted to override individual reset
    methods instead of creating custom error_handler.

    * ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
    aren't accessible. sata_promise doesn't need to use separate
    error_handlers for PATA and SATA anymore.

    * softreset is broken for sata_inic162x and sata_sx4. As libata now
    always prefers hardreset, this doesn't really matter but the ops are
    forced to NULL using ATA_OP_NULL for documentation purpose.

    * pata_hpt374 needs to use different prereset for the first and second
    PCI functions. This used to be done by branching from
    hpt374_error_handler(). The proper way to do this is to use
    separate ops and port_info tables for each function. Converted.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • libata lets low level drivers build ata_port_operations table and
    register it with libata core layer. This allows low level drivers
    high level of flexibility but also burdens them with lots of
    boilerplate entries.

    This becomes worse for drivers which support related similar
    controllers which differ slightly. They share most of the operations
    except for a few. However, the driver still needs to list all
    operations for each variant. This results in large number of
    duplicate entries, which is not only inefficient but also error-prone
    as it becomes very difficult to tell what the actual differences are.

    This duplicate boilerplates all over the low level drivers also make
    updating the core layer exteremely difficult and error-prone. When
    compounded with multi-branched development model, it ends up
    accumulating inconsistencies over time. Some of those inconsistencies
    cause immediate problems and fixed. Others just remain there dormant
    making maintenance increasingly difficult.

    To rectify the problem, this patch implements ata_port_operations
    inheritance. To allow LLDs to easily re-use their own ops tables
    overriding only specific methods, this patch implements poor man's
    class inheritance. An ops table has ->inherits field which can be set
    to any ops table as long as it doesn't create a loop. When the host
    is started, the inheritance chain is followed and any operation which
    isn't specified is taken from the nearest ancestor which has it
    specified. This operation is called finalization and done only once
    per an ops table and the LLD doesn't have to do anything special about
    it other than making the ops table non-const such that libata can
    update it.

    libata provides four base ops tables lower drivers can inherit from -
    base, sata, pmp, sff and bmdma. To avoid overriding these ops
    accidentaly, these ops are declared const and LLDs should always
    inherit these instead of using them directly.

    After finalization, all the ops table are identical before and after
    the patch except for setting .irq_handler to ata_interrupt in drivers
    which didn't use to. The .irq_handler doesn't have any actual effect
    and the field will soon be removed by later patch.

    * sata_sx4 is still using old style EH and currently doesn't take
    advantage of ops inheritance.

    Signed-off-by: Tejun Heo

    Tejun Heo