From patchwork Fri Jan 11 15:10:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10758213 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 CFE7E91E for ; Fri, 11 Jan 2019 15:06:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B85C329C71 for ; Fri, 11 Jan 2019 15:06:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABC3229F93; Fri, 11 Jan 2019 15:06: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 4CB7E29C71 for ; Fri, 11 Jan 2019 15:06:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 493A38E0006; Fri, 11 Jan 2019 10:06:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 440D38E0001; Fri, 11 Jan 2019 10:06:39 -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 358778E0006; Fri, 11 Jan 2019 10:06:39 -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 E7AED8E0001 for ; Fri, 11 Jan 2019 10:06:38 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id 75so10507440pfq.8 for ; Fri, 11 Jan 2019 07:06: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=jJyfr251abKPUjfrLnfnZBYdiVZ7BdP/pFKC0YWuEDs=; b=QrxlR2R3u4suqD8w6fBwOj8ZYC2GRh55QkZi0Omf98ziJ5NxNgPGi8WNI3vs4rvoHG rACQOgP0YxOohlHb4Iw+2Ut8fGY3T+rkWN12wKAK53TpxIylbRizpCDfVt5Eolip8jBa p9rupcsFxx356rqnaJhOO7G65tRHVp4lkkCv1CwWWucQbBuK/cet7Eo9QoIsfPux09gJ zC+apeA4QVKLi8csmF8r4Eamzvk7FreX1+nxWMOTtlQS43pQacTodAy0MtOQqc7MMdRx FxJpdQZbnH/U5Fac+ZSSPnBjk+HpeV2fg3utjlJB/WlPK7Fp4B8Di1QajDz3tui/S5Yh ozdA== X-Gm-Message-State: AJcUukePwLK9q6ErTo0q0rGSick1sISniDr0e4AbHSlea7V8bx0ld5La RCTz2a/T+36RWssUdKlR5ZrPr/sW/TKd9X3Z8q1u5crNFcjuzYFZHWLDBKKN5dW6pj/UGXz1K7B MTzz3Uly6UHk/ALyMMCewO4kdBzggq+j+r+QUWvHreNIdYvuDJ8r+Tc7uzSCE4XoBUtGL3XZj4F fYkn2JisQ5YS0s9upOGsADxBZM7MEOJTt+aT43Hde4ARkJDidI2nl9Hw5KdrU+XKJUFPE3hvAUb PDu/JiA/XK6gYhYxuvQdPx4Tb2sxkV9fRaddbA+xg17fH3FKP9kLlN6+wmVbZ7uD6k3qwI7V3ft tQiVfkLM5vZfvuj5/GpDaZB+4spmOBYCe0tUjClTiO3IBQK9jwI8Eto9bBe9nJu5gr9FI8tm7hx i X-Received: by 2002:a63:5c22:: with SMTP id q34mr3560409pgb.417.1547219198598; Fri, 11 Jan 2019 07:06:38 -0800 (PST) X-Received: by 2002:a63:5c22:: with SMTP id q34mr3560356pgb.417.1547219197909; Fri, 11 Jan 2019 07:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547219197; cv=none; d=google.com; s=arc-20160816; b=Pu2l1FSVuc3h87Ng6aZP47m3cOjH1Lw4EV2R/g84rGb4KylewEV+N/6R6XKIHUz7hx PhZwuy5gZh5t+IfFgFuBo1vGaKKGFFjBkdB2/yADjxrPlGldwoOUTyScw0HPn1Hucpww bSXFrGtrXK50a5wCNgL/+KSl2Va+MNqByVeyQjgbVHqnzT5A8OQX3spFLKQh5MThTqkh rsI0oZXPN7jJFrqZGWTldr8wc4FQ+nF5bAQ4GSsljH1z9hBcOxx4Q8lX4kAQBPGAmfTk sGWHIlfWNz5+Tjs9gPN2UWQA+jfPHrXhdtQcA4mOcW/w7e5HeR7ze7GyuSZLUod4WDzI Udfg== 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=jJyfr251abKPUjfrLnfnZBYdiVZ7BdP/pFKC0YWuEDs=; b=ykLxaAPix6b4T0Zw5epqpR0Y1IM1LOJw4dGJ1/MZNufB/MxLDVl+8Fb3Xln7ZZaeV9 9FiqmuqpjJA6BYZQFYJz+F4Xj5a38NfmJVu8Rlj7pqvrZXbzHF3cbXZwzc/E5Qfb2UPV juhL5CPuVXFbQ/1PyZYZQnifE4RmeDT4Br3X/e1W3/lVKRxllwqkQ+odmXshgY38MNvK J3pgk+SNqkd65tTBkyHF8Z2ffuGbxtaz2T2e+eZ5ZB5nLXrsstE+wapHOljLpi2DcDAW YE2bf40e1PJ0tKx3aQ+Gq+TsyPQMRnZjySLQt+ColjovOVE65uEqYu4A4Nxf+OqXo1xQ zOwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jn8yGcSe; 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 i11sor3787964pfj.7.2019.01.11.07.06.37 for (Google Transport Security); Fri, 11 Jan 2019 07:06: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=Jn8yGcSe; 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=jJyfr251abKPUjfrLnfnZBYdiVZ7BdP/pFKC0YWuEDs=; b=Jn8yGcSec9ppfdCMuebFOrYumbJez4VJp9ziQIzdHm4MyE7zHGBNv9jGGByDvcgQpn a4Mb1kNvbp+zXJnQq1QgIOOI7k4m7EBEOI8R9NBuJ+gOUIP+fz5rqpguuFagKdcElYjD +1EqR/6zuGgPokgzBSRbAqHNI2HGCTOaMZ7jveItEs2ypgi/m2luTW5lGJazXMnGy64q MXCUeX8B4/c4+WJv1umzbb5ZhKe3bWYqfF0fK3MwigxOq0vl1h7hkKTts1HzhjTGM/nY qASR6ayanD3G4foV2vBVIcJhbX1WEF9mjWene/Rj0RM1C+DPFca6892JPfFLhNGY97Kh 7gXQ== X-Google-Smtp-Source: ALg8bN76xSFly+CWNyQpefhrTarhDoTZdH79A8t9NSuLjWP1kW/Wkt1ixSodqPFgFeaytLToyuoA9A== X-Received: by 2002:aa7:83c6:: with SMTP id j6mr14876943pfn.91.1547219197536; Fri, 11 Jan 2019 07:06:37 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.52.190]) by smtp.gmail.com with ESMTPSA id 6sm165163391pfv.30.2019.01.11.07.06.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Jan 2019 07:06:36 -0800 (PST) Date: Fri, 11 Jan 2019 20:40:37 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, oleksandr_andrushchenko@epam.com, airlied@linux.ie, linux@armlinux.org.uk, robin.murphy@arm.com 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: <20190111151037.GA2781@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: Oleksandr Andrushchenko --- drivers/gpu/drm/xen/xen_drm_front_gem.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 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..9990c2f 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; - } + ret = vm_insert_range(vma, xen_obj->pages, xen_obj->num_pages); + if (ret < 0) + DRM_ERROR("Failed to insert pages into vma: %d\n", ret); - addr += PAGE_SIZE; - } - return 0; + return ret; } int xen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma)