1. 12 Oct, 2007 5 commits
    • Kristen Carlson Accardi's avatar
      [libata] ahci: send event when AN received · 2f294968
      Kristen Carlson Accardi authored
      When we get an SDB FIS with the 'N' bit set, we should send
      an event to user space to indicate that there has been a
      media change.  This will be done via the scsi device.
      Signed-off-by: default avatarKristen Carlson Accardi <kristen.c.accardi@intel.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Mark Lord's avatar
      libata: add support for ATA_16 on ATAPI · baf4fdfa
      Mark Lord authored
      Add support for issuing ATA_16 passthru commands to ATAPI devices
      managed by libata.  It requires the previous CDB length fix patch.
      A boot/module parameter, "atapi_passthru16=0" can be used to globally
      disable this feature, if ever desired.
      tj: restructured __ata_scsi_queuecmd() according to Jeff's suggestion.
      Signed-off-by: default avatarMark Lord <liml@rtr.ca>
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata-link: update hotplug to handle PMP links · 41bda9c9
      Tejun Heo authored
      Update hotplug to handle PMP links.  When PMP is attached, the PMP
      number corresponds to C of SCSI H:C:I:L.  While at it, change argument
      to ata_find_dev() to @devno from @id to avoid confusion with SCSI
      device ID.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata-link: implement and use link/device iterators · f58229f8
      Tejun Heo authored
      Multiple links and different number of devices per link should be
      considered to iterate over links and devices.  This patch implements
      and uses link and device iterators - ata_port_for_each_link() and
      ata_link_for_each_dev() - and ata_link_max_devices().
      This change makes a lot of functions iterate over only possible
      devices instead of from dev 0 to dev ATA_MAX_DEVICES.  All such
      changes have been examined and nothing should be broken.
      While at it, add a separating comment before device helpers to
      distinguish them better from link helpers and others.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata-link: introduce ata_link · 9af5c9c9
      Tejun Heo authored
      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: default avatarTejun Heo <htejun@gmail.com>
      Cc: James Bottomley <James.Bottomley@SteelEye.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  2. 24 Jul, 2007 1 commit
  3. 20 Jul, 2007 1 commit
    • Tejun Heo's avatar
      libata: improve SCSI scan failure handling · 1ae46317
      Tejun Heo authored
      SCSI scan may fail due to memory allocation failure even if EH is not
      in progress.  Due to use of GFP_ATOMIC in SCSI scan path, allocation
      failure isn't too rare especially while probing multiple devices at
      once which is the case when a bunch of devices are connected to PMP.
      This patch moves SCSI scan failure detetion logic from
      ata_scsi_hotplug() to ata_scsi_scan_host() and implement synchronous
      scan behavior.  The synchronous path sleeps briefly and repeats SCSI
      scan if some devices aren't attached properly.  It contains robust
      retry loop to minimize the chance of device misdetection during boot
      and falls back to async retry if everything fails.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  4. 09 Jul, 2007 1 commit
  5. 27 Jun, 2007 1 commit
  6. 09 Jun, 2007 5 commits
  7. 25 May, 2007 1 commit
  8. 17 May, 2007 1 commit
    • Tejun Heo's avatar
      libata: remove libata.spindown_compat · d9aca22c
      Tejun Heo authored
      With STANDBYDOWN tracking added, libata.spindown_compat isn't
      necessary anymore.  If userspace shutdown(8) issues STANDBYNOW, libata
      warns.  If userspace shutdown(8) doesn't issue STANDBYNOW, libata does
      the right thing.  Userspace can tell whether kernel supports spindown
      by testing whether sysfs node manage_start_stop exists as before.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  9. 15 May, 2007 2 commits
    • Tejun Heo's avatar
      libata: track spindown status and skip spindown_compat if possible · 13b8d09f
      Tejun Heo authored
      Our assumption that most distros issue STANDBYNOW seems wrong.  The
      upstream sysvinit and thus many distros including gentoo and opensuse
      don't take any action for libata disks on spindown.  We can skip
      compat handling for these distros so that they don't need to update
      anything to take advantage of kernel-side shutdown.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata: fix shutdown warning message printing · da071b42
      Tejun Heo authored
      Unlocking ap->lock and ssleeping don't work because SCSI commands can
      be issued from completion path without context.  Reimplement delayed
      completion by allowing translation functions to override
      qc->scsidone(), storing the original completion function to
      scmd->scsi_done() and overriding qc->scsidone() with a function which
      schedules delayed invocation of scmd->scsi_done().
      This isn't pretty at all but all the ugly parts are thankfully
      contained in the stop translation path where the compat feature is
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  10. 11 May, 2007 2 commits
    • Tejun Heo's avatar
      libata: implement libata.spindown_compat · 920a4b10
      Tejun Heo authored
      Now that libata uses sd->manage_start_stop, libata spins down disk on
      shutdown.  In an attempt to compensate libata's previous shortcoming,
      some distros sync and spin down disks attached via libata in their
      shutdown(8).  Some disks spin back up just to spin down again on
      STANDBYNOW1 if the command is issued when the disk is spun down, so
      this double spinning down causes problem.
      This patch implements module parameter libata.spindown_compat which,
      when set to one (default value), prevents libata from spinning down
      disks on shutdown thus avoiding double spinning down.  Note that
      libata spins down disks for suspend to mem and disk, so with
      libata.spindown_compat set to one, disks should be properly spun down
      in all cases without modifying shutdown(8).
      shutdown(8) should be fixed eventually.  Some drive do spin up on
      SYNCHRONZE_CACHE even when their cache is clean.  Those disks
      currently spin up briefly when sd tries to shutdown the device and
      then the machine powers off immediately, which can't be good for the
      head.  We can't skip SYNCHRONIZE_CACHE during shudown as it can be
      dangerous data integrity-wise.
      So, this spindown_compat parameter is already scheduled for removal by
      the end of the next year and here's what shutdown(8) should do.
        * Check whether /sys/modules/libata/parameters/spindown_compat
          exists.  If it does, write 0 to it.
        * For each libata harddisk {
      	* Check whether /sys/class/scsi_disk/h:c:i:l/manage_start_stop
      	  exists.  Iff it doesn't, synchronize cache and spin the disk
      	  down as before.
      The above procedure will make shutdown(8) work properly with kernels
      before this change, ones with this workaround and later ones without
      To accelerate shutdown(8) updates, if the compat mode is in use, this
      patch prints BIG FAT warning for five seconds during shutdown (the
      optimal interval to annoy the user just the right amount discovered by
      hours of tireless usability testing).
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata: reimplement suspend/resume support using sdev->manage_start_stop · 9666f400
      Tejun Heo authored
      Reimplement suspend/resume support using sdev->manage_start_stop.
      * Device suspend/resume is now SCSI layer's responsibility and the
        code is simplified a lot.
      * DPM is dropped.  This also simplifies code a lot.  Suspend/resume
        status is port-wide now.
      * ata_scsi_device_suspend/resume() and ata_dev_ready() removed.
      * Resume now has to wait for disk to spin up before proceeding.  I
        couldn't find easy way out as libata is in EH waiting for the
        disk to be ready and sd is waiting for EH to complete to issue
      * sdev->manage_start_stop is set to 1 in ata_scsi_slave_config().
        This fixes spindown on shutdown and suspend-to-disk.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  11. 28 Apr, 2007 3 commits
    • Tejun Heo's avatar
      libata: separate out ata_host_alloc() and ata_host_register() · f3187195
      Tejun Heo authored
      Reorganize ata_host_alloc() and its subroutines into the following
      three functions.
      * ata_host_alloc() : allocates host and its ports.  shost is not
        registered automatically.
      * ata_scsi_add_hosts() : allocates and adds shosts associated with an
        ATA host.  Used by ata_host_register().
      * ata_host_register() : takes a fully initialized ata_host structure
        and registers it to libata layer and probes it.
      Only ata_host_alloc() and ata_host_register() are exported.
      ata_device_add() is rewritten using the above functions.  This patch
      does not introduce any observable behavior change.  Things worth
      * print_id is assigned at registration time and LLDs are allowed to
        overallocate ports and reduce host->n_ports during initialization.
        ata_host_register() will throw away unused ports automatically.
      * All SCSI host initialization stuff now resides in
        ata_scsi_add_hosts() in libata-scsi.c, where it should be.
      * ipr is now the only user of ata_host_init().  Either kill it by
        converting ipr to use ata_host_alloc() and friends or rename and
        move it to libata-scsi.c
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Mark Lord's avatar
      libata: add support for READ/WRITE LONG · 5a5dbd18
      Mark Lord authored
      The READ/WRITE LONG commands are theoretically obsolete,
      but the majority of drives in existance still implement them.
      The WRITE_LONG and WRITE_LONG_ONCE commands are of particular
      interest for fault injection testing -- eg. creating "media errors"
      at specific locations on a disk.
      The fussy bit is that these commands require a non-standard
      sector size, usually 520 bytes instead of 512.
      This patch adds support to libata for READ/WRITE LONG commands
      issued via SG_IO/ATA_16.
      Signed-off-by: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Mark Lord's avatar
      RESEND: libata: check cdb len per dev instead of per host · f0ef88ed
      Mark Lord authored
      Resending, with s/printk/DPRINTK/ as pointed out by Alan.
      Fix libata to perform CDB len validation per device
      rather than per host.  This way, validation still works
      when we have a mix of 12-byte and 16-byte devices on
      a common host interface.
      Signed-off-by: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  12. 04 Apr, 2007 1 commit
  13. 02 Mar, 2007 1 commit
  14. 21 Feb, 2007 5 commits
    • Tejun Heo's avatar
      libata: s/ap->id/ap->print_id/g · 44877b4e
      Tejun Heo authored
      ata_port has two different id fields - id and port_no.  id is
      system-wide 1-based unique id for the port while port_no is 0-based
      host-wide port number.  The former is primarily used to identify the
      ATA port to the user in printk messages while the latter is used in
      various places in libata core and LLDs to index the port inside the
      The two fields feel quite similar and sometimes ap->id is used in
      place of ap->port_no, which is very difficult to spot.  This patch
      renames ap->id to ap->print_id to reduce the possibility of such bugs.
      Some printk messages are adjusted such that id string (ata%u[.%u])
      isn't printed twice and/or to use ata_*_printk() instead of hardcoded
      id format.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata: fix ata_scsi_change_queue_depth() · c3c70c44
      Tejun Heo authored
      Fix ata_scsi_change_queue_depth() such that...
      * NCQ on/off is exactly determined using the same logic as the issue path.
      * queue depth is adjusted to 1 if NCQ is not enabled.
      * -EINVAL is returned if requested action is ignored due to limitations.
      This fixes the bug which allows queue depth to be increased on
      blacklisted NCQ hosts/devices.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata: fix ata_scmd_need_defer() · fcf1bf15
      Tejun Heo authored
      Fix ata_scmd_need_defer() such that...
      * whether NCQ is used or not is exactly determined using the same
        criteria as the issue path.
      * defer-check is performed in all cases.
      This fixes race condition where turning off NCQ on the fly causes
      non-NCQ commands sneak into NCQ phase.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Tejun Heo's avatar
      libata: fix probe_ent alloc/free bugs · 4d05447e
      Tejun Heo authored
      ata_probe_ent_alloc() had a temporary hack such that devm_kzalloc()
      was used for allocation if devres had been previously initialized on
      the device; otherwise, plain kzalloc() was used.  This was to make the
      code useable from both the old and devres-aware libata drivers during
      transition.  This hack made ata_sas_port_alloc() unable to determine
      how the probe_ent is allocated, causing double free in some cases.
      Remove the now-unneeded hack and make ata_sas_port_alloc() use
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: James Bottomley <James.Bottomley@SteelEye.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    • Mark Lord's avatar
      libata bugfix: HDIO_DRIVE_TASK · 2b067191
      Mark Lord authored
      I was trying to use HDIO_DRIVE_TASK for something today,
      and discovered that the libata implementation does not copy
      over the upper four LBA bits from args[6].
      This is serious, as any tools using this ioctl would have their
      commands applied to the wrong sectors on the drive, possibly resulting
      in disk corruption.
      Ideally, newer apps should use SG_IO/ATA_16 directly,
      avoiding this bug.  But with libata poised to displace drivers/ide,
      better compatibility here is a must.
      This patch fixes libata to use the upper four LBA bits passed
      in from the ioctl.
      The original drivers/ide implementation copies over all bits
      except for the master/slave select bit.  With this patch,
      libata will copy only the four high-order LBA bits,
      just in case there are assumptions elsewhere in libata (?).
      Signed-Off-By: default avatarMark Lord <mlord@pobox.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
  15. 09 Feb, 2007 6 commits
  16. 30 Jan, 2007 2 commits
  17. 24 Jan, 2007 1 commit
  18. 20 Dec, 2006 1 commit
    • Tejun Heo's avatar
      [PATCH] libata: take scmd->cmd_len into account when translating SCSI commands · 2e5704f6
      Tejun Heo authored
      libata depended on SCSI command to have the correct length when
      tranlating it into an ATA command.  This generally worked for commands
      issued by SCSI HLD but user could issue arbitrary broken command using
      sg interface.
      Also, when building ATAPI command, full command size was always
      copied.  Because some ATAPI devices needs bytes after CDB cleared, if
      upper layer doesn't clear bytes after CDB, such devices will
      malfunction.  This necessiated recent clear-garbage-after-CDB fix in
      sg interfaces.  However, scsi_execute() isn't fixed yet and HL-DT-ST
      DVD-RAM GSA-H30N malfunctions on initialization commands issued from
      This patch makes xlat functions always consider SCSI cmd_len.  Each
      translation function checks for proper cmd_len and ATAPI translaation
      clears bytes after CDB.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Douglas Gilbert <dougg@torque.net>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>