diff mbox

[4/6] drm/dp: Introduce DP MST topology manager state to track DP link bw

Message ID 1483081776-5605-5-git-send-email-dhinakaran.pandiyan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dhinakaran Pandiyan Dec. 30, 2016, 7:09 a.m. UTC
Link bandwidth is shared between multiple display streams in DP MST
configurations. The DP MST topology manager structure maintains the shared
link bandwidth for a primary link directly connected to the GPU. For atomic
modesetting drivers, checking if there is sufficient link bandwidth for a
mode needs to be done during the atomic_check phase to avoid failed
modesets. Let's encsapsulate the available link bw information in a state
structure so that bw can be allocated and released atomically for each of
the ports sharing the primary link.

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/drm_atomic.c          | 66 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_atomic_helper.c   | 10 ++++++
 drivers/gpu/drm/drm_dp_mst_topology.c | 10 ++++++
 include/drm/drm_atomic.h              | 11 ++++++
 include/drm/drm_dp_mst_helper.h       | 13 +++++++
 5 files changed, 110 insertions(+)

Comments

kernel test robot Dec. 30, 2016, 10:21 a.m. UTC | #1
Hi Dhinakaran,

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.10-rc1 next-20161224]
[cannot apply to drm/drm-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dhinakaran-Pandiyan/Introduce-DP-MST-Topology-state/20161230-151546
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
   include/linux/init.h:1: warning: no structured comments found
   include/linux/workqueue.h:392: warning: No description found for parameter '...'
   include/linux/workqueue.h:392: warning: Excess function parameter 'args' description in 'alloc_workqueue'
   include/linux/workqueue.h:413: warning: No description found for parameter '...'
   include/linux/workqueue.h:413: warning: Excess function parameter 'args' description in 'alloc_ordered_workqueue'
   include/linux/kthread.h:26: warning: No description found for parameter '...'
   kernel/sys.c:1: warning: no structured comments found
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/sound/core.h:324: warning: No description found for parameter '...'
   include/sound/core.h:335: warning: No description found for parameter '...'
   include/sound/core.h:388: warning: No description found for parameter '...'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'load'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'firstopen'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'open'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'preclose'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'postclose'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'lastclose'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'unload'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'dma_ioctl'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'dma_quiescent'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'context_dtor'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'set_busid'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'irq_handler'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'irq_preinstall'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'irq_postinstall'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'irq_uninstall'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'debugfs_init'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'debugfs_cleanup'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_open_object'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_close_object'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'prime_handle_to_fd'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'prime_fd_to_handle'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_export'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_import'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_pin'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_unpin'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_res_obj'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_get_sg_table'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_import_sg_table'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_vmap'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_vunmap'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_prime_mmap'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'vgaarb_irq'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'gem_vm_ops'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'major'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'minor'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'patchlevel'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'name'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'desc'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'date'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'driver_features'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'dev_priv_size'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'ioctls'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'num_ioctls'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'fops'
   include/drm/drm_drv.h:409: warning: No description found for parameter 'legacy_dev_list'
>> include/drm/drm_atomic.h:197: warning: No description found for parameter 'num_mst_topologies'
>> include/drm/drm_atomic.h:197: warning: No description found for parameter 'dp_mst_topologies'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'i915'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'pid'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'name'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'hw_id'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'priority'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_alignment'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_offset_bias'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'engine[I915_NUM_ENGINES]'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ring_size'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'desc_template'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'status_notifier'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'execlists_force_single_submission'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'closed'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'bannable'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'banned'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'guilty_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'active_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ban_score'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'hang_stats' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'legacy_hw_ctx' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1203: warning: cannot understand function prototype: 'enum drrs_refresh_rate_type '
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'obj'
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'type'
   drivers/gpu/drm/i915/i915_drv.h:3346: warning: No description found for parameter 'obj'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'i915'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'pid'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'name'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'hw_id'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'priority'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_alignment'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_offset_bias'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'engine[I915_NUM_ENGINES]'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ring_size'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'desc_template'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'status_notifier'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'execlists_force_single_submission'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'closed'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'bannable'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'banned'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'guilty_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'active_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ban_score'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'hang_stats' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'legacy_hw_ctx' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1203: warning: cannot understand function prototype: 'enum drrs_refresh_rate_type '
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'obj'
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'type'
   drivers/gpu/drm/i915/i915_drv.h:3346: warning: No description found for parameter 'obj'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'i915'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'pid'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'name'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'hw_id'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'priority'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_alignment'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ggtt_offset_bias'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'engine[I915_NUM_ENGINES]'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ring_size'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'desc_template'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'status_notifier'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'execlists_force_single_submission'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'closed'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'bannable'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'banned'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'guilty_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'active_count'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: No description found for parameter 'ban_score'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'hang_stats' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1119: warning: Excess struct/union/enum/typedef member 'legacy_hw_ctx' description in 'i915_gem_context'
   drivers/gpu/drm/i915/i915_drv.h:1203: warning: cannot understand function prototype: 'enum drrs_refresh_rate_type '
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'obj'
   drivers/gpu/drm/i915/i915_drv.h:3334: warning: No description found for parameter 'type'
   drivers/gpu/drm/i915/i915_drv.h:3346: warning: No description found for parameter 'obj'
   include/media/media-entity.h:1054: warning: No description found for parameter '...'
   include/net/mac80211.h:3207: ERROR: Unexpected indentation.
   include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/net/mac80211.h:3212: ERROR: Unexpected indentation.
   include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/net/mac80211.h:1772: ERROR: Unexpected indentation.
   include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without end-string.
   kernel/time/timer.c:1240: ERROR: Unexpected indentation.
   kernel/time/timer.c:1242: ERROR: Unexpected indentation.
   kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:121: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:124: ERROR: Unexpected indentation.
   include/linux/wait.h:126: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/signal.c:317: WARNING: Inline literal start-string without end-string.
   drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a blank line; unexpected unindent.
   drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without a blank line; unexpected unindent.
   include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
   WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting

vim +/num_mst_topologies +197 include/drm/drm_atomic.h

43968d7b Daniel Vetter       2016-09-21  181  	struct __drm_crtcs_state *crtcs;
43968d7b Daniel Vetter       2016-09-21  182  	int num_connector;
43968d7b Daniel Vetter       2016-09-21  183  	struct __drm_connnectors_state *connectors;
051ada4a Dhinakaran Pandiyan 2016-12-29  184  	int num_mst_topologies;
051ada4a Dhinakaran Pandiyan 2016-12-29  185  	struct __drm_dp_mst_topology_state *dp_mst_topologies;
43968d7b Daniel Vetter       2016-09-21  186  
43968d7b Daniel Vetter       2016-09-21  187  	struct drm_modeset_acquire_ctx *acquire_ctx;
43968d7b Daniel Vetter       2016-09-21  188  
43968d7b Daniel Vetter       2016-09-21  189  	/**
43968d7b Daniel Vetter       2016-09-21  190  	 * @commit_work:
43968d7b Daniel Vetter       2016-09-21  191  	 *
43968d7b Daniel Vetter       2016-09-21  192  	 * Work item which can be used by the driver or helpers to execute the
43968d7b Daniel Vetter       2016-09-21  193  	 * commit without blocking.
43968d7b Daniel Vetter       2016-09-21  194  	 */
43968d7b Daniel Vetter       2016-09-21  195  	struct work_struct commit_work;
43968d7b Daniel Vetter       2016-09-21  196  };
43968d7b Daniel Vetter       2016-09-21 @197  
3b24f7d6 Daniel Vetter       2016-06-08  198  void drm_crtc_commit_put(struct drm_crtc_commit *commit);
3b24f7d6 Daniel Vetter       2016-06-08  199  static inline void drm_crtc_commit_get(struct drm_crtc_commit *commit)
3b24f7d6 Daniel Vetter       2016-06-08  200  {
3b24f7d6 Daniel Vetter       2016-06-08  201  	kref_get(&commit->ref);
3b24f7d6 Daniel Vetter       2016-06-08  202  }
3b24f7d6 Daniel Vetter       2016-06-08  203  
cc4ceb48 Daniel Vetter       2014-07-25  204  struct drm_atomic_state * __must_check
cc4ceb48 Daniel Vetter       2014-07-25  205  drm_atomic_state_alloc(struct drm_device *dev);

