dcn10_resource.c 30.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
* Copyright 2016 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */

#include "dm_services.h"
#include "dc.h"

#include "resource.h"
#include "include/irq_service_interface.h"
#include "dcn10/dcn10_resource.h"

#include "dcn10/dcn10_ipp.h"
#include "dcn10/dcn10_mpc.h"
#include "irq/dcn10/irq_service_dcn10.h"
36
#include "dcn10/dcn10_dpp.h"
37
#include "dcn10_optc.h"
38 39 40
#include "dcn10/dcn10_hw_sequencer.h"
#include "dce110/dce110_hw_sequencer.h"
#include "dcn10/dcn10_opp.h"
41
#include "dcn10/dcn10_link_encoder.h"
42
#include "dcn10/dcn10_stream_encoder.h"
43 44 45 46 47 48
#include "dce/dce_clocks.h"
#include "dce/dce_clock_source.h"
#include "dce/dce_audio.h"
#include "dce/dce_hwseq.h"
#include "../virtual/virtual_stream_encoder.h"
#include "dce110/dce110_resource.h"
49
#include "dce112/dce112_resource.h"
50
#include "dcn10_hubp.h"
51
#include "dcn10_hubbub.h"
52

53 54
#include "soc15_hw_ip.h"
#include "vega10_ip_offset.h"
55

56 57
#include "dcn/dcn_1_0_offset.h"
#include "dcn/dcn_1_0_sh_mask.h"
58

59
#include "nbio/nbio_7_0_offset.h"
60

61 62
#include "mmhub/mmhub_9_1_offset.h"
#include "mmhub/mmhub_9_1_sh_mask.h"
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

#include "reg_helper.h"
#include "dce/dce_abm.h"
#include "dce/dce_dmcu.h"

#ifndef mmDP0_DP_DPHY_INTERNAL_CTRL
	#define mmDP0_DP_DPHY_INTERNAL_CTRL		0x210f
	#define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP1_DP_DPHY_INTERNAL_CTRL		0x220f
	#define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP2_DP_DPHY_INTERNAL_CTRL		0x230f
	#define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP3_DP_DPHY_INTERNAL_CTRL		0x240f
	#define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP4_DP_DPHY_INTERNAL_CTRL		0x250f
	#define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP5_DP_DPHY_INTERNAL_CTRL		0x260f
	#define mmDP5_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
	#define mmDP6_DP_DPHY_INTERNAL_CTRL		0x270f
	#define mmDP6_DP_DPHY_INTERNAL_CTRL_BASE_IDX	2
#endif


enum dcn10_clk_src_array_id {
	DCN10_CLK_SRC_PLL0,
	DCN10_CLK_SRC_PLL1,
	DCN10_CLK_SRC_PLL2,
	DCN10_CLK_SRC_PLL3,
	DCN10_CLK_SRC_TOTAL
};

/* begin *********************
 * macros to expend register list macro defined in HW object header file */

/* DCN */
#define BASE_INNER(seg) \
	DCE_BASE__INST0_SEG ## seg

#define BASE(seg) \
	BASE_INNER(seg)

#define SR(reg_name)\
		.reg_name = BASE(mm ## reg_name ## _BASE_IDX) +  \
					mm ## reg_name

#define SRI(reg_name, block, id)\
	.reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
					mm ## block ## id ## _ ## reg_name


#define SRII(reg_name, block, id)\
	.reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
					mm ## block ## id ## _ ## reg_name

/* NBIO */
#define NBIO_BASE_INNER(seg) \
	NBIF_BASE__INST0_SEG ## seg

#define NBIO_BASE(seg) \
	NBIO_BASE_INNER(seg)

#define NBIO_SR(reg_name)\
		.reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) +  \
					mm ## reg_name

128 129 130
/* MMHUB */
#define MMHUB_BASE_INNER(seg) \
	MMHUB_BASE__INST0_SEG ## seg
131

132 133
#define MMHUB_BASE(seg) \
	MMHUB_BASE_INNER(seg)
134

135 136
#define MMHUB_SR(reg_name)\
		.reg_name = MMHUB_BASE(mm ## reg_name ## _BASE_IDX) +  \
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
					mm ## reg_name

/* macros to expend register list macro defined in HW object header file
 * end *********************/


static const struct dce_dmcu_registers dmcu_regs = {
		DMCU_DCN10_REG_LIST()
};

static const struct dce_dmcu_shift dmcu_shift = {
		DMCU_MASK_SH_LIST_DCN10(__SHIFT)
};

static const struct dce_dmcu_mask dmcu_mask = {
		DMCU_MASK_SH_LIST_DCN10(_MASK)
};

static const struct dce_abm_registers abm_regs = {
		ABM_DCN10_REG_LIST(0)
};

static const struct dce_abm_shift abm_shift = {
		ABM_MASK_SH_LIST_DCN10(__SHIFT)
};

static const struct dce_abm_mask abm_mask = {
		ABM_MASK_SH_LIST_DCN10(_MASK)
};

#define stream_enc_regs(id)\
[id] = {\
169
	SE_DCN_REG_LIST(id)\
170 171
}

172
static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
173 174 175 176 177 178
	stream_enc_regs(0),
	stream_enc_regs(1),
	stream_enc_regs(2),
	stream_enc_regs(3),
};

179
static const struct dcn10_stream_encoder_shift se_shift = {
180 181 182
		SE_COMMON_MASK_SH_LIST_DCN10(__SHIFT)
};

