From: Peter Colberg <peter.colberg@intel.com>
To: Wu Hao <hao.wu@intel.com>, Tom Rix <trix@redhat.com>,
Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Russ Weight <russ.weight@linux.dev>,
Marco Pagani <marpagan@redhat.com>,
Matthew Gerlach <matthew.gerlach@linux.intel.com>,
Basheer Ahmed Muddebihal
<basheer.ahmed.muddebihal@linux.intel.com>,
Russ Weight <russell.h.weight@intel.com>,
Peter Colberg <peter.colberg@intel.com>
Subject: [PATCH v5 18/18] fpga: dfl: destroy/recreate feature platform device on port release/assign
Date: Tue, 19 Nov 2024 20:10:34 -0500 [thread overview]
Message-ID: <20241120011035.230574-19-peter.colberg@intel.com> (raw)
In-Reply-To: <20241120011035.230574-1-peter.colberg@intel.com>
From: Xu Yilun <yilun.xu@intel.com>
Now that the internal DFL APIs have been converted to consume DFL
enumeration info from a separate structure, dfl_feature_dev_data, which
lifetime is independent of the feature device, proceed to completely
destroy and recreate the feature platform device on port release and
assign, respectively. This resolves a longstanding issue in the use of
platform_device_add(), which states to "not call this routine more than
once for any device structure" and which used to print a kernel warning.
The function feature_dev_unregister() resets the device pointer in the
feature data to NULL to signal that the feature platform device has been
destroyed. This substitutes the previous device_is_registered() checks.
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>
Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Reviewed-by: Basheer Ahmed Muddebihal <basheer.ahmed.muddebihal@linux.intel.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
---
Changes since v4:
- No changes.
Changes since v3:
- New patch extracted from last patch of v3 series.
---
drivers/fpga/dfl.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index d4b8df4e0ebc..b01fb446bc7c 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -1630,21 +1630,10 @@ EXPORT_SYMBOL_GPL(dfl_fpga_feature_devs_enumerate);
*/
void dfl_fpga_feature_devs_remove(struct dfl_fpga_cdev *cdev)
{
- struct dfl_feature_dev_data *fdata, *ptmp;
-
mutex_lock(&cdev->lock);
if (cdev->fme_dev)
put_device(cdev->fme_dev);
- list_for_each_entry_safe(fdata, ptmp, &cdev->port_dev_list, node) {
- struct platform_device *port_dev = fdata->dev;
-
- /* remove released ports */
- if (!device_is_registered(&port_dev->dev))
- platform_device_put(port_dev);
-
- list_del(&fdata->node);
- }
mutex_unlock(&cdev->lock);
remove_feature_devs(cdev);
@@ -1724,7 +1713,7 @@ int dfl_fpga_cdev_release_port(struct dfl_fpga_cdev *cdev, int port_id)
if (!fdata)
goto unlock_exit;
- if (!device_is_registered(&fdata->dev->dev)) {
+ if (!fdata->dev) {
ret = -EBUSY;
goto unlock_exit;
}
@@ -1735,7 +1724,7 @@ int dfl_fpga_cdev_release_port(struct dfl_fpga_cdev *cdev, int port_id)
if (ret)
goto unlock_exit;
- platform_device_del(fdata->dev);
+ feature_dev_unregister(fdata);
cdev->released_port_num++;
unlock_exit:
mutex_unlock(&cdev->lock);
@@ -1765,12 +1754,12 @@ int dfl_fpga_cdev_assign_port(struct dfl_fpga_cdev *cdev, int port_id)
if (!fdata)
goto unlock_exit;
- if (device_is_registered(&fdata->dev->dev)) {
+ if (fdata->dev) {
ret = -EBUSY;
goto unlock_exit;
}
- ret = platform_device_add(fdata->dev);
+ ret = feature_dev_register(fdata);
if (ret)
goto unlock_exit;
@@ -1820,7 +1809,7 @@ void dfl_fpga_cdev_config_ports_pf(struct dfl_fpga_cdev *cdev)
mutex_lock(&cdev->lock);
list_for_each_entry(fdata, &cdev->port_dev_list, node) {
- if (device_is_registered(&fdata->dev->dev))
+ if (fdata->dev)
continue;
config_port_pf_mode(cdev->fme_dev, fdata->id);
@@ -1857,7 +1846,7 @@ int dfl_fpga_cdev_config_ports_vf(struct dfl_fpga_cdev *cdev, int num_vfs)
}
list_for_each_entry(fdata, &cdev->port_dev_list, node) {
- if (device_is_registered(&fdata->dev->dev))
+ if (fdata->dev)
continue;
config_port_vf_mode(cdev->fme_dev, fdata->id);
--
2.47.0
next prev parent reply other threads:[~2024-11-20 1:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 1:10 [PATCH v5 00/18] fpga: dfl: fix kernel warning on port release/assign for SRIOV Peter Colberg
2024-11-20 1:10 ` [PATCH v5 01/18] fpga: dfl: omit unneeded argument pdata from dfl_feature_instance_init() Peter Colberg
2024-11-20 1:10 ` [PATCH v5 02/18] fpga: dfl: return platform data from dfl_fpga_inode_to_feature_dev_data() Peter Colberg
2024-11-20 1:10 ` [PATCH v5 03/18] fpga: dfl: afu: use parent device to log errors on port enable/disable Peter Colberg
2024-11-20 1:10 ` [PATCH v5 04/18] fpga: dfl: afu: define local pointer to feature device Peter Colberg
2024-11-20 1:10 ` [PATCH v5 05/18] fpga: dfl: pass feature platform data instead of device as argument Peter Colberg
2024-11-20 1:10 ` [PATCH v5 06/18] fpga: dfl: factor out feature data creation from build_info_commit_dev() Peter Colberg
2024-11-20 1:10 ` [PATCH v5 07/18] fpga: dfl: store FIU type in feature platform data Peter Colberg
2024-11-20 1:10 ` [PATCH v5 08/18] fpga: dfl: refactor internal DFL APIs to take/return feature device data Peter Colberg
2024-11-20 1:10 ` [PATCH v5 09/18] fpga: dfl: factor out feature device registration Peter Colberg
2024-11-20 1:10 ` [PATCH v5 10/18] fpga: dfl: factor out feature device data from platform device data Peter Colberg
2024-11-20 1:10 ` [PATCH v5 11/18] fpga: dfl: convert features from flexible array member to separate array Peter Colberg
2024-11-20 1:10 ` [PATCH v5 12/18] fpga: dfl: store MMIO resources in feature device data Peter Colberg
2024-11-20 1:10 ` [PATCH v5 13/18] fpga: dfl: store platform device name " Peter Colberg
2024-11-20 1:10 ` [PATCH v5 14/18] fpga: dfl: store platform device id " Peter Colberg
2024-11-20 1:10 ` [PATCH v5 15/18] fpga: dfl: allocate platform device after " Peter Colberg
2024-11-20 1:10 ` [PATCH v5 16/18] fpga: dfl: remove unneeded function build_info_create_dev() Peter Colberg
2024-11-20 1:10 ` [PATCH v5 17/18] fpga: dfl: drop unneeded get_device() and put_device() of feature device Peter Colberg
2024-11-20 1:10 ` Peter Colberg [this message]
2024-12-10 9:07 ` [PATCH v5 00/18] fpga: dfl: fix kernel warning on port release/assign for SRIOV Xu Yilun
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=20241120011035.230574-19-peter.colberg@intel.com \
--to=peter.colberg@intel.com \
--cc=basheer.ahmed.muddebihal@linux.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 \
/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®