Received: by 10.213.65.68 with SMTP id h4csp1537553imn; Mon, 19 Mar 2018 06:57:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELvSI2XM3oGv/EI01KxMBmTHJBBaEr9S7vMghkR82EVGp6kY5rckq1OFj6mx2K8OKRz0/q4q X-Received: by 2002:a17:902:4381:: with SMTP id j1-v6mr12842338pld.297.1521467830527; Mon, 19 Mar 2018 06:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521467830; cv=none; d=google.com; s=arc-20160816; b=IpCwkGdrA+sepQ8dGd/pznJswArUwzfBB0dLTlgHOpwHxEVso3LLhMdUni40+3u1tZ eq3MHx3s/1CwOPFYOR4LySvCU61nBkAnaf/pJHoyB+pGKXRjY7Ryh+NHMB3NRiGFnEAn VLp8F/3y5MMM2Oq+Yi8ETw/rnxKqDI9vFK6mqOc4z4dDWnbjvHwHQfKrSinkFPuLtYNH iNqAKLH9I2ITx3Faor67h57Y1Xjfo2x9yXYgMzAKwzkn9Dgugl1P8XwKal/E7ROZrcit 51u7hL1RnQIeLYygPmlAp2mefuu6KtgWsmSSkHp9XhTJPVh9HvzDdF3+trVRoNWiQa6g +Erg== 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=Rhf+XhUjGA+1YCpMjscEGCsEXEb9nAzVj2QjS3I3J8M=; b=Dzi6rOwWVg6Nnm3ZholvKB5im7rfypoJLmjTEULOzceuESmyJZWhqxdbeTGhuqgeMT 63xCIWmvhfAa5VVjA2J4LFmu7ey0wVC6GS9Ml97CPKMyEcggwFtDiBLQ8PxSIUFRzKs7 pF98opn1HcS5gbg5CtmdncFid31voJ1Y/UA009tozmicWdK3IZ8hzt92oPCUrHNs7pZG SpyavWqlR7POEoK1CiC02YeC3ZtGp6fK6XfyFkuaP0DWTiqjP27PUOP4Gztpq+vPd6ZU DH/RHVjf+pPTk5BvWbgcGMqPWqgL6aniv+7UgUEIH4sSjQNiMCdufNCbqlXhg9cKRJoh jjNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=bUNaa2YR; 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 z69si41581pfk.321.2018.03.19.06.56.56; Mon, 19 Mar 2018 06:57:10 -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=bUNaa2YR; 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 S933366AbeCSNvs (ORCPT + 99 others); Mon, 19 Mar 2018 09:51:48 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:53603 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932584AbeCSNvq (ORCPT ); Mon, 19 Mar 2018 09:51:46 -0400 Received: by mail-wm0-f41.google.com with SMTP id e194so15267012wmd.3 for ; Mon, 19 Mar 2018 06:51:45 -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=Rhf+XhUjGA+1YCpMjscEGCsEXEb9nAzVj2QjS3I3J8M=; b=bUNaa2YRzye132qUBywZe7OAVsjbKUCiiT/EQvFtSHxYrftsNG1nCis9nwjLYQt2JX TziJClF9O8On+fTsZOZb92eE/rgk0X4+Z3caDaF5gZXDDlJQt0+JXKOHY7i7fMdcsOx8 3PpSE98rJ83duNTJ+8TfKQOdznV012OOqnIs0= 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=Rhf+XhUjGA+1YCpMjscEGCsEXEb9nAzVj2QjS3I3J8M=; b=nRz4p4gFwYMmut040UtKaN9g6uYo118xmhn0kDX4ZDnxSByfP3YSkBgVXBG9XgQW5H vnNDQLIwgpo5LYaT8mBe0nAuBKqGaJSr1TzO7nj/tYK6kllgiivEPRqfUIJBit1FbKT6 sx53wQX8oBaXFyiSW9iebTu7ZjYRVtDZFJu5hiqHh4QTAHMI7NlbuM9wZIoTlwJ5QOlB wcyJDMcSsknvcEFOIlygv6IUsfVIVwjjzscVCU6VYABYjMvrz2M6F/Pp5WD3CfrXfUlN nXpc2MNmW+xLlNjc4GI4rFjxnjtymz5le7B7vNbmHjA66rR6JO+ByJUPek+uCJd1dzUQ EyTw== X-Gm-Message-State: AElRT7Gkb0Qj9dHnQUc3diLtzIko1/+u6ZXNgidBSahOiQnUuGoOTKoJ tX8LELmJFM7leTndXAAR2aRVVA== X-Received: by 10.80.165.218 with SMTP id b26mr13727631edc.147.1521467504773; Mon, 19 Mar 2018 06:51:44 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id s27sm240226edm.78.2018.03.19.06.51.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Mar 2018 06:51:43 -0700 (PDT) Date: Mon, 19 Mar 2018 14:51:41 +0100 From: Daniel Vetter To: Oleksandr Andrushchenko Cc: 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, jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Oleksandr Andrushchenko Subject: Re: [PATCH RESEND v2 1/2] drm/xen-front: Add support for Xen PV display frontend Message-ID: <20180319135141.GK14155@phenom.ffwll.local> Mail-Followup-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, jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Oleksandr Andrushchenko References: <1520958066-22875-1-git-send-email-andr2000@gmail.com> <1520958066-22875-2-git-send-email-andr2000@gmail.com> <20180316082330.GF25297@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Mar 16, 2018 at 12:52:09PM +0200, Oleksandr Andrushchenko wrote: > Hi, Daniel! > Sorry, if I strip the patch too much below. > > On 03/16/2018 10:23 AM, Daniel Vetter wrote: > > > > S-o-b line went missing here :-) > will restore it back ;) > > > > I've read through it, 2 actual review comments (around hot-unplug and > > around the error recovery for failed flips), a few bikesheds, but looks > > all reasonable to me. And much easier to read as one big patch (it's just > > 3k). > > > > One more thing I'd do as a follow-up (don't rewrite everything, this is > > close to merge, better to get it in first): You have a lot of indirections > > and function calls across sources files. That's kinda ok if you have a > > huge driver with 100+k lines of code where you have to split things up. > > But for a small driver like yours here it's a bit overkill. > will review and try to rework after the driver is in > > > > Personally I'd merge at least the xen backend stuff into the corresponding > > kms code, but that's up to you. > I prefer to have it in smaller chunks and all related code at > one place, so it is easier to maintain. That is why I didn't > plumb frontend <-> backend code right into the KMS code. > > And as mentioned, if you decide to do > > that, a follow-up patch (once this has merged) is perfectly fine. > Ok, after the merge If you prefer your current layout, then pls keep it. Bikeshed = personal style nit, feel free to ignore if you like stuff differently. In the end it's your driver, not mine, and I can easily navigate the current code (with a few extra jumps). -Daniel > > -Daniel > > > > > +int xen_drm_front_dbuf_create_from_sgt(struct xen_drm_front_info *front_info, > > > + uint64_t dbuf_cookie, uint32_t width, uint32_t height, > > > + uint32_t bpp, uint64_t size, struct sg_table *sgt) > > > +{ > > > + return be_dbuf_create_int(front_info, dbuf_cookie, width, height, > > > + bpp, size, NULL, sgt); > > > +} > > > + > > > +int xen_drm_front_dbuf_create_from_pages(struct xen_drm_front_info *front_info, > > > + uint64_t dbuf_cookie, uint32_t width, uint32_t height, > > > + uint32_t bpp, uint64_t size, struct page **pages) > > > +{ > > > + return be_dbuf_create_int(front_info, dbuf_cookie, width, height, > > > + bpp, size, pages, NULL); > > > +} > > The above two wrappers seem a bit much, just to set sgt = NULL or pages = > > NULL in one of them. I'd drop them, but that's a bikeshed so feel free to > > ignore. > I had that the way you say in some of the previous implementations, > but finally decided to have these dummy wrappers: seems > to be cleaner this way > > > +static void displback_disconnect(struct xen_drm_front_info *front_info) > > > +{ > > > + bool removed = true; > > > + > > > + if (front_info->drm_pdev) { > > > + if (xen_drm_front_drv_is_used(front_info->drm_pdev)) { > > > + DRM_WARN("DRM driver still in use, deferring removal\n"); > > > + removed = false; > > > + } else > > > + xen_drv_remove_internal(front_info); > > Ok this logic here is fishy, since you're open-coding the drm unplug > > infrastructure, but slightly differently and slightyl racy. If you have a > > driver where your underlying "hw" (well it's virtual here, but same idea) > > can disappear any time while userspace is still using the drm driver, you > > need to use the drm_dev_unplug() function and related code. > > drm_dev_unplug() works like drm_dev_unregister, except for the hotplug > > case. > > > > Then you also have to guard all the driver entry points where you do > > access the backchannel using drm_dev_is_unplugged() (I've seen a few of > > those already). Then you can rip out all the logic here and the xen_drm_front_drv_is_used() helper. > Will rework it with drm_dev_unplug, thank you > > I thought there's some patches from Noralf in-flight that improved the > > docs on this, I need to check > > > > > +#define XEN_DRM_NUM_VIDEO_MODES 1 > > > +#define XEN_DRM_CRTC_VREFRESH_HZ 60 > > > + > > > +static int connector_get_modes(struct drm_connector *connector) > > > +{ > > > + struct xen_drm_front_drm_pipeline *pipeline = > > > + to_xen_drm_pipeline(connector); > > > + struct drm_display_mode *mode; > > > + struct videomode videomode; > > > + int width, height; > > > + > > > + mode = drm_mode_create(connector->dev); > > > + if (!mode) > > > + return 0; > > > + > > > + memset(&videomode, 0, sizeof(videomode)); > > > + videomode.hactive = pipeline->width; > > > + videomode.vactive = pipeline->height; > > > + width = videomode.hactive + videomode.hfront_porch + > > > + videomode.hback_porch + videomode.hsync_len; > > > + height = videomode.vactive + videomode.vfront_porch + > > > + videomode.vback_porch + videomode.vsync_len; > > > + videomode.pixelclock = width * height * XEN_DRM_CRTC_VREFRESH_HZ; > > > + mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; > > > + > > > + drm_display_mode_from_videomode(&videomode, mode); > > > + drm_mode_probed_add(connector, mode); > > > + return XEN_DRM_NUM_VIDEO_MODES; > > Bikeshed: just hardcode this to 1, the #define is imo more confusing. > ok, will remove #define > > > > > + > > > + } > > > + /* > > > + * Send page flip request to the backend *after* we have event cached > > > + * above, so on page flip done event from the backend we can > > > + * deliver it and there is no race condition between this code and > > > + * event from the backend. > > > + * If this is not a page flip, e.g. no flip done event from the backend > > > + * is expected, then send now. > > > + */ > > > + if (!display_send_page_flip(pipe, old_plane_state)) > > > + xen_drm_front_kms_send_pending_event(pipeline); > > The control flow here is a bit confusing. I'd put the call to send out the > > event right away in case of a failure to communicate with the backend into > > display_send_page_flip() itself. Then drop the bool return value and make > > it void, and also push the comment explaining what you do in case of > > errors into that function. > The reason for having bool for page flip here is that we > need to send pending event for display enable/disable, for example. > So, I decided to make it this way: > 1. page flip handled - handles pending event internally > (defers sending until frame done event from the backend) > 2. page flip failed - handles externally in case of any > page flip related error, e.g. "not handled" cases, either > due to backend communication error or whatever else > 3. all other cases, but page flip > > > > That way the error handling and recovery is all neatly tied together in > > one place instead of spread around. > Well, I tried to keep it all at one place, but as we decided > to implement connector hotplug for error delivery it > became split. Also, I handle frame done event time-outs there. You can leave things as-is if you prefer, just for me it looked a bit confusion and unecessarily complex. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch