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)