From patchwork Mon Dec 17 20:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734269 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 C1965924 for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B27A02989C for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A52672A24F; Mon, 17 Dec 2018 20:20:26 +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 38B872989C for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AC548E0051; Mon, 17 Dec 2018 15:20:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 334ED8E0033; Mon, 17 Dec 2018 15:20:25 -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 1D5D28E0051; Mon, 17 Dec 2018 15:20:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id CBCB88E0033 for ; Mon, 17 Dec 2018 15:20:24 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id p15so12857334pfk.7 for ; Mon, 17 Dec 2018 12:20:24 -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=hI+wecKM2hMDv4EVr+P+m6qAcyYMoOOs5RsEAXbLlqUhpVohece5L8YYXKUOrKgGbB 30AV7fQtiQAgH/Pmf2SeFconm/GZMEmRHDAWPiDoGLkB2+YVjN9wg8ltjQCNyIj/DVJo OPjdgOWvZN9qVQO2k8uBK85PqJkUG3NFv5e1YtmaXnodlz1Tzw67qwPxuIoaEOoZrlmI zZ3KRb0mmYdVHBqMpe0WFEXM1AadimPB5oFMMV07c0k2Rs+Uo0NAm2gPEmi55vcweMgi yxtgQQ/AXfdswtE9ImQbGGgLq6AQCM4wlc9Fj+k6ad9chwe5BDs9wFL3tgSoi9DVa4EH J4uQ== X-Gm-Message-State: AA+aEWY/omG/T/9GWsNEn16PqfWurlh7HVTcUkhO6q0xT0WKa3lz8Ahj /wykHma4d7gqn6Re2r2rViy2hb6IueuYQ6KmZ0BQXSVeiNo2+BZjJjBR2riNVrxYErIzT+76FEk 2jviduv1EcvMJlLjZXaDlWimvBRMjvY5h1dUKgH34KudRFIR2vlK8I959v/1ZjyR+0EO4KTKtXe izFn4h2bTg0dCfMiLLwLcfypPdtA52SfH4aVUIWc7c794JaSItg4p6EIfN9Upw1blduGxH665ep ZcooCQissZRLMPcMj56S6SOxhWGIUPtAYibwI+Xj1ZZUFKb0VweIxAALa9gDAYnD6IpM3a9YoTY wp3blZ/Z3tQKrIsiMO+kQPE9HS9eXCUSHvAL6TEPq81eEgltSLyZBvf0drmjkehP1v7BmUPCoqu w X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr14017559plb.297.1545078024469; Mon, 17 Dec 2018 12:20:24 -0800 (PST) X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr14017521plb.297.1545078023651; Mon, 17 Dec 2018 12:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078023; cv=none; d=google.com; s=arc-20160816; b=cty73IGkFTfN/pl6OoO2gnu3PwWkn9MlT9TEXA3U+swtl1eDQ1kVzE9XoMqmkRnipO UHN56LXrI+mqxZ3mgXRs3zkO+AubObEHrRk2//A/+FYRlhBK5FGRrXrMsaun//xglMJo XM5db4lN42zbmFzP3M472nFr9I50jKxBc7cp26rWXosrxbqquwHcpRwuOvZeykW1SbFX 0qawqXJYS8I3Qh7Xqn74Vlx09U2bwnf5vqjpr47VnEunfhfNF6AJnoCQj2yj2yvhw3FH gWv0Xw1OGPXZo0JXPWJpL3ruA5z4WMuG+svzjD8i0B+Tte3pMy86Mr+KU+sMWjvHMeT3 e5fg== 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=kLsak9UsbXUBf4EPYNMawJhnIX/uQG4INf8znhscN2Zc6AKLqQiGMafBbQosHJhYGx CFyMtR+FBj7X+RDOh6clNds0jbp9/2a3YVjf1wKy/UkyQMcK0a5/7fiMvTKBdBAdQEn3 B/nLvRxmFmttnIEiJ/wJ0jB0ihW0prrbrAiHxbu/H4xIQTHYovgeDicbvE5g7KPa0VqV /ANNk/RX9cQ0XQAJn7hb5WgHxoaL0S8M0nwU3evk/zvrW838AMlFx8N/VaF5G6DGcrwg QSlNU0x+eTnYUbqUsKtXXPeEpT5GD9032rJptRHe6YfNR7LoTT0yDUDxj4m430Hhe/CP 6MRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fws+fhY7; 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 1sor20810548pls.72.2018.12.17.12.20.23 for (Google Transport Security); Mon, 17 Dec 2018 12:20:23 -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=Fws+fhY7; 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=Fws+fhY7OGBeBQzZIt7AfmMfEWU0cNhX2vqMdb1yNiRZXNX1tRQHb4vYuxPcpPKNJ1 Hb+0nVDcrQsOZM5YJYZg8lWXylPHNMhFUab14v+d1rI1iTEXaGbE72ZNINF4xAYqtmK3 u2xSL5jg5k0XWrMMwKSdNHYiXIl056gtmnrnU1K5z6xmkCg6maIGr61iUzFsdp7m6p5b AhXfHeEceYCaMXLYAJn7+/rBRGa4IegyZWt9JvH1ABBLNl4zbVOYWPDUsGAgsSpwRlQY uB6uGb/aH0cnaw3DCa8lUxnntiluqFAER78NHS2Fl50o3leVq1m7/6gqtSGA2sxohSyS L2xw== X-Google-Smtp-Source: AFSGD/XGXG9KVSKHfEOg6j87CYwUtc/H11tveEpFu3OIi9T52naHMGkf12FyOB+zZiJiH4z/gZspFg== X-Received: by 2002:a17:902:9305:: with SMTP id bc5mr13746784plb.86.1545078023341; Mon, 17 Dec 2018 12:20:23 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id 202sm25834765pfy.87.2018.12.17.12.20.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:20:22 -0800 (PST) Date: Tue, 18 Dec 2018 01:54:14 +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 v4 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181217202414.GA13431@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)