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

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

4 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