From patchwork Fri Oct 21 23:45:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Navare, Manasi" X-Patchwork-Id: 9391601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6246E6077A for ; Mon, 24 Oct 2016 08:32:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5356128D27 for ; Mon, 24 Oct 2016 08:32:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46B3928D62; Mon, 24 Oct 2016 08:32:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9AC6328D27 for ; Mon, 24 Oct 2016 08:32:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 309306E38A; Mon, 24 Oct 2016 08:31:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 313866EDE5; Fri, 21 Oct 2016 23:44:33 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP; 21 Oct 2016 16:44:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,527,1473145200"; d="scan'208";a="22676691" Received: from manasi-otcmedia.jf.intel.com ([10.7.199.175]) by orsmga004.jf.intel.com with ESMTP; 21 Oct 2016 16:44:20 -0700 From: Manasi Navare To: intel-gfx@lists.freedesktop.org Subject: [PATCH 1/5] drm: Add atomic helper to redo a modeset on current mode Date: Fri, 21 Oct 2016 16:45:39 -0700 Message-Id: <1477093543-11622-2-git-send-email-manasi.d.navare@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477093543-11622-1-git-send-email-manasi.d.navare@intel.com> References: <1477093543-11622-1-git-send-email-manasi.d.navare@intel.com> X-Mailman-Approved-At: Mon, 24 Oct 2016 08:31:09 +0000 Cc: Manasi Navare , Daniel Vetter , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function provides a way for the driver to redo a modeset on the current mode and retry the link training at a lower link rate/lane count/bpp. This will get called incase the link training fails during the current modeset. Cc: dri-devel@lists.freedesktop.org Cc: Jani Nikula Cc: Daniel Vetter Cc: Ville Syrjala Signed-off-by: Manasi Navare --- drivers/gpu/drm/drm_atomic_helper.c | 58 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + 2 files changed, 59 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index f936276..0c1614e 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2895,6 +2895,64 @@ int drm_atomic_helper_connector_dpms(struct drm_connector *connector, EXPORT_SYMBOL(drm_atomic_helper_connector_dpms); /** + * drm_atomic_helper_connector_modeset - Force a modeset on a connector + * @connector: DRM connector + * + * Provides a way to redo a modeset with the current mode so that it can + * drop the bpp, link rate/lane count and retry the link training. + * + * Returns: + * Returns 0 on success, negative errno numbers on failure. + */ +int +drm_atomic_helper_connector_modeset(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_modeset_acquire_ctx ctx; + struct drm_atomic_state *state; + struct drm_connector_state *connector_state; + struct drm_crtc_state *crtc_state; + int ret = 0; + + drm_modeset_acquire_init(&ctx, 0); + state = drm_atomic_state_alloc(dev); + if (!state) { + ret = -ENOMEM; + goto fail; + } + state->acquire_ctx = &ctx; +retry: + ret = 0; + connector_state = drm_atomic_get_connector_state(state, connector); + if (IS_ERR(connector_state)) { + ret = PTR_ERR(connector_state); + goto fail; + } + if (!connector_state->crtc) + goto fail; + + crtc_state = drm_atomic_get_existing_crtc_state(state, + connector_state->crtc); + crtc_state->connectors_changed = true; + ret = drm_atomic_commit(state); +fail: + if (ret == -EDEADLK) { + drm_atomic_state_clear(state); + drm_modeset_backoff(&ctx); + goto retry; + } + + if (state) + drm_atomic_state_put(state); + + drm_modeset_drop_locks(&ctx); + drm_modeset_acquire_fini(&ctx); + + return ret; +} +EXPORT_SYMBOL(drm_atomic_helper_connector_modeset); + +/** * drm_atomic_helper_best_encoder - Helper for &drm_connector_helper_funcs * ->best_encoder callback * @connector: Connector control structure diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 7ff92b0..8de24dc 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -126,6 +126,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, uint32_t flags); int drm_atomic_helper_connector_dpms(struct drm_connector *connector, int mode); +int drm_atomic_helper_connector_modeset(struct drm_connector *connector); struct drm_encoder * drm_atomic_helper_best_encoder(struct drm_connector *connector);