From patchwork Mon Jul 18 09:14:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9234243 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 C0B01607FF for ; Mon, 18 Jul 2016 09:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0F98254F7 for ; Mon, 18 Jul 2016 09:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A582A26AE3; Mon, 18 Jul 2016 09:17:47 +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 3F76D254F7 for ; Mon, 18 Jul 2016 09:17:47 +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 1bP4f2-0002RM-Up; Mon, 18 Jul 2016 09:16:24 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bP4dt-0000ME-Dk for linux-arm-kernel@lists.infradead.org; Mon, 18 Jul 2016 09:15:17 +0000 Received: by mail-pa0-x233.google.com with SMTP id dx3so59096033pab.2 for ; Mon, 18 Jul 2016 02:14:53 -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=LAmvalbzte/wmPcB+F0LwB/L5Q30A2sGrrVHZwD4bMcuhk8mAcsHFweWDfhNwaCqDj UHAnByA7dHSgHY8sRaM0ZZkLW8BhepdWy+TRxHUekx4qd1jAdfMiob9RwfHMKueQycRo uVffsb314X+VKBjtijdY6eMQYJYmoL+tRwE4o= 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=gavrnx1vxCpidiVn5Z4YCILBPCgEkE4PeTBcApOIGUd5UBkse5z4GfXuNIaPR3K7vQ zW+ZvXIgdE+BLkdHMiHBOTUEm503HuYDoae2KP5nz9V3G7XPClT3deUAKs5kjr4x2fQx JBVrgmcllGN7MTVWqmYvlVPoJhGEW9dl1lJsD7Zi2wI/TnTOHWLRERh+yFwtRCfsxlxo 9DeotPK1uiNhIKlbRR9OnDQSHF9wiRNMpJQ7qI8MzYU5cWcGbmRC//hyjPw04pxFKAs4 Ao+JgNbtEDpOC5OhHBK/qCMLLXmrObgoq1oMOqV+ulv04bMLP8vdPXxYilRbF2YTF/fW OV5A== X-Gm-Message-State: ALyK8tIpyReJwBvoBpttT8hnqM1jO2TFHIxgNqjJMTkcIEQTIt0/tLcx0AOtGOswL3JAevit X-Received: by 10.66.233.38 with SMTP id tt6mr54180010pac.99.1468833292249; Mon, 18 Jul 2016 02:14:52 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jul 2016 02:14:51 -0700 (PDT) From: Anup Patel To: "Hans J. Koch" , Greg Kroah-Hartman , Jonathan Corbet Subject: [PATCH v2 4/8] uio: Add new UIO_MEM_DEVICE type for mem regions Date: Mon, 18 Jul 2016 14:44:16 +0530 Message-Id: <1468833260-5305-5-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_021513_824263_A5CC536B X-CRM114-Status: GOOD ( 12.75 ) 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 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