Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7902474imm; Thu, 28 Jun 2018 11:05:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxKIDquKLCEYR00RMtCL74lCwZ/8XbzIJZ3wdRKCgi+7wV8gnrc1L53fG1OLfD45/H2BXK X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr9679899pgv.79.1530209139713; Thu, 28 Jun 2018 11:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530209139; cv=none; d=google.com; s=arc-20160816; b=1Gp149wdZR6vmQz4VYZFxlGRVJG0XQJzlIN5iisDN7W3cvuoGFfiMTKg/zKbLenbHJ pEMwAt1Rbggi6LKP5NY5iSz7B8y65Lv8GjpDlTvRrfpraktzYIdUe9c5pD29hzHTbR/G 4FFZWO4CZU8s/SGQ1lyHTFxmQAsxfdnY/+Q1F7szI2eiKPvZoLYAvcfpld9If8Jxp15Z tcNRr6D7RpG55bg7PhiQx4En4Wsmqy6MNe0O1kK2AyUXIhZfXxcclaVeeaSFQ7zI2JS/ A48W7xpZCbzQdL6enAfSb8ZMhXJzwrKksO8VlJYcX0wdPqJd9/kUu7d6CsT43vDdbl2v 2OZQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=FeDbZigwOmow8vj4ynLfvCH9kt7rNMUCmx8LtbIgiVU=; b=vMT6n9k6xTbbZS40CprZ5tiys98ab3S5WcuqEE0gpP54Hl1Bxr3893GiTap8sRICMp CkbYtBWPDMANJRaP2Jp4FxVB9Ua4sr0HTOt4p4Tyiywdqw2/yKU4qVitMEDjW/w9ncdZ WMGpPwHWSRi32X/xFPTTtq4c9nCswp1ZmNEkbX/EZOYcN/eKdaqvpuW1tyWB4MIYbugu PcXkZR5NrSn0N1u4LRS0X0RoE6pepG7mo7H4uHD9ZP4vAhBGzdZtN9ksd1R6OOjl0t9k PpGLXLxLmSdxzb4YBiIl2T974obgo3hZl1CX6Hi4qnfYCHhsNba5t5CbjfAV7Mbp41OY oSAg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s73-v6si6171975pfs.157.2018.06.28.11.05.25; Thu, 28 Jun 2018 11:05:39 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965905AbeF1NfU (ORCPT + 99 others); Thu, 28 Jun 2018 09:35:20 -0400 Received: from mga04.intel.com ([192.55.52.120]:3430 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753771AbeF1NfT (ORCPT ); Thu, 28 Jun 2018 09:35:19 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2018 06:35:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,283,1526367600"; d="scan'208";a="51217755" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga008.fm.intel.com with SMTP; 28 Jun 2018 06:35:15 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 28 Jun 2018 16:35:14 +0300 Date: Thu, 28 Jun 2018 16:35:14 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Enric Balletbo i Serra Cc: David Airlie , dnicoara@chromium.org, =?iso-8859-1?Q?St=E9phane?= Marchesin , Sean Paul , alexandros.frantzis@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, tomasz Figa , Gustavo Padovan , kernel@collabora.com Subject: Re: [RFC PATCH] drm/atomic: add ASYNC_UPDATE flag to the Atomic IOCTL. Message-ID: <20180628133514.GK20518@intel.com> References: <20180627212506.24061-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180627212506.24061-1-enric.balletbo@collabora.com> 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 Wed, Jun 27, 2018 at 11:25:06PM +0200, Enric Balletbo i Serra wrote: > From: Gustavo Padovan > > This flag tells core to jump ahead the queued update if the conditions > in drm_atomic_async_check() are met. That means we are only able to do an > async update if no modeset is pending and update for the same plane is > not queued. > > It uses the already in place infrastructure for async updates. I still dislike the name. On Intel hw "async flip" means "flip asap and tear". Whereas the legcay cursor thing i915 has is a normal sync flip. "unthrottled" or something like that would be less confusing. As far as introducing this flag, at least i915 totally lacks a mechanism for deferring the buffer unpinning after the vblank. Hence this can't be used by i915 currently. I think the only reason we get away with the cursor hack is that we unbind the vma lazily and it's unlikely that the small cursor vma is going to get knocked out before the next vblank. For larger buffers that risk grows. We would probably want a stress test that smashes the gtt hard while doing "async updates" to catch this. There's also the question of how out fences work with the async updates. I see that you disallow such an update if there's a previous sync update still pending. That simplifies things a little bit I suppose. But still you would need to track the fences per-plane and signal the old fence ones as soon as the new update overrides the pending update. And if you want to allow multiple planes in one async update then I think the uapi would need to be changed to have per-plane fences as well because subsequent updates could override only a part of a previous update. > It is useful for cursor updates and async PageFlips over the atomic > ioctl, otherwise in some cases updates may be delayed to the point the > user will notice it. > > DRM_MODE_ATOMIC_ASYNC_UPDATE should be passed to the Atomic IOCTL to use > this feature. > > Signed-off-by: Gustavo Padovan > Signed-off-by: Enric Balletbo i Serra > --- > Hi, > > This is an attempt to introduce the new ASYNC_UPDATE flag for atomic > operations, see the commit message for a more detailed description. > > To test this patch we have created an IGT test that we plan to send to > the ML but also was tested using a small program that exercises the uAPI > for easy sanity testing. The program created by Alexandros can be found here > [2]. To test, just build the program and use the --atomic flag to use the > cursor plane in normal (blocking mode), and --atomic-async to use the cursor > plane with the ASYNC_UPDATE flag.E.g. > > drm_cursor --atomic > > or > > drm_cursor --atomic-async > > The test worked on a Samsung Chromebook Plus on top of mainline plus > the patch to update cursors asynchronously through atomic for the > drm/rockchip driver [3]. > > Alexandros also did a proof-of-concept to use this flag and draw cursors > using atomic if possible on ozone [1]. > > Best regards, > Enric > > [1] https://chromium-review.googlesource.com/c/chromium/src/+/1092711 > [2] https://gitlab.collabora.com/alf/drm-cursor > [3] https://patchwork.kernel.org/patch/10492693/ > > > drivers/gpu/drm/drm_atomic.c | 6 ++++++ > drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++--- > include/uapi/drm/drm_mode.h | 4 +++- > 3 files changed, 15 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index c825c76edc1d..15b799f46982 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -80,6 +80,7 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) > * setting this appropriately? > */ > state->allow_modeset = true; > + state->async_update = true; > > state->crtcs = kcalloc(dev->mode_config.num_crtc, > sizeof(*state->crtcs), GFP_KERNEL); > @@ -2320,6 +2321,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, > (arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) > return -EINVAL; > > + if ((arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET) && > + (arg->flags & DRM_MODE_ATOMIC_ASYNC_UPDATE)) > + return -EINVAL; > + > drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); > > state = drm_atomic_state_alloc(dev); > @@ -2328,6 +2333,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, > > state->acquire_ctx = &ctx; > state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); > + state->async_update = !!(arg->flags & DRM_MODE_ATOMIC_ASYNC_UPDATE); > > retry: > plane_mask = 0; > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > index c35654591c12..aeb0523d3bcf 100644 > --- a/drivers/gpu/drm/drm_atomic_helper.c > +++ b/drivers/gpu/drm/drm_atomic_helper.c > @@ -891,7 +891,7 @@ int drm_atomic_helper_check(struct drm_device *dev, > if (ret) > return ret; > > - if (state->legacy_cursor_update) > + if (state->async_update || state->legacy_cursor_update) > state->async_update = !drm_atomic_helper_async_check(dev, state); > > return ret; > @@ -1526,13 +1526,16 @@ int drm_atomic_helper_async_check(struct drm_device *dev, > if (new_plane_state->fence) > return -EINVAL; > > + /* Only do an async update if there is a pending commit. */ > + if (!old_plane_state->commit) > + return -EINVAL; > + > /* > * Don't do an async update if there is an outstanding commit modifying > * the plane. This prevents our async update's changes from getting > * overridden by a previous synchronous update's state. > */ > - if (old_plane_state->commit && > - !try_wait_for_completion(&old_plane_state->commit->hw_done)) > + if (!try_wait_for_completion(&old_plane_state->commit->hw_done)) > return -EBUSY; > > return funcs->atomic_async_check(plane, new_plane_state); > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h > index 50bcf4214ff9..772e84f0edeb 100644 > --- a/include/uapi/drm/drm_mode.h > +++ b/include/uapi/drm/drm_mode.h > @@ -718,13 +718,15 @@ struct drm_mode_destroy_dumb { > #define DRM_MODE_ATOMIC_TEST_ONLY 0x0100 > #define DRM_MODE_ATOMIC_NONBLOCK 0x0200 > #define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400 > +#define DRM_MODE_ATOMIC_ASYNC_UPDATE 0x0800 > > #define DRM_MODE_ATOMIC_FLAGS (\ > DRM_MODE_PAGE_FLIP_EVENT |\ > DRM_MODE_PAGE_FLIP_ASYNC |\ > DRM_MODE_ATOMIC_TEST_ONLY |\ > DRM_MODE_ATOMIC_NONBLOCK |\ > - DRM_MODE_ATOMIC_ALLOW_MODESET) > + DRM_MODE_ATOMIC_ALLOW_MODESET |\ > + DRM_MODE_ATOMIC_ASYNC_UPDATE) > > struct drm_mode_atomic { > __u32 flags; > -- > 2.18.0 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrj?l? Intel