-
Notifications
You must be signed in to change notification settings - Fork 612
os/arch/arm/src/amebasmart: refactor peripheral suspend flow memory management #6723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os/arch/arm/src/amebasmart: refactor peripheral suspend flow memory management #6723
Conversation
Note: only i2c/i2s out of all other peripherals are affected due to the use of kmm_free in suspend sleep hook, thus this only addresses those 2
|
Hello @lhenry-realtek, How about this seperate init/deinit and suspend/resume? |
Hi @ewoodev We are thinking that maybe instead of doing free in suspend, we will instead do the following: init flow --> check flag if not init, then do 1 time malloc. Otherwise just reuse the allocated pointer Reason is the peripheral will lose state and registers need to be re-init when exit PG to resync the hardware, but the os driver memory side (i2c/i2s_object) do not need to malloc again |
529fc7b
to
8ce77c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please solve confict? and check edwakuwaku's comments?
8ce77c9
to
fa7387e
Compare
…anagement This commit refactors peripheral object to remove kmm_free in suspend flow The memory region is instead reused by memset to 0 and then reinitialized
18d7e45
to
b7bca0c
Compare
@@ -60,7 +60,7 @@ void i2c_send_restart(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len, u8 restart); | |||
* @retval 1: I2C1 Device. | |||
* @retval 2: I2C2 Device. | |||
*/ | |||
static uint32_t i2c_index_get(PinName sda) | |||
uint32_t i2c_index_get(PinName sda) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this changes needed?
priv->initialized = true; | ||
} else { | ||
/* memset 0 if not required to allocate */ | ||
memset(priv->i2c_object, 0, sizeof(i2c_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The i2c_t
has just two members with 32 bit size of each. Then, just allocating 0 or null will be much faster than memset which is working with 8 bit. How do you think?
@@ -242,6 +242,9 @@ static const struct amebasmart_i2s_config_s amebasmart_i2s3_config = { | |||
.txenab = 0, | |||
}; | |||
#endif | |||
|
|||
static u8 g_i2s_inited[I2S_NUM_MAX]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it impossible to follow the same way with i2c?
@lhenry-realtek Because I are much much urgent, let me merge it now. Please check my comments at next Monday. |
@lhenry-realtek This PR is not working.. When i2cuninitialize is called, then even we call i2cinitialize, i2c is not working. Because of your new variable, other necessary operation in i2cinitialize is not called. |
This commit refactors peripheral object to remove kmm_free in suspend flow
The memory region is instead reused by memset to 0 and then reinitialized