From: Marco Pagani <marpagan@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Xu Yilun <yilun.xu@linux.intel.com>
Cc: 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 12:33:25 +0100 [thread overview]
Message-ID: <1fbdf0d8-d8c5-4616-ab49-bda4112771e8@redhat.com> (raw)
In-Reply-To: <2023110839-jam-relapsing-7f5d@gregkh>
On 2023-11-08 17:20, 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().
>
My understanding is that the lock is there not for reference counting
but to prevent concurrent reprogramming of the region by in-kernel API
consumers.
>>>> Could you help elaborate more about the race?
>>>>
>>>
>>> I accidentally misused the word race. My concern was that memory might
>>> be released after the last put_device(), causing mutex_unlock() to be
>>> called on a mutex that does not exist anymore. It should not happen
>>> for the moment since the region does not use devres, but I think it
>>> still makes the code more brittle.
>>
>> It makes sense.
>>
Thanks,
Marco
next prev parent reply other threads:[~2023-11-09 11:34 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 ` 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
2023-11-09 11:33 ` Marco Pagani [this message]
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=1fbdf0d8-d8c5-4616-ab49-bda4112771e8@redhat.com \
--to=marpagan@redhat.com \
--cc=atull@opensource.altera.com \
--cc=gregkh@linuxfoundation.org \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®