From patchwork Wed Jun 26 01:37:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11016717 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 9A0CD924 for ; Wed, 26 Jun 2019 01:38:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 893C0271CB for ; Wed, 26 Jun 2019 01:38:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9AD285F2; Wed, 26 Jun 2019 01:38:07 +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 2CB36271CB for ; Wed, 26 Jun 2019 01:38:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EEC06E1D2; Wed, 26 Jun 2019 01:38:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BA7E6E1D2 for ; Wed, 26 Jun 2019 01:38:04 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id x47so631451qtk.11 for ; Tue, 25 Jun 2019 18:38:04 -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=Dcji4DG1mYdfSzaoYm1b9GBfrTHcBOQ4lNkuX8kgim8=; b=rpIF3Ji7Y0FvmF5CIIdaI3WMS2KFdSmH+CjUcyY3R5phG31m5ULZcrVyY6zbOZ/o26 UXwdnbPbwX0f5SJpgMbLZrvpPyzPOV6ftP1o9zVnee+58srjMsoBEDnbHiqJzEs05BDZ /JFxc/eTVjCGQGjJ56akN5QcpYAj5MfyfJrQr/r4ohHwqtY4B3jopjiim13XTlBIeOSL rk99YCeD8tL7NLV3YkJB1YxHLdKtIJcUryb3hvd2zhqaMvAd7mV7ScFGd8JFtZWnIgUA lWDciUnzanrsLG+JnlQZPXH08xfyyj/SqEC8/oygdbPcvqqJuPWtRY7zxrgpujnJectM 1fcg== X-Gm-Message-State: APjAAAWqBKo+cUGY8nwGAg20PF3OlelgyYtEj5rJwTYBb6+8WQ0YH1OD ql+zjV2qe+ZoQScilJMX0DA= X-Google-Smtp-Source: APXvYqwJv4ZMACGc1XJpqCZdYEetDgEmL+h2ns1p1TA6Wm0McZDXDfxD+AdQ2jcvbnMU6UqRAJyk/w== X-Received: by 2002:aed:3747:: with SMTP id i65mr1413779qtb.166.1561513083429; Tue, 25 Jun 2019 18:38:03 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id e18sm7441097qkm.49.2019.06.25.18.37.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 18:38:03 -0700 (PDT) Date: Tue, 25 Jun 2019 22:37:58 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V3 3/5] drm/vkms: Decouple crc operations from composer Message-ID: <6e8a03dc7c666ee998ee36172a96cff39f8dd46d.1561491964.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Dcji4DG1mYdfSzaoYm1b9GBfrTHcBOQ4lNkuX8kgim8=; b=QYqgls57UiwrwknJ+w6IfGJFDRY1zpL306MGaJVEbcPuLpkedTVidtXe12U7J8ObsL wbnA98tWBTOmbjCY4W6urdJT+XoYAkh1CMcVlx23yB2q185Up7fYoNTmG8kzB+1/RXnu 1kS6yqT8hEIPPbhn6lbU7EFU1vfucpe3BpG1N0TGYR7rFzGl4nRcDpEGHVtzhuU0BUiV AiNtow8FBlAob7PeSyxcmPQ0fiE5FrR5FI86blq5dGPvL6wPw/dXpnyy0tFYD+hzrr+U BLE7As7vn5cIA+q4uxelG6GUVjGeEi4yJ6O1WqKcvlmAcbmG+pE4gulRp6NQ1AezulbF PRBA== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In the vkms_composer.c, some of the functions related to CRC and compose have interdependence between each other. This patch reworks some functions inside vkms_composer to make crc and composer computation decoupled. This patch is preparation work for making vkms able to support new features. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 49 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index eb7ea8be1f98..51a270514219 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -105,35 +105,31 @@ static void compose_cursor(struct vkms_composer *cursor_composer, primary_composer, cursor_composer); } -static uint32_t _vkms_get_crc(struct vkms_composer *primary_composer, - struct vkms_composer *cursor_composer) +static int compose_planes(void **vaddr_out, + struct vkms_composer *primary_composer, + struct vkms_composer *cursor_composer) { struct drm_framebuffer *fb = &primary_composer->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); struct vkms_gem_object *vkms_obj = drm_gem_to_vkms_gem(gem_obj); - void *vaddr_out = kzalloc(vkms_obj->gem.size, GFP_KERNEL); - u32 crc = 0; - if (!vaddr_out) { - DRM_ERROR("Failed to allocate memory for output frame."); - return 0; + if (!*vaddr_out) { + *vaddr_out = kzalloc(vkms_obj->gem.size, GFP_KERNEL); + if (!*vaddr_out) { + DRM_ERROR("Cannot allocate memory for output frame."); + return -ENOMEM; + } } - if (WARN_ON(!vkms_obj->vaddr)) { - kfree(vaddr_out); - return crc; - } + if (WARN_ON(!vkms_obj->vaddr)) + return -EINVAL; - memcpy(vaddr_out, vkms_obj->vaddr, vkms_obj->gem.size); + memcpy(*vaddr_out, vkms_obj->vaddr, vkms_obj->gem.size); if (cursor_composer) - compose_cursor(cursor_composer, primary_composer, vaddr_out); + compose_cursor(cursor_composer, primary_composer, *vaddr_out); - crc = compute_crc(vaddr_out, primary_composer); - - kfree(vaddr_out); - - return crc; + return 0; } /** @@ -154,9 +150,11 @@ void vkms_composer_worker(struct work_struct *work) struct vkms_output *out = drm_crtc_to_vkms_output(crtc); struct vkms_composer *primary_composer = NULL; struct vkms_composer *cursor_composer = NULL; + void *vaddr_out = NULL; u32 crc32 = 0; u64 frame_start, frame_end; bool crc_pending; + int ret; spin_lock_irq(&out->composer_lock); frame_start = crtc_state->frame_start; @@ -180,14 +178,25 @@ void vkms_composer_worker(struct work_struct *work) if (crtc_state->num_active_planes == 2) cursor_composer = crtc_state->active_planes[1]->composer; - if (primary_composer) - crc32 = _vkms_get_crc(primary_composer, cursor_composer); + if (!primary_composer) + return; + + ret = compose_planes(&vaddr_out, primary_composer, cursor_composer); + if (ret) { + if (ret == -EINVAL) + kfree(vaddr_out); + return; + } + + crc32 = compute_crc(vaddr_out, primary_composer); /* * The worker can fall behind the vblank hrtimer, make sure we catch up. */ while (frame_start <= frame_end) drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32); + + kfree(vaddr_out); } static const char * const pipe_crc_sources[] = {"auto"};