From patchwork Fri Jan 15 02:42:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Feng X-Patchwork-Id: 59801 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp270950lbb; Thu, 14 Jan 2016 18:42:57 -0800 (PST) X-Received: by 10.66.255.97 with SMTP id ap1mr11311949pad.135.1452825776931; Thu, 14 Jan 2016 18:42:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uk9si13103161pac.166.2016.01.14.18.42.56; Thu, 14 Jan 2016 18:42:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753514AbcAOCmz (ORCPT + 29 others); Thu, 14 Jan 2016 21:42:55 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:48882 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753069AbcAOCmx (ORCPT ); Thu, 14 Jan 2016 21:42:53 -0500 Received: from 172.24.1.50 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.50]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CZW84815; Fri, 15 Jan 2016 10:42:47 +0800 (CST) Received: from vm163-62.huawei.com (10.184.163.62) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Fri, 15 Jan 2016 10:42:35 +0800 From: Chen Feng To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH] staging: ion: make the pte default none PTE_RDONLY Date: Fri, 15 Jan 2016 10:42:33 +0800 Message-ID: <1452825753-36364-1-git-send-email-puck.chen@hisilicon.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.184.163.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.56985CA9.00F0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f2f6d0d7c9c4a368a4ea0b1c0e33ed0a Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The page is already alloc at ion_alloc function, ion_mmap map the alloced pages to user-space. The default prot can be PTE_RDONLY. Take a look at here: set_pte_at() arch/arm64/include/asm: if (pte_dirty(pte) && pte_write(pte)) pte_val(pte) &= ~PTE_RDONLY; else pte_val(pte) |= PTE_RDONLY; So with the dirty bit,it can improve the efficiency and donnot need to handle memory fault when use access. Signed-off-by: Chen Feng Signed-off-by: Wei Dong Reviewed-by: Zhuangluan Su --- drivers/staging/android/ion/ion.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index e237e9f..dba5942 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1026,6 +1026,9 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) if (!(buffer->flags & ION_FLAG_CACHED)) vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + /*Default writeable*/ + vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot); + mutex_lock(&buffer->lock); /* now map it to userspace */ ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);