Commit 05018936 authored by Piotr Raczynski's avatar Piotr Raczynski Committed by Tony Nguyen

ice: use preferred MSIX allocation api

Move away from using pci_enable_msix_range/pci_disable_msix and use
pci_alloc_irq_vectors/pci_free_irq_vectors instead.

As a result stop tracking msix_entries since with newer API entries are
handled by MSIX core. However, due to current design of communication
with RDMA driver which accesses ice_pf::msix_entries directly, keep
using the array just for RDMA driver use.
Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarPiotr Raczynski <piotr.raczynski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent afe87cfe
...@@ -235,14 +235,33 @@ EXPORT_SYMBOL_GPL(ice_get_qos_params); ...@@ -235,14 +235,33 @@ EXPORT_SYMBOL_GPL(ice_get_qos_params);
static int ice_reserve_rdma_qvector(struct ice_pf *pf) static int ice_reserve_rdma_qvector(struct ice_pf *pf)
{ {
if (ice_is_rdma_ena(pf)) { if (ice_is_rdma_ena(pf)) {
int index; int index, i;
index = ice_get_res(pf, pf->irq_tracker, pf->num_rdma_msix, index = ice_get_res(pf, pf->irq_tracker, pf->num_rdma_msix,
ICE_RES_RDMA_VEC_ID); ICE_RES_RDMA_VEC_ID);
if (index < 0) if (index < 0)
return index; return index;
pf->msix_entries = kcalloc(pf->num_rdma_msix,
sizeof(*pf->msix_entries),
GFP_KERNEL);
if (!pf->msix_entries) {
ice_free_res(pf->irq_tracker, pf->rdma_base_vector,
ICE_RES_RDMA_VEC_ID);
return -ENOMEM;
}
pf->num_avail_sw_msix -= pf->num_rdma_msix; pf->num_avail_sw_msix -= pf->num_rdma_msix;
pf->rdma_base_vector = (u16)index;
/* RDMA is the only user of pf->msix_entries array */
pf->rdma_base_vector = 0;
for (i = 0; i < pf->num_rdma_msix; i++, index++) {
struct msix_entry *entry = &pf->msix_entries[i];
entry->entry = index;
entry->vector = pci_irq_vector(pf->pdev, index);
}
} }
return 0; return 0;
} }
...@@ -253,6 +272,12 @@ static int ice_reserve_rdma_qvector(struct ice_pf *pf) ...@@ -253,6 +272,12 @@ static int ice_reserve_rdma_qvector(struct ice_pf *pf)
*/ */
static void ice_free_rdma_qvector(struct ice_pf *pf) static void ice_free_rdma_qvector(struct ice_pf *pf)
{ {
if (!pf->msix_entries)
return;
kfree(pf->msix_entries);
pf->msix_entries = NULL;
pf->num_avail_sw_msix -= pf->num_rdma_msix; pf->num_avail_sw_msix -= pf->num_rdma_msix;
ice_free_res(pf->irq_tracker, pf->rdma_base_vector, ice_free_res(pf->irq_tracker, pf->rdma_base_vector,
ICE_RES_RDMA_VEC_ID); ICE_RES_RDMA_VEC_ID);
......
...@@ -59,7 +59,7 @@ static int ice_ena_msix_range(struct ice_pf *pf) ...@@ -59,7 +59,7 @@ static int ice_ena_msix_range(struct ice_pf *pf)
{ {
int num_cpus, hw_num_msix, v_other, v_wanted, v_actual; int num_cpus, hw_num_msix, v_other, v_wanted, v_actual;
struct device *dev = ice_pf_to_dev(pf); struct device *dev = ice_pf_to_dev(pf);
int err, i; int err;
hw_num_msix = pf->hw.func_caps.common_cap.num_msix_vectors; hw_num_msix = pf->hw.func_caps.common_cap.num_msix_vectors;
num_cpus = num_online_cpus(); num_cpus = num_online_cpus();
...@@ -113,23 +113,13 @@ static int ice_ena_msix_range(struct ice_pf *pf) ...@@ -113,23 +113,13 @@ static int ice_ena_msix_range(struct ice_pf *pf)
pf->num_rdma_msix); pf->num_rdma_msix);
} }
pf->msix_entries = devm_kcalloc(dev, v_wanted,
sizeof(*pf->msix_entries), GFP_KERNEL);
if (!pf->msix_entries) {
err = -ENOMEM;
goto exit_err;
}
for (i = 0; i < v_wanted; i++)
pf->msix_entries[i].entry = i;
/* actually reserve the vectors */ /* actually reserve the vectors */
v_actual = pci_enable_msix_range(pf->pdev, pf->msix_entries, v_actual = pci_alloc_irq_vectors(pf->pdev, ICE_MIN_MSIX, v_wanted,
ICE_MIN_MSIX, v_wanted); PCI_IRQ_MSIX);
if (v_actual < 0) { if (v_actual < 0) {
dev_err(dev, "unable to reserve MSI-X vectors\n"); dev_err(dev, "unable to reserve MSI-X vectors\n");
err = v_actual; err = v_actual;
goto msix_err; goto exit_err;
} }
if (v_actual < v_wanted) { if (v_actual < v_wanted) {
...@@ -138,9 +128,9 @@ static int ice_ena_msix_range(struct ice_pf *pf) ...@@ -138,9 +128,9 @@ static int ice_ena_msix_range(struct ice_pf *pf)
if (v_actual < ICE_MIN_MSIX) { if (v_actual < ICE_MIN_MSIX) {
/* error if we can't get minimum vectors */ /* error if we can't get minimum vectors */
pci_disable_msix(pf->pdev); pci_free_irq_vectors(pf->pdev);
err = -ERANGE; err = -ERANGE;
goto msix_err; goto exit_err;
} else { } else {
int v_remain = v_actual - v_other; int v_remain = v_actual - v_other;
...@@ -160,33 +150,19 @@ static int ice_ena_msix_range(struct ice_pf *pf) ...@@ -160,33 +150,19 @@ static int ice_ena_msix_range(struct ice_pf *pf)
return v_actual; return v_actual;
msix_err:
devm_kfree(dev, pf->msix_entries);
exit_err: exit_err:
pf->num_rdma_msix = 0; pf->num_rdma_msix = 0;
pf->num_lan_msix = 0; pf->num_lan_msix = 0;
return err; return err;
} }
/**
* ice_dis_msix - Disable MSI-X interrupt setup in OS
* @pf: board private structure
*/
static void ice_dis_msix(struct ice_pf *pf)
{
pci_disable_msix(pf->pdev);
devm_kfree(ice_pf_to_dev(pf), pf->msix_entries);
pf->msix_entries = NULL;
}
/** /**
* ice_clear_interrupt_scheme - Undo things done by ice_init_interrupt_scheme * ice_clear_interrupt_scheme - Undo things done by ice_init_interrupt_scheme
* @pf: board private structure * @pf: board private structure
*/ */
void ice_clear_interrupt_scheme(struct ice_pf *pf) void ice_clear_interrupt_scheme(struct ice_pf *pf)
{ {
ice_dis_msix(pf); pci_free_irq_vectors(pf->pdev);
if (pf->irq_tracker) { if (pf->irq_tracker) {
devm_kfree(ice_pf_to_dev(pf), pf->irq_tracker); devm_kfree(ice_pf_to_dev(pf), pf->irq_tracker);
...@@ -213,7 +189,7 @@ int ice_init_interrupt_scheme(struct ice_pf *pf) ...@@ -213,7 +189,7 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
vectors), vectors),
GFP_KERNEL); GFP_KERNEL);
if (!pf->irq_tracker) { if (!pf->irq_tracker) {
ice_dis_msix(pf); pci_free_irq_vectors(pf->pdev);
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -3243,10 +3243,8 @@ static void ice_free_irq_msix_misc(struct ice_pf *pf) ...@@ -3243,10 +3243,8 @@ static void ice_free_irq_msix_misc(struct ice_pf *pf)
wr32(hw, PFINT_OICR_ENA, 0); wr32(hw, PFINT_OICR_ENA, 0);
ice_flush(hw); ice_flush(hw);
if (pf->msix_entries) { synchronize_irq(misc_irq_num);
synchronize_irq(misc_irq_num); devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf);
devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf);
}
pf->num_avail_sw_msix += 1; pf->num_avail_sw_msix += 1;
ice_free_res(pf->irq_tracker, pf->oicr_idx, ICE_RES_MISC_VEC_ID); ice_free_res(pf->irq_tracker, pf->oicr_idx, ICE_RES_MISC_VEC_ID);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment