RE: [char-misc-next v2 1/5] mei: set parent for char device

From: Usyskin, Alexander
Date: Wed Jul 16 2025 - 04:10:01 EST


> Subject: Re: [char-misc-next v2 1/5] mei: set parent for char device
>
> On Wed, Jul 16, 2025 at 07:44:28AM +0000, Usyskin, Alexander wrote:
> > > Subject: Re: [char-misc-next v2 1/5] mei: set parent for char device
> > >
> > > On Mon, Jun 30, 2025 at 01:02:12PM +0000, Usyskin, Alexander wrote:
> > > > > Subject: Re: [char-misc-next v2 1/5] mei: set parent for char device
> > > > >
> > > > > On Mon, Jun 30, 2025 at 12:19:38PM +0300, Alexander Usyskin
> wrote:
> > > > > > Connect char device to parent device to avoid
> > > > > > parent device unload while char device is
> > > > > > still held open by user-space.
> > > > >
> > > > > No, that's not what cdev_set_parent() does.
> > > > >
> > > > https://elixir.bootlin.com/linux/v6.16-rc3/source/fs/char_dev.c#L511
> > > > * cdev_set_parent() sets a parent kobject which will be referenced
> > > > * appropriately so the parent is not freed before the cdev. This
> > > > * should be called before cdev_add.
> > > >
> > > > This is what written there. Is my interpretation wrong?
> > >
> > > It has nothing to do with a char device being open or closed from
> > > userspace, it has to deal with properly placing the device in the
> > > kobject tree and the object references being correct.
> > >
> > > Surely the mei device had this set up before, right? If not, how did
> > > sysfs look with these char devices with no real parent?
> > >
> >
> > Mei device never had this setup.
>
> So what is the "parent" of a mei device today?
>

PCI device in CSME case and auxiliary one for discrete graphics.

> > I've looked at other drivers - some of them do not have this setup.
>
> Then they are broken, don't copy them :)

Yep, I'm trying to fix this mess.
I've found a way to use existing mei class device to anchor the mei_device.
With this we can use mei class device as parent for the cdev.
Pushed the series (v3), looking for reactions whatever this is the right way.

- -
Thanks,
Sasha