Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yonatan Nachum <ynachum@amazon.com>
Cc: jgg@nvidia.com, linux-rdma@vger.kernel.org, mrgolin@amazon.com,
	sleybo@amazon.com, matua@amazon.com, gal.pressman@linux.dev,
	Firas Jahjah <firasj@amazon.com>
Subject: Re: [PATCH for-next v2 1/2] RDMA/efa: Add initialization of AH cache rhashtable
Date: Tue, 19 May 2026 16:07:55 +0300	[thread overview]
Message-ID: <20260519130755.GV33515@unreal> (raw)
In-Reply-To: <20260512061121.2177521-2-ynachum@amazon.com>

On Tue, May 12, 2026 at 06:11:20AM +0000, Yonatan Nachum wrote:
> New EFA devices don't support the creation of multiple address handles
> to the same remote on the same PD.
> To overcome this limitation, introduce an AH cache rhashtable which will
> store the refcounts of the same AH creation on the same PD and will
> allow the driver to manage AH reuse. The hashtable key is the
> combination of PD and GID. Add initialization and teardown logic for the
> rhashtable.
> 
> Reviewed-by: Firas Jahjah <firasj@amazon.com>
> Reviewed-by: Michael Margolin <mrgolin@amazon.com>
> Signed-off-by: Yonatan Nachum <ynachum@amazon.com>
> ---
>  drivers/infiniband/hw/efa/Makefile       |  4 +--
>  drivers/infiniband/hw/efa/efa_ah_cache.c | 30 ++++++++++++++++++++
>  drivers/infiniband/hw/efa/efa_ah_cache.h | 36 ++++++++++++++++++++++++
>  drivers/infiniband/hw/efa/efa_com.c      | 12 +++++++-
>  drivers/infiniband/hw/efa/efa_com.h      |  5 +++-
>  5 files changed, 83 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/infiniband/hw/efa/efa_ah_cache.c
>  create mode 100644 drivers/infiniband/hw/efa/efa_ah_cache.h

<...>

> +struct efa_ah_cache_entry {
> +	struct efa_ah_cache_key key;
> +	u16 ah;
> +	bool initialized;

If this variable is present, it indicates that the reference count is being  
used incorrectly. In the uninitialized state, the refcount must be 0.

Thanks

> +	refcount_t refcount;
> +	struct rhash_head linkage;
> +	struct mutex lock; /* Serializes device commands per cache entry */
> +};
> +
> +struct efa_ah_cache {
> +	struct rhashtable hashtable;
> +	struct mutex lock; /* Protects AH cache hashtable */
> +};
> +
> +int efa_ah_cache_init(struct efa_ah_cache *ah_cache);
> +void efa_ah_cache_destroy(struct efa_ah_cache *ah_cache);
> +
> +#endif /* _EFA_AH_CACHE_H_ */
> diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c
> index e97b5f0d7003..b9b922583709 100644
> --- a/drivers/infiniband/hw/efa/efa_com.c
> +++ b/drivers/infiniband/hw/efa/efa_com.c
> @@ -688,6 +688,8 @@ void efa_com_admin_destroy(struct efa_com_dev *edev)
>  
>  	size = aenq->depth * sizeof(*aenq->entries);
>  	dma_free_coherent(edev->dmadev, size, aenq->entries, aenq->dma_addr);
> +
> +	efa_ah_cache_destroy(&edev->ah_cache);
>  }
>  
>  /**
> @@ -746,6 +748,12 @@ int efa_com_admin_init(struct efa_com_dev *edev,
>  		return -ENODEV;
>  	}
>  
> +	err = efa_ah_cache_init(&edev->ah_cache);
> +	if (err) {
> +		ibdev_err(edev->efa_dev, "Failed to init AH cache\n");
> +		return err;
> +	}
> +
>  	aq->depth = EFA_ADMIN_QUEUE_DEPTH;
>  
>  	aq->dmadev = edev->dmadev;
> @@ -758,7 +766,7 @@ int efa_com_admin_init(struct efa_com_dev *edev,
>  
>  	err = efa_com_init_comp_ctxt(aq);
>  	if (err)
> -		return err;
> +		goto err_destroy_ah_cache;
>  
>  	err = efa_com_admin_init_sq(edev);
>  	if (err)
> @@ -796,6 +804,8 @@ int efa_com_admin_init(struct efa_com_dev *edev,
>  			  aq->sq.entries, aq->sq.dma_addr);
>  err_destroy_comp_ctxt:
>  	devm_kfree(edev->dmadev, aq->comp_ctx);
> +err_destroy_ah_cache:
> +	efa_ah_cache_destroy(&edev->ah_cache);
>  
>  	return err;
>  }
> diff --git a/drivers/infiniband/hw/efa/efa_com.h b/drivers/infiniband/hw/efa/efa_com.h
> index 4d9ca97e4296..dc365df7f3dd 100644
> --- a/drivers/infiniband/hw/efa/efa_com.h
> +++ b/drivers/infiniband/hw/efa/efa_com.h
> @@ -1,6 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
>  /*
> - * Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved.
> + * Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All rights reserved.
>   */
>  
>  #ifndef _EFA_COM_H_
> @@ -14,6 +14,7 @@
>  
>  #include <rdma/ib_verbs.h>
>  
> +#include "efa_ah_cache.h"
>  #include "efa_common_defs.h"
>  #include "efa_admin_defs.h"
>  #include "efa_admin_cmds_defs.h"
> @@ -112,6 +113,8 @@ struct efa_com_dev {
>  	u32 supported_features;
>  	u32 dma_addr_bits;
>  
> +	struct efa_ah_cache ah_cache;
> +
>  	struct efa_com_mmio_read mmio_read;
>  };
>  
> -- 
> 2.50.1
> 

  parent reply	other threads:[~2026-05-19 13:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  6:11 [PATCH for-next v2 0/2] RDMA/efa: Add AH cache for AH reuse Yonatan Nachum
2026-05-12  6:11 ` [PATCH for-next v2 1/2] RDMA/efa: Add initialization of AH cache rhashtable Yonatan Nachum
2026-05-14  5:12   ` Zhu Yanjun
2026-05-14 10:02     ` Yonatan Nachum
2026-05-15  5:09       ` Zhu Yanjun
2026-05-17  7:06         ` Yonatan Nachum
2026-05-19 13:07   ` Leon Romanovsky [this message]
2026-05-20  6:53     ` Yonatan Nachum
2026-05-12  6:11 ` [PATCH for-next v2 2/2] RDMA/efa: Add AH cache handling on create and destroy AH Yonatan Nachum
2026-05-19 13:38   ` Leon Romanovsky
2026-05-20  7:03     ` Yonatan Nachum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260519130755.GV33515@unreal \
    --to=leon@kernel.org \
    --cc=firasj@amazon.com \
    --cc=gal.pressman@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matua@amazon.com \
    --cc=mrgolin@amazon.com \
    --cc=sleybo@amazon.com \
    --cc=ynachum@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox