1. 29 Jan, 2021 1 commit
  2. 27 Jan, 2021 14 commits
  3. 23 Jan, 2021 25 commits
    • Yang Li's avatar
      scsi: qla2xxx: Remove redundant NULL check · 18c05faf
      Yang Li authored
      Fix below warnings reported by coccicheck:
      ./drivers/scsi/qla2xxx/qla_init.c:3371:2-7: WARNING: NULL check before
      some freeing functions is not needed.
      ./drivers/scsi/qla2xxx/qla_init.c:7855:5-10: WARNING: NULL check before
      some freeing functions is not needed.
      ./drivers/scsi/qla2xxx/qla_init.c:7916:2-7: WARNING: NULL check before
      some freeing functions is not needed.
      ./drivers/scsi/qla2xxx/qla_init.c:8113:4-18: WARNING: NULL check before
      some freeing functions is not needed.
      ./drivers/scsi/qla2xxx/qla_init.c:8174:2-7: WARNING: NULL check before
      some freeing functions is not needed.
      
      Link: https://lore.kernel.org/r/1611306174-92627-1-git-send-email-abaci-bugfix@linux.alibaba.comReported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarYang Li <abaci-bugfix@linux.alibaba.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      18c05faf
    • kernel test robot's avatar
      scsi: megaraid: Fix ifnullfree.cocci warnings · 12e3ef8b
      kernel test robot authored
      NULL check before vfree is not needed.
      
      Generated by: scripts/coccinelle/free/ifnullfree.cocci
      
      Link: https://lore.kernel.org/r/alpine.DEB.2.22.394.2012111113060.2669@hadrienReported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJulia Lawall <julia.lawall@inria.fr>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      12e3ef8b
    • René Rebe's avatar
      scsi: qla1280: Fix printk regression · cd9df0c2
      René Rebe authored
      Since Linus Torvalds reinstated KERN_CONT in commit 4bcc595c ("printk:
      reinstate KERN_CONT for printing continuation lines") in 2015, the qla1280
      SCSI driver printed a rather ugly and screen real estate wasting multi-line
      per device status glibberish during boot. Fix this by adding KERN_CONT as
      needed.
      
      Tested on my Sgi Octane: https://youtu.be/Lfqe1SYR2jk
      
      Link: https://lore.kernel.org/r/20201210.223944.388095546873159172.rene@exactcode.comSigned-off-by: default avatarRené Rebe <rene@exactcode.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      cd9df0c2
    • Bean Huo's avatar
      scsi: ufs: Cleanup WB buffer flush toggle implementation · d3ba622d
      Bean Huo authored
      Delete ufshcd_wb_buf_flush_enable() and ufshcd_wb_buf_flush_disable(). Move
      the implementation into ufshcd_wb_toggle_flush().
      
      Link: https://lore.kernel.org/r/20210121185736.12471-1-huobean@gmail.comReviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Reviewed-by: default avatarCan Guo <cang@codeaurora.org>
      Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      d3ba622d
    • Dan Carpenter's avatar
      scsi: qla2xxx: Remove unnecessary NULL check · c750a9c9
      Dan Carpenter authored
      The list iterator can't be NULL so this check is not required.  Removing
      the check silences a Smatch warning about inconsistent NULL checking.
      
          drivers/scsi/qla2xxx/qla_dfs.c:371 qla_dfs_tgt_counters_show()
          error: we previously assumed 'fcport' could be null (see line 372)
      
      Link: https://lore.kernel.org/r/YAkaaSrhn1mFqyHy@mwandaAcked-by: default avatarSaurav Kashyap <skashyap@marvell.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c750a9c9
    • Jiapeng Zhong's avatar
      scsi: qla2xxx: Assign boolean values to a bool variable · 71311be1
      Jiapeng Zhong authored
      Fix the following coccicheck warnings:
      
      ./drivers/scsi/qla2xxx/qla_isr.c:780:2-18: WARNING: Assignment
      of 0/1 to bool variable.
      
      Link: https://lore.kernel.org/r/1611127919-56551-1-git-send-email-abaci-bugfix@linux.alibaba.comReported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarJiapeng Zhong <abaci-bugfix@linux.alibaba.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      71311be1
    • Eric Curtin's avatar
    • YANG LI's avatar
      scsi: mpt3sas: Simplify bool comparison · bfb3f00c
      YANG LI authored
      Fix the following coccicheck warning:
      
      ./drivers/scsi/mpt3sas/mpt3sas_base.c:2424:5-20: WARNING: Comparison of 0/1
      to bool variable
      
      Link: https://lore.kernel.org/r/1610355253-25960-1-git-send-email-abaci-bugfix@linux.alibaba.comReported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYANG LI <abaci-bugfix@linux.alibaba.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      bfb3f00c
    • Ahmed S. Darwish's avatar
      scsi: libsas: Remove temporarily-added _gfp() API variants · 65f7cfba
      Ahmed S. Darwish authored
      These variants were added for bisectability. Remove them, as all call sites
      have now been convertd to use the original API.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-20-a.darwish@linutronix.de
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      65f7cfba
    • Ahmed S. Darwish's avatar
      scsi: mvsas: Switch back to original libsas event notifiers · 36cdfd0f
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original libas API, while still passing GFP context.
      The libsas _gfp() variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-19-a.darwish@linutronix.deReviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      36cdfd0f
    • Ahmed S. Darwish's avatar
      scsi: isci: Switch back to original libsas event notifiers · c1220866
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original libas API, while still passing GFP context.
      The libsas _gfp() variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-18-a.darwish@linutronix.de
      Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c1220866
    • Ahmed S. Darwish's avatar
      scsi: libsas: Switch back to original event notifiers API · f76d9f1a
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original event notifiers API, while still passing GFP
      context.  The _gfp() notifier variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-17-a.darwish@linutronix.de
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f76d9f1a
    • Ahmed S. Darwish's avatar
      scsi: pm80xx: Switch back to original libsas event notifiers · de6d7547
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original libas API, while still passing GFP context.
      The libsas _gfp() variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-16-a.darwish@linutronix.de
      Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Reviewed-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      de6d7547
    • Ahmed S. Darwish's avatar
      scsi: aic94xx: Switch back to original libsas event notifiers · 093289e4
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original libas API, while still passing GFP context.
      The libsas _gfp() variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-15-a.darwish@linutronix.deReviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      093289e4
    • Ahmed S. Darwish's avatar
      scsi: hisi_sas: Switch back to original libsas event notifiers · 872a90b5
      Ahmed S. Darwish authored
      libsas event notifiers required an extension where gfp_t flags must be
      explicitly passed. For bisectability, a temporary _gfp() variant of such
      functions were added. All call sites then got converted use the _gfp()
      variants and explicitly pass GFP context. Having no callers left, the
      original libsas notifiers were then modified to accept gfp_t flags by
      default.
      
      Switch back to the original libas API, while still passing GFP context.
      The libsas _gfp() variants will be removed afterwards.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-14-a.darwish@linutronix.deReviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      872a90b5
    • Ahmed S. Darwish's avatar
      scsi: libsas: Add gfp_t flags parameter to event notifications · 5d6a75a1
      Ahmed S. Darwish authored
      All call-sites of below libsas APIs:
      
        - sas_alloc_event()
        - sas_notify_port_event()
        - sas_notify_phy_event()
      
      have been converted to use the _gfp()-suffixed version.  Modify the
      original APIs above to take a gfp_t flags parameter by default.
      
      For bisectability, call-sites will be modified again to use the original
      libsas APIs (while passing gfp_t). The temporary _gfp()-suffixed versions
      can then be removed.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-13-a.darwish@linutronix.de
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      5d6a75a1
    • Ahmed S. Darwish's avatar
      scsi: hisi_sas: Pass gfp_t flags to libsas event notifiers · 26c7efc3
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      Below are the context analysis for modified functions:
      
      => hisi_sas_bytes_dmaed():
      
      Since it is invoked from both process and atomic contexts, let its callers
      pass the gfp_t flags:
      
        * hisi_sas_main.c:
        ------------------
      
          hisi_sas_phyup_work(): workqueue context
            -> hisi_sas_bytes_dmaed(..., GFP_KERNEL)
      
          hisi_sas_controller_reset_done(): has an msleep()
            -> hisi_sas_rescan_topology()
              -> hisi_sas_phy_down()
                -> hisi_sas_bytes_dmaed(..., GFP_KERNEL)
      
          hisi_sas_debug_I_T_nexus_reset(): calls wait_for_completion_timeout()
            -> hisi_sas_phy_down()
              -> hisi_sas_bytes_dmaed(..., GFP_KERNEL)
      
        * hisi_sas_v1_hw.c:
        -------------------
      
          int_abnormal_v1_hw(): irq handler
            -> hisi_sas_phy_down()
              -> hisi_sas_bytes_dmaed(..., GFP_ATOMIC)
      
        * hisi_sas_v[23]_hw.c:
        ----------------------
      
          int_phy_updown_v[23]_hw(): irq handler
            -> phy_down_v[23]_hw()
              -> hisi_sas_phy_down()
                -> hisi_sas_bytes_dmaed(..., GFP_ATOMIC)
      
      => int_bcast_v1_hw() and phy_bcast_v3_hw():
      
      Both are invoked exclusively from irq handlers. Pass GFP_ATOMIC.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-12-a.darwish@linutronix.deReviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      26c7efc3
    • Ahmed S. Darwish's avatar
      scsi: aic94xx: Pass gfp_t flags to libsas event notifiers · 111d06ab
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      Context analysis:
      
        aic94xx_hwi.c: asd_dl_tasklet_handler()
          -> asd_ascb::tasklet_complete()
          == escb_tasklet_complete()
            -> aic94xx_scb.c: asd_phy_event_tasklet()
            -> aic94xx_scb.c: asd_bytes_dmaed_tasklet()
            -> aic94xx_scb.c: asd_link_reset_err_tasklet()
            -> aic94xx_scb.c: asd_primitive_rcvd_tasklet()
      
      All functions are invoked by escb_tasklet_complete(), which is invoked by
      the tasklet handler. Pass GFP_ATOMIC.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-11-a.darwish@linutronix.deReviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      111d06ab
    • Ahmed S. Darwish's avatar
      scsi: pm80xx: Pass gfp_t flags to libsas event notifiers · cd4e8176
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      Call chain analysis, pm8001_hwi.c:
      
        pm8001_interrupt_handler_msix() || pm8001_interrupt_handler_intx() || pm8001_tasklet()
          -> PM8001_CHIP_DISP->isr() = pm80xx_chip_isr()
            -> process_oq [spin_lock_irqsave(&pm8001_ha->lock, ...)]
              -> process_one_iomb()
                -> mpi_hw_event()
                  -> hw_event_sas_phy_up()
                    -> pm8001_bytes_dmaed()
                  -> hw_event_sata_phy_up
                    -> pm8001_bytes_dmaed()
      
      All functions are invoked by process_one_iomb(), which is invoked by the
      interrupt service routine and the tasklet handler. A similar call chain is
      also found at pm80xx_hwi.c. Pass GFP_ATOMIC.
      
      For pm8001_sas.c, pm8001_phy_control() runs in task context as it calls
      wait_for_completion() and msleep().  Pass GFP_KERNEL.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-10-a.darwish@linutronix.de
      Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Reviewed-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      cd4e8176
    • Ahmed S. Darwish's avatar
      scsi: libsas: Pass gfp_t flags to event notifiers · 19a39831
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      Context analysis:
      
        - sas_enable_revalidation(): process, acquires mutex
        - sas_resume_ha(): process, calls wait_event_timeout()
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-9-a.darwish@linutronix.de
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      19a39831
    • Ahmed S. Darwish's avatar
      scsi: isci: Pass gfp_t flags in isci_port_bc_change_received() · 71dca553
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      libsas sas_notify_port_event() is called from
      isci_port_bc_change_received(). Below is the context analysis for all of
      its call chains:
      
      host.c: sci_controller_error_handler(): atomic, irq handler     (*)
      OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
        -> sci_controller_process_completions()
          -> sci_controller_event_completion()
            -> phy.c: sci_phy_event_handler()
              -> port.c: sci_port_broadcast_change_received()
                -> isci_port_bc_change_received()
      
      host.c: isci_host_init()                                        (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_initialize(), atomic                        (*)
          -> port_config.c: sci_port_configuration_agent_initialize()
            -> sci_mpc_agent_validate_phy_configuration()
              -> port.c: sci_port_add_phy()
                -> sci_port_set_phy()
                  -> phy.c: sci_phy_set_port()
                    -> port.c: sci_port_broadcast_change_received()
                      -> isci_port_bc_change_received()
      
      port_config.c: apc_agent_timeout(), atomic, timer callback      (*)
        -> sci_apc_agent_configure_ports()
          -> port.c: sci_port_add_phy()
            -> sci_port_set_phy()
              -> phy.c: sci_phy_set_port()
                -> port.c: sci_port_broadcast_change_received()
                  -> isci_port_bc_change_received()
      
      phy.c: enter SCI state: *SCI_PHY_STOPPED*                       # Cont. from [1]
        -> sci_phy_stopped_state_enter()
          -> host.c: sci_controller_link_down()
            -> ->link_down_handler()
            == port_config.c: sci_apc_agent_link_down()
              -> port.c: sci_port_remove_phy()
                -> sci_port_clear_phy()
                  -> phy.c: sci_phy_set_port()
                    -> port.c: sci_port_broadcast_change_received()
                      -> isci_port_bc_change_received()
      
      phy.c: enter SCI state: *SCI_PHY_STARTING*                      # Cont. from [2]
        -> sci_phy_starting_state_enter()
          -> host.c: sci_controller_link_down()
            -> ->link_down_handler()
            == port_config.c: sci_apc_agent_link_down()
              -> port.c: sci_port_remove_phy()
                -> sci_port_clear_phy()
                  -> phy.c: sci_phy_set_port()
                    -> port.c: sci_port_broadcast_change_received()
                      -> isci_port_bc_change_received()
      
      [1] Call chains for entering state: *SCI_PHY_STOPPED*
      -----------------------------------------------------
      
      host.c: isci_host_init()                                        (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_initialize(), atomic                        (*)
            -> phy.c: sci_phy_initialize()
              -> phy.c: sci_phy_link_layer_initialization()
                -> phy.c: sci_change_state(SCI_PHY_STOPPED)
      
      init.c: PCI ->remove() || PM_OPS ->suspend,  process context    (+)
        -> host.c: isci_host_deinit()
          -> sci_controller_stop_phys()
            -> phy.c: sci_phy_stop()
      	-> sci_change_state(SCI_PHY_STOPPED)
      
      phy.c: isci_phy_control()
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_phy_stop(), atomic                                     (*)
          -> sci_change_state(SCI_PHY_STOPPED)
      
      [2] Call chains for entering state: *SCI_PHY_STARTING*
      ------------------------------------------------------
      
      phy.c: phy_sata_timeout(), atimer, timer callback               (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_change_state(SCI_PHY_STARTING)
      
      host.c: phy_startup_timeout(), atomic, timer callback           (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_controller_start_next_phy()
          -> sci_phy_start()
            -> sci_change_state(SCI_PHY_STARTING)
      
      host.c: isci_host_start()                                       (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_start(), atomic                             (*)
          -> sci_controller_start_next_phy()
            -> sci_phy_start()
              -> sci_change_state(SCI_PHY_STARTING)
      
      phy.c: Enter SCI state *SCI_PHY_SUB_FINAL*                      # Cont. from [2A]
        -> sci_change_state(SCI_PHY_SUB_FINAL)
          -> sci_phy_starting_final_substate_enter()
            -> sci_change_state(SCI_PHY_READY)
              -> Enter SCI state: *SCI_PHY_READY*
                -> sci_phy_ready_state_enter()
                  -> host.c: sci_controller_link_up()
                    -> sci_controller_start_next_phy()
                      -> sci_phy_start()
                        -> sci_change_state(SCI_PHY_STARTING)
      
      phy.c: sci_phy_event_handler(), atomic, discussed earlier       (*)
        -> sci_change_state(SCI_PHY_STARTING), 11 instances
      
      port.c: isci_port_perform_hard_reset()
      spin_lock_irqsave(isci_host::scic_lock, )
        -> port.c: sci_port_hard_reset(), atomic                      (*)
          -> phy.c: sci_phy_reset()
            -> sci_change_state(SCI_PHY_RESETTING)
              -> enter SCI PHY state: *SCI_PHY_RESETTING*
                -> sci_phy_resetting_state_enter()
                  -> sci_change_state(SCI_PHY_STARTING)
      
      [2A] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
      ------------------------------------------------------------
      
      host.c: power_control_timeout(), atomic, timer callback         (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> phy.c: sci_phy_consume_power_handler()
          -> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)
      
      host.c: sci_controller_error_handler(): atomic, irq handler     (*)
      OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
        -> sci_controller_process_completions()
          -> sci_controller_unsolicited_frame()
            -> phy.c: sci_phy_frame_handler()
              -> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
                -> sci_phy_starting_await_sas_power_substate_enter()
                  -> host.c: sci_controller_power_control_queue_insert()
                    -> phy.c: sci_phy_consume_power_handler()
                      -> sci_change_state(SCI_PHY_SUB_FINAL)
              -> sci_change_state(SCI_PHY_SUB_FINAL)
          -> sci_controller_event_completion()
            -> phy.c: sci_phy_event_handler()
              -> sci_phy_start_sata_link_training()
                -> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
                  -> sci_phy_starting_await_sata_power_substate_enter
                    -> host.c: sci_controller_power_control_queue_insert()
                      -> phy.c: sci_phy_consume_power_handler()
                        -> sci_change_state(SCI_PHY_SUB_FINAL)
      
      As can be seen from the "(*)" markers above, almost all the call-chains are
      atomic. The only exception, marked with "(+)", is a PCI ->remove() and
      PM_OPS ->suspend() cold path. Thus, pass GFP_ATOMIC to the libsas port
      event notifier.
      
      Note, the now-replaced libsas APIs used in_interrupt() to implicitly decide
      which memory allocation type to use.  This was only partially correct, as
      it fails to choose the correct GFP flags when just preemption or interrupts
      are disabled. Such buggy code paths are marked with "(@)" in the call
      chains above.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-8-a.darwish@linutronix.de
      Fixes: 1c393b97 ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
      Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      71dca553
    • Ahmed S. Darwish's avatar
      scsi: isci: Pass gfp_t flags in isci_port_link_up() · 5ce79029
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      libsas sas_notify_port_event() is called from isci_port_link_up().  Below
      is the context analysis for all of its call chains:
      
      host.c: isci_host_init()                                        (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_initialize(), atomic                        (*)
          -> port_config.c: sci_port_configuration_agent_initialize()
            -> sci_mpc_agent_validate_phy_configuration()
              -> port.c: sci_port_add_phy()
                -> sci_port_general_link_up_handler()
                  -> sci_port_activate_phy()
                    -> isci_port_link_up()
      
      port_config.c: apc_agent_timeout(), atomic, timer callback      (*)
        -> sci_apc_agent_configure_ports()
          -> port.c: sci_port_add_phy()
            -> sci_port_general_link_up_handler()
              -> sci_port_activate_phy()
                -> isci_port_link_up()
      
      phy.c: enter SCI state: *SCI_PHY_SUB_FINAL*                     # Cont. from [1]
        -> phy.c: sci_phy_starting_final_substate_enter()
          -> phy.c: sci_change_state(SCI_PHY_READY)
            -> enter SCI state: *SCI_PHY_READY*
              -> phy.c: sci_phy_ready_state_enter()
                -> host.c: sci_controller_link_up()
                  -> .link_up_handler()
                  == port_config.c: sci_apc_agent_link_up()
                    -> port.c: sci_port_link_up()
                      -> (continue at [A])
                  == port_config.c: sci_mpc_agent_link_up()
      	      -> port.c: sci_port_link_up()
                      -> (continue at [A])
      
      port_config.c: mpc_agent_timeout(), atomic, timer callback      (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> ->link_up_handler()
        == port_config.c: sci_apc_agent_link_up()
          -> port.c: sci_port_link_up()
            -> (continue at [A])
        == port_config.c: sci_mpc_agent_link_up()
          -> port.c: sci_port_link_up()
            -> (continue at [A])
      
      [A] port.c: sci_port_link_up()
        -> sci_port_activate_phy()
          -> isci_port_link_up()
        -> sci_port_general_link_up_handler()
          -> sci_port_activate_phy()
            -> isci_port_link_up()
      
      [1] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
      -----------------------------------------------------------
      
      host.c: power_control_timeout(), atomic, timer callback         (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> phy.c: sci_phy_consume_power_handler()
          -> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)
      
      host.c: sci_controller_error_handler(): atomic, irq handler     (*)
      OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
        -> sci_controller_process_completions()
          -> sci_controller_unsolicited_frame()
            -> phy.c: sci_phy_frame_handler()
              -> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
                -> sci_phy_starting_await_sas_power_substate_enter()
                  -> host.c: sci_controller_power_control_queue_insert()
                    -> phy.c: sci_phy_consume_power_handler()
                      -> sci_change_state(SCI_PHY_SUB_FINAL)
              -> sci_change_state(SCI_PHY_SUB_FINAL)
          -> sci_controller_event_completion()
            -> phy.c: sci_phy_event_handler()
              -> sci_phy_start_sata_link_training()
                -> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
                  -> sci_phy_starting_await_sata_power_substate_enter
                    -> host.c: sci_controller_power_control_queue_insert()
                      -> phy.c: sci_phy_consume_power_handler()
                        -> sci_change_state(SCI_PHY_SUB_FINAL)
      
      As can be seen from the "(*)" markers above, all the call-chains are
      atomic.  Pass GFP_ATOMIC to libsas port event notifier.
      
      Note, the now-replaced libsas APIs used in_interrupt() to implicitly decide
      which memory allocation type to use.  This was only partially correct, as
      it fails to choose the correct GFP flags when just preemption or interrupts
      are disabled. Such buggy code paths are marked with "(@)" in the call
      chains above.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-7-a.darwish@linutronix.de
      Fixes: 1c393b97 ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
      Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      5ce79029
    • Ahmed S. Darwish's avatar
      scsi: isci: Pass gfp_t flags in isci_port_link_down() · 885ab3b8
      Ahmed S. Darwish authored
      Use the new libsas event notifiers API, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      sas_notify_phy_event() is exclusively called by isci_port_link_down().
      Below is the context analysis for all of its call chains:
      
      port.c: port_timeout(), atomic, timer callback                  (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> port_state_machine_change(..., SCI_PORT_FAILED)
          -> enter SCI port state: *SCI_PORT_FAILED*
            -> sci_port_failed_state_enter()
              -> isci_port_hard_reset_complete()
                -> isci_port_link_down()
      
      port.c: isci_port_perform_hard_reset()
      spin_lock_irqsave(isci_host::scic_lock, )
        -> port.c: sci_port_hard_reset(), atomic                      (*)
          -> phy.c: sci_phy_reset()
            -> sci_change_state(SCI_PHY_RESETTING)
              -> enter SCI PHY state: *SCI_PHY_RESETTING*
                -> sci_phy_resetting_state_enter()
                  -> port.c: sci_port_deactivate_phy()
      	      -> isci_port_link_down()
      
      port.c: enter SCI port state: *SCI_PORT_READY*                  # Cont. from [1]
        -> sci_port_ready_state_enter()
          -> isci_port_hard_reset_complete()
            -> isci_port_link_down()
      
      phy.c: enter SCI state: *SCI_PHY_STOPPED*                       # Cont. from [2]
        -> sci_phy_stopped_state_enter()
          -> host.c: sci_controller_link_down()
            -> ->link_down_handler()
            == port_config.c: sci_apc_agent_link_down()
              -> port.c: sci_port_remove_phy()
                -> sci_port_deactivate_phy()
                  -> isci_port_link_down()
            == port_config.c: sci_mpc_agent_link_down()
              -> port.c: sci_port_link_down()
                -> sci_port_deactivate_phy()
                  -> isci_port_link_down()
      
      phy.c: enter SCI state: *SCI_PHY_STARTING*                      # Cont. from [3]
        -> sci_phy_starting_state_enter()
          -> host.c: sci_controller_link_down()
            -> ->link_down_handler()
            == port_config.c: sci_apc_agent_link_down()
              -> port.c: sci_port_remove_phy()
                -> isci_port_link_down()
            == port_config.c: sci_mpc_agent_link_down()
              -> port.c: sci_port_link_down()
                -> sci_port_deactivate_phy()
                  -> isci_port_link_down()
      
      [1] Call chains for 'enter SCI port state: *SCI_PORT_READY*'
      ------------------------------------------------------------
      
      host.c: isci_host_init()                                        (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_initialize(), atomic                        (*)
          -> port_config.c: sci_port_configuration_agent_initialize()
            -> sci_mpc_agent_validate_phy_configuration()
              -> port.c: sci_port_add_phy()
                -> sci_port_general_link_up_handler()
                  -> port_state_machine_change(, SCI_PORT_READY)
                    -> enter port state *SCI_PORT_READY*
      
      host.c: isci_host_start()                                       (@)
      spin_lock_irq(isci_host::scic_lock)
        -> host.c: sci_controller_start(), atomic                     (*)
          -> host.c: sci_port_start()
            -> port.c: port_state_machine_change(, SCI_PORT_READY)
              -> enter port state *SCI_PORT_READY*
      
      port_config.c: apc_agent_timeout(), atomic, timer callback      (*)
        -> sci_apc_agent_configure_ports()
          -> port.c: sci_port_add_phy()
            -> sci_port_general_link_up_handler()
              -> port_state_machine_change(, SCI_PORT_READY)
                -> enter port state *SCI_PORT_READY*
      
      port_config.c: mpc_agent_timeout(), atomic, timer callback      (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> ->link_up_handler()
        == port.c: sci_apc_agent_link_up()
          -> sci_port_general_link_up_handler()
            -> port_state_machine_change(, SCI_PORT_READY)
              -> enter port state *SCI_PORT_READY*
        == port.c: sci_mpc_agent_link_up()
          -> port.c: sci_port_link_up()
            -> sci_port_general_link_up_handler()
              -> port_state_machine_change(, SCI_PORT_READY)
                -> enter port state *SCI_PORT_READY*
      
      phy.c: enter SCI state: SCI_PHY_SUB_FINAL                       # Cont. from [1A]
        -> sci_phy_starting_final_substate_enter()
          -> sci_change_state(SCI_PHY_READY)
            -> enter SCI state: *SCI_PHY_READY*
              -> sci_phy_ready_state_enter()
                -> host.c: sci_controller_link_up()
                  -> port_agent.link_up_handler()
                  == port_config.c: sci_apc_agent_link_up()
                    -> port.c: sci_port_link_up()
                      -> sci_port_general_link_up_handler()
                        -> port_state_machine_change(, SCI_PORT_READY)
                          -> enter port state *SCI_PORT_READY*
                  == port_config.c: sci_mpc_agent_link_up()
                    -> port.c: sci_port_link_up()
                      -> sci_port_general_link_up_handler()
                        -> port_state_machine_change(, SCI_PORT_READY)
                          -> enter port state *SCI_PORT_READY*
      
      [1A] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
      ------------------------------------------------------------
      
      host.c: power_control_timeout(), atomic, timer callback         (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> phy.c: sci_phy_consume_power_handler()
          -> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)
      
      host.c: sci_controller_error_handler(): atomic, irq handler     (*)
      OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
        -> sci_controller_process_completions()
          -> sci_controller_unsolicited_frame()
            -> phy.c: sci_phy_frame_handler()
              -> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
                -> sci_phy_starting_await_sas_power_substate_enter()
                  -> host.c: sci_controller_power_control_queue_insert()
                    -> phy.c: sci_phy_consume_power_handler()
                      -> sci_change_state(SCI_PHY_SUB_FINAL)
              -> sci_change_state(SCI_PHY_SUB_FINAL)
          -> sci_controller_event_completion()
            -> phy.c: sci_phy_event_handler()
              -> sci_phy_start_sata_link_training()
                -> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
                  -> sci_phy_starting_await_sata_power_substate_enter
                    -> host.c: sci_controller_power_control_queue_insert()
                      -> phy.c: sci_phy_consume_power_handler()
                        -> sci_change_state(SCI_PHY_SUB_FINAL)
      
      [2] Call chains for entering state: *SCI_PHY_STOPPED*
      -----------------------------------------------------
      
      host.c: isci_host_init()                                        (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_initialize(), atomic                        (*)
            -> phy.c: sci_phy_initialize()
              -> phy.c: sci_phy_link_layer_initialization()
                -> phy.c: sci_change_state(SCI_PHY_STOPPED)
      
      init.c: PCI ->remove() || PM_OPS ->suspend,  process context    (+)
        -> host.c: isci_host_deinit()
          -> sci_controller_stop_phys()
            -> phy.c: sci_phy_stop()
      	-> sci_change_state(SCI_PHY_STOPPED)
      
      phy.c: isci_phy_control()
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_phy_stop(), atomic                                     (*)
          -> sci_change_state(SCI_PHY_STOPPED)
      
      [3] Call chains for entering state: *SCI_PHY_STARTING*
      ------------------------------------------------------
      
      phy.c: phy_sata_timeout(), atimer, timer callback               (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_change_state(SCI_PHY_STARTING)
      
      host.c: phy_startup_timeout(), atomic, timer callback           (*)
      spin_lock_irqsave(isci_host::scic_lock, )
        -> sci_controller_start_next_phy()
          -> sci_phy_start()
            -> sci_change_state(SCI_PHY_STARTING)
      
      host.c: isci_host_start()                                       (@)
      spin_lock_irq(isci_host::scic_lock)
        -> sci_controller_start(), atomic                             (*)
          -> sci_controller_start_next_phy()
            -> sci_phy_start()
              -> sci_change_state(SCI_PHY_STARTING)
      
      phy.c: Enter SCI state *SCI_PHY_SUB_FINAL*, atomic, check above (*)
        -> sci_change_state(SCI_PHY_SUB_FINAL)
          -> sci_phy_starting_final_substate_enter()
            -> sci_change_state(SCI_PHY_READY)
              -> Enter SCI state: *SCI_PHY_READY*
                -> sci_phy_ready_state_enter()
                  -> host.c: sci_controller_link_up()
                    -> sci_controller_start_next_phy()
                      -> sci_phy_start()
                        -> sci_change_state(SCI_PHY_STARTING)
      
      phy.c: sci_phy_event_handler(), atomic, discussed earlier       (*)
        -> sci_change_state(SCI_PHY_STARTING), 11 instances
      
      phy.c: enter SCI state: *SCI_PHY_RESETTING*, atomic, discussed  (*)
        -> sci_phy_resetting_state_enter()
          -> sci_change_state(SCI_PHY_STARTING)
      
      As can be seen from the "(*)" markers above, almost all the call-chains are
      atomic. The only exception, marked with "(+)", is a PCI ->remove() and
      PM_OPS ->suspend() cold path. Thus, pass GFP_ATOMIC to the libsas phy event
      notifier.
      
      Note, The now-replaced libsas APIs used in_interrupt() to implicitly decide
      which memory allocation type to use.  This was only partially correct, as
      it fails to choose the correct GFP flags when just preemption or interrupts
      are disabled. Such buggy code paths are marked with "(@)" in the call
      chains above.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-6-a.darwish@linutronix.de
      Fixes: 1c393b97 ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
      Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      885ab3b8
    • Ahmed S. Darwish's avatar
      scsi: mvsas: Pass gfp_t flags to libsas event notifiers · feb18e90
      Ahmed S. Darwish authored
      mvsas calls the non _gfp version of the libsas event notifiers API, leading
      to the buggy call chains below:
      
        mvsas/mv_sas.c: mvs_work_queue() [process context]
        spin_lock_irqsave(mvs_info::lock, )
          -> libsas/sas_event.c: sas_notify_phy_event()
            -> sas_alloc_event()
              -> in_interrupt() = false
                -> invalid GFP_KERNEL allocation
          -> libsas/sas_event.c: sas_notify_port_event()
            -> sas_alloc_event()
              -> in_interrupt() = false
                -> invalid GFP_KERNEL allocation
      
      Use the new event notifiers API instead, which requires callers to
      explicitly pass the gfp_t memory allocation flags.
      
      Below are context analysis for the modified functions:
      
      => mvs_bytes_dmaed():
      
      Since it is invoked from both process and atomic contexts, let its callers
      pass the gfp_t flags. Call chains:
      
        scsi_scan.c: do_scsi_scan_host() [has msleep()]
          -> shost->hostt->scan_start()
          -> [mvsas/mv_init.c: Scsi_Host::scsi_host_template .scan_start = mvs_scan_start()]
          -> mvsas/mv_sas.c: mvs_scan_start()
            -> mvs_bytes_dmaed(..., GFP_KERNEL)
      
        mvsas/mv_sas.c: mvs_work_queue()
        spin_lock_irqsave(mvs_info::lock,)
          -> mvs_bytes_dmaed(..., GFP_ATOMIC)
      
        mvsas/mv_64xx.c: mvs_64xx_isr() || mvsas/mv_94xx.c: mvs_94xx_isr()
          -> mvsas/mv_chips.h: mvs_int_full()
            -> mvsas/mv_sas.c: mvs_int_port()
              -> mvs_bytes_dmaed(..., GFP_ATOMIC);
      
      => mvs_work_queue():
      
      Invoked from process context, but it calls all the libsas event notifier
      APIs under a spin_lock_irqsave(). Pass GFP_ATOMIC.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-5-a.darwish@linutronix.de
      Fixes: 1c393b97 ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      feb18e90
    • Ahmed S. Darwish's avatar
      scsi: libsas: Introduce a _gfp() variant of event notifiers · c2d0f1a6
      Ahmed S. Darwish authored
      sas_alloc_event() uses in_interrupt() to decide which allocation should be
      used.
      
      The usage of in_interrupt() in drivers is phased out and Linus clearly
      requested that code which changes behaviour depending on context should
      either be separated or the context be conveyed in an argument passed by the
      caller, which usually knows the context.
      
      The in_interrupt() check is also only partially correct, because it fails
      to choose the correct code path when just preemption or interrupts are
      disabled. For example, as in the following call chain:
      
        mvsas/mv_sas.c: mvs_work_queue() [process context]
        spin_lock_irqsave(mvs_info::lock, )
          -> libsas/sas_event.c: sas_notify_phy_event()
            -> sas_alloc_event()
              -> in_interrupt() = false
                -> invalid GFP_KERNEL allocation
          -> libsas/sas_event.c: sas_notify_port_event()
            -> sas_alloc_event()
              -> in_interrupt() = false
                -> invalid GFP_KERNEL allocation
      
      Introduce sas_alloc_event_gfp(), sas_notify_port_event_gfp(), and
      sas_notify_phy_event_gfp(), which all behave like the non _gfp() variants
      but use a caller-passed GFP mask for allocations.
      
      For bisectability, all callers will be modified first to pass GFP context,
      then the non _gfp() libsas API variants will be modified to take a gfp_t by
      default.
      
      Link: https://lore.kernel.org/r/20210118100955.1761652-4-a.darwish@linutronix.de
      Fixes: 1c393b97 ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
      Cc: Jason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c2d0f1a6