From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Dave Jiang <dave.jiang@intel.com>,
Shannon Nelson <shannon.nelson@amd.com>,
<andrew.gospodarek@broadcom.com>, <aron.silverton@oracle.com>,
<dan.j.williams@intel.com>, <daniel.vetter@ffwll.ch>,
<dsahern@kernel.org>, <gregkh@linuxfoundation.org>,
<hch@infradead.org>, <itayavr@nvidia.com>, <jiri@nvidia.com>,
<kuba@kernel.org>, <lbloch@nvidia.com>, <leonro@nvidia.com>,
<linux-cxl@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
<netdev@vger.kernel.org>, <saeedm@nvidia.com>,
<brett.creeley@amd.com>
Subject: Re: [PATCH v2 4/6] pds_fwctl: initial driver framework
Date: Tue, 4 Mar 2025 09:50:36 +0800 [thread overview]
Message-ID: <20250304095036.00000edf@huawei.com> (raw)
In-Reply-To: <20250303172953.GC133783@nvidia.com>
On Mon, 3 Mar 2025 13:29:53 -0400
Jason Gunthorpe <jgg@nvidia.com> wrote:
> On Mon, Mar 03, 2025 at 09:45:52AM -0700, Dave Jiang wrote:
> > > +static int pdsfc_probe(struct auxiliary_device *adev,
> > > + const struct auxiliary_device_id *id)
> > > +{
> > > + struct pds_auxiliary_dev *padev =
> > > + container_of(adev, struct pds_auxiliary_dev, aux_dev);
> > > + struct pdsfc_dev *pdsfc __free(pdsfc_dev) =
> > > + fwctl_alloc_device(&padev->vf_pdev->dev, &pdsfc_ops,
> > > + struct pdsfc_dev, fwctl);
> > > + struct device *dev = &adev->dev;
> > > + int err;
> > > +
> >
> > It's ok to move the pdsfc declaration inline right before this check
> > below. That would help prevent any accidental usages of pdsfc before
> > the check. This is an exception to the coding style guidelines with
> > the introduction of cleanup mechanisms.
>
> Yeah.. I'm starting to feel negative about cleanup.h - there are too
> many special style notes that seem to only be known by hearsay :\
I think this one is more about the classic risk of undefined
behavior meaning the compiler removes the check. So if we had a
bob = pdsfc->fred;
but didn't use bob before the check on pdsfc != NULL then
the compiler is allowed to remove the check on pdsfc existing
as the dereferencce can be assume to mean pdsfc is always
!= NULL.
So not really a cleanup.h related issue at all (and not in my
view suitable for adding to the nice help Dan put in that file).
Doesn't matter too much though. Personally I'm kind of content
now with cleanup.h usage but it was a bit of time to teach
myself the new way of thinking about things.
Jonathan
>
> > > +static void pdsfc_remove(struct auxiliary_device *adev)
> > > +{
> > > + struct pdsfc_dev *pdsfc __free(pdsfc_dev) = auxiliary_get_drvdata(adev);
> > > +
> > > + fwctl_unregister(&pdsfc->fwctl);
> >
> > Missing fwctl_put(). See fwctl_unregister() header comments. Caller
> > must still call fwctl_put() to free the fwctl after calling
> > fwctl_unregister().
>
> The code is correct, the put is hidden in the __free
>
> However I think we decided not to use __free in this context and open
> code the put as a style choice
>
> Thanks,
> Jason
next prev parent reply other threads:[~2025-03-04 1:50 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 1:35 [PATCH v2 0/6] pds_fwctl: fwctl for AMD/Pensando core devices Shannon Nelson
2025-03-01 1:35 ` [PATCH v2 1/6] pds_core: make pdsc_auxbus_dev_del() void Shannon Nelson
2025-03-04 1:57 ` Jonathan Cameron
2025-03-04 4:09 ` Kalesh Anakkur Purayil
2025-03-01 1:35 ` [PATCH v2 2/6] pds_core: specify auxiliary_device to be created Shannon Nelson
2025-03-04 7:44 ` Jonathan Cameron
2025-03-01 1:35 ` [PATCH v2 3/6] pds_core: add new fwctl auxiliary_device Shannon Nelson
2025-03-04 8:03 ` Jonathan Cameron
2025-03-06 1:48 ` Nelson, Shannon
2025-03-01 1:35 ` [PATCH v2 4/6] pds_fwctl: initial driver framework Shannon Nelson
2025-03-03 16:45 ` Dave Jiang
2025-03-03 17:29 ` Jason Gunthorpe
2025-03-03 17:35 ` Nelson, Shannon
2025-03-04 1:50 ` Jonathan Cameron [this message]
2025-03-03 17:31 ` Nelson, Shannon
2025-03-03 17:46 ` Dave Jiang
2025-03-04 8:30 ` Jonathan Cameron
2025-03-06 1:52 ` Nelson, Shannon
2025-03-04 19:39 ` Jason Gunthorpe
2025-03-06 2:05 ` Nelson, Shannon
2025-03-01 1:35 ` [PATCH v2 5/6] pds_fwctl: add rpc and query support Shannon Nelson
2025-03-04 9:08 ` Jonathan Cameron
2025-03-04 17:24 ` Jason Gunthorpe
2025-03-06 2:02 ` Nelson, Shannon
2025-03-06 1:55 ` Nelson, Shannon
2025-03-04 19:52 ` Jason Gunthorpe
2025-03-06 2:07 ` Nelson, Shannon
2025-03-01 1:35 ` [PATCH v2 6/6] pds_fwctl: add Documentation entries Shannon Nelson
2025-03-04 9:12 ` Jonathan Cameron
2025-03-06 1:56 ` Nelson, Shannon
2025-03-02 12:34 ` [PATCH v2 0/6] pds_fwctl: fwctl for AMD/Pensando core devices Leon Romanovsky
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=20250304095036.00000edf@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=aron.silverton@oracle.com \
--cc=brett.creeley@amd.com \
--cc=dan.j.williams@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dave.jiang@intel.com \
--cc=dsahern@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=itayavr@nvidia.com \
--cc=jgg@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=lbloch@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.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;
as well as URLs for NNTP newsgroup(s).