[Feature][ZXW-88]merge P50 version
Only Configure: No
Affected branch: master
Affected module: unknown
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I34667719d9e0e7e29e8e4368848601cde0a48408
diff --git a/ap/os/linux/linux-3.4.x/ipc/shm.c b/ap/os/linux/linux-3.4.x/ipc/shm.c
index 47d3255..8bf7f7b 100755
--- a/ap/os/linux/linux-3.4.x/ipc/shm.c
+++ b/ap/os/linux/linux-3.4.x/ipc/shm.c
@@ -72,11 +72,6 @@
static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
#endif
-#ifdef CONFIG_SYSVIPC_CROSS_SHM
-extern int shm_remote_free_pages(struct vm_area_struct *unmap_vma);
-extern int shm_do_remote_map_vma(struct vm_area_struct *vma, key_t key);
-#endif
-
void shm_init_ns(struct ipc_namespace *ns)
{
ns->shm_ctlmax = SHMMAX;
@@ -150,20 +145,50 @@
}
#ifdef CONFIG_SYSVIPC_CROSS_SHM
-void shm_mmap_pagetable(struct vm_area_struct *vma, struct file *file)
+key_t shm_do_remote_analy_key(struct file *file)
{
- int ret = 0;
+ key_t key = 0;
+ char *shm_name = NULL;
struct shm_file_data *sfd;
struct shmid_kernel *shp;
+ struct path *shm_path = NULL;
+ struct dentry *shm_dentry = NULL;
- sfd = shm_file_data(file);
- shp = shm_lock(sfd->ns, sfd->id);
+ if (file && (file->shm_flags == SHM_REMOTE_SYSV_YES))
+ {
+ sfd = shm_file_data(file);
+ shp = shm_lock(sfd->ns, sfd->id);
+ key = shp->shm_perm.key;
+ shm_unlock(shp);
+ }
+ else if (file && (file->shm_flags == SHM_REMOTE_POSIX_YES))
+ {
+ shm_path = &file->f_path;
+
+ if(shm_path && (shm_path->dentry))
+ {
+ shm_name = shm_path->dentry->d_name.name;
+ if (!shm_name)
+ panic("shm_posix_mmap_pagetable name is NULL\n");
+ }
+ key = shm_hash_name_to_key(shm_name, strlen(shm_name));
+ }
+ return key;
+}
- ret = shm_do_remote_map_vma(vma, shp->shm_perm.key);
+int shm_ipc_mmap_pagetable(struct vm_area_struct *vma, struct file *file)
+{
+ int ret = 0;
+ key_t shm_key = 0;
+
+ shm_key = shm_do_remote_analy_key(file);
+ ret = shm_do_remote_map_vma(vma, shm_key);
if (ret < 0)
- printk("shm_mmap_pagetable Error");
-
- shm_unlock(shp);
+ {
+ printk("shm_ipc_mmap_pagetable Error: No Mem\n");
+ return -ENOMEM;
+ }
+ return ret;
}
#endif
@@ -266,10 +291,7 @@
shp->shm_lprid = task_tgid_vnr(current);
shp->shm_dtim = get_seconds();
shp->shm_nattch--;
-#ifdef CONFIG_SYSVIPC_CROSS_SHM
- if (shp->shm_perm.rpmflag == TRUE)
- shm_remote_free_pages(shp->shm_perm.key);
-#endif
+
if (shm_may_destroy(ns, shp))
shm_destroy(ns, shp);
else
@@ -548,10 +570,21 @@
shp->shm_file = file;
shp->shm_creator = current;
#ifdef CONFIG_SYSVIPC_CROSS_SHM
- if((key & SHM_REMOTE_ATTR_MASK) == SHM_REMOTE_ATTR_MASK)
- shp->shm_perm.rpmflag = TRUE;
+ if((key & SHM_REMOTE_SYSV_MASK) == SHM_REMOTE_SYSV_MASK)
+ {
+ error = shm_do_newseg_check(key, size);
+ if (error < 0)
+ {
+ printk("shm size error, should be the same PAGE_ALIGN size\n");
+ return error;
+ }
+ else
+ shp->shm_perm.rpmflag = TRUE;
+ }
else
+ {
shp->shm_perm.rpmflag = FALSE;
+ }
#endif
/*
* shmid gets reported as "inode#" in /proc/pid/maps.
@@ -1087,7 +1120,7 @@
sfd->vm_ops = NULL;
#ifdef CONFIG_SYSVIPC_CROSS_SHM
if(shp->shm_perm.rpmflag == TRUE)
- file->f_flags = SHM_REMOTE_ATTR_YES;
+ file->shm_flags = SHM_REMOTE_SYSV_YES;
#endif
down_write(¤t->mm->mmap_sem);
if (addr && !(shmflg & SHM_REMAP)) {