From: matthew.gerlach@linux.intel.com
To: Alan Tull <atull@kernel.org>
Cc: Moritz Fischer <moritz.fischer@ettus.com>,
Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org
Subject: Re: [RFC 1/8] fpga-mgr: add a single function for fpga loading methods
Date: Wed, 15 Feb 2017 16:36:53 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.20.1702151633090.2455@mgerlach-VirtualBox> (raw)
In-Reply-To: <1487175261-7051-2-git-send-email-atull@kernel.org>
Hi Alan,
On Wed, 15 Feb 2017, Alan Tull wrote:
> Currently fpga-mgr.c has three methods for loading FPGA's depending on how
> the FPGA image is presented: in a sg table, as a single buffer, or as a
> firmware file. This commit adds these parameters to the fpga_image_info
> stuct and adds a single function that can accept the image as any of these
> three. This allows code to be written that could use any of the three
> methods.
>
> Signed-off-by: Alan Tull <atull@kernel.org>
> ---
> drivers/fpga/fpga-mgr.c | 12 ++++++++++++
> drivers/fpga/fpga-region.c | 17 +++++++----------
> include/linux/fpga/fpga-mgr.h | 10 ++++++++++
> 3 files changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index 86d2cb2..b7c719a 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -309,6 +309,18 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr,
> }
> EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);
>
> +int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info)
> +{
> + if (info->firmware_name)
> + return fpga_mgr_firmware_load(mgr, info, info->firmware_name);
> + if (info->sgt)
> + return fpga_mgr_buf_load_sg(mgr, info, info->sgt);
> + if (info->buf && info->count)
> + return fpga_mgr_buf_load(mgr, info, info->buf, info->count);
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL_GPL(fpga_mgr_load);
> +
I like this cleaner api.
> static const char * const state_str[] = {
> [FPGA_MGR_STATE_UNKNOWN] = "unknown",
> [FPGA_MGR_STATE_POWER_OFF] = "power off",
> diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
> index 3222fdb..24f4ed5 100644
> --- a/drivers/fpga/fpga-region.c
> +++ b/drivers/fpga/fpga-region.c
> @@ -223,14 +223,11 @@ static int fpga_region_get_bridges(struct fpga_region *region,
> /**
> * fpga_region_program_fpga - program FPGA
> * @region: FPGA region
> - * @firmware_name: name of FPGA image firmware file
> * @overlay: device node of the overlay
> - * Program an FPGA using information in the device tree.
> - * Function assumes that there is a firmware-name property.
> + * Program an FPGA using information in the region's fpga image info.
> * Return 0 for success or negative error code.
> */
> static int fpga_region_program_fpga(struct fpga_region *region,
> - const char *firmware_name,
> struct device_node *overlay)
> {
> struct fpga_manager *mgr;
> @@ -260,7 +257,7 @@ static int fpga_region_program_fpga(struct fpga_region *region,
> goto err_put_br;
> }
>
> - ret = fpga_mgr_firmware_load(mgr, region->info, firmware_name);
> + ret = fpga_mgr_load(mgr, region->info);
> if (ret) {
> pr_err("failed to load fpga image\n");
> goto err_put_br;
> @@ -351,7 +348,6 @@ static int child_regions_with_firmware(struct device_node *overlay)
> static int fpga_region_notify_pre_apply(struct fpga_region *region,
> struct of_overlay_notify_data *nd)
> {
> - const char *firmware_name = NULL;
> struct fpga_image_info *info;
> int ret;
>
> @@ -373,7 +369,8 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
> if (of_property_read_bool(nd->overlay, "external-fpga-config"))
> info->flags |= FPGA_MGR_EXTERNAL_CONFIG;
>
> - of_property_read_string(nd->overlay, "firmware-name", &firmware_name);
> + of_property_read_string(nd->overlay, "firmware-name",
> + &info->firmware_name);
>
> of_property_read_u32(nd->overlay, "region-unfreeze-timeout-us",
> &info->enable_timeout_us);
> @@ -382,7 +379,7 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
> &info->disable_timeout_us);
>
> /* If FPGA was externally programmed, don't specify firmware */
> - if ((info->flags & FPGA_MGR_EXTERNAL_CONFIG) && firmware_name) {
> + if ((info->flags & FPGA_MGR_EXTERNAL_CONFIG) && info->firmware_name) {
> pr_err("error: specified firmware and external-fpga-config");
> return -EINVAL;
> }
> @@ -392,12 +389,12 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
> return 0;
>
> /* If we got this far, we should be programming the FPGA */
> - if (!firmware_name) {
> + if (!info->firmware_name) {
> pr_err("should specify firmware-name or external-fpga-config\n");
> return -EINVAL;
> }
>
> - return fpga_region_program_fpga(region, firmware_name, nd->overlay);
> + return fpga_region_program_fpga(region, nd->overlay);
> }
>
> /**
> diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
> index 57beb5d..45df05a 100644
> --- a/include/linux/fpga/fpga-mgr.h
> +++ b/include/linux/fpga/fpga-mgr.h
> @@ -76,11 +76,19 @@ enum fpga_mgr_states {
> * @flags: boolean flags as defined above
> * @enable_timeout_us: maximum time to enable traffic through bridge (uSec)
> * @disable_timeout_us: maximum time to disable traffic through bridge (uSec)
> + * @firmware_name: name of FPGA image firmware file
> + * @sgt: scatter/gather table containing FPGA image
> + * @buf: contiguous buffer containing FPGA image
> + * @count: size of buf
> */
> struct fpga_image_info {
> u32 flags;
> u32 enable_timeout_us;
> u32 disable_timeout_us;
We really need to address your patch adds the config_complete_timout_us.
It seems like it would conflict with this patch.
> + const char *firmware_name;
> + struct sg_table *sgt;
> + const char *buf;
> + size_t count;
> };
>
> /**
> @@ -139,6 +147,8 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr,
> struct fpga_image_info *info,
> const char *image_name);
>
> +int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info);
> +
> struct fpga_manager *of_fpga_mgr_get(struct device_node *node);
>
> struct fpga_manager *fpga_mgr_get(struct device *dev);
> --
> 2.7.4
>
> --
> 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:[~2017-02-16 0:37 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 16:14 FPGA Region enhancements and fixes Alan Tull
2017-02-15 16:14 ` [RFC 1/8] fpga-mgr: add a single function for fpga loading methods Alan Tull
2017-02-16 0:36 ` matthew.gerlach [this message]
2017-02-15 16:14 ` [RFC 2/8] fpga-region: support more than one overlay per FPGA region Alan Tull
2017-02-16 16:50 ` matthew.gerlach
2017-02-16 17:35 ` Alan Tull
2017-02-15 16:14 ` [RFC 3/8] fpga-bridge: add non-dt support Alan Tull
2017-02-15 16:14 ` [RFC 4/8] doc: fpga-mgr: separate getting/locking FPGA manager Alan Tull
2017-02-17 17:14 ` Li, Yi
2017-02-17 21:55 ` Alan Tull
2017-02-17 17:52 ` Moritz Fischer
2017-02-17 22:02 ` Alan Tull
2017-02-15 16:14 ` [RFC 5/8] " Alan Tull
2017-02-15 16:14 ` [RFC 6/8] fpga-region: separate out common code to allow non-dt support Alan Tull
2017-02-15 16:14 ` [RFC 7/8] fpga-region: add sysfs interface Alan Tull
2017-02-15 17:21 ` Jason Gunthorpe
2017-02-15 17:46 ` Alan Tull
2017-02-15 17:55 ` Moritz Fischer
2017-02-15 18:06 ` Jason Gunthorpe
2017-02-15 18:23 ` Alan Tull
2017-02-15 18:31 ` Moritz Fischer
2017-02-15 19:49 ` Jason Gunthorpe
2017-02-15 22:49 ` Alan Tull
2017-02-15 23:07 ` Jason Gunthorpe
2017-02-15 20:07 ` matthew.gerlach
2017-02-15 20:37 ` Jason Gunthorpe
2017-02-15 20:54 ` Moritz Fischer
2017-02-15 21:15 ` Jason Gunthorpe
2017-02-15 21:36 ` Moritz Fischer
2017-02-15 22:42 ` Alan Tull
2017-02-16 0:16 ` Moritz Fischer
2017-02-16 17:47 ` Alan Tull
2017-02-16 17:56 ` Jason Gunthorpe
2017-02-16 18:11 ` Moritz Fischer
2017-02-17 22:28 ` Yves Vandervennet
2017-02-18 2:30 ` Moritz Fischer
2017-02-18 12:45 ` Nadathur, Sundar
2017-02-18 20:10 ` Alan Tull
2017-02-18 20:45 ` Moritz Fischer
2017-02-19 15:00 ` Alan Tull
2017-02-19 23:16 ` Alan Tull
2017-02-20 23:49 ` Moritz Fischer
2017-02-21 18:33 ` Alan Tull
2017-02-22 3:13 ` Nadathur, Sundar
2017-02-22 3:49 ` Moritz Fischer
2017-02-22 5:12 ` Jason Gunthorpe
2017-02-22 5:38 ` Moritz Fischer
2017-02-22 5:46 ` Nadathur, Sundar
2017-02-22 6:05 ` Moritz Fischer
2017-02-22 16:44 ` Jason Gunthorpe
2017-02-22 17:50 ` Moritz Fischer
2017-02-22 17:54 ` Jason Gunthorpe
2017-02-22 17:57 ` Moritz Fischer
2017-02-22 16:33 ` Alan Tull
2017-02-22 16:44 ` Moritz Fischer
2017-02-22 16:52 ` Alan Tull
2017-02-27 20:09 ` Alan Tull
2017-02-27 22:49 ` Moritz Fischer
2017-02-28 0:04 ` matthew.gerlach
2017-02-15 21:20 ` Anatolij Gustschin
2017-02-15 16:14 ` [RFC 8/8] doc: fpga: add sysfs document for fpga region Alan Tull
2017-02-28 17:35 ` FPGA Region enhancements and fixes Alan Tull
2017-02-28 22:03 ` Alan Tull
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=alpine.DEB.2.20.1702151633090.2455@mgerlach-VirtualBox \
--to=matthew.gerlach@linux.intel.com \
--cc=atull@kernel.org \
--cc=jgunthorpe@obsidianresearch.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=moritz.fischer@ettus.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®