1. 27 12月, 2019 3 次提交
  2. 20 6月, 2018 1 次提交
    • J
      scsi: libsas: dynamically allocate and free ata host · 2fa4a326
      Jason Yan 提交于
      Commit 2623c7a5 ("libata: add refcounting to ata_host") v4.17+ introduced
      refcounting to ata_host and will increase or decrease the refcount when
      adding or deleting transport ATA port.
      
      Now the ata host for libsas is embedded in domain_device, and the ->kref
      member is not initialized. Afer we add ata transport class, ata_host_get()
      will be called when adding transport ATA port and a warning will be
      triggered as below:
      
      refcount_t: increment on 0; use-after-free.
      WARNING: CPU: 2 PID: 103 at
      lib/refcount.c:153 refcount_inc+0x40/0x48 ......  Call trace:
       refcount_inc+0x40/0x48
       ata_host_get+0x10/0x18
       ata_tport_add+0x40/0x120
       ata_sas_tport_add+0xc/0x14
       sas_ata_init+0x7c/0xc8
       sas_discover_domain+0x380/0x53c
       process_one_work+0x12c/0x288
       worker_thread+0x58/0x3f0
       kthread+0xfc/0x128
       ret_from_fork+0x10/0x18
      
      And also when removing transport ATA port ata_host_put() will be called and
      another similar warning will be triggered. If the refcount decreased to
      zero, the ata host will be freed. But this ata host is only part of
      domain_device, it cannot be freed directly.
      
      So we have to change this embedded static ata host to a dynamically
      allocated ata host and initialize the ->kref member. To use ata_host_get()
      and ata_host_put() in libsas, we need to move the declaration of these
      functions to the public libata.h and export them.
      
      Fixes: b6240a4d ("scsi: libsas: add transport class for ATA devices")
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Taras Kondratiuk <takondra@cisco.com>
      CC: Tejun Heo <tj@kernel.org>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      2fa4a326
  3. 11 1月, 2018 1 次提交
    • J
      scsi: libsas: direct call probe and destruct · 0558f33c
      Jason Yan 提交于
      In commit 87c8331f ("[SCSI] libsas: prevent domain rediscovery
      competing with ata error handling") introduced disco mutex to prevent
      rediscovery competing with ata error handling and put the whole
      revalidation in the mutex. But the rphy add/remove needs to wait for the
      error handling which also grabs the disco mutex. This may leads to dead
      lock.So the probe and destruct event were introduce to do the rphy
      add/remove asynchronously and out of the lock.
      
      The asynchronously processed workers makes the whole discovery process
      not atomic, the other events may interrupt the process. For example,
      if a loss of signal event inserted before the probe event, the
      sas_deform_port() is called and the port will be deleted.
      
      And sas_port_delete() may run before the destruct event, but the
      port-x:x is the top parent of end device or expander. This leads to
      a kernel WARNING such as:
      
      [   82.042979] sysfs group 'power' not found for kobject 'phy-1:0:22'
      [   82.042983] ------------[ cut here ]------------
      [   82.042986] WARNING: CPU: 54 PID: 1714 at fs/sysfs/group.c:237
      sysfs_remove_group+0x94/0xa0
      [   82.043059] Call trace:
      [   82.043082] [<ffff0000082e7624>] sysfs_remove_group+0x94/0xa0
      [   82.043085] [<ffff00000864e320>] dpm_sysfs_remove+0x60/0x70
      [   82.043086] [<ffff00000863ee10>] device_del+0x138/0x308
      [   82.043089] [<ffff00000869a2d0>] sas_phy_delete+0x38/0x60
      [   82.043091] [<ffff00000869a86c>] do_sas_phy_delete+0x6c/0x80
      [   82.043093] [<ffff00000863dc20>] device_for_each_child+0x58/0xa0
      [   82.043095] [<ffff000008696f80>] sas_remove_children+0x40/0x50
      [   82.043100] [<ffff00000869d1bc>] sas_destruct_devices+0x64/0xa0
      [   82.043102] [<ffff0000080e93bc>] process_one_work+0x1fc/0x4b0
      [   82.043104] [<ffff0000080e96c0>] worker_thread+0x50/0x490
      [   82.043105] [<ffff0000080f0364>] kthread+0xfc/0x128
      [   82.043107] [<ffff0000080836c0>] ret_from_fork+0x10/0x50
      
      Make probe and destruct a direct call in the disco and revalidate function,
      but put them outside the lock. The whole discovery or revalidate won't
      be interrupted by other events. And the DISCE_PROBE and DISCE_DESTRUCT
      event are deleted as a result of the direct call.
      
      Introduce a new list to destruct the sas_port and put the port delete after
      the destruct. This makes sure the right order of destroying the sysfs
      kobject and fix the warning above.
      
      In sas_ex_revalidate_domain() have a loop to find all broadcasted
      device, and sometimes we have a chance to find the same expander twice.
      Because the sas_port will be deleted at the end of the whole revalidate
      process, sas_port with the same name cannot be added before this.
      Otherwise the sysfs will complain of creating duplicate filename. Since
      the LLDD will send broadcast for every device change, we can only
      process one expander's revalidation.
      
      [mkp: kbuild test robot warning]
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      0558f33c
  4. 09 1月, 2018 4 次提交
    • J
      scsi: libsas: Use new workqueue to run sas event and disco event · 93bdbd06
      Jason Yan 提交于
      Now all libsas works are queued to scsi host workqueue, include sas
      event work post by LLDD and sas discovery work, and a sas hotplug flow
      may be divided into several works, e.g libsas receive a
      PORTE_BYTES_DMAED event, currently we process it as following steps:
      
      sas_form_port  --- run in work in shost workq
      	sas_discover_domain  --- run in another work in shost workq
      		...
      		sas_probe_devices  --- run in new work in shost workq
      We found during hot-add a device, libsas may need run several
      works in same workqueue to add device in system, the process is
      not atomic, it may interrupt by other sas event works, like
      PHYE_LOSS_OF_SIGNAL.
      
      This patch is preparation of execute libsas sas event in sync. We need
      to use different workqueue to run sas event and disco event. Otherwise
      the work will be blocked for waiting another chained work in the same
      workqueue.
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      93bdbd06
    • J
      scsi: libsas: make the event threshold configurable · 8eea9dd8
      Jason Yan 提交于
      Add a sysfs attr that LLDD can configure it for every host. We made an
      example in hisi_sas. Other LLDDs using libsas can implement it if they
      want.
      Suggested-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      Acked-by: John Garry <john.garry@huawei.com> #for hisi_sas part
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      8eea9dd8
    • J
      scsi: libsas: shut down the PHY if events reached the threshold · f12486e0
      Jason Yan 提交于
      If the PHY burst too many events, we will alloc a lot of events for the
      worker. This may leads to memory exhaustion.
      
      Dan Williams suggested to shut down the PHY if the events reached the
      threshold, because in this case the PHY may have gone into some
      erroneous state. Users can re-enable the PHY by sysfs if they want.
      
      We cannot use the fixed memory pool because if we run out of events, the
      shut down event and loss of signal event will lost too. The events still
      need to be allocated and processed in this case.
      Suggested-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      f12486e0
    • J
      scsi: libsas: Use dynamic alloced work to avoid sas event lost · 1c393b97
      Jason Yan 提交于
      Now libsas hotplug work is static, every sas event type has its own
      static work, LLDD driver queues the hotplug work into shost->work_q.  If
      LLDD driver burst posts lots hotplug events to libsas, the hotplug
      events may pending in the workqueue like
      
      shost->work_q
      new work[PORTE_BYTES_DMAED] --> |[PHYE_LOSS_OF_SIGNAL][PORTE_BYTES_DMAED] -> processing
                                      |<-------wait worker to process-------->|
      
      In this case, a new PORTE_BYTES_DMAED event coming, libsas try to queue
      it to shost->work_q, but this work is already pending, so it would be
      lost. Finally, libsas delete the related sas port and sas devices, but
      LLDD driver expect libsas add the sas port and devices(last sas event).
      
      This patch use dynamic allocated work to avoid this issue.
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      CC: John Garry <john.garry@huawei.com>
      CC: Johannes Thumshirn <jthumshirn@suse.de>
      CC: Ewan Milne <emilne@redhat.com>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Tomas Henzl <thenzl@redhat.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      1c393b97
  5. 22 11月, 2017 1 次提交
  6. 02 11月, 2017 1 次提交
    • K
      scsi: sas: Convert timers to use timer_setup() · 77570eed
      Kees Cook 提交于
      In preparation for unconditionally passing the struct timer_list pointer to
      all timer callbacks, switch to using the new timer_setup() and from_timer()
      to pass the timer pointer explicitly. This requires adding a pointer to
      hold the timer's target task, as there isn't a link back from slow_task.
      
      Cc: John Garry <john.garry@huawei.com>
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Jack Wang <jinpu.wang@profitbricks.com>
      Cc: lindar_liu@usish.com
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Benjamin Block <bblock@linux.vnet.ibm.com>
      Cc: Baoyou Xie <baoyou.xie@linaro.org>
      Cc: Wei Yongjun <weiyongjun1@huawei.com>
      Cc: linux-scsi@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Acked-by: John Garry <john.garry@huawei.com> # for hisi_sas part
      Tested-by: John Garry <john.garry@huawei.com> # basic sanity test for hisi_sas
      Reviewed-by: NJack Wang <jinpu.wang@profitbricks.com>
      77570eed
  7. 16 9月, 2017 3 次提交
  8. 30 8月, 2017 1 次提交
  9. 26 8月, 2017 1 次提交
  10. 28 6月, 2017 1 次提交
  11. 05 4月, 2017 1 次提交
  12. 04 12月, 2014 1 次提交
  13. 27 11月, 2014 1 次提交
    • C
      libsas: remove task_collector mode · 79855d17
      Christoph Hellwig 提交于
      The task_collector mode (or "latency_injector", (C) Dan Willians) is an
      optional I/O path in libsas that queues up scsi commands instead of
      directly sending it to the hardware.  It generall increases latencies
      to in the optiomal case slightly reduce mmio traffic to the hardware.
      
      Only the obsolete aic94xx driver and the mvsas driver allowed to use
      it without recompiling the kernel, and most drivers didn't support it
      at all.
      
      Remove the giant blob of code to allow better optimizations for scsi-mq
      in the future.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Acked-by: NDan Williams <dan.j.williams@intel.com>
      79855d17
  14. 24 11月, 2014 1 次提交
  15. 06 11月, 2014 1 次提交
  16. 19 3月, 2014 1 次提交
    • D
      libata, libsas: kill pm_result and related cleanup · bc6e7c4b
      Dan Williams 提交于
      Tejun says:
        "At least for libata, worrying about suspend/resume failures don't make
         whole lot of sense.  If suspend failed, just proceed with suspend.  If
         the device can't be woken up afterwards, that's that.  There isn't
         anything we could have done differently anyway.  The same for resume, if
         spinup fails, the device is dud and the following commands will invoke
         EH actions and will eventually fail.  Again, there really isn't any
         *choice* to make.  Just making sure the errors are handled gracefully
         (ie. don't crash) and the following commands are handled correctly
         should be enough."
      
      The only libata user that actually cares about the result from a suspend
      operation is libsas.  However, it only cares about whether queuing a new
      operation collides with an in-flight one.  All libsas does with the
      error is retry, but we can just let libata wait for the previous
      operation before continuing.
      
      Other cleanups include:
      1/ Unifying all ata port pm operations on an ata_port_pm_ prefix
      2/ Marking all ata port pm helper routines as returning void, only
         ata_port_pm_ entry points need to fake a 0 return value.
      3/ Killing ata_port_{suspend|resume}_common() in favor of calling
         ata_port_request_pm() directly
      4/ Killing the wrappers that just do a to_ata_port() conversion
      5/ Clearly marking the entry points that do async operations with an
        _async suffix.
      
      Reference: http://marc.info/?l=linux-scsi&m=138995409532286&w=2
      
      Cc: Phillip Susi <psusi@ubuntu.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Suggested-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NTodd Brandt <todd.e.brandt@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      bc6e7c4b
  17. 05 6月, 2013 1 次提交
    • J
      [SCSI] libsas: implement > 16 byte CDB support · e73823f7
      James Bottomley 提交于
      Remove the arbitrary expectation in libsas that all SCSI commands are 16 bytes
      or less.  Instead do all copies via cmd->cmd_len (and use a pointer to this in
      the libsas task instead of a copy).  Note that this still doesn't enable > 16
      byte CDB support in the underlying drivers because their internal format has
      to be fixed and the wire format of > 16 byte CDBs according to the SAS spec is
      different.  the libsas drivers (isci, aic94xx, mvsas and pm8xxx are all
      updated for this change.
      
      Cc: Lukasz Dorau <lukasz.dorau@intel.com>
      Cc: Maciej Patelczyk <maciej.patelczyk@intel.com>
      Cc: Dave Jiang <dave.jiang@intel.com>
      Cc: Jack Wang <xjtuwjp@gmail.com>
      Cc: Lindar Liu <lindar_liu@usish.com>
      Cc: Xiangliang Yu <yuxiangl@marvell.com>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      e73823f7
  18. 10 5月, 2013 1 次提交
    • J
      [SCSI] sas: unify the pointlessly separated enums sas_dev_type and sas_device_type · aa9f8328
      James Bottomley 提交于
      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: NJames Bottomley <JBottomley@Parallels.com>
      aa9f8328
  19. 24 8月, 2012 1 次提交
    • D
      [SCSI] libsas: suspend / resume support · 303694ee
      Dan Williams 提交于
      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: NDan Williams <dan.j.williams@intel.com>
      Reviewed-by: NJacek Danecki <jacek.danecki@intel.com>
      Tested-by: NMaciej Patelczyk <maciej.patelczyk@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      303694ee
  20. 20 7月, 2012 5 次提交
  21. 08 7月, 2012 1 次提交
  22. 23 4月, 2012 1 次提交
  23. 01 3月, 2012 5 次提交
  24. 20 2月, 2012 2 次提交