Skip to content

Commit 19c60fd

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== This series lowers the CPU usage of the ice driver when using its provided /dev/gnss*. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4eaeca1 + b488ae5 commit 19c60fd

5 files changed

Lines changed: 36 additions & 53 deletions

File tree

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,6 @@ ice_sq_send_cmd_retry(struct ice_hw *hw, struct ice_ctl_q_info *cq,
16191619
{
16201620
struct ice_aq_desc desc_cpy;
16211621
bool is_cmd_for_retry;
1622-
u8 *buf_cpy = NULL;
16231622
u8 idx = 0;
16241623
u16 opcode;
16251624
int status;
@@ -1629,11 +1628,8 @@ ice_sq_send_cmd_retry(struct ice_hw *hw, struct ice_ctl_q_info *cq,
16291628
memset(&desc_cpy, 0, sizeof(desc_cpy));
16301629

16311630
if (is_cmd_for_retry) {
1632-
if (buf) {
1633-
buf_cpy = kzalloc(buf_size, GFP_KERNEL);
1634-
if (!buf_cpy)
1635-
return -ENOMEM;
1636-
}
1631+
/* All retryable cmds are direct, without buf. */
1632+
WARN_ON(buf);
16371633

16381634
memcpy(&desc_cpy, desc, sizeof(desc_cpy));
16391635
}
@@ -1645,17 +1641,12 @@ ice_sq_send_cmd_retry(struct ice_hw *hw, struct ice_ctl_q_info *cq,
16451641
hw->adminq.sq_last_status != ICE_AQ_RC_EBUSY)
16461642
break;
16471643

1648-
if (buf_cpy)
1649-
memcpy(buf, buf_cpy, buf_size);
1650-
16511644
memcpy(desc, &desc_cpy, sizeof(desc_cpy));
16521645

1653-
mdelay(ICE_SQ_SEND_DELAY_TIME_MS);
1646+
msleep(ICE_SQ_SEND_DELAY_TIME_MS);
16541647

16551648
} while (++idx < ICE_SQ_SEND_MAX_EXECUTE);
16561649

1657-
kfree(buf_cpy);
1658-
16591650
return status;
16601651
}
16611652

@@ -1992,19 +1983,19 @@ ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
19921983
*/
19931984
void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res)
19941985
{
1995-
u32 total_delay = 0;
1986+
unsigned long timeout;
19961987
int status;
19971988

1998-
status = ice_aq_release_res(hw, res, 0, NULL);
1999-
20001989
/* there are some rare cases when trying to release the resource
20011990
* results in an admin queue timeout, so handle them correctly
20021991
*/
2003-
while ((status == -EIO) && (total_delay < hw->adminq.sq_cmd_timeout)) {
2004-
mdelay(1);
1992+
timeout = jiffies + 10 * ICE_CTL_Q_SQ_CMD_TIMEOUT;
1993+
do {
20051994
status = ice_aq_release_res(hw, res, 0, NULL);
2006-
total_delay++;
2007-
}
1995+
if (status != -EIO)
1996+
break;
1997+
usleep_range(1000, 2000);
1998+
} while (time_before(jiffies, timeout));
20081999
}
20092000

20102001
/**

drivers/net/ethernet/intel/ice/ice_controlq.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,6 @@ static int ice_init_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
637637
return -EIO;
638638
}
639639

640-
/* setup SQ command write back timeout */
641-
cq->sq_cmd_timeout = ICE_CTL_Q_SQ_CMD_TIMEOUT;
642-
643640
/* allocate the ATQ */
644641
ret_code = ice_init_sq(hw, cq);
645642
if (ret_code)
@@ -967,7 +964,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
967964
struct ice_aq_desc *desc_on_ring;
968965
bool cmd_completed = false;
969966
struct ice_sq_cd *details;
970-
u32 total_delay = 0;
967+
unsigned long timeout;
971968
int status = 0;
972969
u16 retval = 0;
973970
u32 val = 0;
@@ -1060,13 +1057,14 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
10601057
cq->sq.next_to_use = 0;
10611058
wr32(hw, cq->sq.tail, cq->sq.next_to_use);
10621059

1060+
timeout = jiffies + ICE_CTL_Q_SQ_CMD_TIMEOUT;
10631061
do {
10641062
if (ice_sq_done(hw, cq))
10651063
break;
10661064

1067-
udelay(ICE_CTL_Q_SQ_CMD_USEC);
1068-
total_delay++;
1069-
} while (total_delay < cq->sq_cmd_timeout);
1065+
usleep_range(ICE_CTL_Q_SQ_CMD_USEC,
1066+
ICE_CTL_Q_SQ_CMD_USEC * 3 / 2);
1067+
} while (time_before(jiffies, timeout));
10701068