183 184
static const struct dcn10_stream_encoder_mask se_mask = {
		SE_COMMON_MASK_SH_LIST_DCN10(_MASK)
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
};

#define audio_regs(id)\
[id] = {\
		AUD_COMMON_REG_LIST(id)\
}

static const struct dce_audio_registers audio_regs[] = {
	audio_regs(0),
	audio_regs(1),
	audio_regs(2),
	audio_regs(3),
};

#define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
		AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)

static const struct dce_audio_shift audio_shift = {
		DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
};

static const struct dce_aduio_mask audio_mask = {
		DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
};

#define aux_regs(id)\
[id] = {\
	AUX_REG_LIST(id)\
}

217
static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
218 219 220
		aux_regs(0),
		aux_regs(1),
		aux_regs(2),
221
		aux_regs(3)
222 223 224 225 226 227 228
};

#define hpd_regs(id)\
[id] = {\
	HPD_REG_LIST(id)\
}

229
static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
230 231 232
		hpd_regs(0),
		hpd_regs(1),
		hpd_regs(2),
233
		hpd_regs(3)
234 235 236 237 238 239 240 241
};

#define link_regs(id)\
[id] = {\
	LE_DCN10_REG_LIST(id), \
	SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
}

242
static const struct dcn10_link_enc_registers link_enc_regs[] = {
243 244 245
	link_regs(0),
	link_regs(1),
	link_regs(2),
246 247 248 249 250 251 252 253 254
	link_regs(3)
};

static const struct dcn10_link_enc_shift le_shift = {
		LINK_ENCODER_MASK_SH_LIST_DCN10(__SHIFT)
};

static const struct dcn10_link_enc_mask le_mask = {
		LINK_ENCODER_MASK_SH_LIST_DCN10(_MASK)
255 256 257 258
};

#define ipp_regs(id)\
[id] = {\
259
	IPP_REG_LIST_DCN10(id),\
260 261 262 263 264 265 266 267 268 269
}

static const struct dcn10_ipp_registers ipp_regs[] = {
	ipp_regs(0),
	ipp_regs(1),
	ipp_regs(2),
	ipp_regs(3),
};

static const struct dcn10_ipp_shift ipp_shift = {
270
		IPP_MASK_SH_LIST_DCN10(__SHIFT)
271 272 273
};

static const struct dcn10_ipp_mask ipp_mask = {
274
		IPP_MASK_SH_LIST_DCN10(_MASK),
275 276 277 278
};

#define opp_regs(id)\
[id] = {\
279
	OPP_REG_LIST_DCN10(id),\
280 281 282 283 284 285 286 287 288 289
}

static const struct dcn10_opp_registers opp_regs[] = {
	opp_regs(0),
	opp_regs(1),
	opp_regs(2),
	opp_regs(3),
};

static const struct dcn10_opp_shift opp_shift = {
290
		OPP_MASK_SH_LIST_DCN10(__SHIFT)
291 292 293
};

static const struct dcn10_opp_mask opp_mask = {
294
		OPP_MASK_SH_LIST_DCN10(_MASK),
295 296 297 298
};

#define tf_regs(id)\
[id] = {\
299
	TF_REG_LIST_DCN10(id),\
300 301
}

302
static const struct dcn_dpp_registers tf_regs[] = {
303 304 305 306 307 308
	tf_regs(0),
	tf_regs(1),
	tf_regs(2),
	tf_regs(3),
};

309
static const struct dcn_dpp_shift tf_shift = {
310
	TF_REG_LIST_SH_MASK_DCN10(__SHIFT),
311 312
	TF_DEBUG_REG_LIST_SH_DCN10

313 314
};

315
static const struct dcn_dpp_mask tf_mask = {
316
	TF_REG_LIST_SH_MASK_DCN10(_MASK),
317
	TF_DEBUG_REG_LIST_MASK_DCN10
318 319
};

320 321 322 323
static const struct dcn_mpc_registers mpc_regs = {
		MPC_COMMON_REG_LIST_DCN1_0(0),
		MPC_COMMON_REG_LIST_DCN1_0(1),
		MPC_COMMON_REG_LIST_DCN1_0(2),
324 325 326 327 328
		MPC_COMMON_REG_LIST_DCN1_0(3),
		MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(0),
		MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(1),
		MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(2),
		MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(3)
329 330
};

331 332
static const struct dcn_mpc_shift mpc_shift = {
	MPC_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
333 334
};

335 336
static const struct dcn_mpc_mask mpc_mask = {
	MPC_COMMON_MASK_SH_LIST_DCN1_0(_MASK),
337 338 339 340 341
};

#define tg_regs(id)\
[id] = {TG_COMMON_REG_LIST_DCN1_0(id)}

342
static const struct dcn_optc_registers tg_regs[] = {
343 344 345 346 347 348
	tg_regs(0),
	tg_regs(1),
	tg_regs(2),
	tg_regs(3),
};

349
static const struct dcn_optc_shift tg_shift = {
350 351 352
	TG_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
};

353
static const struct dcn_optc_mask tg_mask = {
354 355 356 357 358
	TG_COMMON_MASK_SH_LIST_DCN1_0(_MASK)
};


static const struct bios_registers bios_regs = {
359
		NBIO_SR(BIOS_SCRATCH_3),
360 361 362
		NBIO_SR(BIOS_SCRATCH_6)
};

363
#define hubp_regs(id)\
364
[id] = {\
365
	HUBP_REG_LIST_DCN10(id)\
366 367 368
}


