minigbm: Drop DRM master if taken by accident on primary node

On display-only DRM devices (e.g. vkms) we have to use primary node for
GBM, which is used by cros-camera. However, if cros-camera is started
before Chrome, it automatically takes over DRM master via minigbm,
blocking Chrome from starting.

Since we don't actually need any DRM master ioctls in minigbm (it works
on render nodes anyway), we'd like to drop it whenever it's taken by
accident.

BUG=b:239110721
TEST=On VM with vkms: stop ui -> restart cros-camera -> start ui

Change-Id: I66d60210e221dad9450ecd1eea939bd1d7813bbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4290730
Commit-Queue: Yi Xie <yixie@chromium.org>
Tested-by: Yi Xie <yixie@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
This commit is contained in:
Yi Xie 2023-02-27 16:18:46 +09:00 committed by Chromeos LUCI
parent ecbc89179e
commit fa8ea877d3

View file

@ -329,6 +329,11 @@ static struct gbm_device *try_drm_devices(drmDevicePtr *devs, int dev_count, int
if (fd >= 0) {
struct gbm_device *gbm = gbm_create_device(fd);
if (gbm) {
// DRM master might be taken by accident on a primary node even
// if master is not needed for GBM. Drop it so that programs
// that actually need DRM master (e.g. Chrome) won't be blocked.
if (type == DRM_NODE_PRIMARY && drmIsMaster(fd))
drmDropMaster(fd);
*out_fd = fd;
return gbm;
}