linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 06:27:24 +0100	[thread overview]
Message-ID: <2023110922-lurk-subdivide-4962@gregkh> (raw)
In-Reply-To: <ZUxpHk/8pCusjXOb@yilunxu-OptiPlex-7050>

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?

> > > The lock/unlock of mutex
> > > scattered in different functions is also an uncommon style. Maybe some
> > > atomic count should be enough.
> > 
> > Don't make a fake lock with an atomic variable, use real locks if you
> > need it.
> 
> I mean, here it doesn't not looks like a "locking" senario, although it
> works.
> 
> The purpose here is to declare a device state, which says the device is
> exclusively used by a user, no other user is allowed. But usually we use
> mutex to protect against critical code blocks, not to represent a long
> live device state.
> 
> I'm still OK for the existing mutex usage as it doesn't break anything
> and if we don't want change much.
> 
> > 
> > Or don't even care about module unloading at all!  Why does it matter?
> > It can never happen without explicit intervention and it's something
> > that a lot of the time, just will cause problems.  Don't do a lot of
> > extra work for something that doesn't matter.
> 
> mm.. as mentioned above some fundamental subsystems do care about
> module unloading, and I tend to keep it same way. But mm... I'm OK to
> make things easier if you insist.

You can care, but my point being that don't make it very complex and
slow just for something that no one will ever do in normal device
operation.

thanks,

greg k-h

  reply	other threads:[~2023-11-09  5:29 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 [this message]
2023-11-09  7:16             ` Xu Yilun
2023-11-09  7:30               ` Greg Kroah-Hartman
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=2023110922-lurk-subdivide-4962@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).