All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Maciej Kwapulinski <maciej.kwapulinski@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>,
	Derek Kiernan <derek.kiernan@xilinx.com>,
	Dragan Cvetic <dragan.cvetic@xilinx.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Tomasz Jankowski <tomasz1.jankowski@intel.com>,
	Savo Novakovic <savox.novakovic@intel.com>,
	Jianxun Zhang <jianxun.zhang@linux.intel.com>
Subject: Re: [PATCH v3 13/14] intel_gna: add file operations to a 'misc' device
Date: Thu, 13 May 2021 13:19:16 +0200	[thread overview]
Message-ID: <YJ0LNB0V113ky0FB@kroah.com> (raw)
In-Reply-To: <20210513110040.2268-14-maciej.kwapulinski@linux.intel.com>

On Thu, May 13, 2021 at 01:00:39PM +0200, Maciej Kwapulinski wrote:
> From: Tomasz Jankowski <tomasz1.jankowski@intel.com>
> 
> Signed-off-by: Tomasz Jankowski <tomasz1.jankowski@intel.com>
> Tested-by: Savo Novakovic <savox.novakovic@intel.com>
> Co-developed-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
> Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
> Co-developed-by: Maciej Kwapulinski <maciej.kwapulinski@linux.intel.com>
> Signed-off-by: Maciej Kwapulinski <maciej.kwapulinski@linux.intel.com>
> ---
>  drivers/misc/intel/gna/device.c | 60 +++++++++++++++++++++++++++++++--
>  1 file changed, 57 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/intel/gna/device.c b/drivers/misc/intel/gna/device.c
> index 1e6345a8325b..c882055de8cf 100644
> --- a/drivers/misc/intel/gna/device.c
> +++ b/drivers/misc/intel/gna/device.c
> @@ -4,7 +4,9 @@
>  #include <linux/device.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/interrupt.h>
> +#include <linux/fs.h>
>  #include <linux/module.h>
> +#include <linux/slab.h>
>  
>  #include <uapi/misc/intel/gna.h>
>  
> @@ -20,16 +22,68 @@ module_param(recovery_timeout, int, 0644);
>  MODULE_PARM_DESC(recovery_timeout, "Recovery timeout in seconds");
>  #endif
>  
> -struct file;
> -
>  static int gna_open(struct inode *inode, struct file *f)
>  {
> -	return -EPERM;
> +	struct gna_file_private *file_priv;
> +	struct gna_private *gna_priv;
> +
> +	gna_priv = container_of(f->private_data, struct gna_private, misc);
> +
> +	file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
> +	if (!file_priv)
> +		return -ENOMEM;
> +
> +	file_priv->fd = f;
> +	file_priv->gna_priv = gna_priv;
> +
> +	mutex_init(&file_priv->memlist_lock);
> +	INIT_LIST_HEAD(&file_priv->memory_list);
> +
> +	INIT_LIST_HEAD(&file_priv->flist);
> +
> +	mutex_lock(&gna_priv->flist_lock);
> +	list_add_tail(&file_priv->flist, &gna_priv->file_list);
> +	mutex_unlock(&gna_priv->flist_lock);
> +
> +	f->private_data = file_priv;
> +
> +	return 0;
> +}
> +
> +static int gna_release(struct inode *inode, struct file *f)
> +{
> +	struct gna_memory_object *iter_mo, *temp_mo;
> +	struct gna_file_private *file_priv;
> +	struct gna_private *gna_priv;
> +
> +	/* free all memory objects created by that file */
> +	file_priv = (struct gna_file_private *)f->private_data;
> +	gna_priv = file_priv->gna_priv;
> +
> +	mutex_lock(&file_priv->memlist_lock);
> +	list_for_each_entry_safe(iter_mo, temp_mo, &file_priv->memory_list, file_mem_list) {
> +		queue_work(gna_priv->request_wq, &iter_mo->work);
> +		wait_event(iter_mo->waitq, true);
> +		gna_memory_free(gna_priv, iter_mo);
> +	}
> +	mutex_unlock(&file_priv->memlist_lock);
> +
> +	gna_delete_file_requests(f, gna_priv);
> +
> +	mutex_lock(&gna_priv->flist_lock);
> +	list_del_init(&file_priv->flist);
> +	mutex_unlock(&gna_priv->flist_lock);
> +	kfree(file_priv);
> +	f->private_data = NULL;
> +
> +	return 0;
>  }
>  
>  static const struct file_operations gna_file_ops = {
>  	.owner		=	THIS_MODULE,
>  	.open		=	gna_open,
> +	.release	=	gna_release,
> +	.unlocked_ioctl =	gna_ioctl,

Wait, where's the ioctl?  You added it earlier in the series?

gotta go dig now...


greg k-h

  reply	other threads:[~2021-05-13 11:19 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 11:00 [PATCH v3 00/14] Driver of Intel(R) Gaussian & Neural Accelerator Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 01/14] intel_gna: add driver module Maciej Kwapulinski
2021-05-13 11:13   ` Greg Kroah-Hartman
2021-05-13 11:00 ` [PATCH v3 02/14] intel_gna: add component of hardware operation Maciej Kwapulinski
2021-05-13 11:15   ` Greg Kroah-Hartman
2021-05-13 11:00 ` [PATCH v3 03/14] intel_gna: read hardware info in the driver Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 04/14] intel_gna: add memory handling Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 05/14] intel_gna: initialize mmu Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 06/14] intel_gna: add hardware ids Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 07/14] intel_gna: add request component Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 08/14] intel_gna: implement scoring Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 09/14] intel_gna: add a work queue to process scoring requests Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 10/14] intel_gna: add interrupt handler Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 11/14] intel_gna: add ioctl handler Maciej Kwapulinski
2021-05-13 11:24   ` Greg Kroah-Hartman
2021-05-14  8:20     ` Maciej Kwapulinski
2021-05-14  8:32       ` Greg Kroah-Hartman
2021-05-24 10:43         ` Maciej Kwapulinski
2021-05-24 10:49           ` Greg Kroah-Hartman
2021-05-25  7:50             ` Maciej Kwapulinski
2021-05-13 14:16   ` Matthew Wilcox
     [not found]   ` <20210514101253.1037-1-hdanton@sina.com>
