From patchwork Tue Oct 21 05:56:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Jindal X-Patchwork-Id: 39097 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78ED0203C5 for ; Tue, 21 Oct 2014 05:58:34 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf303492lam.8 for ; Mon, 20 Oct 2014 22:58:33 -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=aTXXSwGT2W/HKrq9hAEj2MXGm7AW0XYazq69MIXbtxiMkmyVkXbGWCH+aiYA77g2Ue qFE+G5feOO4fe3n6OnvK0RnFNBLkOvOekekuhudsQprIiS4tSW6ybAqXj19/C56HHOPU U08pNQ30Ycnzi5PAtqBwV47KUH8I3W0I0LaG0T+VtQiaF4uz8mMF0DzuOWrnDZj5onQu 2ijFx5o4cWe8T6eGAszwkZPUI57ztwIORBQZ5IeAPT+s92eMGSMRaEQcEHZQYBbxqQIf Ww6dZGKC4xhH5L4DxeBzb6aebb4FW99DwIx+u68DgeBxUvl264ALU6BTIdvrynWiw0T5 uHkg== X-Gm-Message-State: ALoCoQnp1E8Ep0/nsaWpEmlGxzKoRO8bMV6Ohp4uig/et2K+v+12FJaYeB7jFDwnNtLL0cnzQ3ep X-Received: by 10.112.217.102 with SMTP id ox6mr3096lbc.19.1413871113263; Mon, 20 Oct 2014 22:58:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.43 with SMTP id cj11ls16838lad.85.gmail; Mon, 20 Oct 2014 22:58:32 -0700 (PDT) X-Received: by 10.152.205.103 with SMTP id lf7mr32136150lac.2.1413871112868; Mon, 20 Oct 2014 22:58:32 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id pw1si17255100lbb.13.2014.10.20.22.58.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 22:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id s18so387726lam.9 for ; Mon, 20 Oct 2014 22:58:32 -0700 (PDT) X-Received: by 10.152.29.8 with SMTP id f8mr32125372lah.56.1413871112772; Mon, 20 Oct 2014 22:58:32 -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.84.229 with SMTP id c5csp438448lbz; Mon, 20 Oct 2014 22:58:31 -0700 (PDT) X-Received: by 10.70.88.35 with SMTP id bd3mr31974577pdb.91.1413871111235; Mon, 20 Oct 2014 22:58:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix4si9812809pac.198.2014.10.20.22.58.30 for ; Mon, 20 Oct 2014 22:58:31 -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 S1754400AbaJUF60 (ORCPT + 27 others); Tue, 21 Oct 2014 01:58:26 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:62209 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754300AbaJUF6W (ORCPT ); Tue, 21 Oct 2014 01:58:22 -0400 Received: by mail-pd0-f173.google.com with SMTP id g10so622357pdj.18 for ; Mon, 20 Oct 2014 22:58:21 -0700 (PDT) X-Received: by 10.66.248.104 with SMTP id yl8mr11677500pac.2.1413871101585; Mon, 20 Oct 2014 22:58:21 -0700 (PDT) Received: from pnqlab023.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id fz1sm3945569pbb.80.2014.10.20.22.58.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 22:58:21 -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, Guenter Roeck , Varka Bhadram , Ankit Jindal Subject: [PATCH v3 2/6] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Tue, 21 Oct 2014 11:26:46 +0530 Message-Id: <1413871011-4101-3-git-send-email-ankit.jindal@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1413871011-4101-1-git-send-email-ankit.jindal@linaro.org> References: <1413871011-4101-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.50 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