369 370 371 372 373
static const struct dcn_mi_registers hubp_regs[] = {
	hubp_regs(0),
	hubp_regs(1),
	hubp_regs(2),
	hubp_regs(3),
374 375
};

376 377
static const struct dcn_mi_shift hubp_shift = {
		HUBP_MASK_SH_LIST_DCN10(__SHIFT)
378 379
};

380 381
static const struct dcn_mi_mask hubp_mask = {
		HUBP_MASK_SH_LIST_DCN10(_MASK)
382 383
};

384 385 386 387 388 389 390 391 392 393 394 395 396

static const struct dcn_hubbub_registers hubbub_reg = {
		HUBBUB_REG_LIST_DCN10(0)
};

static const struct dcn_hubbub_shift hubbub_shift = {
		HUBBUB_MASK_SH_LIST_DCN10(__SHIFT)
};

static const struct dcn_hubbub_mask hubbub_mask = {
		HUBBUB_MASK_SH_LIST_DCN10(_MASK)
};

397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
#define clk_src_regs(index, pllid)\
[index] = {\
	CS_COMMON_REG_LIST_DCN1_0(index, pllid),\
}

static const struct dce110_clk_src_regs clk_src_regs[] = {
	clk_src_regs(0, A),
	clk_src_regs(1, B),
	clk_src_regs(2, C),
	clk_src_regs(3, D)
};

static const struct dce110_clk_src_shift cs_shift = {
		CS_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
};

static const struct dce110_clk_src_mask cs_mask = {
		CS_COMMON_MASK_SH_LIST_DCN1_0(_MASK)
};


static const struct resource_caps res_cap = {
		.num_timing_generator = 4,
420
		.num_opp = 4,
421 422 423 424 425 426 427
		.num_video_plane = 4,
		.num_audio = 4,
		.num_stream_encoder = 4,
		.num_pll = 4,
};

static const struct dc_debug debug_defaults_drv = {
428
		.sanity_checks = true,
429 430 431
		.disable_dmcu = true,
		.force_abm_enable = false,
		.timing_trace = false,
432
		.clock_trace = true,
433

434 435 436 437 438 439
		/* raven smu dones't allow 0 disp clk,
		 * smu min disp clk limit is 50Mhz
		 * keep min disp clk 100Mhz avoid smu hang
		 */
		.min_disp_clk_khz = 100000,

440
		.disable_pplib_clock_request = true,
441
		.disable_pplib_wm_range = false,
442
		.pplib_wm_report_mode = WM_REPORT_DEFAULT,
443
		.pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
444
		.force_single_disp_pipe_split = true,
445
		.disable_dcc = DCC_ENABLE,
446
		.voltage_align_fclk = true,
447
		.disable_stereo_support = true,
448
		.vsr_support = true,
449
		.performance_trace = false,
450
		.az_endpoint_mute_only = true,
451
		.recovery_enabled = false, /*enable this by default after testing.*/
452
		.max_downscale_src_width = 3840,
453 454 455 456 457 458
};

static const struct dc_debug debug_defaults_diags = {
		.disable_dmcu = true,
		.force_abm_enable = false,
		.timing_trace = true,
459
		.clock_trace = true,
460
		.disable_stutter = true,
461
		.disable_pplib_clock_request = true,
462
		.disable_pplib_wm_range = true
463 464
};

465
static void dcn10_dpp_destroy(struct dpp **dpp)
466
{
467 468
	kfree(TO_DCN10_DPP(*dpp));
	*dpp = NULL;
469 470
}

471
static struct dpp *dcn10_dpp_create(
472 473 474
	struct dc_context *ctx,
	uint32_t inst)
{
475
	struct dcn10_dpp *dpp =
476
		kzalloc(sizeof(struct dcn10_dpp), GFP_KERNEL);
477

478
	if (!dpp)
479 480
		return NULL;

481 482
	dpp1_construct(dpp, ctx, inst,
		       &tf_regs[inst], &tf_shift, &tf_mask);
483
	return &dpp->base;
484 485 486 487 488 489
}

static struct input_pixel_processor *dcn10_ipp_create(
	struct dc_context *ctx, uint32_t inst)
{
	struct dcn10_ipp *ipp =
490
		kzalloc(sizeof(struct dcn10_ipp), GFP_KERNEL);
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506

	if (!ipp) {
		BREAK_TO_DEBUGGER();
		return NULL;
	}

	dcn10_ipp_construct(ipp, ctx, inst,
			&ipp_regs[inst], &ipp_shift, &ipp_mask);
	return &ipp->base;
}


static struct output_pixel_processor *dcn10_opp_create(
	struct dc_context *ctx, uint32_t inst)
{
	struct dcn10_opp *opp =
507
		kzalloc(sizeof(struct dcn10_opp), GFP_KERNEL);
508 509 510 511 512 513 514 515 516 517 518

	if (!opp) {
		BREAK_TO_DEBUGGER();
		return NULL;
	}

	dcn10_opp_construct(opp, ctx, inst,
			&opp_regs[inst], &opp_shift, &opp_mask);
	return &opp->base;
}

519
static struct mpc *dcn10_mpc_create(struct dc_context *ctx)
520
{
521 522
	struct dcn10_mpc *mpc10 = kzalloc(sizeof(struct dcn10_mpc),
					  GFP_KERNEL);
523

524
	if (!mpc10)
525 526
		return NULL;

527 528 529 530 531
	dcn10_mpc_construct(mpc10, ctx,
			&mpc_regs,
			&mpc_shift,
			&mpc_mask,
			4);
532

533
	return &mpc10->base;
534 535
}

