Skip to content

Commit

Permalink
net/hns3: fix VF reset handler interruption
Browse files Browse the repository at this point in the history
[ upstream commit 94cf4db1603fe9074b5275cc4b63685fc91fdac5 ]

Currently, the VF reset interrupt is enabled before the reset
process is completed. If the VF reset is triggered by an IMP
reset, the initialization of IMP is may not completed, and the
VF reset interrupt may continue to be reported. In this scenario,
the VF reset being performed by the driver does not need to be
interrupted. Therefore, for VF reset, the driver has to enable
the interrupt after the end of reset.

Fixes: a5475d6 ("net/hns3: support VF")

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Jie Hai <haijie1@huawei.com>
  • Loading branch information
Dengdui Huang authored and kevintraynor committed Dec 5, 2023
1 parent 9023608 commit 9bb15a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 12 additions & 0 deletions drivers/net/hns3/hns3_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status,
uint32_t link_speed, uint8_t link_duplex);
void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported);
void hns3_clear_reset_event(struct hns3_hw *hw);
void hns3vf_clear_reset_event(struct hns3_hw *hw);

static inline bool
is_reset_pending(struct hns3_adapter *hns)
Expand All @@ -1048,4 +1049,15 @@ is_reset_pending(struct hns3_adapter *hns)
return ret;
}

static inline void
hns3_clear_reset_status(struct hns3_hw *hw)
{
struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);

if (hns->is_vf)
hns3vf_clear_reset_event(hw);
else
hns3_clear_reset_event(hw);
}

#endif /* _HNS3_ETHDEV_H_ */
19 changes: 17 additions & 2 deletions drivers/net/hns3/hns3_ethdev_vf.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,19 @@ hns3vf_enable_irq0(struct hns3_hw *hw)
hns3_write_dev(hw, HNS3_MISC_VECTOR_REG_BASE, 1);
}

void
hns3vf_clear_reset_event(struct hns3_hw *hw)
{
uint32_t clearval;
uint32_t cmdq_stat_reg;

cmdq_stat_reg = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_STAT_REG);
clearval = cmdq_stat_reg & ~BIT(HNS3_VECTOR0_RST_INT_B);
hns3_write_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG, clearval);

hns3vf_enable_irq0(hw);
}

static enum hns3vf_evt_cause
hns3vf_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval)
{
Expand Down Expand Up @@ -685,8 +698,10 @@ hns3vf_interrupt_handler(void *param)
break;
}

/* Enable interrupt */
hns3vf_enable_irq0(hw);
/* Enable interrupt if it is not caused by reset */
if (event_cause == HNS3VF_VECTOR0_EVENT_MBX ||
event_cause == HNS3VF_VECTOR0_EVENT_OTHER)
hns3vf_enable_irq0(hw);
}

void
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/hns3/hns3_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2730,8 +2730,7 @@ hns3_reset_post(struct hns3_adapter *hns)
/* IMP will wait ready flag before reset */
hns3_notify_reset_ready(hw, false);
hns3_clear_reset_level(hw, &hw->reset.pending);
if (!hns->is_vf)
hns3_clear_reset_event(hw);
hns3_clear_reset_status(hw);
__atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED);
hw->reset.attempts = 0;
hw->reset.stats.success_cnt++;
Expand Down

0 comments on commit 9bb15a3

Please sign in to comment.