From patchwork Sat Jul 14 12:20:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10525057 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 2853060245 for ; Sun, 15 Jul 2018 14:59:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A4A284A7 for ; Sun, 15 Jul 2018 14:59:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E3822890F; Sun, 15 Jul 2018 14:59:22 +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 C2F56284A7 for ; Sun, 15 Jul 2018 14:59:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 752FE6E3F5; Sun, 15 Jul 2018 14:57:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 14A1E6E067 for ; Sat, 14 Jul 2018 12:20:27 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id 69-v6so11547158wmf.3 for ; Sat, 14 Jul 2018 05:20:27 -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=Qkb9dpeyzblhgzjv9TtKuRNpiiHZmc2hIWqOLjUBBl4=; b=d4G2mRCKQioAH97k+f+OQ4VgExjvMYOwslyO89RUfDlTqbLds4oFPnNMs/e1T4D9e6 U1WqnyhgrfEzfk0S7OxetRWdZll5UsDKIsnlkiJ99Jk1nzcp6KD3ffAFs4Zeu3sMg3aj BBbu667HXs0T4eacZ+AwftK2Sc7hR3/n+AMAJY+2mSSS4B+r80Cwo19Z7vHEo27YMxXg nSWtrwIQ6ZfB2mx5+yHdFmM4ZrImCOVsp+whFrY2FhgTfKJeo5WDblnrficipcL+7spi yTGdjp5woitEQ5JwzM00cHIBFDtfH6ZgSs+DKoLPb/aKgsJMtteqSzk/3GY28qn7il0L 8L/A== X-Gm-Message-State: AOUpUlFGcgvnwQQMXezVta9plh4RTpscZwRgg/eP9I8OwFh41eF/SOiz 8q1u7vLnchRFFMvilhsDScBDgrgm X-Google-Smtp-Source: AAOMgpdqWI1R7ZtfTBdnsBml6gn445CoLzJmYzhLyDksoe9df7EhjuqlJ8H06/4m2XHvEWUqETWYqQ== X-Received: by 2002:a1c:c8:: with SMTP id 191-v6mr5715039wma.115.1531570825395; Sat, 14 Jul 2018 05:20:25 -0700 (PDT) Received: from haneenDRM ([188.48.174.13]) by smtp.gmail.com with ESMTPSA id n14-v6sm750092wmc.14.2018.07.14.05.20.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 14 Jul 2018 05:20:24 -0700 (PDT) Date: Sat, 14 Jul 2018 15:20:21 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/5] drm/vkms: map/unmap buffers in [prepare/cleanup]_fb hooks Message-ID: <0882f4736ba1014f3c84de3aef0813866b1911f3.1531570020.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: Sun, 15 Jul 2018 14:57:27 +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 --- Changes in v2: - use vkms_gem_vunmap drivers/gpu/drm/vkms/vkms_plane.c | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 9f75b1e2c1c4..877483984897 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -7,8 +7,9 @@ */ #include "vkms_drv.h" -#include #include +#include +#include static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, @@ -24,8 +25,41 @@ 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 = drm_gem_to_vkms_gem(gem_obj); + vkms_obj->vaddr = vkms_gem_vmap(gem_obj); + + if (!vkms_obj->vaddr) + DRM_ERROR("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; + + if (!old_state->fb) + return; + + gem_obj = drm_gem_fb_get_obj(old_state->fb, 0); + vkms_gem_vunmap(gem_obj); +} + static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { .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)