Skip to content

main_v2 - Optimize Crater Lake - sensor monitor#214

Closed
DelphineChiu wants to merge 1 commit into
facebook:main_v2from
Wiwynn:PR/new-cl-sensor
Closed

main_v2 - Optimize Crater Lake - sensor monitor#214
DelphineChiu wants to merge 1 commit into
facebook:main_v2from
Wiwynn:PR/new-cl-sensor

Conversation

@DelphineChiu

Copy link
Copy Markdown

Summary:
- Move src/sensor/dev to common/dev
- Move sensor table from src/sensor/plat_sensor.c to src/platform/plat_sensor_table.c
- Move some functions in src/sensor/plat_sensor.c to common/sensor/sensor.c
- Move sdr table from src/sensor/plat_sdr.c to src/platform/plat_sdr_table.c
- Move some functions in src/sensor/plat_sdr.c to common/sensor/sdr.c
-Add 6 element in sensor config struct
- mux_address: i2c mux address in front of the device.
- mux_offset: mux offset to switch to the device.
- pre_sensor_read_fn: function to call before reading sensor value.
- pre_sensor_read_args: argument for pre_sensor_read_fn.
- post_sensor_read_fn: function to call after reading sensor value.
- post_sensor_read_args: argument for post_sensor_read_fn.
- The convert sensor reading to 4 bytes response data in ipmi
OEM_1S_ACCURACY_SENSNR handler.
- byte 0 ~ 1 is decimal part (LSB).
- byte 2 ~ 3 is fraction part (LSB).
- Revise sensor_poll stack size from 1000 to 2048.
- Revise gpio_workq stack size from 1024 to 2048.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 23, 2022
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread common/dev/adc.c
*reading = (acur_cal_MBR(sensor_num, val) / 1000) & 0xFFFF;
sensor_config[snrcfg_sensor_num].cache = *reading;
sensor_config[snrcfg_sensor_num].cache_status = SNR_READ_ACUR_SUCCESS;
*reading = (float)val * cfg->arg0 / cfg->arg1 / 1000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if reading is null at beginning of function

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GoldenBug,

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This problem will be solved in those PRs.
Let me create an issue #223 for tracking.

Comment thread common/dev/adm1278.c

bool adm1278_read(uint8_t sensor_num, float *reading)
{
snr_cfg *cfg = &sensor_config[sensor_config_index_map[sensor_num]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we changed all these in the main branch but we'd like to keep all these consistent.

extend "snr" -> "sensor."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GoldenBug,

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This problem will be solved in those PRs.
Let me create an issue #223 for tracking.

Comment thread common/dev/adm1278.c
printf("Sensor number %x read fail\n", sensor_num);
return false;
}
*reading = val;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that reading isn't null before dereference.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This problem will be solved in those PRs.
Let me create an issue #223 for tracking.

Comment thread common/dev/adm1278.c
} else if (sensor_num == SENSOR_NUM_PWR_HSCIN) {
// m = +6123 * Rsense(mohm), b = 0, R = -2
val = ((((msg.data[1] << 8) | msg.data[0]) * 100) / 1530.75);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else case here of bad sensor_num is passed in

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This problem will be solved in those PRs.
Let me create an issue #223 for tracking.

Comment thread common/dev/isl69260.c
int isl69260_switch_page(uint8_t sensor_num, void *args)
{
snr_cfg *cfg = &sensor_config[sensor_config_index_map[sensor_num]];
struct isl69260_page_data *page = args;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if args is null?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This problem will be solved in those PRs.
Let me create an issue #223 for tracking.

Comment thread common/usb/usb.c
keep_data_len += rx_len;
}
if (keep_data_len == fwupdate_data_len) {
while (k_msgq_put(&ipmi_msgq, &current_msg, K_NO_WAIT) != 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for this to loop forever?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed it and done the forced update.
Please review it. Thanks.

card_type_2ou = TYPE_2OU_DPV2_8;
} else if (i2c_msg.data[0] == TYPE_2OU_DPV2_16) { // in case the SKU exist
card_type_2ou = TYPE_2OU_DPV2_16;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either an else statement in case type isn't found or a switch statement with a default: tag

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed it and done the forced update.
Please review it. Thanks.

}

memcpy(&IPMB_config_table[0], &pal_IPMB_config_table[0], sizeof(pal_IPMB_config_table));
return 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem has been fixed in #195 .

RESERVED_ADDRESS, "RESERVED_ATTR", "RESERVED_ATTR" },
};

