On Tue, Mar 20, 2018 at 01:58:01PM +0200, Oleksandr Andrushchenko wrote:Ok, probably new reworked code will make things cleaner and answer
On 03/19/2018 05:28 PM, Daniel Vetter wrote:Why exactly do you need to keep track of your drm_devices from the xenbus?
There should be no difference between immediate removal and delayedWell, they are not decoupled for simplicity of handling,
removal of the drm_device from the xenbus pov. The lifetimes of the
front-end (drm_device) and backend (the xen bus thing) are entirely
decoupled:
please see below
So for case 2 you only have 1 case:I have re-worked the driver with this in mind [1]
- drm_dev_unplug
- tear down the entire xenbus backend completely
- all xenbus access will be caught with drm_dev_entre/exit (well right
now drm_dev_is_unplugged) checks, including any access to your private
drm_device data
- once drm_device->open_count == 0 the core will tear down the
drm_device instance and call your optional drm_driver->release
callback.
So past drm_dev_unplug the drm_device is in zombie state and the only
thing that will happen is a) it rejects all ioctls and anything else
userspace might ask it to do and b) gets releases once the last
userspace reference is gone.
So, I now use drm_dev_unplug and destroy the DRM device
on drm_driver.release.
In context of unplug work I also merged xen_drm_front_drv.c and
xen_drm_front.c as these are too coupled together now.
Could you please take a look and tell me if this is what you mean?
If the backend comes up again, you create a _new_ drm_device instanceWe only have a single xenbus instance, so this way I'll need
(while the other one is still in the process of eventually getting
released).
to handle list of such zombies. For that reason I prefer to
wait until the DRM device is destroyed, telling the backend
to hold on until then (via going into XenbusStateReconfiguring state).
Once unplugged, there should be no connection with the "hw" for your
device, in neither direction. Maybe I need to look again, but this still
smells funny and not like something you should ever do.
I need to wait for Xen community reviewers before resending, so thisAnother drawback of such approach is that I'll have differentFix userspace :-)
minors at run-time, e.g. card0, card1, etc.
For software which has /dev/dri/card0 hardcoded it may be a problem.
But this is minor, IMO
But yeah unlikely this is a problem, hotplugging is fairly old thing.
Please just resend, makes it easier to comment inline.In short, your driver code should never have a need to look atYes, you are correct: at [1] I am not touching drm_device->open_count
drm_device->open_count. I hope this explains it a bit better.
-Daniel
anymore and everything just happens synchronously
[1] https://github.com/andr2000/linux/commits/drm_tip_pv_drm_v3
-DanielThank you,