Re: [PATCH 6/9] drm/xen-front: Introduce DRM/KMS virtual display driver

From: Oleksandr Andrushchenko
Date: Fri Feb 23 2018 - 10:20:04 EST


On 02/23/2018 05:12 PM, Boris Ostrovsky wrote:
On 02/21/2018 03:03 AM, Oleksandr Andrushchenko wrote:

+
+struct drm_driver xen_drm_driver = {
+ .driver_features = DRIVER_GEM | DRIVER_MODESET |
+ DRIVER_PRIME | DRIVER_ATOMIC,
+ .lastclose = lastclose,
+ .gem_free_object_unlocked = free_object,
+ .gem_vm_ops = &xen_drm_vm_ops,
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+ .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+ .gem_prime_import = drm_gem_prime_import,
+ .gem_prime_export = drm_gem_prime_export,
+ .gem_prime_get_sg_table = prime_get_sg_table,
+ .gem_prime_import_sg_table = prime_import_sg_table,
+ .gem_prime_vmap = prime_vmap,
+ .gem_prime_vunmap = prime_vunmap,
+ .gem_prime_mmap = prime_mmap,
+ .dumb_create = dumb_create,
+ .fops = &xendrm_fops,
+ .name = "xendrm-du",
+ .desc = "Xen PV DRM Display Unit",
+ .date = "20161109",
You must have been working on this for a while ;-)
yes, this is true ;)

I assume this needs to be updated.
It can be, but I would either stick to the current value
for historical reasons or would update it in the final version
of the driver, so it reflects the date of issuing ;)
+bool xen_drm_front_drv_is_used(struct platform_device *pdev)
+{
+ struct xen_drm_front_drm_info *drm_info = platform_get_drvdata(pdev);
+ struct drm_device *dev;
+
+ if (!drm_info)
+ return false;
+
+ dev = drm_info->drm_dev;
+ if (!dev)
+ return false;
+
+ /*
+ * FIXME: the code below must be protected by drm_global_mutex,
+ * but it is not accessible to us. Anyways there is a race condition,
+ * but we will re-try.
+ */
+ return dev->open_count != 0;
Would it be a problem, given the race, if you report that the frontend
is not in use, while it actually is?
no, backend will not be able to activate us again
-boris