1. 17 Apr, 2008 40 commits
    • Tejun Heo's avatar
      libata: implement and use sata_std_hardreset() · 57c9efdf
      Tejun Heo authored
      Implement sata_std_hardreset(), which simply wraps around
      sata_link_hardreset().  sata_std_hardreset() becomes new standard
      hardreset method for sata_port_ops and sata_sff_hardreset() moves from
      ata_base_port_ops to ata_sff_port_ops, which is where it really
      belongs.
      
      ata_is_builtin_hardreset() is added so that both
      ata_std_error_handler() and ata_sff_error_handler() skip both builtin
      hardresets if SCR isn't accessible.
      
      piix_sidpr_hardreset() in ata_piix.c is identical to
      sata_std_hardreset() in functionality and got replaced with the
      standard function.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      57c9efdf
    • Tejun Heo's avatar
      libata: move generic hardreset code from sata_sff_hardreset() to sata_link_hardreset() · 9dadd45b
      Tejun Heo authored
      sata_sff_hardreset() contains link readiness wait logic which isn't
      SFF specific.  Move that part into sata_link_hardreset(), which now
      takes two more parameters - @online and @check_ready.  Both are
      optional.  The former is out parameter for link onlineness after
      reset.  The latter is used to wait for link readiness after hardreset.
      
      Users of sata_link_hardreset() is updated to use new funtionality and
      ahci_hardreset() is updated to use sata_link_hardreset() instead of
      sata_sff_hardreset().  This doesn't really cause any behavior change.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      9dadd45b
    • Tejun Heo's avatar
      ahci: use ata_wait_after_reset() instead of ata_sff_wait_ready() · a89611e8
      Tejun Heo authored
      Implement ahci_check_ready() and replace ata_sff_wait_after_reset()
      with ata_wait_after_reset().  As ahci was faking TF access, this
      change doesn't result in any functional difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      a89611e8
    • Tejun Heo's avatar
      libata: separate out ata_wait_ready() and implement ata_wait_after_reset() · aa2731ad
      Tejun Heo authored
      Factor out waiting logic (which is common to all ATA controllers) from
      ata_sff_wait_ready() into ata_wait_ready().  ata_wait_ready() takes
      @check_ready function pointer and uses it to poll for readiness.  This
      allows non-SFF controllers to use ata_wait_ready() to wait for link
      readiness.
      
      This patch also implements ata_wait_after_reset() - generic version of
      ata_sff_wait_after_reset() - using ata_wait_ready().
      
      ata_sff_wait_ready() is reimplemented using ata_wait_ready() and
      ata_sff_check_ready().  Functionality remains the same.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      aa2731ad
    • Tejun Heo's avatar
      libata: restructure SFF post-reset readiness waits · 705e76be
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      705e76be
    • Tejun Heo's avatar
      libata: separate out ata_std_postreset() from ata_sff_postreset() · 203c75b8
      Tejun Heo authored
      Separate out generic ATA portion from ata_sff_postreset() into
      ata_std_postreset() and implement ata_sff_postreset() using the std
      version.
      
      ata_base_port_ops now has ata_std_postreset() for its postreset and
      ata_sff_port_ops overrides it to ata_sff_postreset().
      
      This change affects pdc_adma, ahci, sata_fsl and sata_sil24.  pdc_adma
      now specifies postreset to ata_sff_postreset() explicitly.  sata_fsl
      and sata_sil24 now use ata_std_postreset() which makes no difference
      to them.  ahci now calls ata_std_postreset() from its own postreset
      method, which causes no behavior difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      203c75b8
    • Tejun Heo's avatar
      libata: separate out ata_std_prereset() from ata_sff_prereset() · 0aa1113d
      Tejun Heo authored
      Separate out generic ATA portion from ata_sff_prereset() into
      ata_std_prereset() and implement ata_sff_prereset() using the std
      version.  Waiting for device readiness is the only SFF specific part.
      
      ata_base_port_ops now has ata_std_prereset() for its prereset and
      ata_sff_port_ops overrides it to ata_sff_prereset().  This change can
      affect pdc_adma, ahci, sata_fsl and sata_sil24.  pdc_adma implements
      its own prereset using ata_sff_prereset() and the rest has hardreset
      and thus are unaffected by this change.
      
      This change reflects real world situation.  There is no generic way to
      wait for device readiness for non-SFF controllers and some of them
      don't have any mechanism for that.  Non-sff drivers which don't have
      hardreset should wrap ata_std_prereset() and wait for device readiness
      itself but there's no such driver now and isn't likely to be popular
      in the future either.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      0aa1113d
    • Tejun Heo's avatar
      libata: clean up port_ops->sff_irq_clear() · 288623a0
      Tejun Heo authored
      ->sff_irq_clear() is called only from SFF interrupt handler, so there
      is no reason to initialize it for non-SFF controllers.  Also,
      ata_sff_irq_clear() can handle both BMDMA and non-BMDMA SFF
      controllers.
      
      This patch kills ata_noop_irq_clear() and removes it from base
      port_ops and sets ->sff_irq_clear to ata_sff_irq_clear() in sff
      port_ops instead of bmdma port_ops.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      288623a0
    • Tejun Heo's avatar
      libata: rename SFF port ops · 5682ed33
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      5682ed33
    • Tejun Heo's avatar
      libata: rename SFF functions · 9363c382
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      9363c382
    • Mark Lord's avatar
      sata_mv fix ifctl handling · b67a1064
      Mark Lord authored
      Fix handling of the SATA_INTERFACE_CFG register to match datasheet requirements.
      Signed-off-by: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      b67a1064
    • Mark Lord's avatar
      sata_mv clean up mv_stop_edma usage · b562468c
      Mark Lord authored
      Clean up uses of mv_stop_edma{_engine}() to match datasheet requirements.
      Signed-off-by: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      b562468c
    • Mark Lord's avatar
      sata_mv cosmetic fixes · e12bef50
      Mark Lord authored
      Various cosmetic fixes in preparation for real code changes later on.
      Signed-off-by: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      e12bef50
    • Yoichi Yuasa's avatar
      use ATA_TAG_INTERNAL in ata_tag_internal() · 83c063dd
      Yoichi Yuasa authored
      It should be ATA_TAG_INTERNAL.
      Signed-off-by: default avatarYoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      83c063dd
    • Chris Wedgwood's avatar
      Add 'short help text' to ATA_ACPI so it's [de]selectable. · c30484d7
      Chris Wedgwood authored
      ATA_ACPI isn't selectable right now because it lacks 'short help
      text'.  This means it's always enabled and always enables ACPI_DOCK.
      Add text so it's now [de]selectable.
      
      cc: Jeff Garzik <jeff@garzik.org>
      cc: Tejun Heo <htejun@gmail.com>
      cc: Len Brown <len.brown@intel.com>
      Signed-off-by: default avatarChris Wedgwood <cw@f00f.org>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      c30484d7
    • Tejun Heo's avatar
      pdc_adma: kill adma_host_stop() · fc4712d1
      Tejun Heo authored
      adma_host_stop() does the same thing that adma_port_stop() does.  Kill
      it.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Mark Lord <liml@rtr.ca>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      fc4712d1
    • Tejun Heo's avatar
      pdc_adma: inherit ata_sff_port_ops · b0316b15
      Tejun Heo authored
      With the previous ops standardization, pdc_adma now can inherit
      ata_sff_port_ops instead of ata_base_port_ops.  Make the change.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Mark Lord <liml@rtr.ca>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      b0316b15
    • Tejun Heo's avatar
      libata/pdc_adma: make SFF EH handle non-bmdma SFF drivers and standardize pdc_adma ops · ed82f964
      Tejun Heo authored
      pdc_adma has interface similar to SFF but has its own DMA interface.
      It currently implements noop bmdma ops to avoid crashing
      ata_bmdma_error_handler() which BTW actually is EH for SFF drivers.
      
      This patch makes ata_bmdma_error_handler() dereference bmdma ops iff
      bmdma_addr is initialized as done in ata_bmdma_post_internal_cmd.
      This change allows pdc_adma to standardize ops and use SFF
      error_handler and post_internal_cmd.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Mark Lord <liml@rtr.ca>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      ed82f964
    • Tejun Heo's avatar
      libata: kill unused ata_flush_cache() · d8b81b80
      Tejun Heo authored
      ata_flush_code() hasn't been in use for quite some time now.  Kill it.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      d8b81b80
    • Tejun Heo's avatar
      libata: implement ATA_QCFLAG_RETRY · 03faab78
      Tejun Heo authored
      Currently whether a command should be retried after failure is
      determined inside ata_eh_finish().  Add ATA_QCFLAG_RETRY and move the
      logic into ata_eh_autopsy().  This makes things clearer and helps
      extending retry determination logic.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      03faab78
    • Tejun Heo's avatar
      libata: make ata_tf_to_lba[48]() generic · a5987e0a
      Tejun Heo authored
      ata_tf_to_lba[48]() currently return LBA in tf + 1 for
      ata_read_native_max_address().  Make them return LBA and make it
      global so that it can be used to read LBA off TF for other purposes.
      ata_read_native_max_address() now adds 1 itself.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      a5987e0a
    • Jeff Garzik's avatar
      [libata] sata_nv: disable ADMA by default · 06993d22
      Jeff Garzik authored
      Continues to have open issues, and engineering support is extremely difficult
      to come by, according to fellow NVIDIA engineers.
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      06993d22
    • Al Viro's avatar
      libata annotations · 826cd156
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      826cd156
    • Tejun Heo's avatar
      ata_piix: kill ich6_sata_ahci and clean up · 9c0bf675
      Tejun Heo authored
      ich6_sata_ahci and ich6_sata are identical.  Kill ich6_sata_ahci and
      drop _ahci postfixes from controller ids, which doesn't really mean
      anything at this point.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      9c0bf675
    • Tejun Heo's avatar
      ata_piix: don't attach to ICH6M in ahci mode · 5016d7d2
      Tejun Heo authored
      ata_piix when attached to ICH6M in AHCI mode doesn't provide any
      benefit over using ahci and has detection problems.  Don't let
      ata_piix claim ICH6M if it's in AHCI mode.
      
      This change makes ICH6R the only one which ata_piix can attach to even
      when it's in ahci mode which is necessary as some devices don't work
      properly under ahci mode.  Drop PIIX_FLAG_AHCI and match the
      controller directly so that piix_disable_ahci() is called only for it.
      
      This change makes PIIX_SCC no longer used and it gets dropped too.
      
      This fixes bz 9491.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Robert M. Albrecht <romal@gmx.de>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      5016d7d2
    • Tejun Heo's avatar
      pata_scc: fix compile warning · c1796d98
      Tejun Heo authored
      Missed one during mass conversion (dc14c0c5).  Fix it.  Spotted by
      Stephen Rothwell.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      c1796d98
    • Alan Cox's avatar
      libata: isolate and rework cable logic · 15a5551c
      Alan Cox authored
      Signed-off-by: default avatarAlan Cox <alan@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      15a5551c
    • Zoltan Boszormenyi's avatar
      ata: SWNCQ should be enabled by default · d21279f4
      Zoltan Boszormenyi authored
      Signed-off-by: default avatarZoltan Boszormenyi <zboszor@dunaweb.hu>
      Cc: Robert Hancock <hancockr@shaw.ca>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      d21279f4
    • Harvey Harrison's avatar
      pata_amd: fix sparse warning · d9c74fbe
      Harvey Harrison authored
      Current code is essentially choosing between dividing by 1 or
      dividing by two, make the conditions a little more obvious.
      
      As a bonus, removes a sparse error:
      drivers/ata/pata_amd.c:59:11: warning: symbol '__x' shadows an earlier one
      drivers/ata/pata_amd.c:59:11: originally declared here
      Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      d9c74fbe
    • Tejun Heo's avatar
      libata: kill ata_chk_status() · 6fd36390
      Tejun Heo authored
      ata_chk_status() just calls ops->check_status and it only adds
      confusion with other status functions.  Kill it.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      6fd36390
    • Tejun Heo's avatar
      libata: kill ata_chk_status() call from ata_dev_configure() · 3d5a3d67
      Tejun Heo authored
      ata_dev_configure() isn't tied to any controller interface except for
      the probe debug message printing at the end of the function.  Kill the
      message.
      
      This is to help separating out SFF support from core layer.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      3d5a3d67
    • Tejun Heo's avatar
      libata: move ata_pci_default_filter() out of CONFIG_PCI · 071ce34d
      Tejun Heo authored
      ata_pci_default_filter() doesn't really have anything to do with PCI.
      It's generally applicable to BMDMA controllers.  Move it out of
      CONFIG_PCI.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      071ce34d
    • Tejun Heo's avatar
      libata: reorganize SFF related stuff · 624d5c51
      Tejun Heo authored
      * Move SFF related functions from libata-core.c to libata-sff.c.
      
        ata_[bmdma_]sff_port_ops, ata_devchk(), ata_dev_try_classify(),
        ata_std_dev_select(), ata_tf_to_host(), ata_busy_sleep(),
        ata_wait_after_reset(), ata_wait_ready(), ata_bus_post_reset(),
        ata_bus_softreset(), ata_bus_reset(), ata_std_softreset(),
        sata_std_hardreset(), ata_fill_sg(), ata_fill_sg_dumb(),
        ata_qc_prep(), ata_dump_qc_prep(), ata_data_xfer(),
        ata_data_xfer_noirq(), ata_pio_sector(), ata_pio_sectors(),
        atapi_send_cdb(), __atapi_pio_bytes(), atapi_pio_bytes(),
        ata_hsm_ok_in_wq(), ata_hsm_qc_complete(), ata_hsm_move(),
        ata_pio_task(), ata_qc_issue_prot(), ata_host_intr(),
        ata_interrupt(), ata_std_ports()
      
      * Make ata_pio_queue_task() global as it's now called from
        libata-sff.c.
      
      * Move SFF related stuff in include/linux/libata.h and
        drivers/ata/libata.h into one place.  While at it, move timing
        constants into the global enum definition and fortify comments a
        bit.
      
      This patch strictly moves stuff around and as such doesn't cause any
      functional difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      624d5c51
    • Tejun Heo's avatar
      libata: reorder functions in libata-sff.c · 272f7884
      Tejun Heo authored
      Reorder functions in drivers/ata/libata-sff.c such that functions
      generally follow ops table order and init functions come last.  This
      is in preparation of SFF cleanup.
      
      This patch strictly moves stuff around and as such doesn't cause any
      functional difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      272f7884
    • Tejun Heo's avatar
      libata: drop ata_dev_select() from ata_dev_read_id · 21572ea5
      Tejun Heo authored
      There is no reason to issue device select in read_id, it will be done
      by ops->qc_issue() when IDENTIFY[_PACKET] is issued via
      ata_exec_internal().
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      21572ea5
    • Tejun Heo's avatar
      libata: make reset related methods proper port operations · a1efdaba
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      a1efdaba
    • Tejun Heo's avatar
      libata: kill port_info->sht and ->irq_handler · 95947193
      Tejun Heo authored
      libata core layer doesn't care about sht or ->irq_handler.  Those are
      only of interest to the LLD during initialization.  This is confusing
      and has caused several drivers to have duplicate unused initializers
      for these fields.
      
      Currently only sata_nv uses these fields.  Make sata_nv use
      ->private_data, which is supposed to carry LLD-specific information,
      instead and kill ->sht and ->irq_handler.  nv_pi_priv structure is
      defined and struct literals are used to initialize private_data.
      Notational overhead is negligible.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      95947193
    • Tejun Heo's avatar
      libata: stop overloading port_info->private_data · 887125e3
      Tejun Heo authored
      port_info->private_data is currently used for two purposes - to record
      private data about the port_info or to specify host->private_data to
      use when allocating ata_host.
      
      This overloading is confusing and counter-intuitive in that
      port_info->private_data becomes host->private_data instead of
      port->private_data.  In addition, port_info and host don't correspond
      to each other 1-to-1.  Currently, the first non-NULL
      port_info->private_data is used.
      
      This patch makes port_info->private_data just be what it is -
      private_data for the port_info where LLD can jot down extra info.
      libata no longer sets host->private_data to the first non-NULL
      port_info->private_data, @host_priv argument is added to
      ata_pci_init_one() instead.  LLDs which use ata_pci_init_one() can use
      this argument to pass in pointer to host private data.  LLDs which
      don't should use init-register model anyway and can initialize
      host->private_data directly.
      
      Adding @host_priv instead of using init-register model for LLDs which
      use ata_pci_init_one() is suggested by Alan Cox.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      887125e3
    • Tejun Heo's avatar
      libata: make ata_pci_init_one() not use ops->irq_handler and pi->sht · 1bd5b715
      Tejun Heo authored
      ata_pci_init_one() is the only function which uses ops->irq_handler
      and pi->sht.  Other initialization functions take the same information
      as arguments.  This causes confusion and duplicate unused entries in
      structures.
      
      Make ata_pci_init_one() take sht as an argument and use ata_interrupt
      implicitly.  All current users use ata_interrupt and if different irq
      handler is necessary open coding ata_pci_init_one() using
      ata_prepare_sff_host() and ata_activate_sff_host can be done under ten
      lines including error handling and driver which requires custom
      interrupt handler is likely to require custom initialization anyway.
      
      As ata_pci_init_one() was the last user of ops->irq_handler, this
      patch also kills the field.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      1bd5b715
    • Tejun Heo's avatar
      libata: implement and use ops inheritance · 029cfd6b
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      029cfd6b