From patchwork Thu Dec 6 18:43:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716623 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 8562B13BF for ; Thu, 6 Dec 2018 18:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A9C2F115 for ; Thu, 6 Dec 2018 18:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB852F11C; Thu, 6 Dec 2018 18:39:27 +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 ED1D32F115 for ; Thu, 6 Dec 2018 18:39:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CD506B7B63; Thu, 6 Dec 2018 13:39:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 07C366B7B64; Thu, 6 Dec 2018 13:39: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 E5EBE6B7B66; Thu, 6 Dec 2018 13:39:25 -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 9D9EB6B7B63 for ; Thu, 6 Dec 2018 13:39:25 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id 89so813871ple.19 for ; Thu, 06 Dec 2018 10:39:25 -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=kAgXkxEOg5WMHF23mQEcRg8JWgntSdSZsFPBHiqY5X4yJXcgzJQNaWJdGxoSKXLiz1 1VbstDiCwHhPixGg9QFv1I4pxITzO6np7RtaOAa9YEqepCthIxlqY1XceqvHi4Axx00J avXplAd+iSLqW2kRMKSotFSYthxP3u2QRUq4zSouMe7Yb/mqT0zKC6Zjgcs82OHfO8fE C4bM+4rTnlQSyePxJGUntxE5zT/jm5eqKScXPHxtF/tfYH8q+gIl2TTfjcxzFGXnunlR 0/KF+e55o0ldDyyYtg4h2WdD/TqDn3wRt2nZvO55I55uU6BnrlBte5PE+dbRNtWJQjYX GzIw== X-Gm-Message-State: AA+aEWYiQdw2Vn4fVEoVzzZ6GxKKXE42gI6dW6+aNuLQVBiJZUNbxY97 38/h2qmUiZP1KeDeHq83BHtmQQxFghz8lpOtse+SOV4gwiT14aIdPhrAp3qf1wWVU635BxWmn8u YW5H/1WrdjuZVC4P/5sTO7FzBYhjekf4IU1HBEeha/othiKd0qprBBOaxINK8aq/VWXxfBzYF2r bTOwdkx8sC4anOxiqI7e8e93wTGaYd+DVzlTXfLlocD5RTadzEBus1svGhtw6qv4Hw5M2Byy0m3 1uNYtxL4btZAytsacDktGSqY3vRq22royLMd6BRI5EGcWTW40NJjSG6d4ivEKYMCQfN/LaaHUeH 1Ko2Qx+i6sqWx4JHmO8UsSCxuoeCEh85pXFZWzhXyHUvKBZU07gVMYkAio8pq61A351F7hNPkwZ g X-Received: by 2002:a17:902:9897:: with SMTP id s23mr27974888plp.69.1544121565319; Thu, 06 Dec 2018 10:39:25 -0800 (PST) X-Received: by 2002:a17:902:9897:: with SMTP id s23mr27974860plp.69.1544121564487; Thu, 06 Dec 2018 10:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121564; cv=none; d=google.com; s=arc-20160816; b=ILZoR9Nd8cOQ0hYqQvfWdCySDFp11cr67uDH6Q6AnxQs5kuQaKXPmiraceod7ufsqS TAcxwNzJs73hiojPizl7eTQZarMlu6+C2iBjTvlvk5cA9i5OEsPSRYH1O6Y1SBwNbNGY oBUSatEdIj1OqYSgqIcfNq7QpZ5Nc8wHGUcPpajVRKIgkzNfVSFgPlh3N9pRIeBR83Ew By2761j6+dthG9ZcN5vZ+PWJbhXy29o5vjumpF+b7cwO6gSTPDNgVpRhvAaFvKyCIC0F rrnofs+SwQfCGkFX+aSTj41FQuLb64Dfr6lQhacLdf97+rAzu2wPbThYTch+WdXBQvA3 Rg7w== 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=iXgx3OSeke1w1kC5V9EPePMzaWa1vDqgX1m6TP3u6S+9XY2CMjA9uhgt/AHIa+ffmJ 2FRwPvywidb7cv60BA8UHc0mcPr7z1FXNUjbJucI4zgSaYldAXitWZvC7Rt0l1O/GWyR XgC9+oawat+/PZlt5K+GIZtq/fASKVSbPgOcum8eOlY+9V7X3nyoiG5VgJHSmVVvsC/+ nmFvqRlKMBErCVYtUCmVV57XZp1pEzDjcaCu3J49Bf6kc9gCX/0GTVjl4Ez3u6GfeQfY ayCEck6wKdIokcsh1uBF9kNVEcIO39Kpc9Th3zQMHTlhqODhGqrgiHALxxJTlEbp4EFJ 0UBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gt35VdLO; 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 h191sor1940358pge.48.2018.12.06.10.39.24 for (Google Transport Security); Thu, 06 Dec 2018 10:39: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=gt35VdLO; 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=gt35VdLOJLkkwu6HM2z/QMOGYwYxQY75TZOeYdRPNnTaNn34UV2lOUy11lpMiKEIfl pJUTYq87JeZixJZt6DZ2BEh2ecwXtuaUNMY4mqSOb/ww0qlIfkmmuqzotryN5D9+6oQi 9xhmmpXQscZwqEWbKQ208V/yDxrw52NwRgJ141Brcflo/mxEtx/n6YjZDnoXQO/6v7R5 NuiN1qnkxp/ZrYifd/oDMRri6z2c+QGns5ibd0289c2wHJf8F6j730XXRwGlnIw4sp8a L+bo4aqgKCsZYoPJZPAGP8JM7G+Rsh8zuj4x+O4mxtV2I8OIYHnpyGahS2dJCHTOy092 pWOg== X-Google-Smtp-Source: AFSGD/UfFSt2nT8PksMeYnwOlOFwT/wi4bvRW16Y0LYOo7p9wxEoYqUr+4/gwU/InzrrQl8sQGE8eQ== X-Received: by 2002:a63:2849:: with SMTP id o70mr23387850pgo.155.1544121564152; Thu, 06 Dec 2018 10:39:24 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id p11sm2259233pgn.60.2018.12.06.10.39.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:39:23 -0800 (PST) Date: Fri, 7 Dec 2018 00:13:11 +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 v3 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181206184311.GA29651@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)