From patchwork Fri Jul 15 09:03:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9231397 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 7AD4E60574 for ; Fri, 15 Jul 2016 09:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6868025E13 for ; Fri, 15 Jul 2016 09:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C744280D0; Fri, 15 Jul 2016 09:06:59 +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 D886425E13 for ; Fri, 15 Jul 2016 09:06:58 +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 1bNz3z-00035E-FO; Fri, 15 Jul 2016 09:05:39 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bNz3J-0001Kp-A5 for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2016 09:05:00 +0000 Received: by mail-pf0-x231.google.com with SMTP id y134so13510853pfg.0 for ; Fri, 15 Jul 2016 02:04:36 -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=cKVZXHzCuqQvZAqM8xGH8RHsF5+YQLIWI/RqWwE0zSI=; b=g5BM2+Ga4VlBO+WfzbFv1nqbDPgncYpBebecLd7yVyyUvmHhaDoCyw7TCqqch+4uh3 N9ElMr/wjdn35N7Dz348SA2/txzdpntzNt5B98hs6bV68af7R+PPlOuxrqvBCUa7JL8p HYEC2J3UOVvR5rAnfyTY5QaGgI2llYRz8O+UY= 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=cKVZXHzCuqQvZAqM8xGH8RHsF5+YQLIWI/RqWwE0zSI=; b=FhiwBURXL8kaeLWSHnPqKBtTVbRU93b5FwaHBqnUpcvtnk6OZ+yXiwiBxMmwFRbgm9 olok3I9/W40GSQDTzo0wf31GXjkdPSC4u+u1gXbckS3iC6FFMrjqs7kS/BT/XmCHqUtE gH4+fmbqaMNQ5AdsrJPtw+jpNlPrAxJK0TYfgjQZlvjFGNAsp06rah/EAR37+zEE8bD/ 2Fbo7o4VB+3OCDM934D8gCO3x3pvSjNcUhZOCwYb6DomF9HJzqPjlzyAH5zt4n2VcJJI tQG/fUaMGR8HQBr83t4H+L5cCgpJLJqY4mGcGbDTvJs+vcRgb/OLKS4ELTN80FjLN168 2YkQ== X-Gm-Message-State: ALyK8tJPC6Sr351moHCL6FaV+ghw+x60uypBleFBGNleW7Re9tzOcK1YAXeyXvKiFPJO8k34 X-Received: by 10.98.75.65 with SMTP id y62mr19522951pfa.99.1468573476039; Fri, 15 Jul 2016 02:04:36 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jul 2016 02:04:35 -0700 (PDT) From: Anup Patel To: "Hans J. Koch" , Greg Kroah-Hartman , Jonathan Corbet Subject: [PATCH 3/8] uio: Add new UIO_MEM_DEVICE type for mem regions Date: Fri, 15 Jul 2016 14:33:58 +0530 Message-Id: <1468573443-4670-4-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_020457_690640_A00C94C7 X-CRM114-Status: GOOD ( 11.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: 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 On ARM64, the MMU supports special memory attributes for device memory/registers. Due to this we have pgprot_device() provided by asm/pgtable.h of arch/arm64. On architectures that do not have special MMU attribute for device memory/registers, the asm-generic/pgtable.h maps pgprot_device() to pgprot_noncached(). This patch introduces a new UIO mem region type UIO_MEM_DEVICE to represent device registers/memory. The UIO device drivers should prefer this new UIO mem region type for memory mapped device registers. Signed-off-by: Anup Patel --- drivers/uio/uio.c | 4 ++++ include/linux/uio_driver.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 0e53076..a00990c 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -663,6 +663,9 @@ static int uio_mmap_physical(struct vm_area_struct *vma, int memtype) case UIO_MEM_PHYS_CACHE: /* Do nothing. */ break; + case UIO_MEM_DEVICE: + vma->vm_page_prot = pgprot_device(vma->vm_page_prot); + break; default: return -EINVAL; } @@ -714,6 +717,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) switch (idev->info->mem[mi].memtype) { case UIO_MEM_PHYS: case UIO_MEM_PHYS_CACHE: + case UIO_MEM_DEVICE: return uio_mmap_physical(vma, idev->info->mem[mi].memtype); case UIO_MEM_LOGICAL: case UIO_MEM_VIRTUAL: diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 31359aee..7349f95 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -129,6 +129,7 @@ extern void uio_event_notify(struct uio_info *info); #define UIO_MEM_LOGICAL 2 #define UIO_MEM_VIRTUAL 3 #define UIO_MEM_PHYS_CACHE 4 +#define UIO_MEM_DEVICE 5 /* defines for uio_port->porttype */ #define UIO_PORT_NONE 0