Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp583297pxj; Thu, 13 May 2021 11:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHKuHa6dk9a7RG+Do7lXpqkfOOP6FuMrvTtu72VJ//Z+wzOWHublRKfXwVB0l3eDnB/NjD X-Received: by 2002:a9d:6145:: with SMTP id c5mr36355718otk.58.1620931779001; Thu, 13 May 2021 11:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620931778; cv=none; d=google.com; s=arc-20160816; b=n2rDRhHdNL9kQtAevpBGAiCXsStjUA1kKpsC8Rv/xwqvQj/gPd2vlBKE+IIn4/BvTL YCRHrcPqwOtj1fwSS3zvm5wHDIGvtTUiWKpnlxsaicF2l3iEE8zUtTgSLnjAc2RnG85M Uyq/0vRL8WWeKeDDtHxGL/BcCOKFehoqsw0SeWAE4kg4x9pv6xfqtDqkWTe0ZUMstCju mr5+AVMlOI50gkxzJoOStcNYm+ZqWPUIeCFqZFGF6Zlh0qA/zWoefmn91uQ40dHRQ0xA D23iO4Suiez+jOAG2ed4s4p5QR56wjVuyLabd9j58OaCtheGEv3fMnC89KLkhueyprEe G93A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oN8M7P59R47zfD4woDl45QmByIg4ZDxwN+Pxa2J7Q6s=; b=YwRGenQzbzlFZM5SL3E0XVoJf//mFTu4vdcrlz+i7SfCbt9PlE7fRhzLgeTuChDFw6 k2wBg9MAL7XDAOT4gHBZZ7rTGlGPOTSqYJbQGem9Rs07m2VRPqoW7bbxoGxGwlPZHZJH R5H6nybpnO4UigQREJPjGFgX20WCgTnYn//3uGNQ+xJd/wkSbrHrn9s8LuGrN5uBf7DG uLd31Gt6NQRMKM1CPqxas1erXPjPeZdummv2MFzh8VDU2YEOBd5cuL5YeYmSO91gAhE4 gWx/2rbdMWy+EYgaSVVRT27zXB2LzO7tj5n1ndiJDYtagefp/21BxfTpcnw2h5iO88tk Kxcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SSrpOmBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p67si4252547oig.196.2021.05.13.11.49.25; Thu, 13 May 2021 11:49:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SSrpOmBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232613AbhEMLUa (ORCPT + 99 others); Thu, 13 May 2021 07:20:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:36936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbhEMLU3 (ORCPT ); Thu, 13 May 2021 07:20:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8D67613CA; Thu, 13 May 2021 11:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620904758; bh=1DY1eVWYP757z7axkngnQdbTOZst1Izo014oZvuSrP8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SSrpOmBhn99/rBSDiyUjMMGpnlA393P7pqKhCUmbwmBoHVYAyxmG0PxuFe6bac8zU ejPrmRwjy7kZwEtbOtadutYmnJgs3O4ebtZEcpTl9P/QPz0kxwZv5G7qAQWhknqLhS 701yS8QR8qVySAgpBREaVxwbrF/d9c/P89QK/xIU= Date: Thu, 13 May 2021 13:19:16 +0200 From: Greg Kroah-Hartman To: Maciej Kwapulinski Cc: Arnd Bergmann , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Tomasz Jankowski , Savo Novakovic , Jianxun Zhang Subject: Re: [PATCH v3 13/14] intel_gna: add file operations to a 'misc' device Message-ID: References: <20210513110040.2268-1-maciej.kwapulinski@linux.intel.com> <20210513110040.2268-14-maciej.kwapulinski@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210513110040.2268-14-maciej.kwapulinski@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 13, 2021 at 01:00:39PM +0200, Maciej Kwapulinski wrote: > From: Tomasz Jankowski > > Signed-off-by: Tomasz Jankowski > Tested-by: Savo Novakovic > Co-developed-by: Jianxun Zhang > Signed-off-by: Jianxun Zhang > Co-developed-by: Maciej Kwapulinski > Signed-off-by: Maciej Kwapulinski > --- > 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 > #include > #include > +#include > #include > +#include > > #include > > @@ -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