From patchwork Mon Jul 18 09:14:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9234241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4BE5E607FF for ; Mon, 18 Jul 2016 09:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C339254F7 for ; Mon, 18 Jul 2016 09:17:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30AD2263DC; Mon, 18 Jul 2016 09:17:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C2738254F7 for ; Mon, 18 Jul 2016 09:17:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bP4ee-0002CV-VF; Mon, 18 Jul 2016 09:16:00 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bP4dj-0000Km-9M for linux-arm-kernel@lists.infradead.org; Mon, 18 Jul 2016 09:15:06 +0000 Received: by mail-pa0-x22e.google.com with SMTP id fi15so58807710pac.1 for ; Mon, 18 Jul 2016 02:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LIGxKUJt6kg/YwvzWzDhCUujuiuGrt3lw1punpajGDg=; b=eJNhD1qEdGEmtnr8oWjkbzsXUGzYvprIXffUHV0M+CAAkDMyLfN2cNmrQ8P9zVPgZ1 s0ne++18TzS3w1jqkW4c25VeJhj5msmANqTZ4Xld1N5udpMdwOVwxzJPRxVIYtj+vB17 0a+e+C0MSkL7WboQl9Ba5/G698ULd/lDda1pk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LIGxKUJt6kg/YwvzWzDhCUujuiuGrt3lw1punpajGDg=; b=UN5vUSByodIN/e+jCiHC7n6LKKqOH7Xdi90T5Un3JmHOaXXlTzkXH2lk5mR3Q863Fm G9TqcwbROcxoFW4GpuzGBZdCXY5r/O7//ktFyVxuqfZk6LpSVOuosA/Zt2dejwawF/ae 5NojflZctPIVHcuwDXDammYmTJUIeK4Ukj3ZzkfpaCNavqJgLOZOW+8+L7NxKvkAjZMR XTeDKd9kk/D9NbnXPjf9m+W/B7L+jHrcTq9YabiGCmfUIlMDDM8M9Vl0ZWMWbRBNE1LV QPBiumXmdDwhIAdEdmbHOi25CkOteu1wegLyky90ANisrS+WzlaGUj7HblRNE5B4H9On edJA== X-Gm-Message-State: ALyK8tK2jV4bT5lP9YvBkNUScO42IlwGFHuKirbnM1m4hLX5C2GbCOEsnHpV1b5K4CvgBlLk X-Received: by 10.66.11.234 with SMTP id t10mr54579968pab.66.1468833285116; Mon, 18 Jul 2016 02:14:45 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.ban.broadcom.com ([202.140.56.34]) by smtp.gmail.com with ESMTPSA id z1sm2883269pab.19.2016.07.18.02.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jul 2016 02:14:44 -0700 (PDT) From: Anup Patel To: "Hans J. Koch" , Greg Kroah-Hartman , Jonathan Corbet Subject: [PATCH v2 3/8] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Mon, 18 Jul 2016 14:44:15 +0530 Message-Id: <1468833260-5305-4-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468833260-5305-1-git-send-email-anup.patel@broadcom.com> References: <1468833260-5305-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160718_021503_547634_AC9BE398 X-CRM114-Status: GOOD ( 15.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Anup Patel , Scott Branden , linux-doc@vger.kernel.org, Ray Jui , Russell King - ARM Linux , linux-kernel@vger.kernel.org, Rob Herring , bcm-kernel-feedback-list@broadcom.com, Ankit Jindal , linux-arm-kernel@lists.infradead.org, Jan Viktorin MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ankit Jindal 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: Anup Patel --- drivers/uio/uio.c | 16 +++++++++++++--- include/linux/uio_driver.h | 9 +++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index f2729b7..0e53076 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -641,7 +641,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, int memtype) { struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); @@ -656,7 +656,16 @@ 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); + switch (memtype) { + case UIO_MEM_PHYS: + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + break; + case UIO_MEM_PHYS_CACHE: + /* Do nothing. */ + break; + default: + return -EINVAL; + } /* * We cannot use the vm_iomap_memory() helper here, @@ -704,7 +713,8 @@ 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_PHYS_CACHE: + return uio_mmap_physical(vma, idev->info->mem[mi].memtype); case UIO_MEM_LOGICAL: case UIO_MEM_VIRTUAL: return uio_mmap_logical(vma); diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 32c0e83..31359aee 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -124,10 +124,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_LOGICAL 2 -#define UIO_MEM_VIRTUAL 3 +#define UIO_MEM_NONE 0 +#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