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

9 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
     
  • libata lets low level drivers build scsi_host_template and register it
    to the SCSI layer. This allows low level drivers high level of
    flexibility but also burdens them with lots of boilerplate entries.

    This patch implements SHT initializers which can be used to initialize
    all the boilerplate entries in a sht. Three variants of them are
    implemented - BASE, BMDMA and NCQ - for different types of drivers.
    Note that entries can be overriden by putting individual initializers
    after the helper macro.

    All sht tables are identical before and after this patch.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Over the time, port info, ops and sht structures developed quite a bit
    of inconsistencies. This patch updates drivers.

    * Enable/disable_pm callbacks added to all ahci ops tables.

    * Every driver for SFF controllers now uses ata_sff_port_start()
    instead of ata_port_start() unless the driver has custom
    implementation.

    * Every driver for SFF controllers now uses ata_pci_default_filter()
    unless the driver has custom implementation.

    * Removed an odd port_info->sht initialization from ata_piix.c.
    Likely a merge byproduct.

    * A port which has ATA_FLAG_SATA set doesn't need to set cable_detect
    to ata_cable_sata(). Remove it from via and mv port ops.

    * Some drivers had unnecessary .max_sectors initialization which is
    ignored and was missing .slave_destroy callback. Fixed.

    * Removed unnecessary sht initializations port_info's.

    * Removed onsolete scsi device suspend/resume callbacks from
    pata_bf54x.

    * No reason to set ata_pci_default_filter() and bmdma functions for
    PIO-only drivers. Remove those callbacks and replace
    ata_bmdma_irq_clear with ata_noop_irq_clear.

    * pata_platform sets port_start to ata_dummy_ret0. port_start can
    just be set to NULL.

    * sata_fsl supports NCQ but was missing qc_defer. Fixed.

    * pata_rb600_cf implements dummy port_start. Removed.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • When both soft and hard resets are available, libata preferred
    softreset till now. The logic behind it was to be softer to devices;
    however, this doesn't really help much. Rationales for the change:

    * BIOS may freeze lock certain things during boot and softreset can't
    unlock those. This by itself is okay but during operation PHY event
    or other error conditions can trigger hardreset and the device may
    end up with different configuration.

    For example, after a hardreset, previously unlockable HPA can be
    unlocked resulting in different device size and thus revalidation
    failure. Similar condition can occur during or after resume.

    * Certain ATAPI devices require hardreset to recover after certain
    error conditions. On PATA, this is done by issuing the DEVICE RESET
    command. On SATA, COMRESET has equivalent effect. The problem is
    that DEVICE RESET needs its own execution protocol.

    For SFF controllers with bare TF access, it can be easily
    implemented but more advanced controllers (e.g. ahci and sata_sil24)
    require specialized implementations. Simply using hardreset solves
    the problem nicely.

    * COMRESET initialization sequence is the norm in SATA land and many
    SATA devices don't work properly if only SRST is used. For example,
    some PMPs behave this way and libata works around by always issuing
    hardreset if the host supports PMP.

    Like the above example, libata has developed a number of mechanisms
    aiming to promote softreset to hardreset if softreset is not going
    to work. This approach is time consuming and error prone.

    Also, note that, dependingon how you read the specs, it could be
    argued that PMP fan-out ports require COMRESET to start operation.
    In fact, all the PMPs on the market except one don't work properly
    if COMRESET is not issued to fan-out ports after PMP reset.

    * COMRESET is an integral part of SATA connection and any working
    device should be able to handle COMRESET properly. After all, it's
    the way to signal hardreset during reboot. This is the most used
    and recommended (at least by the ahci spec) method of resetting
    devices.

    So, this patch makes libata prefer hardreset over softreset by making
    the following changes.

    * Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
    ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
    now only used to tell prereset whether soft or hard reset will be
    issued.

    * Strip out now unneeded promote-to-hardreset logics from
    ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
    other places.

    Signed-off-by: Tejun Heo

    Tejun Heo
     

16 Feb, 2008

1 commit


06 Feb, 2008

1 commit


29 Oct, 2007

1 commit


15 Oct, 2007

1 commit


13 Oct, 2007