:::::: The code at line 197 was first introduced by commit
:::::: 43968d7b806d7a7e021261294c583a216fddf0e5 drm: Extract drm_plane.[hc]

:::::: TO: Daniel Vetter <daniel.vetter@ffwll.ch>
:::::: CC: Sean Paul <seanpaul@chromium.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index b1b5401..5f2fc96 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -31,6 +31,7 @@ 
 #include <drm/drm_mode.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_print.h>
+#include <drm/drm_dp_mst_helper.h>
 #include <linux/sync_file.h>
 
 #include "drm_crtc_internal.h"
@@ -62,6 +63,7 @@  void drm_atomic_state_default_release(struct drm_atomic_state *state)
 	kfree(state->connectors);
 	kfree(state->crtcs);
 	kfree(state->planes);
+	kfree(state->dp_mst_topologies);
 }
 EXPORT_SYMBOL(drm_atomic_state_default_release);
 
@@ -189,6 +191,18 @@  void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 		state->planes[i].ptr = NULL;
 		state->planes[i].state = NULL;
 	}
+
+	for (i = 0; i < state->num_mst_topologies; i++) {
+		struct drm_dp_mst_topology_mgr *mgr = state->dp_mst_topologies[i].ptr;
+
+		if (!mgr)
+			continue;
+
+		kfree(state->dp_mst_topologies[i].state);
+		state->dp_mst_topologies[i].ptr = NULL;
+		state->dp_mst_topologies[i].state = NULL;
+	}
+
 }
 EXPORT_SYMBOL(drm_atomic_state_default_clear);
 
