Skip to content

Commit

Permalink
soc/power9/chip.c: allocate only necessary amount of HOMERs
Browse files Browse the repository at this point in the history
Rather than copying what HOMER does.

Change-Id: I60168789fd2e1664aa746d4cf849338a37d2e036
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
  • Loading branch information
SergiiDmytruk committed Mar 8, 2022
1 parent 8e0653e commit ea16333
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/soc/ibm/power9/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static inline unsigned long size_k(uint64_t reg)
static void enable_soc_dev(struct device *dev)
{
int chip, idx = 0;
unsigned long reserved_size, top = 0;
unsigned long reserved_size, homers_size, occ_area, top = 0;
uint8_t chips = fsi_get_present_chips();

for (chip = 0; chip < MAX_CHIPS; chip++) {
Expand Down Expand Up @@ -527,17 +527,19 @@ static void enable_soc_dev(struct device *dev)
/*
* Reserve top 8M (OCC common area) + 4M (HOMER).
*
* TODO: 8M + (4M per CPU), hostboot reserves always 8M + 8 * 4M.
* 8M + (4M per CPU), hostboot always reserves 8M + 8 * 4M.
*/
reserved_size = 8*1024 + 4*1024 *8 /* * num_of_cpus */;
homers_size = 4*1024 * __builtin_popcount(chips);
reserved_size = 8*1024 + homers_size;
top -= reserved_size;
reserved_ram_resource(dev, idx++, top, reserved_size);

/*
* Assumption: OCC boots successfully or coreboot die()s, booting in safe
* mode without runtime power management is not supported.
*/
build_homer_image((void *)(top * 1024), nominal_freq);
occ_area = top + homers_size;
build_homer_image((void *)(top * 1024), (void *)(occ_area * 1024), nominal_freq);

if (CONFIG(PAYLOAD_FIT_SUPPORT)) {
struct device_tree_fixup *dt_fixup;
Expand Down
2 changes: 1 addition & 1 deletion src/soc/ibm/power9/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
struct soc_ibm_power9_config {
};

void build_homer_image(void *homer_bar, uint64_t nominal_freq[]);
void build_homer_image(void *homer_bar, void *common_occ_area, uint64_t nominal_freq[]);

#endif /* __SOC_CAVIUM_CN81XX_CHIP_H */
8 changes: 4 additions & 4 deletions src/soc/ibm/power9/homer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,12 +3269,12 @@ static void setup_wakeup_mode(uint8_t chip, uint64_t cores)
}

/* 15.2 set HOMER BAR */
static void istep_15_2(uint8_t chip, struct homer_st *homer)
static void istep_15_2(uint8_t chip, struct homer_st *homer, void *common_occ_area)
{
write_rscom(chip, 0x05012B00, (uint64_t)homer);
write_rscom(chip, 0x05012B04, (4 * MiB - 1) & ~((uint64_t)MiB - 1));

write_rscom(chip, 0x05012B02, (uint64_t)homer + (8 - chip) * 4 * MiB); // FIXME
write_rscom(chip, 0x05012B02, (uint64_t)common_occ_area);
write_rscom(chip, 0x05012B06, (8 * MiB - 1) & ~((uint64_t)MiB - 1));
}

Expand Down Expand Up @@ -3430,7 +3430,7 @@ static void istep_15_4(uint8_t chip, uint64_t cores)
/*
* This logic is for SMF disabled only!
*/
void build_homer_image(void *homer_bar, uint64_t nominal_freq[])
void build_homer_image(void *homer_bar, void *common_occ_area, uint64_t nominal_freq[])
{
const uint8_t chips = fsi_get_present_chips();

Expand Down Expand Up @@ -3514,7 +3514,7 @@ void build_homer_image(void *homer_bar, uint64_t nominal_freq[])
setup_wakeup_mode(/*chip=*/0, cores[0]);

report_istep(15,2);
istep_15_2(/*chip=*/0, &homer[0]);
istep_15_2(/*chip=*/0, &homer[0], common_occ_area);
report_istep(15,3);
istep_15_3(/*chip=*/0, cores[0]);
report_istep(15,4);
Expand Down

0 comments on commit ea16333

Please sign in to comment.