Received: by 10.213.65.68 with SMTP id h4csp431700imn; Tue, 20 Mar 2018 06:49:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELuhuXf0gGthTIjVYppd1zuCke/l5xKola455r+2PDIg0uuDpO1o4nloLqoja9PjLPEdUrPI X-Received: by 10.98.226.23 with SMTP id a23mr775270pfi.157.1521553780651; Tue, 20 Mar 2018 06:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521553780; cv=none; d=google.com; s=arc-20160816; b=RSbbPtqNOIxTAmV/Kj509lWe1/DmO841zp05KFKfeBWNP7TfclbHW/Kg9VhKoEQabQ rqW/eXsLhSYZPycqHDXUKwr9verrn/Pk9fh0nPK0K/8wD6nJU9QW5yme05VnCZ7ec0rU Gzb/oKC/NR5NDBKoxG/URZYT7OC5cYMky2iziRDrNGYTmalzZYy9ejQ/XeaAiDW6EhaT M6CdMV4MYvAC8F/DQfO/Bi+IW+KMxqzQiTqTTsnmBldvCQCQOHtrk4nKyA8naz/iUmNJ +7QZhHolSK/ZJlIGRUFN6JD5xFHfn/g7ocEFHzr0+b7k7PTpgdegrYJSVQOUpIBmJcYr nhQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=dgaX1qrqdBdk/BnwMP4YBRmU5nTl4QbRKAyyfZ+uUQY=; b=tFw6Xp4L3UxugBAhLVi/5bcl+E2wwQc/Jp1TGsZr+GyYYs+e0i/0C17L4jfqm67eAw tKGQ2FomNC5Mcali5zdS0ZByDKHBHJFA7+fB9WN/DBjj9/s7yE0HgZ6pJl7z58WB9gNb gDUUsPTKdFNd/r6/LJWbC4PQowCWZbNP6PnpmA5uQLeCcxx75OwfzK4mGv7MgUKBtwVq fZciA5cO+wklwcnlwz/A1R6JdQmrm49xkRwjncBPivyUaGYzMhR+YKN4XrNHwAs0HO32 9ckSV3rYJJH5/kSfLLuR3Z7DLjWr1cDUlo4bgfR9rDY/7GF1BbVThY5TjTO9fm1PRCMl 0byw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=byAm84kt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si1221992pgp.215.2018.03.20.06.49.25; Tue, 20 Mar 2018 06:49:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=byAm84kt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753763AbeCTNr1 (ORCPT + 99 others); Tue, 20 Mar 2018 09:47:27 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35048 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753745AbeCTNrV (ORCPT ); Tue, 20 Mar 2018 09:47:21 -0400 Received: by mail-wm0-f53.google.com with SMTP id r82so3662142wme.0 for ; Tue, 20 Mar 2018 06:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=dgaX1qrqdBdk/BnwMP4YBRmU5nTl4QbRKAyyfZ+uUQY=; b=byAm84ktz+3/UhHbkfLHY5keHq1TAb1o7vzUNXnHwdo+ksQGgoYoQ4dj0AsRQSBsCw ZEPqRq7TJmZENYB50A15N35g+q2EgBapS27ydarbzbysW+8RbuU8kqhEQYRxCIuSO2l+ 5lKlyLyWCQwH9YPQUp3fmbCmUAsRr9ThAUtAw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=dgaX1qrqdBdk/BnwMP4YBRmU5nTl4QbRKAyyfZ+uUQY=; b=Qi0oSntNLjIA2S6OsKjp0yvOkYgfmn8eB3zpDjZqFoSwLMrPFD9WhYkJod2BTJCv31 9vIb54MR/8eLuOMHNZpf16sIyJpFhSVICtBeBfJYm/Za3pX8k2koL0Z984HaRNJheVbp vwTjt9nXrEmEnZwegppuTCELBUUdhV0yduI9OApCnsAwuZC/djEafP93N2a8GzF4eXfF JYMOdilZoqR4P5yXNc3IQC7I/YPHueev9FzKjR3F/i8MG4NXrC9prlX0kvIvWSxjkbrU Z58N7jRDitZfrfumrbOMxd6BGOaXgDaZQPOhmBLpBMMi0oj6C1ciUtXoped+0MyP8MGa 3YBQ== X-Gm-Message-State: AElRT7F0Rg/XNoNlBNpKi5YAsBpI+0LRxWPXX0MiqFzQHBEtFCa+swbH oCa+ZEyfkMRds0OFhF0lWV2CxQ== X-Received: by 10.80.134.120 with SMTP id 53mr18173592edt.187.1521553639785; Tue, 20 Mar 2018 06:47:19 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id i61sm1932216edc.53.2018.03.20.06.47.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Mar 2018 06:47:18 -0700 (PDT) Date: Tue, 20 Mar 2018 14:47:16 +0100 From: Daniel Vetter To: Oleksandr Andrushchenko Cc: Daniel Vetter , xen-devel@lists.xenproject.org, Linux Kernel Mailing List , dri-devel , Dave Airlie , Daniel Vetter , Sean Paul , Gustavo Padovan , Juergen Gross , boris.ostrovsky@oracle.com, Konrad Rzeszutek Wilk , "Oleksandr_Andrushchenko@epam.com" Subject: Re: [PATCH RESEND v2 1/2] drm/xen-front: Add support for Xen PV display frontend Message-ID: <20180320134715.GT14155@phenom.ffwll.local> Mail-Followup-To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, Linux Kernel Mailing List , dri-devel , Dave Airlie , Daniel Vetter , Sean Paul , Gustavo Padovan , Juergen Gross , boris.ostrovsky@oracle.com, Konrad Rzeszutek Wilk , "Oleksandr_Andrushchenko@epam.com" References: <1520958066-22875-1-git-send-email-andr2000@gmail.com> <1520958066-22875-2-git-send-email-andr2000@gmail.com> <20180316082330.GF25297@phenom.ffwll.local> <20180319135141.GK14155@phenom.ffwll.local> <0808bf3b-7301-cc28-1cb5-40a4c8aad5cc@gmail.com> <7c4e0f8f-9ec0-e38b-7b37-264241df4ba5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c4e0f8f-9ec0-e38b-7b37-264241df4ba5@gmail.com> X-Operating-System: Linux phenom 4.15.0-1-amd64 User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 20, 2018 at 01:58:01PM +0200, Oleksandr Andrushchenko wrote: > On 03/19/2018 05:28 PM, Daniel Vetter wrote: > > There should be no difference between immediate removal and delayed > > 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: > Well, they are not decoupled for simplicity of handling, > please see below > > > > So for case 2 you only have 1 case: > > > > - 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. > I have re-worked the driver with this in mind [1] > 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 instance > > (while the other one is still in the process of eventually getting > > released). > We only have a single xenbus instance, so this way I'll need > 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). Why exactly do you need to keep track of your drm_devices from the xenbus? 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. > Another drawback of such approach is that I'll have different > 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 Fix userspace :-) But yeah unlikely this is a problem, hotplugging is fairly old thing. > > In short, your driver code should never have a need to look at > > drm_device->open_count. I hope this explains it a bit better. > > -Daniel > > > Yes, you are correct: at [1] I am not touching drm_device->open_count > anymore and everything just happens synchronously > [1] https://github.com/andr2000/linux/commits/drm_tip_pv_drm_v3 Please just resend, makes it easier to comment inline. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch