Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86/intel/pmc: Display LPM requirements for multiple PMCs

Update the substate_requirements attribute to display the requirements for
all the PMCs on a package.

Signed-off-by: Rajvi Jingar <rajvi.jingar@linux.intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20231129222132.2331261-17-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Rajvi Jingar and committed by
Hans de Goede
0f601dec 104f7494

+63 -50
+63 -50
drivers/platform/x86/intel/pmc/core.c
··· 728 728 } 729 729 DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_l_sts_regs); 730 730 731 - static void pmc_core_substate_req_header_show(struct seq_file *s) 731 + static void pmc_core_substate_req_header_show(struct seq_file *s, int pmc_index) 732 732 { 733 733 struct pmc_dev *pmcdev = s->private; 734 734 int i, mode; ··· 743 743 static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused) 744 744 { 745 745 struct pmc_dev *pmcdev = s->private; 746 - struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; 747 - const struct pmc_bit_map **maps = pmc->map->lpm_sts; 748 - const struct pmc_bit_map *map; 749 - const int num_maps = pmc->map->lpm_num_maps; 750 - u32 sts_offset = pmc->map->lpm_status_offset; 751 - u32 *lpm_req_regs = pmc->lpm_req_regs; 752 - int mp; 746 + u32 sts_offset; 747 + u32 *lpm_req_regs; 748 + int num_maps, mp, pmc_index; 753 749 754 - /* Display the header */ 755 - pmc_core_substate_req_header_show(s); 750 + for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs); ++pmc_index) { 751 + struct pmc *pmc = pmcdev->pmcs[pmc_index]; 752 + const struct pmc_bit_map **maps; 756 753 757 - /* Loop over maps */ 758 - for (mp = 0; mp < num_maps; mp++) { 759 - u32 req_mask = 0; 760 - u32 lpm_status; 761 - int mode, idx, i, len = 32; 754 + if (!pmc) 755 + continue; 756 + 757 + maps = pmc->map->lpm_sts; 758 + num_maps = pmc->map->lpm_num_maps; 759 + sts_offset = pmc->map->lpm_status_offset; 760 + lpm_req_regs = pmc->lpm_req_regs; 762 761 763 762 /* 764 - * Capture the requirements and create a mask so that we only 765 - * show an element if it's required for at least one of the 766 - * enabled low power modes 763 + * When there are multiple PMCs, though the PMC may exist, the 764 + * requirement register discovery could have failed so check 765 + * before accessing. 767 766 */ 768 - pmc_for_each_mode(idx, mode, pmcdev) 769 - req_mask |= lpm_req_regs[mp + (mode * num_maps)]; 767 + if (!lpm_req_regs) 768 + continue; 770 769 771 - /* Get the last latched status for this map */ 772 - lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4)); 770 + /* Display the header */ 771 + pmc_core_substate_req_header_show(s, pmc_index); 773 772 774 - /* Loop over elements in this map */ 775 - map = maps[mp]; 776 - for (i = 0; map[i].name && i < len; i++) { 777 - u32 bit_mask = map[i].bit_mask; 773 + /* Loop over maps */ 774 + for (mp = 0; mp < num_maps; mp++) { 775 + u32 req_mask = 0; 776 + u32 lpm_status; 777 + const struct pmc_bit_map *map; 778 + int mode, idx, i, len = 32; 778 779 779 - if (!(bit_mask & req_mask)) 780 - /* 781 - * Not required for any enabled states 782 - * so don't display 783 - */ 784 - continue; 780 + /* 781 + * Capture the requirements and create a mask so that we only 782 + * show an element if it's required for at least one of the 783 + * enabled low power modes 784 + */ 785 + pmc_for_each_mode(idx, mode, pmcdev) 786 + req_mask |= lpm_req_regs[mp + (mode * num_maps)]; 785 787 786 - /* Display the element name in the first column */ 787 - seq_printf(s, "%30s |", map[i].name); 788 + /* Get the last latched status for this map */ 789 + lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4)); 788 790 789 - /* Loop over the enabled states and display if required */ 790 - pmc_for_each_mode(idx, mode, pmcdev) { 791 - if (lpm_req_regs[mp + (mode * num_maps)] & bit_mask) 792 - seq_printf(s, " %9s |", 793 - "Required"); 794 - else 795 - seq_printf(s, " %9s |", " "); 791 + /* Loop over elements in this map */ 792 + map = maps[mp]; 793 + for (i = 0; map[i].name && i < len; i++) { 794 + u32 bit_mask = map[i].bit_mask; 795 + 796 + if (!(bit_mask & req_mask)) { 797 + /* 798 + * Not required for any enabled states 799 + * so don't display 800 + */ 801 + continue; 802 + } 803 + 804 + /* Display the element name in the first column */ 805 + seq_printf(s, "pmc%d: %26s |", pmc_index, map[i].name); 806 + 807 + /* Loop over the enabled states and display if required */ 808 + pmc_for_each_mode(idx, mode, pmcdev) { 809 + bool required = lpm_req_regs[mp + (mode * num_maps)] & 810 + bit_mask; 811 + seq_printf(s, " %9s |", required ? "Required" : " "); 812 + } 813 + 814 + /* In Status column, show the last captured state of this agent */ 815 + seq_printf(s, " %9s |", lpm_status & bit_mask ? "Yes" : " "); 816 + 817 + seq_puts(s, "\n"); 796 818 } 797 - 798 - /* In Status column, show the last captured state of this agent */ 799 - if (lpm_status & bit_mask) 800 - seq_printf(s, " %9s |", "Yes"); 801 - else 802 - seq_printf(s, " %9s |", " "); 803 - 804 - seq_puts(s, "\n"); 805 819 } 806 820 } 807 - 808 821 return 0; 809 822 } 810 823 DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_req_regs);