536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
static struct hubbub *dcn10_hubbub_create(struct dc_context *ctx)
{
	struct hubbub *hubbub = kzalloc(sizeof(struct hubbub),
					  GFP_KERNEL);

	if (!hubbub)
		return NULL;

	hubbub1_construct(hubbub, ctx,
			&hubbub_reg,
			&hubbub_shift,
			&hubbub_mask);

	return hubbub;
}

552 553 554 555
static struct timing_generator *dcn10_timing_generator_create(
		struct dc_context *ctx,
		uint32_t instance)
{
556 557
	struct optc *tgn10 =
		kzalloc(sizeof(struct optc), GFP_KERNEL);
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587

	if (!tgn10)
		return NULL;

	tgn10->base.inst = instance;
	tgn10->base.ctx = ctx;

	tgn10->tg_regs = &tg_regs[instance];
	tgn10->tg_shift = &tg_shift;
	tgn10->tg_mask = &tg_mask;

	dcn10_timing_generator_init(tgn10);

	return &tgn10->base;
}

static const struct encoder_feature_support link_enc_feature = {
		.max_hdmi_deep_color = COLOR_DEPTH_121212,
		.max_hdmi_pixel_clock = 600000,
		.ycbcr420_supported = true,
		.flags.bits.IS_HBR2_CAPABLE = true,
		.flags.bits.IS_HBR3_CAPABLE = true,
		.flags.bits.IS_TPS3_CAPABLE = true,
		.flags.bits.IS_TPS4_CAPABLE = true,
		.flags.bits.IS_YCBCR_CAPABLE = true
};

struct link_encoder *dcn10_link_encoder_create(
	const struct encoder_init_data *enc_init_data)
{
588 589
	struct dcn10_link_encoder *enc10 =
		kzalloc(sizeof(struct dcn10_link_encoder), GFP_KERNEL);
590

591
	if (!enc10)
592 593
		return NULL;

594
	dcn10_link_encoder_construct(enc10,
595 596 597 598
				      enc_init_data,
				      &link_enc_feature,
				      &link_enc_regs[enc_init_data->transmitter],
				      &link_enc_aux_regs[enc_init_data->channel - 1],
599 600 601
				      &link_enc_hpd_regs[enc_init_data->hpd_source],
				      &le_shift,
				      &le_mask);
602

603
	return &enc10->base;
604 605 606 607 608 609 610 611 612 613
}

struct clock_source *dcn10_clock_source_create(
	struct dc_context *ctx,
	struct dc_bios *bios,
	enum clock_source_id id,
	const struct dce110_clk_src_regs *regs,
	bool dp_clk_src)
{
	struct dce110_clk_src *clk_src =
614
		kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632

	if (!clk_src)
		return NULL;

	if (dce110_clk_src_construct(clk_src, ctx, bios, id,
			regs, &cs_shift, &cs_mask)) {
		clk_src->base.dp_clk_src = dp_clk_src;
		return &clk_src->base;
	}

	BREAK_TO_DEBUGGER();
	return NULL;
}

static void read_dce_straps(
	struct dc_context *ctx,
	struct resource_straps *straps)
{
633 634
	generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
		FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
635 636 637 638 639 640 641 642 643 644 645 646 647
}

static struct audio *create_audio(
		struct dc_context *ctx, unsigned int inst)
{
	return dce_audio_create(ctx, inst,
			&audio_regs[inst], &audio_shift, &audio_mask);
}

static struct stream_encoder *dcn10_stream_encoder_create(
	enum engine_id eng_id,
	struct dc_context *ctx)
{
648 649
	struct dcn10_stream_encoder *enc1 =
		kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
650

651
	if (!enc1)
652 653
		return NULL;

654
	dcn10_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id,
655 656
					&stream_enc_regs[eng_id],
					&se_shift, &se_mask);
657
	return &enc1->base;
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
}

static const struct dce_hwseq_registers hwseq_reg = {
		HWSEQ_DCN1_REG_LIST()
};

static const struct dce_hwseq_shift hwseq_shift = {
		HWSEQ_DCN1_MASK_SH_LIST(__SHIFT)
};

static const struct dce_hwseq_mask hwseq_mask = {
		HWSEQ_DCN1_MASK_SH_LIST(_MASK)
};

static struct dce_hwseq *dcn10_hwseq_create(
	struct dc_context *ctx)
{
675
	struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
676 677 678 679 680 681

	if (hws) {
		hws->ctx = ctx;
		hws->regs = &hwseq_reg;
		hws->shifts = &hwseq_shift;
		hws->masks = &hwseq_mask;
682
		hws->wa.DEGVIDCN10_253 = true;
683
		hws->wa.false_optc_underflow = true;
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
	}
	return hws;
}

static const struct resource_create_funcs res_create_funcs = {
	.read_dce_straps = read_dce_straps,
	.create_audio = create_audio,
	.create_stream_encoder = dcn10_stream_encoder_create,
	.create_hwseq = dcn10_hwseq_create,
};

static const struct resource_create_funcs res_create_maximus_funcs = {
	.read_dce_straps = NULL,
	.create_audio = NULL,
	.create_stream_encoder = NULL,
	.create_hwseq = dcn10_hwseq_create,
};

void dcn10_clock_source_destroy(struct clock_source **clk_src)
{
704
	kfree(TO_DCE110_CLK_SRC(*clk_src));
705 706 707
	*clk_src = NULL;
}

