Skip to content

Commit f552b30

Browse files
committed
Merge branch 'there-are-some-bugfix-for-the-hns3-ethernet-driver'
Jijie Shao says: ==================== There are some bugfix for the HNS3 ethernet driver There's a series of bugfix that's been accepted: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=d80a3091308491455b6501b1c4b68698c4a7cd24 However, The series is making the driver poke into IOMMU internals instead of implementing appropriate IOMMU workarounds. After discussion, the series was reverted: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=249cfa318fb1b77eb726c2ff4f74c9685f04e568 But only two patches are related to the IOMMU. Other patches involve only the modification of the driver. This series resends other patches. v2*: https://lore.kernel.org/[email protected] v2: https://lore.kernel.org/[email protected] v1: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 80fb40b + 9741e72 commit f552b30

File tree

8 files changed

+114
-93
lines changed

8 files changed

+114
-93
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,6 @@ struct hnae3_handle {
916916

917917
u8 netdev_flags;
918918
struct dentry *hnae3_dbgfs;
919-
/* protects concurrent contention between debugfs commands */
920-
struct mutex dbgfs_lock;
921-
char **dbgfs_buf;
922919

923920
/* Network interface message level enabled bits */
924921
u32 msg_enable;

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 31 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,69 +1260,55 @@ static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,
12601260
static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12611261
size_t count, loff_t *ppos)
12621262
{
1263-
struct hns3_dbg_data *dbg_data = filp->private_data;
1263+
char *buf = filp->private_data;
1264+
1265+
return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
1266+
}
1267+
1268+
static int hns3_dbg_open(struct inode *inode, struct file *filp)
1269+
{
1270+
struct hns3_dbg_data *dbg_data = inode->i_private;
12641271
struct hnae3_handle *handle = dbg_data->handle;
12651272
struct hns3_nic_priv *priv = handle->priv;
1266-
ssize_t size = 0;
1267-
char **save_buf;
1268-
char *read_buf;
12691273
u32 index;
1274+
char *buf;
12701275
int ret;
12711276

1277+
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
1278+
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
1279+
return -EBUSY;
1280+
12721281
ret = hns3_dbg_get_cmd_index(dbg_data, &index);
12731282
if (ret)
12741283
return ret;
12751284

1276-
mutex_lock(&handle->dbgfs_lock);
1277-
save_buf = &handle->dbgfs_buf[index];
1278-
1279-
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
1280-
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) {
1281-
ret = -EBUSY;
1282-
goto out;
1283-
}
1284-
1285-
if (*save_buf) {
1286-
read_buf = *save_buf;
1287-
} else {
1288-
read_buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL);
1289-
if (!read_buf) {
1290-
ret = -ENOMEM;
1291-
goto out;
1292-
}
1293-
1294-
/* save the buffer addr until the last read operation */
1295-
*save_buf = read_buf;
1296-
1297-
/* get data ready for the first time to read */
1298-
ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
1299-
read_buf, hns3_dbg_cmd[index].buf_len);
1300-
if (ret)
1301-
goto out;
1302-
}
1285+
buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL);
1286+
if (!buf)
1287+
return -ENOMEM;
13031288

1304-
size = simple_read_from_buffer(buffer, count, ppos, read_buf,
1305-
strlen(read_buf));
1306-
if (size > 0) {
1307-
mutex_unlock(&handle->dbgfs_lock);
1308-
return size;
1289+
ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
1290+
buf, hns3_dbg_cmd[index].buf_len);
1291+
if (ret) {
1292+
kvfree(buf);
1293+
return ret;
13091294
}
13101295

1311-
out:
1312-
/* free the buffer for the last read operation */
1313-
if (*save_buf) {
1314-
kvfree(*save_buf);
1315-
*save_buf = NULL;
1316-
}
1296+
filp->private_data = buf;
1297+
return 0;
1298+
}
13171299

