device: store device pm busy status in the state structure

Move the busy status from a global atomic bit sequence to atomic flags
in the device PM state.  While this temporarily adds 4 bytes to each
PM structure the whole device PM infrastructure will be refactored and
it's likely the extra memory can be recovered.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2021-02-02 10:37:30 -06:00 committed by Anas Nashif
commit d1a0568e11
3 changed files with 26 additions and 43 deletions

View file

@ -13,27 +13,6 @@
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif
/*
* Space for storing per device init status and busy bitmap in case PM is
* enabled. Since we do not know beforehand the number of devices,
* we go through the below mechanism to allocate the required space.
* Both are made of 1 bit per-device instance, so we compute the size of
* of an entire bitfield, aligned on 32bits.
*/
#define DEVICE_COUNT \
((__device_end - __device_start) / _DEVICE_STRUCT_SIZEOF)
#define DEVICE_BITFIELD_SIZE (((DEVICE_COUNT + 31) / 32) * 4)
#ifdef CONFIG_PM_DEVICE
#define DEVICE_BUSY_BITFIELD() \
FILL(0x00); \
__device_busy_start = .; \
. = . + DEVICE_BITFIELD_SIZE; \
__device_busy_end = .;
#else
#define DEVICE_BUSY_BITFIELD()
#endif
SECTION_DATA_PROLOGUE(devices,,)
{
/* link in devices objects, which are tied to the init ones;
@ -47,7 +26,6 @@
CREATE_OBJ_LEVEL(device, APPLICATION)
CREATE_OBJ_LEVEL(device, SMP)
__device_end = .;
DEVICE_BUSY_BITFIELD()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(initshell,,)