RT-Thread / RT-Thread/rt-thread
[Bug]components/drivers/pm/pm.c rt_pm_device_register API would be hang when RT_USING_SMP is configured
Open
Nobody has claimed this yet.
bug
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
Description
RT-Thread Version
5.1.0
Hardware Type/Architectures
riscv
Develop Toolchain
GCC
Describe the bug
- define RT_USING_SMP macro
- using rt_pm_device_register API at components initialization context
- the API would be hang at RT_KERNEL_REALLOC calling
Solution:
put the RT_KERNEL_REALLOC calling out of critical region, just like as below:
device_pm = (struct rt_device_pm *)RT_KERNEL_REALLOC(_pm.device_pm,
(_pm.device_pm_number + 1) * sizeof(struct rt_device_pm));
if (device_pm != RT_NULL)
{
level = rt_hw_interrupt_disable();
_pm.device_pm = device_pm;
_pm.device_pm[_pm.device_pm_number].device = device;
_pm.device_pm[_pm.device_pm_number].ops = ops;
_pm.device_pm_number += 1;
rt_hw_interrupt_enable(level);
}
Other additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in components/drivers/pm/pm.c at rt_pm_device_register and trace the RT_KERNEL_REALLOC call while RT_USING_SMP is enabled. Reproduce the hang during component initialization with the RISC-V GCC setup, then verify that registration completes without hanging when the allocator is outside the critical region.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100