From patchwork Thu Nov 13 07:45:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Jindal X-Patchwork-Id: 40709 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 008AD240ED for ; Thu, 13 Nov 2014 07:47:31 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf2899254wiv.6 for ; Wed, 12 Nov 2014 23:47:30 -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=GfW2rsLmOzFzUh33ZBPj4hnLQMx8/O5r85YZuXmH3cKkYuTuQuylW9zNwBoJ9Q/0Vp OmowNkQbnuJ36Yz29KnBccqcwhPSsT/KIz5uoPy4GkorI0tV41YY+BuB/Gwk8VHPRmnd HFWLZDZQLVctbaH0GWiMfqQgWuavY6MZBIpVC/3ez1berqxKYM8WxE3a86b/nb3yrfs9 SKVTaqI31qE+n7QYB9tksDRsuy1wkJd5NIaHuSHQtlniNMapiPYq6tSytiv9QNlXc3X1 FDh+Ue94xKfNCjpqr/VjdB4HaXfYONuE3SWMkGfjTJCd2z6EZU+2z65q0vvXhJ5xCj/m rK/A== X-Gm-Message-State: ALoCoQnBGrwtQfSuARbsGcK4V0MDhWsX9eNbgvPNH7B8/Vzy/LD+4xoPoadiQbOB0MrYS1qwVz62 X-Received: by 10.180.90.234 with SMTP id bz10mr7619101wib.0.1415864850289; Wed, 12 Nov 2014 23:47:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.200 with SMTP id x8ls707700lae.76.gmail; Wed, 12 Nov 2014 23:47:29 -0800 (PST) X-Received: by 10.152.9.136 with SMTP id z8mr830801laa.2.1415864849776; Wed, 12 Nov 2014 23:47:29 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id jo7si37481109lbc.39.2014.11.12.23.47.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 23:47:29 -0800 (PST) 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 hs14so6519498lab.9 for ; Wed, 12 Nov 2014 23:47:29 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr805669lbc.34.1415864849687; Wed, 12 Nov 2014 23:47:29 -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 ew9csp551186lbc; Wed, 12 Nov 2014 23:47:28 -0800 (PST) X-Received: by 10.70.87.144 with SMTP id ay16mr754480pdb.85.1415864847257; Wed, 12 Nov 2014 23:47:27 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha3si24779438pbc.225.2014.11.12.23.47.26 for ; Wed, 12 Nov 2014 23:47:27 -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 S932115AbaKMHrO (ORCPT + 25 others); Thu, 13 Nov 2014 02:47:14 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:52378 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932093AbaKMHrL (ORCPT ); Thu, 13 Nov 2014 02:47:11 -0500 Received: by mail-pa0-f42.google.com with SMTP id et14so3548pad.1 for ; Wed, 12 Nov 2014 23:47:11 -0800 (PST) X-Received: by 10.68.221.34 with SMTP id qb2mr954313pbc.72.1415864830944; Wed, 12 Nov 2014 23:47:10 -0800 (PST) Received: from pnqlab023.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id ev8sm24087271pdb.28.2014.11.12.23.47.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 23:47:10 -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 , Ankit Jindal Subject: [PATCH v4 2/6] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Thu, 13 Nov 2014 13:15:18 +0530 Message-Id: <1415864722-2800-3-git-send-email-ankit.jindal@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415864722-2800-1-git-send-email-ankit.jindal@linaro.org> References: <1415864722-2800-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