Linux-FPGA Archive mirror
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@linux.intel.com>
To: Peter Colberg <peter.colberg@intel.com>
Cc: 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,
	Russ Weight <russ.weight@linux.dev>,
	Marco Pagani <marpagan@redhat.com>,
	Matthew Gerlach <matthew.gerlach@linux.intel.com>
Subject: Re: [RFC PATCH v2 8/9] fpga: dfl: migrate dfl_get_feature_by_id() to dfl_feature_dev_data
Date: Tue, 23 Apr 2024 23:16:31 +0800	[thread overview]
Message-ID: <ZifQz/QJvYpFljMv@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20240409233942.828440-9-peter.colberg@intel.com>

On Tue, Apr 09, 2024 at 07:39:41PM -0400, Peter Colberg wrote:
> This change separates out most of the symbol name changes required by this
> patch series for the function: dfl_get_feature_by_id(). 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
> ---
>  drivers/fpga/dfl-afu-error.c |  59 +++++++------
>  drivers/fpga/dfl-afu-main.c  | 166 ++++++++++++++++++-----------------
>  drivers/fpga/dfl-afu.h       |  26 +++---
>  drivers/fpga/dfl-fme-error.c |  98 +++++++++++----------
>  drivers/fpga/dfl-fme-main.c  |  18 ++--
>  drivers/fpga/dfl-fme-pr.c    |   6 +-
>  drivers/fpga/dfl.c           |   3 +-
>  drivers/fpga/dfl.h           |  13 ++-
>  8 files changed, 203 insertions(+), 186 deletions(-)
> 
> diff --git a/drivers/fpga/dfl-afu-error.c b/drivers/fpga/dfl-afu-error.c
> index ab7be6217368..0f392d1f6d45 100644
> --- a/drivers/fpga/dfl-afu-error.c
> +++ b/drivers/fpga/dfl-afu-error.c
> @@ -28,37 +28,36 @@
>  #define ERROR_MASK		GENMASK_ULL(63, 0)
>  
>  /* mask or unmask port errors by the error mask register. */
> -static void __afu_port_err_mask(struct device *dev, bool mask)
> +static void __afu_port_err_mask(struct dfl_feature_dev_data *fdata, bool mask)

Maybe first replace all "struct device *dev" arguments with "struct
dfl_feature_platform data *pdata", then you could do simple
pdata->fdata replacement the same as other patches.