6 commits

  • The SATA_PATA_SHARING register doesn't have anything to do with the
    SATA part of the controller. It indicates whether an extern SATA PHY
    is attached to the PATA part of the controller and if so how it is
    wired. As the PATA part is driven by pata_via, sata_via has no reason
    to care about that. Also, pata_via should work fine under all
    configurations.

    This patch removes unnecessary attach failures. It seems recent via
    chipsets are defaulting to different values or are actually connected
    to SATA PHY triggering this more often.

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

    Tejun Heo
     
  • Currently, port configuration reporting has the following problems.

    * iomapped address is reported instead of raw address
    * report contains irrelevant fields or lacks necessary fields for
    non-SFF controllers.
    * host->irq/irq2 are there just for reporting and hacky.

    This patch implements and uses ata_port_desc() and
    ata_port_pbar_desc(). ata_port_desc() is almost identical to
    ata_ehi_push_desc() except that it takes @ap instead of @ehi, has no
    locking requirement, can only be used during host initialization and "
    " is used as separator instead of ", ". ata_port_pbar_desc() is a
    helper to ease reporting of a PCI BAR or an offsetted address into it.

    LLD pushes whatever description it wants using the above two
    functions. The accumulated description is printed on host
    registration after "[S/P]ATA max MAX_XFERMODE ".

    SFF init helpers and ata_host_activate() automatically add
    descriptions for addresses and irq respectively, so only LLDs which
    isn't standard SFF need to add custom descriptions. In many cases,
    such controllers need to report different things anyway.

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

    Tejun Heo
     
  • It was always set to ata_port_disable(). Removed the hook, and replaced
    the very few ap->ops->port_disable() callsites with direct calls to
    ata_port_disable().

    Signed-off-by: Jeff Garzik

    Jeff Garzik
     
  • * ->irq_ack() is redundant to what the irq handler already
    performs... chk-status + irq-clear. Furthermore, it is only
    called in one place, when screaming-irq-debugging is enabled,
    so we don't want to bother with a hook just for that.

    * ata_dummy_irq_on() is only ever used in drivers that have
    no callpath reaching ->irq_on(). Remove .irq_on hook from
    those drivers, and the now-unused ata_dummy_irq_on()

    Signed-off-by: Jeff Garzik

    Jeff Garzik
     
  • Make reset methods and related functions deal with ata_link instead of
    ata_port.

    * ata_do_reset()
    * ata_eh_reset()
    * all prereset/reset/postreset methods and related functions

    This patch introduces no behavior change.

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

    Tejun Heo
     
  • Introduce ata_link. It abstracts PHY and sits between ata_port and
    ata_device. This new level of abstraction is necessary to support
    SATA Port Multiplier, which basically adds a bunch of links (PHYs) to
    a ATA host port. Fields related to command execution, spd_limit and
    EH are per-link and thus moved to ata_link.

    This patch only defines the host link. Multiple link handling will be
    added later. Also, a lot of ap->link derefences are added but many of
    them will be removed as each part is converted to deal directly with
    ata_link instead of ata_port.

    This patch introduces no behavior change.

    Signed-off-by: Tejun Heo
    Cc: James Bottomley
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

01 Sep, 2007

1 commit

  • I think that I've found and fixed the problem. There is a copy/paste bug in
    vt6421_set_dma_mode() function which causes wrong values to be written to
    PATA_UDMA_TIMING register.

    This patch fixes a copy/paste bug that breaks DMA modes on VT6421 PATA port.

    Signed-off-by: Ondrej Zary
    Acked-by: Alan Cox
    Signed-off-by: Jeff Garzik

    Ondrej Zary
     

31 Aug, 2007

1 commit


20 Jul, 2007

1 commit


11 Jul, 2007

1 commit

  • With PCI resource fix up for legacy hosts. We can use the same code
    path to allocate IO resources and initialize host for both legacy and
    native SFF hosts. Only IRQ requesting needs to be different.

    Rename ata_pci_*_native_host() to ata_pci_*_sff_host(), kill all
    legacy specific functions and use the renamed functions instead. This
    simplifies code a lot.

    Signed-off-by: Tejun Heo
    Cc: Alan Cox
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

10 Jul, 2007

2 commits


25 May, 2007

1 commit

  • Supplied by VIA.

    Also, convert named constants to hex values in the pata_via
    PCI ID table. (standard libata policy for PCI device IDs, which are
    considered simply arbitrary hex numbers, without a need to create a
    single-use constant in linux/pci_ids.h)

    Signed-off-by: Jeff Garzik

    Jeff Garzik
     

22 May, 2007

1 commit


18 May, 2007

1 commit


12 May, 2007

2 commits

  • Cc: Tejun Heo
    Cc: Jeff Garzik
    Signed-off-by: Andrew Morton
    Signed-off-by: Jeff Garzik

    Andrew Morton
     
  • The intention of using port_mask in SFF init helpers was to eventually
    support exoctic configurations such as combination of legacy and
    native port on the same controller. This never became actually
    necessary and the related code always has been subtly broken one way
    or the other. Now that new init model is in place, there is no reason
    to make common helpers capable of handling all corner cases. Exotic
    cases can simply dealt within LLDs as necessary.

    This patch removes port_mask handling in SFF init helpers. SFF init
    helpers don't take n_ports argument and interpret it into port_mask
    anymore. All information is carried via port_info. n_ports argument
    is dropped and always two ports are allocated. LLD can tell SFF to
    skip certain port by marking it dummy. Note that SFF code has been
    treating unuvailable ports this way for a long time until recent
    breakage fix from Linus and is consistent with how other drivers
    handle with unavailable ports.

    This fixes 1-port legacy host handling still broken after the recent
    native mode fix and simplifies SFF init logic. The following changes
    are made...

    * ata_pci_init_native_host() and ata_init_legacy_host() both now try
    to initialized whatever they can and mark failed ports dummy. They
    return 0 if any port is successfully initialized.

    * ata_pci_prepare_native_host() and ata_pci_init_one() now doesn't
    take n_ports argument. All info should be specified via port_info
    array. Always two ports are allocated.

    * ata_pci_init_bmdma() exported to be used by LLDs in exotic cases.

    * port_info handling in all LLDs are standardized - all port_info
    arrays are const stack variable named ppi. Unless the second port
    is different from the first, its port_info is specified as NULL
    (tells libata that it's identical to the last non-NULL port_info).

    * pata_hpt37x/hpt3x2n: don't modify static variable directly. Make an
    on-stack copy instead as ata_piix does.

    * pata_uli: It has 4 ports instead of 2. Don't use
    ata_pci_prepare_native_host(). Allocate the host explicitly and use
    init helpers. It's simple enough.

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

    Tejun Heo