Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] The explicit `msi_sharing = true` requirement for platforms without 
dynamic MSI-X support is unconditionally overwritten, leading to incorrect 
MSI-X configuration.
--

commit 113e4b9419d10774e0a86653bf123b1add7cbc2e
Author: Long Li <[email protected]>

net: mana: Query device capabilities and configure MSI-X sharing for EQs

This commit adjusts the max number of queues to allow dedicated MSI-X vectors
for each vPort and enables MSI-X sharing among vPorts when there are not
enough vectors or the platform does not support dynamic MSI-X allocation.

> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c 
> b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> index 3bc3fff559991..bbd055849e363 100644
> --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
> +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> @@ -179,8 +179,18 @@ static int mana_gd_query_max_resources(struct pci_dev 
> *pdev)
>       struct gdma_context *gc = pci_get_drvdata(pdev);
>       struct gdma_query_max_resources_resp resp = {};
>       struct gdma_general_req req = {};
> +     unsigned int max_num_queues;
> +     u8 bm_hostmode;
> +     u16 num_ports;
>       int err;
>  
> +     /* Reset msi_sharing so it is recomputed from current hardware
> +      * state. On resume, num_online_cpus() or num_msix_usable may
> +      * have changed, making dedicated MSI-X feasible where it was
> +      * not before.
> +      */
> +     gc->msi_sharing = false;
> +

Does this unconditional reset unintentionally overwrite the platform constraint
for systems without dynamic MSI-X support?

[ ... ]

> @@ -1889,6 +1936,7 @@ static int mana_gd_setup_hwc_irqs(struct pci_dev *pdev)
>               /* Need 1 interrupt for HWC */
>               max_irqs = min(num_online_cpus(), MANA_MAX_NUM_QUEUES) + 1;
>               min_irqs = 2;
> +             gc->msi_sharing = true;
>       }
>  
>       nvec = pci_alloc_irq_vectors(pdev, min_irqs, max_irqs, PCI_IRQ_MSIX);

The commit message states that sharing is always used when the platform does
not support dynamic MSI-X allocation. This is successfully set here in
mana_gd_setup_hwc_irqs().

However, looking at mana_gd_setup(), mana_gd_query_max_resources() is called
after mana_gd_setup_hwc_irqs().

Will this execution order cause the driver to ignore the limitation and
attempt to use dedicated MSI-X vectors if there happen to be enough
pre-allocated vectors to satisfy the per-vPort math later in the function?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to