708 709
static struct pp_smu_funcs_rv *dcn10_pp_smu_create(struct dc_context *ctx)
{
710
	struct pp_smu_funcs_rv *pp_smu = kzalloc(sizeof(*pp_smu), GFP_KERNEL);
711 712 713 714 715 716 717 718

	if (!pp_smu)
		return pp_smu;

	dm_pp_get_funcs_rv(ctx, pp_smu);
	return pp_smu;
}

719 720 721 722 723 724 725 726 727
static void destruct(struct dcn10_resource_pool *pool)
{
	unsigned int i;

	for (i = 0; i < pool->base.stream_enc_count; i++) {
		if (pool->base.stream_enc[i] != NULL) {
			/* TODO: free dcn version of stream encoder once implemented
			 * rather than using virtual stream encoder
			 */
728
			kfree(pool->base.stream_enc[i]);
729 730 731 732
			pool->base.stream_enc[i] = NULL;
		}
	}

733
	if (pool->base.mpc != NULL) {
734
		kfree(TO_DCN10_MPC(pool->base.mpc));
735 736
		pool->base.mpc = NULL;
	}
737 738 739 740 741 742

	if (pool->base.hubbub != NULL) {
		kfree(pool->base.hubbub);
		pool->base.hubbub = NULL;
	}

743 744 745 746
	for (i = 0; i < pool->base.pipe_count; i++) {
		if (pool->base.opps[i] != NULL)
			pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);

747 748
		if (pool->base.dpps[i] != NULL)
			dcn10_dpp_destroy(&pool->base.dpps[i]);
749 750 751 752

		if (pool->base.ipps[i] != NULL)
			pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);

753 754 755
		if (pool->base.hubps[i] != NULL) {
			kfree(TO_DCN10_HUBP(pool->base.hubps[i]));
			pool->base.hubps[i] = NULL;
756 757 758 759 760 761 762
		}

		if (pool->base.irqs != NULL) {
			dal_irq_service_destroy(&pool->base.irqs);
		}

		if (pool->base.timing_generators[i] != NULL)	{
763
			kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
764 765 766 767
			pool->base.timing_generators[i] = NULL;
		}
	}

768 769
	for (i = 0; i < pool->base.stream_enc_count; i++)
		kfree(pool->base.stream_enc[i]);
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793

	for (i = 0; i < pool->base.audio_count; i++) {
		if (pool->base.audios[i])
			dce_aud_destroy(&pool->base.audios[i]);
	}

	for (i = 0; i < pool->base.clk_src_count; i++) {
		if (pool->base.clock_sources[i] != NULL) {
			dcn10_clock_source_destroy(&pool->base.clock_sources[i]);
			pool->base.clock_sources[i] = NULL;
		}
	}

	if (pool->base.dp_clock_source != NULL) {
		dcn10_clock_source_destroy(&pool->base.dp_clock_source);
		pool->base.dp_clock_source = NULL;
	}

	if (pool->base.abm != NULL)
		dce_abm_destroy(&pool->base.abm);

	if (pool->base.dmcu != NULL)
		dce_dmcu_destroy(&pool->base.dmcu);

794 795
	if (pool->base.dccg != NULL)
		dce_dccg_destroy(&pool->base.dccg);
796

797
	kfree(pool->base.pp_smu);
798 799
}

800
static struct hubp *dcn10_hubp_create(
801 802 803
	struct dc_context *ctx,
	uint32_t inst)
{
804 805
	struct dcn10_hubp *hubp1 =
		kzalloc(sizeof(struct dcn10_hubp), GFP_KERNEL);
806

807
	if (!hubp1)
808 809
		return NULL;

810
	dcn10_hubp_construct(hubp1, ctx, inst,
811
			     &hubp_regs[inst], &hubp_shift, &hubp_mask);
812
	return &hubp1->base;
813 814 815 816 817 818
}

static void get_pixel_clock_parameters(
	const struct pipe_ctx *pipe_ctx,
	struct pixel_clk_params *pixel_clk_params)
{
819
	const struct dc_stream_state *stream = pipe_ctx->stream;
820
	pixel_clk_params->requested_pix_clk = stream->timing.pix_clk_khz;
821 822
	pixel_clk_params->encoder_object_id = stream->sink->link->link_enc->id;
	pixel_clk_params->signal_type = pipe_ctx->stream->signal;
823
	pixel_clk_params->controller_id = pipe_ctx->stream_res.tg->inst + 1;
824 825 826 827 828
	/* TODO: un-hardcode*/
	pixel_clk_params->requested_sym_clk = LINK_RATE_LOW *
		LINK_RATE_REF_FREQ_IN_KHZ;
	pixel_clk_params->flags.ENABLE_SS = 0;
	pixel_clk_params->color_depth =
829
		stream->timing.display_color_depth;
830
	pixel_clk_params->flags.DISPLAY_BLANKED = 1;
831
	pixel_clk_params->pixel_encoding = stream->timing.pixel_encoding;
832

833
	if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
834 835
		pixel_clk_params->color_depth = COLOR_DEPTH_888;

836
	if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420)
837 838 839 840
		pixel_clk_params->requested_pix_clk  /= 2;

}

841
static void build_clamping_params(struct dc_stream_state *stream)
842 843
{
	stream->clamping.clamping_level = CLAMPING_FULL_RANGE;
844 845
	stream->clamping.c_depth = stream->timing.display_color_depth;
	stream->clamping.pixel_encoding = stream->timing.pixel_encoding;
846 847
}

