device: Revise how initialization status is being handled

In order to make all device instances constant, driver_api pointer is
not set to NULL anymore if initialization failed.

Instead, have a bitfield dedicated to it.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-04-30 11:49:39 +02:00 committed by Carles Cufí
commit aac9e2c5e3
3 changed files with 33 additions and 21 deletions

View file

@ -14,18 +14,27 @@
#endif
/*
* Space for storing per device busy bitmap. Since we do not know beforehand
* the number of devices, we go through the below mechanism to allocate the
* required space.
* 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.
*/
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
#define DEVICE_COUNT \
((__device_end - __device_start) / _DEVICE_STRUCT_SIZEOF)
#define DEV_BUSY_SZ (((DEVICE_COUNT + 31) / 32) * 4)
#define DEVICE_BITFIELD_SIZE (((DEVICE_COUNT + 31) / 32) * 4)
#define DEVICE_INIT_STATUS_BITFIELD() \
FILL(0x00); \
__device_init_status_start = .; \
. = . + DEVICE_BITFIELD_SIZE; \
__device_init_status_end = .;
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
#define DEVICE_BUSY_BITFIELD() \
FILL(0x00) ; \
FILL(0x00); \
__device_busy_start = .; \
. = . + DEV_BUSY_SZ; \
. = . + DEVICE_BITFIELD_SIZE; \
__device_busy_end = .;
#else
#define DEVICE_BUSY_BITFIELD()
@ -44,6 +53,7 @@
CREATE_OBJ_LEVEL(device, APPLICATION)
CREATE_OBJ_LEVEL(device, SMP)
__device_end = .;
DEVICE_INIT_STATUS_BITFIELD()
DEVICE_BUSY_BITFIELD()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)