mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-04-29 12:28:27 +02:00
Merge branch 'there-are-some-bugfix-for-hibmcge-ethernet-driver'
Jijie Shao says: ==================== There are some bugfix for hibmcge ethernet driver This patch set is intended to fix several issues for hibmcge driver: 1. Holding the rtnl_lock in pci_error_handlers->reset_prepare() may lead to a deadlock issue. 2. A division by zero issue caused by debugfs when the port is down. 3. A probabilistic false positive issue with np_link_fail. v2: https://lore.kernel.org/20250805181446.3deaceb9@kernel.org v1: https://lore.kernel.org/20250731134749.4090041-1-shaojijie@huawei.com ==================== Link: https://patch.msgid.link/20250806102758.3632674-1-shaojijie@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -53,9 +53,11 @@ static int hbg_reset_prepare(struct hbg_priv *priv, enum hbg_reset_type type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ASSERT_RTNL();
|
||||
if (test_and_set_bit(HBG_NIC_STATE_RESETTING, &priv->state))
|
||||
return -EBUSY;
|
||||
|
||||
if (netif_running(priv->netdev)) {
|
||||
clear_bit(HBG_NIC_STATE_RESETTING, &priv->state);
|
||||
dev_warn(&priv->pdev->dev,
|
||||
"failed to reset because port is up\n");
|
||||
return -EBUSY;
|
||||
@@ -64,7 +66,6 @@ static int hbg_reset_prepare(struct hbg_priv *priv, enum hbg_reset_type type)
|
||||
netif_device_detach(priv->netdev);
|
||||
|
||||
priv->reset_type = type;
|
||||
set_bit(HBG_NIC_STATE_RESETTING, &priv->state);
|
||||
clear_bit(HBG_NIC_STATE_RESET_FAIL, &priv->state);
|
||||
ret = hbg_hw_event_notify(priv, HBG_HW_EVENT_RESET);
|
||||
if (ret) {
|
||||
@@ -84,29 +85,26 @@ static int hbg_reset_done(struct hbg_priv *priv, enum hbg_reset_type type)
|
||||
type != priv->reset_type)
|
||||
return 0;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
clear_bit(HBG_NIC_STATE_RESETTING, &priv->state);
|
||||
ret = hbg_rebuild(priv);
|
||||
if (ret) {
|
||||
priv->stats.reset_fail_cnt++;
|
||||
set_bit(HBG_NIC_STATE_RESET_FAIL, &priv->state);
|
||||
clear_bit(HBG_NIC_STATE_RESETTING, &priv->state);
|
||||
dev_err(&priv->pdev->dev, "failed to rebuild after reset\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
netif_device_attach(priv->netdev);
|
||||
clear_bit(HBG_NIC_STATE_RESETTING, &priv->state);
|
||||
|
||||
dev_info(&priv->pdev->dev, "reset done\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* must be protected by rtnl lock */
|
||||
int hbg_reset(struct hbg_priv *priv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ASSERT_RTNL();
|
||||
ret = hbg_reset_prepare(priv, HBG_RESET_TYPE_FUNCTION);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -171,7 +169,6 @@ static void hbg_pci_err_reset_prepare(struct pci_dev *pdev)
|
||||
struct net_device *netdev = pci_get_drvdata(pdev);
|
||||
struct hbg_priv *priv = netdev_priv(netdev);
|
||||
|
||||
rtnl_lock();
|
||||
hbg_reset_prepare(priv, HBG_RESET_TYPE_FLR);
|
||||
}
|
||||
|
||||
@@ -181,7 +178,6 @@ static void hbg_pci_err_reset_done(struct pci_dev *pdev)
|
||||
struct hbg_priv *priv = netdev_priv(netdev);
|
||||
|
||||
hbg_reset_done(priv, HBG_RESET_TYPE_FLR);
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
static const struct pci_error_handlers hbg_pci_err_handler = {
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#define HBG_HW_EVENT_WAIT_TIMEOUT_US (2 * 1000 * 1000)
|
||||
#define HBG_HW_EVENT_WAIT_INTERVAL_US (10 * 1000)
|
||||
#define HBG_MAC_LINK_WAIT_TIMEOUT_US (500 * 1000)
|
||||
#define HBG_MAC_LINK_WAIT_INTERVAL_US (5 * 1000)
|
||||
/* little endian or big endian.
|
||||
* ctrl means packet description, data means skb packet data
|
||||
*/
|
||||
@@ -228,6 +230,9 @@ void hbg_hw_fill_buffer(struct hbg_priv *priv, u32 buffer_dma_addr)
|
||||
|
||||
void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
|
||||
{
|
||||
u32 link_status;
|
||||
int ret;
|
||||
|
||||
hbg_hw_mac_enable(priv, HBG_STATUS_DISABLE);
|
||||
|
||||
hbg_reg_write_field(priv, HBG_REG_PORT_MODE_ADDR,
|
||||
@@ -239,8 +244,14 @@ void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
|
||||
|
||||
hbg_hw_mac_enable(priv, HBG_STATUS_ENABLE);
|
||||
|
||||
if (!hbg_reg_read_field(priv, HBG_REG_AN_NEG_STATE_ADDR,
|
||||
HBG_REG_AN_NEG_STATE_NP_LINK_OK_B))
|
||||
/* wait MAC link up */
|
||||
ret = readl_poll_timeout(priv->io_base + HBG_REG_AN_NEG_STATE_ADDR,
|
||||
link_status,
|
||||
FIELD_GET(HBG_REG_AN_NEG_STATE_NP_LINK_OK_B,
|
||||
link_status),
|
||||
HBG_MAC_LINK_WAIT_INTERVAL_US,
|
||||
HBG_MAC_LINK_WAIT_TIMEOUT_US);
|
||||
if (ret)
|
||||
hbg_np_link_fail_task_schedule(priv);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,12 @@ static inline bool hbg_fifo_is_full(struct hbg_priv *priv, enum hbg_dir dir)
|
||||
|
||||
static inline u32 hbg_get_queue_used_num(struct hbg_ring *ring)
|
||||
{
|
||||
return (ring->ntu + ring->len - ring->ntc) % ring->len;
|
||||
u32 len = READ_ONCE(ring->len);
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
return (READ_ONCE(ring->ntu) + len - READ_ONCE(ring->ntc)) % len;
|
||||
}
|
||||
|
||||
netdev_tx_t hbg_net_start_xmit(struct sk_buff *skb, struct net_device *netdev);
|
||||
|
||||
Reference in New Issue
Block a user