[PATCH 5/5] drm: Add four ioctls for managing drm mode object leases [v6]

Keith Packard keithp at keithp.com
Mon Oct 16 21:31:30 UTC 2017


Sean Paul <seanpaul at chromium.org> writes:

> nit: space before ,

Thanks.

>> +	/* Clone the lessor file to create a new file for us */
>> +	DRM_DEBUG_LEASE("Allocating lease file\n");
>> +	path_get(&lessor_file->f_path);
>
> Please forgive the stupid question, but where is this reference given
> up?

That's not a stupid question, it's a very subtle one which took me quite
a while to sort out. Here's path_get:

        void path_get(const struct path *path)
        {
        	mntget(path->mnt);
        	dget(path->dentry);
        }

So, getting a reference on a 'path' actually gets a reference on two of
the things it points to.

alloc_file is passed the path and doesn't take an additional reference
on either of these fields, presumably because the normal path has the
caller taking a reference while looking up the object and handing that
reference off to alloc_file. In our case, we're creating a new file that
refers to the same path as an existing one, so we need another
reference.

When the file is finally freed in __fput, the two references are dropped
at the end of the function:

        static void __fput(struct file *file)
        {
        	struct dentry *dentry = file->f_path.dentry;
        	struct vfsmount *mnt = file->f_path.mnt;

                ...

               	dput(dentry);
        	mntput(mnt);
        }

This was probably the twistiest part of creating a lease. All of the DRM
stuff was trivial; getting the core kernel object reference counts right
was a pain.

>> +	if (lessee->lessor == NULL)
>> +		/* owner can use all objects */
>> +		object_idr = &lessee->dev->mode_config.crtc_idr;
>
> What about other types of objects?

If I understand your question correctly, the answer is that 'crtc_idr'
is misnamed -- it holds all of the mode setting objects.

Thanks for your review, let me know if you have more questions!

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20171016/6288a8bc/attachment.sig>


More information about the dri-devel mailing list