848
static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
849 850
{

851
	get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->stream_res.pix_clk_params);
852 853 854

	pipe_ctx->clock_source->funcs->get_pix_clk_dividers(
		pipe_ctx->clock_source,
855
		&pipe_ctx->stream_res.pix_clk_params,
856 857
		&pipe_ctx->pll_settings);

858
	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
859 860 861 862 863 864

	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
					&pipe_ctx->stream->bit_depth_params);
	build_clamping_params(pipe_ctx->stream);
}

865
static enum dc_status build_mapped_resource(
866
		const struct dc *dc,
867
		struct dc_state *context,
868
		struct dc_stream_state *stream)
869
{
870
	struct pipe_ctx *pipe_ctx = resource_get_head_pipe_for_stream(&context->res_ctx, stream);
871

872 873
	/*TODO Seems unneeded anymore */
	/*	if (old_context && resource_is_stream_unchanged(old_context, stream)) {
874
			if (stream != NULL && old_context->streams[i] != NULL) {
875
				 todo: shouldn't have to copy missing parameter here
876 877 878
				resource_build_bit_depth_reduction_params(stream,
						&stream->bit_depth_params);
				stream->clamping.pixel_encoding =
879
						stream->timing.pixel_encoding;
880 881 882 883 884 885 886 887

				resource_build_bit_depth_reduction_params(stream,
								&stream->bit_depth_params);
				build_clamping_params(stream);

				continue;
			}
		}
888
	*/
889

890 891
	if (!pipe_ctx)
		return DC_ERROR_UNEXPECTED;
892

893
	build_pipe_hw_param(pipe_ctx);
894 895 896
	return DC_OK;
}

897
enum dc_status dcn10_add_stream_to_ctx(
898
		struct dc *dc,
899
		struct dc_state *new_ctx,
900
		struct dc_stream_state *dc_stream)
901
{
902
	enum dc_status result = DC_ERROR_UNEXPECTED;
903

904
	result = resource_map_pool_resources(dc, new_ctx, dc_stream);
905

906 907
	if (result == DC_OK)
		result = resource_map_phy_clock_resources(dc, new_ctx, dc_stream);
908 909


910 911
	if (result == DC_OK)
		result = build_mapped_resource(dc, new_ctx, dc_stream);
912 913 914 915 916

	return result;
}

static struct pipe_ctx *dcn10_acquire_idle_pipe_for_layer(
917
		struct dc_state *context,
918
		const struct resource_pool *pool,
919
		struct dc_stream_state *stream)
920 921 922 923 924
{
	struct resource_context *res_ctx = &context->res_ctx;
	struct pipe_ctx *head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);
	struct pipe_ctx *idle_pipe = find_idle_secondary_pipe(res_ctx, pool);

925
	if (!head_pipe) {
926
		ASSERT(0);
927 928
		return NULL;
	}
929 930

	if (!idle_pipe)
931
		return NULL;
932 933

	idle_pipe->stream = head_pipe->stream;
934
	idle_pipe->stream_res.tg = head_pipe->stream_res.tg;
935
	idle_pipe->stream_res.abm = head_pipe->stream_res.abm;
936
	idle_pipe->stream_res.opp = head_pipe->stream_res.opp;
937

938
	idle_pipe->plane_res.hubp = pool->hubps[idle_pipe->pipe_idx];
939
	idle_pipe->plane_res.ipp = pool->ipps[idle_pipe->pipe_idx];
940
	idle_pipe->plane_res.dpp = pool->dpps[idle_pipe->pipe_idx];
941
	idle_pipe->plane_res.mpcc_inst = pool->dpps[idle_pipe->pipe_idx]->inst;
942 943 944 945

	return idle_pipe;
}

946
static bool dcn10_get_dcc_compression_cap(const struct dc *dc,
947 948 949
		const struct dc_dcc_surface_param *input,
		struct dc_surface_dcc_cap *output)
{
950 951 952 953
	return dc->res_pool->hubbub->funcs->get_dcc_compression_cap(
			dc->res_pool->hubbub,
			input,
			output);
954 955 956 957 958 959 960
}

static void dcn10_destroy_resource_pool(struct resource_pool **pool)
{
	struct dcn10_resource_pool *dcn10_pool = TO_DCN10_RES_POOL(*pool);

	destruct(dcn10_pool);
961
	kfree(dcn10_pool);
962 963 964
	*pool = NULL;
}

965
static enum dc_status dcn10_validate_plane(const struct dc_plane_state *plane_state, struct dc_caps *caps)
966 967
{
	if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN
968 969
			&& caps->max_video_width != 0
			&& plane_state->src_rect.width > caps->max_video_width)
970 971 972 973
		return DC_FAIL_SURFACE_VALIDATE;

	return DC_OK;
}
974 975

static struct dc_cap_funcs cap_funcs = {
976
	.get_dcc_compression_cap = dcn10_get_dcc_compression_cap
977 978 979 980 981 982 983
};

static struct resource_funcs dcn10_res_pool_funcs = {
	.destroy = dcn10_destroy_resource_pool,
	.link_enc_create = dcn10_link_encoder_create,
	.validate_bandwidth = dcn_validate_bandwidth,
	.acquire_idle_pipe_for_layer = dcn10_acquire_idle_pipe_for_layer,
984
	.validate_plane = dcn10_validate_plane,
985
	.add_stream_to_ctx = dcn10_add_stream_to_ctx
986 987
};

