From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Xu Yilun <yilun.xu@linux.intel.com>
Cc: Marco Pagani <marpagan@redhat.com>,
Moritz Fischer <mdf@kernel.org>, Wu Hao <hao.wu@intel.com>,
Xu Yilun <yilun.xu@intel.com>, Tom Rix <trix@redhat.com>,
Alan Tull <atull@opensource.altera.com>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] fpga: remove module reference counting from core components
Date: Thu, 9 Nov 2023 08:30:10 +0100 [thread overview]
Message-ID: <2023110918-showroom-choosy-ad14@gregkh> (raw)
In-Reply-To: <ZUyHSs+oI9AsQdZE@yilunxu-OptiPlex-7050>
On Thu, Nov 09, 2023 at 03:16:26PM +0800, Xu Yilun wrote:
> On Thu, Nov 09, 2023 at 06:27:24AM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Nov 09, 2023 at 01:07:42PM +0800, Xu Yilun wrote:
> > > On Wed, Nov 08, 2023 at 05:20:53PM +0100, Greg Kroah-Hartman wrote:
> > > > On Wed, Nov 08, 2023 at 11:52:52PM +0800, Xu Yilun wrote:
> > > > > > >>
> > > > > > >> In fpga_region_get() / fpga_region_put(): call get_device() before
> > > > > > >> acquiring the mutex and put_device() after having released the mutex
> > > > > > >> to avoid races.
> > > >
> > > > Why do you need another reference count with a lock? You already have
> > > > that with the calls to get/put_device().
> > >
> > > The low-level driver module could still be possibly unloaded at the same
> > > time, if so, when FPGA core run some callbacks provided by low-level driver
> > > module, its referenced page of code is unmapped...
> >
> > Then something is designed wrong here, the unloading of the low-level
> > driver should remove the access to the device itself. Perhaps fix that?
>
> Actually the low-level driver module on its own has no way to garantee its
> own code page of callbacks not accessed. It *is* accessing its code page
> when it tries (to release) any protection.
It is not up to the low-level driver to do this, it's up to the code
that calls into it (i.e. the fpga core code) to handle the proper
reference counting.
> Core code must help, and something like file_operations.owner is an
> effective way.
Yes, that should be all that you need.
thanks,
greg k-h
next prev parent reply other threads:[~2023-11-09 7:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231027152928.184012-1-marpagan@redhat.com>
2023-10-30 8:32 ` [RFC PATCH] fpga: remove module reference counting from core components Xu Yilun
2023-11-03 20:31 ` Marco Pagani
2023-11-08 15:52 ` Xu Yilun
2023-11-08 16:20 ` Greg Kroah-Hartman
2023-11-09 5:07 ` Xu Yilun
2023-11-09 5:27 ` Greg Kroah-Hartman
2023-11-09 7:16 ` Xu Yilun
2023-11-09 7:30 ` Greg Kroah-Hartman [this message]
2023-11-09 11:33 ` Marco Pagani
2023-11-10 22:58 ` Marco Pagani
2023-11-11 11:02 ` Greg Kroah-Hartman
2023-11-14 6:53 ` Xu Yilun
2023-11-17 21:58 ` Marco Pagani
2023-11-17 22:06 ` Greg Kroah-Hartman
2023-11-18 11:58 ` Xu Yilun
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=2023110918-showroom-choosy-ad14@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=atull@opensource.altera.com \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marpagan@redhat.com \
--cc=mdf@kernel.org \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
--cc=yilun.xu@linux.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 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).