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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 128 129 130 131 132 133 134 135 136 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 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 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
|
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <linux/bitops.h>
#include <drm/drm_print.h>
#include "i915_reg.h"
#include "i915_utils.h"
#include "intel_atomic.h"
#include "intel_bw.h"
#include "intel_cdclk.h"
#include "intel_de.h"
#include "intel_display_trace.h"
#include "intel_pmdemand.h"
#include "intel_step.h"
#include "skl_watermark.h"
struct pmdemand_params {
u16 qclk_gv_bw;
u8 voltage_index;
u8 qclk_gv_index;
u8 active_pipes;
u8 active_dbufs; /* pre-Xe3 only */
/* Total number of non type C active phys from active_phys_mask */
u8 active_phys;
u8 plls;
u16 cdclk_freq_mhz;
/* max from ddi_clocks[] */
u16 ddiclk_max;
u8 scalers; /* pre-Xe3 only */
};
struct intel_pmdemand_state {
struct intel_global_state base;
/* Maintain a persistent list of port clocks across all crtcs */
int ddi_clocks[I915_MAX_PIPES];
/* Maintain a persistent list of non type C phys mask */
u16 active_combo_phys_mask;
/* Parameters to be configured in the pmdemand registers */
struct pmdemand_params params;
};
struct intel_pmdemand_state *to_intel_pmdemand_state(struct intel_global_state *obj_state)
{
return container_of(obj_state, struct intel_pmdemand_state, base);
}
static struct intel_global_state *
intel_pmdemand_duplicate_state(struct intel_global_obj *obj)
{
struct intel_pmdemand_state *pmdemand_state;
pmdemand_state = kmemdup(obj->state, sizeof(*pmdemand_state), GFP_KERNEL);
if (!pmdemand_state)
return NULL;
return &pmdemand_state->base;
}
static void intel_pmdemand_destroy_state(struct intel_global_obj *obj,
struct intel_global_state *state)
{
kfree(state);
}
static const struct intel_global_state_funcs intel_pmdemand_funcs = {
.atomic_duplicate_state = intel_pmdemand_duplicate_state,
.atomic_destroy_state = intel_pmdemand_destroy_state,
};
static struct intel_pmdemand_state *
intel_atomic_get_pmdemand_state(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
struct intel_global_state *pmdemand_state =
intel_atomic_get_global_obj_state(state,
&display->pmdemand.obj);
if (IS_ERR(pmdemand_state))
return ERR_CAST(pmdemand_state);
return to_intel_pmdemand_state(pmdemand_state);
}
static struct intel_pmdemand_state *
intel_atomic_get_old_pmdemand_state(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
struct intel_global_state *pmdemand_state =
intel_atomic_get_old_global_obj_state(state,
&display->pmdemand.obj);
if (!pmdemand_state)
return NULL;
return to_intel_pmdemand_state(pmdemand_state);
}
static struct intel_pmdemand_state *
intel_atomic_get_new_pmdemand_state(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
struct intel_global_state *pmdemand_state =
intel_atomic_get_new_global_obj_state(state,
&display->pmdemand.obj);
if (!pmdemand_state)
return NULL;
return to_intel_pmdemand_state(pmdemand_state);
}
int intel_pmdemand_init(struct intel_display *display)
{
struct intel_pmdemand_state *pmdemand_state;
pmdemand_state = kzalloc(sizeof(*pmdemand_state), GFP_KERNEL);
if (!pmdemand_state)
return -ENOMEM;
intel_atomic_global_obj_init(display, &display->pmdemand.obj,
&pmdemand_state->base,
&intel_pmdemand_funcs);
if (IS_DISPLAY_VERx100_STEP(display, 1400, STEP_A0, STEP_C0))
/* Wa_14016740474 */
intel_de_rmw(display, XELPD_CHICKEN_DCPR_3, 0, DMD_RSP_TIMEOUT_DISABLE);
return 0;
}
void intel_pmdemand_init_early(struct intel_display *display)
{
mutex_init(&display->pmdemand.lock);
init_waitqueue_head(&display->pmdemand.waitqueue);
}
void
intel_pmdemand_update_phys_mask(struct intel_display *display,
struct intel_encoder *encoder,
struct intel_pmdemand_state *pmdemand_state,
bool set_bit)
{
enum phy phy;
if (DISPLAY_VER(display) < 14)
return;
if (!encoder)
return;
if (intel_encoder_is_tc(encoder))
return;
phy = intel_encoder_to_phy(encoder);
if (set_bit)
pmdemand_state->active_combo_phys_mask |= BIT(phy);
else
pmdemand_state->active_combo_phys_mask &= ~BIT(phy);
}
void
intel_pmdemand_update_port_clock(struct intel_display *display,
struct intel_pmdemand_state *pmdemand_state,
enum pipe pipe, int port_clock)
{
if (DISPLAY_VER(display) < 14)
return;
pmdemand_state->ddi_clocks[pipe] = port_clock;
}
static void
intel_pmdemand_update_max_ddiclk(struct intel_display *display,
struct intel_atomic_state *state,
struct intel_pmdemand_state *pmdemand_state)
{
int max_ddiclk = 0;
const struct intel_crtc_state *new_crtc_state;
struct intel_crtc *crtc;
int i;
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i)
intel_pmdemand_update_port_clock(display, pmdemand_state,
crtc->pipe,
new_crtc_state->port_clock);
for (i = 0; i < ARRAY_SIZE(pmdemand_state->ddi_clocks); i++)
max_ddiclk = max(pmdemand_state->ddi_clocks[i], max_ddiclk);
pmdemand_state->params.ddiclk_max = DIV_ROUND_UP(max_ddiclk, 1000);
}
static void
intel_pmdemand_update_connector_phys(struct intel_display *display,
struct intel_atomic_state *state,
struct drm_connector_state *conn_state,
bool set_bit,
struct intel_pmdemand_state *pmdemand_state)
{
struct intel_encoder *encoder = to_intel_encoder(conn_state->best_encoder);
struct intel_crtc *crtc = to_intel_crtc(conn_state->crtc);
struct intel_crtc_state *crtc_state;
if (!crtc)
return;
if (set_bit)
crtc_state = intel_atomic_get_new_crtc_state(state, crtc);
else
crtc_state = intel_atomic_get_old_crtc_state(state, crtc);
if (!crtc_state->hw.active)
return;
intel_pmdemand_update_phys_mask(display, encoder, pmdemand_state,
set_bit);
}
static void
intel_pmdemand_update_active_non_tc_phys(struct intel_display *display,
struct intel_atomic_state *state,
struct intel_pmdemand_state *pmdemand_state)
{
struct drm_connector_state *old_conn_state;
struct drm_connector_state *new_conn_state;
struct drm_connector *connector;
int i;
for_each_oldnew_connector_in_state(&state->base, connector,
old_conn_state, new_conn_state, i) {
if (!intel_connector_needs_modeset(state, connector))
continue;
/* First clear the active phys in the old connector state */
intel_pmdemand_update_connector_phys(display, state,
old_conn_state, false,
pmdemand_state);
/* Then set the active phys in new connector state */
intel_pmdemand_update_connector_phys(display, state,
new_conn_state, true,
pmdemand_state);
}
pmdemand_state->params.active_phys =
min_t(u16, hweight16(pmdemand_state->active_combo_phys_mask),
7);
}
static bool
intel_pmdemand_encoder_has_tc_phy(struct intel_display *display,
struct intel_encoder *encoder)
{
return encoder && intel_encoder_is_tc(encoder);
}
static bool
intel_pmdemand_connector_needs_update(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
struct drm_connector_state *old_conn_state;
struct drm_connector_state *new_conn_state;
struct drm_connector *connector;
int i;
for_each_oldnew_connector_in_state(&state->base, connector,
old_conn_state, new_conn_state, i) {
struct intel_encoder *old_encoder =
to_intel_encoder(old_conn_state->best_encoder);
struct intel_encoder *new_encoder =
to_intel_encoder(new_conn_state->best_encoder);
if (!intel_connector_needs_modeset(state, connector))
continue;
if (old_encoder == new_encoder ||
(intel_pmdemand_encoder_has_tc_phy(display, old_encoder) &&
intel_pmdemand_encoder_has_tc_phy(display, new_encoder)))
continue;
return true;
}
return false;
}
static bool intel_pmdemand_needs_update(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
const struct intel_bw_state *new_bw_state, *old_bw_state;
const struct intel_cdclk_state *new_cdclk_state, *old_cdclk_state;
const struct intel_crtc_state *new_crtc_state, *old_crtc_state;
const struct intel_dbuf_state *new_dbuf_state, *old_dbuf_state;
struct intel_crtc *crtc;
int i;
new_bw_state = intel_atomic_get_new_bw_state(state);
old_bw_state = intel_atomic_get_old_bw_state(state);
if (new_bw_state && new_bw_state->qgv_point_peakbw !=
old_bw_state->qgv_point_peakbw)
return true;
new_dbuf_state = intel_atomic_get_new_dbuf_state(state);
old_dbuf_state = intel_atomic_get_old_dbuf_state(state);
if (new_dbuf_state &&
new_dbuf_state->active_pipes != old_dbuf_state->active_pipes)
return true;
if (DISPLAY_VER(display) < 30) {
if (new_dbuf_state &&
new_dbuf_state->enabled_slices !=
old_dbuf_state->enabled_slices)
return true;
}
new_cdclk_state = intel_atomic_get_new_cdclk_state(state);
old_cdclk_state = intel_atomic_get_old_cdclk_state(state);
if (new_cdclk_state &&
(new_cdclk_state->actual.cdclk !=
old_cdclk_state->actual.cdclk ||
new_cdclk_state->actual.voltage_level !=
old_cdclk_state->actual.voltage_level))
return true;
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i)
if (new_crtc_state->port_clock != old_crtc_state->port_clock)
return true;
return intel_pmdemand_connector_needs_update(state);
}
int intel_pmdemand_atomic_check(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
const struct intel_bw_state *new_bw_state;
const struct intel_cdclk_state *new_cdclk_state;
const struct intel_dbuf_state *new_dbuf_state;
struct intel_pmdemand_state *new_pmdemand_state;
if (DISPLAY_VER(display) < 14)
return 0;
if (!intel_pmdemand_needs_update(state))
return 0;
new_pmdemand_state = intel_atomic_get_pmdemand_state(state);
if (IS_ERR(new_pmdemand_state))
return PTR_ERR(new_pmdemand_state);
new_bw_state = intel_atomic_get_bw_state(state);
if (IS_ERR(new_bw_state))
return PTR_ERR(new_bw_state);
/* firmware will calculate the qclk_gv_index, requirement is set to 0 */
new_pmdemand_state->params.qclk_gv_index = 0;
new_pmdemand_state->params.qclk_gv_bw = new_bw_state->qgv_point_peakbw;
new_dbuf_state = intel_atomic_get_dbuf_state(state);
if (IS_ERR(new_dbuf_state))
return PTR_ERR(new_dbuf_state);
if (DISPLAY_VER(display) < 30) {
new_pmdemand_state->params.active_dbufs =
min_t(u8, hweight8(new_dbuf_state->enabled_slices), 3);
new_pmdemand_state->params.active_pipes =
min_t(u8, hweight8(new_dbuf_state->active_pipes), 3);
} else {
new_pmdemand_state->params.active_pipes =
min_t(u8, hweight8(new_dbuf_state->active_pipes), INTEL_NUM_PIPES(display));
}
new_cdclk_state = intel_atomic_get_cdclk_state(state);
if (IS_ERR(new_cdclk_state))
return PTR_ERR(new_cdclk_state);
new_pmdemand_state->params.voltage_index =
new_cdclk_state->actual.voltage_level;
new_pmdemand_state->params.cdclk_freq_mhz =
DIV_ROUND_UP(new_cdclk_state->actual.cdclk, 1000);
intel_pmdemand_update_max_ddiclk(display, state, new_pmdemand_state);
intel_pmdemand_update_active_non_tc_phys(display, state, new_pmdemand_state);
/*
* Active_PLLs starts with 1 because of CDCLK PLL.
* TODO: Missing to account genlock filter when it gets used.
*/
new_pmdemand_state->params.plls =
min_t(u16, new_pmdemand_state->params.active_phys + 1, 7);
/*
* Setting scalers to max as it can not be calculated during flips and
* fastsets without taking global states locks.
*/
new_pmdemand_state->params.scalers = 7;
if (state->base.allow_modeset)
return intel_atomic_serialize_global_state(&new_pmdemand_state->base);
else
return intel_atomic_lock_global_state(&new_pmdemand_state->base);
}
static bool intel_pmdemand_check_prev_transaction(struct intel_display *display)
{
return !(intel_de_wait_for_clear(display,
XELPDP_INITIATE_PMDEMAND_REQUEST(1),
XELPDP_PMDEMAND_REQ_ENABLE, 10) ||
intel_de_wait_for_clear(display,
GEN12_DCPR_STATUS_1,
XELPDP_PMDEMAND_INFLIGHT_STATUS, 10));
}
void
intel_pmdemand_init_pmdemand_params(struct intel_display *display,
struct intel_pmdemand_state *pmdemand_state)
{
u32 reg1, reg2;
if (DISPLAY_VER(display) < 14)
return;
mutex_lock(&display->pmdemand.lock);
if (drm_WARN_ON(display->drm,
!intel_pmdemand_check_prev_transaction(display))) {
memset(&pmdemand_state->params, 0,
sizeof(pmdemand_state->params));
goto unlock;
}
reg1 = intel_de_read(display, XELPDP_INITIATE_PMDEMAND_REQUEST(0));
reg2 = intel_de_read(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1));
pmdemand_state->params.qclk_gv_bw =
REG_FIELD_GET(XELPDP_PMDEMAND_QCLK_GV_BW_MASK, reg1);
pmdemand_state->params.voltage_index =
REG_FIELD_GET(XELPDP_PMDEMAND_VOLTAGE_INDEX_MASK, reg1);
pmdemand_state->params.qclk_gv_index =
REG_FIELD_GET(XELPDP_PMDEMAND_QCLK_GV_INDEX_MASK, reg1);
pmdemand_state->params.active_phys =
REG_FIELD_GET(XELPDP_PMDEMAND_PHYS_MASK, reg1);
pmdemand_state->params.cdclk_freq_mhz =
REG_FIELD_GET(XELPDP_PMDEMAND_CDCLK_FREQ_MASK, reg2);
pmdemand_state->params.ddiclk_max =
REG_FIELD_GET(XELPDP_PMDEMAND_DDICLK_FREQ_MASK, reg2);
if (DISPLAY_VER(display) >= 30) {
pmdemand_state->params.active_pipes =
REG_FIELD_GET(XE3_PMDEMAND_PIPES_MASK, reg1);
} else {
pmdemand_state->params.active_pipes =
REG_FIELD_GET(XELPDP_PMDEMAND_PIPES_MASK, reg1);
pmdemand_state->params.active_dbufs =
REG_FIELD_GET(XELPDP_PMDEMAND_DBUFS_MASK, reg1);
pmdemand_state->params.scalers =
REG_FIELD_GET(XELPDP_PMDEMAND_SCALERS_MASK, reg2);
}
unlock:
mutex_unlock(&display->pmdemand.lock);
}
static bool intel_pmdemand_req_complete(struct intel_display *display)
{
return !(intel_de_read(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1)) &
XELPDP_PMDEMAND_REQ_ENABLE);
}
static void intel_pmdemand_poll(struct intel_display *display)
{
const unsigned int timeout_ms = 10;
u32 status;
int ret;
ret = intel_de_wait_custom(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1),
XELPDP_PMDEMAND_REQ_ENABLE, 0,
50, timeout_ms, &status);
if (ret == -ETIMEDOUT)
drm_err(display->drm,
"timed out waiting for Punit PM Demand Response within %ums (status 0x%08x)\n",
timeout_ms, status);
}
static void intel_pmdemand_wait(struct intel_display *display)
{
/* Wa_14024400148 For lnl use polling method */
if (DISPLAY_VER(display) == 20) {
intel_pmdemand_poll(display);
} else {
if (!wait_event_timeout(display->pmdemand.waitqueue,
intel_pmdemand_req_complete(display),
msecs_to_jiffies_timeout(10)))
drm_err(display->drm,
"timed out waiting for Punit PM Demand Response\n");
}
}
/* Required to be programmed during Display Init Sequences. */
void intel_pmdemand_program_dbuf(struct intel_display *display,
u8 dbuf_slices)
{
u32 dbufs = min_t(u32, hweight8(dbuf_slices), 3);
/* PM Demand only tracks active dbufs on pre-Xe3 platforms */
if (DISPLAY_VER(display) >= 30)
return;
mutex_lock(&display->pmdemand.lock);
if (drm_WARN_ON(display->drm,
!intel_pmdemand_check_prev_transaction(display)))
goto unlock;
intel_de_rmw(display, XELPDP_INITIATE_PMDEMAND_REQUEST(0),
XELPDP_PMDEMAND_DBUFS_MASK,
REG_FIELD_PREP(XELPDP_PMDEMAND_DBUFS_MASK, dbufs));
intel_de_rmw(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1), 0,
XELPDP_PMDEMAND_REQ_ENABLE);
intel_pmdemand_wait(display);
unlock:
mutex_unlock(&display->pmdemand.lock);
}
static void
intel_pmdemand_update_params(struct intel_display *display,
const struct intel_pmdemand_state *new,
const struct intel_pmdemand_state *old,
u32 *reg1, u32 *reg2, bool serialized)
{
/*
* The pmdemand parameter updates happens in two steps. Pre plane and
* post plane updates. During the pre plane, as DE might still be
* handling with some old operations, to avoid unexpected performance
* issues, program the pmdemand parameters with higher of old and new
* values. And then after once settled, use the new parameter values
* as part of the post plane update.
*
* If the pmdemand params update happens without modeset allowed, this
* means we can't serialize the updates. So that implies possibility of
* some parallel atomic commits affecting the pmdemand parameters. In
* that case, we need to consider the current values from the register
* as well. So in pre-plane case, we need to check the max of old, new
* and current register value if not serialized. In post plane update
* we need to consider max of new and current register value if not
* serialized
*/
#define update_reg(reg, field, mask) do { \
u32 current_val = serialized ? 0 : REG_FIELD_GET((mask), *(reg)); \
u32 old_val = old ? old->params.field : 0; \
u32 new_val = new->params.field; \
\
*(reg) &= ~(mask); \
*(reg) |= REG_FIELD_PREP((mask), max3(old_val, new_val, current_val)); \
} while (0)
/* Set 1*/
update_reg(reg1, qclk_gv_bw, XELPDP_PMDEMAND_QCLK_GV_BW_MASK);
update_reg(reg1, voltage_index, XELPDP_PMDEMAND_VOLTAGE_INDEX_MASK);
update_reg(reg1, qclk_gv_index, XELPDP_PMDEMAND_QCLK_GV_INDEX_MASK);
update_reg(reg1, active_phys, XELPDP_PMDEMAND_PHYS_MASK);
/* Set 2*/
update_reg(reg2, cdclk_freq_mhz, XELPDP_PMDEMAND_CDCLK_FREQ_MASK);
update_reg(reg2, ddiclk_max, XELPDP_PMDEMAND_DDICLK_FREQ_MASK);
update_reg(reg2, plls, XELPDP_PMDEMAND_PLLS_MASK);
if (DISPLAY_VER(display) >= 30) {
update_reg(reg1, active_pipes, XE3_PMDEMAND_PIPES_MASK);
} else {
update_reg(reg1, active_pipes, XELPDP_PMDEMAND_PIPES_MASK);
update_reg(reg1, active_dbufs, XELPDP_PMDEMAND_DBUFS_MASK);
update_reg(reg2, scalers, XELPDP_PMDEMAND_SCALERS_MASK);
}
#undef update_reg
}
static void
intel_pmdemand_program_params(struct intel_display *display,
const struct intel_pmdemand_state *new,
const struct intel_pmdemand_state *old,
bool serialized)
{
bool changed = false;
u32 reg1, mod_reg1;
u32 reg2, mod_reg2;
mutex_lock(&display->pmdemand.lock);
if (drm_WARN_ON(display->drm,
!intel_pmdemand_check_prev_transaction(display)))
goto unlock;
reg1 = intel_de_read(display, XELPDP_INITIATE_PMDEMAND_REQUEST(0));
mod_reg1 = reg1;
reg2 = intel_de_read(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1));
mod_reg2 = reg2;
intel_pmdemand_update_params(display, new, old, &mod_reg1, &mod_reg2,
serialized);
if (reg1 != mod_reg1) {
intel_de_write(display, XELPDP_INITIATE_PMDEMAND_REQUEST(0),
mod_reg1);
changed = true;
}
if (reg2 != mod_reg2) {
intel_de_write(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1),
mod_reg2);
changed = true;
}
/* Initiate pm demand request only if register values are changed */
if (!changed)
goto unlock;
drm_dbg_kms(display->drm,
"initiate pmdemand request values: (0x%x 0x%x)\n",
mod_reg1, mod_reg2);
intel_de_rmw(display, XELPDP_INITIATE_PMDEMAND_REQUEST(1), 0,
XELPDP_PMDEMAND_REQ_ENABLE);
intel_pmdemand_wait(display);
unlock:
mutex_unlock(&display->pmdemand.lock);
}
static bool
intel_pmdemand_state_changed(const struct intel_pmdemand_state *new,
const struct intel_pmdemand_state *old)
{
return memcmp(&new->params, &old->params, sizeof(new->params)) != 0;
}
void intel_pmdemand_pre_plane_update(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
const struct intel_pmdemand_state *new_pmdemand_state =
intel_atomic_get_new_pmdemand_state(state);
const struct intel_pmdemand_state *old_pmdemand_state =
intel_atomic_get_old_pmdemand_state(state);
if (DISPLAY_VER(display) < 14)
return;
if (!new_pmdemand_state ||
!intel_pmdemand_state_changed(new_pmdemand_state,
old_pmdemand_state))
return;
WARN_ON(!new_pmdemand_state->base.changed);
intel_pmdemand_program_params(display, new_pmdemand_state,
old_pmdemand_state,
intel_atomic_global_state_is_serialized(state));
}
void intel_pmdemand_post_plane_update(struct intel_atomic_state *state)
{
struct intel_display *display = to_intel_display(state);
const struct intel_pmdemand_state *new_pmdemand_state =
intel_atomic_get_new_pmdemand_state(state);
const struct intel_pmdemand_state *old_pmdemand_state =
intel_atomic_get_old_pmdemand_state(state);
if (DISPLAY_VER(display) < 14)
return;
if (!new_pmdemand_state ||
!intel_pmdemand_state_changed(new_pmdemand_state,
old_pmdemand_state))
return;
WARN_ON(!new_pmdemand_state->base.changed);
intel_pmdemand_program_params(display, new_pmdemand_state, NULL,
intel_atomic_global_state_is_serialized(state));
}
|