2022-07-22 22:15:20

by Jim Shargo

[permalink] [raw]
Subject: [PATCH 0/5] drm/vkms: Add ConfigFS Support

Intro
=====

This patchset adds basic ConfigFS support to VKMS, allowing users to
build new DRM devices with user-defined DRM objects and object
relationships by creating, writing, and symlinking files.

Usage
=====

Modprobe VKMS and mount ConfigFS:

$ mkdir -p /config/; mount -t configfs
$ modprobe vkms enable_overlay=1 enable_cursor=1 enable_writeback=1

This will create a `/config/vkms` directory, where users may create
new VKMS devices. The standard default device is still created, so
existing use-cases should be unaffected.

Creating a new device happens in three stages:

1) Create a new directory to represent a new device:
$ mkdir /config/vkms/dev

2) Populate the new device with crtcs, planes, connectors, encoders,
and CRTCs by mkdir'ing in the appropriate directories. Connect the
objects via symlinks.

3) To register the device:
$ echo 1 > /config/vkms/dev/is_registered

If the write is successful, you have a new VKMS device ready to use!

See the updated vkms.rst for more details and a full example.

Changes within VKMS
===================

The most meaningful change within VKMS is the introduction of a list
of "cards" representing individual virtual drivers. Each card
maintains its own devices, arrays of objects, and output/writeback
machinery.

Until cards are registered, all of their data lives in within the
ConfigFS tree. Only during registration do we interface with DRM at
all to create the device.

Due to limitations with ConfigFS, the default device is a special
case, without all of the objects represented in its ConfigFS
directory.

Testing
=======

Suspend tests are not working in my VM, so I skipped those. Otherwise,
here are the tests that I have been running:

$ igt-gpu-tools/scripts/run-tests.sh -x ".*suspend.*" \
-t ".*kms_flip.*" \
-t ".*kms_writeback.*" \
-t ".*kms_cursor_crc*" \
-t ".*kms_plane.*"

I've observed no changes between passed/failed tests before and after
my changes on the default device.

IGT revision: eddc67c5c85b8ee6eb4d13752ca43da5073dc985

I'll also note that I've been working on a VKMS test suite in IGT that
exercises the new ConfigFS behavior, and that it's a work-in-progress.

Future Work
===========

This should be the biggest and most invasive change in VKMS to make it
more configurable and able to mimic real devices. That said, it should
serve as a basis for additional useful features, including:

- Simulating hot-plugging by keeping the connectors directory live
and allowing users to add/remove connectors after the device is
registered.
- Additional properties could be turned on and off, or tuned, based
on files within object directories. For instance, GAMMA/DEGAMMA
LUT sizes could be configurable per-device, or support for
individual formats could be turned on and off.

Additional Notes
================

This is my first kernel patchset, and though I've had it reviewed by
my team (with a lot of of kernel/drm expertise), I recommend reading
it with a bit of extra scrutiny. As you can tell by the fact this
didn't get mailed with the other patches :P.

Thanks!

Jim Shargo (5):
drm/vkms: Merge default_config and device
drm/vkms: VKMS now supports more than one "card"
drm/vkms: Support multiple objects (crtcs, etc.) per card
drm/vkms: Add ConfigFS scaffolding to VKMS
drm/vkms: Support registering configfs devices

Documentation/gpu/vkms.rst | 76 ++++
drivers/gpu/drm/Kconfig | 1 +
drivers/gpu/drm/vkms/Makefile | 1 +
drivers/gpu/drm/vkms/vkms_composer.c | 28 +-
drivers/gpu/drm/vkms/vkms_configfs.c | 546 ++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_crtc.c | 88 +++--
drivers/gpu/drm/vkms/vkms_drv.c | 204 ++++++----
drivers/gpu/drm/vkms/vkms_drv.h | 173 ++++++--
drivers/gpu/drm/vkms/vkms_output.c | 335 +++++++++++++---
drivers/gpu/drm/vkms/vkms_plane.c | 43 +-
drivers/gpu/drm/vkms/vkms_writeback.c | 27 +-
11 files changed, 1288 insertions(+), 234 deletions(-)
create mode 100644 drivers/gpu/drm/vkms/vkms_configfs.c

--
2.37.1.359.gd136c6c3e2-goog