988 989 990 991 992 993 994 995
static uint32_t read_pipe_fuses(struct dc_context *ctx)
{
	uint32_t value = dm_read_reg_soc15(ctx, mmCC_DC_PIPE_DIS, 0);
	/* RV1 support max 4 pipes */
	value = value & 0xf;
	return value;
}

996 997
static bool construct(
	uint8_t num_virtual_links,
998
	struct dc *dc,
999 1000 1001
	struct dcn10_resource_pool *pool)
{
	int i;
1002
	int j;
1003
	struct dc_context *ctx = dc->ctx;
1004
	uint32_t pipe_fuses = read_pipe_fuses(ctx);
1005 1006 1007

	ctx->dc_bios->regs = &bios_regs;

1008 1009
		pool->base.res_cap = &res_cap;

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
	pool->base.funcs = &dcn10_res_pool_funcs;

	/*
	 * TODO fill in from actual raven resource when we create
	 * more than virtual encoder
	 */

	/*************************************************
	 *  Resource + asic cap harcoding                *
	 *************************************************/
	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;

1022 1023 1024
	/* max pipe num for ASIC before check pipe fuses */
	pool->base.pipe_count = pool->base.res_cap->num_timing_generator;

1025
	dc->caps.max_video_width = 3840;
1026 1027 1028 1029
	dc->caps.max_downscale_ratio = 200;
	dc->caps.i2c_speed_in_khz = 100;
	dc->caps.max_cursor_size = 256;
	dc->caps.max_slave_planes = 1;
1030
	dc->caps.is_apu = true;
1031
	dc->caps.post_blend_color_processing = false;
1032

1033
	if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
1034
		dc->debug = debug_defaults_drv;
1035
	else
1036
		dc->debug = debug_defaults_diags;
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070

	/*************************************************
	 *  Create resources                             *
	 *************************************************/

	pool->base.clock_sources[DCN10_CLK_SRC_PLL0] =
			dcn10_clock_source_create(ctx, ctx->dc_bios,
				CLOCK_SOURCE_COMBO_PHY_PLL0,
				&clk_src_regs[0], false);
	pool->base.clock_sources[DCN10_CLK_SRC_PLL1] =
			dcn10_clock_source_create(ctx, ctx->dc_bios,
				CLOCK_SOURCE_COMBO_PHY_PLL1,
				&clk_src_regs[1], false);
	pool->base.clock_sources[DCN10_CLK_SRC_PLL2] =
			dcn10_clock_source_create(ctx, ctx->dc_bios,
				CLOCK_SOURCE_COMBO_PHY_PLL2,
				&clk_src_regs[2], false);
	pool->base.clock_sources[DCN10_CLK_SRC_PLL3] =
			dcn10_clock_source_create(ctx, ctx->dc_bios,
				CLOCK_SOURCE_COMBO_PHY_PLL3,
				&clk_src_regs[3], false);

	pool->base.clk_src_count = DCN10_CLK_SRC_TOTAL;

	pool->base.dp_clock_source =
			dcn10_clock_source_create(ctx, ctx->dc_bios,
				CLOCK_SOURCE_ID_DP_DTO,
				/* todo: not reuse phy_pll registers */
				&clk_src_regs[0], true);

	for (i = 0; i < pool->base.clk_src_count; i++) {
		if (pool->base.clock_sources[i] == NULL) {
			dm_error("DC: failed to create clock sources!\n");
			BREAK_TO_DEBUGGER();
1071
			goto fail;
1072 1073 1074
		}
	}

1075
	pool->base.dccg = dcn1_dccg_create(ctx);
1076
	if (pool->base.dccg == NULL) {
1077 1078 1079
		dm_error("DC: failed to create display clock!\n");
		BREAK_TO_DEBUGGER();
		goto fail;
1080 1081 1082 1083 1084 1085 1086 1087 1088
	}

	pool->base.dmcu = dcn10_dmcu_create(ctx,
			&dmcu_regs,
			&dmcu_shift,
			&dmcu_mask);
	if (pool->base.dmcu == NULL) {
		dm_error("DC: failed to create dmcu!\n");
		BREAK_TO_DEBUGGER();
1089
		goto fail;
1090 1091 1092 1093 1094 1095 1096 1097 1098
	}

	pool->base.abm = dce_abm_create(ctx,
			&abm_regs,
			&abm_shift,
			&abm_mask);
	if (pool->base.abm == NULL) {
		dm_error("DC: failed to create abm!\n");
		BREAK_TO_DEBUGGER();
1099
		goto fail;
1100 1101 1102
	}

