From patchwork Mon Nov 17 10:36:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Jindal X-Patchwork-Id: 40899 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C265D24035 for ; Mon, 17 Nov 2014 10:38:30 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id y19sf911666wgg.11 for ; Mon, 17 Nov 2014 02:38:27 -0800 (PST) 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=AWqfV4lBalhsDqH/BKEoVKrfIeBkSdqEbMIPpv4UYapMZLhK4zvaWp7m5eArZXRP0Q P5e2jLlvyaK7aF/3HIYihOPwMRaTaHM2wOtPek7rR80AsedXuYRJ7jiHK5mP7kwhX5FY sqoPVxgyD5/HDm+OTDfjP9vBgYJOu1B+aQ1RHPRsIG11MbdxH0wQpTH1c5pJuhhnII1T PuCG4k/KKlrExn5Nced1+jL5Kw4qpc2mFKFyBd6dlzRIWAzbvF+6I+uMxgJIL+IlFji7 ivWH4jq8oCbMomNXKCkubMWqnvdf3cS1NCqFbFX5nbOKaNbm0h4iW61zUcNim8nOE4Sf GqUQ== X-Gm-Message-State: ALoCoQlQMhtlNcbayrXQ196xnRxOyTfUDrlON/X0sJSSK3uZkKkkpJbuK4zRkLStYwCBFGSeXQdQ X-Received: by 10.112.72.106 with SMTP id c10mr223247lbv.15.1416220706931; Mon, 17 Nov 2014 02:38:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.135 with SMTP id jo7ls1188067lab.108.gmail; Mon, 17 Nov 2014 02:38:26 -0800 (PST) X-Received: by 10.112.135.229 with SMTP id pv5mr26422217lbb.52.1416220706750; Mon, 17 Nov 2014 02:38:26 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id jb8si32309229lbc.58.2014.11.17.02.38.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 02:38:26 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id pn19so1102875lab.26 for ; Mon, 17 Nov 2014 02:38:26 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr26189103lbc.23.1416220706624; Mon, 17 Nov 2014 02:38:26 -0800 (PST) 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.184.201 with SMTP id ew9csp1132634lbc; Mon, 17 Nov 2014 02:38:25 -0800 (PST) X-Received: by 10.66.145.234 with SMTP id sx10mr2589859pab.130.1416220704940; Mon, 17 Nov 2014 02:38:24 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si9498164pdi.115.2014.11.17.02.38.24 for ; Mon, 17 Nov 2014 02:38:24 -0800 (PST) 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 S1752683AbaKQKiP (ORCPT + 26 others); Mon, 17 Nov 2014 05:38:15 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:61553 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbaKQKiM (ORCPT ); Mon, 17 Nov 2014 05:38:12 -0500 Received: by mail-pd0-f171.google.com with SMTP id r10so20931703pdi.16 for ; Mon, 17 Nov 2014 02:38:12 -0800 (PST) X-Received: by 10.70.42.98 with SMTP id n2mr2851906pdl.139.1416220692047; Mon, 17 Nov 2014 02:38:12 -0800 (PST) Received: from pnqlab023.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id od9sm8945685pbb.96.2014.11.17.02.38.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 02:38:11 -0800 (PST) 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, Guenter Roeck , Varka Bhadram , Kumar Gala , Anup Patel , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Ankit Jindal Subject: [PATCH v5 2/6] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Mon, 17 Nov 2014 16:06:08 +0530 Message-Id: <1416220572-13381-3-git-send-email-ankit.jindal@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1416220572-13381-1-git-send-email-ankit.jindal@linaro.org> References: <1416220572-13381-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.215.53 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