Re: [RFD] gpiolib: gpiochip is always dangling after remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Linus

On 8 March 2016 at 15:53, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
> On Fri, Feb 26, 2016 at 8:06 PM, Bamvor Jian Zhang <bamv2005@xxxxxxxxx> wrote:
>
>> From: Bamvor Jian Zhang <bamvor.zhangjian@xxxxxxxxxx>
>>
>> In my gpiochip mockup driver, after call gpiochip_remove, the
>> gpipchip is not actually removed even if there is no clients in
>> userspace. It could be removed if remove the corresonding reference
>> count in this patch.
>>
>> But such gpiochip will be removed even if user space open the
>> corresponding chardev. I am not sure If I do not right thing.
>> Please correct me if I am wrong.
>>
>> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@xxxxxxxxxx>
>
> I think you're onto the right thing, thank you for looking into this.
>
> My idea was that the gdev->dev and gdev->cdev should stay around
> until the last userspace user is gone, even if the gpiochip_remove()
> was called.
>
> Maybe I just got the refcounts wrong :(
>
> It'd be great if you can come up with a patch that has the following
> properties:
>
> gpiochip_add_data(), no userspace users, gpiochip_remove()
> -> refcount goes to zero and gpiodevice_release() gets called
>
> gpiochip_add_data(), add some userspace users, gpiochip_remove()
> -> refcount does not go to zero and gpiodevice_release() is not called
> Then remove the userspace users:
> -> refcount goes to zero and gpiodevice_release() gets called
>
> It might be that using device_add(), device_del() directly like I'm
> doing cannot really solve this :( then we need to rethink the mechanism
> in terms of device_register()/device_unregister(), but I couldn't
> get that to work with the way chardevs are added.
Ok, I will do it.

Regards

Bamvor
> Yours,
> Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux