From patchwork Mon Aug 8 05:52:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9266689 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 74F0860839 for ; Mon, 8 Aug 2016 05:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6635926E69 for ; Mon, 8 Aug 2016 05:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B00827813; Mon, 8 Aug 2016 05:56:06 +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 E1D7E26E69 for ; Mon, 8 Aug 2016 05:56:05 +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 1bWdWO-00015w-6N; Mon, 08 Aug 2016 05:54:44 +0000 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bWdVm-0000i7-6A for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2016 05:54:07 +0000 Received: by mail-pf0-x22b.google.com with SMTP id h186so115473856pfg.3 for ; Sun, 07 Aug 2016 22:53:45 -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=cuyL2ybMnKmmcsh1OBfrOld7Obyhm7wjjIK9N9gevpdoan5UmamToHsIQd3yYufJWS zdwa7p1/p+9woBcjqBYUc0iuDR4Ws3GkuEk25tmgwN7GO49pQyB+Rz+ykWj8MKHHtrKf 6EQhYifX0FnTFIjRy5Jvfz5B0cDZB6sfczyCg= 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=BGS4sdeDsdG16OV94QTelJhst1MYixvz6nD+Qa6aIg0m2IKJC3EazJzG0vgx61mt/j oU/WVoV9n3n2/CgzW4/Perzay3eox6PUelzI/HKiN+6DxHmAwlyWxMWTMwCjKoNLFeK3 8i/qmlV8Ns+6wpr77OgjfdmVfJuicUcpphEB+fvO5T9ST5s5Elq+oO8IHLo078sU9iBU xatE8DP2J1qCwgPY9hmL6m16sNWNigU9nANn5TMEHngOLQn41v3xCJUlRXnuwgxMM5Uw JwsGtGFO5DdMjua3TfjxLdIsbDyUtyOb0OHu8AEwqiAVKfFoosyRyIhcBOg8zMvH/aNq VS9w== X-Gm-Message-State: AEkoous9Pgkf9Y7TUTsN5DrLE6sRDLjsLpkb13j5HwIaKiOd0598oSjip2cuN47rPQ/yq/ht X-Received: by 10.98.79.27 with SMTP id d27mr159430304pfb.127.1470635625144; Sun, 07 Aug 2016 22:53: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 u72sm44404402pfa.31.2016.08.07.22.53.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 07 Aug 2016 22:53:44 -0700 (PDT) From: Anup Patel To: Greg Kroah-Hartman , Jonathan Corbet Subject: [PATCH RESEND v2 4/8] uio: Add new UIO_MEM_DEVICE type for mem regions Date: Mon, 8 Aug 2016 11:22:33 +0530 Message-Id: <1470635557-13416-5-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470635557-13416-1-git-send-email-anup.patel@broadcom.com> References: <1470635557-13416-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160807_225406_331371_2B337B0E X-CRM114-Status: GOOD ( 12.68 ) 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