From patchwork Tue Sep 9 09:56:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Jindal X-Patchwork-Id: 37061 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B653320491 for ; Tue, 9 Sep 2014 09:57:56 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf81779019iec.8 for ; Tue, 09 Sep 2014 02:57:56 -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=cycWUyczEYU+HIKZ9T1fTWV44fvmpXGAbY1plSb2ds8=; b=MKfcEOk3HfJ/w9t2FpQmRs12vYlQ2A0sip3OWZnY2YG8L4g+K/H8eK19RekRrSiweP fIvhRvOHYqxi6O9rF9Wj7qSqn9azi0y5M11Cxqbmy9toh0uJGoyj72ZFF1w8WICy5PeQ zb9QoM22oXSlqxuGA5siQ6lYv1Z7VdguyPH7fwG0Uoxg5DzNixdFK8BgTeIKpAyUoxTa bGrAoJV1Ja6nC4Sh8JX3rXtI367zaW2Wsge8A62QUPVHIm2u/9I6WdttSepLY/n0tsCL 82UL1yrhaScFnfR0S06i4cWsCGWyc8OVqhm3rJJaxL2a+oWkpNvHOg9fnnqWOkvyRDBd hYKw== X-Gm-Message-State: ALoCoQkGhJYsw5z5YPC7jtsi6CqsecRE1g4EWiHa10NvDNxoTMtQMGvZoZvYOo0RQ4j4TPmux2jw X-Received: by 10.182.91.43 with SMTP id cb11mr22079544obb.13.1410256676249; Tue, 09 Sep 2014 02:57:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.6 with SMTP id s6ls2108861qgd.22.gmail; Tue, 09 Sep 2014 02:57:56 -0700 (PDT) X-Received: by 10.221.68.66 with SMTP id xx2mr30145565vcb.1.1410256676153; Tue, 09 Sep 2014 02:57:56 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ci16si5551464vdb.93.2014.09.09.02.57.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 02:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hy10so3047244vcb.31 for ; Tue, 09 Sep 2014 02:57:56 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr2391372vdb.27.1410256676068; Tue, 09 Sep 2014 02:57:56 -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.221.45.67 with SMTP id uj3csp258754vcb; Tue, 9 Sep 2014 02:57:55 -0700 (PDT) X-Received: by 10.67.15.172 with SMTP id fp12mr55967188pad.4.1410256675183; Tue, 09 Sep 2014 02:57:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wq7si22024912pbc.257.2014.09.09.02.57.54 for ; Tue, 09 Sep 2014 02:57:55 -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 S1756299AbaIIJ5k (ORCPT + 27 others); Tue, 9 Sep 2014 05:57:40 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:44473 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756261AbaIIJ5h (ORCPT ); Tue, 9 Sep 2014 05:57:37 -0400 Received: by mail-pa0-f45.google.com with SMTP id rd3so4446742pab.4 for ; Tue, 09 Sep 2014 02:57:37 -0700 (PDT) X-Received: by 10.69.31.139 with SMTP id km11mr3187325pbd.67.1410256657321; Tue, 09 Sep 2014 02:57:37 -0700 (PDT) Received: from pnqlab023.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id r7sm3467936pdj.75.2014.09.09.02.57.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 02:57:36 -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 , Ankit Jindal Subject: [PATCH 1/5] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Tue, 9 Sep 2014 15:26:55 +0530 Message-Id: <1410256619-3213-2-git-send-email-ankit.jindal@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1410256619-3213-1-git-send-email-ankit.jindal@linaro.org> References: <1410256619-3213-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.220.172 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 useful if dma-capable devices are capable of maintaining coherency with CPU caches becasue we can allow cacheable access to memory shared between such devices and user space. 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 | 22 +++++++++++++--------- include/linux/uio_driver.h | 7 ++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index a673e5b..ff5b6c0 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, @@ -706,13 +708,15 @@ 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); - case UIO_MEM_LOGICAL: - case UIO_MEM_VIRTUAL: - return uio_mmap_logical(vma); - default: - return -EINVAL; + case UIO_MEM_PHYS: + 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..f6ea5bc 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -114,10 +114,11 @@ extern void uio_event_notify(struct uio_info *info); #define UIO_IRQ_NONE 0 /* defines for uio_mem->memtype */ -#define UIO_MEM_NONE 0 -#define UIO_MEM_PHYS 1 +#define UIO_MEM_NONE 0 +#define UIO_MEM_PHYS 1 #define UIO_MEM_LOGICAL 2 -#define UIO_MEM_VIRTUAL 3 +#define UIO_MEM_VIRTUAL 3 +#define UIO_MEM_PHYS_CACHE 4 /* defines for uio_port->porttype */ #define UIO_PORT_NONE 0