@@ -604,6 +604,27 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba,
604604 readl_poll_timeout_atomic(regs, val, cond, delay_us, timeout_us);\
605605})
606606
607+ static void interrupt_enable_v3_hw (struct hisi_hba * hisi_hba )
608+ {
609+ int i ;
610+
611+ for (i = 0 ; i < hisi_hba -> queue_count ; i ++ )
612+ hisi_sas_write32 (hisi_hba , OQ0_INT_SRC_MSK + 0x4 * i , 0 );
613+
614+ hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK1 , 0xfefefefe );
615+ hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK2 , 0xfefefefe );
616+ hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK3 , 0xffc220ff );
617+ hisi_sas_write32 (hisi_hba , SAS_ECC_INTR_MSK , 0x155555 );
618+
619+ for (i = 0 ; i < hisi_hba -> n_phy ; i ++ ) {
620+ hisi_sas_phy_write32 (hisi_hba , i , CHL_INT1_MSK , 0xf2057fff );
621+ hisi_sas_phy_write32 (hisi_hba , i , CHL_INT2_MSK , 0xffffbfe );
622+ hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_NOT_RDY_MSK , 0x0 );
623+ hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_PHY_ENA_MSK , 0x0 );
624+ hisi_sas_phy_write32 (hisi_hba , i , SL_RX_BCAST_CHK_MSK , 0x0 );
625+ }
626+ }
627+
607628static void init_reg_v3_hw (struct hisi_hba * hisi_hba )
608629{
609630 int i , j ;
@@ -624,20 +645,14 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
624645 hisi_sas_write32 (hisi_hba , ENT_INT_SRC1 , 0xffffffff );
625646 hisi_sas_write32 (hisi_hba , ENT_INT_SRC2 , 0xffffffff );
626647 hisi_sas_write32 (hisi_hba , ENT_INT_SRC3 , 0xffffffff );
627- hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK1 , 0xfefefefe );
628- hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK2 , 0xfefefefe );
629- hisi_sas_write32 (hisi_hba , ENT_INT_SRC_MSK3 , 0xffc220ff );
630648 hisi_sas_write32 (hisi_hba , CHNL_PHYUPDOWN_INT_MSK , 0x0 );
631649 hisi_sas_write32 (hisi_hba , CHNL_ENT_INT_MSK , 0x0 );
632650 hisi_sas_write32 (hisi_hba , HGC_COM_INT_MSK , 0x0 );
633- hisi_sas_write32 (hisi_hba , SAS_ECC_INTR_MSK , 0x155555 );
634651 hisi_sas_write32 (hisi_hba , AWQOS_AWCACHE_CFG , 0xf0f0 );
635652 hisi_sas_write32 (hisi_hba , ARQOS_ARCACHE_CFG , 0xf0f0 );
636- for (i = 0 ; i < hisi_hba -> queue_count ; i ++ )
637- hisi_sas_write32 (hisi_hba , OQ0_INT_SRC_MSK + 0x4 * i , 0 );
638-
639653 hisi_sas_write32 (hisi_hba , HYPER_STREAM_ID_EN_CFG , 1 );
640654
655+ interrupt_enable_v3_hw (hisi_hba );
641656 for (i = 0 ; i < hisi_hba -> n_phy ; i ++ ) {
642657 enum sas_linkrate max ;
643658 struct hisi_sas_phy * phy = & hisi_hba -> phy [i ];
@@ -660,13 +675,8 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
660675 hisi_sas_phy_write32 (hisi_hba , i , CHL_INT1 , 0xffffffff );
661676 hisi_sas_phy_write32 (hisi_hba , i , CHL_INT2 , 0xffffffff );
662677 hisi_sas_phy_write32 (hisi_hba , i , RXOP_CHECK_CFG_H , 0x1000 );
663- hisi_sas_phy_write32 (hisi_hba , i , CHL_INT1_MSK , 0xf2057fff );
664- hisi_sas_phy_write32 (hisi_hba , i , CHL_INT2_MSK , 0xffffbfe );
665678 hisi_sas_phy_write32 (hisi_hba , i , PHY_CTRL_RDY_MSK , 0x0 );
666- hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_NOT_RDY_MSK , 0x0 );
667679 hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_DWS_RESET_MSK , 0x0 );
668- hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_PHY_ENA_MSK , 0x0 );
669- hisi_sas_phy_write32 (hisi_hba , i , SL_RX_BCAST_CHK_MSK , 0x0 );
670680 hisi_sas_phy_write32 (hisi_hba , i , PHYCTRL_OOB_RESTART_MSK , 0x1 );
671681 hisi_sas_phy_write32 (hisi_hba , i , STP_LINK_TIMER , 0x7f7a120 );
672682 hisi_sas_phy_write32 (hisi_hba , i , CON_CFG_DRIVER , 0x2a0a01 );
@@ -888,13 +898,15 @@ static void dereg_device_v3_hw(struct hisi_hba *hisi_hba,
888898
889899 cfg_abt_set_query_iptt = hisi_sas_read32 (hisi_hba ,
890900 CFG_ABT_SET_QUERY_IPTT );
901+ spin_lock (& sas_dev -> lock );
891902 list_for_each_entry_safe (slot , slot2 , & sas_dev -> list , entry ) {
892903 cfg_abt_set_query_iptt &= ~CFG_SET_ABORTED_IPTT_MSK ;
893904 cfg_abt_set_query_iptt |= (1 << CFG_SET_ABORTED_EN_OFF ) |
894905 (slot -> idx << CFG_SET_ABORTED_IPTT_OFF );
895906 hisi_sas_write32 (hisi_hba , CFG_ABT_SET_QUERY_IPTT ,
896907 cfg_abt_set_query_iptt );
897908 }
909+ spin_unlock (& sas_dev -> lock );
898910 cfg_abt_set_query_iptt &= ~(1 << CFG_SET_ABORTED_EN_OFF );
899911 hisi_sas_write32 (hisi_hba , CFG_ABT_SET_QUERY_IPTT ,
900912 cfg_abt_set_query_iptt );
@@ -2325,7 +2337,11 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,
23252337 error_info [0 ], error_info [1 ],
23262338 error_info [2 ], error_info [3 ]);
23272339 if (unlikely (slot -> abort )) {
2328- sas_task_abort (task );
2340+ if (dev_is_sata (device ) && task -> ata_task .use_ncq )
2341+ sas_ata_device_link_abort (device , true);
2342+ else
2343+ sas_task_abort (task );
2344+
23292345 return ;
23302346 }
23312347 goto out ;
@@ -2379,7 +2395,7 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,
23792395 }
23802396 task -> task_state_flags |= SAS_TASK_STATE_DONE ;
23812397 spin_unlock_irqrestore (& task -> task_state_lock , flags );
2382- hisi_sas_slot_task_free (hisi_hba , task , slot );
2398+ hisi_sas_slot_task_free (hisi_hba , task , slot , true );
23832399
23842400 if (!is_internal && (task -> task_proto != SAS_PROTOCOL_SMP )) {
23852401 spin_lock_irqsave (& device -> done_lock , flags );
@@ -2655,7 +2671,6 @@ static int disable_host_v3_hw(struct hisi_hba *hisi_hba)
26552671 u32 status , reg_val ;
26562672 int rc ;
26572673
2658- interrupt_disable_v3_hw (hisi_hba );
26592674 hisi_sas_sync_poll_cqs (hisi_hba );
26602675 hisi_sas_write32 (hisi_hba , DLVRY_QUEUE_ENABLE , 0x0 );
26612676
@@ -2686,6 +2701,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba)
26862701 struct device * dev = hisi_hba -> dev ;
26872702 int rc ;
26882703
2704+ interrupt_disable_v3_hw (hisi_hba );
26892705 rc = disable_host_v3_hw (hisi_hba );
26902706 if (rc ) {
26912707 dev_err (dev , "soft reset: disable host failed rc=%d\n" , rc );
@@ -5054,6 +5070,7 @@ static void hisi_sas_reset_prepare_v3_hw(struct pci_dev *pdev)
50545070 set_bit (HISI_SAS_RESETTING_BIT , & hisi_hba -> flags );
50555071 hisi_sas_controller_reset_prepare (hisi_hba );
50565072
5073+ interrupt_disable_v3_hw (hisi_hba );
50575074 rc = disable_host_v3_hw (hisi_hba );
50585075 if (rc )
50595076 dev_err (dev , "FLR: disable host failed rc=%d\n" , rc );
@@ -5083,6 +5100,21 @@ enum {
50835100 hip08 ,
50845101};
50855102
5103+ static void enable_host_v3_hw (struct hisi_hba * hisi_hba )
5104+ {
5105+ u32 reg_val ;
5106+
5107+ hisi_sas_write32 (hisi_hba , DLVRY_QUEUE_ENABLE ,
5108+ (u32 )((1ULL << hisi_hba -> queue_count ) - 1 ));
5109+
5110+ phys_init_v3_hw (hisi_hba );
5111+ reg_val = hisi_sas_read32 (hisi_hba , AXI_MASTER_CFG_BASE +
5112+ AM_CTRL_GLOBAL );
5113+ reg_val &= ~AM_CTRL_SHUTDOWN_REQ_MSK ;
5114+ hisi_sas_write32 (hisi_hba , AXI_MASTER_CFG_BASE +
5115+ AM_CTRL_GLOBAL , reg_val );
5116+ }
5117+
50865118static int _suspend_v3_hw (struct device * device )
50875119{
50885120 struct pci_dev * pdev = to_pci_dev (device );
@@ -5105,14 +5137,18 @@ static int _suspend_v3_hw(struct device *device)
51055137 scsi_block_requests (shost );
51065138 set_bit (HISI_SAS_REJECT_CMD_BIT , & hisi_hba -> flags );
51075139 flush_workqueue (hisi_hba -> wq );
5140+ interrupt_disable_v3_hw (hisi_hba );
5141+
5142+ if (atomic_read (& device -> power .usage_count )) {
5143+ dev_err (dev , "PM suspend: host status cannot be suspended\n" );
5144+ rc = - EBUSY ;
5145+ goto err_out ;
5146+ }
51085147
51095148 rc = disable_host_v3_hw (hisi_hba );
51105149 if (rc ) {
51115150 dev_err (dev , "PM suspend: disable host failed rc=%d\n" , rc );
5112- clear_bit (HISI_SAS_REJECT_CMD_BIT , & hisi_hba -> flags );
5113- clear_bit (HISI_SAS_RESETTING_BIT , & hisi_hba -> flags );
5114- scsi_unblock_requests (shost );
5115- return rc ;
5151+ goto err_out_recover_host ;
51165152 }
51175153
51185154 hisi_sas_init_mem (hisi_hba );
@@ -5123,6 +5159,15 @@ static int _suspend_v3_hw(struct device *device)
51235159
51245160 dev_warn (dev , "end of suspending controller\n" );
51255161 return 0 ;
5162+
5163+ err_out_recover_host :
5164+ enable_host_v3_hw (hisi_hba );
5165+ err_out :
5166+ interrupt_enable_v3_hw (hisi_hba );
5167+ clear_bit (HISI_SAS_REJECT_CMD_BIT , & hisi_hba -> flags );
5168+ clear_bit (HISI_SAS_RESETTING_BIT , & hisi_hba -> flags );
5169+ scsi_unblock_requests (shost );
5170+ return rc ;
51265171}
51275172
51285173static int _resume_v3_hw (struct device * device )
0 commit comments