This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new bfcc283694 arch/esp32_himemcdev: Multiple instances of struct file for the same file share the f_inode, ensuring that the mapping status is associated with the file entity rather than a single descriptor. Avoid redundant mapping operations caused by multiple descriptors operating on the same file. bfcc283694 is described below commit bfcc283694ba2aec660dad5317dc9427dc619863 Author: nuttxs <zhaoqing.zh...@sony.com> AuthorDate: Fri Feb 21 12:57:05 2025 +0800 arch/esp32_himemcdev: Multiple instances of struct file for the same file share the f_inode, ensuring that the mapping status is associated with the file entity rather than a single descriptor. Avoid redundant mapping operations caused by multiple descriptors operating on the same file. Signed-off-by: nuttxs <zhaoqing.zh...@sony.com> --- arch/xtensa/src/esp32/esp32_himem_chardev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_himem_chardev.c b/arch/xtensa/src/esp32/esp32_himem_chardev.c index 0138b96d55..ea8dd3ece6 100644 --- a/arch/xtensa/src/esp32/esp32_himem_chardev.c +++ b/arch/xtensa/src/esp32/esp32_himem_chardev.c @@ -62,7 +62,7 @@ static size_t g_ram_offset; /* used by himem map/unmap */ static void *g_himem_ptr; /* mapped himem pointer */ -static struct file *g_mapped_filep; /* for multi device */ +static struct inode *g_mapped_inode; /* for multi device */ /**************************************************************************** * Priavte Functions @@ -120,7 +120,8 @@ static int himem_chardev_read_write(int is_write, struct file *filep, length, dev->size); goto err; } - if ((mmap_offset != g_ram_offset) || (g_mapped_filep != filep)) + if ((mmap_offset != g_ram_offset) || \ + (g_mapped_inode != filep->f_inode)) { if (g_ram_offset != HIMEM_UNMAPPED) { @@ -134,7 +135,7 @@ static int himem_chardev_read_write(int is_write, struct file *filep, goto err; } g_ram_offset = HIMEM_UNMAPPED; - g_mapped_filep = NULL; + g_mapped_inode = NULL; } ret = esp_himem_map(dev->mem_handle, g_range_handle, mmap_offset * ESP_HIMEM_BLKSZ, @@ -145,7 +146,7 @@ static int himem_chardev_read_write(int is_write, struct file *filep, goto err; } g_ram_offset = mmap_offset; - g_mapped_filep = filep; + g_mapped_inode = filep->f_inode; } himem_ptr = g_himem_ptr + priv->offset % ESP_HIMEM_BLKSZ; copy_range = ESP_HIMEM_BLKSZ - priv->offset % ESP_HIMEM_BLKSZ; @@ -273,7 +274,7 @@ int himem_chardev_init(void) } g_ram_offset = HIMEM_UNMAPPED; - g_mapped_filep = NULL; + g_mapped_inode = NULL; return ret; } @@ -382,7 +383,7 @@ int himem_chardev_unregister(char *name) } g_ram_offset = HIMEM_UNMAPPED; - g_mapped_filep = NULL; + g_mapped_inode = NULL; } ret = esp_himem_free(dev->mem_handle);