>  {
>  	void __iomem *base;
>  
> -	base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
> +	base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_ERROR);
>  
>  	writeq(mask ? ERROR_MASK : 0, base + PORT_ERROR_MASK);
>  }
>  
>  static void afu_port_err_mask(struct device *dev, bool mask)
>  {
> -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
> +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
>  
> -	mutex_lock(&pdata->lock);
> -	__afu_port_err_mask(dev, mask);
> -	mutex_unlock(&pdata->lock);
> +	mutex_lock(&fdata->lock);
> +	__afu_port_err_mask(fdata, mask);
> +	mutex_unlock(&fdata->lock);
>  }
>  
>  /* clear port errors. */
>  static int afu_port_err_clear(struct device *dev, u64 err)
>  {
> -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
> -	struct platform_device *pdev = to_platform_device(dev);
> +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
>  	void __iomem *base_err, *base_hdr;
>  	int enable_ret = 0, ret = -EBUSY;
>  	u64 v;
>  
> -	base_err = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
> -	base_hdr = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
> +	base_err = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_ERROR);
> +	base_hdr = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_HEADER);
>  
> -	mutex_lock(&pdata->lock);
> +	mutex_lock(&fdata->lock);
>  
>  	/*
>  	 * clear Port Errors
> @@ -80,12 +79,12 @@ static int afu_port_err_clear(struct device *dev, u64 err)
>  	}
>  
>  	/* Halt Port by keeping Port in reset */
> -	ret = __afu_port_disable(pdev);
> +	ret = __afu_port_disable(fdata);
>  	if (ret)
>  		goto done;
>  
>  	/* Mask all errors */
> -	__afu_port_err_mask(dev, true);
> +	__afu_port_err_mask(fdata, true);
>  
>  	/* Clear errors if err input matches with current port errors.*/
>  	v = readq(base_err + PORT_ERROR);
> @@ -102,28 +101,28 @@ static int afu_port_err_clear(struct device *dev, u64 err)
>  	}
>  
>  	/* Clear mask */
> -	__afu_port_err_mask(dev, false);
> +	__afu_port_err_mask(fdata, false);
>  
>  	/* Enable the Port by clearing the reset */
> -	enable_ret = __afu_port_enable(pdev);
> +	enable_ret = __afu_port_enable(fdata);
>  
>  done:
> -	mutex_unlock(&pdata->lock);
> +	mutex_unlock(&fdata->lock);
>  	return enable_ret ? enable_ret : ret;
>  }
>  
>  static ssize_t errors_show(struct device *dev, struct device_attribute *attr,
>  			   char *buf)
>  {
> -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
> +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
>  	void __iomem *base;
>  	u64 error;
>  
> -	base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
> +	base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_ERROR);
>  
> -	mutex_lock(&pdata->lock);
> +	mutex_lock(&fdata->lock);
>  	error = readq(base + PORT_ERROR);
> -	mutex_unlock(&pdata->lock);
> +	mutex_unlock(&fdata->lock);
>  
>  	return sprintf(buf, "0x%llx\n", (unsigned long long)error);
>  }
> @@ -146,15 +145,15 @@ static DEVICE_ATTR_RW(errors);
>  static ssize_t first_error_show(struct device *dev,
>  				struct device_attribute *attr, char *buf)
>  {
> -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
> +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
>  	void __iomem *base;
>  	u64 error;
>  
> -	base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
> +	base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_ERROR);
>  
> -	mutex_lock(&pdata->lock);
> +	mutex_lock(&fdata->lock);
>  	error = readq(base + PORT_FIRST_ERROR);
> -	mutex_unlock(&pdata->lock);
> +	mutex_unlock(&fdata->lock);
>  
>  	return sprintf(buf, "0x%llx\n", (unsigned long long)error);
>  }
> @@ -164,16 +163,16 @@ static ssize_t first_malformed_req_show(struct device *dev,
>  					struct device_attribute *attr,
>  					char *buf)
>  {
> -	struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
> +	struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev);
>  	void __iomem *base;
>  	u64 req0, req1;
>  
> -	base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
> +	base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_ERROR);
>  
> -	mutex_lock(&pdata->lock);
> +	mutex_lock(&fdata->lock);
>  	req0 = readq(base + PORT_MALFORMED_REQ0);
>  	req1 = readq(base + PORT_MALFORMED_REQ1);
> -	mutex_unlock(&pdata->lock);
> +	mutex_unlock(&fdata->lock);
>  
>  	return sprintf(buf, "0x%016llx%016llx\n",
>  		       (unsigned long long)req1, (unsigned long long)req0);
> @@ -191,12 +190,14 @@ static umode_t port_err_attrs_visible(struct kobject *kobj,
>  				      struct attribute *attr, int n)
>  {
>  	struct device *dev = kobj_to_dev(kobj);
> +	struct dfl_feature_dev_data *fdata;
>  
> +	fdata = to_dfl_feature_dev_data(dev);
>  	/*
>  	 * sysfs entries are visible only if related private feature is
>  	 * enumerated.
>  	 */
> -	if (!dfl_get_feature_by_id(dev, PORT_FEATURE_ID_ERROR))
> +	if (!dfl_get_feature_by_id(fdata, PORT_FEATURE_ID_ERROR))
>  		return 0;
>  
>  	return attr->mode;
> diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
> index 61868cdd5b0b..42928cc7e42b 100644
> --- a/drivers/fpga/dfl-afu-main.c
> +++ b/drivers/fpga/dfl-afu-main.c
> @@ -26,7 +26,7 @@
>  
>  /**
>   * __afu_port_enable - enable a port by clear reset
> - * @pdev: port platform device.
> + * @fdata: port feature dev data.
>   *
>   * Enable Port by clear the port soft reset bit, which is set by default.
>   * The AFU is unable to respond to any MMIO access while in reset.
> @@ -35,18 +35,17 @@
>   *
>   * The caller needs to hold lock for protection.
>   */
> -int __afu_port_enable(struct platform_device *pdev)
> +int __afu_port_enable(struct dfl_feature_dev_data *fdata)

Same suggestion. Replace "struct platform_device *pdev" with "struct
dfl_feature_platform_data *pdata" first. Then do massive pdata->fdata
replacement.

Thanks,
Yilun

  reply	other threads:[~2024-04-23 15:21 UTC|newest]

Thread overview: 18+ 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-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-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-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-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 [this message]
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-04-23  8:27 ` [RFC PATCH v2 0/9] " 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=ZifQz/QJvYpFljMv@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@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=peter.colberg@intel.com \
    --cc=russ.weight@linux.dev \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).