From patchwork Tue Jan 24 23:49:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9536169 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 620D96042D for ; Tue, 24 Jan 2017 23:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562072787C for ; Tue, 24 Jan 2017 23:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B09827BA5; Tue, 24 Jan 2017 23:51:11 +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 C5C5D2787C for ; Tue, 24 Jan 2017 23:51:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 670A76E8BD; Tue, 24 Jan 2017 23:51:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 714BC6E8BF; Tue, 24 Jan 2017 23:51:07 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 24 Jan 2017 15:51:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,281,1477983600"; d="scan'208";a="217227274" Received: from nuc-skylake.jf.intel.com ([10.54.75.136]) by fmsmga004.fm.intel.com with ESMTP; 24 Jan 2017 15:51:06 -0800 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Tue, 24 Jan 2017 15:49:34 -0800 Message-Id: <1485301777-3465-7-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485301777-3465-1-git-send-email-dhinakaran.pandiyan@intel.com> References: <1485301777-3465-1-git-send-email-dhinakaran.pandiyan@intel.com> Cc: Alex Deucher , Daniel Vetter , Dhinakaran Pandiyan , dri-devel@lists.freedesktop.org, Ben Skeggs Subject: [Intel-gfx] [PATCH v2 6/9] 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 | 4 ++++ 2 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 247286b..abebb42 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2500,6 +2500,49 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, } /** + * drm_dp_atomic_release_vcpi_slots() - Release allocated vcpi slots + * @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 req=%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 8cbdbfa..4d61269 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -615,5 +615,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