From patchwork Mon Jul 9 15:46:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10516217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52690601D4 for ; Tue, 10 Jul 2018 06:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F00B28C13 for ; Tue, 10 Jul 2018 06:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3353D28C45; Tue, 10 Jul 2018 06:56:21 +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, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E78B528C4D for ; Tue, 10 Jul 2018 06:56:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF9916E790; Tue, 10 Jul 2018 06:55:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FD786E46B for ; Mon, 9 Jul 2018 15:46:56 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id 69-v6so21142007wmf.3 for ; Mon, 09 Jul 2018 08:46:56 -0700 (PDT) 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=YJLuqL0PUESWKvLbUx7Uu5IMY+SqW8nKXgsaU4mHb/8=; b=UEYY7wpaPb5vfL9k8sqDfHeBVBDzGaAovqZAhcYcDbHCS1nDy0M7cbm7BGSJQc0/24 CvKc/PMZLOcelMB6W72L7yYKbCIpAdNsSuCdhqYQEpzSN/gWrVSQqoFT6himPVUDAa36 t6fcgfES11Jx+fuq0xLL1omN00pFvyYvMNdoYonVeMAqbPRzY+5Ry4II/9B0/HcC/Ulz RkV17j6JhwWkQlrJf6kwSbJ9hOcAVS5Qmvg6RqgdA89s8XT/8WjWOd4UTistLHR15LEl lntfd2wbzFD0XA+IyzjCQUccRJ2m3RvBy0s2ob4UqKuKxSpRwvY8WWOIi+hdnUHJJZj5 Slyg== X-Gm-Message-State: APt69E1menbOzTf5i5jz268YaKh5EU4MaHK6uFwSvo59v5Vcu7FcZlTC 7rjOjHJoBRd7r12bQx35mhDI++Fr X-Google-Smtp-Source: AAOMgpelesv4JQUkEi0lPw7mlyoN3r6ewGwBjZXWLEJXn4rplfejOs7sbYWoqfSKAcZC9axBgi/dqQ== X-Received: by 2002:a1c:2807:: with SMTP id o7-v6mr11757387wmo.11.1531151214681; Mon, 09 Jul 2018 08:46:54 -0700 (PDT) Received: from haneen-vb ([78.191.177.254]) by smtp.gmail.com with ESMTPSA id 125-v6sm31100820wmw.9.2018.07.09.08.46.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 08:46:54 -0700 (PDT) Date: Mon, 9 Jul 2018 18:46:49 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/vkms: map/unmap buffers in [prepare/cleanup]_fb hooks Message-ID: <3c62d375dc439268e9ea77fb8f3d599ee927a2a6.1531149873.git.hamohammed.sa@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Tue, 10 Jul 2018 06:55:25 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hamohammed.sa@gmail.com, rodrigosiqueiramelo@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch map/unmap GEM backing memory to kernel address space in prepare/cleanup_fb respectively and cache the virtual address for later use. Signed-off-by: Haneen Mohammed --- drivers/gpu/drm/vkms/vkms_plane.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index f7f63143f6d0..f464eb0e05dd 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -9,6 +9,7 @@ #include "vkms_drv.h" #include #include +#include static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, @@ -30,9 +31,49 @@ static void vkms_primary_plane_update(struct drm_plane *plane, { } +static int vkms_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct drm_gem_object *gem_obj; + struct vkms_gem_object *vkms_obj; + + if (!state->fb) + return 0; + + gem_obj = drm_gem_fb_get_obj(state->fb, 0); + vkms_obj = container_of(gem_obj, struct vkms_gem_object, gem); + vkms_obj->vaddr = vkms_gem_vmap(gem_obj); + + if (!vkms_obj->vaddr) + DRM_INFO("vmap failed\n"); + + return drm_gem_fb_prepare_fb(plane, state); +} + +static void vkms_cleanup_fb(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ + struct drm_gem_object *gem_obj; + struct vkms_gem_object *vkms_obj; + + if (!old_state->fb) + return; + + gem_obj = drm_gem_fb_get_obj(old_state->fb, 0); + vkms_obj = container_of(gem_obj, struct vkms_gem_object, gem); + + if (vkms_obj && vkms_obj->pages) { + vunmap(vkms_obj->vaddr); + drm_gem_put_pages(gem_obj, vkms_obj->pages, false, true); + vkms_obj->pages = NULL; + } +} + static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { .atomic_check = vkms_plane_atomic_check, .atomic_update = vkms_primary_plane_update, + .prepare_fb = vkms_prepare_fb, + .cleanup_fb = vkms_cleanup_fb, }; struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev)