public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	shannon.nelson@amd.com, brett.creeley@amd.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, corbet@lwn.net, andrew+netdev@lunn.ch,
	allen.hubbe@amd.com, nikhil.agarwal@amd.com,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Boyer <andrew.boyer@amd.com>
Subject: Re: [PATCH v3 10/14] RDMA/ionic: Register device ops for control path
Date: Tue, 8 Jul 2025 15:35:52 +0530	[thread overview]
Message-ID: <76a68f62-1f73-cc81-0f5b-48a6982a54c7@amd.com> (raw)
In-Reply-To: <20250707164609.GA592765@unreal>


On 7/7/25 22:16, Leon Romanovsky wrote:
> On Mon, Jul 07, 2025 at 08:26:20PM +0530, Abhijit Gangurde wrote:
>> On 7/7/25 12:51, Leon Romanovsky wrote:
>>> On Mon, Jul 07, 2025 at 10:57:13AM +0530, Abhijit Gangurde wrote:
>>>> On 7/4/25 22:38, Leon Romanovsky wrote:
>>>>> On Thu, Jul 03, 2025 at 12:49:30PM +0530, Abhijit Gangurde wrote:
>>>>>> On 7/2/25 23:30, Leon Romanovsky wrote:
>>>>>>> On Wed, Jul 02, 2025 at 10:18:03AM -0300, Jason Gunthorpe wrote:
>>>>>>>> On Tue, Jul 01, 2025 at 01:38:44PM +0300, Leon Romanovsky wrote:
>>>>>>>>>> +static void ionic_flush_qs(struct ionic_ibdev *dev)
>>>>>>>>>> +{
>>>>>>>>>> +	struct ionic_qp *qp, *qp_tmp;
>>>>>>>>>> +	struct ionic_cq *cq, *cq_tmp;
>>>>>>>>>> +	LIST_HEAD(flush_list);
>>>>>>>>>> +	unsigned long index;
>>>>>>>>>> +
>>>>>>>>>> +	/* Flush qp send and recv */
>>>>>>>>>> +	rcu_read_lock();
>>>>>>>>>> +	xa_for_each(&dev->qp_tbl, index, qp) {
>>>>>>>>>> +		kref_get(&qp->qp_kref);
>>>>>>>>>> +		list_add_tail(&qp->ibkill_flush_ent, &flush_list);
>>>>>>>>>> +	}
>>>>>>>>>> +	rcu_read_unlock();
>>>>>>>>> Same question as for CQ. What does RCU lock protect here?
>>>>>>>> It should protect the kref_get against free of qp. The qp memory must
>>>>>>>> be RCU freed.
>>>>>>> I'm not sure that this was intension here. Let's wait for an answer from the author.
>>>>>> As Jason mentioned, It was intended to protect the kref_get against free of
>>>>>> cq and qp
>>>>>> in the destroy path.
>>>>> How is it possible? IB/core is supposed to protect from accessing verbs
>>>>> resources post their release/destroy.
>>>>>
>>>>> After you answered what RCU is protecting, I don't see why you would
>>>>> have custom kref over QP/CQ/e.t.c objects.
>>>>>
>>>>> Thanks
>>>> The RCU protected kref here is making sure that all the hw events are
>>>> processed before destroy callback returns. Similarly, when driver is
>>>> going for ib_unregister_device, it is draining the pending WRs and events.
>>> I asked why do you have kref in first place? When ib_unregister_device
>>> is called all "pending MR" already supposed to be destroyed.
>>>
>>> Thansk
>> The custom kref on QP/CQ object is holding the completion for the destroy
>> callback.
>> If any pending async hw events are being processed, destroy would wait on
>> this completion
>> before it returns.
> Please see how other drivers avoid such situation. There is no need in
> custom kref.
>
> Thanks

As per your suggestion, I looked some of the other RDMA drivers. While 
many are using locks, that approach would negate the lockless lookup we 
gain from the xarray.
The MANA RDMA driver, for instance, uses a similar refcount and 
completion mechanism to handle asynchronous events.

Thanks



  reply	other threads:[~2025-07-08 10:06 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 12:13 [PATCH v3 00/14] Introduce AMD Pensando RDMA driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 01/14] net: ionic: Create an auxiliary device for rdma driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 02/14] net: ionic: Update LIF identity with additional RDMA capabilities Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 03/14] net: ionic: Export the APIs from net driver to support device commands Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 04/14] net: ionic: Provide RDMA reset support for the RDMA driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 05/14] net: ionic: Provide interrupt allocation " Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 06/14] net: ionic: Provide doorbell and CMB region information Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 07/14] RDMA: Add IONIC to rdma_driver_id definition Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter Abhijit Gangurde
2025-06-26  7:26   ` Leon Romanovsky
2025-06-27 10:18     ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 09/14] RDMA/ionic: Create device queues to support admin operations Abhijit Gangurde
2025-07-01 10:24   ` Leon Romanovsky
2025-07-03  6:59     ` Abhijit Gangurde
2025-07-03  8:41       ` Leon Romanovsky
2025-07-04 10:45         ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 10/14] RDMA/ionic: Register device ops for control path Abhijit Gangurde
2025-07-01 10:38   ` Leon Romanovsky
2025-07-02 13:18     ` Jason Gunthorpe
2025-07-02 18:00       ` Leon Romanovsky
2025-07-03  7:19         ` Abhijit Gangurde
2025-07-04 17:08           ` Leon Romanovsky
2025-07-07  5:27             ` Abhijit Gangurde
2025-07-07  7:21               ` Leon Romanovsky
2025-07-07 14:56                 ` Abhijit Gangurde
2025-07-07 16:46                   ` Leon Romanovsky
2025-07-08 10:05                     ` Abhijit Gangurde [this message]
2025-07-13  6:27                       ` Leon Romanovsky
2025-07-15 19:16                         ` Jason Gunthorpe
2025-07-20  8:39                           ` Abhijit Gangurde
2025-07-03  7:00     ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 11/14] RDMA/ionic: Register device ops for datapath Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 12/14] RDMA/ionic: Register device ops for miscellaneous functionality Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 13/14] RDMA/ionic: Implement device stats ops Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 14/14] RDMA/ionic: Add Makefile/Kconfig to kernel build environment Abhijit Gangurde
2025-06-25 21:44 ` [PATCH v3 00/14] Introduce AMD Pensando RDMA driver Jakub Kicinski
2025-06-26  7:07 ` Leon Romanovsky
2025-06-27 10:06   ` Abhijit Gangurde

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=76a68f62-1f73-cc81-0f5b-48a6982a54c7@amd.com \
    --to=abhijit.gangurde@amd.com \
    --cc=allen.hubbe@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew.boyer@amd.com \
    --cc=brett.creeley@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikhil.agarwal@amd.com \
    --cc=pabeni@redhat.com \
    --cc=shannon.nelson@amd.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