From patchwork Sun Dec 2 06:19:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9387A1579 for ; Sun, 2 Dec 2018 06:16:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8131A2B11D for ; Sun, 2 Dec 2018 06:16:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 748302B12A; Sun, 2 Dec 2018 06:16:04 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D30F2B11D for ; Sun, 2 Dec 2018 06:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EFD26B61F8; Sun, 2 Dec 2018 01:16:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 99EBC6B61F9; Sun, 2 Dec 2018 01:16:02 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88E5D6B61FA; Sun, 2 Dec 2018 01:16:02 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 4A6186B61F8 for ; Sun, 2 Dec 2018 01:16:02 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id v12so7483764plp.16 for ; Sat, 01 Dec 2018 22:16:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=zpuGNdUnpdN5wTEIRBOxYuxj5rUfCCVuWQ25gpRoE6s=; b=JkD5d9HQSCJuMv7TcOonEuPvKTYuALvfMoaQcKKqZB592vS++cC+jmwX9D+CzoT+xB ci0glGHQsQg4X9QN0uc3kVNs+j5Xz4IGG0Ha82Va8ecZIj+B0Syaf9kIZF8mC/Ib+blp k7ZXGdwQo4eS/OjxmYoob3VLVb17tGgSCF8vnqCsgAS3llZ69tIuO8qDd7cXpea/22vm tuJmiABaBXTa2pN6u/9F3nVEniaCx05qsx2mtR7ore5IZSBHtgGbL3hN3eK8dCNxVRt1 vxR9S1TIxzmBYFMFjmThTeOFSBED98kbGZJXErgmORysdiHTiFScHcCkx0wJwTjUNXCF qBVw== X-Gm-Message-State: AA+aEWZWOxutZ43zy7lMJw3pHTfKw+Siw6Ud2QPnZz5SOtnahC4Y6H8V w7ttt4OAG61qMJhHO1beUa6e5TkZz+cXKnGcVBfLCSMIMVTN+rguQbwBfT9XxLbhSUAmTiONqVq UdmqMEXi7P/LjJvhQmeCJkIb1gj5CVr0t+yRHmI5edSd2GX7GiEENjoXK7Typ1QsY6BmKz+JT7p 8QH1ietfM0sMQPgIe2hJ3dBUFAlDsQOm5NjfEPYg+/EHASxLwVTbjvg2iyq99irIojJIHHxBpLN IsTRvR+Mq8J+qJ2Bz3fzkS1K18+3dwQFlMAMAymI93vilzNXYOEBm2+WaG1rITBViRtOLGHUO+P NaK/Bxbhjh8QHUpJzebOmcLw7Zn30vphD0EzrDAtni51RucwXjTxMPGwSELkOSAP1gYz0FPJGqP n X-Received: by 2002:a62:9419:: with SMTP id m25mr11971214pfe.147.1543731361907; Sat, 01 Dec 2018 22:16:01 -0800 (PST) X-Received: by 2002:a62:9419:: with SMTP id m25mr11971188pfe.147.1543731360928; Sat, 01 Dec 2018 22:16:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731360; cv=none; d=google.com; s=arc-20160816; b=nVevVrFw6jdsho9ACtwiWtrqugQZ/z4lw0/jzYuOS1cZhRGhXrPuDOIY3Yqf2Nu0QJ lVOPSRlGadLWZRLg0KiWrllKDBW3/hdmH7tmZZB6VuL6CUb6TRpT913IR0bYLV851im5 V6TkLuJleoHb8NKCoefm2nqYceEkcShdrCLqi1Td4ThvnmNnst2U3usUtvq40E+9TK31 Hy5haQ0PXOriokUqYZryoBi1eTeROZaswo029p+OPFJXrhf+dPEBBRt0tT6Q6FFHI3hy qZwI8DCSLB+wIOauctu05eA8XThQwW7NHfXodR9n6Fn/wHj0A6prJf3KnEukO5tCZSjG qgCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=zpuGNdUnpdN5wTEIRBOxYuxj5rUfCCVuWQ25gpRoE6s=; b=ZlacafiYw+P0+PAbHr4EXC5vXWSh/cgnp33aLQN48LEefr5mEtnTLUL2wztu4iy2Dd Ptwh3XywrQBc3VOklRMsVPF07Zs5IxWoR1YB/lSkeCVt5f72BmBBBHOV0PHhxZiCCrcg 45IO1Il50gONkoMRpOkxJn2B5pvzB7LVOReGJ+xFIsBbJT7umQu8q+QynOZjwUdZi4/w P58728Hfpb5xGwpRZAX7MrYWpbALj6jCyZq9UIDNXEjug/2ZhAySZU+y7xP1MRqAKRW6 mOBvbr2HUJ4fGXNkoA7+S9fKK/17zdtP+54zyvg5au7FYYCCYz0TI3vmttP32l0bz+hq mUqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bWk6uLkF; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v191sor12663918pgb.53.2018.12.01.22.16.00 for (Google Transport Security); Sat, 01 Dec 2018 22:16:00 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bWk6uLkF; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=zpuGNdUnpdN5wTEIRBOxYuxj5rUfCCVuWQ25gpRoE6s=; b=bWk6uLkFrct4pezrRVHDS3fxAfnzuH30JJU4oMJOz2yuRc6qGON0LS3euO9PI18qCG ZWCJ/La6wnc++Nb6Jl5M7htxappQkoe07uJn+Tgm2gzZrUpW4u6sFMq4hhElyN39p+9v zz1vE8r8mohE3kP3S+LsBxTj9Y9QmOvTxyr+xuNsnDmySrcEt7Zz/1uqxJRqxgRQTFTW h/SSYR9cuTSYigG5l+TwSwbmOvd7pT/sHv8kYvijQHX0gOgpzngqpuzQWss+3SjvQuvP Q74IyFtYvg1IFgMLRPd0NLO+dpLsHbzDcBnYYIMyHZbKylIA5otr3Lj2UWKVL3p/SPpM lv9w== X-Google-Smtp-Source: AFSGD/UBkP9uRpZkSu5Rmi17UiqjfK/g8dHm6TgDXv94eGr1l1iC6bkXVyD45WRhl9f9OjSvEy60DQ== X-Received: by 2002:a63:4c4e:: with SMTP id m14mr9689461pgl.173.1543731360563; Sat, 01 Dec 2018 22:16:00 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id v14sm16952190pgf.3.2018.12.01.22.15.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:15:59 -0800 (PST) Date: Sun, 2 Dec 2018 11:49:44 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, riel@surriel.com, sfr@canb.auug.org.au, rppt@linux.vnet.ibm.com, peterz@infradead.org, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com, stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, kyungmin.park@samsung.com, mchehab@kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org Subject: [PATCH v2 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181202061944.GA3094@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers. vm_insert_range is the new API which will be used to map a range of kernel memory/pages to user vma. This API is tested by Heiko for Rockchip drm driver, on rk3188, rk3288, rk3328 and rk3399 with graphics. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Tested-by: Heiko Stuebner Reviewed-by: Mike Rapoport --- include/linux/mm_types.h | 3 +++ mm/memory.c | 38 ++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 48 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 5ed8f62..15ae24f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, extern void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count); + static inline void init_tlb_flush_pending(struct mm_struct *mm) { atomic_set(&mm->tlb_flush_pending, 0); diff --git a/mm/memory.c b/mm/memory.c index 15c417e..84ea46c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,44 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, } /** + * vm_insert_range - insert range of kernel pages into user vma + * @vma: user vma to map to + * @addr: target user address of this page + * @pages: pointer to array of source kernel pages + * @page_count: number of pages need to insert into user vma + * + * This allows drivers to insert range of kernel pages they've allocated + * into a user vma. This is a generic function which drivers can use + * rather than using their own way of mapping range of kernel pages into + * user vma. + * + * If we fail to insert any page into the vma, the function will return + * immediately leaving any previously-inserted pages present. Callers + * from the mmap handler may immediately return the error as their caller + * will destroy the vma, removing any successfully-inserted pages. Other + * callers should make their own arrangements for calling unmap_region(). + * + * Context: Process context. Called by mmap handlers. + * Return: 0 on success and error code otherwise + */ +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + unsigned long uaddr = addr; + int ret = 0, i; + + for (i = 0; i < page_count; i++) { + ret = vm_insert_page(vma, uaddr, pages[i]); + if (ret < 0) + return ret; + uaddr += PAGE_SIZE; + } + + return ret; +} +EXPORT_SYMBOL(vm_insert_range); + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..d6ef5c7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_insert_range); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Sun Dec 2 06:21:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BBDB1579 for ; Sun, 2 Dec 2018 06:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5670C2B11D for ; Sun, 2 Dec 2018 06:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466D32B12A; Sun, 2 Dec 2018 06:17:28 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA27D2B11D for ; Sun, 2 Dec 2018 06:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07CA66B61F8; Sun, 2 Dec 2018 01:17:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 000936B61FA; Sun, 2 Dec 2018 01:17:26 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE51C6B61FB; Sun, 2 Dec 2018 01:17:26 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 99DC66B61F8 for ; Sun, 2 Dec 2018 01:17:26 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id bj3so7475911plb.17 for ; Sat, 01 Dec 2018 22:17:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=M5GVk7+Gz+2YNymxj7d3XB1f3E675vsSass40DGnlxojzPMb32f0yBwucmoJYGLNM/ mBGbZ+K9DJWhqgxycRcPYsj4ZI90EGX+8fAlIOYiPTtlSAsOz4cKIGGUvnad0VMPr746 GlCSK/gRzdS20gELakE0gyg0xYvLWSM1zr8Msu7knjWIg7yiHAccT/f5WjuS6gilnYqH JLx80iYRBOhTAX2+G/9/3agKGkplEgSatgXXiRB65bDHUl2uh2kXD2YglYdcFi+MBbiX EOv7K4eDUhQpolPb6dXZ2mJereFXzRJ5jxOSqRzpSIqK/YtNnsrNV8R/pQhImqmrk7j2 cvFQ== X-Gm-Message-State: AA+aEWZziRge2P9RR7RrqtNn1slkQyh2dEkXPvWKkgtdZIGs+ZCPJ9On 1CM2w/W772LQxRdZ6jKZ94MQ1j81rThxXkfCKQTeOhBJymKQri5EFQ/4YFq9tvNhHWpMq9yKiH7 SY8CpzshybUFEjWZHsuJXZ1b+W1QAOHQbMc4yJooT6PbqTCGYyWpLL4omTt5iR1uAWtIHEZzbyn m4KWQawMyjIqrReQ/PiCxtW6G9lC1OuMoG70KEkwF2fdjrgXnSODb5jrVcxQITetAn6YMV/CkoD jchhCdHN3bUJ580COSjhSpWrGil1lUTFdA5BcVp6w6EhaTyftu5rhZSh6+23Kg5SLRqcxuPo2Ga ORjpGZ/rB6UO+17Kx18lQWyh5twpyfIevxoPQ0NmP5OJ/QXPnsVAoND4lGto6DUo6+HLLtd0gZn f X-Received: by 2002:a62:109b:: with SMTP id 27mr11154388pfq.227.1543731446299; Sat, 01 Dec 2018 22:17:26 -0800 (PST) X-Received: by 2002:a62:109b:: with SMTP id 27mr11154375pfq.227.1543731445560; Sat, 01 Dec 2018 22:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731445; cv=none; d=google.com; s=arc-20160816; b=U+MxFcWEDydk0S1YPvsSPThecRUwCGMFtlOPv2sHKlwx6MWN9eg8LT8b9TA7t0PZdG fwfyGp3HHHekhGhE5zCeZTu7jG22DosyiHW4un+7uUdUS/ZuFsFjAgFrRhyGWemHVTT9 sw9MRHnfTs1h+gER3RFSv2r9R1vq4ZAfVZvRCc+KH5VPRxXFbDHekue7eZQAdsLkesWX dC9k3Ww72/28ymc7JMc/XQalc6mnDpjpVvfI1jJBh6MrdQd5qN5ypFvODw/7qe+HWA3G mXccTIjseVXnAwsm2jBeRttxTnWNzETu3CUq/jDJWAL/jBD4To9zh4muDRJRHMngXFtS h0XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=FLGQX568wfjz98hLen7c6N4w08HujBrDvMbCuyaevEfnHfZUwX+4zU6Sj5Vhk1cLQb xQO4oC81dXkXlznW7jvjxNTCog7n140hY7tWI7dT/phrMDA3AhIAkzNHpmRhXQmTCRFZ 5iWKh2I3t80+tv5BnBf0Ysy5JKW5LNl08MuUOzo3W2eDKPxIt48HXC4/LOQubDuLVZhZ /3e4I0xkQEATV9iz4Vm40An0o8Pu7SmSYd2D64+kuwvQIizjjL6zoSdlH+va6Hj2PTQT azmbk1v/uyCNNiNpWjIC44eUSOEKxmJnd09tLqrB9UOuBoCJCSyalHbR+SmOqU7gIKeO f1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mBs4dq/T"; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v13sor12744528pgn.66.2018.12.01.22.17.25 for (Google Transport Security); Sat, 01 Dec 2018 22:17:25 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mBs4dq/T"; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=mBs4dq/TeqPHUFL3AVrh3JJ/g+dMhVdSUtuuYiWThyelgCPlvamNLncj9Z0m9wretJ dHQvALWfWyfZ+7pRKHCJ8GadHqubftSlzYY9F1kU9Q42HBarg2E2uV5mDeQzLVNSb048 gv8GxLTCIgRIx432n2ija9tH3s8sgqauV6Ulm8WtyP7po08V3uPqb5C6Xs5u3x4KCpZC GAXsbgqClWr3kUjmQtErJtDmoLutvnGAy293IObP4qojbp3bkmwLacBfB9qkW4bQdN86 hJ62U470REpyHVCTaNKFe5GJyUfNQi/0Px/7/+s0OfcUYwyXdeauPqvC1Q2BEUbrPjW7 CDmw== X-Google-Smtp-Source: AFSGD/XskkVCLMV56P5G6hSJkQEj8Bb7420tD78vrgpfyz80/Ofs70Y80gJpaUlH3MXPhcU17HkqjA== X-Received: by 2002:a65:63d3:: with SMTP id n19mr9785026pgv.179.1543731445240; Sat, 01 Dec 2018 22:17:25 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id q1sm12648437pfb.96.2018.12.01.22.17.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:17:24 -0800 (PST) Date: Sun, 2 Dec 2018 11:51:09 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181202062109.GA3111@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder --- arch/arm/mm/dma-mapping.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..4eec323 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,31 +1582,24 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs) { - unsigned long uaddr = vma->vm_start; - unsigned long usize = vma->vm_end - vma->vm_start; + unsigned long page_count = vma_pages(vma); struct page **pages = __iommu_get_pages(cpu_addr, attrs); unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long off = vma->vm_pgoff; + int err; if (!pages) return -ENXIO; - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) + if (off >= nr_pages || page_count > nr_pages - off) return -ENXIO; pages += off; + err = vm_insert_range(vma, vma->vm_start, pages, page_count); + if (err) + pr_err("Remapping memory failed: %d\n", err); - do { - int ret = vm_insert_page(vma, uaddr, *pages++); - if (ret) { - pr_err("Remapping memory failed: %d\n", ret); - return ret; - } - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - - return 0; + return err; } static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, From patchwork Sun Dec 2 06:21:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F3E11579 for ; Sun, 2 Dec 2018 06:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DF2C2B11D for ; Sun, 2 Dec 2018 06:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E5502B12A; Sun, 2 Dec 2018 06:18:16 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6CFF2B11D for ; Sun, 2 Dec 2018 06:18:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21FE6B61FB; Sun, 2 Dec 2018 01:18:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CAAB06B61FC; Sun, 2 Dec 2018 01:18:14 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4CED6B61FD; Sun, 2 Dec 2018 01:18:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 6EEDF6B61FB for ; Sun, 2 Dec 2018 01:18:14 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id ay11so7495253plb.20 for ; Sat, 01 Dec 2018 22:18:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=YVD5Z9lfh58z5+d5iqx40A6MewG7h6466HSed98qNYbbqxmuO3Ms6Z0C3U5k0Squqo CkLYmawtnPoP+Em3yxVS94dsqLvIgTeBZbSzeDff4PSehGftxPgkEfeHh6uF3T9ubijd fjQeZ3ZXL6LTiRadk3hhJgk0CRvd4f6zj27sOB5DFkycrIvdfPySWWvNWxeRq+4SPKZs /bph9LpOgLEZlbE5VHnJ0fNr8DyCgHdyJbqe7SpZAT+Ibin7GLT43j7Dnga65VbZZAsI oSGTo52oV6UviCASHwNLP4Y574Tv95/g7UM9VCDFV4DtOIY+BaJYMg705TJzBBqeoidH E9eA== X-Gm-Message-State: AA+aEWaGr7pgHTmX7wSHE427PtXmA41hhx1KrfzErbW7NsnlfWGS+1ba kI32xQLJ5E3msy8ETy15Z5dlLEvWjVzXpEzdmUabPmK67SbPOuQym8hdAw26hJjLZWUl0Q9BCUt opVn4Mb3yfGemJCoRDxpZAOKfnT88bG9S3R9dlb+HVMxdtXzEEN1F4g/IWBmMu2873XYT10OFTs B7+U+JHuDiJ/VlgW6KMsn7ZILDUlJdYUftA5qHxMrCTyumllz6BJzOBobsi+zOSAn2D6eLgFJ0L 5Ue9zeQxt4OK6/q0ZtyhvYkHNuzqB4+3BSSrQflsTCro85ECI4rWy57HWPeMVFPiikooIhc8whG oX4x9zdVBQZcoALnOPDNdOsm9+aY75XbIchJGnsxd03FDuU2AITEHGepRfnANWUrK+3v4qVCG9o K X-Received: by 2002:a17:902:346:: with SMTP id 64mr11796355pld.337.1543731494077; Sat, 01 Dec 2018 22:18:14 -0800 (PST) X-Received: by 2002:a17:902:346:: with SMTP id 64mr11796342pld.337.1543731493505; Sat, 01 Dec 2018 22:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731493; cv=none; d=google.com; s=arc-20160816; b=gAymoRsuJQOodqerYnZbvyGCtPaCjkyvDaMXCeme1g/OY8aRxyxsoIXXIPubUwiGJh fCVHN/BqIWVhnIaNJCYRWME26A/aURl/+wupZkU/BTd/7/y739d1xtFnUfwbTVWsDZQr yXYJXxlBOxE58c/Al87OXw7OQ1Vps2DfB1s31I6fYweQEGaR80aI5tCm02Tx+VGqk6eE UVDAc8Zda8lctf/U++bxiXUI1S17DY4xgPO3SOyeGPZxrIfUj/8+lxcpSBDY3ASD0IPo axyoyOzg3pia0Rkn7PjBR5kQoSyyoPHuXFZJ1zjQoOFm9bixVzv+aXFNDswf92Srg3Aj 1qmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=AC9PLpTtr3YCKJSZ+2wHmdW+o1K89q02j1+FGyybcJvfeZponZ0968urrx494IjXUm +jGq/scxuISNMsIjvrcCYMjASrJx9cjn6MpIer+984BxWiGgrN3DST2JSTltczS4v664 W7FDwqjjJn99nZgatjUR1lHbiggDSVq9OQmSYoGyKNfAZT/s/T0cZsE07dq8iI1K0u4K 9amsm0MIe0J8DgOPSNiPSoKwWU46PQy4IUF3mLiLsRRdy3QDZBgmS0EYIai2CxkaLzCZ xhKri9yFnPYMy2m00QrRLrPc4UOVg0bRTrulIJfF/+VkUFCuZ+IupiDS4FYko7w79XKG 0hbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ob52eAyb; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t18sor10124624pfi.23.2018.12.01.22.18.13 for (Google Transport Security); Sat, 01 Dec 2018 22:18:13 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ob52eAyb; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=Ob52eAybZ+ukSyGdY8U/Z1jdhXxFQFle/dMi4Et2nQndtm7MZ2i4ONnKsVDEIcjDDz 9W38WqOW1p9mt0J7xkQxfLmLL/jnq1/LcrLmoOqnc9m337jYRgsykPHqvssdhQ8pmZqy AcyrBFinNSivTuQmUI01wz1gKLQW9G1svEowGTi2+SAQF6CW3SbPSPNlOgF5HsoRXG/R 9K9JQ52ZvaqN5BHcgkhczNdO8IQ5qGjOakvBGCY0Sm0g3u6hbovABd7E77bu2Yv2l4eb Ba8iBaRv7cN2h5YB8JO3+4IihJv60g16Rfz+y3KC66wo+3y0mJ60ov/ncoRJ0hAIFPOQ x9gA== X-Google-Smtp-Source: AFSGD/UHCJICHgiE0m052Ybq6CARBcS+P92LNUcrBDatOdJIiC6ahi3tnqCNt66ImpC9ArLD+LG41w== X-Received: by 2002:a62:546:: with SMTP id 67mr11166313pff.99.1543731493182; Sat, 01 Dec 2018 22:18:13 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id g15sm46055783pfj.131.2018.12.01.22.18.11 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:18:12 -0800 (PST) Date: Sun, 2 Dec 2018 11:51:56 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net Subject: [PATCH v2 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181202062156.GA3131@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/firewire/core-iso.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 35e784c..7bf28bb 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) { - unsigned long uaddr; - int i, err; - - uaddr = vma->vm_start; - for (i = 0; i < buffer->page_count; i++) { - err = vm_insert_page(vma, uaddr, buffer->pages[i]); - if (err) - return err; - - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, buffer->pages, + buffer->page_count); } void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, From patchwork Sun Dec 2 06:22:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7CCF13AD for ; Sun, 2 Dec 2018 06:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D66742B4ED for ; Sun, 2 Dec 2018 06:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C97472B4F2; Sun, 2 Dec 2018 06:19:13 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A0692B4ED for ; Sun, 2 Dec 2018 06:19:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB1686B61FC; Sun, 2 Dec 2018 01:19:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A60066B61FD; Sun, 2 Dec 2018 01:19:12 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9032F6B61FE; Sun, 2 Dec 2018 01:19:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 4A25B6B61FC for ; Sun, 2 Dec 2018 01:19:12 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id y2so7493425plr.8 for ; Sat, 01 Dec 2018 22:19:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=eVrH89lLX+P5XTr59E5+iiYNudEtZkEkknVqjCQlCp1DJgqcKJFm4k2rbuFFQaXWAy UGR3EWD10U2Rqq0/jqZy6V29TKsqj+wUFDbSYe/t/7bSEUipPy+hHgc6ZieXoqltWN/o nVyxOKif6nOAWOaAbAQiqyQxBrMyHqyuK3/iO8QqNzUUdDFmRbL1ZYR0EXjOfq+93dPo FkP+rZNXr+JBN2s8mgU+EXI4LyVdUgBcvKsVVWe7WemVmYWO4DDUVOip7AVQi45TeCjr EqbafnlRrJkLHGroEhn1Muwrg6SwEpp6kIoN1jgjWpmY10fV58fFFNVeGLih0U+/DOQC /gQg== X-Gm-Message-State: AA+aEWY7ESuNwvbsCwQYsrcow9jJmQsj4ulx8MUGOtV4kmzcGpputok/ p9luGA/kCtFsZUHnP/qMM0tTm5T60rjJFeZI8WWeDM3HFT4LBljOs7wONMQmcd5zPCd9CmBmiys V825KmjiyLSZwjRFeXa1NnemmB3j44jeCCL8QKiGmbzqsa3iY4yKstuLWToGFvLc4EjNvybv2Ux OHnv7SwxynqAl3zdOl+/PDkwh6hYfY+UxS+lNQaJCmzSquBZY6lFA0YVbnJtA7tpC7nMbKN/8aj 2cwoWbLjTDm8Uql62oVhlO/bDyQLVThttHFmwL4Sfk4ssZVYXV+9ZNmGvZzzYFYXGM27PNoa1Z6 V/UBNK6dcWbLJU2jiLzf6XqaaWTQdZ73UC3N9PgDJT+jKfg7BNBC2eHunl2MgNgQxBsaNVFEvuv U X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr10962935plh.302.1543731551999; Sat, 01 Dec 2018 22:19:11 -0800 (PST) X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr10962920plh.302.1543731551334; Sat, 01 Dec 2018 22:19:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731551; cv=none; d=google.com; s=arc-20160816; b=gNczCFa4b+089ghk6CK9lsKF9Z0x9ZGDlMBNFAnqISduchtgW70cO4GjP7wBOaPavr +lpVHmtz0cfWReWdW7ZnaObRlSCQJgiugvFXemkvjskTgm6vDWZ48YRDAVzGtKSF/OLD 7ye6Uo0h0uaXWowfOSx3lW0MEdyjktg5WqNKFzyADbHZVp17PfSWut1tdohvfv7qGDBF tRpRp1ECs3KQ1U+x5SHvWmnoHg5msTECMtxWCyufie/aSP9qVbls6733f78GcLeHo8zJ UhoU/TO7fMFoVmYGbsByLwATkZqMg8ZrcERwdsA9v1oAq7qVAI06YhHPUTPWdyWgMhfG IDfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=d2WWpd+aVEdu5mT9QS/ZFMves8ADQQkgFO7PUyP1NLIl0dnT0+4g2DslnD/VALzutF mqtFpT2cQAyhJJoC1IR8moyyBU172xp0mxbLkBLyxSFz83ju7PH7zD4GL/3OmvBoJMWQ 7Wa+Z7rd33lKpHS0vgyiE9UZZ/RXqswupW9PUKjc1smI1FvYmaf9hvorIVvCGzyUd/1O 5n6mmjzG2MIBbUE5ZgtS6skgJYI4waX2OAQ94ZqgwnbdZxOwM17ZUCIpRuwzCwge+Xhl SREhclZPlrbaJFRGrW/mT/ByTSVhTp/3AXfz8PtA9UgqdKzdY0Y9jxvBcb4voyQ+E0wr FaOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uy2BvgZZ; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z11sor13367326pln.25.2018.12.01.22.19.11 for (Google Transport Security); Sat, 01 Dec 2018 22:19:11 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uy2BvgZZ; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=Uy2BvgZZkqOXNK7hWBYo3ARMJUfASECRH1vDxiNUgHBWwBso/Dw5MVQ3h240LKOn9r NhpjK25eGn1477k5XxEo8EOyY+Y9o+E/DUJKbzrcAxAiamgY14sFBQ5e4pPJJZIPgx0x NzFau/vgdlUWyYjWlRMcagejTL6DGAwAmAsSxpCb68yXr9XBuwp/SaCrwZvvzqcGm0L3 4PgcxWbXzJwKYve3R9DhlAzPDVVBxKO/xslBA5HeS47vJGvTrlgakEwa4L493x3uvLwo PdxNdGZOUlyPHJ+JMUkdbANMZcGvWiGUFFuBO0DsdK/adiQyQW7EAu9QSeBXHtYH1PiP vFeg== X-Google-Smtp-Source: AFSGD/WRNjFD6zB7/hjn8Xn+aoz1dyOHhd/PEH2NIgt7PDmUyJF+fZfXXjivwgpQAMMMOqZJ+B9xkw== X-Received: by 2002:a17:902:e085:: with SMTP id cb5mr11348736plb.24.1543731551018; Sat, 01 Dec 2018 22:19:11 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id n73sm14870007pfj.148.2018.12.01.22.19.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:19:10 -0800 (PST) Date: Sun, 2 Dec 2018 11:52:55 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181202062255.GA3159@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Tested-by: Heiko Stuebner Acked-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..2cb83bb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,10 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - unsigned int i, count = obj->size >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); - unsigned long uaddr = vma->vm_start; - unsigned long offset = vma->vm_pgoff; - unsigned long end = user_count + offset; - int ret; - - if (user_count == 0) - return -ENXIO; - if (end > count) - return -ENXIO; - for (i = offset; i < end; i++) { - ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); - if (ret) - return ret; - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, rk_obj->pages, + user_count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj, From patchwork Sun Dec 2 06:24:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4319D13AD for ; Sun, 2 Dec 2018 06:20:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E5E52B4F2 for ; Sun, 2 Dec 2018 06:20:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DB382B4FA; Sun, 2 Dec 2018 06:20:28 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FEB62B4F2 for ; Sun, 2 Dec 2018 06:20:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFEB26B61FC; Sun, 2 Dec 2018 01:20:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AADAF6B61FD; Sun, 2 Dec 2018 01:20:26 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99DF56B61FE; Sun, 2 Dec 2018 01:20:26 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 55B616B61FC for ; Sun, 2 Dec 2018 01:20:26 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 82so2510525pfs.20 for ; Sat, 01 Dec 2018 22:20:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=bmfYh8HFmIidGZySmut+R0ejZGXCmmwElvvndsGmTxfvoIRthLVWGpz+Hk4RHnQhbz KIKYVmB3QTvS+byZ1Uhyj4I42Yw9/F3r4/mBYKrzFTAJubhaUt1Iert7/3JiFpI4eHzU v1R073ZwWIXOe4AwhhqzX3Xey3K2WddSSJ2qVy9fZ2+8KmfcjxAcL6wbB8SwLSoajtH/ pcCTGgkRY3Gkwd3D/HcWeDANlBLnt72Lqd9eZ8GZ0jWQcyZn8ZijYyVhoPg2crDXlP/a w9fKE2W4hhYt6lE7R1KpXXx6+aCnsDoInSze9Jbbf6MQ9499Wa8Z1qfh6pP7ZnSg6xtO Tp7Q== X-Gm-Message-State: AA+aEWYeMesbZXoKqpOMrdteI4orxCyRYgxbvrktbGfczyo0j9ltHj/k Gto1P7THttpUD+3/XpHgJ7SJAXiOk4cpPbvMQuj6T53lBNmgkAwh12GHlf5NxqfNASah3TjXHUN IJbHOiesDQj9rV8pWKJHlQTr9QfGCquUpjea3BcnoTTP/T7GyXsgDdgvIHI8Ryv2x273MykdmjH ebHldBhZelRMFRjr91yKT4EreoBEYhdVjtLsKK9mAKSLIf9Y37qXLVtz79pCz48kdJGevSMPiu3 s9OLRvBhBwbgiGzVjvs9tN7U3b7O/7eyQQ3j1PmvK3n8G2NRbQ5WqR7FJc3NnIktkmvGfAczNDW GKkVi9G/0yOS9hFdyHti9A43Ydqb2kbO1F2g+8j3OuoGFkD9OIhLAiLEjAN5wtIBdLRmebTI4ZT 1 X-Received: by 2002:a62:2702:: with SMTP id n2mr11756229pfn.29.1543731625962; Sat, 01 Dec 2018 22:20:25 -0800 (PST) X-Received: by 2002:a62:2702:: with SMTP id n2mr11756205pfn.29.1543731624932; Sat, 01 Dec 2018 22:20:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731624; cv=none; d=google.com; s=arc-20160816; b=c/z9mqgRt6tJMXOv+iCMZhBCPRfavvZ1pVH26VfUUJM3dtxuxADCMy52LnmH0jL9H1 ptFfpRN3if9PmZokkAJPpBgUM1Z2CqybGs1VmTbdiM6YPPmq37hc+NDrpJreqbFeUxTj XtW561aaK9O2JNoDykrqaop3sjrQezSWNW/jpKD2qNauiXmDsh2ZrI/MNcXJ03CukUHI qkggUGVZ8BDzd9km1W7yh1aSPsjtX7T0sOvFZVnJ914IXpiCVRLUZSRdy8A+IbuS2vIK LZ/WgfFpbmXoFb7jb0mLaW+i/adN86FdtN1sMecnfHE9fJb2DYhsl8FhhdP6hCX78aF3 wUlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=h/EkdZkYSCqOHcAWpJwu02PJNZIj5Yg0Be81IFDov4yrYtnsiZSwldaW2UtaZwCRMy o4GpzvYnVg7zLWLYbDapScX0racReu1wZ7VDoNfOi/lLkumCDjApRuE8QlTQ3kQ/xrzW BO3Ezkld7lFtTATpNKtwPMl0nc2FzGbpqFJkb48LyvYk2U6toqqIf5EJYAccSqE2UsmN FlhYWx8uwezRkJcEEK6t/1HJvIAJEe9GcRClxx/boMiV6hrpvI1zw50UT/VreHtBQTdO V0AB070d6HJwZaZoq+xQvwG+KfZpA4S2/oQFpvQHA+kNbudMcxojKO7NGUU3WcTwUQSi 1VfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p5hPFJ3i; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q15sor13551863plr.34.2018.12.01.22.20.24 for (Google Transport Security); Sat, 01 Dec 2018 22:20:24 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p5hPFJ3i; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=p5hPFJ3iSMtwwIFg6uQF6/1FmqoFOIF7Z7cv0qKHYdoPTS1Dget3BqY7fzgcPpg+ne FLj3CU5H9J/pEfpGYVp/1OdBYEwxCU/2uqb+U3AsdayDjssFGsuV06VCAYzDEkwn9WhA hZTFsU+FKQ8rZPQP6e3h0YATS8ToxJkercqFvK8LYdI3nmE1fdElhw3UuPJ3SPbmE7Mo cBUiP44KfYpWIve7yAyu+ztKUBjJIndFcvRtrpBuWP7l1iCGTGGA4lt3NB5l7Fe7kWh2 U5m3UyT0Clxp1LaoZO5I3Kz4PCL/3x5D32MDn+iAFStg4AlR7uIOpaa0NinYWmgWbCk6 8UGQ== X-Google-Smtp-Source: AFSGD/VY5/fEWSrHIAji3y6gn1HY31kQbbulywZEulPpaUoQZqHYw4pOSjtRtYYrVApigSKFsr3e/g== X-Received: by 2002:a17:902:7603:: with SMTP id k3mr11634668pll.285.1543731624627; Sat, 01 Dec 2018 22:20:24 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id 128sm16732440pfu.129.2018.12.01.22.20.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:20:23 -0800 (PST) Date: Sun, 2 Dec 2018 11:54:08 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, oleksandr_andrushchenko@epam.com, airlied@linux.ie Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xen.org Subject: [PATCH v2 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181202062408.GA3178@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Reviewed-by: Oleksandr Andrushchenko --- drivers/gpu/drm/xen/xen_drm_front_gem.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 47ff019..c21e5d1 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -225,8 +225,7 @@ struct drm_gem_object * static int gem_mmap_obj(struct xen_gem_object *xen_obj, struct vm_area_struct *vma) { - unsigned long addr = vma->vm_start; - int i; + int ret; /* * clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the @@ -247,18 +246,11 @@ static int gem_mmap_obj(struct xen_gem_object *xen_obj, * FIXME: as we insert all the pages now then no .fault handler must * be called, so don't provide one */ - for (i = 0; i < xen_obj->num_pages; i++) { - int ret; - - ret = vm_insert_page(vma, addr, xen_obj->pages[i]); - if (ret < 0) { - DRM_ERROR("Failed to insert pages into vma: %d\n", ret); - return ret; - } - - addr += PAGE_SIZE; - } - return 0; + ret = vm_insert_range(vma, vma->vm_start, xen_obj->pages, + xen_obj->num_pages); + if (ret < 0) + DRM_ERROR("Failed to insert pages into vma: %d\n", ret); + return ret; } int xen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma) From patchwork Sun Dec 2 06:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65CF41579 for ; Sun, 2 Dec 2018 06:22:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEB82AE91 for ; Sun, 2 Dec 2018 06:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B99C2B4FA; Sun, 2 Dec 2018 06:22:12 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8471B2AE91 for ; Sun, 2 Dec 2018 06:22:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B25AE6B61FE; Sun, 2 Dec 2018 01:22:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD3146B61FF; Sun, 2 Dec 2018 01:22:10 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99B926B6200; Sun, 2 Dec 2018 01:22:10 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 594F86B61FE for ; Sun, 2 Dec 2018 01:22:10 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id d23so7468107plj.22 for ; Sat, 01 Dec 2018 22:22:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=QNpvV4dh1IbRI2o2JXLxQlnUyXLVPlEyUySO6vgmdhTmSSbeCgdpUzO6+IJG49Zpkb inoUlZFEJb79Yhw6wilfOoCfttAxf4OsAxFa3BUU5Pgy/M7ydEleqf3EIb4kyseL3Po0 zaWJYDubpJy/7ls8rClvM8ED7jOe7Xe0uuRFzt1g+JEV6RCgZcpJ6wFNr1AiaoIdZLph jNCXwmGILYYtZtCmPWCQObr6GLUkqCbN5rAJdL9pPYol4802tkWlqOhvME1mx7oDAjyw +nHCsoKKO2g7uoDkJkCn0kBmdXhq6BNFqydfbZrKM65fkT5jWiVkWa4Xxa+zgxBLq/nW p0pg== X-Gm-Message-State: AA+aEWbW0Si/J4weouPz0enBTpznbfMuTiNZk4yiyJKu1GHbfEi2lopE rXQsiVLt71M131aDAhdSIwjPZUAt8m/bYKG6AMVctfnIeGpSbZIvq4gBLmxr7QaQS3ujZyOzBEP aGr13kw41Y9O9/HljhndJxnpmnMHFf/7R+dfyfQMt2MO1aD26DsorVwtK1gimcaRwsGhQxVGuyd 8M5INPOh8nEDUB3o9so72qod+Z3cVz2L6jpGFeprsNfF8h8Tp9B8923LGIH90wadDsKkkQdE4oE mkAK7I7mzOhdxB+lHqb68wqUqpWP8jhMAHkh8jG0Nz/FR3Y+tv2Tj9z+7grKHoiKlWPXfS8Iikk gKemcAQ83sMnemdh31bF9Q6ut9zrLR78VerZy0/t9tCutZxRycZ77+FFaHG+64RRBZ1L/MmLSo5 5 X-Received: by 2002:a17:902:b118:: with SMTP id q24mr11649598plr.209.1543731730032; Sat, 01 Dec 2018 22:22:10 -0800 (PST) X-Received: by 2002:a17:902:b118:: with SMTP id q24mr11649588plr.209.1543731729400; Sat, 01 Dec 2018 22:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731729; cv=none; d=google.com; s=arc-20160816; b=XPYkyoTzU8joLjkmWVwjf3d3C804pgJMt8iRW+nvkDZ8igqqfc+YB376tWhy+WYTxK IP1FkPF18K6dNmavm8AHxIVpluW4YntBToPifwNhSdZfXp3lcg3WfpaqOBJNQAJ8HbdW x4GankHIDQlKOYL3z9qIq9Xbobttl/0B4vt6jpZkCA+EsHYcwMS/dI1R6+xD1sCTTedp uv1+GB2Te+FCTd7ll2m7QRlTiGOeEVzsAYVMjL/Xpz4KJrM9pI4dsQgmSnM98IdySshf Btcxhq1LdeRS38OhNDjLyrFFIIySdc2ZOpXkYf6nbWOY3kuN6t1GwbX0I/BIo/aOBlLS 2XxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=w0+QV+pe3P2tG4D0zgVLmuqRawDdlMnSmzB6g/0KJI+tREnB9Rih7Z4Wj7/JayD+jS 29VGBlxUsKQlxDp3q1ihvnKqp6T0/tm5g+2JdJffaRcb+Ao1YrM50ZTcxoRMqn1icc5T rFJ9QZ02KqDlxeRB8t533ZFMTVJBmjrZBFrcgiTSgnRgonTb+ohOEBbdPItAn816zmOU 9Qb1QQNCbn/+F8t1Xxqmpf11w4kDgNNeK2bW8ofqTqmquOv6+tiWhhZMKGYDzv4Bowwu SKMUXt1ExiGde2NMPGf4jyyCYatQLEkpRycAfGVbqVv5innxao305a0dWGHbaQ+LxLFz v46g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E66PxSJO; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f15sor13098130pgh.59.2018.12.01.22.22.09 for (Google Transport Security); Sat, 01 Dec 2018 22:22:09 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E66PxSJO; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=E66PxSJOATRlRyxk80lKrd/PPERGyhxxszoqxynYdKqGN1haLtgsOzfQHtEPslbiXw zHl6PkrOjijeS+cspvZr3/fA8QDseQINb50rdwUAuvynH0g6GT4769OS/CfE70NJPBaG nBA+3dbYlNmgu2fEtkS1MVZoHusgbAM5dFPoy5sB/YutBrMjHmJcJefDPs1l5UFK7dS9 jBjnbTK13hVAtILMaN0Pwp045AxBkzPu91quj8BNW9kETTmtvOAplbxqaTZM6hzwBATp dsB91BjVz8U5yyOYWalhuzheuQNNkg2AbUO7ufjZj78Mo3bk32QN+p1Ysv8QnAW2gSBR NpVw== X-Google-Smtp-Source: AFSGD/V4MrGOvLQK8YAEdmVrkPOOILIeEIqHAzxQJv0N2ksWP4eVZ+yeiaMJNltR2QCz0j3pP/BOVQ== X-Received: by 2002:a63:61c8:: with SMTP id v191mr9746466pgb.242.1543731728624; Sat, 01 Dec 2018 22:22:08 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id a9sm9909585pgq.20.2018.12.01.22.22.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:22:07 -0800 (PST) Date: Sun, 2 Dec 2018 11:55:53 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org, robin.murphy@arm.com Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181202062552.GA3203@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/iommu/dma-iommu.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b0475..a2c65e2 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -622,17 +622,10 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, int iommu_dma_mmap(struct page **pages, size_t size, struct vm_area_struct *vma) { - unsigned long uaddr = vma->vm_start; - unsigned int i, count = PAGE_ALIGN(size) >> PAGE_SHIFT; - int ret = -ENXIO; + unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; - for (i = vma->vm_pgoff; i < count && uaddr < vma->vm_end; i++) { - ret = vm_insert_page(vma, uaddr, pages[i]); - if (ret) - break; - uaddr += PAGE_SIZE; - } - return ret; + return vm_insert_range(vma, vma->vm_start, + pages + vma->vm_pgoff, count); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, From patchwork Sun Dec 2 06:26:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 582E713AD for ; Sun, 2 Dec 2018 06:23:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480982AE91 for ; Sun, 2 Dec 2018 06:23:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF232B4FA; Sun, 2 Dec 2018 06:23:12 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADF852B4F9 for ; Sun, 2 Dec 2018 06:23:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD5646B6200; Sun, 2 Dec 2018 01:23:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A83836B6201; Sun, 2 Dec 2018 01:23:09 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99ADA6B6202; Sun, 2 Dec 2018 01:23:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 578246B6200 for ; Sun, 2 Dec 2018 01:23:09 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id f69so8344946pff.5 for ; Sat, 01 Dec 2018 22:23:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=lqCezG0BHCBZ6xOsfX6h53FlagMpfJR0PQM/KC5oLA/lSP9aa9Au9PR/p5OvYhmfEC rRd5LZcuHsMoxYgJEvs4D6AKcn6VnBUsQ2ybmpRkdFCvJgchERytUVQyEhnaEK8YBir1 NlRwRR9yFoCfK5EPiDVY9Pp416TSai1vrz3IKad2h7hdQAOmDe1tHF2sG3eZOSykLxAH vrac4PjiiG+UfNzu8sVrKW2Xc3hwSDnk+UJag0eE5cbzqxdhkJ4KA+rqrF4CmLXJbvJ1 PhukC+xwR7e9/JWhil2Dpb8kOlHbp9eSE41N9NdXonJTK76cXN47CY9dzByeuU7AGkXB 5D7w== X-Gm-Message-State: AA+aEWZdYk7bI6Y02oe8iy7vm/fsAEd9klWTjD4BVrS2pP1AZqls2KRm znn8QhimPPLwdjKLyb3sdggeUEmHsL3H5zBMvU4QeluPhSqoA4ZuzENqKMOEeBbbH3tL70OcnVV xQvQX7oEtJz0//57PJcQAuj0II5HXTiOjFwqTuDwq0IWzFsQvE0P5+Yy75Hu67t/h0i8Tl9dUbM LsHVRhbWzOi1sjh1NqGVDqiCv5ChaBhWHwfos3rNr+NtsLA/nMv4IdE1sSmzgefriWlukb3p0NE JX4n7kigs/m84UHaIwkBwaez/WPvLCutxgI4xWctBOl7iXmAJc3NTJAyVBqDF2rpY2y583If5Lo E8slXFtJprkBfupG0yIpVtvIomiAutrPmW8o/DSnujtmZwKJmSbMeYjBIa7vSFUL5qmLY80EA4P 9 X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr11361567plp.36.1543731789042; Sat, 01 Dec 2018 22:23:09 -0800 (PST) X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr11361552plp.36.1543731788436; Sat, 01 Dec 2018 22:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731788; cv=none; d=google.com; s=arc-20160816; b=E5+mBspeWZhqEAq7B3az+HtDwqeArDo4ZhQ+ZVXGYXnlDRyAu9OVKp457ThQHUqAt2 vTh7KntUXTPzGk6G2I11OD+1Ngn4/OpABrTSUcGhRCXXMDtYgf7MB2wrWd1n2RULIDYK iRBOEAYFCKnEI9ms1do0EEyuSdTFstDVBLjkkpOdvyOJiU+yjq3lfUdfSGdSXutO48J4 sC7PkUYES8aFJlcORZCHrYQ+obeVIIEWcOh0+vm9VQnAvA8DEggG4j/O2EQ/Dlk6rzx+ 3paludYaUQFaPEQUqQCoe7Aiz5dEMXMW2F7pPJVv0d0cSO9zacB4OuiyqqDK9BaR7U9P eBRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=hpfqJGxdsJfCvOEkiflv+6pfaftIpLnF4bQpLfRl+WQUqBZYOnZS7E9Ua4WGTm0VZD 6NLkFV9vghsdefarMVWGshGrbXFEYhov9m1j5B+Xt18Xkd5vJuVaBHINVaGbASgOjNl6 0kRLnn2GC07Epdu2lQr0A7BMFuXCv9UvywSOtpnvWpykXDjeATi66b8EFp35RxGUo9EA kecE76GPdZttmzYi8DQeGsrrFE9VtMLytA+RtALkmhyNvInus5DPmaIxGKql1OJjeRcg RHgS59eQoQcEwIkTHwLymqC4NwoWQzpcGY0FWDnUIKECC/EKd5wf5mB/DQUHeicPqfEz 4+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hPiK5Zwo; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c128sor14089835pfg.37.2018.12.01.22.23.08 for (Google Transport Security); Sat, 01 Dec 2018 22:23:08 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hPiK5Zwo; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=hPiK5ZwoLAoXcrDlPOaaw510DQZbubdxWxzvpQbUMc9IouraIxDN/hT4ozgrDVtvcy fDm7cVPxj+FgIrWQL0TM58NxHbX+Y6FneUIc8DmkmH4y5jOCv/z1ConA6wJZ8D5P8xY5 kpAWzRwXvWRCFIvMMY0RaGewZcbCCvcvHkY/QWYZmRJ6ump9I4s9surJR/mZClKxlW8Q A9bDo9qufPb5j7rpKRBlv9x6G2qY8EVtHjqlYbuJPCtzJT/ixeGVVTClxqIS60vRFeLK v9+DhMQYGj6xoCTmD7prS7Lwsnuh3GX0gmpoNVskL+LyDjAfpH4pb5jr3biQuJyAQ4Z+ kxow== X-Google-Smtp-Source: AFSGD/UVytr1ebhaz8huA/7jJoF2k67t/aK5DcMLAnNhxvR8OqiWPdb4h2JlZP3fcvU+4L9b6rRnvg== X-Received: by 2002:a62:d0c1:: with SMTP id p184mr11350123pfg.245.1543731787667; Sat, 01 Dec 2018 22:23:07 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id n68sm15355295pfb.62.2018.12.01.22.23.06 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:23:06 -0800 (PST) Date: Sun, 2 Dec 2018 11:56:52 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181202062651.GA3225@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Acked-by: Marek Szyprowski --- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index 015e737..898adef 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -328,28 +328,19 @@ static unsigned int vb2_dma_sg_num_users(void *buf_priv) static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) { struct vb2_dma_sg_buf *buf = buf_priv; - unsigned long uaddr = vma->vm_start; - unsigned long usize = vma->vm_end - vma->vm_start; - int i = 0; + unsigned long page_count = vma_pages(vma); + int err; if (!buf) { printk(KERN_ERR "No memory to map\n"); return -EINVAL; } - do { - int ret; - - ret = vm_insert_page(vma, uaddr, buf->pages[i++]); - if (ret) { - printk(KERN_ERR "Remapping memory, error: %d\n", ret); - return ret; - } - - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - + err = vm_insert_range(vma, vma->vm_start, buf->pages, page_count); + if (err) { + printk(KERN_ERR "Remapping memory, error: %d\n", err); + return err; + } /* * Use common vm_area operations to track buffer refcount.