From patchwork Fri Jul 15 09:03:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9231387 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 0C71460574 for ; Fri, 15 Jul 2016 09:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED75125E13 for ; Fri, 15 Jul 2016 09:06:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1D6D280D0; Fri, 15 Jul 2016 09:06:41 +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=ham 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 528F625E13 for ; Fri, 15 Jul 2016 09:06:41 +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 1bNz3X-0001yc-Vy; Fri, 15 Jul 2016 09:05:12 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bNz3D-0001Ia-9o for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2016 09:04:53 +0000 Received: by mail-pa0-x229.google.com with SMTP id pp5so30944099pac.3 for ; Fri, 15 Jul 2016 02:04:30 -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=EUXrQ8eLoWYMVn889gwBB3la+QSzysLyN6iMpRgJ35+u4UBFeoMN1kTUmobaVCaAWP 5R4v2hUAxBZFY7kyUmfw0MzWOVlw+XEOyV1XQJ22zhiVzseoU9/tJJEAht92mMt/A+Dc yFmuacloW07jI2tAVBSdqociTSQ6sbIa/m0CE= 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=U5TShkKINv7NWQ3BbTIxSoXF1ePL0UMCT8F6HLvNwjb7QjF+5N65SKM52cQhvV/GLW eTs4SNfaljF/llI9YPPcCUQv/xh88NB4nT0jWN+Uw41PI2UxK1ts+zliNcCPRxrfrAR6 DF9oN1vgnkExzTPtjBOYQBQfPiaRYlF2abiG1USklYPLJlj3HJtJONRJRl4Kgpy9WYvb muDzYOHE+usIwj1VShoS/RdXlbs7DPcGZeSKsvg9HBmcvIsIpLOojIG+9lepDXyUcenS qVRGVkR4yxmaHTWhXxs0SW8Yv+l7aOx56HPjL14afM8NOvHVJ7tHJlXzR04O2+nBpzEI XQbw== X-Gm-Message-State: ALyK8tJ+tOI/l/6UZ23gwXY9Tuhh8a2IECg25EJAAtgJdx8uXNfbdMy4UV84oM9AVs8lp9W7 X-Received: by 10.67.7.98 with SMTP id db2mr29611533pad.156.1468573469970; Fri, 15 Jul 2016 02:04:29 -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 m78sm6811923pfj.66.2016.07.15.02.04.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jul 2016 02:04:29 -0700 (PDT) From: Anup Patel To: "Hans J. Koch" , Greg Kroah-Hartman , Jonathan Corbet Subject: [PATCH 2/8] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions Date: Fri, 15 Jul 2016 14:33:57 +0530 Message-Id: <1468573443-4670-3-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468573443-4670-1-git-send-email-anup.patel@broadcom.com> References: <1468573443-4670-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160715_020451_535587_697155C2 X-CRM114-Status: GOOD ( 14.20 ) 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: Anup Patel , Scott Branden , linux-doc@vger.kernel.org, Ray Jui , 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