diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 04de806e0246..8cdd4a45b5f6 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -595,6 +595,8 @@ struct fastrpc_mmap { uintptr_t attr; struct timespec64 map_start_time; struct timespec64 map_end_time; + /* Mapping for fastrpc shell */ + bool is_filemap; }; enum fastrpc_perfkeys { @@ -1274,7 +1276,9 @@ static int fastrpc_mmap_remove(struct fastrpc_file *fl, int fd, uintptr_t va, hlist_for_each_entry_safe(map, n, &me->maps, hn) { if ((fd < 0 || map->fd == fd) && map->raddr == va && map->raddr + map->len == va + len && - map->refs == 1) { + map->refs == 1 && + /* Skip unmap if it is fastrpc shell memory */ + !map->is_filemap) { match = map; hlist_del_init(&map->hn); break; @@ -1288,7 +1292,9 @@ static int fastrpc_mmap_remove(struct fastrpc_file *fl, int fd, uintptr_t va, hlist_for_each_entry_safe(map, n, &fl->maps, hn) { if ((fd < 0 || map->fd == fd) && map->raddr == va && map->raddr + map->len == va + len && - map->refs == 1) { + map->refs == 1 && + /* Skip unmap if it is fastrpc shell memory */ + !map->is_filemap) { match = map; hlist_del_init(&map->hn); break; @@ -1466,6 +1472,7 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct dma_buf * map->attr = attr; map->buf = buf; map->frpc_md_index = -1; + map->is_filemap = false; ktime_get_real_ts64(&map->map_start_time); if (mflags == ADSP_MMAP_HEAP_ADDR || mflags == ADSP_MMAP_REMOTE_HEAP_ADDR) { @@ -3918,6 +3925,8 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl, mutex_lock(&fl->map_mutex); err = fastrpc_mmap_create(fl, init->filefd, NULL, 0, init->file, init->filelen, mflags, &file); + if (file) + file->is_filemap = true; mutex_unlock(&fl->map_mutex); if (err) goto bail;