@@ -981,6 +995,58 @@  static void drm_atomic_plane_print_state(struct drm_printer *p,
 		plane->funcs->atomic_print_state(p, state);
 }
 
+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 ret, i;
+	size_t new_size;
+	struct __drm_dp_mst_topology_state *new_arr;
+	struct drm_dp_mst_topology_state *new_mst_state;
+	int num_topologies;
+	struct drm_mode_config *config = &mgr->dev->mode_config;
+
+	WARN_ON(!state->acquire_ctx);
+
+	ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
+	if (ret)
+		return ERR_PTR(ret);
+
+	for (i = 0; i < state->num_mst_topologies; i++) {
+		if (mgr == state->dp_mst_topologies[i].ptr &&
+		    state->dp_mst_topologies[i].state) {
+			return state->dp_mst_topologies[i].state;
+		}
+	}
+
+	num_topologies = state->num_mst_topologies + 1;
+	new_size = sizeof(*state->dp_mst_topologies) * num_topologies;
+	new_arr = krealloc(state->dp_mst_topologies, new_size, GFP_KERNEL);
+	if (!new_arr)
+		return ERR_PTR(-ENOMEM);
+
+	state->dp_mst_topologies = new_arr;
+	memset(&state->dp_mst_topologies[state->num_mst_topologies], 0,
+		sizeof(*state->dp_mst_topologies));
+
+	new_mst_state = kmalloc(sizeof(*mgr->state), GFP_KERNEL);
+	if (!new_mst_state)
+		return ERR_PTR(-ENOMEM);
+
+	new_mst_state->avail_slots = mgr->state->avail_slots;
+	state->dp_mst_topologies[state->num_mst_topologies].state = new_mst_state;
+	state->dp_mst_topologies[state->num_mst_topologies].ptr = mgr;
+	state->num_mst_topologies = num_topologies;
+	new_mst_state->mgr = mgr;
+	mgr->state->state = state;
+
+	DRM_DEBUG_ATOMIC("Added [MST Topology w/ base connector:%d] %p state to %p\n",
+			 mgr->conn_base_id, new_mst_state, state);
+
+	return new_mst_state;
+}
+EXPORT_SYMBOL(drm_atomic_get_mst_topology_state);
+
 /**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 799c156..0c0e497 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -30,6 +30,7 @@ 
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_mst_helper.h>
 #include <linux/dma-fence.h>
 
 #include "drm_crtc_internal.h"
@@ -1992,6 +1993,15 @@  void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		connector->state->state = NULL;
 	}
 
+	for (i = 0; i < state->num_mst_topologies; i++) {
+		struct drm_dp_mst_topology_mgr *mgr;
+
+		mgr = state->dp_mst_topologies[i].ptr;
+		mgr->state->state = state;
+		swap(state->dp_mst_topologies[i].state, mgr->state);
+		mgr->state->state = NULL;
+	}
+
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
 		crtc->state->state = state;
 		swap(state->crtcs[i].state, crtc->state);
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index d42a6c0..1be19e1 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2042,6 +2042,9 @@  int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
 			goto out_unlock;
 		}
 
+		/* max. time slots - one slot for MTP header */
+		mgr->state->avail_slots = 63;
+
 		/* add initial branch device at LCT 1 */
 		mstb = drm_dp_add_mst_branch_device(1, NULL);
 		if (mstb == NULL) {
@@ -2973,6 +2976,11 @@  int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,
 	mgr->proposed_vcpis = kcalloc(max_payloads, sizeof(struct drm_dp_vcpi *), GFP_KERNEL);
 	if (!mgr->proposed_vcpis)
 		return -ENOMEM;
+	mgr->state = kzalloc(sizeof(*mgr->state), GFP_KERNEL);
+	if (!mgr->state)
+		return -ENOMEM;
+	mgr->state->mgr = mgr;
+
 	set_bit(0, &mgr->payload_mask);
 	if (test_calc_pbn_mode() < 0)
 		DRM_ERROR("MST PBN self-test failed\n");
@@ -2995,6 +3003,8 @@  void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr)
 	kfree(mgr->proposed_vcpis);
 	mgr->proposed_vcpis = NULL;
 	mutex_unlock(&mgr->payload_lock);
