blob: 1b71a826e7c2c90c1f5ddfae6c30bd295db1a2e5 [file] [log] [blame]
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001/*
Lloyd Atkinson8c3eca02016-12-20 17:04:33 -05002 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#define pr_fmt(fmt) "[drm:%s] " fmt, __func__
16#include "sde_kms.h"
17#include "sde_hw_lm.h"
18#include "sde_hw_ctl.h"
19#include "sde_hw_cdm.h"
20#include "sde_hw_dspp.h"
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +053021#include "sde_hw_ds.h"
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040022#include "sde_hw_pingpong.h"
23#include "sde_hw_intf.h"
24#include "sde_hw_wb.h"
Alan Kwong83285fb2016-10-21 20:51:17 -040025#include "sde_encoder.h"
26#include "sde_connector.h"
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -080027#include "sde_hw_dsc.h"
Alan Kwong4dd64c82017-02-04 18:41:51 -080028#include "sde_hw_rot.h"
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040029
30#define RESERVED_BY_OTHER(h, r) \
31 ((h)->rsvp && ((h)->rsvp->enc_id != (r)->enc_id))
32
33#define RM_RQ_LOCK(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_RESERVE_LOCK))
34#define RM_RQ_CLEAR(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_RESERVE_CLEAR))
35#define RM_RQ_DSPP(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_DSPP))
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +053036#define RM_RQ_DS(r) ((r)->top_ctrl & BIT(SDE_RM_TOPCTL_DS))
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070037#define RM_IS_TOPOLOGY_MATCH(t, r) ((t).num_lm == (r).num_lm && \
38 (t).num_comp_enc == (r).num_enc && \
39 (t).num_intf == (r).num_intf)
40
41struct sde_rm_topology_def {
42 enum sde_rm_topology_name top_name;
43 int num_lm;
44 int num_comp_enc;
45 int num_intf;
46 int num_ctl;
47 int needs_split_display;
48};
49
50static const struct sde_rm_topology_def g_top_table[] = {
51 { SDE_RM_TOPOLOGY_NONE, 0, 0, 0, 0, false },
52 { SDE_RM_TOPOLOGY_SINGLEPIPE, 1, 0, 1, 1, false },
53 { SDE_RM_TOPOLOGY_SINGLEPIPE_DSC, 1, 1, 1, 1, false },
54 { SDE_RM_TOPOLOGY_DUALPIPE, 2, 0, 2, 2, true },
55 { SDE_RM_TOPOLOGY_DUALPIPE_DSC, 2, 2, 2, 2, true },
56 { SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE, 2, 0, 1, 1, false },
57 { SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC, 2, 1, 1, 1, false },
58 { SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE, 2, 2, 1, 1, false },
59 { SDE_RM_TOPOLOGY_PPSPLIT, 1, 0, 2, 1, true },
60};
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040061
62/**
63 * struct sde_rm_requirements - Reservation requirements parameter bundle
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070064 * @top_ctrl: topology control preference from kernel client
65 * @top: selected topology for the display
66 * @hw_res: Hardware resources required as reported by the encoders
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040067 */
68struct sde_rm_requirements {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040069 uint64_t top_ctrl;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070070 const struct sde_rm_topology_def *topology;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040071 struct sde_encoder_hw_resources hw_res;
72};
73
74/**
75 * struct sde_rm_rsvp - Use Case Reservation tagging structure
76 * Used to tag HW blocks as reserved by a CRTC->Encoder->Connector chain
77 * By using as a tag, rather than lists of pointers to HW blocks used
78 * we can avoid some list management since we don't know how many blocks
79 * of each type a given use case may require.
80 * @list: List head for list of all reservations
81 * @seq: Global RSVP sequence number for debugging, especially for
82 * differentiating differenct allocations for same encoder.
83 * @enc_id: Reservations are tracked by Encoder DRM object ID.
84 * CRTCs may be connected to multiple Encoders.
85 * An encoder or connector id identifies the display path.
86 * @topology DRM<->HW topology use case
87 */
88struct sde_rm_rsvp {
89 struct list_head list;
90 uint32_t seq;
91 uint32_t enc_id;
92 enum sde_rm_topology_name topology;
93};
94
95/**
96 * struct sde_rm_hw_blk - hardware block tracking list member
97 * @list: List head for list of all hardware blocks tracking items
98 * @rsvp: Pointer to use case reservation if reserved by a client
99 * @rsvp_nxt: Temporary pointer used during reservation to the incoming
100 * request. Will be swapped into rsvp if proposal is accepted
101 * @type: Type of hardware block this structure tracks
102 * @id: Hardware ID number, within it's own space, ie. LM_X
103 * @catalog: Pointer to the hardware catalog entry for this block
104 * @hw: Pointer to the hardware register access object for this block
105 */
106struct sde_rm_hw_blk {
107 struct list_head list;
108 struct sde_rm_rsvp *rsvp;
109 struct sde_rm_rsvp *rsvp_nxt;
110 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400111 uint32_t id;
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400112 struct sde_hw_blk *hw;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400113};
114
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400115/**
116 * sde_rm_dbg_rsvp_stage - enum of steps in making reservation for event logging
117 */
118enum sde_rm_dbg_rsvp_stage {
119 SDE_RM_STAGE_BEGIN,
120 SDE_RM_STAGE_AFTER_CLEAR,
121 SDE_RM_STAGE_AFTER_RSVPNEXT,
122 SDE_RM_STAGE_FINAL
123};
124
125static void _sde_rm_print_rsvps(
126 struct sde_rm *rm,
127 enum sde_rm_dbg_rsvp_stage stage)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400128{
129 struct sde_rm_rsvp *rsvp;
130 struct sde_rm_hw_blk *blk;
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400131 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400132
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400133 SDE_DEBUG("%d\n", stage);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400134
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400135 list_for_each_entry(rsvp, &rm->rsvps, list) {
136 SDE_DEBUG("%d rsvp[s%ue%u] topology %d\n", stage, rsvp->seq,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400137 rsvp->enc_id, rsvp->topology);
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400138 SDE_EVT32(stage, rsvp->seq, rsvp->enc_id, rsvp->topology);
139 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400140
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400141 for (type = 0; type < SDE_HW_BLK_MAX; type++) {
142 list_for_each_entry(blk, &rm->hw_blks[type], list) {
143 if (!blk->rsvp && !blk->rsvp_nxt)
144 continue;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400145
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -0400146 SDE_DEBUG("%d rsvp[s%ue%u->s%ue%u] %d %d\n", stage,
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400147 (blk->rsvp) ? blk->rsvp->seq : 0,
148 (blk->rsvp) ? blk->rsvp->enc_id : 0,
149 (blk->rsvp_nxt) ? blk->rsvp_nxt->seq : 0,
150 (blk->rsvp_nxt) ? blk->rsvp_nxt->enc_id : 0,
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -0400151 blk->type, blk->id);
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400152
153 SDE_EVT32(stage,
154 (blk->rsvp) ? blk->rsvp->seq : 0,
155 (blk->rsvp) ? blk->rsvp->enc_id : 0,
156 (blk->rsvp_nxt) ? blk->rsvp_nxt->seq : 0,
157 (blk->rsvp_nxt) ? blk->rsvp_nxt->enc_id : 0,
158 blk->type, blk->id);
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400159 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400160 }
161}
162
163struct sde_hw_mdp *sde_rm_get_mdp(struct sde_rm *rm)
164{
165 return rm->hw_mdp;
166}
167
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400168void sde_rm_init_hw_iter(
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400169 struct sde_rm_hw_iter *iter,
170 uint32_t enc_id,
171 enum sde_hw_blk_type type)
172{
173 memset(iter, 0, sizeof(*iter));
174 iter->enc_id = enc_id;
175 iter->type = type;
176}
177
Jeykumar Sankaran83ddcb02017-10-27 11:34:50 -0700178enum sde_rm_topology_name sde_rm_get_topology_name(
179 struct msm_display_topology topology)
180{
181 int i;
182
183 for (i = 0; i < SDE_RM_TOPOLOGY_MAX; i++)
184 if (RM_IS_TOPOLOGY_MATCH(g_top_table[i], topology))
185 return g_top_table[i].top_name;
186
187 return SDE_RM_TOPOLOGY_NONE;
188}
189
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700190static bool _sde_rm_get_hw_locked(struct sde_rm *rm, struct sde_rm_hw_iter *i)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400191{
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400192 struct list_head *blk_list;
193
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400194 if (!rm || !i || i->type >= SDE_HW_BLK_MAX) {
195 SDE_ERROR("invalid rm\n");
196 return false;
197 }
198
199 i->hw = NULL;
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400200 blk_list = &rm->hw_blks[i->type];
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400201
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400202 if (i->blk && (&i->blk->list == blk_list)) {
Lloyd Atkinson75d898c2017-01-23 10:10:39 -0500203 SDE_DEBUG("attempt resume iteration past last\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400204 return false;
205 }
206
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400207 i->blk = list_prepare_entry(i->blk, blk_list, list);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400208
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400209 list_for_each_entry_continue(i->blk, blk_list, list) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400210 struct sde_rm_rsvp *rsvp = i->blk->rsvp;
211
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400212 if (i->blk->type != i->type) {
213 SDE_ERROR("found incorrect block type %d on %d list\n",
214 i->blk->type, i->type);
215 return false;
216 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400217
218 if ((i->enc_id == 0) || (rsvp && rsvp->enc_id == i->enc_id)) {
219 i->hw = i->blk->hw;
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -0400220 SDE_DEBUG("found type %d id %d for enc %d\n",
221 i->type, i->blk->id, i->enc_id);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400222 return true;
223 }
224 }
225
226 SDE_DEBUG("no match, type %d for enc %d\n", i->type, i->enc_id);
227
228 return false;
229}
230
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700231bool sde_rm_get_hw(struct sde_rm *rm, struct sde_rm_hw_iter *i)
232{
233 bool ret;
234
235 mutex_lock(&rm->rm_lock);
236 ret = _sde_rm_get_hw_locked(rm, i);
237 mutex_unlock(&rm->rm_lock);
238
239 return ret;
240}
241
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400242static void _sde_rm_hw_destroy(enum sde_hw_blk_type type, void *hw)
243{
244 switch (type) {
245 case SDE_HW_BLK_LM:
246 sde_hw_lm_destroy(hw);
247 break;
248 case SDE_HW_BLK_DSPP:
249 sde_hw_dspp_destroy(hw);
250 break;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530251 case SDE_HW_BLK_DS:
252 sde_hw_ds_destroy(hw);
253 break;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400254 case SDE_HW_BLK_CTL:
255 sde_hw_ctl_destroy(hw);
256 break;
257 case SDE_HW_BLK_CDM:
258 sde_hw_cdm_destroy(hw);
259 break;
260 case SDE_HW_BLK_PINGPONG:
261 sde_hw_pingpong_destroy(hw);
262 break;
263 case SDE_HW_BLK_INTF:
264 sde_hw_intf_destroy(hw);
265 break;
266 case SDE_HW_BLK_WB:
267 sde_hw_wb_destroy(hw);
268 break;
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800269 case SDE_HW_BLK_DSC:
270 sde_hw_dsc_destroy(hw);
271 break;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800272 case SDE_HW_BLK_ROT:
273 sde_hw_rot_destroy(hw);
274 break;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400275 case SDE_HW_BLK_SSPP:
276 /* SSPPs are not managed by the resource manager */
277 case SDE_HW_BLK_TOP:
278 /* Top is a singleton, not managed in hw_blks list */
279 case SDE_HW_BLK_MAX:
280 default:
281 SDE_ERROR("unsupported block type %d\n", type);
282 break;
283 }
284}
285
286int sde_rm_destroy(struct sde_rm *rm)
287{
288
289 struct sde_rm_rsvp *rsvp_cur, *rsvp_nxt;
290 struct sde_rm_hw_blk *hw_cur, *hw_nxt;
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400291 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400292
293 if (!rm) {
294 SDE_ERROR("invalid rm\n");
295 return -EINVAL;
296 }
297
298 list_for_each_entry_safe(rsvp_cur, rsvp_nxt, &rm->rsvps, list) {
299 list_del(&rsvp_cur->list);
300 kfree(rsvp_cur);
301 }
302
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400303
304 for (type = 0; type < SDE_HW_BLK_MAX; type++) {
305 list_for_each_entry_safe(hw_cur, hw_nxt, &rm->hw_blks[type],
306 list) {
307 list_del(&hw_cur->list);
308 _sde_rm_hw_destroy(hw_cur->type, hw_cur->hw);
309 kfree(hw_cur);
310 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400311 }
312
313 sde_hw_mdp_destroy(rm->hw_mdp);
314 rm->hw_mdp = NULL;
315
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700316 mutex_destroy(&rm->rm_lock);
317
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400318 return 0;
319}
320
321static int _sde_rm_hw_blk_create(
322 struct sde_rm *rm,
323 struct sde_mdss_cfg *cat,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530324 void __iomem *mmio,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400325 enum sde_hw_blk_type type,
326 uint32_t id,
327 void *hw_catalog_info)
328{
329 struct sde_rm_hw_blk *blk;
330 struct sde_hw_mdp *hw_mdp;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400331 void *hw;
332
333 hw_mdp = rm->hw_mdp;
334
335 switch (type) {
336 case SDE_HW_BLK_LM:
337 hw = sde_hw_lm_init(id, mmio, cat);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400338 break;
339 case SDE_HW_BLK_DSPP:
340 hw = sde_hw_dspp_init(id, mmio, cat);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400341 break;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530342 case SDE_HW_BLK_DS:
343 hw = sde_hw_ds_init(id, mmio, cat);
344 break;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400345 case SDE_HW_BLK_CTL:
346 hw = sde_hw_ctl_init(id, mmio, cat);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400347 break;
348 case SDE_HW_BLK_CDM:
349 hw = sde_hw_cdm_init(id, mmio, cat, hw_mdp);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400350 break;
351 case SDE_HW_BLK_PINGPONG:
352 hw = sde_hw_pingpong_init(id, mmio, cat);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400353 break;
354 case SDE_HW_BLK_INTF:
355 hw = sde_hw_intf_init(id, mmio, cat);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400356 break;
357 case SDE_HW_BLK_WB:
358 hw = sde_hw_wb_init(id, mmio, cat, hw_mdp);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400359 break;
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800360 case SDE_HW_BLK_DSC:
361 hw = sde_hw_dsc_init(id, mmio, cat);
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800362 break;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800363 case SDE_HW_BLK_ROT:
364 hw = sde_hw_rot_init(id, mmio, cat);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800365 break;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400366 case SDE_HW_BLK_SSPP:
367 /* SSPPs are not managed by the resource manager */
368 case SDE_HW_BLK_TOP:
369 /* Top is a singleton, not managed in hw_blks list */
370 case SDE_HW_BLK_MAX:
371 default:
372 SDE_ERROR("unsupported block type %d\n", type);
373 return -EINVAL;
374 }
375
376 if (IS_ERR_OR_NULL(hw)) {
377 SDE_ERROR("failed hw object creation: type %d, err %ld\n",
378 type, PTR_ERR(hw));
379 return -EFAULT;
380 }
381
382 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
383 if (!blk) {
384 _sde_rm_hw_destroy(type, hw);
385 return -ENOMEM;
386 }
387
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400388 blk->type = type;
389 blk->id = id;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400390 blk->hw = hw;
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400391 list_add_tail(&blk->list, &rm->hw_blks[type]);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400392
393 return 0;
394}
395
396int sde_rm_init(struct sde_rm *rm,
397 struct sde_mdss_cfg *cat,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530398 void __iomem *mmio,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400399 struct drm_device *dev)
400{
401 int rc, i;
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400402 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400403
404 if (!rm || !cat || !mmio || !dev) {
405 SDE_ERROR("invalid kms\n");
406 return -EINVAL;
407 }
408
409 /* Clear, setup lists */
410 memset(rm, 0, sizeof(*rm));
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700411
412 mutex_init(&rm->rm_lock);
413
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400414 INIT_LIST_HEAD(&rm->rsvps);
Lloyd Atkinsond1709812016-08-31 10:04:02 -0400415 for (type = 0; type < SDE_HW_BLK_MAX; type++)
416 INIT_LIST_HEAD(&rm->hw_blks[type]);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400417
Alan Kwong4dd64c82017-02-04 18:41:51 -0800418 rm->dev = dev;
419
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400420 /* Some of the sub-blocks require an mdptop to be created */
421 rm->hw_mdp = sde_hw_mdptop_init(MDP_TOP, mmio, cat);
422 if (IS_ERR_OR_NULL(rm->hw_mdp)) {
423 rc = PTR_ERR(rm->hw_mdp);
424 rm->hw_mdp = NULL;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700425 SDE_ERROR("failed: mdp hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400426 goto fail;
427 }
428
429 /* Interrogate HW catalog and create tracking items for hw blocks */
430 for (i = 0; i < cat->mixer_count; i++) {
431 struct sde_lm_cfg *lm = &cat->mixer[i];
432
433 if (lm->pingpong == PINGPONG_MAX) {
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700434 SDE_ERROR("mixer %d without pingpong\n", lm->id);
435 goto fail;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400436 }
437
438 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_LM,
439 cat->mixer[i].id, &cat->mixer[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700440 if (rc) {
441 SDE_ERROR("failed: lm hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400442 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700443 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400444
445 if (!rm->lm_max_width) {
446 rm->lm_max_width = lm->sblk->maxwidth;
447 } else if (rm->lm_max_width != lm->sblk->maxwidth) {
448 /*
449 * Don't expect to have hw where lm max widths differ.
450 * If found, take the min.
451 */
452 SDE_ERROR("unsupported: lm maxwidth differs\n");
453 if (rm->lm_max_width > lm->sblk->maxwidth)
454 rm->lm_max_width = lm->sblk->maxwidth;
455 }
456 }
457
458 for (i = 0; i < cat->dspp_count; i++) {
459 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_DSPP,
460 cat->dspp[i].id, &cat->dspp[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700461 if (rc) {
462 SDE_ERROR("failed: dspp hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400463 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700464 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400465 }
466
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530467 if (cat->mdp[0].has_dest_scaler) {
468 for (i = 0; i < cat->ds_count; i++) {
469 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_DS,
470 cat->ds[i].id, &cat->ds[i]);
471 if (rc) {
472 SDE_ERROR("failed: ds hw not available\n");
473 goto fail;
474 }
475 }
476 }
477
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400478 for (i = 0; i < cat->pingpong_count; i++) {
479 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_PINGPONG,
480 cat->pingpong[i].id, &cat->pingpong[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700481 if (rc) {
482 SDE_ERROR("failed: pp hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400483 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700484 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400485 }
486
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800487 for (i = 0; i < cat->dsc_count; i++) {
488 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_DSC,
489 cat->dsc[i].id, &cat->dsc[i]);
490 if (rc) {
491 SDE_ERROR("failed: dsc hw not available\n");
492 goto fail;
493 }
494 }
495
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400496 for (i = 0; i < cat->intf_count; i++) {
497 if (cat->intf[i].type == INTF_NONE) {
498 SDE_DEBUG("skip intf %d with type none\n", i);
499 continue;
500 }
501
502 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_INTF,
503 cat->intf[i].id, &cat->intf[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700504 if (rc) {
505 SDE_ERROR("failed: intf hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400506 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700507 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400508 }
509
510 for (i = 0; i < cat->wb_count; i++) {
511 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_WB,
512 cat->wb[i].id, &cat->wb[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700513 if (rc) {
514 SDE_ERROR("failed: wb hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400515 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700516 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400517 }
518
Alan Kwong4dd64c82017-02-04 18:41:51 -0800519 for (i = 0; i < cat->rot_count; i++) {
520 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_ROT,
521 cat->rot[i].id, &cat->rot[i]);
522 if (rc) {
523 SDE_ERROR("failed: rot hw not available\n");
524 goto fail;
525 }
526 }
527
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400528 for (i = 0; i < cat->ctl_count; i++) {
529 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_CTL,
530 cat->ctl[i].id, &cat->ctl[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700531 if (rc) {
532 SDE_ERROR("failed: ctl hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400533 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700534 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400535 }
536
537 for (i = 0; i < cat->cdm_count; i++) {
538 rc = _sde_rm_hw_blk_create(rm, cat, mmio, SDE_HW_BLK_CDM,
539 cat->cdm[i].id, &cat->cdm[i]);
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700540 if (rc) {
541 SDE_ERROR("failed: cdm hw not available\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400542 goto fail;
Dhaval Patel3e8b8c92016-10-05 18:01:06 -0700543 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400544 }
545
546 return 0;
547
548fail:
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400549 sde_rm_destroy(rm);
550
551 return rc;
552}
553
554/**
555 * _sde_rm_check_lm_and_get_connected_blks - check if proposed layer mixer meets
556 * proposed use case requirements, incl. hardwired dependent blocks like
557 * pingpong, and dspp.
558 * @rm: sde resource manager handle
559 * @rsvp: reservation currently being created
560 * @reqs: proposed use case requirements
561 * @lm: proposed layer mixer, function checks if lm, and all other hardwired
562 * blocks connected to the lm (pp, dspp) are available and appropriate
563 * @dspp: output parameter, dspp block attached to the layer mixer.
564 * NULL if dspp was not available, or not matching requirements.
565 * @pp: output parameter, pingpong block attached to the layer mixer.
566 * NULL if dspp was not available, or not matching requirements.
567 * @primary_lm: if non-null, this function check if lm is compatible primary_lm
568 * as well as satisfying all other requirements
569 * @Return: true if lm matches all requirements, false otherwise
570 */
571static bool _sde_rm_check_lm_and_get_connected_blks(
572 struct sde_rm *rm,
573 struct sde_rm_rsvp *rsvp,
574 struct sde_rm_requirements *reqs,
575 struct sde_rm_hw_blk *lm,
576 struct sde_rm_hw_blk **dspp,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530577 struct sde_rm_hw_blk **ds,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400578 struct sde_rm_hw_blk **pp,
579 struct sde_rm_hw_blk *primary_lm)
580{
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400581 const struct sde_lm_cfg *lm_cfg = to_sde_hw_mixer(lm->hw)->cap;
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400582 const struct sde_pingpong_cfg *pp_cfg;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400583 struct sde_rm_hw_iter iter;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530584 bool is_valid_dspp, is_valid_ds, ret;
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700585 u32 display_pref;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400586
587 *dspp = NULL;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530588 *ds = NULL;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400589 *pp = NULL;
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700590 display_pref = lm_cfg->features & BIT(SDE_DISP_PRIMARY_PREF);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400591
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700592 SDE_DEBUG("check lm %d: dspp %d ds %d pp %d display_pref: %d\n",
593 lm_cfg->id, lm_cfg->dspp, lm_cfg->ds,
594 lm_cfg->pingpong, display_pref);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400595
596 /* Check if this layer mixer is a peer of the proposed primary LM */
597 if (primary_lm) {
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400598 const struct sde_lm_cfg *prim_lm_cfg =
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400599 to_sde_hw_mixer(primary_lm->hw)->cap;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400600
601 if (!test_bit(lm_cfg->id, &prim_lm_cfg->lm_pair_mask)) {
602 SDE_DEBUG("lm %d not peer of lm %d\n", lm_cfg->id,
603 prim_lm_cfg->id);
604 return false;
605 }
606 }
607
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700608 /* bypass rest of the checks if LM for primary display is found */
609 if (!display_pref) {
610 is_valid_dspp = (lm_cfg->dspp != DSPP_MAX) ? true : false;
611 is_valid_ds = (lm_cfg->ds != DS_MAX) ? true : false;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530612
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700613 /**
614 * RM_RQ_X: specification of which LMs to choose
615 * is_valid_X: indicates whether LM is tied with block X
616 * ret: true if given LM matches the user requirement,
617 * false otherwise
618 */
619 if (RM_RQ_DSPP(reqs) && RM_RQ_DS(reqs))
620 ret = (is_valid_dspp && is_valid_ds);
621 else if (RM_RQ_DSPP(reqs))
622 ret = is_valid_dspp;
623 else if (RM_RQ_DS(reqs))
624 ret = is_valid_ds;
625 else
626 ret = !(is_valid_dspp || is_valid_ds);
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530627
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700628 if (!ret) {
629 SDE_DEBUG(
630 "fail:lm(%d)req_dspp(%d)dspp(%d)req_ds(%d)ds(%d)\n",
631 lm_cfg->id, (bool)(RM_RQ_DSPP(reqs)),
632 lm_cfg->dspp, (bool)(RM_RQ_DS(reqs)),
633 lm_cfg->ds);
634 return ret;
635 }
636 } else if (!(reqs->hw_res.is_primary && display_pref)) {
637 SDE_DEBUG(
638 "display preference is not met. is_primary: %d display_pref: %d\n",
639 (int)reqs->hw_res.is_primary, (int)display_pref);
640 return false;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400641 }
642
643 /* Already reserved? */
644 if (RESERVED_BY_OTHER(lm, rsvp)) {
645 SDE_DEBUG("lm %d already reserved\n", lm_cfg->id);
646 return false;
647 }
648
649 if (lm_cfg->dspp != DSPP_MAX) {
650 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_DSPP);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700651 while (_sde_rm_get_hw_locked(rm, &iter)) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400652 if (iter.blk->id == lm_cfg->dspp) {
653 *dspp = iter.blk;
654 break;
655 }
656 }
657
658 if (!*dspp) {
659 SDE_DEBUG("lm %d failed to retrieve dspp %d\n", lm->id,
660 lm_cfg->dspp);
661 return false;
662 }
663
664 if (RESERVED_BY_OTHER(*dspp, rsvp)) {
665 SDE_DEBUG("lm %d dspp %d already reserved\n",
666 lm->id, (*dspp)->id);
667 return false;
668 }
669 }
670
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530671 if (lm_cfg->ds != DS_MAX) {
672 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_DS);
673 while (_sde_rm_get_hw_locked(rm, &iter)) {
674 if (iter.blk->id == lm_cfg->ds) {
675 *ds = iter.blk;
676 break;
677 }
678 }
679
680 if (!*ds) {
681 SDE_DEBUG("lm %d failed to retrieve ds %d\n", lm->id,
682 lm_cfg->ds);
683 return false;
684 }
685
686 if (RESERVED_BY_OTHER(*ds, rsvp)) {
687 SDE_DEBUG("lm %d ds %d already reserved\n",
688 lm->id, (*ds)->id);
689 return false;
690 }
691 }
692
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400693 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_PINGPONG);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700694 while (_sde_rm_get_hw_locked(rm, &iter)) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400695 if (iter.blk->id == lm_cfg->pingpong) {
696 *pp = iter.blk;
697 break;
698 }
699 }
700
701 if (!*pp) {
702 SDE_ERROR("failed to get pp on lm %d\n", lm_cfg->pingpong);
703 return false;
704 }
705
706 if (RESERVED_BY_OTHER(*pp, rsvp)) {
707 SDE_DEBUG("lm %d pp %d already reserved\n", lm->id,
708 (*pp)->id);
709 *dspp = NULL;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530710 *ds = NULL;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400711 return false;
712 }
713
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400714 pp_cfg = to_sde_hw_pingpong((*pp)->hw)->caps;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700715 if ((reqs->topology->top_name == SDE_RM_TOPOLOGY_PPSPLIT) &&
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400716 !(test_bit(SDE_PINGPONG_SPLIT, &pp_cfg->features))) {
717 SDE_DEBUG("pp %d doesn't support ppsplit\n", pp_cfg->id);
718 *dspp = NULL;
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530719 *ds = NULL;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400720 return false;
721 }
722
723 return true;
724}
725
726static int _sde_rm_reserve_lms(
727 struct sde_rm *rm,
728 struct sde_rm_rsvp *rsvp,
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700729 struct sde_rm_requirements *reqs,
730 u8 *_lm_ids)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400731
732{
733 struct sde_rm_hw_blk *lm[MAX_BLOCKS];
734 struct sde_rm_hw_blk *dspp[MAX_BLOCKS];
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530735 struct sde_rm_hw_blk *ds[MAX_BLOCKS];
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400736 struct sde_rm_hw_blk *pp[MAX_BLOCKS];
737 struct sde_rm_hw_iter iter_i, iter_j;
738 int lm_count = 0;
Clarence Ip8e69ad02016-12-09 09:43:57 -0500739 int i, rc = 0;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400740
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700741 if (!reqs->topology->num_lm) {
742 SDE_ERROR("invalid number of lm: %d\n", reqs->topology->num_lm);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400743 return -EINVAL;
744 }
745
746 /* Find a primary mixer */
747 sde_rm_init_hw_iter(&iter_i, 0, SDE_HW_BLK_LM);
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700748 while (lm_count != reqs->topology->num_lm &&
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700749 _sde_rm_get_hw_locked(rm, &iter_i)) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400750 memset(&lm, 0, sizeof(lm));
751 memset(&dspp, 0, sizeof(dspp));
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530752 memset(&ds, 0, sizeof(ds));
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400753 memset(&pp, 0, sizeof(pp));
754
755 lm_count = 0;
756 lm[lm_count] = iter_i.blk;
757
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700758 SDE_DEBUG("blk id = %d, _lm_ids[%d] = %d\n",
759 iter_i.blk->id,
760 lm_count,
761 _lm_ids ? _lm_ids[lm_count] : -1);
762
763 if (_lm_ids && (lm[lm_count])->id != _lm_ids[lm_count])
764 continue;
765
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530766 if (!_sde_rm_check_lm_and_get_connected_blks(
767 rm, rsvp, reqs, lm[lm_count],
768 &dspp[lm_count], &ds[lm_count],
769 &pp[lm_count], NULL))
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400770 continue;
771
772 ++lm_count;
773
774 /* Valid primary mixer found, find matching peers */
775 sde_rm_init_hw_iter(&iter_j, 0, SDE_HW_BLK_LM);
776
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700777 while (lm_count != reqs->topology->num_lm &&
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700778 _sde_rm_get_hw_locked(rm, &iter_j)) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400779 if (iter_i.blk == iter_j.blk)
780 continue;
781
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530782 if (!_sde_rm_check_lm_and_get_connected_blks(
783 rm, rsvp, reqs, iter_j.blk,
784 &dspp[lm_count], &ds[lm_count],
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400785 &pp[lm_count], iter_i.blk))
786 continue;
787
788 lm[lm_count] = iter_j.blk;
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700789 SDE_DEBUG("blk id = %d, _lm_ids[%d] = %d\n",
790 iter_i.blk->id,
791 lm_count,
792 _lm_ids ? _lm_ids[lm_count] : -1);
793
794 if (_lm_ids && (lm[lm_count])->id != _lm_ids[lm_count])
795 continue;
796
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400797 ++lm_count;
798 }
799 }
800
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700801 if (lm_count != reqs->topology->num_lm) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400802 SDE_DEBUG("unable to find appropriate mixers\n");
803 return -ENAVAIL;
804 }
805
806 for (i = 0; i < ARRAY_SIZE(lm); i++) {
807 if (!lm[i])
808 break;
809
810 lm[i]->rsvp_nxt = rsvp;
811 pp[i]->rsvp_nxt = rsvp;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400812 if (dspp[i])
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400813 dspp[i]->rsvp_nxt = rsvp;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400814
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530815 if (ds[i])
816 ds[i]->rsvp_nxt = rsvp;
817
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400818 SDE_EVT32(lm[i]->type, rsvp->enc_id, lm[i]->id, pp[i]->id,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530819 dspp[i] ? dspp[i]->id : 0,
820 ds[i] ? ds[i]->id : 0);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400821 }
822
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700823 if (reqs->topology->top_name == SDE_RM_TOPOLOGY_PPSPLIT) {
Clarence Ip8e69ad02016-12-09 09:43:57 -0500824 /* reserve a free PINGPONG_SLAVE block */
825 rc = -ENAVAIL;
826 sde_rm_init_hw_iter(&iter_i, 0, SDE_HW_BLK_PINGPONG);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700827 while (_sde_rm_get_hw_locked(rm, &iter_i)) {
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400828 const struct sde_hw_pingpong *pp =
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400829 to_sde_hw_pingpong(iter_i.blk->hw);
Lloyd Atkinson4a752fc2017-05-19 16:09:17 -0400830 const struct sde_pingpong_cfg *pp_cfg = pp->caps;
Clarence Ip8e69ad02016-12-09 09:43:57 -0500831
832 if (!(test_bit(SDE_PINGPONG_SLAVE, &pp_cfg->features)))
833 continue;
834 if (RESERVED_BY_OTHER(iter_i.blk, rsvp))
835 continue;
836
837 iter_i.blk->rsvp_nxt = rsvp;
838 rc = 0;
839 break;
840 }
841 }
842
843 return rc;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400844}
845
846static int _sde_rm_reserve_ctls(
847 struct sde_rm *rm,
848 struct sde_rm_rsvp *rsvp,
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700849 struct sde_rm_requirements *reqs,
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700850 const struct sde_rm_topology_def *top,
851 u8 *_ctl_ids)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400852{
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400853 struct sde_rm_hw_blk *ctls[MAX_BLOCKS];
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400854 struct sde_rm_hw_iter iter;
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400855 int i = 0;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400856
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400857 memset(&ctls, 0, sizeof(ctls));
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400858
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400859 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_CTL);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700860 while (_sde_rm_get_hw_locked(rm, &iter)) {
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400861 const struct sde_hw_ctl *ctl = to_sde_hw_ctl(iter.blk->hw);
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400862 unsigned long features = ctl->caps->features;
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700863 bool has_split_display, has_ppsplit, primary_pref;
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400864
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400865 if (RESERVED_BY_OTHER(iter.blk, rsvp))
866 continue;
867
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400868 has_split_display = BIT(SDE_CTL_SPLIT_DISPLAY) & features;
869 has_ppsplit = BIT(SDE_CTL_PINGPONG_SPLIT) & features;
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700870 primary_pref = BIT(SDE_CTL_PRIMARY_PREF) & features;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400871
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400872 SDE_DEBUG("ctl %d caps 0x%lX\n", iter.blk->id, features);
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400873
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700874 /*
875 * bypass rest feature checks on finding CTL preferred
876 * for primary displays.
877 */
Chandan Uddarajubf4927d2017-10-05 15:36:32 -0700878 if (!primary_pref && !_ctl_ids) {
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700879 if (top->needs_split_display != has_split_display)
880 continue;
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400881
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700882 if (top->top_name == SDE_RM_TOPOLOGY_PPSPLIT &&
883 !has_ppsplit)
884 continue;
885 } else if (!(reqs->hw_res.is_primary && primary_pref)) {
886 SDE_DEBUG(
887 "display pref not met. is_primary: %d primary_pref: %d\n",
888 reqs->hw_res.is_primary, primary_pref);
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400889 continue;
Jeykumar Sankaran6f215d42017-09-12 16:15:23 -0700890 }
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400891
892 ctls[i] = iter.blk;
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700893
894 SDE_DEBUG("blk id = %d, _ctl_ids[%d] = %d\n",
895 iter.blk->id, i,
896 _ctl_ids ? _ctl_ids[i] : -1);
897
898 if (_ctl_ids && (ctls[i]->id != _ctl_ids[i]))
899 continue;
900
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400901 SDE_DEBUG("ctl %d match\n", iter.blk->id);
902
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700903 if (++i == top->num_ctl)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400904 break;
905 }
906
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700907 if (i != top->num_ctl)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400908 return -ENAVAIL;
909
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700910 for (i = 0; i < ARRAY_SIZE(ctls) && i < top->num_ctl; i++) {
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400911 ctls[i]->rsvp_nxt = rsvp;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400912 SDE_EVT32(ctls[i]->type, rsvp->enc_id, ctls[i]->id);
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -0400913 }
914
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400915 return 0;
916}
917
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800918static int _sde_rm_reserve_dsc(
919 struct sde_rm *rm,
920 struct sde_rm_rsvp *rsvp,
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700921 const struct sde_rm_topology_def *top,
922 u8 *_dsc_ids)
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800923{
924 struct sde_rm_hw_iter iter;
925 int alloc_count = 0;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700926 int num_dsc_enc = top->num_lm;
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800927
Jeykumar Sankaran2b098072017-03-16 17:25:59 -0700928 if (!top->num_comp_enc)
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800929 return 0;
930
931 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_DSC);
932
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700933 while (_sde_rm_get_hw_locked(rm, &iter)) {
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800934 if (RESERVED_BY_OTHER(iter.blk, rsvp))
935 continue;
936
Chandan Uddaraju758f28b2017-09-04 10:24:10 -0700937 SDE_DEBUG("blk id = %d, _dsc_ids[%d] = %d\n",
938 iter.blk->id,
939 alloc_count,
940 _dsc_ids ? _dsc_ids[alloc_count] : -1);
941
942 if (_dsc_ids && (iter.blk->id != _dsc_ids[alloc_count]))
943 continue;
944
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -0800945 iter.blk->rsvp_nxt = rsvp;
946 SDE_EVT32(iter.blk->type, rsvp->enc_id, iter.blk->id);
947
948 if (++alloc_count == num_dsc_enc)
949 return 0;
950 }
951
952 SDE_ERROR("couldn't reserve %d dsc blocks for enc id %d\n",
953 num_dsc_enc, rsvp->enc_id);
954
955 return -ENAVAIL;
956}
957
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400958static int _sde_rm_reserve_cdm(
959 struct sde_rm *rm,
960 struct sde_rm_rsvp *rsvp,
961 uint32_t id,
962 enum sde_hw_blk_type type)
963{
964 struct sde_rm_hw_iter iter;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400965
966 sde_rm_init_hw_iter(&iter, 0, SDE_HW_BLK_CDM);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -0700967 while (_sde_rm_get_hw_locked(rm, &iter)) {
Lloyd Atkinsonf82d7b92017-05-19 16:23:04 -0400968 const struct sde_hw_cdm *cdm = to_sde_hw_cdm(iter.blk->hw);
Lloyd Atkinson4a752fc2017-05-19 16:09:17 -0400969 const struct sde_cdm_cfg *caps = cdm->caps;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400970 bool match = false;
971
972 if (RESERVED_BY_OTHER(iter.blk, rsvp))
973 continue;
974
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400975 if (type == SDE_HW_BLK_INTF && id != INTF_MAX)
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400976 match = test_bit(id, &caps->intf_connect);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400977 else if (type == SDE_HW_BLK_WB && id != WB_MAX)
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400978 match = test_bit(id, &caps->wb_connect);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400979
980 SDE_DEBUG("type %d id %d, cdm intfs %lu wbs %lu match %d\n",
Lloyd Atkinsond13cca22017-05-03 14:59:04 -0400981 type, id, caps->intf_connect, caps->wb_connect,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400982 match);
983
984 if (!match)
985 continue;
986
987 iter.blk->rsvp_nxt = rsvp;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400988 SDE_EVT32(iter.blk->type, rsvp->enc_id, iter.blk->id);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400989 break;
990 }
991
992 if (!iter.hw) {
993 SDE_ERROR("couldn't reserve cdm for type %d id %d\n", type, id);
994 return -ENAVAIL;
995 }
996
997 return 0;
998}
999
1000static int _sde_rm_reserve_intf_or_wb(
1001 struct sde_rm *rm,
1002 struct sde_rm_rsvp *rsvp,
1003 uint32_t id,
1004 enum sde_hw_blk_type type,
1005 bool needs_cdm)
1006{
1007 struct sde_rm_hw_iter iter;
Lloyd Atkinson04d301c2016-08-31 11:39:45 -04001008 int ret = 0;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001009
1010 /* Find the block entry in the rm, and note the reservation */
1011 sde_rm_init_hw_iter(&iter, 0, type);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001012 while (_sde_rm_get_hw_locked(rm, &iter)) {
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001013 if (iter.blk->id != id)
1014 continue;
1015
1016 if (RESERVED_BY_OTHER(iter.blk, rsvp)) {
1017 SDE_ERROR("type %d id %d already reserved\n", type, id);
1018 return -ENAVAIL;
1019 }
1020
1021 iter.blk->rsvp_nxt = rsvp;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001022 SDE_EVT32(iter.blk->type, rsvp->enc_id, iter.blk->id);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001023 break;
1024 }
1025
1026 /* Shouldn't happen since wbs / intfs are fixed at probe */
1027 if (!iter.hw) {
1028 SDE_ERROR("couldn't find type %d id %d\n", type, id);
1029 return -EINVAL;
1030 }
1031
1032 /* Expected only one intf or wb will request cdm */
1033 if (needs_cdm)
1034 ret = _sde_rm_reserve_cdm(rm, rsvp, id, type);
1035
1036 return ret;
1037}
1038
1039static int _sde_rm_reserve_intf_related_hw(
1040 struct sde_rm *rm,
1041 struct sde_rm_rsvp *rsvp,
1042 struct sde_encoder_hw_resources *hw_res)
1043{
1044 int i, ret = 0;
1045 u32 id;
1046
1047 for (i = 0; i < ARRAY_SIZE(hw_res->intfs); i++) {
1048 if (hw_res->intfs[i] == INTF_MODE_NONE)
1049 continue;
1050 id = i + INTF_0;
1051 ret = _sde_rm_reserve_intf_or_wb(rm, rsvp, id,
1052 SDE_HW_BLK_INTF, hw_res->needs_cdm);
1053 if (ret)
1054 return ret;
1055 }
1056
1057 for (i = 0; i < ARRAY_SIZE(hw_res->wbs); i++) {
1058 if (hw_res->wbs[i] == INTF_MODE_NONE)
1059 continue;
1060 id = i + WB_0;
1061 ret = _sde_rm_reserve_intf_or_wb(rm, rsvp, id,
1062 SDE_HW_BLK_WB, hw_res->needs_cdm);
1063 if (ret)
1064 return ret;
1065 }
1066
1067 return ret;
1068}
1069
1070static int _sde_rm_make_next_rsvp(
1071 struct sde_rm *rm,
1072 struct drm_encoder *enc,
1073 struct drm_crtc_state *crtc_state,
1074 struct drm_connector_state *conn_state,
1075 struct sde_rm_rsvp *rsvp,
1076 struct sde_rm_requirements *reqs)
1077{
1078 int ret;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001079 struct sde_rm_topology_def topology;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001080
1081 /* Create reservation info, tag reserved blocks with it as we go */
1082 rsvp->seq = ++rm->rsvp_next_seq;
1083 rsvp->enc_id = enc->base.id;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001084 rsvp->topology = reqs->topology->top_name;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001085 list_add_tail(&rsvp->list, &rm->rsvps);
1086
1087 /*
1088 * Assign LMs and blocks whose usage is tied to them: DSPP & Pingpong.
1089 * Do assignment preferring to give away low-resource mixers first:
1090 * - Check mixers without DSPPs
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -04001091 * - Only then allow to grab from mixers with DSPP capability
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001092 */
Chandan Uddaraju758f28b2017-09-04 10:24:10 -07001093 ret = _sde_rm_reserve_lms(rm, rsvp, reqs, NULL);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001094 if (ret && !RM_RQ_DSPP(reqs)) {
1095 reqs->top_ctrl |= BIT(SDE_RM_TOPCTL_DSPP);
Chandan Uddaraju758f28b2017-09-04 10:24:10 -07001096 ret = _sde_rm_reserve_lms(rm, rsvp, reqs, NULL);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001097 }
1098
1099 if (ret) {
1100 SDE_ERROR("unable to find appropriate mixers\n");
1101 return ret;
1102 }
1103
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -04001104 /*
1105 * Do assignment preferring to give away low-resource CTLs first:
1106 * - Check mixers without Split Display
1107 * - Only then allow to grab from CTLs with split display capability
1108 */
Chandan Uddaraju758f28b2017-09-04 10:24:10 -07001109 _sde_rm_reserve_ctls(rm, rsvp, reqs, reqs->topology, NULL);
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001110 if (ret && !reqs->topology->needs_split_display) {
1111 memcpy(&topology, reqs->topology, sizeof(topology));
1112 topology.needs_split_display = true;
Chandan Uddaraju758f28b2017-09-04 10:24:10 -07001113 _sde_rm_reserve_ctls(rm, rsvp, reqs, &topology, NULL);
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -04001114 }
1115 if (ret) {
1116 SDE_ERROR("unable to find appropriate CTL\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001117 return ret;
Lloyd Atkinsoncf8996b2016-08-23 09:34:13 -04001118 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001119
1120 /* Assign INTFs, WBs, and blks whose usage is tied to them: CTL & CDM */
1121 ret = _sde_rm_reserve_intf_related_hw(rm, rsvp, &reqs->hw_res);
1122 if (ret)
1123 return ret;
1124
Chandan Uddaraju758f28b2017-09-04 10:24:10 -07001125 ret = _sde_rm_reserve_dsc(rm, rsvp, reqs->topology, NULL);
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -08001126 if (ret)
1127 return ret;
1128
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001129 return ret;
1130}
1131
Chandan Uddaraju9efbbe32017-11-09 23:57:05 -08001132/**
1133 * sde_rm_get_pp_dsc_for_cont_splash - retrieve the current dsc enabled blocks
1134 * and disable autorefresh if enabled.
1135 * @mmio: mapped register io address of MDP
1136 * @max_dsc_cnt: number of DSC blocks supported in the hw
1137 * @dsc_ids: pointer to store the active DSC block IDs
1138 * return: number of active DSC blocks
1139 */
1140static int _sde_rm_get_pp_dsc_for_cont_splash(struct sde_rm *rm,
1141 int max_dsc_cnt, u8 *dsc_ids)
1142{
1143 int index = 0;
1144 int value, dsc_cnt = 0;
1145 struct sde_hw_autorefresh cfg;
1146 struct sde_rm_hw_iter iter_pp;
1147
1148 if (!rm || !dsc_ids) {
1149 SDE_ERROR("invalid input parameters\n");
1150 return 0;
1151 }
1152
1153 SDE_DEBUG("max_dsc_cnt = %d\n", max_dsc_cnt);
1154 sde_rm_init_hw_iter(&iter_pp, 0, SDE_HW_BLK_PINGPONG);
1155 while (_sde_rm_get_hw_locked(rm, &iter_pp)) {
1156 struct sde_hw_pingpong *pp =
1157 to_sde_hw_pingpong(iter_pp.blk->hw);
1158
1159 if (!pp->ops.get_dsc_status) {
1160 SDE_ERROR("get_dsc_status ops not initialized\n");
1161 return 0;
1162 }
1163 value = pp->ops.get_dsc_status(pp);
1164 SDE_DEBUG("DSC[%d]=0x%x, dsc_cnt = %d\n",
1165 index, value, dsc_cnt);
1166 if (value) {
1167 dsc_ids[dsc_cnt] = index + DSC_0;
1168 dsc_cnt++;
1169 }
1170 index++;
1171
1172 if (!pp->ops.get_autorefresh) {
1173 SDE_ERROR("get_autorefresh api not supported\n");
1174 return 0;
1175 }
1176 memset(&cfg, 0, sizeof(cfg));
1177 if (!pp->ops.get_autorefresh(pp, &cfg)
1178 && (cfg.enable)
1179 && (pp->ops.setup_autorefresh)) {
1180 cfg.enable = false;
1181 SDE_DEBUG("Disabling autoreferesh\n");
1182 pp->ops.setup_autorefresh(pp, &cfg);
1183 /*
1184 * Wait for one frame update so that
1185 * auto refresh disable is through
1186 */
1187 usleep_range(16000, 20000);
1188 }
1189 }
1190
1191 return dsc_cnt;
1192}
1193
1194/**
1195 * _sde_rm_get_ctl_lm_for_cont_splash - retrieve the current LM blocks
1196 * @ctl: Pointer to CTL hardware block
1197 * @max_lm_cnt: number of LM blocks supported in the hw
1198 * @lm_cnt: number of LM blocks already active
1199 * @lm_ids: pointer to store the active LM block IDs
1200 * @top: pointer to the current "ctl_top" structure
1201 * @index: ctl_top index
1202 * return: number of active LM blocks for this CTL block
1203 */
1204static int _sde_rm_get_ctl_lm_for_cont_splash(struct sde_hw_ctl *ctl,
1205 int max_lm_cnt, u8 lm_cnt,
1206 u8 *lm_ids, struct ctl_top *top,
1207 int index)
1208{
1209 int j;
1210 struct sde_splash_lm_hw *lm;
1211
1212 if (!ctl || !top || !lm_ids) {
1213 SDE_ERROR("invalid input parameters\n");
1214 return 0;
1215 }
1216
1217 lm = top->lm;
1218 for (j = 0; j < max_lm_cnt; j++) {
1219 lm[top->ctl_lm_cnt].lm_reg_value =
1220 ctl->ops.read_ctl_layers(ctl, j + LM_0);
1221 SDE_DEBUG("ctl[%d]_top --> lm[%d]=0x%x, j=%d\n",
1222 index, top->ctl_lm_cnt,
1223 lm[top->ctl_lm_cnt].lm_reg_value, j);
1224 SDE_DEBUG("lm_cnt = %d\n", lm_cnt);
1225 if (lm[top->ctl_lm_cnt].lm_reg_value) {
1226 lm[top->ctl_lm_cnt].ctl_id = index;
1227 lm_ids[lm_cnt++] = j + LM_0;
1228 lm[top->ctl_lm_cnt].lm_id = j + LM_0;
1229 SDE_DEBUG("ctl_id=%d, lm[%d].lm_id = %d\n",
1230 lm[top->ctl_lm_cnt].ctl_id,
1231 top->ctl_lm_cnt,
1232 lm[top->ctl_lm_cnt].lm_id);
1233 top->ctl_lm_cnt++;
1234 }
1235 }
1236 return top->ctl_lm_cnt;
1237}
1238
1239/**
1240 * _sde_rm_get_ctl_top_for_cont_splash - retrieve the current LM blocks
1241 * @ctl: Pointer to CTL hardware block
1242 * @top: pointer to the current "ctl_top" structure thats needs update
1243 * @index: ctl_top index
1244 */
1245static void _sde_rm_get_ctl_top_for_cont_splash(struct sde_hw_ctl *ctl,
1246 struct ctl_top *top)
1247{
1248 if (!ctl || !top) {
1249 SDE_ERROR("invalid input parameters\n");
1250 return;
1251 }
1252
1253 if (!ctl->ops.read_ctl_top) {
1254 SDE_ERROR("read_ctl_top not initialized\n");
1255 return;
1256 }
1257
1258 top->value = ctl->ops.read_ctl_top(ctl);
1259 top->intf_sel = (top->value >> 4) & 0xf;
1260 top->pp_sel = (top->value >> 8) & 0x7;
1261 top->dspp_sel = (top->value >> 11) & 0x3;
1262 top->mode_sel = (top->value >> 17) & 0x1;
1263
1264 SDE_DEBUG("id=%d,top->0x%x,pp_sel=0x%x,dspp_sel=0x%x,intf_sel=%d\n",
1265 ctl->idx, top->value, top->pp_sel,
1266 top->dspp_sel, top->intf_sel);
1267}
1268
1269int sde_rm_cont_splash_res_init(struct sde_rm *rm,
1270 struct sde_splash_data *splash_data,
1271 struct sde_mdss_cfg *cat)
1272{
1273 struct sde_rm_hw_iter iter_c;
1274 int index = 0, ctl_top_cnt;
1275
1276 if (!rm || !cat || !splash_data) {
1277 SDE_ERROR("invalid input parameters\n");
1278 return -EINVAL;
1279 }
1280
1281 SDE_DEBUG("mixer_count=%d, ctl_count=%d, dsc_count=%d\n",
1282 cat->mixer_count,
1283 cat->ctl_count,
1284 cat->dsc_count);
1285
1286 ctl_top_cnt = cat->ctl_count;
1287
1288 if (ctl_top_cnt > ARRAY_SIZE(splash_data->top)) {
1289 SDE_ERROR("Mismatch in ctl_top array size\n");
1290 return -EINVAL;
1291 }
1292
1293 sde_rm_init_hw_iter(&iter_c, 0, SDE_HW_BLK_CTL);
1294 while (_sde_rm_get_hw_locked(rm, &iter_c)) {
1295 struct sde_hw_ctl *ctl = to_sde_hw_ctl(iter_c.blk->hw);
1296
1297 _sde_rm_get_ctl_top_for_cont_splash(ctl,
1298 &splash_data->top[index]);
1299 if (splash_data->top[index].intf_sel) {
1300 splash_data->lm_cnt +=
1301 _sde_rm_get_ctl_lm_for_cont_splash
1302 (ctl,
1303 cat->mixer_count,
1304 splash_data->lm_cnt,
1305 splash_data->lm_ids,
1306 &splash_data->top[index], index);
1307 splash_data->ctl_ids[splash_data->ctl_top_cnt]
1308 = index + CTL_0;
1309 splash_data->ctl_top_cnt++;
1310 splash_data->cont_splash_en = true;
1311 }
1312 index++;
1313 }
1314
1315 /* Skip DSC blk reads if cont_splash is disabled */
1316 if (!splash_data->cont_splash_en)
1317 return 0;
1318
1319 splash_data->dsc_cnt =
1320 _sde_rm_get_pp_dsc_for_cont_splash(rm,
1321 cat->dsc_count,
1322 splash_data->dsc_ids);
1323 SDE_DEBUG("splash_data: ctl_top_cnt=%d, lm_cnt=%d, dsc_cnt=%d\n",
1324 splash_data->ctl_top_cnt, splash_data->lm_cnt,
1325 splash_data->dsc_cnt);
1326
1327 return 0;
1328}
1329
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001330static int _sde_rm_make_next_rsvp_for_cont_splash(
1331 struct sde_rm *rm,
1332 struct drm_encoder *enc,
1333 struct drm_crtc_state *crtc_state,
1334 struct drm_connector_state *conn_state,
1335 struct sde_rm_rsvp *rsvp,
1336 struct sde_rm_requirements *reqs)
1337{
1338 int ret;
1339 struct sde_rm_topology_def topology;
1340 struct msm_drm_private *priv;
1341 struct sde_kms *sde_kms;
1342 int i;
1343
1344 if (!enc->dev || !enc->dev->dev_private) {
1345 SDE_ERROR("drm device invalid\n");
1346 return -EINVAL;
1347 }
1348 priv = enc->dev->dev_private;
1349 if (!priv->kms) {
1350 SDE_ERROR("invalid kms\n");
1351 return -EINVAL;
1352 }
1353 sde_kms = to_sde_kms(priv->kms);
1354
1355 for (i = 0; i < sde_kms->splash_data.lm_cnt; i++)
1356 SDE_DEBUG("splash_data.lm_ids[%d] = %d\n",
1357 i, sde_kms->splash_data.lm_ids[i]);
1358
1359 if (sde_kms->splash_data.lm_cnt !=
1360 reqs->topology->num_lm)
1361 SDE_DEBUG("Configured splash screen LMs != needed LM cnt\n");
1362
1363 /* Create reservation info, tag reserved blocks with it as we go */
1364 rsvp->seq = ++rm->rsvp_next_seq;
1365 rsvp->enc_id = enc->base.id;
1366 rsvp->topology = reqs->topology->top_name;
1367 list_add_tail(&rsvp->list, &rm->rsvps);
1368
1369 /*
1370 * Assign LMs and blocks whose usage is tied to them: DSPP & Pingpong.
1371 * Do assignment preferring to give away low-resource mixers first:
1372 * - Check mixers without DSPPs
1373 * - Only then allow to grab from mixers with DSPP capability
1374 */
1375 ret = _sde_rm_reserve_lms(rm, rsvp, reqs,
1376 sde_kms->splash_data.lm_ids);
1377 if (ret && !RM_RQ_DSPP(reqs)) {
1378 reqs->top_ctrl |= BIT(SDE_RM_TOPCTL_DSPP);
1379 ret = _sde_rm_reserve_lms(rm, rsvp, reqs,
1380 sde_kms->splash_data.lm_ids);
1381 }
1382
1383 if (ret) {
1384 SDE_ERROR("unable to find appropriate mixers\n");
1385 return ret;
1386 }
1387
1388 /*
1389 * Do assignment preferring to give away low-resource CTLs first:
1390 * - Check mixers without Split Display
1391 * - Only then allow to grab from CTLs with split display capability
1392 */
1393 for (i = 0; i < sde_kms->splash_data.ctl_top_cnt; i++)
1394 SDE_DEBUG("splash_data.ctl_ids[%d] = %d\n",
1395 i, sde_kms->splash_data.ctl_ids[i]);
1396
1397 _sde_rm_reserve_ctls(rm, rsvp, reqs, reqs->topology,
1398 sde_kms->splash_data.ctl_ids);
1399 if (ret && !reqs->topology->needs_split_display) {
1400 memcpy(&topology, reqs->topology, sizeof(topology));
1401 topology.needs_split_display = true;
1402 _sde_rm_reserve_ctls(rm, rsvp, reqs, &topology,
1403 sde_kms->splash_data.ctl_ids);
1404 }
1405 if (ret) {
1406 SDE_ERROR("unable to find appropriate CTL\n");
1407 return ret;
1408 }
1409
1410 /* Assign INTFs, WBs, and blks whose usage is tied to them: CTL & CDM */
1411 ret = _sde_rm_reserve_intf_related_hw(rm, rsvp, &reqs->hw_res);
1412 if (ret)
1413 return ret;
1414
1415 for (i = 0; i < sde_kms->splash_data.dsc_cnt; i++)
1416 SDE_DEBUG("splash_data.dsc_ids[%d] = %d\n",
1417 i, sde_kms->splash_data.dsc_ids[i]);
1418
1419 ret = _sde_rm_reserve_dsc(rm, rsvp, reqs->topology,
1420 sde_kms->splash_data.dsc_ids);
1421 if (ret)
1422 return ret;
1423
1424 return ret;
1425}
1426
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001427static int _sde_rm_populate_requirements(
1428 struct sde_rm *rm,
1429 struct drm_encoder *enc,
1430 struct drm_crtc_state *crtc_state,
1431 struct drm_connector_state *conn_state,
1432 struct sde_rm_requirements *reqs)
1433{
1434 const struct drm_display_mode *mode = &crtc_state->mode;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001435 int i;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001436
1437 memset(reqs, 0, sizeof(*reqs));
1438
1439 reqs->top_ctrl = sde_connector_get_property(conn_state,
1440 CONNECTOR_PROP_TOPOLOGY_CONTROL);
1441 sde_encoder_get_hw_resources(enc, &reqs->hw_res, conn_state);
1442
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001443 for (i = 0; i < SDE_RM_TOPOLOGY_MAX; i++) {
1444 if (RM_IS_TOPOLOGY_MATCH(g_top_table[i],
1445 reqs->hw_res.topology)) {
1446 reqs->topology = &g_top_table[i];
1447 break;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001448 }
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001449 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001450
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001451 if (!reqs->topology) {
1452 SDE_ERROR("invalid topology for the display\n");
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001453 return -EINVAL;
1454 }
1455
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +05301456 /**
1457 * Set the requirement based on caps if not set from user space
1458 * This will ensure to select LM tied with DS blocks
1459 * Currently, DS blocks are tied with LM 0 and LM 1 (primary display)
1460 */
1461 if (!RM_RQ_DS(reqs) && rm->hw_mdp->caps->has_dest_scaler &&
1462 conn_state->connector->connector_type == DRM_MODE_CONNECTOR_DSI)
1463 reqs->top_ctrl |= BIT(SDE_RM_TOPCTL_DS);
1464
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001465 SDE_DEBUG("top_ctrl: 0x%llX num_h_tiles: %d\n", reqs->top_ctrl,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001466 reqs->hw_res.display_num_of_h_tiles);
Jeykumar Sankaran2b098072017-03-16 17:25:59 -07001467 SDE_DEBUG("num_lm: %d num_ctl: %d topology: %d split_display: %d\n",
1468 reqs->topology->num_lm, reqs->topology->num_ctl,
1469 reqs->topology->top_name,
1470 reqs->topology->needs_split_display);
1471 SDE_EVT32(mode->hdisplay, rm->lm_max_width, reqs->topology->num_lm,
1472 reqs->top_ctrl, reqs->topology->top_name,
1473 reqs->topology->num_ctl);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001474
1475 return 0;
1476}
1477
1478static struct sde_rm_rsvp *_sde_rm_get_rsvp(
1479 struct sde_rm *rm,
1480 struct drm_encoder *enc)
1481{
1482 struct sde_rm_rsvp *i;
1483
1484 if (!rm || !enc) {
1485 SDE_ERROR("invalid params\n");
1486 return NULL;
1487 }
1488
1489 if (list_empty(&rm->rsvps))
1490 return NULL;
1491
1492 list_for_each_entry(i, &rm->rsvps, list)
1493 if (i->enc_id == enc->base.id)
1494 return i;
1495
1496 return NULL;
1497}
1498
1499static struct drm_connector *_sde_rm_get_connector(
1500 struct drm_encoder *enc)
1501{
1502 struct drm_connector *conn = NULL;
1503 struct list_head *connector_list =
1504 &enc->dev->mode_config.connector_list;
1505
1506 list_for_each_entry(conn, connector_list, head)
1507 if (conn->encoder == enc)
1508 return conn;
1509
1510 return NULL;
1511}
1512
Jeykumar Sankaran586d0922017-09-18 15:01:33 -07001513int sde_rm_update_topology(struct drm_connector_state *conn_state,
1514 struct msm_display_topology *topology)
1515{
1516 int i, ret = 0;
1517 struct msm_display_topology top;
1518 enum sde_rm_topology_name top_name = SDE_RM_TOPOLOGY_NONE;
1519
1520 if (!conn_state)
1521 return -EINVAL;
1522
1523 if (topology) {
1524 top = *topology;
1525 for (i = 0; i < SDE_RM_TOPOLOGY_MAX; i++)
1526 if (RM_IS_TOPOLOGY_MATCH(g_top_table[i], top)) {
1527 top_name = g_top_table[i].top_name;
1528 break;
1529 }
1530 }
1531
1532 ret = msm_property_set_property(
1533 sde_connector_get_propinfo(conn_state->connector),
1534 sde_connector_get_property_state(conn_state),
1535 CONNECTOR_PROP_TOPOLOGY_NAME, top_name);
1536
1537 return ret;
1538}
1539
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001540/**
1541 * _sde_rm_release_rsvp - release resources and release a reservation
1542 * @rm: KMS handle
1543 * @rsvp: RSVP pointer to release and release resources for
1544 */
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001545static void _sde_rm_release_rsvp(
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001546 struct sde_rm *rm,
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001547 struct sde_rm_rsvp *rsvp,
1548 struct drm_connector *conn)
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001549{
1550 struct sde_rm_rsvp *rsvp_c, *rsvp_n;
1551 struct sde_rm_hw_blk *blk;
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001552 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001553
1554 if (!rsvp)
1555 return;
1556
1557 SDE_DEBUG("rel rsvp %d enc %d\n", rsvp->seq, rsvp->enc_id);
1558
1559 list_for_each_entry_safe(rsvp_c, rsvp_n, &rm->rsvps, list) {
1560 if (rsvp == rsvp_c) {
1561 list_del(&rsvp_c->list);
1562 break;
1563 }
1564 }
1565
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001566 for (type = 0; type < SDE_HW_BLK_MAX; type++) {
1567 list_for_each_entry(blk, &rm->hw_blks[type], list) {
1568 if (blk->rsvp == rsvp) {
1569 blk->rsvp = NULL;
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -04001570 SDE_DEBUG("rel rsvp %d enc %d %d %d\n",
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001571 rsvp->seq, rsvp->enc_id,
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -04001572 blk->type, blk->id);
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001573 }
1574 if (blk->rsvp_nxt == rsvp) {
1575 blk->rsvp_nxt = NULL;
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -04001576 SDE_DEBUG("rel rsvp_nxt %d enc %d %d %d\n",
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001577 rsvp->seq, rsvp->enc_id,
Lloyd Atkinsonef50d8f2017-05-03 12:06:16 -04001578 blk->type, blk->id);
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001579 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001580 }
1581 }
1582
1583 kfree(rsvp);
1584}
1585
1586void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc)
1587{
1588 struct sde_rm_rsvp *rsvp;
1589 struct drm_connector *conn;
1590 uint64_t top_ctrl;
1591
1592 if (!rm || !enc) {
1593 SDE_ERROR("invalid params\n");
1594 return;
1595 }
1596
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001597 mutex_lock(&rm->rm_lock);
1598
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001599 rsvp = _sde_rm_get_rsvp(rm, enc);
1600 if (!rsvp) {
1601 SDE_ERROR("failed to find rsvp for enc %d\n", enc->base.id);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001602 goto end;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001603 }
1604
1605 conn = _sde_rm_get_connector(enc);
1606 if (!conn) {
1607 SDE_ERROR("failed to get connector for enc %d\n", enc->base.id);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001608 goto end;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001609 }
1610
1611 top_ctrl = sde_connector_get_property(conn->state,
1612 CONNECTOR_PROP_TOPOLOGY_CONTROL);
1613
1614 if (top_ctrl & BIT(SDE_RM_TOPCTL_RESERVE_LOCK)) {
1615 SDE_DEBUG("rsvp[s%de%d] not releasing locked resources\n",
1616 rsvp->seq, rsvp->enc_id);
1617 } else {
1618 SDE_DEBUG("release rsvp[s%de%d]\n", rsvp->seq,
1619 rsvp->enc_id);
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001620 _sde_rm_release_rsvp(rm, rsvp, conn);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001621 }
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001622
1623end:
1624 mutex_unlock(&rm->rm_lock);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001625}
1626
1627static int _sde_rm_commit_rsvp(
1628 struct sde_rm *rm,
1629 struct sde_rm_rsvp *rsvp,
1630 struct drm_connector_state *conn_state)
1631{
1632 struct sde_rm_hw_blk *blk;
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001633 enum sde_hw_blk_type type;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001634 int ret = 0;
1635
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001636 /* Swap next rsvp to be the active */
Lloyd Atkinsond1709812016-08-31 10:04:02 -04001637 for (type = 0; type < SDE_HW_BLK_MAX; type++) {
1638 list_for_each_entry(blk, &rm->hw_blks[type], list) {
1639 if (blk->rsvp_nxt) {
1640 blk->rsvp = blk->rsvp_nxt;
1641 blk->rsvp_nxt = NULL;
1642 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001643 }
1644 }
1645
1646 if (!ret) {
1647 SDE_DEBUG("rsrv enc %d topology %d\n", rsvp->enc_id,
1648 rsvp->topology);
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001649 SDE_EVT32(rsvp->enc_id, rsvp->topology);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001650 }
1651
1652 return ret;
1653}
1654
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001655int sde_rm_reserve(
1656 struct sde_rm *rm,
1657 struct drm_encoder *enc,
1658 struct drm_crtc_state *crtc_state,
1659 struct drm_connector_state *conn_state,
1660 bool test_only)
1661{
1662 struct sde_rm_rsvp *rsvp_cur, *rsvp_nxt;
1663 struct sde_rm_requirements reqs;
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001664 struct msm_drm_private *priv;
1665 struct sde_kms *sde_kms;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001666 int ret;
1667
1668 if (!rm || !enc || !crtc_state || !conn_state) {
1669 SDE_ERROR("invalid arguments\n");
1670 return -EINVAL;
1671 }
1672
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001673 if (!enc->dev || !enc->dev->dev_private) {
1674 SDE_ERROR("drm device invalid\n");
1675 return -EINVAL;
1676 }
1677 priv = enc->dev->dev_private;
1678 if (!priv->kms) {
1679 SDE_ERROR("invalid kms\n");
1680 return -EINVAL;
1681 }
1682 sde_kms = to_sde_kms(priv->kms);
1683
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001684 /* Check if this is just a page-flip */
Chandan Uddaraju9efbbe32017-11-09 23:57:05 -08001685 if (!sde_kms->splash_data.cont_splash_en &&
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001686 !drm_atomic_crtc_needs_modeset(crtc_state))
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001687 return 0;
1688
1689 SDE_DEBUG("reserving hw for conn %d enc %d crtc %d test_only %d\n",
1690 conn_state->connector->base.id, enc->base.id,
1691 crtc_state->crtc->base.id, test_only);
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001692 SDE_EVT32(enc->base.id, conn_state->connector->base.id);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001693
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001694 mutex_lock(&rm->rm_lock);
1695
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001696 _sde_rm_print_rsvps(rm, SDE_RM_STAGE_BEGIN);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001697
1698 ret = _sde_rm_populate_requirements(rm, enc, crtc_state,
1699 conn_state, &reqs);
1700 if (ret) {
1701 SDE_ERROR("failed to populate hw requirements\n");
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001702 goto end;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001703 }
1704
1705 /*
1706 * We only support one active reservation per-hw-block. But to implement
1707 * transactional semantics for test-only, and for allowing failure while
1708 * modifying your existing reservation, over the course of this
1709 * function we can have two reservations:
1710 * Current: Existing reservation
1711 * Next: Proposed reservation. The proposed reservation may fail, or may
1712 * be discarded if in test-only mode.
1713 * If reservation is successful, and we're not in test-only, then we
1714 * replace the current with the next.
1715 */
1716 rsvp_nxt = kzalloc(sizeof(*rsvp_nxt), GFP_KERNEL);
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001717 if (!rsvp_nxt) {
1718 ret = -ENOMEM;
1719 goto end;
1720 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001721
1722 rsvp_cur = _sde_rm_get_rsvp(rm, enc);
1723
1724 /*
1725 * User can request that we clear out any reservation during the
1726 * atomic_check phase by using this CLEAR bit
1727 */
1728 if (rsvp_cur && test_only && RM_RQ_CLEAR(&reqs)) {
1729 SDE_DEBUG("test_only & CLEAR: clear rsvp[s%de%d]\n",
1730 rsvp_cur->seq, rsvp_cur->enc_id);
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001731 _sde_rm_release_rsvp(rm, rsvp_cur, conn_state->connector);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001732 rsvp_cur = NULL;
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001733 _sde_rm_print_rsvps(rm, SDE_RM_STAGE_AFTER_CLEAR);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001734 }
1735
1736 /* Check the proposed reservation, store it in hw's "next" field */
Chandan Uddaraju9efbbe32017-11-09 23:57:05 -08001737 if (sde_kms->splash_data.cont_splash_en) {
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001738 SDE_DEBUG("cont_splash feature enabled\n");
1739 ret = _sde_rm_make_next_rsvp_for_cont_splash
1740 (rm, enc, crtc_state, conn_state, rsvp_nxt, &reqs);
1741 } else {
1742 ret = _sde_rm_make_next_rsvp(rm, enc, crtc_state, conn_state,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001743 rsvp_nxt, &reqs);
Chandan Uddarajubf4927d2017-10-05 15:36:32 -07001744 }
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001745
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001746 _sde_rm_print_rsvps(rm, SDE_RM_STAGE_AFTER_RSVPNEXT);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001747
1748 if (ret) {
1749 SDE_ERROR("failed to reserve hw resources: %d\n", ret);
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001750 _sde_rm_release_rsvp(rm, rsvp_nxt, conn_state->connector);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001751 } else if (test_only && !RM_RQ_LOCK(&reqs)) {
1752 /*
1753 * Normally, if test_only, test the reservation and then undo
1754 * However, if the user requests LOCK, then keep the reservation
1755 * made during the atomic_check phase.
1756 */
1757 SDE_DEBUG("test_only: discard test rsvp[s%de%d]\n",
1758 rsvp_nxt->seq, rsvp_nxt->enc_id);
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001759 _sde_rm_release_rsvp(rm, rsvp_nxt, conn_state->connector);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001760 } else {
1761 if (test_only && RM_RQ_LOCK(&reqs))
1762 SDE_DEBUG("test_only & LOCK: lock rsvp[s%de%d]\n",
1763 rsvp_nxt->seq, rsvp_nxt->enc_id);
1764
Lloyd Atkinson9cb3f9e2016-09-22 12:55:39 -04001765 _sde_rm_release_rsvp(rm, rsvp_cur, conn_state->connector);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001766
1767 ret = _sde_rm_commit_rsvp(rm, rsvp_nxt, conn_state);
1768 }
1769
Lloyd Atkinson5d40d312016-09-06 08:34:13 -04001770 _sde_rm_print_rsvps(rm, SDE_RM_STAGE_FINAL);
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001771
Lloyd Atkinsond3b14572017-04-26 08:33:55 -07001772end:
1773 mutex_unlock(&rm->rm_lock);
1774
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001775 return ret;
1776}