LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Russ Weight <russell.h.weight@intel.com> To: mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, Russ Weight <russell.h.weight@intel.com> Subject: [PATCH v15 3/6] fpga: image-load: signal eventfd when complete Date: Wed, 8 Sep 2021 19:18:43 -0700 [thread overview] Message-ID: <20210909021846.681121-4-russell.h.weight@intel.com> (raw) In-Reply-To: <20210909021846.681121-1-russell.h.weight@intel.com> Amend the FPGA_IMAGE_LOAD_WRITE IOCTL implementation to include and eventfd file descriptor as a parameter. The eventfd will be triggered when the image upload completes. Signed-off-by: Russ Weight <russell.h.weight@intel.com> --- v15: - This patch is new to the patch-set, and adds an eventfd to the FPGA_IMAGE_LOAD_WRITE IOCTL. The eventfd is signalled upon completion of an update. --- Documentation/fpga/fpga-image-load.rst | 4 +++- drivers/fpga/fpga-image-load.c | 23 ++++++++++++++++++++--- include/linux/fpga/fpga-image-load.h | 2 ++ include/uapi/linux/fpga-image-load.h | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Documentation/fpga/fpga-image-load.rst b/Documentation/fpga/fpga-image-load.rst index 2ca8d2f0212d..739d735592a5 100644 --- a/Documentation/fpga/fpga-image-load.rst +++ b/Documentation/fpga/fpga-image-load.rst @@ -28,4 +28,6 @@ Start an image load with the provided image buffer. This IOCTL returns immediately after starting a kernel worker thread to process the image load which could take as long a 40 minutes depending on the actual device being updated. This is an exclusive operation; an attempt to start concurrent image -load for the same device will fail with EBUSY. +load for the same device will fail with EBUSY. An eventfd file descriptor +parameter is provided to this IOCTL, and it will be signalled at the +completion of the image load. diff --git a/drivers/fpga/fpga-image-load.c b/drivers/fpga/fpga-image-load.c index f5ccfa9dd977..b784456765b0 100644 --- a/drivers/fpga/fpga-image-load.c +++ b/drivers/fpga/fpga-image-load.c @@ -33,6 +33,7 @@ static void fpga_image_prog_complete(struct fpga_image_load *imgld) { mutex_lock(&imgld->lock); imgld->progress = FPGA_IMAGE_PROG_IDLE; + eventfd_signal(imgld->finished, 1); complete_all(&imgld->update_done); mutex_unlock(&imgld->lock); } @@ -92,6 +93,8 @@ static void fpga_image_do_load(struct work_struct *work) imgld->data = NULL; put_device(&imgld->dev); fpga_image_prog_complete(imgld); + eventfd_ctx_put(imgld->finished); + imgld->finished = NULL; } static int fpga_image_load_ioctl_write(struct fpga_image_load *imgld, @@ -99,6 +102,7 @@ static int fpga_image_load_ioctl_write(struct fpga_image_load *imgld, { struct fpga_image_write wb; unsigned long minsz; + int ret; u8 *buf; if (imgld->driver_unload || imgld->progress != FPGA_IMAGE_PROG_IDLE) @@ -115,13 +119,23 @@ static int fpga_image_load_ioctl_write(struct fpga_image_load *imgld, if (wb.size & 0x3) return -EINVAL; + if (wb.evtfd < 0) + return -EINVAL; + buf = vzalloc(wb.size); if (!buf) return -ENOMEM; if (copy_from_user(buf, u64_to_user_ptr(wb.buf), wb.size)) { - vfree(buf); - return -EFAULT; + ret = -EFAULT; + goto exit_free; + } + + imgld->finished = eventfd_ctx_fdget(wb.evtfd); + if (IS_ERR(imgld->finished)) { + ret = PTR_ERR(imgld->finished); + imgld->finished = NULL; + goto exit_free; } imgld->data = buf; @@ -130,8 +144,11 @@ static int fpga_image_load_ioctl_write(struct fpga_image_load *imgld, imgld->progress = FPGA_IMAGE_PROG_STARTING; reinit_completion(&imgld->update_done); schedule_work(&imgld->work); - return 0; + +exit_free: + vfree(buf); + return ret; } static long fpga_image_load_ioctl(struct file *filp, unsigned int cmd, diff --git a/include/linux/fpga/fpga-image-load.h b/include/linux/fpga/fpga-image-load.h index b3d790e5d943..68f3105b51d2 100644 --- a/include/linux/fpga/fpga-image-load.h +++ b/include/linux/fpga/fpga-image-load.h @@ -10,6 +10,7 @@ #include <linux/cdev.h> #include <linux/completion.h> #include <linux/device.h> +#include <linux/eventfd.h> #include <linux/mutex.h> #include <linux/types.h> #include <uapi/linux/fpga-image-load.h> @@ -52,6 +53,7 @@ struct fpga_image_load { enum fpga_image_prog err_progress; /* progress at time of failure */ enum fpga_image_err err_code; /* image load error code */ bool driver_unload; + struct eventfd_ctx *finished; void *priv; }; diff --git a/include/uapi/linux/fpga-image-load.h b/include/uapi/linux/fpga-image-load.h index 4146a0a9e408..a60da115adf5 100644 --- a/include/uapi/linux/fpga-image-load.h +++ b/include/uapi/linux/fpga-image-load.h @@ -52,6 +52,7 @@ struct fpga_image_write { /* Input */ __u32 flags; /* Zero for now */ __u32 size; /* Data size (in bytes) to be written */ + __s32 evtfd; /* File descriptor for completion signal */ __u64 buf; /* User space address of source data */ }; -- 2.25.1
next prev parent reply other threads:[~2021-09-09 2:19 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-09 2:18 [PATCH v15 0/6] FPGA Image Load (previously Security Manager) Russ Weight 2021-09-09 2:18 ` [PATCH v15 1/6] fpga: image-load: fpga image load class driver Russ Weight 2021-09-10 6:46 ` Xu Yilun 2021-09-10 20:47 ` Russ Weight 2021-09-09 2:18 ` [PATCH v15 2/6] fpga: image-load: enable image loads Russ Weight 2021-09-10 8:22 ` Xu Yilun 2021-09-10 23:18 ` Russ Weight 2021-09-13 6:48 ` Xu Yilun 2021-09-13 9:36 ` Xu Yilun 2021-09-21 19:08 ` Russ Weight 2021-09-09 2:18 ` Russ Weight [this message] 2021-09-09 2:18 ` [PATCH v15 4/6] fpga: image-load: add status ioctl Russ Weight 2021-09-10 8:50 ` Xu Yilun 2021-09-10 23:23 ` Russ Weight 2021-09-11 18:12 ` Tom Rix 2021-09-13 8:24 ` Xu Yilun 2021-09-09 2:18 ` [PATCH v15 5/6] fpga: image-load: create status sysfs node Russ Weight 2021-09-10 8:52 ` Xu Yilun 2021-09-10 23:30 ` Russ Weight 2021-09-11 17:58 ` Tom Rix 2021-09-13 8:27 ` Xu Yilun 2021-09-09 2:18 ` [PATCH v15 6/6] fpga: image-load: enable cancel of image upload Russ Weight 2021-09-10 14:55 ` Xu Yilun 2021-09-10 23:38 ` Russ Weight 2021-09-11 13:13 ` Tom Rix 2021-09-13 10:00 ` Xu Yilun 2021-09-21 20:43 ` Russ Weight [not found] ` <20210912023739.4078-1-hdanton@sina.com> 2021-09-21 18:36 ` [PATCH v15 2/6] fpga: image-load: enable image loads Russ Weight
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=20210909021846.681121-4-russell.h.weight@intel.com \ --to=russell.h.weight@intel.com \ --cc=hao.wu@intel.com \ --cc=lgoncalv@redhat.com \ --cc=linux-fpga@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=matthew.gerlach@intel.com \ --cc=mdf@kernel.org \ --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: linkBe 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).