@@ -235,14 +235,33 @@ EXPORT_SYMBOL_GPL(ice_get_qos_params);
static int ice_reserve_rdma_qvector(struct ice_pf *pf)
{
if (ice_is_rdma_ena(pf)) {
- int index;
+ int index, i;
index = ice_get_res(pf, pf->irq_tracker, pf->num_rdma_msix,
ICE_RES_RDMA_VEC_ID);
if (index < 0)
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->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;
}
@@ -253,6 +272,12 @@ static int ice_reserve_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;
ice_free_res(pf->irq_tracker, pf->rdma_base_vector,
ICE_RES_RDMA_VEC_ID);
@@ -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;
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;
num_cpus = num_online_cpus();
@@ -113,23 +113,13 @@ static int ice_ena_msix_range(struct ice_pf *pf)
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 */
- v_actual = pci_enable_msix_range(pf->pdev, pf->msix_entries,
- ICE_MIN_MSIX, v_wanted);
+ v_actual = pci_alloc_irq_vectors(pf->pdev, ICE_MIN_MSIX, v_wanted,
+ PCI_IRQ_MSIX);
if (v_actual < 0) {
dev_err(dev, "unable to reserve MSI-X vectors\n");
err = v_actual;
- goto msix_err;
+ goto exit_err;
}
if (v_actual < v_wanted) {
@@ -138,9 +128,9 @@ static int ice_ena_msix_range(struct ice_pf *pf)
if (v_actual < ICE_MIN_MSIX) {
/* error if we can't get minimum vectors */
- pci_disable_msix(pf->pdev);
+ pci_free_irq_vectors(pf->pdev);
err = -ERANGE;
- goto msix_err;
+ goto exit_err;
} else {
int v_remain = v_actual - v_other;
@@ -160,33 +150,19 @@ static int ice_ena_msix_range(struct ice_pf *pf)
return v_actual;
-msix_err:
- devm_kfree(dev, pf->msix_entries);
-
exit_err:
pf->num_rdma_msix = 0;
pf->num_lan_msix = 0;
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
* @pf: board private structure
*/
void ice_clear_interrupt_scheme(struct ice_pf *pf)
{
- ice_dis_msix(pf);
+ pci_free_irq_vectors(pf->pdev);
if (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)
vectors),
GFP_KERNEL);
if (!pf->irq_tracker) {
- ice_dis_msix(pf);
+ pci_free_irq_vectors(pf->pdev);
return -ENOMEM;
}
@@ -3243,10 +3243,8 @@ static void ice_free_irq_msix_misc(struct ice_pf *pf)
wr32(hw, PFINT_OICR_ENA, 0);
ice_flush(hw);
- if (pf->msix_entries) {
- synchronize_irq(misc_irq_num);
- devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf);
- }
+ synchronize_irq(misc_irq_num);
+ devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf);
pf->num_avail_sw_msix += 1;
ice_free_res(pf->irq_tracker, pf->oicr_idx, ICE_RES_MISC_VEC_ID);