From patchwork Tue Jul 24 16:29:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10543553 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 CC48C14E2 for ; Wed, 25 Jul 2018 07:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA79F2944E for ; Wed, 25 Jul 2018 07:05:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEE1D29423; Wed, 25 Jul 2018 07:05:19 +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 6D76F29423 for ; Wed, 25 Jul 2018 07:05:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED51E6E2C2; Wed, 25 Jul 2018 07:05:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id D85FE6E5E4 for ; Tue, 24 Jul 2018 16:29:26 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id l9-v6so969007pff.9 for ; Tue, 24 Jul 2018 09:29:26 -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=/c6d+n9tl/AWo37Ai4wcXh7Duz6XHY3xo6HPmt3nZHE=; b=kQC2WFHTt3SMFuF70RHH1zcfnTuvjFfKYJ1CL3NTNpI9IotT5hnTn2C7dfc8Evop6r d4AgUR+IrYSNfaAE+fJ6n0YpCgGZC/a5sf58IGqptcNkP5eOyU4mth2qwGBROqSkghG9 p4XW5PnXaSGqfwt5y5lF1zurxwdCO1QCqEoLAIDf76l51fMhUBeMOQiKO3f9ykmOHfIh wPsy0Y7pHQFQZSS3D66XBasqmlHouju7cyOCNjt32gC+O37tNc8jiKcNCcXRUQd3oMsr eaysmIAnzuoBeCESeM2K4kZJqkpfMcHgLOBxvkWsUAReXObngdc/poGR9NfSUzGQ9LU6 2AQg== X-Gm-Message-State: AOUpUlE7qYEiU9Gs4y+5PsIZOtpYGTewZUxLJ/ysaWBnvMY6yRnaEU12 iIOIL+fFSoIqlKKC5N9suIIToclyXEg= X-Google-Smtp-Source: AAOMgpewIkwgWlTMRvTV0dfZjdUdv6mM+55nMi49ILYdKiYF8jaxjX8cmIpiy+Rw0crXq85VbE6ywg== X-Received: by 2002:a62:cc4d:: with SMTP id a74-v6mr18534921pfg.200.1532449766284; Tue, 24 Jul 2018 09:29:26 -0700 (PDT) Received: from haneenDRM ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id 87-v6sm26438036pfn.103.2018.07.24.09.29.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:29:25 -0700 (PDT) Date: Tue, 24 Jul 2018 19:29:23 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 2/4] drm/vkms: map/unmap buffers in [prepare/cleanup]_fb hooks Message-ID: <17d19f61b6539ce1b614c59762d04d816261b307.1532446182.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: Wed, 25 Jul 2018 07:05:01 +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 Changes in v4: - print return value from vkms_gem_vmap drivers/gpu/drm/vkms/vkms_plane.c | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 9f75b1e2c1c4..5611e7cf5fc9 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,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; + 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: %d\n", ret); + + 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)