From patchwork Tue Mar 19 02:26:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10858733 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 6E1391708 for ; Tue, 19 Mar 2019 02:22:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BB2C29452 for ; Tue, 19 Mar 2019 02:22:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FC672946D; Tue, 19 Mar 2019 02:22:11 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6FC7294B8 for ; Tue, 19 Mar 2019 02:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O61jEXtxrFACT2UV6AMuQzY81fJcfgL1qE8VONmjN/o=; b=aUiXK/5GQ2/5yV eXJ1MCPn517LWSuO8JgZhm8M6llse680gB+pr+HUSXISKKSvMGNlysgzBGMHh67NA8/GiabAK3X1+ g9/xL0v8p0c7hVXkpu26IdCBDQObWQwiV5zVKy9RNgpTtcvQAHQI9eO5PYR6142In7K8bQDx7KqJv eRFVM4MDiTm0RAMj3VkX6CVafrjUk0sFfuC8PAONQEZCf6/BFXySvBFFptsNhW1uytk+wyxf7K5lW Oo4PSB0WQX6iEtD2YwPO3Z5jJK8gSPbnHcL+HFNRp6kYG3uydlo7+kbUvbJk8UgzWQKHjHf2iouBt aU4LmrCbGV1jOhVj/+2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h64OH-0005EP-B4; Tue, 19 Mar 2019 02:22:09 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h64OE-0005DQ-5w; Tue, 19 Mar 2019 02:22:07 +0000 Received: by mail-pg1-x541.google.com with SMTP id h34so12714706pgh.11; Mon, 18 Mar 2019 19:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+cqpEOgVsQX6FuKbkjkqnPdK6JJEhfhSEvMIkCtIVgk=; b=BwZwO/mgWw5cmeGQm07gg2bfziVPZ2aU3Vz8l9vhecEXfsRq1wSNLw5Tv+yoAr4k6e QfcEA2+DQTTXbDaHXA8Quutyc5CY8LDUaHkqOISw8iBUR/dvs0yFXwhZyT8R4RnRvaik KPtZ2hALQAlGX1QFF5QVZVR6tkmcCp+oX0SlhSzKvqSvm3PLsXqywOOy5EHyo8Pyx2vS odp83dilftZ3mXWQaGhoshFSyINw4LYI6tGaRywK7Dd11M80UdE4NViEOWK7UPfUzza2 0y7QmRBNIAy3JVAQlWVVE/67nyWjwXO4GQ2vYciubrJBZZGh3pq7KI3y4a4NmMPx/ufi NXLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+cqpEOgVsQX6FuKbkjkqnPdK6JJEhfhSEvMIkCtIVgk=; b=tq9Z/nAIcVuXkyHdOrwsehYNuHkXxA87IEyFR4Qy/zPs8OhjLUozKZ1c3jjielnlC+ Z+8eh2stHUY4cuy56Ezrl/VXRiA7nf8V3+nkY11EkeabwIlHAqdsAUbb3gFiZvtbq+DZ DSUcgXmo1kpvyM2Y/mL4R6EGX2oCV6nNEzJpyGy01Wzji6OjpgNskNSQvXn3SQ1HtpLI dj6VCeAXAizWNT/v+rjGwVmrQdkYEL6OjYXGT9v8Lyafy+Jl9F1EMRjSjECvr+d2af1V MtC3qCPj9qW1rJeJX9rZmTG8eoJjQ5LomnW8nyUYn4QD9Gawix6X89CaDCVIaOeQkOyQ iHnw== X-Gm-Message-State: APjAAAU5BbS9y5V9ejrMvcHCAP6bcPn0DRbA9JxfQ71Y8YTjk+9jYbuY Vmn3Qw8JROwJmuoiMXb9eZHy2+3q X-Google-Smtp-Source: APXvYqyDvI4zt3fFzBxE7EA/O8ssnYTAAyn+bRG1R0qqvVNexLq29fF+EGU3IMdTuIzc3YDUOwMWrw== X-Received: by 2002:a63:6e8d:: with SMTP id j135mr20527765pgc.160.1552962124157; Mon, 18 Mar 2019 19:22:04 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([106.51.22.39]) by smtp.gmail.com with ESMTPSA id i79sm24658598pfj.28.2019.03.18.19.22.02 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Mar 2019 19:22:03 -0700 (PDT) Date: Tue, 19 Mar 2019 07:56:38 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, linux@armlinux.org.uk, robin.murphy@arm.com Subject: [RESEND PATCH v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_map_pages() Message-ID: <7ba359eb1aceac388d05983c1f29b915bdf291f9.1552921225.git.jrdr.linux@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_192206_225112_C14E317C X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_map_pages() to map range of kernel memory to user vma. Tested on Rockchip hardware and display is working, including talking to Lima via prime. Signed-off-by: Souptick Joarder Tested-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..a2ebb08 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,13 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - unsigned int i, count = obj->size >> PAGE_SHIFT; + unsigned int count = obj->size >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); - unsigned long uaddr = vma->vm_start; - unsigned long offset = vma->vm_pgoff; - unsigned long end = user_count + offset; - int ret; if (user_count == 0) return -ENXIO; - if (end > count) - return -ENXIO; - for (i = offset; i < end; i++) { - ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); - if (ret) - return ret; - uaddr += PAGE_SIZE; - } - - return 0; + return vm_map_pages(vma, rk_obj->pages, count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,