+	kfree(mgr->state);
+	mgr->state = NULL;
 	mgr->dev = NULL;
 	mgr->aux = NULL;
 }
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index b0ebe0f..cb91b5a 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -153,6 +153,11 @@  struct __drm_connnectors_state {
 	struct drm_connector_state *state;
 };
 
+struct __drm_dp_mst_topology_state {
+	struct drm_dp_mst_topology_mgr *ptr;
+	struct drm_dp_mst_topology_state *state;
+};
+
 /**
  * struct drm_atomic_state - the global state object for atomic updates
  * @ref: count of all references to this state (will not be freed until zero)
@@ -177,6 +182,8 @@  struct drm_atomic_state {
 	struct __drm_crtcs_state *crtcs;
 	int num_connector;
 	struct __drm_connnectors_state *connectors;
+	int num_mst_topologies;
+	struct __drm_dp_mst_topology_state *dp_mst_topologies;
 
 	struct drm_modeset_acquire_ctx *acquire_ctx;
 
@@ -250,6 +257,10 @@  int drm_atomic_connector_set_property(struct drm_connector *connector,
 		struct drm_connector_state *state, struct drm_property *property,
 		uint64_t val);
 
+struct drm_dp_mst_topology_state * __must_check
+drm_atomic_get_mst_topology_state(struct drm_atomic_state *state,
+				  struct drm_dp_mst_topology_mgr *mgr);
+
 /**
  * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
  * @state: global atomic state object
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 98d3c73..0a9bf20 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -403,6 +403,12 @@  struct drm_dp_payload {
 	int vcpi;
 };
 
+struct drm_dp_mst_topology_state {
+	int avail_slots;
+	struct drm_atomic_state *state;
+	struct drm_dp_mst_topology_mgr *mgr;
+};
+
 /**
  * struct drm_dp_mst_topology_mgr - DisplayPort MST manager
  *
@@ -481,6 +487,11 @@  struct drm_dp_mst_topology_mgr {
 	int pbn_div;
 
 	/**
+	 *  @state: MST topology manager state for atomic modesetting drivers
+	 */
+	struct drm_dp_mst_topology_state *state;
+
+	/**
 	 * @qlock: protects @tx_msg_downq, the tx_slots in struct
 	 * &drm_dp_mst_branch and txmsg->state once they are queued
 	 */
@@ -596,4 +607,6 @@  void drm_dp_mst_dump_topology(struct seq_file *m,
 
 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);
 #endif