From patchwork Tue Sep 30 04:26:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Jindal X-Patchwork-Id: 38116 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B67A202DB for ; Tue, 30 Sep 2014 04:32:14 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf6189258lab.3 for ; Mon, 29 Sep 2014 21:32:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wHN7HtkAam5DKBZjBEDXlbQ4UlyQCPZ+6uB1Ognxfsk=; b=JXK97RHXbghWXVjZsH6v2ooOz0Zb6hVUvG1cBWbg6543y1RF1e54nUWjHSmVCltzyY aqVM84Lw1I8j9gDoZf4+wEvaFRM//1VXv4wmf1HF/L/xAoj6JLz76wUJVf12xVdwvLRE iCvFwSdE9KEsQD1JUdXfXjnXHPKgTwRJNqHrbSmXe5Hg3gqin9CGlQ3bWLN4cJWqnTAU PMYjNlj2L3NscWoW8M9AYdllMig4jnEji2djzN5YYxSMa0uom3k5cnh8ABAjI6gXxFpz /whI8DLVIPERvGB/ikQvwtiHxH8GnWtGYs6spZ3OriMP7UEd4CRV5pNttg2Bx9IL0L4/ mCBQ== X-Gm-Message-State: ALoCoQl8wYpi4hRj5TxnK8z6+rolvqKWlSzyn+h2G1ft9OZbA92WAn2amkOSMDS/LXhJiNO+JPkL X-Received: by 10.180.24.225 with SMTP id x1mr415621wif.2.1412051533358; Mon, 29 Sep 2014 21:32:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.40 with SMTP id 8ls653698laj.65.gmail; Mon, 29 Sep 2014 21:32:12 -0700 (PDT) X-Received: by 10.112.169.37 with SMTP id ab5mr20245444lbc.27.1412051532904; Mon, 29 Sep 2014 21:32:12 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx.google.com with ESMTPS id kx10si20687891lac.130.2014.09.29.21.32.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 21:32:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id 10so17261215lbg.4 for ; Mon, 29 Sep 2014 21:32:12 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr44498874laf.29.1412051532835; Mon, 29 Sep 2014 21:32:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp283202lbb; Mon, 29 Sep 2014 21:32:12 -0700 (PDT) X-Received: by 10.70.118.9 with SMTP id ki9mr86591853pdb.104.1412051531268; Mon, 29 Sep 2014 21:32:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gk5si25507757pbc.246.2014.09.29.21.32.10 for ; Mon, 29 Sep 2014 21:32:11 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751973AbaI3EcH (ORCPT + 27 others); Tue, 30 Sep 2014 00:32:07 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:61757 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780AbaI3EcD (ORCPT ); Tue, 30 Sep 2014 00:32:03 -0400 Received: by mail-pd0-f177.google.com with SMTP id v10so68873pde.22 for ; Mon, 29 Sep 2014 21:32:02 -0700 (PDT) X-Received: by 10.70.126.101 with SMTP id mx5mr71625259pdb.112.1412051522035; Mon, 29 Sep 2014 21:32:02 -0700 (PDT) Received: from pnqlab023.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id qj2sm13761033pbc.78.2014.09.29.21.31.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 21:32:01 -0700 (PDT) From: Ankit Jindal To: linux-kernel@vger.kernel.org Cc: "Hans J. Koch" , Greg Kroah-Hartman , patches@apm.com, linux-arm-kernel@lists.infradead.org, Rob Herring , Tushar Jagad , Russell King - ARM Linux , devicetree@vger.kernel.org, Ankit Jindal Subject: [PATCH v2 2/6] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Tue, 30 Sep 2014 09:56:05 +0530 Message-Id: <1412051169-9142-3-git-send-email-ankit.jindal@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1412051169-9142-1-git-send-email-ankit.jindal@linaro.org> References: <1412051169-9142-1-git-send-email-ankit.jindal@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ankit.jindal@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently, three types of mem regions are supported: UIO_MEM_PHYS, UIO_MEM_LOGICAL and UIO_MEM_VIRTUAL. Among these UIO_MEM_PHYS helps UIO driver export physcial memory to user space as non-cacheable user memory. Typcially memory-mapped registers of a device are exported to user space as UIO_MEM_PHYS type mem region. The UIO_MEM_PHYS type is not efficient if dma-capable devices are capable of maintaining coherency with CPU caches. This patch adds new type UIO_MEM_PHYS_CACHE for mem regions to enable cacheable access to physical memory from user space. Signed-off-by: Ankit Jindal Signed-off-by: Tushar Jagad --- drivers/uio/uio.c | 11 ++++++++--- include/linux/uio_driver.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 97e6444..120a84b 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -644,7 +644,7 @@ static const struct vm_operations_struct uio_physical_vm_ops = { #endif }; -static int uio_mmap_physical(struct vm_area_struct *vma) +static int uio_mmap_physical(struct vm_area_struct *vma, bool cacheable) { struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); @@ -659,7 +659,9 @@ static int uio_mmap_physical(struct vm_area_struct *vma) return -EINVAL; vma->vm_ops = &uio_physical_vm_ops; - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (!cacheable) + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); /* * We cannot use the vm_iomap_memory() helper here, @@ -707,10 +709,13 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) switch (idev->info->mem[mi].memtype) { case UIO_MEM_PHYS: - return uio_mmap_physical(vma); + return uio_mmap_physical(vma, false); case UIO_MEM_LOGICAL: case UIO_MEM_VIRTUAL: return uio_mmap_logical(vma); + case UIO_MEM_PHYS_CACHE: + return uio_mmap_physical(vma, true); + default: return -EINVAL; } diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 1ad4724..40ca3f3 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -118,6 +118,7 @@ extern void uio_event_notify(struct uio_info *info); #define UIO_MEM_PHYS 1 #define UIO_MEM_LOGICAL 2 #define UIO_MEM_VIRTUAL 3 +#define UIO_MEM_PHYS_CACHE 4 /* defines for uio_port->porttype */ #define UIO_PORT_NONE 0