From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: allen.hubbe@amd.com, nikhil.agarwal@amd.com, davem@davemloft.net,
linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
shannon.nelson@amd.com, brett.creeley@amd.com,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
corbet@lwn.net, jgg@ziepe.ca, leon@kernel.org,
andrew+netdev@lunn.ch
Subject: Re: [PATCH v4 01/14] net: ionic: Create an auxiliary device for rdma driver
Date: Wed, 6 Aug 2025 13:44:47 +0530 [thread overview]
Message-ID: <7393e875-9e7b-929a-a999-2b5e23230da4@amd.com> (raw)
In-Reply-To: <7044823e-c263-4789-b83c-ecb1eccde04f@wanadoo.fr>
On 8/2/25 02:45, Christophe JAILLET wrote:
> Le 23/07/2025 à 19:31, Abhijit Gangurde a écrit :
>> To support RDMA capable ethernet device, create an auxiliary device in
>> the ionic Ethernet driver. The RDMA device is modeled as an auxiliary
>> device to the Ethernet device.
>
> ...
>
>> +static DEFINE_IDA(aux_ida);
>> +
>> +static void ionic_auxbus_release(struct device *dev)
>> +{
>> + struct ionic_aux_dev *ionic_adev;
>> +
>> + ionic_adev = container_of(dev, struct ionic_aux_dev, adev.dev);
>> + kfree(ionic_adev);
>> +}
>> +
>> +int ionic_auxbus_register(struct ionic_lif *lif)
>
> The 2 places that uses thus function don't check its error code.
For the eth driver, RDMA functionality is optional hence return code was
missed. Although devlink parameter to control this is not included in
this series, where it needs return value from this function. Till that
point, I'll make it return void.
>
>> +{
>> + struct ionic_aux_dev *ionic_adev;
>> + struct auxiliary_device *aux_dev;
>> + int err, id;
>> +
>> + if (!(le64_to_cpu(lif->ionic->ident.lif.capabilities) &
>> IONIC_LIF_CAP_RDMA))
>> + return 0;
>> +
>> + ionic_adev = kzalloc(sizeof(*ionic_adev), GFP_KERNEL);
>> + if (!ionic_adev)
>> + return -ENOMEM;
>> +
>> + aux_dev = &ionic_adev->adev;
>> +
>> + id = ida_alloc_range(&aux_ida, 0, INT_MAX, GFP_KERNEL);
>
> Nitpick: why not just: ida_alloc(&aux_ida, GFP_KERNEL);
sure. Will use ida_alloc().
>
>> + if (id < 0) {
>> + dev_err(lif->ionic->dev, "Failed to allocate aux id: %d\n",
>> + id);
>> + err = id;
>> + goto err_adev_free;
>> + }
>> +
>> + aux_dev->id = id;
>> + aux_dev->name = "rdma";
>> + aux_dev->dev.parent = &lif->ionic->pdev->dev;
>> + aux_dev->dev.release = ionic_auxbus_release;
>> + ionic_adev->lif = lif;
>> + err = auxiliary_device_init(aux_dev);
>> + if (err) {
>> + dev_err(lif->ionic->dev, "Failed to initialize %s aux
>> device: %d\n",
>> + aux_dev->name, err);
>> + goto err_ida_free;
>> + }
>> +
>> + err = auxiliary_device_add(aux_dev);
>> + if (err) {
>> + dev_err(lif->ionic->dev, "Failed to add %s aux device: %d\n",
>> + aux_dev->name, err);
>> + goto err_aux_uninit;
>> + }
>> +
>> + lif->ionic_adev = ionic_adev;
>> +
>> + return 0;
>> +
>> +err_aux_uninit:
>> + auxiliary_device_uninit(aux_dev);
>
> I think a return err; is missing here, because, IMOH,
> auxiliary_device_uninit() will call put_device() that will trigger
> ionic_auxbus_release(). So kfree(ionic_adev) would be called twice.
>
> I also think that ida_free() should also be ionic_auxbus_release()
> (just a guess, not checked in details)
Thanks. I will fix this in next spin.
Abhijit
>
>> +err_ida_free:
>> + ida_free(&aux_ida, id);
>> +err_adev_free:
>> + kfree(ionic_adev);
>> +
>> + return err;
>> +}
>> +
>> +void ionic_auxbus_unregister(struct ionic_lif *lif)
>> +{
>> + struct auxiliary_device *aux_dev;
>> + int id;
>> +
>> + mutex_lock(&lif->adev_lock);
>> + if (!lif->ionic_adev)
>> + goto out;
>> +
>> + aux_dev = &lif->ionic_adev->adev;
>> + id = aux_dev->id;
>> +
>> + auxiliary_device_delete(aux_dev);
>> + auxiliary_device_uninit(aux_dev);
>> + ida_free(&aux_ida, id);
>> +
>> + lif->ionic_adev = NULL;
>> +
>> +out:
>> + mutex_unlock(&lif->adev_lock);
>> +}
>
> ...
>
> CJ
next prev parent reply other threads:[~2025-08-06 8:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 17:31 [PATCH v4 00/14] Introduce AMD Pensando RDMA driver Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 01/14] net: ionic: Create an auxiliary device for rdma driver Abhijit Gangurde
2025-07-23 18:11 ` Shannon Nelson
2025-07-28 10:17 ` Abhijit Gangurde
2025-08-01 21:15 ` Christophe JAILLET
2025-08-06 8:14 ` Abhijit Gangurde [this message]
2025-08-09 10:58 ` Christophe JAILLET
2025-07-23 17:31 ` [PATCH v4 02/14] net: ionic: Update LIF identity with additional RDMA capabilities Abhijit Gangurde
2025-07-25 16:29 ` Simon Horman
2025-07-23 17:31 ` [PATCH v4 03/14] net: ionic: Export the APIs from net driver to support device commands Abhijit Gangurde
2025-07-25 16:41 ` Simon Horman
2025-08-01 17:00 ` Jason Gunthorpe
2025-08-01 20:21 ` Jakub Kicinski
2025-08-06 7:54 ` Abhijit Gangurde
2025-08-06 17:58 ` Leon Romanovsky
2025-07-23 17:31 ` [PATCH v4 04/14] net: ionic: Provide RDMA reset support for the RDMA driver Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 05/14] net: ionic: Provide interrupt allocation " Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 06/14] net: ionic: Provide doorbell and CMB region information Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 07/14] RDMA: Add IONIC to rdma_driver_id definition Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 09/14] RDMA/ionic: Create device queues to support admin operations Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 10/14] RDMA/ionic: Register device ops for control path Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 11/14] RDMA/ionic: Register device ops for datapath Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 12/14] RDMA/ionic: Register device ops for miscellaneous functionality Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 13/14] RDMA/ionic: Implement device stats ops Abhijit Gangurde
2025-07-23 17:31 ` [PATCH v4 14/14] RDMA/ionic: Add Makefile/Kconfig to kernel build environment Abhijit Gangurde
2025-07-23 18:10 ` Randy Dunlap
2025-07-30 5:12 ` Abhijit Gangurde
2025-07-23 18:13 ` Shannon Nelson
2025-07-28 10:25 ` Abhijit Gangurde
2025-07-24 15:49 ` kernel test robot
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=7393e875-9e7b-929a-a999-2b5e23230da4@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=christophe.jaillet@wanadoo.fr \
--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
all inboxes | Powered by JetHome®