linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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: [RFC PATCH v2 4/9] fpga: dfl: migrate FPGA Management Engine driver to dfl_feature_dev_data
Date: Thu, 19 Sep 2024 21:35:48 +0000	[thread overview]
Message-ID: <bd5bf25938ec45815dcbd312522bcafe84e6f05e.camel@intel.com> (raw)
In-Reply-To: <ZieBnQBDGgowf+y7@yilunxu-OptiPlex-7050>

On Tue, 2024-04-23 at 17:38 +0800, Xu Yilun wrote:
> On Tue, Apr 09, 2024 at 07:39:37PM -0400, Peter Colberg wrote:
> > This change separates out most of the symbol name changes required by this
> > patch series for the file: drivers/fpga/dfl-fme-main.c. This is done to
> > split a single monolithic change into multiple, smaller patches at the
> > request of the maintainer.
> > 
> > Signed-off-by: Peter Colberg <peter.colberg@intel.com>
> > ---
> > v2:
> > - Split monolithic patch into series at request of maintainer
> > - Change fme_hdr_ioctl_*() to receive dfl_feature_dev_data instead of
> >   dfl_feature_platform_data.
> > - Remove unused local variable pdata in fme_dev_{init,destroy}().
> > ---
> >  drivers/fpga/dfl-fme-main.c | 68 ++++++++++++++++++++-----------------
> >  1 file changed, 36 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
> > index 864924f68f5e..7f119b09b54e 100644
> > --- a/drivers/fpga/dfl-fme-main.c
> > +++ b/drivers/fpga/dfl-fme-main.c
> > @@ -135,10 +135,10 @@ static const struct attribute_group fme_hdr_group = {
> >  	.attrs = fme_hdr_attrs,
> >  };
> >  
> > -static long fme_hdr_ioctl_release_port(struct dfl_feature_platform_data *pdata,
> > +static long fme_hdr_ioctl_release_port(struct dfl_feature_dev_data *fdata,
> >  				       unsigned long arg)
> >  {
> > -	struct dfl_fpga_cdev *cdev = pdata->dfl_cdev;
> > +	struct dfl_fpga_cdev *cdev = fdata->dfl_cdev;
> >  	int port_id;
> >  
> >  	if (get_user(port_id, (int __user *)arg))
> > @@ -147,10 +147,10 @@ static long fme_hdr_ioctl_release_port(struct dfl_feature_platform_data *pdata,
> >  	return dfl_fpga_cdev_release_port(cdev, port_id);
> >  }
> >  
> > -static long fme_hdr_ioctl_assign_port(struct dfl_feature_platform_data *pdata,
> > +static long fme_hdr_ioctl_assign_port(struct dfl_feature_dev_data *fdata,
> >  				      unsigned long arg)
> >  {
> > -	struct dfl_fpga_cdev *cdev = pdata->dfl_cdev;
> > +	struct dfl_fpga_cdev *cdev = fdata->dfl_cdev;
> >  	int port_id;
> >  
> >  	if (get_user(port_id, (int __user *)arg))
> > @@ -163,13 +163,13 @@ static long fme_hdr_ioctl(struct platform_device *pdev,
> >  			  struct dfl_feature *feature,
> >  			  unsigned int cmd, unsigned long arg)
> >  {
> > -	struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
> 
> Maybe firstly make a patch to:
> 
>   #define to_dfl_feature_platform_data	dev_get_platdata
> 
> And s/to_dfl_feature_platform_data/dev_get_platdata
> 
> Then we could do replacements in this patch more friendly.

I have combined the pdata -> fdata replacements into a single patch
"fpga: dfl: refactor functions to take/return feature device data",
which adds two aliases and refactors the code accordingly:

#define dfl_feature_dev_data dfl_feature_platform_data
#define to_dfl_feature_dev_data dev_get_platdata

> 
> > +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(&pdev->dev);
> >  
> >  	switch (cmd) {
> >  	case DFL_FPGA_FME_PORT_RELEASE:
> > -		return fme_hdr_ioctl_release_port(pdata, arg);
> > +		return fme_hdr_ioctl_release_port(fdata, arg);
> >  	case DFL_FPGA_FME_PORT_ASSIGN:
> > -		return fme_hdr_ioctl_assign_port(pdata, arg);
> > +		return fme_hdr_ioctl_assign_port(fdata, arg);
> >  	}
> >  
> >  	return -ENODEV;
> > @@ -411,14 +411,14 @@ static int power_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> >  static int power_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
> >  			     u32 attr, int channel, long val)
> >  {
> > -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev->parent);
> > +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
> >  	struct dfl_feature *feature = dev_get_drvdata(dev);
> >  	int ret = 0;
> >  	u64 v;
> >  
> >  	val = clamp_val(val / MICRO, 0, PWR_THRESHOLD_MAX);
> >  
> > -	mutex_lock(&pdata->lock);
> > +	mutex_lock(&fdata->lock);
> >  
> >  	switch (attr) {
> >  	case hwmon_power_max:
> > @@ -438,7 +438,7 @@ static int power_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
> >  		break;
> >  	}
> >  
> > -	mutex_unlock(&pdata->lock);
> > +	mutex_unlock(&fdata->lock);
> >  
> >  	return ret;
> >  }
> > @@ -589,7 +589,7 @@ static struct dfl_feature_driver fme_feature_drvs[] = {
> >  	},
> >  };
> >  
> > -static long fme_ioctl_check_extension(struct dfl_feature_platform_data *pdata,
> > +static long fme_ioctl_check_extension(struct dfl_feature_dev_data *fdata,
> >  				      unsigned long arg)
> >  {
> >  	/* No extension support for now */
> > @@ -600,19 +600,21 @@ static int fme_open(struct inode *inode, struct file *filp)
> >  {
> >  	struct platform_device *fdev = dfl_fpga_inode_to_feature_dev(inode);
> >  	struct dfl_feature_platform_data *pdata = dev_get_platdata(&fdev->dev);
> 
> Why not do the same replacement here?

This has been prepared in the patch "fpga: dfl: omit unneeded null
pointer check from {afu,fme}_open()" followed by the pdata -> fdata
replacement in "fpga: dfl: refactor functions to take/return feature
device data".

> 
> > +	struct dfl_feature_dev_data *fdata;
> >  	int ret;
> >  
> >  	if (WARN_ON(!pdata))
> >  		return -ENODEV;
> >  
> > -	mutex_lock(&pdata->lock);
> > -	ret = dfl_feature_dev_use_begin(pdata, filp->f_flags & O_EXCL);
> > +	fdata = pdata;
> > +	mutex_lock(&fdata->lock);
> > +	ret = dfl_feature_dev_use_begin(fdata, filp->f_flags & O_EXCL);
> >  	if (!ret) {
> >  		dev_dbg(&fdev->dev, "Device File Opened %d Times\n",
> > -			dfl_feature_dev_use_count(pdata));
> > +			dfl_feature_dev_use_count(fdata));
> >  		filp->private_data = pdata;
> >  	}
> > -	mutex_unlock(&pdata->lock);
> > +	mutex_unlock(&fdata->lock);
> >  
> >  	return ret;
> >  }
> > @@ -620,19 +622,20 @@ static int fme_open(struct inode *inode, struct file *filp)
> >  static int fme_release(struct inode *inode, struct file *filp)
> >  {
> >  	struct dfl_feature_platform_data *pdata = filp->private_data;
> > -	struct platform_device *pdev = pdata->dev;
> > +	struct dfl_feature_dev_data *fdata = pdata;
> 
> ditto.

This has been done in "fpga: dfl: refactor functions to take/return
feature device data".
> 
> > +	struct platform_device *pdev = fdata->dev;
> >  	struct dfl_feature *feature;
> >  
> >  	dev_dbg(&pdev->dev, "Device File Release\n");
> >  
> > -	mutex_lock(&pdata->lock);
> > -	dfl_feature_dev_use_end(pdata);
> > +	mutex_lock(&fdata->lock);
> > +	dfl_feature_dev_use_end(fdata);
> >  
> > -	if (!dfl_feature_dev_use_count(pdata))
> > -		dfl_fpga_dev_for_each_feature(pdata, feature)
> > +	if (!dfl_feature_dev_use_count(fdata))
> > +		dfl_fpga_dev_for_each_feature(fdata, feature)
> >  			dfl_fpga_set_irq_triggers(feature, 0,
> >  						  feature->nr_irqs, NULL);
> > -	mutex_unlock(&pdata->lock);
> > +	mutex_unlock(&fdata->lock);
> >  
> >  	return 0;
> >  }
> > @@ -640,7 +643,8 @@ static int fme_release(struct inode *inode, struct file *filp)
> >  static long fme_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >  {
> >  	struct dfl_feature_platform_data *pdata = filp->private_data;
> > -	struct platform_device *pdev = pdata->dev;
> > +	struct dfl_feature_dev_data *fdata = pdata;
> 
> ditto

This has been done in "fpga: dfl: refactor functions to take/return
feature device data".

Thanks,
Peter

> 
> > +	struct platform_device *pdev = fdata->dev;
> >  	struct dfl_feature *f;
> >  	long ret;
> >  
> > @@ -650,7 +654,7 @@ static long fme_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >  	case DFL_FPGA_GET_API_VERSION:
> >  		return DFL_FPGA_API_VERSION;
> >  	case DFL_FPGA_CHECK_EXTENSION:
> > -		return fme_ioctl_check_extension(pdata, arg);
> > +		return fme_ioctl_check_extension(fdata, arg);
> >  	default:
> >  		/*
> >  		 * Let sub-feature's ioctl function to handle the cmd.
> > @@ -658,7 +662,7 @@ static long fme_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >  		 * handled in this sub feature, and returns 0 or other
> >  		 * error code if cmd is handled.
> >  		 */
> > -		dfl_fpga_dev_for_each_feature(pdata, f) {
> > +		dfl_fpga_dev_for_each_feature(fdata, f) {
> >  			if (f->ops && f->ops->ioctl) {
> >  				ret = f->ops->ioctl(pdev, f, cmd, arg);
> >  				if (ret != -ENODEV)
> > @@ -672,27 +676,27 @@ static long fme_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >  
> >  static int fme_dev_init(struct platform_device *pdev)
> >  {
> > -	struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
> > +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(&pdev->dev);
> >  	struct dfl_fme *fme;
> >  
> >  	fme = devm_kzalloc(&pdev->dev, sizeof(*fme), GFP_KERNEL);
> >  	if (!fme)
> >  		return -ENOMEM;
> >  
> > -	mutex_lock(&pdata->lock);
> > -	dfl_fpga_pdata_set_private(pdata, fme);
> > -	mutex_unlock(&pdata->lock);
> > +	mutex_lock(&fdata->lock);
> > +	dfl_fpga_fdata_set_private(fdata, fme);
> > +	mutex_unlock(&fdata->lock);
> >  
> >  	return 0;
> >  }
> >  
> >  static void fme_dev_destroy(struct platform_device *pdev)
> >  {
> > -	struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
> > +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(&pdev->dev);
> >  
> > -	mutex_lock(&pdata->lock);
> > -	dfl_fpga_pdata_set_private(pdata, NULL);
> > -	mutex_unlock(&pdata->lock);
> > +	mutex_lock(&fdata->lock);
> > +	dfl_fpga_fdata_set_private(fdata, NULL);
> > +	mutex_unlock(&fdata->lock);
> >  }
> >  
> >  static const struct file_operations fme_fops = {
> > -- 
> > 2.44.0
> > 
> > 


  reply	other threads:[~2024-09-19 21:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 23:39 [RFC PATCH v2 0/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV 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 [this message]
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
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=bd5bf25938ec45815dcbd312522bcafe84e6f05e.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;
as well as URLs for NNTP newsgroup(s).