	dml_init_instance(&dc->dml, DML_PROJECT_RAVEN1);
1103 1104
	memcpy(dc->dcn_ip, &dcn10_ip_defaults, sizeof(dcn10_ip_defaults));
	memcpy(dc->dcn_soc, &dcn10_soc_defaults, sizeof(dcn10_soc_defaults));
1105

1106
	if (ASICREV_IS_RV1_F0(dc->ctx->asic_id.hw_internal_rev)) {
1107
		dc->dcn_soc->urgent_latency = 3;
1108
		dc->debug.disable_dmcu = true;
1109
		dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 41.60f;
1110 1111 1112
	}


1113 1114 1115 1116
	dc->dcn_soc->number_of_channels = dc->ctx->asic_id.vram_width / ddr4_dram_width;
	ASSERT(dc->dcn_soc->number_of_channels < 3);
	if (dc->dcn_soc->number_of_channels == 0)/*old sbios bug*/
		dc->dcn_soc->number_of_channels = 2;
1117

1118 1119 1120 1121 1122
	if (dc->dcn_soc->number_of_channels == 1) {
		dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 19.2f;
		dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 = 17.066f;
		dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 = 14.933f;
		dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = 12.8f;
1123
		if (ASICREV_IS_RV1_F0(dc->ctx->asic_id.hw_internal_rev)) {
1124
			dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 20.80f;
1125
		}
1126 1127
	}

1128 1129
	pool->base.pp_smu = dcn10_pp_smu_create(ctx);

1130
	if (!dc->debug.disable_pplib_clock_request)
1131 1132
		dcn_bw_update_from_pplib(dc);
	dcn_bw_sync_calcs_and_dml(dc);
1133 1134
	if (!dc->debug.disable_pplib_wm_range) {
		dc->res_pool = &pool->base;
1135
		dcn_bw_notify_pplib_of_wm_ranges(dc);
1136
	}
1137 1138 1139 1140 1141 1142

	{
		struct irq_service_init_data init_data;
		init_data.ctx = dc->ctx;
		pool->base.irqs = dal_irq_service_dcn10_create(&init_data);
		if (!pool->base.irqs)
1143
			goto fail;
1144 1145
	}

1146 1147
	/* index to valid pipe resource  */
	j = 0;
1148
	/* mem input -> ipp -> dpp -> opp -> TG */
1149
	for (i = 0; i < pool->base.pipe_count; i++) {
1150 1151 1152 1153 1154 1155
		/* if pipe is disabled, skip instance of HW pipe,
		 * i.e, skip ASIC register instance
		 */
		if ((pipe_fuses & (1 << i)) != 0)
			continue;

1156 1157
		pool->base.hubps[j] = dcn10_hubp_create(ctx, i);
		if (pool->base.hubps[j] == NULL) {
1158 1159 1160
			BREAK_TO_DEBUGGER();
			dm_error(
				"DC: failed to create memory input!\n");
1161
			goto fail;
1162 1163
		}

1164 1165
		pool->base.ipps[j] = dcn10_ipp_create(ctx, i);
		if (pool->base.ipps[j] == NULL) {
1166 1167 1168
			BREAK_TO_DEBUGGER();
			dm_error(
				"DC: failed to create input pixel processor!\n");
1169
			goto fail;
1170 1171
		}

1172 1173
		pool->base.dpps[j] = dcn10_dpp_create(ctx, i);
		if (pool->base.dpps[j] == NULL) {
1174 1175
			BREAK_TO_DEBUGGER();
			dm_error(
1176
				"DC: failed to create dpp!\n");
1177
			goto fail;
1178 1179
		}

1180 1181
		pool->base.opps[j] = dcn10_opp_create(ctx, i);
		if (pool->base.opps[j] == NULL) {
1182 1183 1184
			BREAK_TO_DEBUGGER();
			dm_error(
				"DC: failed to create output pixel processor!\n");
1185
			goto fail;
1186 1187
		}

1188
		pool->base.timing_generators[j] = dcn10_timing_generator_create(
1189
				ctx, i);
1190
		if (pool->base.timing_generators[j] == NULL) {
1191 1192
			BREAK_TO_DEBUGGER();
			dm_error("DC: failed to create tg!\n");
1193
			goto fail;
1194
		}
1195

1196 1197
		/* check next valid pipe */
		j++;
1198
	}
1199 1200 1201

	/* valid pipe num */
	pool->base.pipe_count = j;
1202
	pool->base.timing_generator_count = j;
1203 1204 1205 1206 1207 1208 1209

	/* within dml lib, it is hard code to 4. If ASIC pipe is fused,
	 * the value may be changed
	 */
	dc->dml.ip.max_num_dpp = pool->base.pipe_count;
	dc->dcn_ip->max_num_dpp = pool->base.pipe_count;

1210 1211 1212 1213
	pool->base.mpc = dcn10_mpc_create(ctx);
	if (pool->base.mpc == NULL) {
		BREAK_TO_DEBUGGER();
		dm_error("DC: failed to create mpc!\n");
1214
		goto fail;
1215 1216
	}

1217
	pool->base.hubbub = dcn10_hubbub_create(ctx);
1218
	if (pool->base.hubbub == NULL) {
1219
		BREAK_TO_DEBUGGER();
1220
		dm_error("DC: failed to create hubbub!\n");
1221 1222 1223
		goto fail;
	}

1224 1225 1226
	if (!resource_construct(num_virtual_links, dc, &pool->base,
			(!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
			&res_create_funcs : &res_create_maximus_funcs)))
1227
			goto fail;
1228 1229

	dcn10_hw_sequencer_construct(dc);
1230
	dc->caps.max_planes =  pool->base.pipe_count;
1231

1232
	dc->cap_funcs = cap_funcs;
1233 1234 1235

	return true;

1236
fail:
1237 1238 1239 1240 1241 1242 1243 1244

	destruct(pool);

	return false;
}

struct resource_pool *dcn10_create_resource_pool(
		uint8_t num_virtual_links,
1245
		struct dc *dc)
1246 1247
{
	struct dcn10_resource_pool *pool =
1248
		kzalloc(sizeof(struct dcn10_resource_pool), GFP_KERNEL);
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258

	if (!pool)
		return NULL;

	if (construct(num_virtual_links, dc, pool))
		return &pool->base;

	BREAK_TO_DEBUGGER();
	return NULL;
}