File drivers/gpu/alga/amd/si/dyn_pm/driver.c changed (mode: 100644) (index f9e585d..79b1077) |
... |
... |
long driver_set_performance(struct ctx *ctx) |
572 |
572 |
r = smc_msg(ctx->dev, SMC_MSG_ULV_DIS); |
r = smc_msg(ctx->dev, SMC_MSG_ULV_DIS); |
573 |
573 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
574 |
574 |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the use of the ultra low voltage state\n"); |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the use of the ultra low voltage state\n"); |
575 |
|
goto err; |
|
|
575 |
|
return -SI_ERR; |
576 |
576 |
} |
} |
577 |
577 |
|
|
578 |
|
//TODO: forgot the restrict level smc messages |
|
579 |
|
//TODO: may have to set the best pcie gen here |
|
|
578 |
|
LOG("smc:disable power levels switching"); |
|
579 |
|
r = smc_msg(ctx->dev, SMC_MSG_NO_FORCE_LVL); |
|
580 |
|
if (r == -SI_ERR) { |
|
581 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to disable power level switching\n"); |
|
582 |
|
return -SI_ERR; |
|
583 |
|
} |
|
584 |
|
|
|
585 |
|
LOG("smc:restrict to one powel level"); |
|
586 |
|
r = smc_msg_param(ctx->dev, SMC_MSG_ENA_LVLS_N_SET, 1); |
|
587 |
|
if (r == -SI_ERR) { |
|
588 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to restrict to one power level\n"); |
|
589 |
|
return -SI_ERR; |
|
590 |
|
} |
|
591 |
|
|
|
592 |
|
/* TODO: may have to set the best pcie gen of the power state here */ |
580 |
593 |
|
|
581 |
594 |
LOG("smc:switching off the thermal design power clamping"); |
LOG("smc:switching off the thermal design power clamping"); |
582 |
595 |
r = smc_msg(ctx->dev, SMC_TDP_CLAMPING_OFF); |
r = smc_msg(ctx->dev, SMC_TDP_CLAMPING_OFF); |
583 |
596 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
584 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to the thermal design power clamping\n"); |
|
585 |
|
goto err; |
|
|
597 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the thermal design power clamping\n"); |
|
598 |
|
return -SI_ERR; |
586 |
599 |
} |
} |
587 |
600 |
|
|
588 |
601 |
LOG("smc:switching off the digital temperature estimation"); |
LOG("smc:switching off the digital temperature estimation"); |
589 |
602 |
r = smc_msg(ctx->dev, SMC_MSG_DTE_DIS); |
r = smc_msg(ctx->dev, SMC_MSG_DTE_DIS); |
590 |
603 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
591 |
604 |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the digital temperature estimation\n"); |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the digital temperature estimation\n"); |
592 |
|
goto err; |
|
|
605 |
|
return -SI_ERR; |
593 |
606 |
} |
} |
594 |
607 |
|
|
595 |
608 |
LOG("smc:switching off calculation accumulator"); |
LOG("smc:switching off calculation accumulator"); |
596 |
609 |
r = smc_msg(ctx->dev, SMC_MSG_CAC_DIS); |
r = smc_msg(ctx->dev, SMC_MSG_CAC_DIS); |
597 |
610 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
598 |
611 |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the calculation accumulator\n"); |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the calculation accumulator\n"); |
599 |
|
goto err; |
|
|
612 |
|
return -SI_ERR; |
600 |
613 |
} |
} |
601 |
614 |
|
|
602 |
615 |
LOG("smc:switching off the long term average calculation accumulator"); |
LOG("smc:switching off the long term average calculation accumulator"); |
603 |
616 |
r = smc_msg(ctx->dev, SMC_MSG_CAC_LONG_TERM_AVG_DIS); |
r = smc_msg(ctx->dev, SMC_MSG_CAC_LONG_TERM_AVG_DIS); |
604 |
617 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
605 |
618 |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the long term average calculation accumulator\n"); |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch off the long term average calculation accumulator\n"); |
606 |
|
goto err; |
|
|
619 |
|
return -SI_ERR; |
607 |
620 |
} |
} |
608 |
621 |
|
|
609 |
622 |
LOG("smc:halt"); |
LOG("smc:halt"); |
610 |
623 |
r = smc_msg(ctx->dev, SMC_MSG_HALT); |
r = smc_msg(ctx->dev, SMC_MSG_HALT); |
611 |
624 |
if (r == -SI_ERR) { |
if (r == -SI_ERR) { |
612 |
625 |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:failed to halt\n"); |
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:failed to halt\n"); |
613 |
|
goto err; |
|
|
626 |
|
return -SI_ERR; |
614 |
627 |
} |
} |
615 |
628 |
|
|
616 |
629 |
LOG("smc:waiting to halt"); |
LOG("smc:waiting to halt"); |
617 |
630 |
smc_halt_wait(ctx->dev); |
smc_halt_wait(ctx->dev); |
618 |
631 |
|
|
|
632 |
|
/*--------------------------------------------------------------------*/ |
|
633 |
|
|
619 |
634 |
r = smc_tbls_init(ctx); |
r = smc_tbls_init(ctx); |
620 |
635 |
if (r == -SI_ERR) |
if (r == -SI_ERR) |
621 |
|
goto err; |
|
|
636 |
|
return -SI_ERR; |
622 |
637 |
|
|
623 |
638 |
smc_sw_regs_init(ctx); |
smc_sw_regs_init(ctx); |
624 |
639 |
|
|
625 |
|
//TODO |
|
|
640 |
|
/*--------------------------------------------------------------------*/ |
626 |
641 |
|
|
627 |
|
return 0; |
|
|
642 |
|
LOG("smc:flushing data cache"); |
|
643 |
|
r = smc_msg(ctx->dev, SMC_MSG_DATA_CACHE_FLUSH); |
|
644 |
|
if (r == -SI_ERR) { |
|
645 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to flush the data cache\n"); |
|
646 |
|
return -SI_ERR; |
|
647 |
|
} |
628 |
648 |
|
|
629 |
|
err: |
|
630 |
|
return -SI_ERR; |
|
|
649 |
|
LOG("smc:resume"); |
|
650 |
|
r = smc_msg(ctx->dev, SMC_MSG_RESUME); |
|
651 |
|
if (r == -SI_ERR) { |
|
652 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to resume operations\n"); |
|
653 |
|
return -SI_ERR; |
|
654 |
|
} |
|
655 |
|
|
|
656 |
|
LOG("smc:switch to driver(sw) power state"); |
|
657 |
|
r = smc_msg(ctx->dev, SMC_MSG_SW_STATE_SWITCH); |
|
658 |
|
if (r == -SI_ERR) { |
|
659 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch to driver(sw) power state\n"); |
|
660 |
|
return -SI_ERR; |
|
661 |
|
} |
|
662 |
|
|
|
663 |
|
if (ctx->atb_ulv.lvls_n) { |
|
664 |
|
/* |
|
665 |
|
* the mem clk of the lowest driver state lvl should be the same |
|
666 |
|
* than the ulv one |
|
667 |
|
*/ |
|
668 |
|
LOG("smc:enable ultra low voltage state"); |
|
669 |
|
r = smc_msg(ctx->dev, SMC_MSG_ULV_ENA); |
|
670 |
|
if (r == -SI_ERR) { |
|
671 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:failed to enable the ultra low voltage state\n"); |
|
672 |
|
return -SI_ERR; |
|
673 |
|
} |
|
674 |
|
} |
|
675 |
|
|
|
676 |
|
LOG("smc:switching on the long term average calculation accumulator"); |
|
677 |
|
r = smc_msg(ctx->dev, SMC_MSG_CAC_LONG_TERM_AVG_ENA); |
|
678 |
|
if (r == -SI_ERR) { |
|
679 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch on the long term average calculation accumulator\n"); |
|
680 |
|
return -SI_ERR; |
|
681 |
|
} |
|
682 |
|
|
|
683 |
|
LOG("smc:switching on calculation accumulator"); |
|
684 |
|
r = smc_msg(ctx->dev, SMC_MSG_CAC_ENA); |
|
685 |
|
if (r == -SI_ERR) { |
|
686 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch on the calculation accumulator\n"); |
|
687 |
|
return -SI_ERR; |
|
688 |
|
} |
|
689 |
|
|
|
690 |
|
LOG("smc:switching on the digital temperature estimation"); |
|
691 |
|
r = smc_msg(ctx->dev, SMC_MSG_DTE_ENA); |
|
692 |
|
if (r == -SI_ERR) { |
|
693 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch on the digital temperature estimation\n"); |
|
694 |
|
return -SI_ERR; |
|
695 |
|
} |
|
696 |
|
|
|
697 |
|
LOG("smc:switching on the thermal design power clamping"); |
|
698 |
|
r = smc_msg(ctx->dev, SMC_TDP_CLAMPING_ON); |
|
699 |
|
if (r == -SI_ERR) { |
|
700 |
|
dev_err(&ctx->dev->dev, "dyn_pm:init:smc:unable to switch on the thermal design power clamping\n"); |
|
701 |
|
return -SI_ERR; |
|
702 |
|
} |
|
703 |
|
return 0; |
631 |
704 |
} |
} |
File drivers/gpu/alga/amd/si/smc.h changed (mode: 100644) (index e1022bb..3289752) |
... |
... |
void smc_halt_wait(struct pci_dev *dev); |
26 |
26 |
|
|
27 |
27 |
#define SMC_MSG_HALT 0x0010 |
#define SMC_MSG_HALT 0x0010 |
28 |
28 |
#define SMC_MSG_RESUME 0x0011 |
#define SMC_MSG_RESUME 0x0011 |
|
29 |
|
#define SMC_MSG_SW_STATE_SWITCH 0x0020 |
|
30 |
|
#define SMC_MSG_NO_FORCE_LVL 0x0041 |
29 |
31 |
#define SMC_MSG_CAC_ENA 0x0053 |
#define SMC_MSG_CAC_ENA 0x0053 |
30 |
32 |
#define SMC_MSG_CAC_DIS 0x0054 |
#define SMC_MSG_CAC_DIS 0x0054 |
31 |
33 |
#define SMC_TDP_CLAMPING_ON 0x0059 |
#define SMC_TDP_CLAMPING_ON 0x0059 |
|
... |
... |
void smc_halt_wait(struct pci_dev *dev); |
39 |
41 |
#define SMC_MSG_ULV_EXIT 0x0065 |
#define SMC_MSG_ULV_EXIT 0x0065 |
40 |
42 |
#define SMC_MSG_CAC_LONG_TERM_AVG_ENA 0x006e |
#define SMC_MSG_CAC_LONG_TERM_AVG_ENA 0x006e |
41 |
43 |
#define SMC_MSG_CAC_LONG_TERM_AVG_DIS 0x006f |
#define SMC_MSG_CAC_LONG_TERM_AVG_DIS 0x006f |
|
44 |
|
#define SMC_MSG_DATA_CACHE_FLUSH 0x0080 |
|
45 |
|
#define SMC_MSG_ENA_LVLS_N_SET 0x0082 |
42 |
46 |
#define SMC_MSG_DTE_ENA 0x0087 |
#define SMC_MSG_DTE_ENA 0x0087 |
43 |
47 |
#define SMC_MSG_DTE_DIS 0x0088 |
#define SMC_MSG_DTE_DIS 0x0088 |
44 |
48 |
long smc_msg(struct pci_dev *dev, u16 msg); |
long smc_msg(struct pci_dev *dev, u16 msg); |
|
49 |
|
long smc_msg_param(struct pci_dev *dev, u16 msg, u32 param); |
45 |
50 |
#endif |
#endif |