From patchwork Thu Jul 19 00:18:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10533721 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 E9FD0601D2 for ; Thu, 19 Jul 2018 07:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D90D128CDE for ; Thu, 19 Jul 2018 07:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD6F428D09; Thu, 19 Jul 2018 07:07:06 +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 90D0428CDE for ; Thu, 19 Jul 2018 07:07:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DF9C6ECF9; Thu, 19 Jul 2018 07:04:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7DD86898A4 for ; Thu, 19 Jul 2018 00:19:05 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id c13-v6so6312642wrt.1 for ; Wed, 18 Jul 2018 17:19:05 -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=rFSwWSUPHx08qfTHj71N+ZbZVZc/GTLvwDmYxCddObU=; b=acP+3CCQwIGTtVndnbB/Ra7FGVDR1VO18T4rUwSmVe0AInQbQFiUl0UBC7wB1PCAsZ VnryVMdzd9Qc6bmPW4zXyItZJpSB4Z9hX9p+KqpDs+cB4VKZMxyORvSD3XiEqMRM00K/ QPf+tqybqKu7rI40yPCAjgt6kEPkl1cYdRrtkDashk5+609LQ5J2g1C5hADIATp5YF0r 5T8QvLMwfuqncqv5YthQX++pqKu48f3U8XkxVjxMcuMqL3mE4s6gDUDnQ7i0HkpGL2lj WNaAD3TqdHG0zb8OeFCmMuP4UlDXGNd6sImFslumKN7mMoX71UmdKAdPYhASLi+q9od8 oypQ== X-Gm-Message-State: AOUpUlFHGv58DStaHJBrOUXQnQp0Z1xFNuno0lfqwS6d6F25n2mSwOzf Bc4317xtPp9aOnDmO51gA0CGzt71 X-Google-Smtp-Source: AAOMgpetwXpnTaMfPZKrOjPXV9NTD8Zfn617NApC/pMdF8BZALPFQbBX1t3PaKcBTR8LNCYJPhhaNg== X-Received: by 2002:adf:91e5:: with SMTP id 92-v6mr5867274wri.124.1531959543924; Wed, 18 Jul 2018 17:19:03 -0700 (PDT) Received: from haneenDRM ([188.50.2.36]) by smtp.gmail.com with ESMTPSA id y14-v6sm12998657wrq.45.2018.07.18.17.19.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Jul 2018 17:19:03 -0700 (PDT) Date: Thu, 19 Jul 2018 03:18:55 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/5] drm/vkms: map/unmap buffers in [prepare/cleanup]_fb hooks Message-ID: <06fe5281f62eb541496a0e8f79127f20e895a9ac.1531955948.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: Thu, 19 Jul 2018 07:03:43 +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 Changes in v3: - return error number instead of vkms_obj->vaddr drivers/gpu/drm/vkms/vkms_plane.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 9f75b1e2c1c4..aa6cde34710c 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, @@ -24,8 +25,42 @@ 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; + int ret; + + if (!state->fb) + return 0; + + gem_obj = drm_gem_fb_get_obj(state->fb, 0); + vkms_obj = drm_gem_to_vkms_gem(gem_obj); + ret = vkms_gem_vmap(gem_obj); + + if (ret) + 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)