From patchwork Wed Jun 27 21:23:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10493293 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 7873D60325 for ; Thu, 28 Jun 2018 08:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 611C329EEB for ; Thu, 28 Jun 2018 08:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 557B329F1D; Thu, 28 Jun 2018 08:23:00 +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 EE0FA29EEB for ; Thu, 28 Jun 2018 08:22:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3DC016EC73; Thu, 28 Jun 2018 08:22:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1EE66EBA9 for ; Wed, 27 Jun 2018 21:23:42 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id h10-v6so3382337wrq.8 for ; Wed, 27 Jun 2018 14:23:42 -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=/odNH95qqZIt5XTNnalyZ3tI1ACNmPedUgBoHulFVmY=; b=pzS/PoCmi+a16sH72BrdBlkyOeePRtVkqiNyCj3aVxm4lmtdIsFli2bOyJM36EwgCC pVbuxd1M9y5F+hAzdggH7dZ9nRBvdOBFFGZQSdMDBXN/fXzI4kFxAqxauADV/ava+C8R E0jmzsaZZeq63+fSdrq9SUFnH/cm0deamM6/Jbt+DO71dfvjvmRdVoCkwejQ2dwwzzPv 43X6/SSrZzAlOIPFjH7VRHr6cf9tqbLMjZbqpuuWcjSvGVpZ9/WLNd4vql/A0ZNq55dP Siy0oCSQacKo+uiSDNtR0JhC/CMcmIDubVhYRiIfj7cjNi3BMVp2aVCcdq0yD14CZOHH RuNg== X-Gm-Message-State: APt69E08cnR0SsbVu0H7Y8rAEiF53wrueRHCU1ES5iFYci8p9VxmvqIY F8Bl7eEFHJC2Erq/PwgDqN8uw9pf X-Google-Smtp-Source: AAOMgpeempftSPXD2ZGwD1o93Mhr1eNfEBQ3cFA7k5cdQ3AtpqOiJTmWPNMBG08dshmSo9RS2tnJ4A== X-Received: by 2002:adf:b909:: with SMTP id k9-v6mr6490082wrf.116.1530134620965; Wed, 27 Jun 2018 14:23:40 -0700 (PDT) Received: from haneen-vb ([78.180.222.80]) by smtp.gmail.com with ESMTPSA id 130-v6sm5872101wmr.1.2018.06.27.14.23.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 14:23:40 -0700 (PDT) Date: Thu, 28 Jun 2018 00:23:37 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [RFC 2/3] drm/vkms: map/unmap buffers in [prepare/cleanup]_fb hooks Message-ID: 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, 28 Jun 2018 08:22:06 +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 checks plane state and use prepare/cleanup_fb to map/unmap GEM backing memory to kernel address space. Signed-off-by: Haneen Mohammed --- drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_plane.c | 50 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d6cb8824cee2..300e6a05d473 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -42,6 +42,7 @@ struct vkms_gem_object { struct mutex pages_lock; /* Page lock used in page fault handler */ struct page **pages; void *vaddr; + struct drm_plane_state *plane_state; }; #define drm_crtc_to_vkms_output(target) \ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index f7f63143f6d0..c717f2a41c1d 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, @@ -22,6 +23,14 @@ static const struct drm_plane_funcs vkms_plane_funcs = { static int vkms_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { + if (!state->crtc) + return 0; + + drm_atomic_helper_check_plane_state(state, state->crtc->state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, // false for primary planes + true); return 0; } @@ -30,9 +39,50 @@ 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->plane_state = state; + 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 *state) +{ + struct drm_gem_object *gem_obj; + struct vkms_gem_object *vkms_obj; + + if (!state->fb) + return; + + gem_obj = drm_gem_fb_get_obj(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)