lkml.org 
[lkml]   [2023]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH] fpga: remove module reference counting from core components
From


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

\
 
 \ /
  Last update: 2023-11-20 13:54    [W:0.110 / U:0.728 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site