From: Wu Hao <hao.wu@intel.com>
To: Alan Tull <atull@kernel.org>
Cc: Moritz Fischer <mdf@kernel.org>,
linux-fpga@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-api@vger.kernel.org, "Kang, Luwei" <luwei.kang@intel.com>,
"Zhang, Yi Z" <yi.z.zhang@intel.com>,
Tim Whisonant <tim.whisonant@intel.com>,
Enno Luebbers <enno.luebbers@intel.com>,
Shiva Rao <shiva.rao@intel.com>,
Christopher Rauer <christopher.rauer@intel.com>,
Xiao Guangrong <guangrong.xiao@linux.intel.com>
Subject: Re: [PATCH v6 17/29] fpga: dfl: fme: add partial reconfiguration sub feature support
Date: Fri, 15 Jun 2018 13:52:46 +0800 [thread overview]
Message-ID: <20180615055246.GA27304@hao-dev> (raw)
In-Reply-To: <CANk1AXRU9yXhgWu9_CZLLRQfNKedR22ghoPLGeTRUeTX24XtWw@mail.gmail.com>
On Thu, Jun 14, 2018 at 11:33:00AM -0500, Alan Tull wrote:
> On Wed, Jun 13, 2018 at 8:07 PM, Moritz Fischer <mdf@kernel.org> wrote:
>
> Hellooo,
>
> This probably could use a comment, please see below.
>
> > Hi,
> >
> > quick question for Alan inline below.
> >
>
> >> +static int fme_pr(struct platform_device *pdev, unsigned long arg)
> >> +{
> >> + struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
> >> + void __user *argp = (void __user *)arg;
> >> + struct dfl_fpga_fme_port_pr port_pr;
> >> + struct fpga_image_info *info;
> >> + struct fpga_region *region;
> >> + void __iomem *fme_hdr;
> >> + struct dfl_fme *fme;
> >> + unsigned long minsz;
> >> + void *buf = NULL;
> >> + int ret = 0;
> >> + u64 v;
> >> +
> >> + minsz = offsetofend(struct dfl_fpga_fme_port_pr, buffer_address);
> >> +
> >> + if (copy_from_user(&port_pr, argp, minsz))
> >> + return -EFAULT;
> >> +
> >> + if (port_pr.argsz < minsz || port_pr.flags)
> >> + return -EINVAL;
> >> +
> >> + if (!IS_ALIGNED(port_pr.buffer_size, 4))
> >> + return -EINVAL;
> >> +
> >> + /* get fme header region */
> >> + fme_hdr = dfl_get_feature_ioaddr_by_id(&pdev->dev,
> >> + FME_FEATURE_ID_HEADER);
> >> +
> >> + /* check port id */
> >> + v = readq(fme_hdr + FME_HDR_CAP);
> >> + if (port_pr.port_id >= FIELD_GET(FME_CAP_NUM_PORTS, v)) {
> >> + dev_dbg(&pdev->dev, "port number more than maximum\n");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (!access_ok(VERIFY_READ,
> >> + (void __user *)(unsigned long)port_pr.buffer_address,
> >> + port_pr.buffer_size))
> >> + return -EFAULT;
> >> +
> >> + buf = vmalloc(port_pr.buffer_size);
> >> + if (!buf)
> >> + return -ENOMEM;
> >> +
> >> + if (copy_from_user(buf,
> >> + (void __user *)(unsigned long)port_pr.buffer_address,
> >> + port_pr.buffer_size)) {
> >> + ret = -EFAULT;
> >> + goto free_exit;
> >> + }
> >> +
> >> + /* prepare fpga_image_info for PR */
> >> + info = fpga_image_info_alloc(&pdev->dev);
> >> + if (!info) {
> >> + ret = -ENOMEM;
> >> + goto free_exit;
> >> + }
> >> +
> >> + info->flags |= FPGA_MGR_PARTIAL_RECONFIG;
> >> +
> >> + mutex_lock(&pdata->lock);
> >> + fme = dfl_fpga_pdata_get_private(pdata);
> >> + /* fme device has been unregistered. */
> >> + if (!fme) {
> >> + ret = -EINVAL;
> >> + goto unlock_exit;
> >> + }
> >> +
> >> + region = dfl_fme_region_find(fme, port_pr.port_id);
> >> + if (!region) {
> >> + ret = -EINVAL;
> >> + goto unlock_exit;
> >> + }
> >> +
> >> + fpga_image_info_free(region->info);
> >> +
> >> + info->buf = buf;
> >> + info->count = port_pr.buffer_size;
> >> + info->region_id = port_pr.port_id;
> >> + region->info = info;
> >> +
> >> + ret = fpga_region_program_fpga(region);
> >> +
> >> + if (region->get_bridges)
> >> + fpga_bridges_put(®ion->bridge_list);
> >
> > I'm wondering if this should not be done as part of
> > fpga_region_program_fpga() (It's not at the moment).
> >
> > Alan, am I missing something obvious? :)
>
> It is up to the caller of fpga_region_program_fpga to put the bridges
> before programming again. That prevents something other than the
> caller from reprogramming a partial region or messing with the bridges
> until the caller puts the bridges.
>
> For example, for DT support, applying an overlay calls
> fpga_region_program_fpga() which gets the bridges, disables them, does
> the programming, and reenables the bridges. Then the bridges are
> held, preventing anything else from disabling the bridges until the
> overlay is removed. This was important in the DT case since the
> overlay could include child nodes for hardware in the FPGA. Allowing
> anyone else to play with the bridges while those drivers were
> expecting hardware access could be bad.
>
> I can't remember for certain, but I think this code has to put the
> bridges here because this patch set allows userspace to reset the PR
> region's logic by disabling/reenabling the bridge to clear things out
> between acceleration runs (which Hao promises is OK to do, it's
> documented elsewhere in the pachset). It probably could use a comment
> right here to explain why the bridges are put here so future
> generations know not to break this.
Yes, it's correct. I can add some comments here in the next version.
Thanks
Hao
>
> Alan
>
> >> +
> >> + put_device(®ion->dev);
> >> +unlock_exit:
> >> + mutex_unlock(&pdata->lock);
> >> +free_exit:
> >> + vfree(buf);
> >> + if (copy_to_user((void __user *)arg, &port_pr, minsz))
> >> + return -EFAULT;
> >> +
> >> + return ret;
> >> +}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-15 6:04 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 10:10 [PATCH v6 00/29] FPGA Device Feature List (DFL) Device Drivers Wu Hao
2018-06-12 10:10 ` [PATCH v6 01/29] docs: fpga: add a document for FPGA Device Feature List (DFL) Framework Overview Wu Hao
2018-06-12 10:10 ` [PATCH v6 02/29] fpga: mgr: add region_id to fpga_image_info Wu Hao
2018-06-12 10:10 ` [PATCH v6 03/29] fpga: mgr: add status for fpga-manager Wu Hao
2018-06-12 15:57 ` Alan Tull
2018-06-12 10:10 ` [PATCH v6 04/29] fpga: mgr: add compat_id support Wu Hao
2018-06-12 10:10 ` [PATCH v6 05/29] fpga: region: " Wu Hao
2018-06-13 14:44 ` Moritz Fischer
2018-06-12 10:10 ` [PATCH v6 06/29] fpga: add device feature list support Wu Hao
2018-06-12 15:27 ` Randy Dunlap
2018-06-12 15:42 ` Alan Tull
2018-06-12 10:10 ` [PATCH v6 07/29] fpga: dfl: add chardev support for feature devices Wu Hao
2018-06-12 15:55 ` Alan Tull
2018-06-12 10:10 ` [PATCH v6 08/29] fpga: dfl: add dfl_fpga_cdev_find_port Wu Hao
2018-06-12 10:10 ` [PATCH v6 09/29] fpga: dfl: add feature device infrastructure Wu Hao
2018-06-12 10:10 ` [PATCH v6 10/29] fpga: dfl: add dfl_fpga_port_ops support Wu Hao
2018-06-12 10:10 ` [PATCH v6 11/29] fpga: dfl: add dfl_fpga_check_port_id function Wu Hao
2018-06-12 10:10 ` [PATCH v6 12/29] fpga: add FPGA DFL PCIe device driver Wu Hao
2018-06-12 15:27 ` Randy Dunlap
2018-06-12 23:42 ` Wu Hao
2018-06-13 13:54 ` Moritz Fischer
2018-06-13 16:34 ` Wu Hao
2018-06-12 10:10 ` [PATCH v6 13/29] fpga: dfl-pci: add enumeration for feature devices Wu Hao
2018-06-12 10:10 ` [PATCH v6 14/29] fpga: dfl: add FPGA Management Engine driver basic framework Wu Hao
2018-06-12 15:27 ` Randy Dunlap
2018-06-13 14:13 ` Moritz Fischer
2018-06-12 10:10 ` [PATCH v6 15/29] fpga: dfl: fme: add header sub feature support Wu Hao
2018-06-12 10:10 ` [PATCH v6 16/29] fpga: dfl: fme: add DFL_FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support Wu Hao
2018-06-12 10:10 ` [PATCH v6 17/29] fpga: dfl: fme: add partial reconfiguration sub feature support Wu Hao
2018-06-14 1:07 ` Moritz Fischer
2018-06-14 16:33 ` Alan Tull
2018-06-15 5:52 ` Wu Hao [this message]
2018-06-12 10:10 ` [PATCH v6 18/29] fpga: dfl: add fpga manager platform driver for FME Wu Hao
2018-06-14 1:16 ` Moritz Fischer
2018-06-14 13:50 ` Wu Hao
2018-06-12 10:10 ` [PATCH v6 19/29] fpga: dfl: fme-mgr: add compat_id support Wu Hao
2018-06-13 20:08 ` Moritz Fischer
2018-06-12 10:10 ` [PATCH v6 20/29] fpga: dfl: add fpga bridge platform driver for FME Wu Hao
2018-06-12 10:10 ` [PATCH v6 21/29] fpga: dfl: add fpga region " Wu Hao
2018-06-12 10:10 ` [PATCH v6 22/29] fpga: dfl: fme-region: add support for compat_id Wu Hao
2018-06-13 14:18 ` Moritz Fischer
2018-06-12 10:10 ` [PATCH v6 23/29] fpga: dfl: add FPGA Accelerated Function Unit driver basic framework Wu Hao
2018-06-12 15:27 ` Randy Dunlap
2018-06-12 10:10 ` [PATCH v6 24/29] fpga: dfl: afu: add port ops support Wu Hao
2018-06-12 10:10 ` [PATCH v6 25/29] fpga: dfl: afu: add header sub feature support Wu Hao
2018-06-12 10:10 ` [PATCH v6 26/29] fpga: dfl: afu: add DFL_FPGA_GET_API_VERSION/CHECK_EXTENSION ioctls support Wu Hao
2018-06-12 10:10 ` [PATCH v6 27/29] fpga: dfl: afu: add afu sub feature support Wu Hao
2018-06-12 10:10 ` [PATCH v6 28/29] fpga: dfl: afu: add DFL_FPGA_PORT_DMA_MAP/UNMAP ioctls support Wu Hao
2018-06-12 10:10 ` [PATCH v6 29/29] MAINTAINERS: add entry for FPGA DFL drivers Wu Hao
2018-06-13 0:56 ` Alan Tull
2018-06-13 13:50 ` Moritz Fischer
2018-06-12 17:33 ` [PATCH v6 00/29] FPGA Device Feature List (DFL) Device Drivers Alan Tull
2018-06-12 23:37 ` Wu Hao
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=20180615055246.GA27304@hao-dev \
--to=hao.wu@intel.com \
--cc=atull@kernel.org \
--cc=christopher.rauer@intel.com \
--cc=enno.luebbers@intel.com \
--cc=guangrong.xiao@linux.intel.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luwei.kang@intel.com \
--cc=mdf@kernel.org \
--cc=shiva.rao@intel.com \
--cc=tim.whisonant@intel.com \
--cc=yi.z.zhang@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