[Intel-gfx] [PATCH 1/3] drm: Expose a method for creating anonymous struct file around drm_minor

Chris Wilson chris at chris-wilson.co.uk
Wed Nov 6 10:42:50 UTC 2019


Quoting Chris Wilson (2019-11-06 10:26:48)
> Quoting Daniel Vetter (2019-11-06 10:19:50)
> > On Wed, Nov 06, 2019 at 10:07:14AM +0000, Chris Wilson wrote:
> > > Sometimes we need to create a struct file to wrap a drm_device, as it
> > > the user were to have opened /dev/dri/card0 but to do so anonymously
> > > (i.e. for internal use). Provide a utility method to create a struct
> > > file with the drm_device->driver.fops, that wrap the drm_device.
> > > 
> > > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > 
> > For proper internal access we already have drm_client_open, so I think
> > this has limited (but good use) in selftests only. So
> > EXPORT_SYMBOL_FOR_TESTS_ONLY plus maybe a clearer name for the intended
> > use like drm_file_mock_open?
> 
> I found the example in drm_gem_prime_mmap() that was doing the same trick,
> and the trick of being able to instantiate new struct file and install a
> fd whenever seems like it will come in handy... Just lacking the third
> user at the moment to claim generality.

The closest example I found in the spirit of creating a new drm_device
struct file and installing it is drm_mode_create_lease_ioctl() that uses
file_clone_open() for this purpose. The argument there would be whether
cloning the (file->f_path, file->f_flags, file->f_cred) is appropriate
versus an anonymous inode. I think cloning the credentials seems correct
for leasing.
-Chris


More information about the dri-devel mailing list