fby3.5: cl: Modified IPMB architecture#47
Conversation
|
@GoldenBug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
| ipmi_msg_cfg *ptr_start = pnode; | ||
|
|
||
| osMutexAcquire(mutex_id[index], osWaitForever); | ||
| k_mutex_lock(&mutex_id[index], K_FOREVER); |
There was a problem hiding this comment.
Should this really wait forever? It seems better to use a timeout as documented in the Zephyr doc at https://docs.zephyrproject.org/latest/reference/kernel/synchronization/mutexes.html
There was a problem hiding this comment.
For function insert node, find node and timeout handler, in timeout case, it risks a condition that BIC sending IPMB success but fail to record IPMB request package, which makes BIC take IPMB response as invalid package according to IPMI specification.
To avoid thread pending forever in mutex, we think we can add mutex status check. If BIC lock mutex fail due to one second timeout, will return directly and record a mutex lock fail in BIC console.
Is that make sense to you? Or do you think there is a better solution?
There was a problem hiding this comment.
The main issue is to not hang forever. Having a one second timeout and recording the lock failure is sufficient to meet this requirement of not hanging the BMC if the mutex is unable to be acquired.
| ipmi_msg_cfg *ptr_start = pnode; | ||
|
|
||
| osMutexAcquire(mutex_id[index], osWaitForever); | ||
| k_mutex_lock(&mutex_id[index], K_FOREVER); |
There was a problem hiding this comment.
Same as above...Shouldn't this timeout at some point?
There was a problem hiding this comment.
Please see comment in insert_node case.
There was a problem hiding this comment.
Just for clarity, I agree with the same change as indicated in the insert_node case.
|
|
||
| while (1) { | ||
| osMessageQueueGet(ipmb_txqueue[ipmb_cfg.index], (void *)¤t_msg_tx, NULL, osWaitForever); // Wait for OS queue send interrupt | ||
| current_msg_tx = (struct ipmi_msg_cfg *) malloc(sizeof(struct ipmi_msg_cfg)); |
There was a problem hiding this comment.
Shouldn't there be a check here to ensure the memory was allocated?
There was a problem hiding this comment.
Will add if memory NULL check.
| while (1) { | ||
| osMessageQueueGet(ipmb_txqueue[ipmb_cfg.index], (void *)¤t_msg_tx, NULL, osWaitForever); // Wait for OS queue send interrupt | ||
| current_msg_tx = (struct ipmi_msg_cfg *) malloc(sizeof(struct ipmi_msg_cfg)); | ||
| k_msgq_get(&ipmb_txqueue[ipmb_cfg.index], (ipmi_msg_cfg *)current_msg_tx, K_FOREVER); // Wait for OS queue send interrupt |
There was a problem hiding this comment.
Should there be a timeout here?
There was a problem hiding this comment.
In architecture design, Tx thread is only in charge of message sending and driver status checking.
So for mutex in Tx thread, we would like to keep it waiting for OS ISR at the moment there is another process requesting sending message by putting mqueue, instead of keeping polling mqueue. It helps a lot in reducing task switch and optimize BIC performance.
There was a problem hiding this comment.
I'm OK with leaving it as it is to reduce the task switching and optimize performance for this instance.
|
|
||
| } else { // TODO: else if (ipmb_cfg.Inf == I3C_IF) | ||
| printf("IPMB %d using not support interface: %x\n", ipmb_cfg.index, ipmb_cfg.Inf); | ||
| free(current_msg_tx); |
There was a problem hiding this comment.
Should there be a check that current_msg_tx is not NULL before freeing it?
There was a problem hiding this comment.
Will add if memory NULL check.
| req_cfg.retries = 0; | ||
| /* Blocks here until is able put message in tx queue */ | ||
| if (osMessageQueuePut(ipmb_txqueue[index], &req_cfg, 0, osWaitForever) != osOK) { | ||
| if (k_msgq_put(&ipmb_txqueue[index], &req_cfg, K_FOREVER) != osOK) { |
There was a problem hiding this comment.
Timeout instead of forever?
There was a problem hiding this comment.
Will add mqueue status check and return corresponding ipmb_error for project layer handling.
| ipmb_error ipmb_send_response(ipmi_msg *resp, uint8_t index) | ||
| { | ||
| osMutexAcquire(mutex_send_res, osWaitForever); | ||
| k_mutex_lock(&mutex_send_res, K_FOREVER); |
There was a problem hiding this comment.
Will add timeout and mutex status check, returning ipmb_error_timeout in mutex timeout case.
| if (k_msgq_put(&ipmb_txqueue[index], &resp_cfg, K_FOREVER) != osOK) { | ||
| //free(resp_cfg); | ||
| osMutexRelease(mutex_send_res); | ||
| k_mutex_unlock(&mutex_send_res); |
There was a problem hiding this comment.
Will add mqueue status check and return corresponding ipmb_error for project layer handling for line 576.
| } | ||
|
|
||
| osMutexAcquire(mutex_id[index], osWaitForever); | ||
| k_mutex_lock(&mutex_id[index], K_FOREVER); |
There was a problem hiding this comment.
Please see comment in insert_node case.
There was a problem hiding this comment.
Agree with making the same change as is mentioned in insert_node case comment.
| #CONFIG_CMSIS_V2_MSGQ_MAX_DYNAMIC_SIZE=32768 | ||
| CONFIG_HEAP_MEM_POOL_SIZE=32768 | ||
| CONFIG_CMSIS_V2_MSGQ_MAX_DYNAMIC_SIZE=16384 | ||
| CONFIG_CMSIS_V2_MSGQ_MAX_DYNAMIC_SIZE=8000 |
There was a problem hiding this comment.
Should this be set to 8192 to be consistent with the max sizes aligning with 4K boundaries?
There was a problem hiding this comment.
OK, we will check if any side effect with setting to 8192 and fix it.
|
I agree with the proposed changes and recommendations for changes (or in the case of the tx thread, leaving it as is). Please move forward with implementing these changes. |
Summary: - There were some threads creating with CMSIS-OS2 API and which required fixed memory space for CMSIS-OS2. For Yv3.5, it requires IPMB TX and RX threads for four I2C buses and occupying too much memory to fix memory for maximum usage. Modified OS API from CMSIS-OS2 API to Zephyr kernel API, including threads, mutex, message queue. Removed memory reservation for CMSIS-OS2 stacks. - To reduce threads stack size, modified IPMB buffer from local variable to pointer and only allocate when process running. - Removed worker from common code, in that Zephyr kernel provided the service already. Test plan: -Build code: Pass -Stress IPMB: Pass Stressed get ME version for over thousands times.
f1647c2 to
aefdfe8
Compare
|
@rainlinWW has updated the pull request. You must reimport the pull request before landing. |
|
I will close this PR and PR new commit again. |
modify modbus struct v1
Summary:
For Yv3.5, it requires IPMB TX and RX threads for four I2C buses and occupying too much memory to fix memory for maximum usage.
Modified OS API from CMSIS-OS2 API to Zephyr kernel API, including threads, mutex, message queue.
Removed memory reservation for CMSIS-OS2 stacks.
Test plan:
-Build code: Pass
-Stress IPMB: Pass
Stressed get ME version for over thousands times.