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)