Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp389012pxk; Sun, 30 Aug 2020 07:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+MAsG+nABAu57m4srIaRjtZcrxIB2dhSBcnBSqUZDGVi7ygpFG26j9dT5jV6PtMtGEtbp X-Received: by 2002:a17:906:6853:: with SMTP id a19mr7601656ejs.506.1598797428642; Sun, 30 Aug 2020 07:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598797428; cv=none; d=google.com; s=arc-20160816; b=jVJTDEeiqRra3J8SgG8Q0yAagKy0zUcATgYo1QLhSh3PgtWdmke2BA8uCL1JUJGzIz ygF37Xvln+uyf1mx94F0kHMx/4DP2WMcqBsS53hw6CqML2n3QLJpKfw193EFjyZPEs+0 OkB1ItfC2Skj+5S6G6Tcz/sXbH2bxCFeezzT/2zXs/dKGT/imuoty9uIPPNgn44Py/lj oYgik+WWyyzmp17RNLI1xdTPZNhMZUArAtgvWlJXoElE21Okgo9guuhos3DuyxQGnOTW 78PLNvljHPOOWJ7PD2fsXSlUk7P/ajipWZZqLoGZuPmFom6sFbfngmeXuLQuPxp/4C9d MAbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZyBQRIpRIUmxpLX99Up9AVw+3VgEJCImZ8A6MyCXh6U=; b=pG/4wCADLe/yaM6f31Dq9xMMgNW9LaxewUjNJFpbwqRPZ6GtADm7d9VDmBVz09rhH7 MYvt6ReXQdVhu/O1f1QxzE9VlBrgz2ftGs3zxnHuNeAP3bPAZU6OBevljWEMrFhDZOLl E3q+Lh8mYbanY56yDfeF4E+9ANiSJJ/rWtjgC1fPg7hh/O2dqHfOJKYVnMFeEZAor4ra 1KAt/D85F7Rv6TsPIreJG2ZHJZcUNfYOquFTC+fCR5ujjqXUlEycN2/eqh8NlGmhm8jU qCq8MJEVwi4vroYO9ZoK9hfROTO9ZbD62G7v5EOaNUn3iamhqU0u+zo4fdLTu738jKLZ 3GeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KsBGTRO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch15si3861556ejb.539.2020.08.30.07.23.26; Sun, 30 Aug 2020 07:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KsBGTRO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726394AbgH3OUv (ORCPT + 99 others); Sun, 30 Aug 2020 10:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgH3OUg (ORCPT ); Sun, 30 Aug 2020 10:20:36 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59928C061573 for ; Sun, 30 Aug 2020 07:20:36 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id f2so1388308qkh.3 for ; Sun, 30 Aug 2020 07:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZyBQRIpRIUmxpLX99Up9AVw+3VgEJCImZ8A6MyCXh6U=; b=KsBGTRO52k++UKESUj3LZEkH1y/FAgcQvgDqfF6MkFB41OmG/SK6RL6Yfk4bvjv+lg Y/tkVL17SmyJCm8PXC6FF8Qo+jinAMsR62n8AL77QRSNd0BEYsGPQCzX6/Ar99Kk3YO4 BVOYmd9ezdHtrjANrO9UHYwGxXenvRZzRJzZovjH3xHbgkPEBOoH9w+DcTd5BNBfeJdB YfO5fDf0QWL15CFJj78d0W3LgTzPTDxvr/iAj6rRcf41+/1cwkq2beVauyZEseFf/T6i SQZs7OCIwtk0ykxj8LZFshgDl7wsbSa7rCnc2RlwrhisiWWZ7LtNHlNGliMm9+wQTu5e l9Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZyBQRIpRIUmxpLX99Up9AVw+3VgEJCImZ8A6MyCXh6U=; b=C74sDgUt9C/s8w97qLcnWyAJ8K5+XOfZ1qiD8Q99ENebG/sWbtzy4XeWlZJFlvr+sz j91htJp6h8Ft8RU25bFmJ5JVMhhx3zDbXjTXTpAf7ltWvvLgB8F+vz5a9oiVnR0UP9nI vkHqndwfJxdw5t5PFsmiY1cqpGK09s0eiY7+LZNZZbbGQy8o+3LYubWP6tfkmRhKFddu FE1w5m7clb8P4RWaNaIM8RjNUiEYq6aeJZfw4NW+io0nvl6NfwpqgTzKLfhAFmNqllo6 8ATGNdLXbUrPXfshqZI9Vpl419T0dThsBNgTNzoRAaycVvwcll+pI+yaoveEEH3eNQ/2 D6RQ== X-Gm-Message-State: AOAM532W5hNUVugO6rZ4tbj1FdR1vc4aR0wyW+0bl5KfgzGqSX0REKBJ LGYMQSznz+666GyONfhj4Ni54qOMrwaR3A== X-Received: by 2002:a37:bcc:: with SMTP id 195mr6891348qkl.287.1598797235190; Sun, 30 Aug 2020 07:20:35 -0700 (PDT) Received: from atma2.hitronhub.home ([2607:fea8:56e0:6d60::2db6]) by smtp.gmail.com with ESMTPSA id o72sm5884861qka.113.2020.08.30.07.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 07:20:34 -0700 (PDT) From: Rodrigo Siqueira To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: melissa.srw@gmail.com, Brian Starkey , Liviu Dudau , Daniel Vetter , Simon Ser , Leandro Ribeiro , daniels@collabora.com, Emil Velikov Subject: [PATCH v6 1/3] drm/vkms: Decouple crc operations from composer Date: Sun, 30 Aug 2020 10:19:58 -0400 Message-Id: <20200830142000.146706-2-rodrigosiqueiramelo@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200830142000.146706-1-rodrigosiqueiramelo@gmail.com> References: <20200830142000.146706-1-rodrigosiqueiramelo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Tested-by: Melissa Wen 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 eaecc5a6c5db..f67d1baf1942 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -131,35 +131,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; } /** @@ -180,9 +176,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; @@ -206,14 +204,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"}; -- 2.28.0