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>,
"matthew.gerlach@linux.intel.com"
<matthew.gerlach@linux.intel.com>
Subject: Re: [PATCH v3 7/9] fpga: dfl: store FIU type in feature platform data
Date: Fri, 25 Oct 2024 22:46:06 +0000 [thread overview]
Message-ID: <a8e0600dff8c0ab296756051fc40baf05e8c9613.camel@intel.com> (raw)
In-Reply-To: <ZvJtg/IFmZAiaJBT@yilunxu-OptiPlex-7050>
On Tue, 2024-09-24 at 15:42 +0800, Xu Yilun wrote:
> On Thu, Sep 19, 2024 at 04:34:28PM -0400, Peter Colberg wrote:
> > Remove the local function feature_dev_id_type() in favour of persisting
> > the FIU type in struct dfl_feature_platform_data. Add type to struct
> > build_feature_devs_info and drop argument to build_info_create_dev().
> >
> > Signed-off-by: Peter Colberg <peter.colberg@intel.com>
> > Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> > ---
> > drivers/fpga/dfl.c | 57 ++++++++++++++++++++++------------------------
> > drivers/fpga/dfl.h | 3 +++
> > 2 files changed, 30 insertions(+), 30 deletions(-)
> >
> > diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> > index e644eb9fde39..9610ef1ec2ff 100644
> > --- a/drivers/fpga/dfl.c
> > +++ b/drivers/fpga/dfl.c
> > @@ -119,17 +119,6 @@ static void dfl_id_free(enum dfl_id_type type, int id)
> > mutex_unlock(&dfl_id_mutex);
> > }
> >
> > -static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev)
> > -{
> > - int i;
> > -
> > - for (i = 0; i < ARRAY_SIZE(dfl_devs); i++)
> > - if (!strcmp(dfl_devs[i].name, pdev->name))
> > - return i;
> > -
> > - return DFL_ID_MAX;
> > -}
> > -
> > static enum dfl_id_type dfh_id_to_type(u16 id)
> > {
> > int i;
> > @@ -379,7 +368,7 @@ dfl_dev_add(struct dfl_feature_platform_data *pdata,
> > if (ret)
> > goto put_dev;
> >
> > - ddev->type = feature_dev_id_type(pdev);
> > + ddev->type = pdata->type;
> > ddev->feature_id = feature->id;
> > ddev->revision = feature->revision;
> > ddev->dfh_version = feature->dfh_version;
> > @@ -693,6 +682,7 @@ EXPORT_SYMBOL_GPL(dfl_fpga_dev_ops_unregister);
> > * @irq_table: Linux IRQ numbers for all irqs, indexed by local irq index of
> > * this device.
> > * @feature_dev: current feature device.
> > + * @type: the current FIU type.
> > * @ioaddr: header register region address of current FIU in enumeration.
> > * @start: register resource start of current FIU.
> > * @len: max register resource length of current FIU.
> > @@ -706,6 +696,7 @@ struct build_feature_devs_info {
> > int *irq_table;
> >
> > struct platform_device *feature_dev;
> > + enum dfl_id_type type;
> > void __iomem *ioaddr;
> > resource_size_t start;
> > resource_size_t len;
> > @@ -752,13 +743,12 @@ static void dfl_fpga_cdev_add_port_data(struct dfl_fpga_cdev *cdev,
> > static struct dfl_feature_platform_data *
> > binfo_create_feature_dev_data(struct build_feature_devs_info *binfo)
> > {
> > + enum dfl_id_type type = binfo->type;
> > struct platform_device *fdev = binfo->feature_dev;
> > struct dfl_feature_platform_data *pdata;
> > struct dfl_feature_info *finfo, *p;
> > - enum dfl_id_type type;
>
> Move this line up breaks the reverse Xmas tree, seems no need.
This has been done in the revised patch "fpga: dfl: store FIU type in
feature platform data".
>
> > int ret, index = 0, res_idx = 0;
> >
> > - type = feature_dev_id_type(fdev);
> > if (WARN_ON_ONCE(type >= DFL_ID_MAX))
> > return ERR_PTR(-EINVAL);
> >
> > @@ -773,6 +763,7 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo)
> > return ERR_PTR(-ENOMEM);
> >
> > pdata->dev = fdev;
> > + pdata->type = type;
> > pdata->num = binfo->feature_num;
> > pdata->dfl_cdev = binfo->cdev;
> > pdata->id = FEATURE_DEV_ID_UNUSED;
> > @@ -861,14 +852,11 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo)
> > }
> >
> > static int
> > -build_info_create_dev(struct build_feature_devs_info *binfo,
> > - enum dfl_id_type type)
> > +build_info_create_dev(struct build_feature_devs_info *binfo)
> > {
> > + enum dfl_id_type type = binfo->type;
> > struct platform_device *fdev;
> >
> > - if (type >= DFL_ID_MAX)
> > - return -EINVAL;
> > -
> > /*
> > * we use -ENODEV as the initialization indicator which indicates
> > * whether the id need to be reclaimed
> > @@ -905,7 +893,7 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo)
> > if (ret)
> > return ret;
> >
> > - if (feature_dev_id_type(binfo->feature_dev) == PORT_ID)
> > + if (binfo->type == PORT_ID)
> > dfl_fpga_cdev_add_port_data(binfo->cdev, pdata);
> > else
> > binfo->cdev->fme_dev = get_device(&binfo->feature_dev->dev);
> > @@ -919,6 +907,9 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo)
> > */
> > binfo->feature_dev = NULL;
> >
> > + /* reset the binfo for next FIU */
> > + binfo->type = DFL_ID_MAX;
> > +
> > return 0;
> > }
> >
> > @@ -931,8 +922,7 @@ static void build_info_free(struct build_feature_devs_info *binfo)
> > * build_info_create_dev()
> > */
> > if (binfo->feature_dev && binfo->feature_dev->id >= 0) {
> > - dfl_id_free(feature_dev_id_type(binfo->feature_dev),
> > - binfo->feature_dev->id);
> > + dfl_id_free(binfo->type, binfo->feature_dev->id);
> >
> > list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) {
> > list_del(&finfo->node);
> > @@ -1030,7 +1020,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
> > * Instead, features with interrupt functionality provide
> > * the information in feature specific registers.
> > */
> > - type = feature_dev_id_type(binfo->feature_dev);
> > + type = binfo->type;
> > if (type == PORT_ID) {
> > switch (fid) {
> > case PORT_FEATURE_ID_UINT:
> > @@ -1222,7 +1212,7 @@ static int parse_feature_port_afu(struct build_feature_devs_info *binfo,
> > return create_feature_instance(binfo, ofst, size, FEATURE_ID_AFU);
> > }
> >
> > -#define is_feature_dev_detected(binfo) (!!(binfo)->feature_dev)
> > +#define is_feature_dev_detected(binfo) ((binfo)->type != DFL_ID_MAX)
>
> Seems too early to make this change. The 2 fields don't always align in
> this phase ..
>
> >
> > static int parse_feature_afu(struct build_feature_devs_info *binfo,
> > resource_size_t ofst)
> > @@ -1232,7 +1222,7 @@ static int parse_feature_afu(struct build_feature_devs_info *binfo,
> > return -EINVAL;
> > }
> >
> > - switch (feature_dev_id_type(binfo->feature_dev)) {
> > + switch (binfo->type) {
> > case PORT_ID:
> > return parse_feature_port_afu(binfo, ofst);
> > default:
> > @@ -1278,6 +1268,7 @@ static void build_info_complete(struct build_feature_devs_info *binfo)
> > static int parse_feature_fiu(struct build_feature_devs_info *binfo,
> > resource_size_t ofst)
> > {
> > + enum dfl_id_type type;
> > int ret = 0;
> > u32 offset;
> > u16 id;
> > @@ -1299,8 +1290,14 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo,
> > v = readq(binfo->ioaddr + DFH);
> > id = FIELD_GET(DFH_ID, v);
> >
> > + type = dfh_id_to_type(id);
> > + if (type >= DFL_ID_MAX)
> > + return -EINVAL;
> > +
> > + binfo->type = type;
> > +
> > /* create platform device for dfl feature dev */
> > - ret = build_info_create_dev(binfo, dfh_id_to_type(id));
> > + ret = build_info_create_dev(binfo);
>
> .. like here, binfo->type is valid but binfo->feature_dev may not.
>
> Thanks,
> Yilun
The conversion of is_feature_dev_detected() to use the FIU type has
been moved to a new patch "fpga: dfl: convert is_feature_dev_detected()
to use FIU type" later in the series.
Thanks,
Peter
next prev parent reply other threads:[~2024-10-25 22:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-19 20:34 [PATCH v3 0/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV Peter Colberg
2024-09-19 20:34 ` [PATCH v3 1/9] fpga: dfl: omit unneeded argument pdata from dfl_feature_instance_init() Peter Colberg
2024-09-19 20:34 ` [PATCH v3 2/9] fpga: dfl: omit unneeded null pointer check from {afu,fme}_open() Peter Colberg
2024-09-24 6:28 ` Xu Yilun
2024-10-25 22:39 ` Colberg, Peter
2024-09-24 6:41 ` Xu Yilun
2024-10-25 22:40 ` Colberg, Peter
2024-09-19 20:34 ` [PATCH v3 3/9] fpga: dfl: afu: use parent device to log errors on port enable/disable Peter Colberg
2024-09-19 20:34 ` [PATCH v3 4/9] fpga: dfl: afu: define local pointer to feature device Peter Colberg
2024-09-19 20:34 ` [PATCH v3 5/9] fpga: dfl: pass feature platform data instead of device as argument Peter Colberg
2024-09-19 20:34 ` [PATCH v3 6/9] fpga: dfl: factor out feature data creation from build_info_commit_dev() Peter Colberg
2024-09-24 7:15 ` Xu Yilun
2024-10-25 22:43 ` Colberg, Peter
2024-09-19 20:34 ` [PATCH v3 7/9] fpga: dfl: store FIU type in feature platform data Peter Colberg
2024-09-24 7:42 ` Xu Yilun
2024-10-25 22:46 ` Colberg, Peter [this message]
2024-09-19 20:34 ` [PATCH v3 8/9] fpga: dfl: refactor functions to take/return feature device data Peter Colberg
2024-09-19 20:34 ` [PATCH v3 9/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV Peter Colberg
2024-09-24 9:01 ` Xu Yilun
2024-10-25 22:54 ` Colberg, Peter
2024-10-26 1: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=a8e0600dff8c0ab296756051fc40baf05e8c9613.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=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®