1. 10 May, 2013 1 commit
    • James Bottomley's avatar
      [SCSI] sas: unify the pointlessly separated enums sas_dev_type and sas_device_type · aa9f8328
      James Bottomley authored
      These enums have been separate since the dawn of SAS, mainly because the
      latter is a procotol only enum and the former includes additional state
      for libsas.  The dichotomy causes endless confusion about which one you
      should use where and leads to pointless warnings like this:
      
      drivers/scsi/mvsas/mv_sas.c: In function 'mvs_update_phyinfo':
      drivers/scsi/mvsas/mv_sas.c:1162:34: warning: comparison between 'enum sas_device_type' and 'enum sas_dev_type' [-Wenum-compare]
      
      Fix by eliminating one of them.  The one kept is effectively the sas.h
      one, but call it sas_device_type and make sure the enums are all
      properly namespaced with the SAS_ prefix.
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      aa9f8328
  2. 24 Aug, 2012 1 commit
    • Dan Williams's avatar
      [SCSI] libsas: suspend / resume support · 303694ee
      Dan Williams authored
      libsas power management routines to suspend and recover the sas domain
      based on a model where the lldd is allowed and expected to be
      "forgetful".
      
      sas_suspend_ha - disable event processing allowing the lldd to take down
                       links without concern for causing hotplug events.
                       Regardless of whether the lldd actually posts link down
                       messages libsas notifies the lldd that all
                       domain_devices are gone.
      
      sas_prep_resume_ha - on the way back up before the lldd starts link
                           training clean out any spurious events that were
                           generated on the way down, and re-enable event
                           processing
      
      sas_resume_ha - after the lldd has started and decided that all phys
      		have posted link-up events this routine is called to let
      		libsas start it's own timeout of any phys that did not
      		resume.  After the timeout an lldd can cancel the
                      phy teardown by posting a link-up event.
      
      Storage for ex_change_count (u16) and phy_change_count (u8) are changed
      to int so they can be set to -1 to indicate 'invalidated'.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Reviewed-by: default avatarJacek Danecki <jacek.danecki@intel.com>
      Tested-by: default avatarMaciej Patelczyk <maciej.patelczyk@intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      303694ee
  3. 20 Jul, 2012 1 commit
  4. 23 Apr, 2012 1 commit
    • Dan Williams's avatar
      [SCSI] libsas, libata: fix start of life for a sas ata_port · b2024459
      Dan Williams authored
      This changes the ordering of initialization and probing events from:
        1/ allocate rphy in PORTE_BYTES_DMAED, DISCE_REVALIDATE_DOMAIN
        2/ allocate ata_port and schedule port probe in DISCE_PROBE
      ...to:
        1/ allocate ata_port in PORTE_BYTES_DMAED, DISCE_REVALIDATE_DOMAIN
        2/ allocate rphy in PORTE_BYTES_DMAED, DISCE_REVALIDATE_DOMAIN
        3/ schedule port probe in DISCE_PROBE
      
      This ordering prevents PHYE_SIGNAL_LOSS_EVENTS from sneaking in to
      destrory ata devices before they have been fully initialized:
      
        BUG: unable to handle kernel paging request at 0000000000003b10
        IP: [<ffffffffa0053d7e>] sas_ata_end_eh+0x12/0x5e [libsas]
        ...
        [<ffffffffa004d1af>] sas_unregister_common_dev+0x78/0xc9 [libsas]
        [<ffffffffa004d4d4>] sas_unregister_dev+0x4f/0xad [libsas]
        [<ffffffffa004d5b1>] sas_unregister_domain_devices+0x7f/0xbf [libsas]
        [<ffffffffa004c487>] sas_deform_port+0x61/0x1b8 [libsas]
        [<ffffffffa004bed0>] sas_phye_loss_of_signal+0x29/0x2b [libsas]
      
      ...and kills the awkward "sata domain_device briefly existing in the
      domain without an ata_port" state.
      Reported-by: default avatarMichal Kosciowski <michal.kosciowski@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Acked-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      b2024459
  5. 29 Feb, 2012 4 commits
  6. 19 Feb, 2012 5 commits
    • Dan Williams's avatar
      [SCSI] libsas: execute transport link resets with libata-eh via host workqueue · 81c757bc
      Dan Williams authored
      Link resets leave ata affiliations intact, so arrange for libsas to make
      an effort to avoid dropping the device due to a slow-to-recover link.
      Towards this end carry out reset in the host workqueue so that it can
      check for ata devices and kick the reset request to libata.  Hard
      resets, in contrast, bypass libata since they are meant for associating
      an ata device with another initiator in the domain (tears down
      affiliations).
      
      Need to add a new transport_sas_phy_reset() since the current
      sas_phy_reset() is a utility function to libsas lldds.  They are not
      prepared for it to loop back into eh.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      81c757bc
    • Dan Williams's avatar
      [SCSI] libsas: use libata-eh-reset for sata rediscovery fis transmit failures · b52df417
      Dan Williams authored
      Since sata devices can take several seconds to recover the link on reset
      the 0.5 seconds that libsas currently waits may not be enough.  Instead
      if we are rediscovering a phy that was previously attached to a sata
      device let libata handle any resets to encourage the device to transmit
      the initial fis.
      
      Once sas_ata_hard_reset() and lldds learn how to honor 'deadline' libsas
      should stop encountering phys in an intermediate state, until then this
      will loop until the fis is transmitted or ->attached_sas_addr gets
      cleared, but in the more likely initial discovery case we keep existing
      behavior.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      b52df417
    • Dan Williams's avatar
      [SCSI] libsas: fix timeout vs completion race · 9095a64a
      Dan Williams authored
      Until we have told the lldd to forget a task a timed out operation can
      return from the hardware at any time.  Since completion frees the task
      we need to make sure that no tasks run their normal completion handler
      once eh has decided to manage the task.  Similar to
      ata_scsi_cmd_error_handler() freeze completions to let eh judge the
      outcome of the race.
      
      Task collector mode is problematic because it presents a situation where
      a task can be timed out and aborted before the lldd has even seen it.
      For this case we need to guarantee that a task that an lldd has been
      told to forget does not get queued after the lldd says "never seen it".
      With sas_scsi_timed_out we achieve this with the ->task_queue_flush
      mutex, rather than adding more time.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      9095a64a
    • Dan Williams's avatar
      [SCSI] libsas: prevent domain rediscovery competing with ata error handling · 87c8331f
      Dan Williams authored
      libata error handling provides for a timeout for link recovery.  libsas
      must not rescan for previously known devices in this interval otherwise
      it may remove a device that is simply waiting for its link to recover.
      Let libata-eh make the determination of when the link is stable and
      prevent libsas (host workqueue) from taking action while this
      determination is pending.
      
      Using a mutex (ha->disco_mutex) to flush and disable revalidation while
      eh is running requires any discovery action that may block on eh be
      moved to its own context outside the lock.  Probing ATA devices
      explicitly waits on ata-eh and the cache-flush-io issued during device
      removal may also pend awaiting eh completion.  Essentially any rphy
      add/remove activity needs to run outside the lock.
      
      This adds two new cleanup states for sas_unregister_domain_devices()
      'allocated-but-not-probed', and 'flagged-for-destruction'.  In the
      'allocated-but-not-probed' state  dev->rphy points to a rphy that is
      known to have not been through a sas_rphy_add() event.  At domain
      teardown check if this device is still pending probe and cleanup
      accordingly.  Similarly if a device has already been queued for removal
      then sas_unregister_domain_devices has nothing to do.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      87c8331f
    • Dan Williams's avatar
      [SCSI] libsas: fix leak of dev->sata_dev.identify_[packet_]device · 756f173f
      Dan Williams authored
      These are never freed in the nominal path.  A domain_device has a
      different lifetime than a sas_rphy we need a dev->rphy independent way
      of identifying sata devices.
      Reviewed-by: default avatarJack Wang <jack_wang@usish.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      756f173f
  7. 02 Mar, 2011 1 commit
    • James Bottomley's avatar
      libsas: convert to libata new error handler · 00dd4998
      James Bottomley authored
      The conversion is quite complex given that the libata new error
      handler has to be hooked into the current libsas timeout and error
      handling.  The way this is done is to process all the failed commands
      via libsas first, but if they have no underlying sas task (and they're
      on a sata device) assume they are destined for the libata error
      handler and send them accordingly.
      
      Finally, activate the port recovery of the libata error handler for
      each port known to the host.  This is somewhat suboptimal, since that
      port may not need recovering, but given the current architecture of
      the libata error handler, it's the only way; and the spurious
      activation is harmless.
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      00dd4998
  8. 13 Feb, 2011 1 commit
    • James Bottomley's avatar
      [SCSI] libsas: convert to libata new error handler · c299190b
      James Bottomley authored
      The conversion is quite complex given that the libata new error
      handler has to be hooked into the current libsas timeout and error
      handling.  The way this is done is to process all the failed commands
      via libsas first, but if they have no underlying sas task (and they're
      on a sata device) assume they are destined for the libata error
      handler and send them accordingly.
      
      Finally, activate the port recovery of the libata error handler for
      each port known to the host.  This is somewhat suboptimal, since that
      port may not need recovering, but given the current architecture of
      the libata error handler, it's the only way; and the spurious
      activation is harmless.
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      c299190b
  9. 07 Apr, 2008 1 commit
    • James Bottomley's avatar
      [SCSI] libsas: fix missing inlines in header file · 79bc1481
      James Bottomley authored
      Two functions in include/scsi/sas_ata.h don't have static inlines
      leading to problems if they're built in:
      
      On Thu, 2008-04-03 at 14:06 +0200, Toralf Förster wrote:
      > drivers/scsi/mvsas.o: In function `sas_ata_init_host_and_port':
      > mvsas.c:(.text+0x0): multiple definition of `sas_ata_init_host_and_port'
      > drivers/scsi/libsas/built-in.o:(.text+0x37f4): first defined here
      > drivers/scsi/mvsas.o: In function `sas_ata_task_abort':
      > mvsas.c:(.text+0x7): multiple definition of `sas_ata_task_abort'
      > drivers/scsi/libsas/built-in.o:(.text+0x37fb): first defined here
      > make[2]: *** [drivers/scsi/built-in.o] Error 1
      > make[1]: *** [drivers/scsi] Error 2
      > make: *** [drivers] Error 2
      
      Add the correct static inline modifiers.
      Tested-by: default avatarToralf Förster <toralf.foerster@gmx.de>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
      79bc1481
  10. 22 Jul, 2007 1 commit
  11. 18 Jul, 2007 2 commits