1. 03 1月, 2020 1 次提交
    • A
      compat_ioctl: scsi: handle HDIO commands from drivers · 75c0b0e1
      Arnd Bergmann 提交于
      The ata_sas_scsi_ioctl() function implements a number of HDIO_* commands
      for SCSI devices, it is used by all libata drivers as well as a few
      drivers that support SAS attached SATA drives.
      
      The only command that is not safe for compat ioctls here is
      HDIO_GET_32BIT. Change the implementation to check for in_compat_syscall()
      in order to do both cases correctly, and change all callers to use it
      as both native and compat callback pointers, including the indirect
      callers through sas_ioctl and ata_scsi_ioctl.
      Reviewed-by: NBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      75c0b0e1
  2. 26 12月, 2019 1 次提交
    • S
      libata: Fix retrieving of active qcs · 8385d756
      Sascha Hauer 提交于
      ata_qc_complete_multiple() is called with a mask of the still active
      tags.
      
      mv_sata doesn't have this information directly and instead calculates
      the still active tags from the started tags (ap->qc_active) and the
      finished tags as (ap->qc_active ^ done_mask)
      
      Since 28361c40 the hw_tag and tag are no longer the same and the
      equation is no longer valid. In ata_exec_internal_sg() ap->qc_active is
      initialized as 1ULL << ATA_TAG_INTERNAL, but in hardware tag 0 is
      started and this will be in done_mask on completion. ap->qc_active ^
      done_mask becomes 0x100000000 ^ 0x1 = 0x100000001 and thus tag 0 used as
      the internal tag will never be reported as completed.
      
      This is fixed by introducing ata_qc_get_active() which returns the
      active hardware tags and calling it where appropriate.
      
      This is tested on mv_sata, but sata_fsl and sata_nv suffer from the same
      problem. There is another case in sata_nv that most likely needs fixing
      as well, but this looks a little different, so I wasn't confident enough
      to change that.
      
      Fixes: 28361c40 ("libata: add extra internal command")
      Cc: stable@vger.kernel.org
      Tested-by: NPali Rohár <pali.rohar@gmail.com>
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      
      Add missing export of ata_qc_get_active(), as per Pali.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      8385d756
  3. 01 11月, 2019 2 次提交
  4. 21 5月, 2019 1 次提交
  5. 09 2月, 2019 1 次提交
  6. 19 12月, 2018 1 次提交
  7. 30 7月, 2018 1 次提交
    • S
      ata: ahci: Support state with min power but Partial low power state · a5ec5a7b
      Srinivas Pandruvada 提交于
      Currently when min_power policy is selected, the partial low power state
      is not entered and link will try aggressively enter to only slumber state.
      Add a new policy which still enable DEVSLP but also try to enter partial
      low power state. This policy is presented as "min_power_with_partial".
      
      For information the difference between partial and slumber
      Partial – PHY logic is powered up, and in a reduced power state. The link
      PM exit latency to active state maximum is 10 ns.
      Slumber – PHY logic is powered up, and in a reduced power state. The link
      PM exit latency to active state maximum is 10 ms.
      Devslp – PHY logic is powered down. The link PM exit latency from this
      state to active state maximum is 20 ms, unless otherwise specified by
      DETO.
      Suggested-and-reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      a5ec5a7b
  8. 12 7月, 2018 1 次提交
    • S
      libata: remove ata_sff_data_xfer_noirq() · 23ebda2f
      Sebastian Andrzej Siewior 提交于
      ata_sff_data_xfer_noirq() is invoked via the ->sff_data_xfer hook. The
      latter is invoked by ata_pio_sector(), atapi_send_cdb() and
      __atapi_pio_bytes() which in turn is invoked by ata_sff_hsm_move().
      The latter function requires that the "ap->lock" lock is held which
      needs to be taken with disabled interrupts.
      
      There is no need have to have ata_sff_data_xfer_noirq() which invokes
      ata_sff_data_xfer32() with disabled interrupts because at this point the
      interrupts are already disabled.
      Remove the function and its references to it and replace all callers
      with ata_sff_data_xfer32().
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      23ebda2f
  9. 02 7月, 2018 1 次提交
    • H
      ahci: Disable LPM on Lenovo 50 series laptops with a too old BIOS · 240630e6
      Hans de Goede 提交于
      There have been several reports of LPM related hard freezes about once
      a day on multiple Lenovo 50 series models. Strange enough these reports
      where not disk model specific as LPM issues usually are and some users
      with the exact same disk + laptop where seeing them while other users
      where not seeing these issues.
      
      It turns out that enabling LPM triggers a firmware bug somewhere, which
      has been fixed in later BIOS versions.
      
      This commit adds a new ahci_broken_lpm() function and a new ATA_FLAG_NO_LPM
      for dealing with this.
      
      The ahci_broken_lpm() function contains DMI match info for the 4 models
      which are known to be affected by this and the DMI BIOS date field for
      known good BIOS versions. If the BIOS date is older then the one in the
      table LPM will be disabled and a warning will be printed.
      
      Note the BIOS dates are for known good versions, some older versions may
      work too, but we don't know for sure, the table is using dates from BIOS
      versions for which users have confirmed that upgrading to that version
      makes the problem go away.
      
      Unfortunately I've been unable to get hold of the reporter who reported
      that BIOS version 2.35 fixed the problems on the W541 for him. I've been
      able to verify the DMI_SYS_VENDOR and DMI_PRODUCT_VERSION from an older
      dmidecode, but I don't know the exact BIOS date as reported in the DMI.
      Lenovo keeps a changelog with dates in their release notes, but the
      dates there are the release dates not the build dates which are in DMI.
      So I've chosen to set the date to which we compare to one day past the
      release date of the 2.34 BIOS. I plan to fix this with a follow up
      commit once I've the necessary info.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      240630e6
  10. 20 6月, 2018 2 次提交
    • 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
    • J
      libata: add command iterator helpers · 6362f0a2
      Jens Axboe 提交于
      Now that we have the internal tag as a special (higher) value tag,
      it gets a bit tricky to iterate the internal commands as some loops
      will exceed ATA_MAX_QUEUE. Add explicit helpers for iterating pending
      commands, both inflight and internal.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      6362f0a2
  11. 29 5月, 2018 1 次提交
  12. 12 5月, 2018 4 次提交
  13. 19 4月, 2018 1 次提交
    • J
      scsi: libsas: add transport class for ATA devices · b6240a4d
      Jason Yan 提交于
      Now ata devices attached with sas controller do not have transport
      class, so that we can not see any information of these ata devices in
      /sys/class/ata_port(or ata_link or ata_device).
      
      Add transport class for the ata devices attached with sas controller.
      The /sys/class directory will show the infomation of the ata devices
      as follows:
      
      localhost:/sys/class # ls ata*
      ata_device:
      dev1.0  dev2.0
      
      ata_link:
      link1  link2
      
      ata_port:
      ata1  ata2
      
      No functional change of the device scanning and io path. The ata
      transport class was deleted when destroying the sas devices.
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      CC: Dan Williams <dan.j.williams@intel.com>
      CC: Tejun Heo <tj@kernel.org>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      b6240a4d
  14. 14 3月, 2018 1 次提交
    • T
      libata: add refcounting to ata_host · 2623c7a5
      Taras Kondratiuk 提交于
      After commit 9a6d6a2d ("ata: make ata port as parent device of scsi
      host") manual driver unbind/remove causes use-after-free.
      
      Unbind unconditionally invokes devres_release_all() which calls
      ata_host_release() and frees ata_host/ata_port memory while it is still
      being referenced as a parent of SCSI host. When SCSI host is finally
      released scsi_host_dev_release() calls put_device(parent) and accesses
      freed ata_port memory.
      
      Add reference counting to make sure that ata_host lives long enough.
      
      Bug report: https://lkml.org/lkml/2017/11/1/945
      Fixes: 9a6d6a2d ("ata: make ata port as parent device of scsi host")
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Lin Ming <minggr@gmail.com>
      Cc: linux-ide@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NTaras Kondratiuk <takondra@cisco.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      2623c7a5
  15. 19 9月, 2017 1 次提交
    • H
      libata: Add new med_power_with_dipm link_power_management_policy setting · f4ac6476
      Hans de Goede 提交于
      As described by Matthew Garret quite a while back:
      https://mjg59.dreamwidth.org/34868.html
      
      Intel CPUs starting with the Haswell generation need SATA links to power
      down for the "package" part of the CPU to reach low power-states like
      PC7 / P8 which bring a significant power-saving with them.
      
      The default max_performance lpm policy does not allow for these high
      PC states, both the medium_power and min_power policies do allow this.
      
      The min_power policy saves significantly more power, but there are some
      reports of some disks / SSDs not liking min_power leading to system
      crashes and in some cases even data corruption has been reported.
      
      Matthew has found a document documenting the default settings of
      Intel's IRST Windows driver with which most laptops ship:
      https://www-ssl.intel.com/content/dam/doc/reference-guide/sata-devices-implementation-recommendations.pdf
      
      Matthew wrote a patch changing med_power to match those defaults, but
      that never got anywhere as some people where reporting issues with the
      patch-set that patch was a part of.
      
      This commit is another attempt to make the default IRST driver settings
      available under Linux, but instead of changing medium_power and
      potentially introducing regressions, this commit adds a new
      med_power_with_dipm setting which is identical to the existing
      medium_power accept that it enables dipm on top, which makes it match
      the Windows IRST driver settings, which should hopefully be safe to
      use on most devices.
      
      The med_power_with_dipm setting is close to min_power, except that:
      a) It does not use host-initiated slumber mode (ASP not set),
         but it does allow device-initiated slumber
      b) It does not enable DevSlp mode
      
      On my T440s test laptop I get the following power savings when idle:
      medium_power		0.9W
      med_power_with_dipm	1.2W
      min_power		1.2W
      Suggested-by: NMatthew Garrett <mjg59@srcf.ucam.org>
      Cc: Matthew Garrett <mjg59@srcf.ucam.org>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      f4ac6476
  16. 29 8月, 2017 2 次提交
  17. 11 7月, 2017 1 次提交
    • D
      libata: Cleanup ata_read_log_page() · 7cfdfdc8
      Damien Le Moal 提交于
      The warning message "READ LOG DMA EXT failed, trying unqueued" in
      ata_read_log_page() as well as the macro name ATA_HORKAGE_NO_NCQ_LOG
      are confusing: the command READ LOG DMA EXT is not an queued NCQ command
      unless it is encapsulated in a RECEIVE FPDMA QUEUED command.
      From ACS-4 READ LOG DMA EXT description:
      
      "The device processes the READ LOG DMA EXT command in the NCQ feature
      set environment (see 4.13.6) if the READ LOG DMA EXT command is
      encapsulated in a RECEIVE FPDMA QUEUED command (see 7.30) with the
      inputs encapsulated as shown in 7.23.6."
      
      To avoid confusion, fix the warning messsage to mention switching to PIO and
      not "unqueued" and rename the macro ATA_HORKAGE_NO_NCQ_LOG to
      ATA_HORKAGE_NO_DMA_LOG.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      7cfdfdc8
  18. 06 6月, 2017 1 次提交
  19. 16 5月, 2017 2 次提交
  20. 07 2月, 2017 1 次提交
  21. 11 1月, 2017 1 次提交
  22. 20 10月, 2016 2 次提交
  23. 22 9月, 2016 1 次提交
  24. 19 7月, 2016 3 次提交
  25. 15 7月, 2016 1 次提交
  26. 14 7月, 2016 1 次提交
  27. 10 5月, 2016 4 次提交