From 672cff7ee5c5eb4a6c058fbcf57dc990d5a68187 Mon Sep 17 00:00:00 2001 From: wanghao-free Date: Wed, 8 Sep 2021 01:43:22 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3OsMountRootfs=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主干存在该问题,下一步同步主干. 挂载rootfs需要emmc驱动,emmc驱动还没有初始化好,内核就尝试挂载rootfs了, 现修改为通过一个事件同步,emmc驱动完成后写事件,内核读到这个事件再挂载rootfs close: #I43WLG Signed-off-by: wanghao-free --- fs/include/disk.h | 2 ++ fs/vfs/disk/disk.c | 32 ++++++++++++++++++++++++++++++++ kernel/common/los_rootfs.c | 1 + 3 files changed, 35 insertions(+) diff --git a/fs/include/disk.h b/fs/include/disk.h index 77737dc3..e81737e4 100755 --- a/fs/include/disk.h +++ b/fs/include/disk.h @@ -700,6 +700,8 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName); * */ INT32 los_get_diskid_byname(const CHAR *diskName); +INT32 DiskEventRead(void); +INT32 DiskEventInit(void); #ifdef __cplusplus #if __cplusplus diff --git a/fs/vfs/disk/disk.c b/fs/vfs/disk/disk.c index 2d6db3a7..89a1bb5d 100755 --- a/fs/vfs/disk/disk.c +++ b/fs/vfs/disk/disk.c @@ -58,6 +58,10 @@ spinlock_t g_diskFatBlockSpinlock; UINT32 g_usbMode = 0; +#ifdef LOSCFG_STORAGE_EMMC +static struct tagEvent g_diskInitEvent; +#endif + #define MEM_ADDR_ALIGN_BYTE 64 #define RWE_RW_RW 0755 @@ -1360,6 +1364,16 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops, } else { disk->type = OTHERS; } +#ifdef LOSCFG_STORAGE_EMMC + ret = LOS_EventWrite(&g_diskInitEvent, 1); + if (ret < 0) { + PRINT_ERR("Disk initialization event write fail \n"); + (void)unregister_blockdriver(diskName); + disk->disk_status = STAT_UNUSED; + return VFS_ERROR; + } +#endif + return ENOERR; DISK_BLKDRIVER_ERROR: @@ -1370,6 +1384,24 @@ DISK_FIND_ERROR: return VFS_ERROR; } +INT32 DiskEventInit(void) +{ +#ifdef LOSCFG_STORAGE_EMMC + return LOS_EventInit(&g_diskInitEvent); +#else + return LOS_OK; +#endif +} + +INT32 DiskEventRead(void) +{ +#ifdef LOSCFG_STORAGE_EMMC + return LOS_EventRead(&g_diskInitEvent, 1, LOS_WAITMODE_OR, LOS_WAIT_FOREVER); +#else + return LOS_OK; +#endif +} + INT32 los_disk_deinit(INT32 diskID) { los_disk *disk = get_disk(diskID); diff --git a/kernel/common/los_rootfs.c b/kernel/common/los_rootfs.c index 11a2de93..36a8852a 100755 --- a/kernel/common/los_rootfs.c +++ b/kernel/common/los_rootfs.c @@ -246,6 +246,7 @@ STATIC INT32 GetArgs(CHAR **args) } #ifdef LOSCFG_STORAGE_EMMC + (void)DiskEventRead(); g_emmcDisk = GetMmcDisk(EMMC); if (g_emmcDisk == NULL) { PRINT_ERR("Get EMMC disk failed!\n");