Re: [PATCH for-next] RDMA/efa: Limit EQs to available MSI-X vectors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Yonatan,

On 03/01/2024 16:21, ynachum@xxxxxxxxxx wrote:
> From: Yonatan Nachum <ynachum@xxxxxxxxxx>
> 
> When creating EQs we take into consideration the max number of EQs the
> device reported it can support and the number of available CPUs. There
> are situations where the number of EQs the device reported it can
> support and the PCI configuration of MSI-X is different, take it in
> account as well when creating EQs.
> Also request at least 1 MSI-X vector for the management queue and allow
> the kernel to return a number of vectors in a range between 1 and the
> max supported MSI-X vectors according to the PCI config.
> 
> Reviewed-by: Michael Margolin <mrgolin@xxxxxxxxxx>
> Reviewed-by: Yonatan Goldhirsh <ygold@xxxxxxxxxx>
> Signed-off-by: Yonatan Nachum <ynachum@xxxxxxxxxx>
> ---
>  drivers/infiniband/hw/efa/efa.h      |  3 ++-
>  drivers/infiniband/hw/efa/efa_main.c | 32 +++++++++++++---------------
>  2 files changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/efa/efa.h b/drivers/infiniband/hw/efa/efa.h
> index 7352a1f5d811..a17045e100cd 100644
> --- a/drivers/infiniband/hw/efa/efa.h
> +++ b/drivers/infiniband/hw/efa/efa.h
> @@ -1,6 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
>  /*
> - * Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
> + * Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All rights reserved.
>   */
>  
>  #ifndef _EFA_H_
> @@ -57,6 +57,7 @@ struct efa_dev {
>  	u64 db_bar_addr;
>  	u64 db_bar_len;
>  
> +	unsigned int num_irq_vectors;
>  	int admin_msix_vector_idx;
>  	struct efa_irq admin_irq;
>  
> diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
> index 15ee92081118..1aade398c723 100644
> --- a/drivers/infiniband/hw/efa/efa_main.c
> +++ b/drivers/infiniband/hw/efa/efa_main.c
> @@ -319,7 +319,9 @@ static int efa_create_eqs(struct efa_dev *dev)
>  	int err;
>  	int i;
>  
> -	neqs = min_t(unsigned int, neqs, num_online_cpus());
> +	neqs = min_t(unsigned int, neqs,
> +		     dev->num_irq_vectors - EFA_COMP_EQS_VEC_BASE);
> +

If the device supports one msix (which is reserved for commands) you'll
end up with zero neqs, and allocate a zero-sized dev->eqs array.

Won't that break when efa_create_cq() is called and try to access this
array?
Especially since efa_ib_device_add() sets num_comp_vectors to 1 in such
case..

>  	dev->neqs = neqs;
>  	dev->eqs = kcalloc(neqs, sizeof(*dev->eqs), GFP_KERNEL);
>  	if (!dev->eqs)




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux