Skip to content

Commit

Permalink
wc: mb: Improve dimm relative sensors read(follow #450) (#473)
Browse files Browse the repository at this point in the history
Summary:
- Improve ddr relative sensors read
  - Add dimm pre-read function to check dimm present or not. BIC would not monitor dimm/pmic sensor if dimm not present.

Dependency: #450

Pull Request resolved: #473

Test Plan:
- Build code: Pass
- Check sensor read from BMC while missing 1 DDR at DIMM_G: Pass

Log:
- BMC console
  ```
  root@bmc-oob:~# sensor-util mb |grep "MB DIMM"
  MB DIMMA Temp                (0xA) :   33.00 C     | (ok)
  MB DIMMC Temp                (0xB) :   32.00 C     | (ok)
  MB DIMME Temp                (0xC) :   39.00 C     | (ok)
  MB DIMMG Temp                (0xD) : NA | (na)
  MB DIMMA PMIC_Pout           (0x62) :    0.00 Watts | (ok)
  MB DIMMC PMIC_Pout           (0x63) :    0.12 Watts | (ok)
  MB DIMME PMIC_Pout           (0x64) :    0.00 Watts | (ok)
  MB DIMMG PMIC_Pout           (0x65) : NA | (na)
  ```

Reviewed By: garnermic

Differential Revision: D38548624

Pulled By: GoldenBug

fbshipit-source-id: 7276294ab3bddaf7a31c31f8ad17bcd2a3abd2ea
  • Loading branch information
MouchenHung-QUANTA authored and facebook-github-bot committed Aug 12, 2022
1 parent 67e3566 commit 156611f
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 9 deletions.
73 changes: 69 additions & 4 deletions meta-facebook/wc-mb/src/platform/plat_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "plat_gpio.h"
#include "plat_hook.h"
#include "plat_sensor_table.h"
#include "intel_peci.h"
#include "intel_dimm.h"
#include "power_status.h"

#include "i2c-mux-tca9548.h"
#include "pmic.h"
Expand Down Expand Up @@ -79,10 +82,19 @@ vr_pre_proc_arg vr_pre_read_args[] = {
[1] = { 0x1 },
};

pmic_pre_proc_arg pmic_pre_read_args[] = { [0] = { .pre_read_init = false },
[1] = { .pre_read_init = false },
[2] = { .pre_read_init = false },
[3] = { .pre_read_init = false } };
pmic_pre_proc_arg pmic_pre_read_args[] = {
[0] = { .pre_read_init = false },
[1] = { .pre_read_init = false },
[2] = { .pre_read_init = false },
[3] = { .pre_read_init = false },
};

dimm_pre_proc_arg dimm_pre_proc_args[] = {
[0] = { .is_present_checked = false },
[1] = { .is_present_checked = false },
[2] = { .is_present_checked = false },
[3] = { .is_present_checked = false },
};

/**************************************************************************************************
* PRE-HOOK/POST-HOOK FUNC
Expand Down Expand Up @@ -306,3 +318,56 @@ bool pre_pmic_read(uint8_t sensor_num, void *args)
}
return true;
}

bool pre_intel_peci_dimm_read(uint8_t sensor_num, void *args)
{
if (get_post_status() == false) {
// BIC can't check DIMM temperature by ME, return true to keep do sensor initial
return true;
}

dimm_pre_proc_arg *pre_proc_args = (dimm_pre_proc_arg *)args;
if (pre_proc_args->is_present_checked == true) {
return true;
}

bool ret = false;
uint8_t dimm_present_result = 0;
sensor_cfg cfg = sensor_config[sensor_config_index_map[sensor_num]];
switch (cfg.offset) {
case PECI_TEMP_CHANNEL0_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_0, DIMM_NUMBER_0, &dimm_present_result);
break;
case PECI_TEMP_CHANNEL2_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_2, DIMM_NUMBER_0, &dimm_present_result);
break;
case PECI_TEMP_CHANNEL3_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_3, DIMM_NUMBER_0, &dimm_present_result);
break;
case PECI_TEMP_CHANNEL4_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_4, DIMM_NUMBER_0, &dimm_present_result);
break;
case PECI_TEMP_CHANNEL6_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_6, DIMM_NUMBER_0, &dimm_present_result);
break;
case PECI_TEMP_CHANNEL7_DIMM0:
ret = check_dimm_present(DIMM_CHANNEL_NUM_7, DIMM_NUMBER_0, &dimm_present_result);
break;
default:
printf("[%s] input sensor 0x%x offset is invalid, offset: 0x%x\n", __func__,
sensor_num, cfg.offset);
return ret;
}

if (ret == false) {
return ret;
}

// Check dimm temperature result, report 0xFF if dimm not present
if (dimm_present_result == DIMM_NOT_PRESENT) {
ret = disable_dimm_pmic_sensor(sensor_num);
}

pre_proc_args->is_present_checked = true;
return ret;
}
8 changes: 7 additions & 1 deletion meta-facebook/wc-mb/src/platform/plat_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ typedef struct _pmic_pre_proc_arg {
bool pre_read_init;
} pmic_pre_proc_arg;

typedef struct _dimm_pre_proc_arg {
bool is_present_checked;
} dimm_pre_proc_arg;

/**************************************************************************************************
* INIT ARGS
**************************************************************************************************/
Expand All @@ -25,17 +29,19 @@ extern pmic_init_arg pmic_init_args[];
extern struct tca9548 mux_conf_addr_0xe2[];
extern vr_pre_proc_arg vr_pre_read_args[];
extern pmic_pre_proc_arg pmic_pre_read_args[];
extern dimm_pre_proc_arg dimm_pre_proc_args[];

/**************************************************************************************************
* PRE-HOOK/POST-HOOK FUNC
**************************************************************************************************/
bool pre_vr_read(uint8_t sensor_num, void *args);
bool pre_nvme_read(uint8_t sensor_num, void *args);
bool pre_pmic_read(uint8_t sensor_num, void *args);
bool pre_vol_bat3v_read(uint8_t sensor_num, void *args);
bool pre_intel_peci_dimm_read(uint8_t sensor_num, void *args);
bool post_vol_bat3v_read(uint8_t sensor_num, void *args, int *reading);
bool post_cpu_margin_read(uint8_t sensor_num, void *args, int *reading);
bool post_adm1278_power_read(uint8_t sensor_num, void *args, int *reading);
bool post_adm1278_current_read(uint8_t sensor_num, void *args, int *reading);
bool pre_pmic_read(uint8_t sensor_num, void *args);

#endif
39 changes: 35 additions & 4 deletions meta-facebook/wc-mb/src/platform/plat_sensor_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ sensor_poll_time_cfg diff_poll_time_sensor_table[] = {
{ SENSOR_NUM_VOL_BAT3V, 0 },
};

dimm_pmic_mapping_cfg dimm_pmic_map_table[] = {
// dimm_sensor_num, mapping_pmic_sensor_num
{ SENSOR_NUM_TEMP_DIMM_A, SENSOR_NUM_PWR_DIMMA_PMIC },
{ SENSOR_NUM_TEMP_DIMM_C, SENSOR_NUM_PWR_DIMMC_PMIC },
{ SENSOR_NUM_TEMP_DIMM_E, SENSOR_NUM_PWR_DIMME_PMIC },
{ SENSOR_NUM_TEMP_DIMM_G, SENSOR_NUM_PWR_DIMMG_PMIC },
};

sensor_cfg plat_sensor_config[] = {
/* number, type, port, address, offset,
access check arg0, arg1, sample_count, cache, cache_status, mux_ADDRess, mux_offset,
Expand Down Expand Up @@ -54,16 +62,20 @@ sensor_cfg plat_sensor_config[] = {
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
{ SENSOR_NUM_TEMP_DIMM_A, sensor_dev_intel_peci, NONE, CPU_PECI_ADDR,
PECI_TEMP_CHANNEL0_DIMM0, post_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT,
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, pre_intel_peci_dimm_read,
&dimm_pre_proc_args[0], NULL, NULL, NULL },
{ SENSOR_NUM_TEMP_DIMM_C, sensor_dev_intel_peci, NONE, CPU_PECI_ADDR,
PECI_TEMP_CHANNEL2_DIMM0, post_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT,
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, pre_intel_peci_dimm_read,
&dimm_pre_proc_args[1], NULL, NULL, NULL },
{ SENSOR_NUM_TEMP_DIMM_E, sensor_dev_intel_peci, NONE, CPU_PECI_ADDR,
PECI_TEMP_CHANNEL4_DIMM0, post_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT,
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, pre_intel_peci_dimm_read,
&dimm_pre_proc_args[2], NULL, NULL, NULL },
{ SENSOR_NUM_TEMP_DIMM_G, sensor_dev_intel_peci, NONE, CPU_PECI_ADDR,
PECI_TEMP_CHANNEL6_DIMM0, post_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT,
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, pre_intel_peci_dimm_read,
&dimm_pre_proc_args[3], NULL, NULL, NULL },
{ SENSOR_NUM_PWR_CPU, sensor_dev_intel_peci, NONE, CPU_PECI_ADDR, PECI_PWR_CPU, post_access,
0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0,
SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL },
Expand Down Expand Up @@ -241,3 +253,22 @@ bool pal_is_time_to_poll(uint8_t sensor_num, int poll_time)
printf("[%s] can't find sensor 0x%x last access time\n", __func__, sensor_num);
return true;
}

bool disable_dimm_pmic_sensor(uint8_t sensor_num)
{
uint8_t table_size = ARRAY_SIZE(dimm_pmic_map_table);

for (uint8_t index = 0; index < table_size; ++index) {
if (sensor_num == dimm_pmic_map_table[index].dimm_sensor_num) {
control_sensor_polling(dimm_pmic_map_table[index].dimm_sensor_num,
DISABLE_SENSOR_POLLING, SENSOR_NOT_PRESENT);
control_sensor_polling(dimm_pmic_map_table[index].mapping_pmic_sensor_num,
DISABLE_SENSOR_POLLING, SENSOR_NOT_PRESENT);
return true;
}
}

printf("[%s] input sensor 0x%x can't find in dimm pmic mapping table\n", __func__,
sensor_num);
return false;
}
7 changes: 7 additions & 0 deletions meta-facebook/wc-mb/src/platform/plat_sensor_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PLAT_SENSOR_TABLE_H

#include <stdint.h>
#include "sensor.h"

/* SENSOR POLLING TIME(second) */
#define POLL_TIME_BAT3V 3600
Expand Down Expand Up @@ -106,7 +107,13 @@
#define SENSOR_NUM_CATERR 0xEB
#define SENSOR_NUM_RMCA 0xEC //TBD: BMC should know this

typedef struct _dimm_pmic_mapping_cfg {
uint8_t dimm_sensor_num;
uint8_t mapping_pmic_sensor_num;
} dimm_pmic_mapping_cfg;

uint8_t plat_get_config_size();
void load_sensor_config(void);
bool disable_dimm_pmic_sensor(uint8_t sensor_num);

#endif

0 comments on commit 156611f

Please sign in to comment.