1. 13 Jan, 2023 1 commit
  2. 04 Jan, 2023 8 commits
    • Damien Le Moal's avatar
      ata: libata-scsi: improve ata_scsiop_maint_in() · 002c4871
      Damien Le Moal authored
      Allow translation of REPORT_SUPPORTED_OPERATION_CODES commands using
      the command format 0x3, that is, checking support for commands that are
      identified using an opcode and a service action.
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      002c4871
    • Niklas Cassel's avatar
      ata: libata-scsi: do not overwrite SCSI ML and status bytes · 7574a837
      Niklas Cassel authored
      For SCSI ML byte:
      In the case where a command is completed via libata EH:
      irq -> ata_qc_complete() -> ata_qc_schedule_eh()
      irq done
      ... -> ata_do_eh() -> ata_eh_link_autopsy() -> ata_eh_finish() ->
      ata_eh_qc_complete() -> __ata_eh_qc_complete() -> __ata_qc_complete() ->
      qc->complete_fn() (ata_scsi_qc_complete()) -> ata_qc_done() ->
      qc->scsidone() (empty stub)
      ... -> scsi_eh_finish_cmd() -> scsi_eh_flush_done_q() ->
      scsi_finish_command()
      
      ata_eh_link_autopsy() will call ata_eh_analyze_tf(), which calls
      scsi_check_sense(), which sets the SCSI ML byte.
      
      Since ata_scsi_qc_complete() is called after scsi_check_sense() when
      a command is completed via libata EH, we cannot simply overwrite the
      SCSI ML byte that was set earlier in the call chain.
      
      For SCSI status byte:
      When a SCSI command is prepared using scsi_prepare_cmd(), it sets
      cmd->result to 0. (SAM_STAT_GOOD is defined as 0x0).
      Likewise, when a command is requeued from SCSI EH, scsi_queue_insert()
      is called, which sets cmd->result to 0.
      
      A SCSI command thus always has a GOOD status by default when being
      sent to libata.
      
      If libata fetches sense data from the device, it will call
      ata_scsi_set_sense(), which will set the status byte to
      SAM_STAT_CHECK_CONDITION, if the caller deems that the status should be
      a check condition.
      
      ata_scsi_qc_complete() should therefore never overwrite the existing
      status byte, because if it is != GOOD, it was set by libata itself,
      for a reason.
      
      For the host byte:
      When libata abort commands, because of a NCQ error, it will schedule
      SCSI EH for all QCs using blk_abort_request(), which will all end up in
      scsi_timeout(), which will call scsi_abort_command(). scsi_timeout()
      sets DID_TIME_OUT regardless if a command was aborted or timed out.
      If we don't clear the DID_TIME_OUT byte for the QC that caused the
      NCQ error, that QC will be reported as a timed out command, instead
      of being reported as a NCQ error.
      
      For a command that actually timed out, DID_TIME_OUT would be fine to
      keep, but libata has its own way of detecting that a command timed out
      (see ata_scsi_cmd_error_handler()), and sets AC_ERR_TIMEOUT if that is
      the case. libata will retry timed out commands.
      
      We could clear DID_TIME_OUT only for the QC that caused the NCQ error,
      but since libata has its own way of detecting timeouts, simply clear it
      always.
      
      Note that the existing ata_scsi_qc_complete() code does:
      cmd->result = SAM_STAT_CHECK_CONDITION or cmd->result = SAM_STAT_GOOD.
      This WILL clear the host byte. So us clearing the host byte
      unconditionally is in line with the existing libata behavior.
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      7574a837
    • Niklas Cassel's avatar
      ata: libata: move NCQ related ATA_DFLAGs · 87aab3c4
      Niklas Cassel authored
      ata_dev_configure() starts off by clearing all flags in ATA_DFLAG_CFG_MASK:
      dev->flags &= ~ATA_DFLAG_CFG_MASK;
      
      ata_dev_configure() then calls ata_dev_config_lba() which calls
      ata_dev_config_ncq().
      
      ata_dev_config_ncq() will set the correct ATA_DFLAGs depending on what is
      actually supported.
      
      Since these flags are set by ata_dev_configure(), they should be in
      ATA_DFLAG_CFG_MASK and not in ATA_DFLAG_INIT_MASK.
      
      ATA_DFLAG_NCQ_PRIO_ENABLED is set via sysfs, is should therefore not be in
      ATA_DFLAG_CFG_MASK. It also cannot be in ATA_DFLAG_INIT_MASK, because
      ata_eh_schedule_probe() calls ata_dev_init(), which will clear all flags in
      ATA_DFLAG_INIT_MASK.
      
      This means that ATA_DFLAG_NCQ_PRIO_ENABLED (the value the user sets via
      sysfs) would get silently cleared if ata_eh_schedule_probe() is called.
      While that should only happen in certain circumstances, it still doesn't
      seem right that it can get silently cleared.
      
      (ata_dev_config_ncq_prio() will still clear the ATA_DFLAG_NCQ_PRIO_ENABLED
      flag if ATA_DFLAG_NCQ_PRIO is suddenly no longer supported after a
      revalidation.)
      
      Because of this, move ATA_DFLAG_NCQ_PRIO_ENABLED to be outside of both
      ATA_DFLAG_CFG_MASK and ATA_DFLAG_INIT_MASK.
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      87aab3c4
    • Niklas Cassel's avatar
      ata: libata: respect successfully completed commands during errors · 7affcded
      Niklas Cassel authored
      In AHCI specification 1.3.1:
      "5.5.3 Processing Completed Commands"
      
      "For each port that has an interrupt pending:
      
      1. Software determines the cause of the interrupt by reading the PxIS
         register. It is possible for multiple bits to be set.
      2. Software clears appropriate bits in the PxIS register corresponding
         to the cause of the interrupt.
      3. Software clears the interrupt bit in IS.IPS corresponding to the port.
      4. If executing non-queued commands, software reads the PxCI register,
         and compares the current value to the list of commands previously
         issued by software that are still outstanding. If executing native
         queued commands, software reads the PxSACT register and compares the
         current value to the list of commands previously issued by software.
         Software completes with success any outstanding command whose
         corresponding bit has been cleared in the respective register. PxCI
         and PxSACT are volatile registers; software should only use their
         values to determine commands that have completed, not to determine
         which commands have previously been issued.
      5. If there were errors, noted in the PxIS register, software performs
         error recovery actions (see section 6.2.2)."
      
      The documentation for the PxSACT shadow register in AHCI:
      "The device clears bits in this field by sending a Set Device Bits FIS
      to the host. The HBA clears bits in this field that are set to ‘1’ in
      the SActive field of the Set Device Bits FIS. The HBA only clears bits
      that correspond to native queued commands that have completed
      successfully."
      
      Additionally, in SATA specification 3.5a:
      "11.15 FPDMA QUEUED command protocol"
      
      "DFPDMAQ11: ERROR
      Halt command processing and transmit Set Device Bits FIS to host
      with the ERR bit in Status field set to one, Interrupt bit set to one,
      ATA error code set to one in the ERROR field, bits in ACT field cleared
      to zero for any outstanding queued commands, and bits set to one
      for any successfully completed queued commands that completion
      notification not yet delivered."
      
      I.e. even when the HBA triggers an error interrupt, the HBA will still
      clear successfully completed commands in PxSACT. Commands that did not
      complete successfully will still have its bit set in PxSACT.
      (Which means the command that caused the NCQ error and queued commands
      that had not yet finished at the time when the NCQ error occurred.)
      
      Additionally, for a HBA that does not have the libata flag
      AHCI_HFLAG_MULTI_MSI set, all ap->locks will point to host->lock, which
      means that IRQs will be disabled for one port while another port's IRQ
      handler is running. The HBA will still receive FISes from the device,
      even if IRQs on the HBA itself are disabled. What can thus e.g. receive
      a FIS that completes several commands successfully, followed by a FIS
      that does (or does not) complete additional commands with the error bit
      set, to indicate that at least one command was aborted.
      
      Therefore, modify ahci_handle_port_interrupt() using the new helper
      ahci_qc_complete() to complete the commands that have already been
      signaled as successfully through a regular completion SDB FIS, as not
      doing so would simply cause successfully completed commands to be
      retried for no good reason.
      Co-developed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      7affcded
    • Niklas Cassel's avatar
      ata: libata: read the shared status for successful NCQ commands once · 93c4aa44
      Niklas Cassel authored
      Currently, the status is being read for each QC, inside
      ata_qc_complete(), which means that QCs being completed by
      ata_qc_complete_multiple() (i.e. multiple QCs completed during a single
      interrupt), can have different status and error bits set. This is
      because the FIS Receive Area will get updated as soon as the HBA
      receives a new FIS from the device in the NCQ case.
      
      Here is an example of the problem:
      ata14.00: ata_qc_complete_multiple: done_mask: 0x180000
      qc tag: 19 cmd: 0x61 flags: 0x11b err_mask: 0x0 tf->status: 0x40
      qc tag: 20 cmd: 0x61 flags: 0x11b err_mask: 0x0 tf->status: 0x43
      
      A print in ata_qc_complete_multiple(), shows that done_mask is: 0x180000
      which means that tag 19 and 20 were completed. Another print in
      ata_qc_complete(), after the call to fill_result_tf(), shows that tag 19
      and 20 have different status values, even though they were completed in
      the same ata_qc_complete_multiple() call.
      
      If PMP is not enabled, simply read the status and error once, before
      calling ata_qc_complete() for each QC. Without PMP, we know that all QCs
      must share the same status and error values.
      
      If PMP is enabled, we also read the status before calling
      ata_qc_complete(), however, we still read the status for each QC, since
      the QCs can belong to different PMP links (which means that the QCs
      does not necessarily share the same status and error values).
      
      Do all this by introducing the new port operation .qc_ncq_fill_rtf. If
      set, this operation is called in ata_qc_complete_multiple() to set the
      result tf for all completed QCs signaled by the last SDB FIS received.
      
      QCs that have their result tf filled are marked with the new flag
      ATA_QCFLAG_RTF_FILLED so that any later execution of the qc_fill_rtf
      port operation does nothing (e.g. when called from ata_qc_complete()).
      Co-developed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      93c4aa44
    • Damien Le Moal's avatar
      ata: libata: simplify qc_fill_rtf port operation interface · 931139af
      Damien Le Moal authored
      The boolean return value of the qc_fill_rtf operation is used nowhere.
      Simplify this operation interface by making it a void function. All
      drivers defining this operation are also updated.
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      931139af
    • Niklas Cassel's avatar
      ata: scsi: rename flag ATA_QCFLAG_FAILED to ATA_QCFLAG_EH · 87629312
      Niklas Cassel authored
      The name ATA_QCFLAG_FAILED is misleading since it does not mean that a
      QC completed in error, or that it didn't complete at all. It means that
      libata decided to schedule EH for the QC, so the QC is now owned by the
      libata error handler (EH).
      
      The normal execution path is responsible for not accessing a QC owned
      by EH. libata core enforces the rule by returning NULL from
      ata_qc_from_tag() for QCs owned by EH.
      
      It is quite easy to mistake that a QC marked with ATA_QCFLAG_FAILED was
      an error. However, a QC that was actually an error is instead indicated
      by having qc->err_mask set. E.g. when we have a NCQ error, we abort all
      QCs, which currently will mark all QCs as ATA_QCFLAG_FAILED. However, it
      will only be a single QC that is an error (i.e. has qc->err_mask set).
      
      Rename ATA_QCFLAG_FAILED to ATA_QCFLAG_EH to more clearly highlight that
      this flag simply means that a QC is now owned by EH. This new name will
      not mislead to think that the QC was an error (which is instead
      indicated by having qc->err_mask set).
      
      This also makes it more obvious that the EH code skips all QCs that do
      not have ATA_QCFLAG_EH set (rather than ATA_QCFLAG_FAILED), since the EH
      code should simply only care about QCs that are owned by EH itself.
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      87629312
    • Wenchao Hao's avatar
      ata: libata-eh: Cleanup ata_scsi_cmd_error_handler() · b83ad9ee
      Wenchao Hao authored
      If ap->ops->error_handler is NULL just return. This patch also
      fixes some comment style issue.
      Signed-off-by: default avatarWenchao Hao <haowenchao@huawei.com>
      Reviewed-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      b83ad9ee
  3. 02 Jan, 2023 1 commit
  4. 01 Jan, 2023 6 commits
  5. 31 Dec, 2022 2 commits
  6. 30 Dec, 2022 19 commits
  7. 29 Dec, 2022 3 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 2258c2dc
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "Changes that were posted too late for 6.1, or after the release.
      
        x86:
      
         - several fixes to nested VMX execution controls
      
         - fixes and clarification to the documentation for Xen emulation
      
         - do not unnecessarily release a pmu event with zero period
      
         - MMU fixes
      
         - fix Coverity warning in kvm_hv_flush_tlb()
      
        selftests:
      
         - fixes for the ucall mechanism in selftests
      
         - other fixes mostly related to compilation with clang"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (41 commits)
        KVM: selftests: restore special vmmcall code layout needed by the harness
        Documentation: kvm: clarify SRCU locking order
        KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET
        KVM: x86/xen: Documentation updates and clarifications
        KVM: x86/xen: Add KVM_XEN_INVALID_GPA and KVM_XEN_INVALID_GFN to uapi
        KVM: x86/xen: Simplify eventfd IOCTLs
        KVM: x86/xen: Fix SRCU/RCU usage in readers of evtchn_ports
        KVM: x86/xen: Use kvm_read_guest_virt() instead of open-coding it badly
        KVM: x86/xen: Fix memory leak in kvm_xen_write_hypercall_page()
        KVM: Delete extra block of "};" in the KVM API documentation
        kvm: x86/mmu: Remove duplicated "be split" in spte.h
        kvm: Remove the unused macro KVM_MMU_READ_{,UN}LOCK()
        MAINTAINERS: adjust entry after renaming the vmx hyperv files
        KVM: selftests: Mark correct page as mapped in virt_map()
        KVM: arm64: selftests: Don't identity map the ucall MMIO hole
        KVM: selftests: document the default implementation of vm_vaddr_populate_bitmap
        KVM: selftests: Use magic value to signal ucall_alloc() failure
        KVM: selftests: Disable "gnu-variable-sized-type-not-at-end" warning
        KVM: selftests: Include lib.mk before consuming $(CC)
        KVM: selftests: Explicitly disable builtins for mem*() overrides
        ...
      2258c2dc
    • Jens Axboe's avatar
      Merge tag 'nvme-6.2-2022-12-29' of git://git.infradead.org/nvme into block-6.2 · 1551ed5a
      Jens Axboe authored
      Pull NVMe fixes from Christoph:
      
      "nvme fixes for Linux 6.2
      
       - fix various problems in handling the Command Supported and Effects log
         (Christoph Hellwig)
       - don't allow unprivileged passthrough of commands that don't transfer
         data but modify logical block content (Christoph Hellwig)
       - add a features and quirks policy document (Christoph Hellwig)
       - fix some really nasty code that was correct but made smatch complain
         (Sagi Grimberg)"
      
      * tag 'nvme-6.2-2022-12-29' of git://git.infradead.org/nvme:
        nvme-auth: fix smatch warning complaints
        nvme: consult the CSE log page for unprivileged passthrough
        nvme: also return I/O command effects from nvme_command_effects
        nvmet: don't defer passthrough commands with trivial effects to the workqueue
        nvmet: set the LBCC bit for commands that modify data
        nvmet: use NVME_CMD_EFFECTS_CSUPP instead of open coding it
        nvme: fix the NVME_CMD_EFFECTS_CSE_MASK definition
        docs, nvme: add a feature and quirk policy document
      1551ed5a
    • Bhaskar Chowdhury's avatar
      kconfig: Add static text for search information in help menu · da8daff9
      Bhaskar Chowdhury authored
      Add few static text to explain how one can bring up the search dialog
      box by pressing the forward slash key anywhere on this interface.
      Signed-off-by: default avatarBhaskar Chowdhury <unixbhaskar@gmail.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      da8daff9