1318-
mutex_unlock(&handle->dbgfs_lock);
1319-
return ret;
1300+
static int hns3_dbg_release(struct inode *inode, struct file *filp)
1301+
{
1302+
kvfree(filp->private_data);
1303+
filp->private_data = NULL;
1304+
return 0;
13201305
}
13211306

13221307
static const struct file_operations hns3_dbg_fops = {
13231308
.owner = THIS_MODULE,
1324-
.open = simple_open,
1309+
.open = hns3_dbg_open,
13251310
.read = hns3_dbg_read,
1311+
.release = hns3_dbg_release,
13261312
};
13271313

13281314
static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd)
@@ -1379,13 +1365,6 @@ int hns3_dbg_init(struct hnae3_handle *handle)
13791365
int ret;
13801366
u32 i;
13811367

1382-
handle->dbgfs_buf = devm_kcalloc(&handle->pdev->dev,
1383-
ARRAY_SIZE(hns3_dbg_cmd),
1384-
sizeof(*handle->dbgfs_buf),
1385-
GFP_KERNEL);
1386-
if (!handle->dbgfs_buf)
1387-
return -ENOMEM;
1388-
13891368
hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry =
13901369
debugfs_create_dir(name, hns3_dbgfs_root);
13911370
handle->hnae3_dbgfs = hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry;
@@ -1395,8 +1374,6 @@ int hns3_dbg_init(struct hnae3_handle *handle)
13951374
debugfs_create_dir(hns3_dbg_dentry[i].name,
13961375
handle->hnae3_dbgfs);
13971376

1398-
mutex_init(&handle->dbgfs_lock);
1399-
14001377
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) {
14011378
if ((hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_TM_NODES &&
14021379
ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2) ||
@@ -1425,24 +1402,13 @@ int hns3_dbg_init(struct hnae3_handle *handle)
14251402
out:
14261403
debugfs_remove_recursive(handle->hnae3_dbgfs);
14271404
handle->hnae3_dbgfs = NULL;
1428-
mutex_destroy(&handle->dbgfs_lock);
14291405
return ret;
14301406
}
14311407

14321408
void hns3_dbg_uninit(struct hnae3_handle *handle)
14331409
{
1434-
u32 i;
1435-
14361410
debugfs_remove_recursive(handle->hnae3_dbgfs);
14371411
handle->hnae3_dbgfs = NULL;
1438-
1439-
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
1440-
if (handle->dbgfs_buf[i]) {
1441-
kvfree(handle->dbgfs_buf[i]);
1442-
handle->dbgfs_buf[i] = NULL;
1443-
}
1444-
1445-
mutex_destroy(&handle->dbgfs_lock);
14461412
}
14471413

14481414
void hns3_dbg_register_debugfs(const char *debugfs_dir_name)

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,6 @@ static int hns3_nic_set_features(struct net_device *netdev,
24522452
return ret;
24532453
}
24542454

2455-
netdev->features = features;
24562455
return 0;
24572456
}
24582457

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/etherdevice.h>
77
#include <linux/init.h>
88
#include <linux/interrupt.h>
9+
#include <linux/irq.h>
910
#include <linux/kernel.h>
1011
#include <linux/module.h>
1112
#include <linux/netdevice.h>
@@ -3574,6 +3575,17 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf,
35743575
return ret;
35753576
}
35763577

