Received: by 10.223.185.116 with SMTP id b49csp428454wrg; Wed, 21 Feb 2018 00:25:22 -0800 (PST) X-Google-Smtp-Source: AH8x226V+eTMuSKozCVzFwFEjzsia3EB6A4P2fQT/co0VFGfOR0k7tSC4nztOnnm3el0Oj/Hvx5k X-Received: by 2002:a17:902:b904:: with SMTP id bf4-v6mr2351350plb.195.1519201521991; Wed, 21 Feb 2018 00:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519201521; cv=none; d=google.com; s=arc-20160816; b=z7RqRUTvAKXyazHg9D0jomaOIbsK7CwLpjrdx70txyX5W3/8uQiSv9TOp7pebRTIbH b5iDYITwZ0IXZXdJaeogX4MjlBFUQfbBT6sFje7hvZjEEaESJ1tgF1goVNjGgJ1pGUiQ 8mcumFI1IxLrYWRQvNIB+vEIoL4ifoJ/vI2grMAMlL1/ZyVOes6OhzuAU1rlsaVHijne wg6pUXVbIktvx8uH0SKn3RRtPkIzyJxAriWlstYld+NZfy5xe7OKPuZHYHo43GlEP0Kc ROLxmwg6co4A22uRaDN/I4zCXr+1fh5V5HyKi78UubX5VkaBmV/7z6NmdDak6g3UogET Nlsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Xfm4SUUSlYn04JbfaaviClIlHvV/5kKU/fuMeC9YbAo=; b=0wFUqNiGyLTIa1r4nUrASJ1KEyH9Iv9V5d/OY6W+U+ymZwp8PDKzsnPQrv+UipUsgm YiUNcPwM81GYIc7cMVbC12ApYie7xfwj3XzDHAJRRdG8PolGA8XCPSscVr85Mga8aC3Q knUtIpv6j2WTv6U3FnewqgPDpYDxzRTAx7dT3cCpjbZ68V2+1EgAkTmkTAFTntGz7/ev X5WdELPUWpO6pj/cJozPtRi5ptqmYWTRi0/Ygu2ZsC2gmGsmPFNRpKEzi/UXXVmCYqVk OkLUU4huPYpU5Cbc4lYyiyj/+xuc8r7J/OB4H5icozBBw+gs9Gl5dWnRlJ4+SBSLEouv Sv4g== ARC-Authentication-Results: i=1; mx.google.com; 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 w22-v6si893651pll.663.2018.02.21.00.25.05; Wed, 21 Feb 2018 00:25:21 -0800 (PST) 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; 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 S1752402AbeBUIXJ (ORCPT + 99 others); Wed, 21 Feb 2018 03:23:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:48660 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeBUIXI (ORCPT ); Wed, 21 Feb 2018 03:23:08 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9932EACFC; Wed, 21 Feb 2018 08:23:06 +0000 (UTC) Subject: Re: [PATCH 2/9] drm/xen-front: Implement Xen bus state handling To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: Oleksandr Andrushchenko References: <1519200222-20623-1-git-send-email-andr2000@gmail.com> <1519200222-20623-3-git-send-email-andr2000@gmail.com> From: Juergen Gross Message-ID: <7b302293-a4ca-0225-576f-0cc33f6f56cb@suse.com> Date: Wed, 21 Feb 2018 09:23:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519200222-20623-3-git-send-email-andr2000@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/02/18 09:03, Oleksandr Andrushchenko wrote: > From: Oleksandr Andrushchenko > > Initial handling for Xen bus states: implement > Xen bus state machine for the frontend driver according to > the state diagram and recovery flow from display para-virtualized > protocol: xen/interface/io/displif.h. > > Signed-off-by: Oleksandr Andrushchenko > --- > drivers/gpu/drm/xen/xen_drm_front.c | 124 +++++++++++++++++++++++++++++++++++- > drivers/gpu/drm/xen/xen_drm_front.h | 26 ++++++++ > 2 files changed, 149 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h > > diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c > index fd372fb464a1..d0306f9d660d 100644 > --- a/drivers/gpu/drm/xen/xen_drm_front.c > +++ b/drivers/gpu/drm/xen/xen_drm_front.c > @@ -24,19 +24,141 @@ > > #include > > +#include "xen_drm_front.h" > + > +static void xen_drv_remove_internal(struct xen_drm_front_info *front_info) > +{ > +} > + > +static int backend_on_initwait(struct xen_drm_front_info *front_info) > +{ > + return 0; > +} > + > +static int backend_on_connected(struct xen_drm_front_info *front_info) > +{ > + return 0; > +} > + > +static void backend_on_disconnected(struct xen_drm_front_info *front_info) > +{ > + xenbus_switch_state(front_info->xb_dev, XenbusStateInitialising); > +} > + > static void backend_on_changed(struct xenbus_device *xb_dev, > enum xenbus_state backend_state) > { > + struct xen_drm_front_info *front_info = dev_get_drvdata(&xb_dev->dev); > + int ret; > + > + DRM_DEBUG("Backend state is %s, front is %s\n", > + xenbus_strstate(backend_state), > + xenbus_strstate(xb_dev->state)); > + > + switch (backend_state) { > + case XenbusStateReconfiguring: > + /* fall through */ > + case XenbusStateReconfigured: > + /* fall through */ > + case XenbusStateInitialised: > + break; > + > + case XenbusStateInitialising: > + /* recovering after backend unexpected closure */ > + backend_on_disconnected(front_info); > + break; > + > + case XenbusStateInitWait: > + /* recovering after backend unexpected closure */ > + backend_on_disconnected(front_info); > + if (xb_dev->state != XenbusStateInitialising) > + break; > + > + ret = backend_on_initwait(front_info); > + if (ret < 0) > + xenbus_dev_fatal(xb_dev, ret, "initializing frontend"); > + else > + xenbus_switch_state(xb_dev, XenbusStateInitialised); > + break; > + > + case XenbusStateConnected: > + if (xb_dev->state != XenbusStateInitialised) > + break; > + > + ret = backend_on_connected(front_info); > + if (ret < 0) > + xenbus_dev_fatal(xb_dev, ret, "initializing DRM driver"); > + else > + xenbus_switch_state(xb_dev, XenbusStateConnected); > + break; > + > + case XenbusStateClosing: > + /* > + * in this state backend starts freeing resources, > + * so let it go into closed state, so we can also > + * remove ours > + */ > + break; > + > + case XenbusStateUnknown: > + /* fall through */ > + case XenbusStateClosed: > + if (xb_dev->state == XenbusStateClosed) > + break; > + > + backend_on_disconnected(front_info); > + break; > + } > } > > static int xen_drv_probe(struct xenbus_device *xb_dev, > const struct xenbus_device_id *id) > { > - return 0; > + struct xen_drm_front_info *front_info; > + > + front_info = devm_kzalloc(&xb_dev->dev, > + sizeof(*front_info), GFP_KERNEL); > + if (!front_info) { > + xenbus_dev_fatal(xb_dev, -ENOMEM, "allocating device memory"); No need for message in case of allocation failure: this is handled in memory allocation already. Juergen