Skip to content

Commit a8c2d39

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: treat dyn_allowed only as suggestion
It can be needed to have some MSI-X allocated as static and rest as dynamic. For example on PF VSI. We want to always have minimum one MSI-X on it, because of that it is allocated as a static one, rest can be dynamic if it is supported. Change the ice_get_irq_res() to allow using static entries if they are free even if caller wants dynamic one. Adjust limit values to the new approach. Min and max in limit means the values that are valid, so decrease max and num_static by one. Set vsi::irq_dyn_alloc if dynamic allocation is supported. Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 3e0d3cb commit a8c2d39

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ static void ice_free_irq_res(struct ice_pf *pf, u16 index)
4545
/**
4646
* ice_get_irq_res - get an interrupt resource
4747
* @pf: board private structure
48-
* @dyn_only: force entry to be dynamically allocated
48+
* @dyn_allowed: allow entry to be dynamically allocated
4949
*
5050
* Allocate new irq entry in the free slot of the tracker. Since xarray
5151
* is used, always allocate new entry at the lowest possible index. Set
5252
* proper allocation limit for maximum tracker entries.
5353
*
5454
* Returns allocated irq entry or NULL on failure.
5555
*/
56-
static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
56+
static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf,
57+
bool dyn_allowed)
5758
{
58-
struct xa_limit limit = { .max = pf->irq_tracker.num_entries,
59+
struct xa_limit limit = { .max = pf->irq_tracker.num_entries - 1,
5960
.min = 0 };
60-
unsigned int num_static = pf->irq_tracker.num_static;
61+
unsigned int num_static = pf->irq_tracker.num_static - 1;
6162
struct ice_irq_entry *entry;
6263
unsigned int index;
6364
int ret;
@@ -66,9 +67,9 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
6667
if (!entry)
6768
return NULL;
6869

69-
/* skip preallocated entries if the caller says so */
70-
if (dyn_only)
71-
limit.min = num_static;
70+
/* only already allocated if the caller says so */
71+
if (!dyn_allowed)
72+
limit.max = num_static;
7273

7374
ret = xa_alloc(&pf->irq_tracker.entries, &index, entry, limit,
7475
GFP_KERNEL);
@@ -78,7 +79,7 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
7879
entry = NULL;
7980
} else {
8081
entry->index = index;
81-
entry->dynamic = index >= num_static;
82+
entry->dynamic = index > num_static;
8283
}
8384

8485
return entry;
@@ -137,7 +138,7 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
137138
/**
138139
* ice_alloc_irq - Allocate new interrupt vector
139140
* @pf: board private structure
140-
* @dyn_only: force dynamic allocation of the interrupt
141+
* @dyn_allowed: allow dynamic allocation of the interrupt
141142
*
142143
* Allocate new interrupt vector for a given owner id.
143144
* return struct msi_map with interrupt details and track
@@ -150,20 +151,20 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
150151
* interrupt will be allocated with pci_msix_alloc_irq_at.
151152
*
152153
* Some callers may only support dynamically allocated interrupts.
153-
* This is indicated with dyn_only flag.
154+
* This is indicated with dyn_allowed flag.
154155
*
155156
* On failure, return map with negative .index. The caller
156157
* is expected to check returned map index.
157158
*
158159
*/
159-
struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_only)
160+
struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_allowed)
160161
{
161162
int sriov_base_vector = pf->sriov_base_vector;
162163
struct msi_map map = { .index = -ENOENT };
163164
struct device *dev = ice_pf_to_dev(pf);
164165
struct ice_irq_entry *entry;
165166

166-
entry = ice_get_irq_res(pf, dyn_only);
167+
entry = ice_get_irq_res(pf, dyn_allowed);
167168
if (!entry)
168169
return map;
169170

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)
571571
return -ENOMEM;
572572
}
573573

574+
vsi->irq_dyn_alloc = pci_msix_can_alloc_dyn(vsi->back->pdev);
575+
574576
switch (vsi->type) {
575577
case ICE_VSI_PF:
576578
case ICE_VSI_SF:

0 commit comments

Comments
 (0)