From patchwork Tue Jan 3 21:01:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9495661 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 70A06606A7 for ; Tue, 3 Jan 2017 21:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6463A271CB for ; Tue, 3 Jan 2017 21:03:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 590EB27CF9; Tue, 3 Jan 2017 21:03:12 +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=ham 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 DEB52271CB for ; Tue, 3 Jan 2017 21:03:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AE586E153; Tue, 3 Jan 2017 21:03:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6ABBE6E153; Tue, 3 Jan 2017 21:03:05 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP; 03 Jan 2017 13:03:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,456,1477983600"; d="scan'208";a="49720302" Received: from nuc-skylake.jf.intel.com ([10.54.75.136]) by fmsmga006.fm.intel.com with ESMTP; 03 Jan 2017 13:03:05 -0800 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Tue, 3 Jan 2017 13:01:50 -0800 Message-Id: <1483477311-3511-6-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483477311-3511-1-git-send-email-dhinakaran.pandiyan@intel.com> References: <1483477311-3511-1-git-send-email-dhinakaran.pandiyan@intel.com> Cc: Daniel Vetter , Dhinakaran Pandiyan , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 5/6] drm/dp: Add DP MST helpers to atomically find and release vcpi slots X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP drm_dp_atomic_find_vcpi_slots() should be called from ->atomic_check() to check there are sufficient vcpi slots for a mode and to add that to the state. This should be followed by a call to drm_dp_mst_allocate_vcpi() in ->atomic_commit() to initialize a struct vcpi for the port. drm_dp_atomic_release_vcpi_slots() should be called from ->atomic_check() to release a port's vcpi slot allocation from the state. Drivers that do not make use of this atomic helper are expected to call drm_dp_find_vcpi_slots() instead before calling drm_dp_mst_allocate_vcpi(). Signed-off-by: Dhinakaran Pandiyan --- drivers/gpu/drm/drm_dp_mst_topology.c | 43 +++++++++++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 5 ++++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 1be19e1..737d61f 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2501,6 +2501,49 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, } /** + * drm_dp_atomic_release_vcpi_slots() - Release allocated vcpi slots from the state + * @topology_state: MST topology state + * @port: port to release the vcpi slots for + */ +int drm_dp_atomic_release_vcpi_slots(struct drm_dp_mst_topology_state *topology_state, + struct drm_dp_mst_port *port) +{ + int alloc = drm_dp_mst_get_vcpi_slots(topology_state->mgr, port); + + topology_state->avail_slots += alloc; + DRM_DEBUG_KMS("vcpi slots released=%d, avail=%d\n", + alloc, topology_state->avail_slots); + return alloc; +} +EXPORT_SYMBOL(drm_dp_atomic_release_vcpi_slots); + +/** + * drm_dp_atomic_find_vcpi_slots() - Find and add vcpi slots to the state + * @topology_state: MST topology state + * @port: port to find vcpi slots for + * @pbn: bandwidth required for the mode in PBN + */ +int drm_dp_atomic_find_vcpi_slots(struct drm_dp_mst_topology_state *topology_state, + struct drm_dp_mst_port *port, int pbn) +{ + int num_slots, curr_alloc; + struct drm_dp_mst_topology_mgr *mgr = topology_state->mgr; + + num_slots = DIV_ROUND_UP(pbn, mgr->pbn_div); + curr_alloc = drm_dp_mst_get_vcpi_slots(mgr, port); + DRM_DEBUG_KMS("vcpi slots new=%d, curr=%d, avail=%d\n", + num_slots, curr_alloc, topology_state->avail_slots); + + if (num_slots - curr_alloc > topology_state->avail_slots) + return -ENOSPC; + + topology_state->avail_slots -= (num_slots - curr_alloc); + DRM_DEBUG_KMS("vcpi slots avail=%d", topology_state->avail_slots); + return num_slots; +} +EXPORT_SYMBOL(drm_dp_atomic_find_vcpi_slots); + +/** * drm_dp_mst_allocate_vcpi() - Allocate a virtual channel * @mgr: manager for this port * @port: port to allocate a virtual channel for. diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 0a9bf20..90395d8 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -609,4 +609,9 @@ void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr); struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr); +int drm_dp_atomic_find_vcpi_slots(struct drm_dp_mst_topology_state *topology_state, + struct drm_dp_mst_port *port, int pbn); +int drm_dp_atomic_release_vcpi_slots(struct drm_dp_mst_topology_state *topology_state, + struct drm_dp_mst_port *port); + #endif