Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3011933ybi; Mon, 17 Jun 2019 14:39:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxK6HPUM7LmGSjdofwjNxgM4+EMJaSnM6G1KcE1BUDCqBwH6CzHFyUsLd1Fa7UIZ1Tn0RiK X-Received: by 2002:a17:90a:9f8e:: with SMTP id o14mr1213229pjp.82.1560807571483; Mon, 17 Jun 2019 14:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807571; cv=none; d=google.com; s=arc-20160816; b=yoA4VLS2vJyflO86Mg0o1imTr7J8K//twuTA4Au0Gl6eKrR2aF19A6/tUDrs8fRXDX SmxUNSiSk8SWAAuKvZwxSwWPOD+FSu/kBPyWfDFz2IbZFW3Skaxb+XQfD0nAgci0kC47 24z0LZ64BaiNtliDbAaq02yKIQO7coTHRby8DjfWZ0MEkSJyfoWW3w4uBFAwt6aG+BjK 9RPBL+9HU6SMLSe28UX0smfjNPy79t0EPvVXnbeq5pGTKi0Ol/SC20lavVhYrAendzoZ HWNSwD9INpycfLDvGQ0dwvyZtUPbDi0AtOt0xLwDldoUZjnQ/yeCuVa7cuH6tPPXc/nf pkoQ== 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:mime-version :message-id:date:subject:cc:to:from; bh=AAg0EjGz9R1hLEivgtxo4cb36kRKdnypy+Cp6DdS1T0=; b=pBc5k56GGljuheuIAKJIOAX77dWprTmiZHBN6YrUxmtB/Xv8OgCGNiBVrHehAtuvlF cl/BWncaNKgJExj/Tt6ZEOF9DxvSShB9gqJN4poXGKKU6xF79yP2kEI/YX0Y1OKqezQn vSk4kNdQCz1pbKSGQz7XNHiD2t82fxxgtfH4aKMWYTIyLstG+ghjn3g97bXiM1yGBZQi AncwF0uFIi1GGEksGDYDMIvwP4H5mzxEs29HFA168o2Z68T0mH+YV+dfVKT5m9uWFW8s bpRXpcxuga7cHRBtRkEjwI16m/pxftI8eavB+oxdC253AxlIe8YkjbedjkpZJjwbDRLj kA7Q== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si12170783pfr.86.2019.06.17.14.39.16; Mon, 17 Jun 2019 14:39:31 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728677AbfFQVjO (ORCPT + 99 others); Mon, 17 Jun 2019 17:39:14 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56534 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726538AbfFQVjN (ORCPT ); Mon, 17 Jun 2019 17:39:13 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 3987B260D9A From: Helen Koike To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: tfiga@chromium.org, mcasas@google.com, zhenyu.z.wang@intel.com, daniel.vetter@ffwll.ch, tina.zhang@intel.com, kernel@collabora.com, ville.syrjala@linux.intel.com, Gustavo Padovan , Enric Balletbo i Serra , Helen Koike , Jani Nikula , Rodrigo Vivi , linux-kernel@vger.kernel.org, Chris Wilson , Matt Roper , David Airlie , Joonas Lahtinen , Maarten Lankhorst , Imre Deak , Daniel Vetter Subject: [PATCH v9 1/2] drm/i915: Introduce async plane update to i915 Date: Mon, 17 Jun 2019 18:38:53 -0300 Message-Id: <20190617213854.32330-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gustavo Padovan Add implementation for async plane update callbacks Signed-off-by: Gustavo Padovan Signed-off-by: Enric Balletbo i Serra Signed-off-by: Tina Zhang Signed-off-by: Helen Koike Tested-by: Tina Zhang --- Hi, I tested this patch set with igt (ksm_cursor_legacy and plane_cursor_legacy) and found no regressions. This patch depends on [1] "[PATCH] drm: don't block fb changes for async plane updates", which is already on drm-misc, otherwise there will be a regression on igt tests: cursor-vs-flip-atomic-transitions-varying-size cursor-vs-flip-toggle cursor-vs-flip-varying-size with errors of type: "CRITICAL: completed 97 cursor updated in a period of 30 flips, we expect to complete approximately 15360 updates, with the threshold set at 7680" When picking this patch, please backmerge [1] into drm-intel tree. [1] https://cgit.freedesktop.org/drm/drm-misc/commit/?h=drm-misc-fixes&id=89a4aac0ab0e6f5eea10d7bf4869dd15c3de2cd4 Thanks Helen Changes in v9: - v8: https://patchwork.kernel.org/patch/10843395/ - Added tested-by tag - submitted to intel-gfx@lists.freedesktop.org to invoke CI - rebased and fixed conflicts on top of drm-tip Changes in v8: - v7: https://lkml.org/lkml/2018/6/8/168 - v7 was splited in two, one that adds the async callbacks and another that updates the cursor. - rebase with drm-intel - allow async update in all types of planes, not only cursor - add watermark checks in async update - remove bypass of intel_prepare_plane_fb() in case of async update - add missing drm_atomic_helper_cleanup_planes(dev, state) call in intel_atomic_commit(). - use swap() function in async update to set the old_fb in the new_state object. - use helpers intel_update_plane()/intel_disable_plane() Changes in v7: - Rebase on top of drm-intel repository. Hopefully now will play nicely with autobuilders. Changes in v6: - Rework the intel_plane_atomic_async_update due driver changed from last time. - Removed the mutex_lock/unlock as causes a deadlock. Changes in v5: - Call drm_atomic_helper_async_check() from the check hook Changes in v4: - Set correct vma to new state for cleanup - Move size checks back to drivers (Ville Syrjälä) Changes in v3: - Move fb setting to core and use new state (Eric Anholt) .../gpu/drm/i915/display/intel_atomic_plane.c | 71 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_display.c | 9 +++ 2 files changed, 80 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c index 30bd4e76fff9..56881a7ec48e 100644 --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c @@ -348,8 +348,79 @@ void i9xx_update_planes_on_crtc(struct intel_atomic_state *state, } } +static int intel_plane_atomic_async_check(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct drm_crtc_state *crtc_state; + + crtc_state = drm_atomic_get_existing_crtc_state(state->state, + state->crtc); + if (WARN_ON(!crtc_state)) + return -EINVAL; + + /* + * When crtc is inactive or there is a modeset pending, + * wait for it to complete in the slowpath + */ + if (!crtc_state->active || to_intel_crtc_state(crtc_state)->update_pipe) + return -EINVAL; + + /* + * If any parameters change that may affect watermarks, + * take the slowpath. Only changing fb or position should be + * in the fastpath. + */ + if (plane->state->crtc != state->crtc || + plane->state->src_w != state->src_w || + plane->state->src_h != state->src_h || + plane->state->crtc_w != state->crtc_w || + plane->state->crtc_h != state->crtc_h || + !plane->state->fb != !state->fb) + return -EINVAL; + + return 0; +} + +static void intel_plane_atomic_async_update(struct drm_plane *plane, + struct drm_plane_state *new_state) +{ + struct intel_atomic_state *intel_new_state = + to_intel_atomic_state(new_state->state); + struct intel_plane *intel_plane = to_intel_plane(plane); + struct drm_crtc *crtc = plane->state->crtc; + struct intel_crtc_state *new_crtc_state; + struct intel_crtc *intel_crtc; + int i; + + for_each_new_intel_crtc_in_state(intel_new_state, intel_crtc, + new_crtc_state, i) + WARN_ON(new_crtc_state->wm.need_postvbl_update || + new_crtc_state->update_wm_post); + + i915_gem_track_fb(intel_fb_obj(plane->state->fb), + intel_fb_obj(new_state->fb), + intel_plane->frontbuffer_bit); + + plane->state->src_x = new_state->src_x; + plane->state->src_y = new_state->src_y; + plane->state->crtc_x = new_state->crtc_x; + plane->state->crtc_y = new_state->crtc_y; + + swap(plane->state->fb, new_state->fb); + + if (plane->state->visible) + intel_update_plane(intel_plane, + to_intel_crtc_state(crtc->state), + to_intel_plane_state(plane->state)); + else + intel_disable_plane(intel_plane, + to_intel_crtc_state(crtc->state)); +} + const struct drm_plane_helper_funcs intel_plane_helper_funcs = { .prepare_fb = intel_prepare_plane_fb, .cleanup_fb = intel_cleanup_plane_fb, .atomic_check = intel_plane_atomic_check, + .atomic_async_check = intel_plane_atomic_async_check, + .atomic_async_update = intel_plane_atomic_async_update, }; diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 8d7e4c8b60bc..bf505b70a037 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -14007,6 +14007,15 @@ static int intel_atomic_commit(struct drm_device *dev, struct drm_i915_private *dev_priv = to_i915(dev); int ret = 0; + if (state->async_update) { + ret = drm_atomic_helper_prepare_planes(dev, state); + if (ret) + return ret; + drm_atomic_helper_async_commit(dev, state); + drm_atomic_helper_cleanup_planes(dev, state); + return 0; + } + intel_state->wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); drm_atomic_state_get(state); -- 2.20.1