From: zhangfei <zhangfei.gao@linaro.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Herbert Xu <herbert@gondor.apana.org.au>,
jonathan.cameron@huawei.com, dave.jiang@intel.com,
grant.likely@arm.com, jean-philippe <jean-philippe@linaro.org>,
Jerome Glisse <jglisse@redhat.com>,
ilias.apalodimas@linaro.org, francois.ozog@linaro.org,
kenneth-lee-2012@foxmail.com, Wangzhou <wangzhou1@hisilicon.com>,
"haojian . zhuang" <haojian.zhuang@linaro.org>,
guodong.xu@linaro.org, linux-accelerators@lists.ozlabs.org,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
iommu@lists.linux-foundation.org,
Kenneth Lee <liguozhu@hisilicon.com>,
Zaibo Xu <xuzaibo@huawei.com>
Subject: Re: [PATCH v11 2/4] uacce: add uacce driver
Date: Mon, 13 Jan 2020 11:34:55 +0800 [thread overview]
Message-ID: <053ccd05-4f11-5be6-47c2-eee5c2f1fdc4@linaro.org> (raw)
In-Reply-To: <20200111194006.GD435222@kroah.com>
Hi, Greg
Thanks for the review.
On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:
> On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:
>> +static int uacce_fops_open(struct inode *inode, struct file *filep)
>> +{
>> + struct uacce_mm *uacce_mm = NULL;
>> + struct uacce_device *uacce;
>> + struct uacce_queue *q;
>> + int ret = 0;
>> +
>> + uacce = xa_load(&uacce_xa, iminor(inode));
>> + if (!uacce)
>> + return -ENODEV;
>> +
>> + if (!try_module_get(uacce->parent->driver->owner))
>> + return -ENODEV;
> Why are you trying to grab the module reference of the parent device?
> Why is that needed and what is that going to help with here?
>
> This shouldn't be needed as the module reference of the owner of the
> fileops for this module is incremented, and the "parent" module depends
> on this module, so how could it be unloaded without this code being
> unloaded?
>
> Yes, if you build this code into the kernel and the "parent" driver is a
> module, then you will not have a reference, but when you remove that
> parent driver the device will be removed as it has to be unregistered
> before that parent driver can be removed from the system, right?
>
> Or what am I missing here?
The refcount here is preventing rmmod "parent" module after fd is opened,
since user driver has mmap kernel memory to user space, like mmio, which
may still in-use.
With the refcount protection, rmmod "parent" module will fail until
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use
>
>> +static void uacce_release(struct device *dev)
>> +{
>> + struct uacce_device *uacce = to_uacce_device(dev);
>> +
>> + kfree(uacce);
>> + uacce = NULL;
> That line didn't do anything :)
Yes, this is a mistake.
It is up to caller to set to NULL to prevent release multi times.
Thanks
next prev parent reply other threads:[~2020-01-13 3:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-11 2:48 [PATCH v11 0/4] Add uacce module for Accelerator Zhangfei Gao
2020-01-11 2:48 ` [PATCH v11 1/4] uacce: Add documents for uacce Zhangfei Gao
2020-01-11 2:48 ` [PATCH v11 2/4] uacce: add uacce driver Zhangfei Gao
2020-01-11 19:40 ` Greg Kroah-Hartman
2020-01-13 3:34 ` zhangfei [this message]
2020-01-14 14:59 ` Greg Kroah-Hartman
2020-01-15 11:18 ` zhangfei
2020-01-15 12:02 ` Greg Kroah-Hartman
2020-01-15 14:11 ` zhangfei
2020-01-15 16:43 ` Dave Jiang
2020-01-16 2:11 ` zhangfei
2020-01-11 2:48 ` [PATCH v11 3/4] crypto: hisilicon - Remove module_param uacce_mode Zhangfei Gao
2020-01-11 2:48 ` [PATCH v11 4/4] crypto: hisilicon - register zip engine to uacce Zhangfei Gao
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=053ccd05-4f11-5be6-47c2-eee5c2f1fdc4@linaro.org \
--to=zhangfei.gao@linaro.org \
--cc=arnd@arndb.de \
--cc=dave.jiang@intel.com \
--cc=francois.ozog@linaro.org \
--cc=grant.likely@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=guodong.xu@linaro.org \
--cc=haojian.zhuang@linaro.org \
--cc=herbert@gondor.apana.org.au \
--cc=ilias.apalodimas@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jean-philippe@linaro.org \
--cc=jglisse@redhat.com \
--cc=jonathan.cameron@huawei.com \
--cc=kenneth-lee-2012@foxmail.com \
--cc=liguozhu@hisilicon.com \
--cc=linux-accelerators@lists.ozlabs.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangzhou1@hisilicon.com \
--cc=xuzaibo@huawei.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;
as well as URLs for NNTP newsgroup(s).