1. 23 Jul, 2011 2 commits
    • Joe Perches's avatar
      ata: Add and use ata_print_version_once · 06296a1e
      Joe Perches authored
      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: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
    • Joe Perches's avatar
      ata: Convert ata_<foo>_printk(KERN_<LEVEL> to ata_<foo>_<level> · a9a79dfe
      Joe Perches authored
      Saves text by removing nearly duplicated text format strings by
      creating ata_<foo>_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: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
  2. 19 May, 2011 1 commit
  3. 24 Apr, 2011 2 commits
  4. 31 Mar, 2011 1 commit
  5. 14 Mar, 2011 1 commit
  6. 02 Mar, 2011 5 commits
  7. 13 Feb, 2011 1 commit
    • James Bottomley's avatar
      [SCSI] libata: separate error handler into usable components · 64878c0e
      James Bottomley authored
      Right at the moment, the libata error handler is incredibly
      monolithic.  This makes it impossible to use from composite drivers
      like libsas and ipr which have to handle error themselves in the first
      The essence of the change is to split the monolithic error handler
      into two components: one which handles a queue of ata commands for
      processing and the other which handles the back end of readying a
      port.  This allows the upper error handler fine grained control in
      calling libsas functions (and making sure they only get called for ATA
      commands whose lower errors have been fixed up).
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Jeff Garzik <jeff@garzik.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
  8. 05 Jan, 2011 1 commit
  9. 16 Nov, 2010 1 commit
    • Jeff Garzik's avatar
      SCSI host lock push-down · f281233d
      Jeff Garzik authored
      Move the mid-layer's ->queuecommand() invocation from being locked
      with the host lock to being unlocked to facilitate speeding up the
      critical path for drivers who don't need this lock taken anyway.
      The patch below presents a simple SCSI host lock push-down as an
      equivalent transformation.  No locking or other behavior should change
      with this patch.  All existing bugs and locking orders are preserved.
      Additionally, add one parameter to queuecommand,
      	struct Scsi_Host *
      and remove one parameter from queuecommand,
      	void (*done)(struct scsi_cmnd *)
      Scsi_Host* is a convenient pointer that most host drivers need anyway,
      and 'done' is redundant to struct scsi_cmnd->scsi_done.
      Minimal code disturbance was attempted with this change.  Most drivers
      needed only two one-line modifications for their host lock push-down.
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Acked-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  10. 21 Oct, 2010 8 commits
    • Andrea Gelmini's avatar
    • Richard Kennedy's avatar
      libata: reorder ata_queued_cmd to remove alignment padding on 64 bit builds · b34e9042
      Richard Kennedy authored
      Reorder structure ata_queued_cmd to remove 8 bytes of alignment padding
      on 64 bit builds & therefore reduce the size of structure ata_port by
      256 bytes.
      Overall this will have little impact, other than reducing the amount of
      memory that is cleared when allocating ata_ports.
      Signed-off-by: default avatarRichard Kennedy <richard@rsk.demon.co.uk>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata: implement cross-port EH exclusion · c0c362b6
      Tejun Heo authored
      In libata, the non-EH code paths should always take and release
      ap->lock explicitly when accessing hardware or shared data structures.
      However, once EH is active, it's assumed that the port is owned by EH
      and EH methods don't explicitly take ap->lock unless race from irq
      handler or other code paths are expected.  However, libata EH didn't
      guarantee exclusion among EHs for ports of the same host.  IOW,
      multiple EHs may execute in parallel on multiple ports of the same
      In many cases, especially in SATA, the ports are completely
      independent of each other and this doesn't cause problems; however,
      there are cases where different ports share the same resource, which
      lead to obscure timing related bugs such as the one fixed by commit
      213373cf (ata_piix: fix locking around SIDPR access).
      This patch implements exclusion among EHs of the same host.  When EH
      begins, it acquires per-host EH ownership by calling ata_eh_acquire().
      When EH finishes, the ownership is released by calling
      ata_eh_release().  EH ownership is also released whenever the EH
      thread goes to sleep from ata_msleep() or explicitly and reacquired
      after waking up.
      This ensures that while EH is actively accessing the hardware, it has
      exclusive access to it while allowing EHs to interleave and progress
      in parallel as they hit waiting stages, which dominate the time spent
      in EH.  This achieves cross-port EH exclusion without pervasive and
      fragile changes while still allowing parallel EH for the most part.
      This was first reported by yuanding02@gmail.com more than three years
      ago in the following bugzilla.  :-)
        https://bugzilla.kernel.org/show_bug.cgi?id=8223Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Reported-by: yuanding02@gmail.com
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata: add @ap to ata_wait_register() and introduce ata_msleep() · 97750ceb
      Tejun Heo authored
      Add optional @ap argument to ata_wait_register() and replace msleep()
      calls with ata_msleep() which take optional @ap in addition to the
      duration.  These will be used to implement EH exclusion.
      This patch doesn't cause any behavior difference.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata: reimplement link power management · 6b7ae954
      Tejun Heo authored
      The current LPM implementation has the following issues.
      * Operation order isn't well thought-out.  e.g. HIPM should be
        configured after IPM in SControl is properly configured.  Not the
        other way around.
      * Suspend/resume paths call ata_lpm_enable/disable() which must only
        be called from EH context directly.  Also, ata_lpm_enable/disable()
        were called whether LPM was in use or not.
      * Implementation is per-port when it should be per-link.  As a result,
        it can't be used for controllers with slave links or PMP.
      * LPM state isn't managed consistently.  After a link reset for
        whatever reason including suspend/resume the actual LPM state would
        be reset leaving ap->lpm_policy inconsistent.
      * Generic/driver-specific logic boundary isn't clear.  Currently,
        libahci has to mangle stuff which libata EH proper should be
        handling.  This makes the implementation unnecessarily complex and
      * Tied to ALPM.  Doesn't consider DIPM only cases and doesn't check
        whether the device allows HIPM.
      * Error handling isn't implemented.
      Given the extent of mismatch with the rest of libata, I don't think
      trying to fix it piecewise makes much sense.  This patch reimplements
      LPM support.
      * The new implementation is per-link.  The target policy is still
        port-wide (ap->target_lpm_policy) but all the mechanisms and states
        are per-link and integrate well with the rest of link abstraction
        and can work with slave and PMP links.
      * Core EH has proper control of LPM state.  LPM state is reconfigured
        when and only when reconfiguration is necessary.  It makes sure that
        LPM state is reset when probing for new device on the link.
        Controller agnostic logic is now implemented in libata EH proper and
        driver implementation only has to deal with controller specifics.
      * Proper error handling.  LPM config failure is attributed to the
        device on the link and LPM is disabled for the link if it fails
      * ops->enable/disable_pm() are replaced with single ops->set_lpm()
        which takes @policy and @hints.  This simplifies driver specific
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata: implement sata_link_scr_lpm() and make ata_dev_set_feature() global · 1152b261
      Tejun Heo authored
      Link power management is about to be reimplemented.  Prepare for it.
      * Implement sata_link_scr_lpm().
      * Drop static from ata_dev_set_feature() and make it available to
        other libata files.
      * Trivial whitespace adjustments.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata: clean up lpm related symbols and sysfs show/store functions · c93b263e
      Tejun Heo authored
      Link power management related symbols are in confusing state w/ mixed
      usages of lpm, ipm and pm.  This patch cleans up lpm related symbols
      and sysfs show/store functions as follows.
        MEDIUM_POWER are renamed to ATA_LPM_UNKNOWN and
      * Pre/postfixes are unified to lpm.
      * sysfs show/store functions for link_power_management_policy were
        curiously named get/put and unnecessarily complex.  Renamed to
        show/store and simplified.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Gwendal Grignou's avatar
      [libata] Add ATA transport class · d9027470
      Gwendal Grignou authored
      This is a scheleton for libata transport class.
      All information is read only, exporting information from libata:
      - ata_port class: one per ATA port
      - ata_link class: one per ATA port or 15 for SATA Port Multiplier
      - ata_device class: up to 2 for PATA link, usually one for SATA.
      Signed-off-by: default avatarGwendal Grignou <gwendal@google.com>
      Reviewed-by: default avatarGrant Grundler <grundler@google.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
  11. 21 Sep, 2010 1 commit
  12. 09 Sep, 2010 2 commits
  13. 02 Jul, 2010 1 commit
    • Tejun Heo's avatar
      libata: take advantage of cmwq and remove concurrency limitations · ad72cf98
      Tejun Heo authored
      libata has two concurrency related limitations.
      a. ata_wq which is used for polling PIO has single thread per CPU.  If
         there are multiple devices doing polling PIO on the same CPU, they
         can't be executed simultaneously.
      b. ata_aux_wq which is used for SCSI probing has single thread.  In
         cases where SCSI probing is stalled for extended period of time
         which is possible for ATAPI devices, this will stall all probing.
      #a is solved by increasing maximum concurrency of ata_wq.  Please note
      that polling PIO might be used under allocation path and thus needs to
      be served by a separate wq with a rescuer.
      #b is solved by using the default wq instead and achieving exclusion
      via per-port mutex.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarJeff Garzik <jgarzik@pobox.com>
  14. 02 Jun, 2010 1 commit
    • Tejun Heo's avatar
      libata: implement on-demand HPA unlocking · d8d9129e
      Tejun Heo authored
      Implement ata_scsi_unlock_native_capacity() which will be called
      through SCSI layer when block layer notices that partitions on a
      device extend beyond the end of the device.  It requests EH to unlock
      HPA, waits for completion and returns the current device capacity.
      This allows libata to unlock HPA on demand instead of having to decide
      whether to unlock upfront.  Unlocking on demand is safer than
      unlocking by upfront because some BIOSes write private data to the
      area beyond HPA limit.  This was suggested by Ben Hutchings.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Suggested-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
  15. 25 May, 2010 5 commits
    • Tejun Heo's avatar
      libata: implement dump_id force param · 43c9c591
      Tejun Heo authored
      Add dump_id libata.force parameter.  If specified, libata dumps full
      IDENTIFY data during device configuration.  This is to aid debugging.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Larry Baker <baker@usgs.gov>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: make BMDMA optional · 9a7780c9
      Tejun Heo authored
      Make BMDMA optional depending on new config variable CONFIG_ATA_BMDMA.
      In Kconfig, drivers are grouped into five groups - non-SFF native, SFF
      w/ custom DMA interface, SFF w/ BMDMA, PIO-only SFF, and generic
      fallback / legacy ones.  Kconfig and Makefile are reorganized
      according to the groups and ordered alphabetically inside each group.
      ata_ioports.bmdma_addr and ata_port.bmdma_prd[_dma] are put into
      CONFIG_ATA_BMDMA, as are all bmdma related ops, variables and
      This increase the binary size slightly when BMDMA is enabled but on
      both native-only and PIO-only configurations the size is slightly
      reduced.  Either way, the size difference is insignificant.  This
      change is more meaningful to signify the separation between SFF and
      BMDMA and as a tool to verify the separation.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: separate out BMDMA init · 1c5afdf7
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: separate out BMDMA irq handler · c3b28894
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: ata_sff_irq_clear() is BMDMA specific · 37f65b8b
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
  16. 19 May, 2010 7 commits
    • Tejun Heo's avatar
      libata-sff: separate out BMDMA qc_issue · 360ff783
      Tejun Heo authored
      Separate out ata_bmdma_qc_issue() from ata_sff_qc_issue() such that
      ata_sff_qc_issue() only deals with non-BMDMA SFF protocols (PIO and
      nodata) while ata_bmdma_qc_issue() deals with the BMDMA protocols and
      uses ata_sff_qc_issue() for non-DMA commands.  All the users are
      updated accordingly.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: prd is BMDMA specific · f60d7011
      Tejun Heo authored
      struct ata_prd and ap->prd are BMDMA specific.  Add bmdma_ prefix to
      them and move them inside CONFIG_ATA_SFF.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: ata_sff_[dumb_]qc_prep are BMDMA specific · f47451c4
      Tejun Heo authored
      Both qc_prep functions deal only with BMDMA PRD setup and PIO only SFF
      drivers don't need them.  Rename to ata_bmdma_[dumb_]qc_prep() and
      All usages are renamed except for pdc_adma and sata_qstor.  Those two
      drivers are not BMDMA drivers and don't need to call BMDMA qc_prep
      functions.  Calls to ata_sff_qc_prep() in the two drivers are removed.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: separate out BMDMA EH · fe06e5f9
      Tejun Heo authored
      Some of error handling logic in ata_sff_error_handler() and all of
      ata_sff_post_internal_cmd() are for BMDMA.  Create
      ata_bmdma_error_handler() and ata_bmdma_post_internal_cmd() and move
      BMDMA part into those.
      While at it, change DMA protocol check to ata_is_dma(), fix
      post_internal_cmd to call ap->ops->bmdma_stop instead of directly
      calling ata_bmdma_stop() and open code hardreset selection so that
      ata_std_error_handler() doesn't have to know about sff hardreset.
      As these two functions are BMDMA specific, there's no reason to check
      for bmdma_addr before calling bmdma methods if the protocol of the
      failed command is DMA.  sata_mv and pata_mpc52xx now don't need to set
      .post_internal_cmd to ATA_OP_NULL and pata_icside and sata_qstor don't
      need to set it to their bmdma_stop routines.
      ata_sff_post_internal_cmd() becomes noop and is removed.
      This fixes p3 described in clean-up-BMDMA-initialization patch.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: port_task is SFF specific · c429137a
      Tejun Heo authored
      port_task is tightly bound to the standard SFF PIO HSM implementation.
      Using it for any other purpose would be error-prone and there's no
      such user and if some drivers need such feature, it would be much
      better off using its own.  Move it inside CONFIG_ATA_SFF and rename it
      to sff_pio_task.
      The only function which is exposed to the core layer is
      ata_sff_flush_pio_task() which is renamed from ata_port_flush_task()
      and now also takes care of resetting hsm_task_state to HSM_ST_IDLE,
      which is possible as it's now specific to PIO HSM.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: ap->[last_]ctl are SFF specific · 5fe7454a
      Tejun Heo authored
      ap->[last_]ctl are specific to SFF controllers.  Put them inside
      CONFIG_ATA_SFF and move initialization into ata_sff_port_init().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    • Tejun Heo's avatar
      libata-sff: rename ap->ops->drain_fifo() to sff_drain_fifo() · 8244cd05
      Tejun Heo authored
      ->drain_fifo() is SFF specific.  Rename and relocate it.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>