From: "Colberg, Peter" <peter.colberg@intel.com>
To: "yilun.xu@linux.intel.com" <yilun.xu@linux.intel.com>
Cc: "Xu, Yilun" <yilun.xu@intel.com>,
"linux-fpga@vger.kernel.org" <linux-fpga@vger.kernel.org>,
"mdf@kernel.org" <mdf@kernel.org>, "Wu, Hao" <hao.wu@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"russ.weight@linux.dev" <russ.weight@linux.dev>,
"Pagani, Marco" <marpagan@redhat.com>,
"trix@redhat.com" <trix@redhat.com>,
"russell.h.weight@intel.com" <russell.h.weight@intel.com>,
"matthew.gerlach@linux.intel.com"
<matthew.gerlach@linux.intel.com>
Subject: Re: [RFC PATCH v2 9/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV
Date: Thu, 19 Sep 2024 21:49:42 +0000 [thread overview]
Message-ID: <21e1306333d397858a906bb17bc3a6908b18be22.camel@intel.com> (raw)
In-Reply-To: <ZmuuqlMJ4nU6m25U@yilunxu-OptiPlex-7050>
On Fri, 2024-06-14 at 10:44 +0800, Xu Yilun wrote:
> On Wed, Jun 12, 2024 at 10:16:29PM +0000, Colberg, Peter wrote:
> > On Tue, 2024-04-23 at 23:36 +0800, Xu Yilun wrote:
> > > On Tue, Apr 09, 2024 at 07:39:42PM -0400, Peter Colberg wrote:
> > > > From: Xu Yilun <yilun.xu@intel.com>
> > > >
> > > > DFL ports are registered as platform devices in PF mode. The port device
> > > > should be removed from the host when the user wants to configure the
> > > > port as a VF and pass through to a virtual machine. The FME device
> > > > ioctls DFL_FPGA_FME_PORT_RELEASE/ASSIGN are designed for this purpose.
> > > >
> > > > In the previous implementation, the port platform device is not completely
> > > > destroyed on port release: it is removed from the system by
> > > > platform_device_del(), but the platform device instance is retained.
> > > > When the port assign ioctl is called, the platform device is added back by
> > > > platform_device_add(), which conflicts with this comment of device_add():
> > > > "Do not call this routine more than once for any device structure", and
> > > > will cause a kernel warning at runtime.
> > > >
> > > > This patch tries to completely unregister the port platform device on
> > > > release and registers a new one on assign. But the main work is to remove
> > > > the dependency on struct dfl_feature_platform_data for many internal DFL
> > > > APIs. This structure holds many DFL enumeration infos for feature devices.
> > > > Many DFL APIs are expected to work with these info even when the port
> > > > platform device is unregistered. But with the change the platform_data will
> > > > be freed in this case. So this patch introduces a new structure
> > > > dfl_feature_dev_data for these APIs, which acts similarly to the previous
> > > > dfl_feature_platform_data. The dfl_feature_platform_data then only needs a
> > > > pointer to dfl_feature_dev_data to make the feature device driver work.
> > > >
> > > > Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> > > > Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> > > > Signed-off-by: Peter Colberg <peter.colberg@intel.com>
> > > > ---
> > > > v2:
> > > > - Split monolithic patch into series at request of maintainer
> > > > - Substitute binfo->type for removed function feature_dev_id_type() in
> > > > parse_feature_irqs().
> > > > - Return ERR_PTR(-ENOMEM) on !feature->params in
> > > > binfo_create_feature_dev_data().
> > > > - Reorder cdev as first member of struct dfl_feature_platform_data
> > > > such that container_of() to obtain pdata evaluates to a no-op.
> > > > - Align kernel-doc function name for __dfl_fpga_cdev_find_port_data().
> > > > ---
> > > > drivers/fpga/dfl-afu-main.c | 9 +-
> > > > drivers/fpga/dfl-fme-br.c | 24 +-
> > > > drivers/fpga/dfl-fme-main.c | 6 +-
> > > > drivers/fpga/dfl.c | 430 +++++++++++++++++-------------------
> > > > drivers/fpga/dfl.h | 86 +++++---
> > > > 5 files changed, 281 insertions(+), 274 deletions(-)
> > > >
> > > > diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
> > > > index 42928cc7e42b..ead03b7aea70 100644
> > > > --- a/drivers/fpga/dfl-afu-main.c
> > > > +++ b/drivers/fpga/dfl-afu-main.c
> > > > @@ -143,9 +143,8 @@ static int port_reset(struct platform_device *pdev)
> > > > return ret;
> > > > }
> > > >
> > > > -static int port_get_id(struct platform_device *pdev)
> > > > +static int port_get_id(struct dfl_feature_dev_data *fdata)
> > > > {
> > > > - struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(&pdev->dev);
> > > > void __iomem *base;
> > > >
> > > > base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_HEADER);
> > > > @@ -156,7 +155,8 @@ static int port_get_id(struct platform_device *pdev)
> > > > static ssize_t
> > > > id_show(struct device *dev, struct device_attribute *attr, char *buf)
> > > > {
> > > > - int id = port_get_id(to_platform_device(dev));
> > > > + struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
> > > > + int id = port_get_id(fdata);
> > >
> >
> > Thank you for the comprehensive review.
> >
> > > My quick idea is we go with these steps:
> > > 1. refactor struct dfl_feature_platform_data then replace all dev/pdev
> > > arguments with pdata when necessary.
> >
> > Could you outline how far the refactoring should go? The main changes
> > are introduced with the destruction of the platform device on port
>
> Yes, exactly. And the goal is to make the change in a standalone patch
> so that everyone can find it, rather than bury in other massive
> replacements.
>
> > release. If the refactoring retains the platform device but adds all
> > the new members to pdata, I find that this patch would introduce non-
> > trivial intermediate code that is then deleted in a subsequent patch.
>
> That would not be a problem, as long as they clearly get explained, and
> in one patch series. Sometimes we need intermediate code to ensure a
> patch for one change, which makes people easy to read.
>
> >
> > > 2. factor out fdata from pdata, add fdata helpers.
> > > 3. massive pdata->fdata replacement.
> > > 4. delete all unused pdata helpers.
> >
> > The (roughly) reverse order seems to produce the smallest patch set:
>
> I don't think 'smallest' is the major concern, but it's fine if you
> firstly addressed other concerns. I cannot actually tell if it is
> better until the code is seen. But to emphasize on, the core change is
> splited out, the massive replacement patches are just replacements so
> they can be easily overviewed and skipped.
Thank you for the guidance. I have restructured the series to move the
massive replacements into two patches, "fpga: dfl: pass feature
platform data instead of device as argument" and "fpga: dfl: refactor
functions to take/return feature device data". The other patches
address auxiliary, functional and non-functional concerns, such that
the final patch "fpga: dfl: fix kernel warning on port release/assign
for SRIOV" is now as small as feasible and focuses on the core change.
Thanks,
Peter
>
> Thanks,
> Yilun
>
> >
> > 1. Replace function argument `struct device *dev` with `struct
> > dfl_feature_platform_data *pdata` as needed.
> > 2. #define dfl_feature_dev_data dfl_feature_platform_data and massive
> > pdata -> fdata replacement.
> > 3. Remove #define dfl_feature_dev_data, factor out dfl_feature_dev_data
> > from dfl_feature_platform_data, and destroy platform device on release.
> >
> > Thanks,
> > Peter
next prev parent reply other threads:[~2024-09-19 21:49 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 23:39 [RFC PATCH v2 0/9] " Peter Colberg
2024-04-09 23:39 ` [RFC PATCH v2 1/9] fpga: dfl: alias dfl_feature_dev_data to dfl_feature_platform_data Peter Colberg
2024-04-09 23:39 ` [RFC PATCH v2 2/9] fpga: dfl: migrate AFU DMA region management driver to dfl_feature_dev_data Peter Colberg
2024-04-23 9:01 ` Xu Yilun
2024-09-19 21:03 ` Colberg, Peter
2024-04-09 23:39 ` [RFC PATCH v2 3/9] fpga: dfl: migrate AFU MMIO " Peter Colberg
2024-04-09 23:56 ` Colberg, Peter
2024-04-23 14:22 ` Xu Yilun
2024-09-19 21:22 ` Colberg, Peter
2024-04-09 23:39 ` [RFC PATCH v2 4/9] fpga: dfl: migrate FPGA Management Engine " Peter Colberg
2024-04-23 9:38 ` Xu Yilun
2024-09-19 21:35 ` Colberg, Peter
2024-04-09 23:39 ` [RFC PATCH v2 5/9] fpga: dfl: migrate FME partial reconfiguration " Peter Colberg
2024-04-09 23:39 ` [RFC PATCH v2 6/9] fpga: dfl: migrate Accelerated Function Unit " Peter Colberg
2024-04-23 14:31 ` Xu Yilun
2024-09-19 21:39 ` Colberg, Peter
2024-04-09 23:39 ` [RFC PATCH v2 7/9] fpga: dfl: migrate DFL support header " Peter Colberg
2024-04-09 23:39 ` [RFC PATCH v2 8/9] fpga: dfl: migrate dfl_get_feature_by_id() " Peter Colberg
2024-04-23 15:16 ` Xu Yilun
2024-09-19 21:42 ` Colberg, Peter
2024-04-09 23:39 ` [RFC PATCH v2 9/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV Peter Colberg
2024-04-23 15:36 ` Xu Yilun
2024-06-12 22:16 ` Colberg, Peter
2024-06-14 2:44 ` Xu Yilun
2024-09-19 21:49 ` Colberg, Peter [this message]
2024-04-23 8:27 ` [RFC PATCH v2 0/9] " Xu Yilun
2024-09-19 21:52 ` Colberg, Peter
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=21e1306333d397858a906bb17bc3a6908b18be22.camel@intel.com \
--to=peter.colberg@intel.com \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marpagan@redhat.com \
--cc=matthew.gerlach@linux.intel.com \
--cc=mdf@kernel.org \
--cc=russ.weight@linux.dev \
--cc=russell.h.weight@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
--cc=yilun.xu@linux.intel.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®