bool pal_load_ipmb_config(void)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function always returns true. Should it be a void return type instead?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return code is checked in ipmb_init() function.
We have fixed it and done the forced update.

Comment on lines +35 to +36
} else {
if (k_work_cancel_delayable(&SLP3_work) != 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an } else if {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed it and done the forced update.
Please review it. Thanks.

@DelphineChiu DelphineChiu changed the title Optimize Crater Lake - sensor monitor (main_v2) Mar 31, 2022
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread common/dev/adc.c
init_adc_dev();
if (!(device_is_ready(dev_adc[0]) && device_is_ready(dev_adc[1]))) {
printk("ADC device not found\n");
printf("ADC device not found\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print statement should identify which ADC device was not found in the event only one is missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some
commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This
problem will be solved in those PRs.
Please check #223 .

Comment thread common/dev/adc.c
osDelay(1);
}

return 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function always returns zero, I would recommend making it a void.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimization code is based on v2022.07.01. After that, the main branch has been phased in some
commits related to sensor monitoring. Those changes will be phased in main_v2 in the other PRs. This
problem will be solved in those PRs.
Please check #223 .

Comment thread common/dev/adm1278.c Outdated
}
}

printf("adm1278 initail fail\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/ipmb/ipmb.c Outdated
if (rx_len > 0) {
if (DEBUG_IPMB) {
printf("Received an IPMB message from bus(%d) data[%d](",
printf("Recieved an IPMB message from bus(%d) data[%d](",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Received

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/ipmb/ipmb.c Outdated
/* Notify the client about the new request */
if (DEBUG_IPMB) {
printf("[%s] Received a request message, netfn(0x%x) InfS(0x%x) seq_s(%d)\n",
printf("[%s] Recieved a request message, netfn(0x%x) InfS(0x%x) seq_s(%d)\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Received

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/sensor/sdr.c Outdated
void add_full_sdr_table(SDR_Full_sensor add_item)
{
if (get_sdr_index(add_item.sensor_num) != SENSOR_NUM_MAX) {
printf("add sensor num [%x] is already exists\n", add_item.sensor_num);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"add sensor num [%x] already exists\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/sensor/sdr.c Outdated
sensor_num);
return;
}
if (mbr_type == MBR_M) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably is better implemented as a switch statement.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/sensor/sensor.c
SNR_READ_ACUR_SUCCESS) {
*reading = sensor_config[SnrNum_SnrCfg_map[sensor_num]].cache;
} else if (read_mode == GET_FROM_CACHE) {
if (sensor_config[sensor_config_index_map[sensor_num]].cache_status ==

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to a switch/case statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

Comment thread common/sensor/sensor.c
return j;
} else if (i == sensor_config_num) {
return SENSOR_NUM_MAX;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need else statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GoldenBug,
We have fixed this and done the forced update.
Please review it. Thanks.

};

snr_cfg fix_class2_sensor_config_table[] = {
/* number, type, port, address, offset,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these tables placeholders for future work? If so, we should add a TODO to indicate the remaining work here (and in the next two empty tables as well)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and done the forced update.
Please review it. Thanks.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

Summary:
    - Move src/sensor/dev to common/dev
    - Move sensor table from src/sensor/plat_sensor.c to src/platform/plat_sensor_table.c
    - Move some functions in src/sensor/plat_sensor.c to common/sensor/sensor.c
    - Move sdr table from src/sensor/plat_sdr.c to src/platform/plat_sdr_table.c
    - Move some functions in src/sensor/plat_sdr.c to common/sensor/sdr.c
    -Add 6 element in sensor config struct
          - mux_address: i2c mux address in front of the device.
          - mux_offset: mux offset to switch to the device.
          - pre_sensor_read_fn: function to call before reading sensor value.
          - pre_sensor_read_args: argument for pre_sensor_read_fn.
          - post_sensor_read_fn: function to call after reading sensor value.
          - post_sensor_read_args: argument for post_sensor_read_fn.
    - The convert sensor reading to 4 bytes response data in ipmi
        OEM_1S_ACCURACY_SENSNR handler.
        - byte 0 ~ 1 is decimal part (LSB).
        - byte 2 ~ 3 is fraction part (LSB).
    - Revise sensor_poll stack size from 1000 to 2048.
    - Revise gpio_workq stack size from 1024 to 2048.
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@GoldenBug GoldenBug closed this Apr 8, 2022
facebook-github-bot pushed a commit that referenced this pull request Apr 8, 2022
Summary:
- Move src/sensor/dev to common/dev
    - Move sensor table from src/sensor/plat_sensor.c to src/platform/plat_sensor_table.c
    - Move some functions in src/sensor/plat_sensor.c to common/sensor/sensor.c
    - Move sdr table from src/sensor/plat_sdr.c to src/platform/plat_sdr_table.c
    - Move some functions in src/sensor/plat_sdr.c to common/sensor/sdr.c
    -Add 6 element in sensor config struct
          - mux_address: i2c mux address in front of the device.
          - mux_offset: mux offset to switch to the device.
          - pre_sensor_read_fn: function to call before reading sensor value.
          - pre_sensor_read_args: argument for pre_sensor_read_fn.
          - post_sensor_read_fn: function to call after reading sensor value.
          - post_sensor_read_args: argument for post_sensor_read_fn.
    - The convert sensor reading to 4 bytes response data in ipmi
        OEM_1S_ACCURACY_SENSNR handler.
        - byte 0 ~ 1 is decimal part (LSB).
        - byte 2 ~ 3 is fraction part (LSB).
    - Revise sensor_poll stack size from 1000 to 2048.
    - Revise gpio_workq stack size from 1024 to 2048.

Pull Request resolved: #214

Reviewed By: garnermic

Differential Revision: D35106136

Pulled By: GoldenBug

fbshipit-source-id: 810d6e8dd3d544d41f43372a193a4ef7aa6045cf
facebook-github-bot pushed a commit that referenced this pull request Apr 26, 2022
Summary:
- Move src/sensor/dev to common/dev
    - Move sensor table from src/sensor/plat_sensor.c to src/platform/plat_sensor_table.c
    - Move some functions in src/sensor/plat_sensor.c to common/sensor/sensor.c
    - Move sdr table from src/sensor/plat_sdr.c to src/platform/plat_sdr_table.c
    - Move some functions in src/sensor/plat_sdr.c to common/sensor/sdr.c
    -Add 6 element in sensor config struct
          - mux_address: i2c mux address in front of the device.
          - mux_offset: mux offset to switch to the device.
          - pre_sensor_read_fn: function to call before reading sensor value.
          - pre_sensor_read_args: argument for pre_sensor_read_fn.
          - post_sensor_read_fn: function to call after reading sensor value.
          - post_sensor_read_args: argument for post_sensor_read_fn.
    - The convert sensor reading to 4 bytes response data in ipmi
        OEM_1S_ACCURACY_SENSNR handler.
        - byte 0 ~ 1 is decimal part (LSB).
        - byte 2 ~ 3 is fraction part (LSB).
    - Revise sensor_poll stack size from 1000 to 2048.
    - Revise gpio_workq stack size from 1024 to 2048.

Pull Request resolved: #214

Reviewed By: garnermic

Differential Revision: D35941625

Pulled By: GoldenBug

fbshipit-source-id: 6026f97d3e707b2bde1987f4db29b73c93e3e281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

5 participants