3578+
static void hclge_set_reset_pending(struct hclge_dev *hdev,
3579+
enum hnae3_reset_type reset_type)
3580+
{
3581+
/* When an incorrect reset type is executed, the get_reset_level
3582+
* function generates the HNAE3_NONE_RESET flag. As a result, this
3583+
* type do not need to pending.
3584+
*/
3585+
if (reset_type != HNAE3_NONE_RESET)
3586+
set_bit(reset_type, &hdev->reset_pending);
3587+
}
3588+
35773589
static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
35783590
{
35793591
u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg;
@@ -3594,7 +3606,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
35943606
*/
35953607
if (BIT(HCLGE_VECTOR0_IMPRESET_INT_B) & msix_src_reg) {
35963608
dev_info(&hdev->pdev->dev, "IMP reset interrupt\n");
3597-
set_bit(HNAE3_IMP_RESET, &hdev->reset_pending);
3609+
hclge_set_reset_pending(hdev, HNAE3_IMP_RESET);
35983610
set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
35993611
*clearval = BIT(HCLGE_VECTOR0_IMPRESET_INT_B);
36003612
hdev->rst_stats.imp_rst_cnt++;
@@ -3604,7 +3616,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
36043616
if (BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) & msix_src_reg) {
36053617
dev_info(&hdev->pdev->dev, "global reset interrupt\n");
36063618
set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
3607-
set_bit(HNAE3_GLOBAL_RESET, &hdev->reset_pending);
3619+
hclge_set_reset_pending(hdev, HNAE3_GLOBAL_RESET);
36083620
*clearval = BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B);
36093621
hdev->rst_stats.global_rst_cnt++;
36103622
return HCLGE_VECTOR0_EVENT_RST;
@@ -3759,7 +3771,7 @@ static int hclge_misc_irq_init(struct hclge_dev *hdev)
37593771
snprintf(hdev->misc_vector.name, HNAE3_INT_NAME_LEN, "%s-misc-%s",
37603772
HCLGE_NAME, pci_name(hdev->pdev));
37613773
ret = request_irq(hdev->misc_vector.vector_irq, hclge_misc_irq_handle,
3762-
0, hdev->misc_vector.name, hdev);
3774+
IRQF_NO_AUTOEN, hdev->misc_vector.name, hdev);
37633775
if (ret) {
37643776
hclge_free_vector(hdev, 0);
37653777
dev_err(&hdev->pdev->dev, "request misc irq(%d) fail\n",
@@ -4052,7 +4064,7 @@ static void hclge_do_reset(struct hclge_dev *hdev)
40524064
case HNAE3_FUNC_RESET:
40534065
dev_info(&pdev->dev, "PF reset requested\n");
40544066
/* schedule again to check later */
4055-
set_bit(HNAE3_FUNC_RESET, &hdev->reset_pending);
4067+
hclge_set_reset_pending(hdev, HNAE3_FUNC_RESET);
40564068
hclge_reset_task_schedule(hdev);
40574069
break;
40584070
default:
@@ -4086,6 +4098,8 @@ static enum hnae3_reset_type hclge_get_reset_level(struct hnae3_ae_dev *ae_dev,
40864098
clear_bit(HNAE3_FLR_RESET, addr);
40874099
}
40884100

4101+
clear_bit(HNAE3_NONE_RESET, addr);
4102+
40894103
if (hdev->reset_type != HNAE3_NONE_RESET &&
40904104
rst_level < hdev->reset_type)
40914105
return HNAE3_NONE_RESET;
@@ -4227,7 +4241,7 @@ static bool hclge_reset_err_handle(struct hclge_dev *hdev)
42274241
return false;
42284242
} else if (hdev->rst_stats.reset_fail_cnt < MAX_RESET_FAIL_CNT) {
42294243
hdev->rst_stats.reset_fail_cnt++;
4230-
set_bit(hdev->reset_type, &hdev->reset_pending);
4244+
hclge_set_reset_pending(hdev, hdev->reset_type);
42314245
dev_info(&hdev->pdev->dev,
42324246
"re-schedule reset task(%u)\n",
42334247
hdev->rst_stats.reset_fail_cnt);
@@ -4470,8 +4484,20 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle)
44704484
static void hclge_set_def_reset_request(struct hnae3_ae_dev *ae_dev,
44714485
enum hnae3_reset_type rst_type)
44724486
{
4487+
#define HCLGE_SUPPORT_RESET_TYPE \
4488+
(BIT(HNAE3_FLR_RESET) | BIT(HNAE3_FUNC_RESET) | \
4489+
BIT(HNAE3_GLOBAL_RESET) | BIT(HNAE3_IMP_RESET))
4490+
44734491
struct hclge_dev *hdev = ae_dev->priv;
44744492

4493+
if (!(BIT(rst_type) & HCLGE_SUPPORT_RESET_TYPE)) {
4494+
/* To prevent reset triggered by hclge_reset_event */
4495+
set_bit(HNAE3_NONE_RESET, &hdev->default_reset_request);
4496+
dev_warn(&hdev->pdev->dev, "unsupported reset type %d\n",
4497+
rst_type);
4498+
return;
4499+
}
4500+
44754501
set_bit(rst_type, &hdev->default_reset_request);
44764502
}
44774503

@@ -11881,9 +11907,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1188111907

1188211908
hclge_init_rxd_adv_layout(hdev);
1188311909

11884-
/* Enable MISC vector(vector0) */
11885-
hclge_enable_vector(&hdev->misc_vector, true);
11886-
1188711910
ret = hclge_init_wol(hdev);
1188811911
if (ret)
1188911912
dev_warn(&pdev->dev,
@@ -11896,6 +11919,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1189611919
hclge_state_init(hdev);
1189711920
hdev->last_reset_time = jiffies;
1189811921

11922+
/* Enable MISC vector(vector0) */
11923+
enable_irq(hdev->misc_vector.vector_irq);
11924+
hclge_enable_vector(&hdev->misc_vector, true);
11925+
1189911926
dev_info(&hdev->pdev->dev, "%s driver initialization finished.\n",
1190011927
HCLGE_DRIVER_NAME);
1190111928

@@ -12301,7 +12328,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
1230112328

1230212329
/* Disable MISC vector(vector0) */
1230312330
hclge_enable_vector(&hdev->misc_vector, false);
12304-
synchronize_irq(hdev->misc_vector.vector_irq);
12331+
disable_irq(hdev->misc_vector.vector_irq);
1230512332

1230612333
/* Disable all hw interrupts */
1230712334
hclge_config_mac_tnl_int(hdev, false);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ bool hclge_ptp_set_tx_info(struct hnae3_handle *handle, struct sk_buff *skb)
5858
struct hclge_dev *hdev = vport->back;
5959
struct hclge_ptp *ptp = hdev->ptp;
6060

61+
if (!ptp)
62+
return false;
63+
6164
if (!test_bit(HCLGE_PTP_FLAG_TX_EN, &ptp->flags) ||
6265
test_and_set_bit(HCLGE_STATE_PTP_TX_HANDLING, &hdev->state)) {
6366
ptp->tx_skipped++;

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_regs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ static int hclge_get_dfx_reg(struct hclge_dev *hdev, void *data)
510510
static int hclge_fetch_pf_reg(struct hclge_dev *hdev, void *data,
511511
struct hnae3_knic_private_info *kinfo)
512512
{
513-
#define HCLGE_RING_REG_OFFSET 0x200
514513
#define HCLGE_RING_INT_REG_OFFSET 0x4
515514

515+
struct hnae3_queue *tqp;
516516
int i, j, reg_num;
517517
int data_num_sum;
518518
u32 *reg = data;
@@ -533,10 +533,11 @@ static int hclge_fetch_pf_reg(struct hclge_dev *hdev, void *data,
533533
reg_num = ARRAY_SIZE(ring_reg_addr_list);
534534
for (j = 0; j < kinfo->num_tqps; j++) {
535535
reg += hclge_reg_get_tlv(HCLGE_REG_TAG_RING, reg_num, reg);
536+
tqp = kinfo->tqp[j];
536537
for (i = 0; i < reg_num; i++)
537-
*reg++ = hclge_read_dev(&hdev->hw,
538-
ring_reg_addr_list[i] +
539-
HCLGE_RING_REG_OFFSET * j);
538+
*reg++ = readl_relaxed(tqp->io_base -
539+
HCLGE_TQP_REG_OFFSET +
540+
ring_reg_addr_list[i]);
540541
}
541542
data_num_sum += (reg_num + HCLGE_REG_TLV_SPACE) * kinfo->num_tqps;
542543

0 commit comments

Comments
 (0)