From patchwork Thu Nov 15 15:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684643 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 5109614DB for ; Thu, 15 Nov 2018 15:41:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA012CAD3 for ; Thu, 15 Nov 2018 15:41:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A4832CB4B; Thu, 15 Nov 2018 15:41:58 +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 BAA5A2CAD3 for ; Thu, 15 Nov 2018 15:41:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF64B6B03B5; Thu, 15 Nov 2018 10:41:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AA5116B03BD; Thu, 15 Nov 2018 10:41:56 -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 994E96B03C1; Thu, 15 Nov 2018 10:41:56 -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 526696B03B5 for ; Thu, 15 Nov 2018 10:41:56 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id g76-v6so16220892pfe.13 for ; Thu, 15 Nov 2018 07:41:56 -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=Cg6brz7mYbLRhNFEJEtQAETpRuMNOqibtuUBxg6orP4=; b=GpZlC0TpYgnuDAhjsf5lIYbea4eyauq5UkBRn1LqkdLjwulj1z+Tk+U1ILDYqzIPAe m1wGJqHZZDfjNrVwiuPb2ckldB0mpArzI8Ywl4kAh1H15cBNtMeAaxjM17DPN3d/Bz0i caMsnTXSwQNZTUsNqELJo6QVrQESzEW7vTCB19Liim5EWw/fjJIuyqYa2qdK62iwMEa4 Vx1JBp+GHYa2m/Jt6vB6ZcBlFzsiWOJgjrlRo/ct7EH7cMx0YoJZmEz6Dpr8BNBdzMkj bwkMWI1wyy4/lUDNwkiIVMAFiYLVM+g2c252eoyyyUmDavqW4OKFPBuZgQlN2Abhg0Dy lgxg== X-Gm-Message-State: AGRZ1gLTuyz5iZohmQwfR9gcTHF2Lh67HvAIgPV8KekWUrwYOw/UzMC2 N5VgtZ0+f8eCmsDtw0Fjyrmrwu0VqOsSI8a62uYmjLlMASwlXdjZ+iniTtQA861AckaFg2VQvV6 ixls40LYbx/VQbvGhpIWUYldW/9cGqfQ5ikNO15KBenLFpuBKuE+q9vJN8aBcwGRc/n7pX9laM/ oWI3CRcc/dFSaIL93g/eJZYPETT5Rn3TaG47+u/tsKXmtbxPhhgEPwkoDzfotRZmXNOpXkjTX+D LzxdLhZIyGuBuMg95TiWoRm1fWTRNL1AHgoT+kBQC243dBzLZOJxzQjcK/6GeNMfO90++0ZFiV+ 2Ajh/hq6LfcDMbKwdOQhQ1OEfJaZWViqOLhLshMliZZjQI/cE1N0TCUv5GI+3YqmQi9qEZRb1/2 w X-Received: by 2002:a62:1709:: with SMTP id 9mr6837560pfx.249.1542296515964; Thu, 15 Nov 2018 07:41:55 -0800 (PST) X-Received: by 2002:a62:1709:: with SMTP id 9mr6837514pfx.249.1542296515110; Thu, 15 Nov 2018 07:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296515; cv=none; d=google.com; s=arc-20160816; b=y1kDmKkHih3qiInfZZmYk67G3Sfxaly9LGgQTaPPY8MMFrnuWZ4TJdV9t8Sp3MkRRG Rm2X9kbO731qQct3GxbAPBJG9KLUL6FAEH3O6l2YaUOYs7DK9o4P6ZClwnldHr8btdZW BKP1x06v11iIhqRj4nRJCpqRdYG67ekV9g2hHwgoSUTfr+mMI3G2b5XD0P6tRoQSIu6r 4DWFWvFVnRNTx0d6QQKH7hxJ0KxCnt52c3SjrFShqu/fYzKd3cPpUY4qRwECDzW464uT xKxgYhrTZ9RIJFPis502PFh20Tgp1daDH5CEsgoBmr7mAuDn+CyiCwIJe+s1Jh+f/EG8 m/PA== 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=Cg6brz7mYbLRhNFEJEtQAETpRuMNOqibtuUBxg6orP4=; b=MJxrDtBmQzVrWDTX2DU+Fk2xj3sav2fOSMZFYWEPzf8q0r5KeONyEEBuY4M3OUtnYh fMfllPs4zQHL4Hwet1DkUX0fDTgfmJiSdh7CkB1rrRTQZTBj2E1puSVHqNFxHpiTOJwt BzsihNXoMArywRhhVu3wG8ZdiMycN9CayI7utgrSH8NU6Rs85kCEFWXcfTRoJzy+0BLq PSoIVJqWqWtnKgd7ShJ0fKASoAfuIho69JcKN/FTdOQaBJ9Spjw04Gn5IO6yyhkl1jBI ++dxEDcq80ZIpC2Ks/IsXuUgDq5ekQ9k7IDxOM0SXeT0CPD0eYWbZMTdyX0kHIxLk5EB r/MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Eh6N6bxm; 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 d10sor17745415pgo.78.2018.11.15.07.41.54 for (Google Transport Security); Thu, 15 Nov 2018 07:41:55 -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=Eh6N6bxm; 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=Cg6brz7mYbLRhNFEJEtQAETpRuMNOqibtuUBxg6orP4=; b=Eh6N6bxmBaJCmbCwKW3nWNFuf4BU086XyvkfRs4vTvK36lWMY6cUN0FJX1PSYvywPA imnNfFW8NM5MhtB/HlVZZcHG+VZLG6fwdGA8wfvH3nTVvJ65/UEg8XF5sPJgwcMQ+Hcp 24J7dBDK4YuAeDF1ME0tMs/isqPAtODXkGF+EuEklxGHrwSqW6x5O9XLDxpRfHpmSSvk Sm1Rl+EzeIHqJmV2GbHPGqlz3EsJ6NJzstXHM7D/kaiWLp1iZCgeJ7SAzbxnhLcdmVAD NANa4oTHJ5p9uJkn4VOq7tq40IfMMMlfkFxDrYrG6YazkS00ehOYAi289jFYFozTT7r6 m7Pg== X-Google-Smtp-Source: AJdET5c/4IUsmJbAFLjrppekHCGzB7YBq4feZP6VdbGvFFyn78AfrEs+pTt1JsSRVIRjujxms+LN6A== X-Received: by 2002:a63:5153:: with SMTP id r19mr6195032pgl.281.1542296514745; Thu, 15 Nov 2018 07:41:54 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id u127-v6sm28519773pfb.47.2018.11.15.07.41.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:41:53 -0800 (PST) Date: Thu, 15 Nov 2018 21:15:30 +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 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181115154530.GA27872@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. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Tested-by: Heiko Stuebner --- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 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..da904ed 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,34 @@ 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: no. 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. + */ +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; +} + +/** * 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 Thu Nov 15 15:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684653 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 D4E621747 for ; Thu, 15 Nov 2018 15:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C51872CB6E for ; Thu, 15 Nov 2018 15:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9BD62CBA5; Thu, 15 Nov 2018 15:44:19 +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 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 96B962BE0E for ; Thu, 15 Nov 2018 15:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 886466B0493; Thu, 15 Nov 2018 10:44:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 833196B0494; Thu, 15 Nov 2018 10:44:04 -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 74A8A6B0495; Thu, 15 Nov 2018 10:44:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 3598E6B0493 for ; Thu, 15 Nov 2018 10:44:04 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id 202so12602197pgb.6 for ; Thu, 15 Nov 2018 07:44:04 -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=EsMpERkzsuP5WcX62hAhLKKuUH22O9iFhxSWW6xbP+Z5b8zFaPoYm44ERsV02WLu7j CotXZl9qfAFD7IzxrY2xxXE2JLscgMNBTmsi8nt1+f0GRSoeQ0CvvGNBXDwYTg2a11DR izrgvGLlH2oQZh5XsdlhmRD+pFVW1h37Ij2XneNvfehpluViEZeiqZtTwLniqtqaKn7L CmEHsxHIIwoubzpAy7qRDKPDFu4aMtc90hFBS+H+uIEceMNQIaMQvL+6wfBRTUd6TK4p 4KXElZNZ0KckhaZfSZX/Tbx8eTmHB6aq7g452Duv0muKzu+a6dW+1gnAilWl3D6e9shU w9kg== X-Gm-Message-State: AGRZ1gJE6wBF8Z8RVeBOrpwATdD/6U7bAnswBtpk9gSG319tjAEpVp/S e7+7OLVDmNXwTymC8b0OcQz2PKzHoVMEJmt6dhGC/Kw41N2gq2CGEenGrmcKA/KtQaWlugdpjfA 8R4VB9Odotsqsp5cwE5eUzjco9vJ2tG1BQ195AdQqCZ46rAF7U/jXU76kz6N014L24nTP2IkqZo jJPopIAyNqQOwOtcKMU1v/+0efVe3LSw0sQiKlbrtZv226l28FmvJJ+F2694VOWYOnXVdm4BTG5 D6vvFOCgQj1vcOpBuaHmc/8XVr/TmTSlkLWHVQkCNStpwKuB0/Kyr2S4StxkcC+WBHaykkRO8tJ BWuCtCuhPC94ATWgrrjSDXShIsbWTILtPqZUqHWGkdx3eJOq3PUNFx4KOAMvnnXCbZzTKEEOdwn S X-Received: by 2002:a62:2c16:: with SMTP id s22-v6mr6901308pfs.6.1542296643874; Thu, 15 Nov 2018 07:44:03 -0800 (PST) X-Received: by 2002:a62:2c16:: with SMTP id s22-v6mr6901249pfs.6.1542296642739; Thu, 15 Nov 2018 07:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296642; cv=none; d=google.com; s=arc-20160816; b=jciZh+x5tovxJvqAGwTVLX6W6VQ6NwhqrPWcM36WM/h2JjOhINvrcm1Tmm0vCMpC3W jDIGVk2CMYkiFFWViXS7xo4PniuTKrWD6FjLyr6fgui8cTdrrOr3MKLi+nrFrFi8hePe YMn+aWT5uQTkAY3nBYhVidpxs6JKqRJ1WYdYUBqz9SdN3Z1zawdHj/pWgMcN/54Q4JPK uiSeGjXtjJajWmUpw/T8q1YYp4nAnxxg2h+II7wZ9j5LLFTmLRSkVpo9RY4OTev7SmGE 8m/GrU2WJFDN7XKx35P31AJElZIatWAdJc88BBaBe6b65N4FRfWwxRi/PRORr8w8RB6Z ovDQ== 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=TajGMrzflObsz17WL5f0FfRfHUULYMpPB9YIZGPOksjTJX9APLd0ojwmw3NXlxh/KI NKf951gfXbjh9kcpCMknyTZGZuA28IwBHdGDSgpAMs5UM3SpN80/O4luZwZN+b0mQ/FB D+ua+ji3IIvpfcHEmgc4kloYL+e/gzF2N5bBs4084lhSXf+pB8TyBBuDTKiztkgtHQFp Agm7k1jzoAbLglRhtfABAYp/2EUvGIXBOIztFfkqgDoTLBT09bhCl8rT2Zt2W44HSY6p 0AWzUIwzYJTvC/5SOIUSgL6GztT8OZq4qyoze40YnlrD7nuhh6JhmvXNDWvfxRPwjubn 7Ohg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=epRwUqy7; 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 cb11-v6sor32699958plb.57.2018.11.15.07.44.02 for (Google Transport Security); Thu, 15 Nov 2018 07:44:02 -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=epRwUqy7; 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=epRwUqy7htlLmwiI24Igzw3C2oNh3YVt5/KrBuU7kZgm/q5KyELQgGneXGQT7KYl56 a3RPp7G+9jGSYocoRz61BXFqCxjj5kjQ3gfSEKVVQLgHz/flWOteAimfOtCvbbgEYkG8 CcSujgQPd2yZZI23W0wET8wDeoaj8n3Nf2JZsVNdKJhDeJv6vb3FP/jiMdHqHt2CJln6 mAZJudFpETbCbNZLF7yseNL0Tskx0lPoRljbm4WuBW6I61un7FVqA0Tgcq3pBkkrXTrA xkOW8ZMIMv2ZW/Lf/Exdd1gaUYmfX8+qHWP7IGSrnJsyltqvS2md833QBVWTLl2eXkdi kXDQ== X-Google-Smtp-Source: AJdET5e2nV1ILwV25QmCQEcQZKLe372AfAKrda1ioGmmzBYIfWQwY2V+kpm1Wxo55YOkrsox1AToPQ== X-Received: by 2002:a17:902:560f:: with SMTP id h15-v6mr6963057pli.160.1542296642414; Thu, 15 Nov 2018 07:44:02 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id x23-v6sm27487376pfm.126.2018.11.15.07.44.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:44:01 -0800 (PST) Date: Thu, 15 Nov 2018 21:17:38 +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 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181115154738.GA27932@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 Thu Nov 15 15:48:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684657 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 6CF4C14DB for ; Thu, 15 Nov 2018 15:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 561802CADD for ; Thu, 15 Nov 2018 15:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4962B2CB61; Thu, 15 Nov 2018 15:44:54 +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 A3B022CB87 for ; Thu, 15 Nov 2018 15:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A31A16B0495; Thu, 15 Nov 2018 10:44:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9DF786B0496; Thu, 15 Nov 2018 10:44:52 -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 8F6466B0497; Thu, 15 Nov 2018 10:44:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 4D9B96B0495 for ; Thu, 15 Nov 2018 10:44:52 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id h10so10772444pgv.20 for ; Thu, 15 Nov 2018 07:44:52 -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=aM1C42m8xdOqFETa7vpI1nSS13dxTXWD/5chbQoQBa8=; b=Nc3N8zGG3y+M3bcQioyEV+7VnfYBEg1uoAl8g6W9MzatwLwxH/ZHHEbU6NmKyWw3Vj oJqrZqXpmsWWes2IwZikyD72PESK5taEJSMI12ztBZady9eHjThkiI4h1cOoJpbH1nja Y2z0Sw2956ly568My7RCP4GuKm7v6GuwcWE8VgOQU65JNYpvwse0jmFXPw0EDYBFuWbn N6WTv+G55ff96Pf2LVjrUgpAXKvtQHCFz+cwe7MEEo5kbb8nll4yfVD0RXYzYgq/tGg5 1D3mGcJxxGAVLUNHeCgl5q8A0owe9UpScfhskxyR3aqrS9S8FaHiNSZDB0+NGP/c19eU lahg== X-Gm-Message-State: AGRZ1gJS2vTy/WjQA3i80GrP6krQxnp7XGmUE4TmeMtY2wp5gyGYQrFl aTdWV+R5v/E95ZXFtdkL/ta/19v+BSvOvikuojuVLHeL9AvBFIrXA7X9ZBSH9y+7JamyvFqSQYn XHaR32htUxI/QYzROR9VbOjtME46EbxawhB9NFS0jXIWAxxq6zbFTqAY1s/ek0MUOjyNJvUXSTs LQ1+e16TYJoxLHjhWeipBCA9B4iAM4N3FqakZSD273YKle01wgknOuvdfUc084gafAWR770aOc8 R1QNyYNjBamU0HcxYkK55s3z7SacZQ8w6ZufyJ1dHMdKtussiVq5p81ufh16WTXbmDoQNG+xkCc uMFhvsY56FdbuzGWhLUXOXyVe+KVK27ug/A+C2s+3Pub/abXfAVmKVEDdk+YbRspoWj/5Wb0u5n t X-Received: by 2002:a62:3647:: with SMTP id d68-v6mr7001426pfa.66.1542296691982; Thu, 15 Nov 2018 07:44:51 -0800 (PST) X-Received: by 2002:a62:3647:: with SMTP id d68-v6mr7001390pfa.66.1542296691261; Thu, 15 Nov 2018 07:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296691; cv=none; d=google.com; s=arc-20160816; b=JMpPrDBz48QY8QvcdLaAybfHCY/N/47DT2w8gvx0R8dy2vMHcEPLjJ/P2AH0Y0wKc+ fPAXSbNpn17I4kofCUTjC980EFhk2WDbxNG0uNiZittuzzRsAip9dE8tKxmnCraKwjsx PygtQXkNobkEvvsnf2LO5sqNete5j9LO0cFqk6twk/fCZsVclYU4UWFb8LsyZ66knQAo ADd/StSvn/wLAIuWs2AO1JB7AUJnnLU+W/BGFo7IHkuKCJLaUcDzuY52ZTLIDLLwfPqb pp6BgPvofo6VjfCFJs03wbIipalQJ3J3KRZwmaZntMQVcoEQvY+VnbahuY08x7OucvBx +qCg== 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=aM1C42m8xdOqFETa7vpI1nSS13dxTXWD/5chbQoQBa8=; b=l98qky1iAXAe5f0LkgNq1XkjVjSIDA9ofZA3M/inDo/srz5gJNBZumDiQ8X3t3xxCd GQh40rylvCfryNrnusBsku5G/SWw91dwbY2WsQuX4vluPdRid2ACCg26YXT5RpLeDqEf SMqQ7tYHy1ZNkJq0J16nCJMDBKeIS4GDGvNGj+HcWocADR5s3YSl/OBRHEXrgm82PL7/ 8e2hZ5q3LYL/rI5YHd0vgfMm/gMCchIDd4vFrUvqO53vmTbvQpkJlFWrLhqcMvkZDMVK EeNYb/QYM+/A7t0KCHyrrR6HxEl8Nm7zclDzTrfeIwR6/ACTFf/xsSd/S27ivZa9VKJj WEuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WPUlk2x5; 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 k3-v6sor33497753pfb.7.2018.11.15.07.44.51 for (Google Transport Security); Thu, 15 Nov 2018 07:44:51 -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=WPUlk2x5; 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=aM1C42m8xdOqFETa7vpI1nSS13dxTXWD/5chbQoQBa8=; b=WPUlk2x5CRHbvpM1bKX0kitApnk9BOX9wd6CvD1uXCrRKIH6tLEay2hxykg+jfsOB5 J3wKWSBsuJ6udvfS4G6bvMcO6ox+2kzBEBlokR74eBZjoMw6d8x1PN71smAmcbb6mBup OdgkIHjtmqbhHbuOLy/q3SSyLzA2k+Xpsv24H8M3CFunfT0Vso70i7cPyZZzP0niaf+O JGIryGQnwC1aAak8kAS+Qx8SqdiY8zDRVlIBvvktT+IuNNm53fGMh6V+fHDKJ1kl3EAv aNkn5Ps0QTpVVhzhG4tLFaxNej9aYPChR96QL/bg7V+spivBI26bw5QPRPmo5pwul8kV BkFg== X-Google-Smtp-Source: AJdET5e7n4pF+rhd6dDpXXTPWo1Rru/vt9norA53b2YS+zYvPSJKdhFnnXdL8xxj4jhF0QHgnmIpvw== X-Received: by 2002:a62:6241:: with SMTP id w62-v6mr6901975pfb.69.1542296690923; Thu, 15 Nov 2018 07:44:50 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id z127-v6sm32794856pfz.135.2018.11.15.07.44.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:44:49 -0800 (PST) Date: Thu, 15 Nov 2018 21:18:26 +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 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181115154826.GA27948@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 Thu Nov 15 15:49:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684663 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 2E207109C for ; Thu, 15 Nov 2018 15:45:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6962CB84 for ; Thu, 15 Nov 2018 15:45:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11F362CB6E; Thu, 15 Nov 2018 15:45:40 +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 A253C2CB84 for ; Thu, 15 Nov 2018 15:45:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB6D16B0498; Thu, 15 Nov 2018 10:45:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B8D1B6B0499; Thu, 15 Nov 2018 10:45:38 -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 AA38B6B049A; Thu, 15 Nov 2018 10:45:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 66E576B0498 for ; Thu, 15 Nov 2018 10:45:38 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id d3so7893136pgv.23 for ; Thu, 15 Nov 2018 07:45:38 -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=AIX2iBgnpBtMYOZdpGjm4pel7//JuaOij1dpz1xfGwk=; b=SNBzPZnoYb5AIvR/7MI9jQPopZP/MrVKp2oFx+uOG41er1q01ZX4EsVQj0RO5Zr8v9 k423GaML2o53iph5wrGGxh5CFahAKG9JmPhnDchjAo31Ly2DQ42hjMGe4Foqr+Z85ujw zhsQ/dMy7LSKJYU8OOg2KngxRZk0504xOZa2QN2/tIRYTyiUDZLlVQeAuLg0P5dyQ5p0 2zCe4T5fZ1k0tdhhqVwdXvly8wQKj2h1MiSgpVg/ponI83MiBikmZ9wu+JjMIROniVpU ghs/+0+mNjt3oHFrz2mG6m88bdy7e05ATWRsvUdQiSB0if3uU0hXgdsyJzuVdMn9mQbz CNRw== X-Gm-Message-State: AGRZ1gL33lsgYxiSffrLY53VDtrcvpnUscjw6c+YEADxGnbQ/a5qZYuE FKrvNqdVYrMoLJcFZkgxiKf9nPSRCNbmal9StdHNMU/+71lo6SadjtUbeaJJo3U8XiuRl5fIYQI MXmirZ9PoSdopSCxkGVkvL4tykSK0iikQuWAf3YJ9TfpEtsR9TJZcmz3Ex45EJoF+Gnaac3GZIb Z+cmIbIZJF1wGjK+Qp9mcynHC9e9uyyEvShrtricYaWX1RRB2pNhbpSSxPYX4O0QjcL7ZYysqpZ VEyRzL9Py6Whlp1D3LiOaf0Dm1ZnwMmxFWMhVanGovXt87u4nzhMwlRWrXEExLKwj7Z708ccLka GoDE7qF9Ff1ruwPul15aGoFZjx23ewNKbQ/I+2PIfr6gaxiUlnpHoInmcSbwkV5VBkhQhAGJHNg O X-Received: by 2002:a62:4587:: with SMTP id n7mr6900370pfi.118.1542296738040; Thu, 15 Nov 2018 07:45:38 -0800 (PST) X-Received: by 2002:a62:4587:: with SMTP id n7mr6900311pfi.118.1542296737226; Thu, 15 Nov 2018 07:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296737; cv=none; d=google.com; s=arc-20160816; b=swskWlrbij4xoPRvz1NJUQJ8kFbXePW7zaVGMVJl+BRW6NLsv1tKCfE5M+hKJAMjO1 Lyvg0ExVrLs65sqOhyRs5UQlQpWrMWYwBOLNnT0ct9HmllxR1EB/ZODpMwKe/jI1omoB vfzlo6Objv+vp8JCXW+j2nsKBQhBwF3KIUsOATOf23LLOwlumby0SEH2noDQ3Gffc/yh NylBixqPZnaz2ThdclbL1V/AoLyVWZb9wCjVp5Hzh2NFEJ506iSVyVROSIeS/nHtUxeN 9Go77ztlKzyhcLVcK11mkHxz4F2XiAcVa1rdujVj+MmAVNuCRsVCjJyu/lpkCKY3t58N Ib4Q== 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=AIX2iBgnpBtMYOZdpGjm4pel7//JuaOij1dpz1xfGwk=; b=vle0SZoC+VH7Wu5kUDxv+a4SO72jbPiFxx2GUsr2VyyXuNXkDlqXmTo2lKArb5a1fF WfvI+S7JvxCR1lJQPpbYcrnEVKUn8nVdav/19wypdcJ98jqB55rFLElo9PqiEHNzpQJv gU+tuiE2jHSsQVVzvxGb1VRNagvMXgGfTEwxhBeqvJ9HM4b5R571LA7jjG90FZVaRKic 2C8PK8/b+9GxDJiSBtuEDXGWhDKtLPaNb20jVQCbpH5tmQ1qdJq8dCjvDOf7tb6iLe7f GpcmsfVz92VZx6ZYSpXDksVZJTPRl3eArYhhI9cNhpPPWK3Ak5OUikGRkpeKhXvkPSCM dKUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iaSnmTGx; 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 f21sor29162044pgm.40.2018.11.15.07.45.37 for (Google Transport Security); Thu, 15 Nov 2018 07:45:37 -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=iaSnmTGx; 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=AIX2iBgnpBtMYOZdpGjm4pel7//JuaOij1dpz1xfGwk=; b=iaSnmTGxauxWoYCvtec0ALIvyDVANHjr0E0iWMOy4jVAkdzU0MtkTmDfa6SpFo8gTx jcVLoP7zG/gd8POY1+AqTH9V7De1H5Rs1TwYUfSBwTnjo7q54144wWJrm4ucHjXWyI4X u+cxZtRfnMBT51mS2ReqTU0bKsePqOAMCssP1vnITv8YsZkW68607kbxO3Lo5iD0R3P9 DN0QuSwxEYqsDlhwAXMIu2Uank6RpS0pkXbAGiUikxQ7LqdmtANZ1DIOh4IFAtGGBXVy fEGg1pQNeorVxVXtIaYLEoQF8vnJNXp6Rya7AX3pFj2I3aucj/YI4hvc/IgXsjyyLDR5 +Xbw== X-Google-Smtp-Source: AJdET5dZn74Y09JVDuVoqOuwbST/m0UXK3vcdwDSp4OFu4wopzDls58DF/KopJXuYC5ZxGgDjTn4UA== X-Received: by 2002:a63:4e41:: with SMTP id o1mr6374565pgl.282.1542296736882; Thu, 15 Nov 2018 07:45:36 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id b2sm24504163pfm.3.2018.11.15.07.45.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:45:35 -0800 (PST) Date: Thu, 15 Nov 2018 21:19:13 +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 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181115154912.GA27969@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..a3eade6 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 err; /* * 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; + err = vm_insert_range(vma, vma->vm_start, xen_obj->pages, + xen_obj->num_pages); + if (err < 0) + DRM_ERROR("Failed to insert pages into vma: %d\n", err); + return err; } int xen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma) From patchwork Thu Nov 15 15:49:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684665 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 BE3BC1747 for ; Thu, 15 Nov 2018 15:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD5932C382 for ; Thu, 15 Nov 2018 15:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0F9E2C888; Thu, 15 Nov 2018 15:46:20 +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 78C242C510 for ; Thu, 15 Nov 2018 15:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 770706B049B; Thu, 15 Nov 2018 10:46:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7476C6B049C; Thu, 15 Nov 2018 10:46:18 -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 65F576B049D; Thu, 15 Nov 2018 10:46:18 -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 25C5D6B049B for ; Thu, 15 Nov 2018 10:46:18 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id i22-v6so15345558pfj.1 for ; Thu, 15 Nov 2018 07:46:18 -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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=iwY3tjel+EGg+zOyGuXPiKIgz+JhF1SYJUy4s3AyLvyrKeRWp9N1glMkf87HE4HyCn IYoOvqNAK4OC8qeOxWTuxfTpqRHiu247a0haoSL4PLOXd2Ngg+ho+IYyXK2KAI+rRfiB 6wC4JCMNL5/5IQOO+yIW95H7o9lX25uI45WaOut6BJMZaYsZ3xI/XQrw5Lw1uA1IM+1E 8ODCv+0viUUckIEgQ6DbcECrSyDHgjlHe53qbkxKIPmglFpbbZDVx5et7xX3CBXnGtej eT+VUoeDIK8srFUpQ9/DvvpHNn054M6fQJZVvOcluL7Z5ttvJ0dlI03/kspMvxTYk+BP D5/Q== X-Gm-Message-State: AGRZ1gIP4XA/xkSFHdOn3og3RdDKIQ2288sV1PsXFc3w8+krOXtuR5ss Dj0ZpsPG5/zhb9IqN6P/FPwlX02XVtD6bULayURCxzWC99ISwTpF9WPCbRnZ2lIiBqwiMxCCM9q 4SmhbYK+1lr+hhsapIPxZJcGnXSy3b5QUPqq46Ya6ANEnBT+wQBvtGOzO6U6FyggaZL9/I3q6m9 TuMCyHTV3yqOCqwbIlkbTalh8/mwcsRsj9ivMnu1ojY3YgcyMbM0GWgwQ/ZIxDaOe/jvXna35dC VPLlnHReLJEjSU7fEbrC94MYtqXsKNGpxrSFkqqZnHmtPaPUQKagE/H7AxM7dGoA7PUxtfy5Fr5 TVQCD65fgNaw80x8V+1ff0ZPrrHIxhs2mfd36li4D4W48Oflh4syB940ql1cQoqDnVLIhTGZeXh F X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr6373925pld.276.1542296777796; Thu, 15 Nov 2018 07:46:17 -0800 (PST) X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr6373878pld.276.1542296776963; Thu, 15 Nov 2018 07:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296776; cv=none; d=google.com; s=arc-20160816; b=xzyL1zFX7+YJdiBfSmjgvnn7US2yyRucEv4xM9I+X/gOCeuvZLsyl0NBSPuZuqf7s7 j5GtQISr/B3snH6nF+Pxrr0JwkPqYNK9tmbdbh9fsOw1R+ug3bfgsk9Dq0StTueDDH7/ jCzsmM4bZh4MSzKM6yMj8viYD4TyiQhUXdjAgtn/6gj07Ouk9TuRM8Onpdq0IoZEl8or ztNXC12iCQXOAFbaXjzr9zxgJWkIBh13iDH/tjXhtvGkXNHQ4WX6I1H7TXx7t1r6i1L2 FiTP6BmI4yWVjv5fgSSXYEKtszH8j++qlubt/nohSQ0Exm5SV9NnuvNQtDHdFd0BjVlx h8qg== 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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=q6LRJYeGmbhG8fsRa5VPc+arnLONqL4IU8VZYDalk71DzXj/uFgrDT3/1HLpOOhXR8 GiQDLIMz1e+6YB8vAC02a8P2UKGEpZbvueyARa8tg2C0VKHuKt+j3DlYF2xocu76yGHi jkkDV/YfF6cT3siC4H7PGtiNVE2P8vthReoJDyuePUjCGdtXRql4n843oGEOxt0xeLdW FfrWMSnKivj50B5apvnWFhsDBIb1cuDOuOU60cqh/X9Ek8Lz4d5GFswXn/bGR2AzvVid dUFaFH4d6odGg7gHo1yewGq9wzEIXvJ2/o0K4SalNXH+Gf9fOkSw8ze2IYYEQ21/7UCR P0VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDL1jXOi; 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 i128sor27134923pgc.75.2018.11.15.07.46.16 for (Google Transport Security); Thu, 15 Nov 2018 07:46:16 -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=KDL1jXOi; 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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=KDL1jXOipi5AI9hqqrIXJb54kJnJcGHPZq2inivM6wT37owA8faKfCyFnyplVYZnJ2 WcPQLs0t0fomnazLFjvCVMXSXW45w7kASTC0eaHU48sGeSCZda4SHSCs4KipKTwwLWPe 86twXHz84aj/2VhHhjQXF5DLGpALUGDrIDAg798dFy/qS+XgbKCzqsdtUiM5jiSJB9TJ twfempieOEafBe8eLr2HyUh5+PRkuIsAp1eXaRnou8Lnt6zxuZObdya1V+OnOGPFeErR J/rmbflib7zF+roU53lBFqGQ2+A5vh0ko6q+0MkuD6c86cLmAfT2/efpTLbzC1uR2+Gt JzyQ== X-Google-Smtp-Source: AJdET5ePnd6LsBs3MvsWmND5rouZNtcp/4maXAw3ddO5kkpXTes4M9S1/JU9EhJVlMxVKMlrn5+f7g== X-Received: by 2002:a63:4a4d:: with SMTP id j13mr6356647pgl.127.1542296776069; Thu, 15 Nov 2018 07:46:16 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id p5-v6sm29750372pfb.109.2018.11.15.07.46.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:46:14 -0800 (PST) Date: Thu, 15 Nov 2018 21:19:50 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181115154950.GA27985@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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b0475..69c66b1 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -622,17 +622,9 @@ 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, count); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, From patchwork Thu Nov 15 15:50:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684667 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 055AE109C for ; Thu, 15 Nov 2018 15:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43682C330 for ; Thu, 15 Nov 2018 15:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4DCC2C955; Thu, 15 Nov 2018 15:47: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=-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 5EA6A2C330 for ; Thu, 15 Nov 2018 15:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F6926B049E; Thu, 15 Nov 2018 10:47:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A5C66B049F; Thu, 15 Nov 2018 10:47:05 -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 748A26B04A0; Thu, 15 Nov 2018 10:47:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 2C4B66B049E for ; Thu, 15 Nov 2018 10:47:05 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id g21-v6so16185344pfg.18 for ; Thu, 15 Nov 2018 07:47:05 -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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=QPDaeQlTxm99pn1COTIfcPTgdCqE5X49zyHdSt9KJRinXZ94tktquElmch2nmrfWI6 tJai9tA3NBB9wO71Qif+kPrWV5bH1+T7XOt4QPBCT3PlXDViuGlWZU2Z6ieX1Bn0lLmJ Nh751V4yTpzIAk1Ouzd4oDjx/dPNZB8QpEso3sc4XE7ONfOzWc1pTap7zrzqVDeLd1gK wUnUsuSFl6aSA6verp3OVAMuR3A0cfflZGR/2FDFRseSaDWts/VpZ+chMHul32wqvxg7 N6w05fMBlc1wIzzIaxHn2RHJzh1Iu5Rivw5HkVYJ9WtgieC6WlNgaaKX2/cbzr8i4/Ym qMBQ== X-Gm-Message-State: AGRZ1gKSH0O+ab5JdXvs9MFgRbAijKT4YBPyo80MYmME3e70b5h9RZPr SKJY5amZmxPGFojYc0AWxQ9Dp34UzGYvoZ1NxEWP6OK8iw7Z/XXKEOsUO28WYWFvWN+07vFOKX3 b0EiP5vrLKTsTmIWviXnKY33113hpttnwWOD1FAdDxNZIpn7+HcjKpHv8Hpt3uYLEJn/sSQBLkQ s639eAHJPjpkeUzWPQ0STEcU9PBrIMNv1ifY6FQaH9wpqqXXDGKICFu5XQeKQE9A43jpK3KrHHG ZukKVogP10vB+a622/CVngwh/AhiZodfbL9tl22ek8qmoY0GWcaDLDi0e7vUA2hVq9WM1LhCHun nuGzIfNeE/fl/8YwUqTj3evjlG2VXOJ82oOrMHb53wYoWx3+a0Z+DimcxyFII6R2jYY2P3JmtK5 q X-Received: by 2002:a62:7d10:: with SMTP id y16-v6mr6860755pfc.245.1542296824846; Thu, 15 Nov 2018 07:47:04 -0800 (PST) X-Received: by 2002:a62:7d10:: with SMTP id y16-v6mr6860685pfc.245.1542296823790; Thu, 15 Nov 2018 07:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296823; cv=none; d=google.com; s=arc-20160816; b=gGhR1RcZPgoqmQwyHxwIYO7itrO91Lg9tN4GV/khRQ7n0YO1H1TvLtgvCWa8pt9mXu 1rsdrC1eRsbcylWo7csvzHAQprJQy0GGqPKejIBLjJBJE28c72SPYyExkYWw+sStrRUt Hddmo/W3exhbi6bhNzIsqbQxbCVN2qMhUZqouNX21FSIkulzmq3wcRPDAZ4Nh+8wFGZ5 gnvwc2Vb6RZJctFo/EawfpNwXz+hy4c3UWGYA/0r+4z1abYchoWOoFh99ffqHRZwt4tV mF8YrV8ust7cf31YWgBwCrHvg5a3HA5Wvb70VDsmq1glZvzulcUmS9LPc5Askp3hQ82N oeJA== 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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=QAjG24XAowSK9C9W2dnr+NA0SBZn5OTkpaSl69K4dDZBs0KB0BeZ1mav414OInHiHQ fTRYQb2L4Mk7o4AzIRK/+CqpA6F7uEm+hr5jhO9isdV2/LfFZ33G3Of+YqhrQT3qR9Kd +R+P92VqbOZ1mstuwAmSgyedWK92kX4KD0Lwas+nyjUYWq8pe+VDjj//H1mCzXGodwSp ySul75/EYTVn1lvcgcjkReGF09ADCLUk+jPPxRxaj6rrM5BYXdJBO6y5AN/KSKDRNwbc I3W7b+WgxXD+OFSHBjZkk7Aiw52wQ0IW83ucWov+3llfcVCCU/mBywqmO4UjBxb5DEWG LCXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EYIpEo6I; 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 i5sor16122465pgq.34.2018.11.15.07.47.03 for (Google Transport Security); Thu, 15 Nov 2018 07:47:03 -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=EYIpEo6I; 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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=EYIpEo6I3fyTu/nA00GV24mLYL1fuyuGTfdcuVne5cPVJTlBojkjhL2OR9kMr1l6cn Scq7Xxv5VO8kmlGpTZK8sToz3x2SA8R2VUHT14wnAGRw97Fvv5Vqye1EyoXfC4hFsSRv CJPVbdMq6d7Zcx34sbWJLXEiOab4y8TidiIMUeAwXtXDI+n1ulichB4QJqC/gUokWoln hH6K/9J9Doub4q0HmhCejsxJoGlHkavlcqgMGD6pG06VxU/WW/pYmLIt6ns2RxPRzngf WULQgfNQRcnx+Sazxjc7zDpqv+SjhYgzIv6Rw51NzfPr07yFExwKQWZCiZybCes1Rk/2 69GQ== X-Google-Smtp-Source: AJdET5fKxAlomurtsT3Waf4QItnpyQmbkiTazNR0OLF+vbiHaETb9N5BF1yWp28J2QIaArlvH2Jy1Q== X-Received: by 2002:a63:fe0a:: with SMTP id p10mr6206480pgh.265.1542296822885; Thu, 15 Nov 2018 07:47:02 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id j187-v6sm31083356pfc.43.2018.11.15.07.47.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:47:01 -0800 (PST) Date: Thu, 15 Nov 2018 21:20:38 +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 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181115155037.GA28004@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. From patchwork Thu Nov 15 15:51:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684673 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 C120C1747 for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AED0F2BE0E for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2A332C955; Thu, 15 Nov 2018 15:47:52 +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 4470B2BE0E for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FCD96B04A0; Thu, 15 Nov 2018 10:47:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 682B76B04A1; Thu, 15 Nov 2018 10:47:51 -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 527136B04A2; Thu, 15 Nov 2018 10:47:51 -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 0B7A96B04A0 for ; Thu, 15 Nov 2018 10:47:51 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id v11so9835116ply.4 for ; Thu, 15 Nov 2018 07:47:51 -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=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=fjYFSD4zu/I/iev9x5C9/kKuUGnarg4aM49qAsbwrKw/MWyc6dOD4MyXCrfyr4K51A HdSLCq+NoaNkGjlP7EIQ+WgTJNfMnuZL4z4u/+eDbBFvfxLBit/8ONSbUmmL7u3aFWmk 3BChusXwNVK3ZceX+PCfHqmas20IQWSvO5db2jXpm6I8VIS+bintOrCigOg/2VyeTy42 fCu5MiksjLUDd8mKoAwnpNyV+CBEyDhrisUBuvsz4AFM+D03VmV1A/ePpBEJ/Cg14vj4 /SkBskSCoENUeBDy0q8dcKzOn7CoMLvyKfM+gr5EGKXpy3b9jsmvMJHGFbpkcKNdyeR5 qr1w== X-Gm-Message-State: AGRZ1gJu08l3dMqUoFyx5cVeJu66XtYt21aVBfHk/PRa2dtBT3dk2guB HScB8jTvaCByiRaOcOt/JwpMI3A0w33Pkt2476v1ubJsNCDjl71lihPtN+IFpMhSPiY8Uynuh4U uUxwI9xBI70t1ndKm1Zpo2hsNwnBBx6JFhj4bU7/wbbUH4+w0eGCAeWbQ60qEvHe7UHWbWxjF5z GNz4FyHvmwu1OmtqtTdBxqtK+aFRAQhSJyFkmXZZpL8V5MQXeotUbEdYMnCDegeyzWt/U6sknyb MSSHXfuuH73TarFCN57bUYNT5RD7Zbtj/aKU7B9O7I/hVdXWgR0TtLTxjGS54eDseZuYrTxQbpx xgibX4GJdUFWYLhuRZ9D2u2gW4fHxZB+3/s6GeGgcRx+2CtbHyWRfSUQF1n6SCb0U7v4lQMPawk U X-Received: by 2002:a17:902:700b:: with SMTP id y11-v6mr6646898plk.323.1542296870728; Thu, 15 Nov 2018 07:47:50 -0800 (PST) X-Received: by 2002:a17:902:700b:: with SMTP id y11-v6mr6646870plk.323.1542296869850; Thu, 15 Nov 2018 07:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296869; cv=none; d=google.com; s=arc-20160816; b=PvFIqpYBFPlxxFTDsTHSuUKHKAMTaBlYe0sAMbHzMmmZ2oN0ZW1V4MbosHB9ROJzyS sTZ4o+jKjsbCFztQi4H05jYmk4KEUjw+WMJigyG7oXr3kHvtUrZU7a5Kwd3kKFeDqWeB ItaLFYWhksZVaWsjZg8iEcDpcTUu9AwKeXvdTI7jFZBYDIA4h+4VPHZkz9SOA0fGnuOi gA0NH+KX9Gmv+M+nX6p8CiKWFgRSVqe7wwV+bkXvhoIooB+SdPk3vyJGZxB2zs4kemDg nnBuPXz7I0MWUzew82skm6sRSZLyoyYji8sCsWEFXzJclDotvxWK8Cee40GvmEZqJQm6 1fcg== 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=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=pil045TWNb0eYawT1fdUcs4grEkGl6/xsdd1eDex9FAqVJI4roDH1aLWdddft2dK5s u4x3HJy02Swz0C/YPyUZRLfJ2Umi2qqq7MTPLvjqrLZ2HboEFT3G4Ixv9Rlfgd7DNN+a hf+VNs6IJRz5D9RRyUM36wSSnon3K8GhkLSiI10EBtt/PoQyc5RCD1Nw9uQjDwF1xA2X VkiVCte6cAJ4pt2GBzYulNpla5OSDauuEe+DD9JZNN9Jd6NtD0kxT7jemrYJPAX23iFz 0vea0rN79nqqMD8ljMte6Mc8WZByWCTlAOK7F092A8NgmlYnlkPw2yD2iV62R3O8p+Tf NZYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqwlFq7R; 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 m28-v6sor26021478pfg.39.2018.11.15.07.47.49 for (Google Transport Security); Thu, 15 Nov 2018 07:47:49 -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=FqwlFq7R; 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=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=FqwlFq7RXy+tYLQhDZXhKCbRPAkRmfn2V/LfWtK/qmLG+Vie8Ebzek8qsl9WCGr9QA 0whTVQ3NWdP1mlPPtsMuVS01rpgpSMe39FgSof8wwl3pR3+Mu8h9fpqLlwo4nvV7MW3i NnUIQpSEuDi5MByoCRtFAGmyh5myCCSY5tUKZwPRtnGJLuWOiwzzw4YvpnCNxbj05mQg zZ3xjcfPFTA0ksT6ELqYnwZmGIgzc5iWvPBDTmi3L5l/raDs66ykKER5uzGdLMOX3/Gk 4gjXFN4347PwqkoehvwTeJaAEpJdj2zpJgNtSWxkg8m5Rgrn73DMSuw+0iubNN0vzC6b /qKw== X-Google-Smtp-Source: AJdET5fbf5V0Ydlq8wMOhTyby2SzmuPQM7mnUTR1SsYy9WXPx2SMZDGWG7EF0a46EpXzZq0230Srng== X-Received: by 2002:a62:4886:: with SMTP id q6mr2284395pfi.182.1542296869041; Thu, 15 Nov 2018 07:47:49 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id i88-v6sm59478434pfi.66.2018.11.15.07.47.43 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:47:48 -0800 (PST) Date: Thu, 15 Nov 2018 21:21:13 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181115155113.GA28021@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/xen/gntdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index b0b02a5..430d4cb 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1084,7 +1084,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) int index = vma->vm_pgoff; int count = vma_pages(vma); struct gntdev_grant_map *map; - int i, err = -EINVAL; + int err = -EINVAL; if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) return -EINVAL; @@ -1145,12 +1145,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) goto out_put_map; if (!use_ptemod) { - for (i = 0; i < count; i++) { - err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, - map->pages[i]); - if (err) - goto out_put_map; - } + err = vm_insert_range(vma, vma->vm_start, map->pages, count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /* From patchwork Thu Nov 15 15:52:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684675 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 5680E109C for ; Thu, 15 Nov 2018 15:49:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99E0A2C55A for ; Thu, 15 Nov 2018 15:48:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87A612C55E; Thu, 15 Nov 2018 15:48:45 +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 0CF6E2C55A for ; Thu, 15 Nov 2018 15:48:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39E466B04A3; Thu, 15 Nov 2018 10:48:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 34DAE6B04A4; Thu, 15 Nov 2018 10:48:44 -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 1EFA36B04A5; Thu, 15 Nov 2018 10:48:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id C9F916B04A3 for ; Thu, 15 Nov 2018 10:48:43 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id r13so13158004pgb.7 for ; Thu, 15 Nov 2018 07:48:43 -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=oOYDPl7I11jBlyi0EH4ySGobxWcMxdpKNBu+OKkydwU=; b=VgVYbwYFa+xaHUHIBvJ7mNEA8pKYVY4L6qpYJGJ8H79Tf2r2gBBWY3EVfy2/UYCDWY GAHTpH0kcf2qjciucDQmV0Vyx5Gu1BW+Xfg+/JCv9pnLB9EBnptuZOsyXaPrsZ7I/ycx 0CeEQA5HLCNOzaxlRZxviO0fOSzisdwx1QurfkI6KZ/xcF3dKAIJoF9q168sfuuYfytS 0ztjB+x89vjTQYUvO5EkSyFgvto23U8oE0gcyupsCEuSProMJQI/+BLwcHAkZKsRCAPb FoPgJJRfPQblTs55ilFnzjdGOY5etI+925iztaI8NDi3h2+9ts2P+UWCBoDArXIOqM3o Ts0Q== X-Gm-Message-State: AGRZ1gKDnjSs6aOG5b0GNnM+SZjUZ1k0hWvf2cLoQoGxtUViGgc4jjib eq6Co1UZ1Lo/CBqcH9Ui5olueXKCUOkDs6OETCpmU2PEAquN5WojOcoeCUPzaBvR+AeXVyGaWUm 0+vPNqM4j6CvR3nx0rrbEew0YHglOsUT6RACmonZhAT8mHO+jF/Rx3xhNK+ha31rak1jh97J9RX ogoSjmC4oakcuctP/oknVbLvsaMdntpNua7BQ91pR4EOCTWt+kZAnXjQR/UbuQK5zR68cf//I/G p0zDTwUesEeV2YEy13jrJOnO2bsoloGMap4t9TsezXZIHW3sw029SPCe/BegXMYsIREEbq2aG9O 09op5KikQOK6hMpl6n7k/7D10kKLZ0coP323JehLX/Dl3nUG+PjZceQbZFJFNcuDQ3/h1MEqDUh C X-Received: by 2002:a17:902:6848:: with SMTP id f8mr6618198pln.300.1542296923496; Thu, 15 Nov 2018 07:48:43 -0800 (PST) X-Received: by 2002:a17:902:6848:: with SMTP id f8mr6618157pln.300.1542296922708; Thu, 15 Nov 2018 07:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296922; cv=none; d=google.com; s=arc-20160816; b=J4V5Igkxc/hNE7TnkAO69Q8FK3aao0Uj9DzH1W1Pxs6JjBeXDmfbnOLSC7wyNHJXUl /pDw16acNBNAiv5t5SnzUjcBgLyziHsKTFHaOEZImN+2mBJSuGz43fxv0SoY3hHDIZPR NRwD3FtqWhe42LWw//MYV+hVKn397U7DfKBSnYzZxFdAqXZwvFm7RGzIZIbqa2x6/PgS eFE7ZC+mLT0OuWQzlegr1nslyh9ey8aFKCV94uejDB/2gE46CHmyNPnNdcL7c2WxArdA bKIuIzae7UKkiGHQ3g5JCTR+q/iarDB/sZ9YmUKKTTNonE+bnNjkB4CK9YYyeoC53HsN oPPA== 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=oOYDPl7I11jBlyi0EH4ySGobxWcMxdpKNBu+OKkydwU=; b=cThQ3roTdE0vYtlzJj8tXdckCJ5oa/17pUAl4dKvAsBq2Qe1qpFi23MrhsgbsIALaq wfYKjFeDhl4v7e3w8auBZLAsTBt2tH1rs7D3GKZImgA7u92i2eSPfTqslevjINzTkhqL t2BXMOpIRZTZ3WMS/phbzEe4CsPR0QKrMayGTQaAZkcYXXL4QAFHw7d1S7dw17SDbTXO L72EDpD6LCDk28dqlYGZETxdv/0BJVD2ILn7Ut1tpzwYsHrlr449/lUR0kc4pWE/+VCP odEB8KZKkqVedo771BmE6REW350EctMFsblnRmUHBerEC5NJ478eNpKTI4UH9mTrHgvD QP6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=inoihOzV; 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 e188sor31719514pgc.19.2018.11.15.07.48.42 for (Google Transport Security); Thu, 15 Nov 2018 07:48:42 -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=inoihOzV; 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=oOYDPl7I11jBlyi0EH4ySGobxWcMxdpKNBu+OKkydwU=; b=inoihOzVvauWHLvinRNbPtuEK6bN3+FQjdHdAI6xnemcLobPU0Xt6Ugh9wMw8hy+rs SOOfP9IJWbgvb3W6nI6Vu/Ctq16+fij7Hf5bE9+b2zmCxmJgqSyAiDDy1MisrdVm1oJP HiYJF6PEIMeekVPyyUZs2rrfC/13Ml+iDvdsOlZIgYkCH/4ILc2Xy/vGY1bNwte/mJp3 A3JcWZ7VJduEIzQ/vGk77Gd8mfS3EUtNGkFSc5B6qUpWwGsTGf1W1Ptu/h9scnpbIm0/ dkkTPFv3gU6AJIK9HYZuzsg45rCpYszyCjUkQGTMFgGNAUHkMJeJ7XErWJR4PEsddndp roHQ== X-Google-Smtp-Source: AJdET5c287Ctegge8urpXjRpkwaEtQ9te3hfg5O2h3PwVJmQ1DKCM7oivVkSw2SZUVl3XEpvWdPufg== X-Received: by 2002:a63:c746:: with SMTP id v6-v6mr6404071pgg.108.1542296921906; Thu, 15 Nov 2018 07:48:41 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id w66-v6sm30499900pfb.51.2018.11.15.07.48.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:48:41 -0800 (PST) Date: Thu, 15 Nov 2018 21:22:17 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range Message-ID: <20181115155217.GA28043@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/xen/privcmd-buf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c index df1ed37..8d8255b 100644 --- a/drivers/xen/privcmd-buf.c +++ b/drivers/xen/privcmd-buf.c @@ -180,12 +180,8 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma) if (vma_priv->n_pages != count) ret = -ENOMEM; else - for (i = 0; i < vma_priv->n_pages; i++) { - ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE, - vma_priv->pages[i]); - if (ret) - break; - } + ret = vm_insert_range(vma, vma->vm_start, vma_priv->pages, + vma_priv->n_pages); if (ret) privcmd_buf_vmapriv_free(vma_priv);