Skip to content

Commit 7952929

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed: Fix allocation in interrupt context
Commit 39651ab ("qed: add support for dcbx") is re-configuring the QM hw-block as part of its sequence. This is done in attention handling context which is non-sleepable, yet memory is allocated in this flow using GFP_KERNEL. Signed-off-by: Sudarsana Reddy Kalluru <[email protected]> Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6ecb0a0 commit 7952929

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/net/ethernet/qlogic/qed/qed_dev.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void qed_resc_free(struct qed_dev *cdev)
155155
}
156156
}
157157

158-
static int qed_init_qm_info(struct qed_hwfn *p_hwfn)
158+
static int qed_init_qm_info(struct qed_hwfn *p_hwfn, bool b_sleepable)
159159
{
160160
u8 num_vports, vf_offset = 0, i, vport_id, num_ports, curr_queue = 0;
161161
struct qed_qm_info *qm_info = &p_hwfn->qm_info;
@@ -182,23 +182,28 @@ static int qed_init_qm_info(struct qed_hwfn *p_hwfn)
182182

183183
/* PQs will be arranged as follows: First per-TC PQ then pure-LB quete.
184184
*/
185-
qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) *
186-
num_pqs, GFP_KERNEL);
185+
qm_info->qm_pq_params = kcalloc(num_pqs,
186+
sizeof(struct init_qm_pq_params),
187+
b_sleepable ? GFP_KERNEL : GFP_ATOMIC);
187188
if (!qm_info->qm_pq_params)
188189
goto alloc_err;
189190

190-
qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) *
191-
num_vports, GFP_KERNEL);
191+
qm_info->qm_vport_params = kcalloc(num_vports,
192+
sizeof(struct init_qm_vport_params),
193+
b_sleepable ? GFP_KERNEL
194+
: GFP_ATOMIC);
192195
if (!qm_info->qm_vport_params)
193196
goto alloc_err;
194197

195-
qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
196-
MAX_NUM_PORTS, GFP_KERNEL);
198+
qm_info->qm_port_params = kcalloc(MAX_NUM_PORTS,
199+
sizeof(struct init_qm_port_params),
200+
b_sleepable ? GFP_KERNEL
201+
: GFP_ATOMIC);
197202
if (!qm_info->qm_port_params)
198203
goto alloc_err;
199204

200-
qm_info->wfq_data = kcalloc(num_vports, sizeof(*qm_info->wfq_data),
201-
GFP_KERNEL);
205+
qm_info->wfq_data = kcalloc(num_vports, sizeof(struct qed_wfq_data),
206+
b_sleepable ? GFP_KERNEL : GFP_ATOMIC);
202207
if (!qm_info->wfq_data)
203208
goto alloc_err;
204209

@@ -299,7 +304,7 @@ int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
299304
qed_qm_info_free(p_hwfn);
300305

301306
/* initialize qed's qm data structure */
302-
rc = qed_init_qm_info(p_hwfn);
307+
rc = qed_init_qm_info(p_hwfn, false);
303308
if (rc)
304309
return rc;
305310

@@ -388,7 +393,7 @@ int qed_resc_alloc(struct qed_dev *cdev)
388393
goto alloc_err;
389394

390395
/* Prepare and process QM requirements */
391-
rc = qed_init_qm_info(p_hwfn);
396+
rc = qed_init_qm_info(p_hwfn, true);
392397
if (rc)
393398
goto alloc_err;
394399

0 commit comments

Comments
 (0)