2021-05-14 15:06     ` Maciej Kwapulinski
2021-05-13 11:00 ` [PATCH v3 12/14] intel_gna: add a 'misc' device Maciej Kwapulinski
2021-05-13 11:18   ` Greg Kroah-Hartman
2021-05-13 17:06     ` Maciej Kwapulinski
2021-05-13 17:15       ` Greg Kroah-Hartman
2021-05-13 11:00 ` [PATCH v3 13/14] intel_gna: add file operations to " Maciej Kwapulinski
2021-05-13 11:19   ` Greg Kroah-Hartman [this message]
2021-05-13 11:00 ` [PATCH v3 14/14] intel_gna: add power management Maciej Kwapulinski
2021-05-14  8:34 ` [PATCH v3 00/14] Driver of Intel(R) Gaussian & Neural Accelerator Greg Kroah-Hartman
2021-05-14  9:00   ` Arnd Bergmann
2021-05-17  7:40     ` Daniel Vetter
2021-05-17  7:40       ` Daniel Vetter
2021-05-17  8:00       ` Greg Kroah-Hartman
2021-05-17  8:49         ` Daniel Vetter
2021-05-17  8:49           ` Daniel Vetter
2021-05-17  8:55           ` Greg Kroah-Hartman
2021-05-17  8:55             ` Greg Kroah-Hartman
2021-05-17  9:12             ` Daniel Vetter
2021-05-17  9:12               ` Daniel Vetter
2021-05-17 18:04               ` Dave Airlie
2021-05-17 18:04                 ` Dave Airlie
2021-05-17 19:12       ` Thomas Zimmermann
2021-05-17 19:23         ` Alex Deucher
2021-05-17 19:23           ` Alex Deucher
2021-05-17 19:39           ` Daniel Vetter
2021-05-17 19:39             ` Daniel Vetter
2021-05-17 19:49           ` Thomas Zimmermann
2021-05-17 19:49             ` Thomas Zimmermann
2021-05-17 20:00             ` Daniel Vetter
2021-05-17 20:00               ` Daniel Vetter
2021-05-17 20:15               ` Thomas Zimmermann
2021-05-17 20:15                 ` Thomas Zimmermann
2021-05-17 19:32         ` Daniel Stone
2021-05-17 19:32           ` Daniel Stone
2021-05-17 20:10           ` Thomas Zimmermann
2021-05-17 20:10             ` Thomas Zimmermann
2021-05-17 21:24             ` Daniel Vetter
2021-05-17 21:24               ` Daniel Vetter
2021-05-17 21:36             ` Dave Airlie
2021-05-17 21:36               ` Dave Airlie
2021-06-16  7:38   ` Maciej Kwapulinski
2022-06-20  9:49     ` maciej.kwapulinski
2022-06-20  9:49       ` maciej.kwapulinski
2022-06-20  9:56       ` Greg KH
2022-06-20  9:56         ` Greg KH
2022-06-20 10:08         ` Maciej Kwapulinski
2022-06-20 10:08           ` Maciej Kwapulinski
2022-06-20 10:26           ` Greg KH
2022-06-20 10:26             ` Greg KH
2022-06-25 17:25       ` Daniel Vetter
2022-06-25 17:25         ` Daniel Vetter
2021-05-20 11:58 ` Linus Walleij

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=YJ0LNB0V113ky0FB@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=derek.kiernan@xilinx.com \
    --cc=dragan.cvetic@xilinx.com \
    --cc=jianxun.zhang@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.kwapulinski@linux.intel.com \
    --cc=savox.novakovic@intel.com \
    --cc=tomasz1.jankowski@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.