Skip to content

Commit

Permalink
qed: Fix allocation in interrupt context
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Sudarsana Reddy Kalluru authored and davem330 committed May 26, 2016
1 parent 6ecb0a0 commit 7952929
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions drivers/net/ethernet/qlogic/qed/qed_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void qed_resc_free(struct qed_dev *cdev)
}
}

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

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

qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) *
num_vports, GFP_KERNEL);
qm_info->qm_vport_params = kcalloc(num_vports,
sizeof(struct init_qm_vport_params),
b_sleepable ? GFP_KERNEL
: GFP_ATOMIC);
if (!qm_info->qm_vport_params)
goto alloc_err;

qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
MAX_NUM_PORTS, GFP_KERNEL);
qm_info->qm_port_params = kcalloc(MAX_NUM_PORTS,
sizeof(struct init_qm_port_params),
b_sleepable ? GFP_KERNEL
: GFP_ATOMIC);
if (!qm_info->qm_port_params)
goto alloc_err;

qm_info->wfq_data = kcalloc(num_vports, sizeof(*qm_info->wfq_data),
GFP_KERNEL);
qm_info->wfq_data = kcalloc(num_vports, sizeof(struct qed_wfq_data),
b_sleepable ? GFP_KERNEL : GFP_ATOMIC);
if (!qm_info->wfq_data)
goto alloc_err;

Expand Down Expand Up @@ -299,7 +304,7 @@ int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
qed_qm_info_free(p_hwfn);

/* initialize qed's qm data structure */
rc = qed_init_qm_info(p_hwfn);
rc = qed_init_qm_info(p_hwfn, false);
if (rc)
return rc;

Expand Down Expand Up @@ -388,7 +393,7 @@ int qed_resc_alloc(struct qed_dev *cdev)
goto alloc_err;

/* Prepare and process QM requirements */
rc = qed_init_qm_info(p_hwfn);
rc = qed_init_qm_info(p_hwfn, true);
if (rc)
goto alloc_err;

Expand Down

0 comments on commit 7952929

Please sign in to comment.