From ebc0aec43c5faabfb0a39636df627d798287417f Mon Sep 17 00:00:00 2001 From: qiutao Date: Wed, 6 Aug 2025 10:41:09 +0800 Subject: [PATCH] ROH: fix variable type inconsistency issue driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICRCW9 ----------------------------------------------------------------------- The following are the specific contents of the modification: 1. ROH/core/sysfs.c: transform the type of i 2. ROH/hw/hns3/hns3_cmdq.c: changing the types of variables and functions 3. ROH/hw/hns3/hns3_cmdq.h: transform the type of num 4. ROH/hw/hns3/hns3_common.h: transform the types of next_to_use and next_to_clean 5. ROH/hw/hns3/hns3_main.c: transform the types of uncopy_bytes and uncopied_bytes 6. ROH/hw/hns3/hns3_verbs.c: changing the type of variables Fixes: aa4a5ce04fa5 ("roh/core: Add roh device sysfs node") Signed-off-by: qiutao --- drivers/roh/core/sysfs.c | 2 +- drivers/roh/hw/hns3/hns3_cmdq.c | 40 +++++++++++++++---------------- drivers/roh/hw/hns3/hns3_cmdq.h | 2 +- drivers/roh/hw/hns3/hns3_common.h | 4 ++-- drivers/roh/hw/hns3/hns3_main.c | 4 ++-- drivers/roh/hw/hns3/hns3_verbs.c | 12 ++++------ 6 files changed, 31 insertions(+), 33 deletions(-) diff --git a/drivers/roh/core/sysfs.c b/drivers/roh/core/sysfs.c index 8776889d4fb3..edb9f7ef3f6f 100644 --- a/drivers/roh/core/sysfs.c +++ b/drivers/roh/core/sysfs.c @@ -66,7 +66,7 @@ static ssize_t print_hw_stat(struct roh_device *dev, struct roh_mib_stats *stats, char *buf) { int offset = 0; - int i; + u32 i; for (i = 0; i < stats->num_counters; i++) offset += sprintf(buf + offset, "%s: %llu\n", diff --git a/drivers/roh/hw/hns3/hns3_cmdq.c b/drivers/roh/hw/hns3/hns3_cmdq.c index 112add3905a8..fcbe80a1f73f 100644 --- a/drivers/roh/hw/hns3/hns3_cmdq.c +++ b/drivers/roh/hw/hns3/hns3_cmdq.c @@ -161,13 +161,13 @@ void hns3_roh_cmdq_exit(struct hns3_roh_device *hroh_dev) hns3_roh_free_cmdq_desc(hroh_dev, &priv->cmdq.crq); } -static int hns3_roh_cmdq_space(struct hns3_roh_cmdq_ring *ring) +static u32 hns3_roh_cmdq_space(struct hns3_roh_cmdq_ring *ring) { - int ntu = ring->next_to_use; - int ntc = ring->next_to_clean; - int used = (ntu - ntc + ring->desc_num) % ring->desc_num; + u32 ntu = ring->next_to_use; + u32 ntc = ring->next_to_clean; + u32 used = (ntu - ntc + ring->desc_num) % ring->desc_num; - return ring->desc_num - used - 1; + return ring->desc_num - used - 1U; } void hns3_roh_cmdq_setup_basic_desc(struct hns3_roh_desc *desc, @@ -181,7 +181,7 @@ void hns3_roh_cmdq_setup_basic_desc(struct hns3_roh_desc *desc, desc->flag |= cpu_to_le16(HNS3_ROH_CMD_FLAG_WR); } -static int hns3_roh_cmdq_csq_done(struct hns3_roh_device *hroh_dev) +static bool hns3_roh_cmdq_csq_done(struct hns3_roh_device *hroh_dev) { struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv; u32 head = hns3_roh_read(hroh_dev, HNS3_ROH_TX_CMDQ_HEAD_REG); @@ -189,13 +189,13 @@ static int hns3_roh_cmdq_csq_done(struct hns3_roh_device *hroh_dev) return head == priv->cmdq.csq.next_to_use; } -static int hns3_roh_cmdq_csq_clean(struct hns3_roh_device *hroh_dev) +static u32 hns3_roh_cmdq_csq_clean(struct hns3_roh_device *hroh_dev) { struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv; struct hns3_roh_cmdq_ring *csq = &priv->cmdq.csq; - u16 ntc = csq->next_to_clean; + u32 ntc = csq->next_to_clean; struct hns3_roh_desc *desc; - int clean = 0; + u32 clean = 0; u32 head; desc = &csq->desc[ntc]; @@ -215,12 +215,12 @@ static int hns3_roh_cmdq_csq_clean(struct hns3_roh_device *hroh_dev) static int hns3_roh_cmdq_build(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *desc, - int num, int *ntc) + u32 num, u32 *ntc) { struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv; struct hns3_roh_cmdq_ring *csq = &priv->cmdq.csq; struct hns3_roh_desc *desc_to_use = NULL; - int handle = 0; + u32 handle = 0; if (num > hns3_roh_cmdq_space(csq)) { /* If CMDQ ring is full, SW HEAD and HW HEAD may be different, @@ -305,13 +305,13 @@ static int hns3_roh_cmd_convert_err_code(u16 desc_ret) } static int hns3_roh_cmd_check_retval(struct hns3_roh_device *hroh_dev, - struct hns3_roh_desc *desc, int num, - int next_to_clean) + struct hns3_roh_desc *desc, u32 num, + u32 next_to_clean) { struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv; - int ntc = next_to_clean; + u32 ntc = next_to_clean; u16 opcode, desc_ret; - int handle; + u32 handle; opcode = le16_to_cpu(desc[0].opcode); for (handle = 0; handle < num; handle++) { @@ -330,13 +330,13 @@ static int hns3_roh_cmd_check_retval(struct hns3_roh_device *hroh_dev, return hns3_roh_cmd_convert_err_code(desc_ret); } -int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *desc, int num) +int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *desc, u32 num) { struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv; struct hns3_roh_cmdq_ring *csq = &priv->cmdq.csq; bool is_completed = false; - int handle = 0; - int ntc = 0; + u32 handle = 0; + u32 ntc = 0; int ret = 0; if (test_bit(HNS3_ROH_STATE_CMD_DISABLE, &priv->handle->rohinfo.reset_state)) @@ -362,7 +362,7 @@ int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *d handle = hns3_roh_cmdq_csq_clean(hroh_dev); if (handle != num) - dev_warn(hroh_dev->dev, "cleaned %d, need to clean %d\n", handle, num); + dev_warn(hroh_dev->dev, "cleaned %u, need to clean %u\n", handle, num); spin_unlock_bh(&csq->lock); return ret; @@ -376,7 +376,7 @@ int hns3_roh_get_link_status(struct hns3_roh_device *hroh_dev, u32 *link_status) int ret; hns3_roh_cmdq_setup_basic_desc(&desc, HNS3_ROH_OPC_QUERY_PORT_LINK_STATUS, true); - ret = hns3_roh_cmdq_send(hroh_dev, &desc, 1); + ret = hns3_roh_cmdq_send(hroh_dev, &desc, 1U); if (ret) { dev_err(hroh_dev->dev, "failed to query link status, ret = %d\n", ret); return ret; diff --git a/drivers/roh/hw/hns3/hns3_cmdq.h b/drivers/roh/hw/hns3/hns3_cmdq.h index 4c9f31a71cb5..ee6acf14d3d5 100644 --- a/drivers/roh/hw/hns3/hns3_cmdq.h +++ b/drivers/roh/hw/hns3/hns3_cmdq.h @@ -109,7 +109,7 @@ static inline void hns3_roh_mbx_ring_ptr_move_crq(struct hns3_roh_cmdq_ring *crq int hns3_roh_cmdq_init(struct hns3_roh_device *hroh_dev); void hns3_roh_cmdq_exit(struct hns3_roh_device *hroh_dev); int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, - struct hns3_roh_desc *desc, int num); + struct hns3_roh_desc *desc, u32 num); void hns3_roh_cmdq_setup_basic_desc(struct hns3_roh_desc *desc, enum hns3_roh_opcode_type opcode, bool is_read); int hns3_roh_get_link_status(struct hns3_roh_device *hroh_dev, u32 *link_status); diff --git a/drivers/roh/hw/hns3/hns3_common.h b/drivers/roh/hw/hns3/hns3_common.h index 0b463cee0750..28de28002583 100644 --- a/drivers/roh/hw/hns3/hns3_common.h +++ b/drivers/roh/hw/hns3/hns3_common.h @@ -40,8 +40,8 @@ struct hns3_roh_cmdq_ring { u16 buf_size; u16 desc_num; - int next_to_use; - int next_to_clean; + u32 next_to_use; + u32 next_to_clean; u8 flag; spinlock_t lock; /* CMDq lock */ }; diff --git a/drivers/roh/hw/hns3/hns3_main.c b/drivers/roh/hw/hns3/hns3_main.c index 843f82d54ea5..def17c8134e8 100644 --- a/drivers/roh/hw/hns3/hns3_main.c +++ b/drivers/roh/hw/hns3/hns3_main.c @@ -389,7 +389,7 @@ static ssize_t hns3_roh_dfx_cmd_read(struct file *filp, char __user *buffer, size_t count, loff_t *pos) { #define HNS3_ROH_DFX_READ_LEN 256 - int uncopy_bytes; + unsigned long uncopy_bytes; char *buf; int len; @@ -454,7 +454,7 @@ static ssize_t hns3_roh_dfx_cmd_write(struct file *filp, const char __user *buff #define HNS3_ROH_DFX_WRITE_LEN 1024 struct hns3_roh_device *hroh_dev = filp->private_data; char *cmd_buf, *cmd_buf_tmp; - int uncopied_bytes; + unsigned long uncopied_bytes; int ret; if (*pos != 0) diff --git a/drivers/roh/hw/hns3/hns3_verbs.c b/drivers/roh/hw/hns3/hns3_verbs.c index b4d23d66c4db..3e9e4b5f6639 100644 --- a/drivers/roh/hw/hns3/hns3_verbs.c +++ b/drivers/roh/hw/hns3/hns3_verbs.c @@ -19,7 +19,7 @@ int hns3_roh_set_eid(struct roh_device *rohdev, struct roh_eid_attr *eid_attr) req->base_eid = cpu_to_le32(eid_attr->base); req->num_eid = cpu_to_le32(eid_attr->num); - ret = hns3_roh_cmdq_send(hroh_dev, &desc, 1); + ret = hns3_roh_cmdq_send(hroh_dev, &desc, 1U); if (ret) { dev_err(hroh_dev->dev, "failed to set eid, ret = %d\n", ret); return ret; @@ -160,7 +160,7 @@ static const char * const hns3_roh_hw_stats_name_private[] = { struct roh_mib_stats *hns3_roh_alloc_hw_stats(struct roh_device *rohdev, enum roh_mib_type mib_type) { struct roh_mib_stats *stats = NULL; - int num_counters; + u32 num_counters; switch (mib_type) { case ROH_MIB_PUBLIC: @@ -190,13 +190,11 @@ int hns3_roh_get_hw_stats(struct roh_device *rohdev, struct roh_mib_stats *stats enum roh_mib_type mib_type) { struct hns3_roh_device *hroh_dev = to_hroh_dev(rohdev); + u32 i, j, start, stats_num, desc_num; u64 *data = (u64 *)(stats->value); enum hns3_roh_opcode_type opcode; struct hns3_roh_desc *desc; - int start, stats_num; __le64 *desc_data; - u32 desc_num; - int i, j; int ret; if (mib_type != ROH_MIB_PUBLIC && mib_type != ROH_MIB_PRIVATE) { @@ -205,10 +203,10 @@ int hns3_roh_get_hw_stats(struct roh_device *rohdev, struct roh_mib_stats *stats } if (mib_type == ROH_MIB_PUBLIC) - desc_num = 1 + DIV_ROUND_UP(stats->num_counters - HNS3_ROH_RD_FIRST_STATS_NUM, + desc_num = 1U + DIV_ROUND_UP(stats->num_counters - HNS3_ROH_RD_FIRST_STATS_NUM, HNS3_ROH_RD_OTHER_STATS_NUM); else - desc_num = 1 + DIV_ROUND_UP(stats->num_counters, HNS3_ROH_RD_OTHER_STATS_NUM); + desc_num = 1U + DIV_ROUND_UP(stats->num_counters, HNS3_ROH_RD_OTHER_STATS_NUM); desc = kcalloc(desc_num, sizeof(struct hns3_roh_desc), GFP_KERNEL); if (!desc) { ret = -ENOMEM; -- Gitee