10711069
/* if ready, copy the desc back to temp */
10721070
if (ice_sq_done(hw, cq)) {

drivers/net/ethernet/intel/ice/ice_controlq.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum ice_ctl_q {
3434
};
3535

3636
/* Control Queue timeout settings - max delay 1s */
37-
#define ICE_CTL_Q_SQ_CMD_TIMEOUT 10000 /* Count 10000 times */
37+
#define ICE_CTL_Q_SQ_CMD_TIMEOUT HZ /* Wait max 1s */
3838
#define ICE_CTL_Q_SQ_CMD_USEC 100 /* Check every 100usec */
3939
#define ICE_CTL_Q_ADMIN_INIT_TIMEOUT 10 /* Count 10 times */
4040
#define ICE_CTL_Q_ADMIN_INIT_MSEC 100 /* Check every 100msec */
@@ -87,7 +87,6 @@ struct ice_ctl_q_info {
8787
enum ice_ctl_q qtype;
8888
struct ice_ctl_q_ring rq; /* receive queue */
8989
struct ice_ctl_q_ring sq; /* send queue */
90-
u32 sq_cmd_timeout; /* send queue cmd write back timeout */
9190
u16 num_rq_entries; /* receive queue depth */
9291
u16 num_sq_entries; /* send queue depth */
9392
u16 rq_buf_size; /* receive queue buffer size */

drivers/net/ethernet/intel/ice/ice_gnss.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static void ice_gnss_read(struct kthread_work *work)
117117
{
118118
struct gnss_serial *gnss = container_of(work, struct gnss_serial,
119119
read_work.work);
120+
unsigned long delay = ICE_GNSS_POLL_DATA_DELAY_TIME;
120121
unsigned int i, bytes_read, data_len, count;
121122
struct ice_aqc_link_topo_addr link_topo;
122123
struct ice_pf *pf;
@@ -136,11 +137,6 @@ static void ice_gnss_read(struct kthread_work *work)
136137
return;
137138

138139
hw = &pf->hw;
139-
buf = (char *)get_zeroed_page(GFP_KERNEL);
140-
if (!buf) {
141-
err = -ENOMEM;
142-
goto exit;
143-
}
144140

145141
memset(&link_topo, 0, sizeof(struct ice_aqc_link_topo_addr));
146142
link_topo.topo_params.index = ICE_E810T_GNSS_I2C_BUS;
@@ -151,25 +147,24 @@ static void ice_gnss_read(struct kthread_work *work)
151147
i2c_params = ICE_GNSS_UBX_DATA_LEN_WIDTH |
152148
ICE_AQC_I2C_USE_REPEATED_START;
153149

154-
/* Read data length in a loop, when it's not 0 the data is ready */
155-
for (i = 0; i < ICE_MAX_UBX_READ_TRIES; i++) {
156-
err = ice_aq_read_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR,
157-
cpu_to_le16(ICE_GNSS_UBX_DATA_LEN_H),
158-
i2c_params, (u8 *)&data_len_b, NULL);
159-
if (err)
160-
goto exit_buf;
150+
err = ice_aq_read_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR,
151+
cpu_to_le16(ICE_GNSS_UBX_DATA_LEN_H),
152+
i2c_params, (u8 *)&data_len_b, NULL);
153+
if (err)
154+
goto requeue;
161155

162-
data_len = be16_to_cpu(data_len_b);
163-
if (data_len != 0 && data_len != U16_MAX)
164-
break;
156+
data_len = be16_to_cpu(data_len_b);
157+
if (data_len == 0 || data_len == U16_MAX)
158+
goto requeue;
165159

166-
mdelay(10);
167-
}
160+
/* The u-blox has data_len bytes for us to read */
168161

169162
data_len = min_t(typeof(data_len), data_len, PAGE_SIZE);
170-
if (!data_len) {
163+
164+
buf = (char *)get_zeroed_page(GFP_KERNEL);
165+
if (!buf) {
171166
err = -ENOMEM;
172-
goto exit_buf;
167+
goto requeue;
173168
}
174169

175170
/* Read received data */
@@ -183,18 +178,19 @@ static void ice_gnss_read(struct kthread_work *work)
183178
cpu_to_le16(ICE_GNSS_UBX_EMPTY_DATA),
184179
bytes_read, &buf[i], NULL);
185180
if (err)
186-
goto exit_buf;
181+
goto free_buf;
187182
}
188183

189184
count = gnss_insert_raw(pf->gnss_dev, buf, i);
190185
if (count != i)
191186
dev_warn(ice_pf_to_dev(pf),
192187
"gnss_insert_raw ret=%d size=%d\n",
193188
count, i);
194-
exit_buf:
189+
delay = ICE_GNSS_TIMER_DELAY_TIME;
190+
free_buf:
195191
free_page((unsigned long)buf);
196-
kthread_queue_delayed_work(gnss->kworker, &gnss->read_work,
197-
ICE_GNSS_TIMER_DELAY_TIME);
192+
requeue:
193+
kthread_queue_delayed_work(gnss->kworker, &gnss->read_work, delay);
198194
exit:
199195
if (err)
200196
dev_dbg(ice_pf_to_dev(pf), "GNSS failed to read err=%d\n", err);

drivers/net/ethernet/intel/ice/ice_gnss.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define _ICE_GNSS_H_
66

77
#define ICE_E810T_GNSS_I2C_BUS 0x2
8+
#define ICE_GNSS_POLL_DATA_DELAY_TIME (HZ / 50) /* poll every 20 ms */
89
#define ICE_GNSS_TIMER_DELAY_TIME (HZ / 10) /* 0.1 second per message */
910
#define ICE_GNSS_TTY_WRITE_BUF 250
1011
#define ICE_MAX_I2C_DATA_SIZE FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M)
@@ -20,8 +21,6 @@
2021
* passed as I2C addr parameter.
2122
*/
2223
#define ICE_GNSS_UBX_WRITE_BYTES (ICE_MAX_I2C_WRITE_BYTES + 1)
23-
#define ICE_MAX_UBX_READ_TRIES 255
24-
#define ICE_MAX_UBX_ACK_READ_TRIES 4095
2524

2625
struct gnss_write_buf {
2726
struct list_head queue;

0 commit comments

Comments
 (0)