Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp783768pxb; Wed, 1 Sep 2021 09:47:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTfMJwW8A5C/YjQvPqcWGWQghSu283v8idNwOiEdLTIyj1DFVm9lEDmWszJrMddDFsLbxc X-Received: by 2002:a17:906:8469:: with SMTP id hx9mr362919ejc.455.1630514856030; Wed, 01 Sep 2021 09:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630514856; cv=none; d=google.com; s=arc-20160816; b=w8HSbwwTAtKZ8TyFdrrI8ileG2NV27EJtj2BVAz6JBbnQkY2zHlQ0D6nAz/6D7in+r DjHXi0mS3IvwMCFoO1A/+yY8G8SMDxLZupWTwGEfU9ZNyFpWc2QMgx39PFAC0HQGAqAc SX5SSm4QZ9IDZ5KKV+uZZ6qnTlsYd1Tu36dCkJUslkDtSCn9dAHR+8SLehWzFmVVOmwH rvzwXb1+lzCamDZHGivvFW2LRhZspNY8lnA7gIY3mBXA/iF6cwWBsVcOkDY/tgmYn1oQ 9Z9Hfdw4HfdUKi1lle7s8pMrr37b1ZZq1HzbsIXMKzU+Hq+miVH9wg5ma6/L4kD8Awvn c0IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LyE0QH6lNCVSo0W1WYh5ma87v3T6xS6WMQH4anjXxD8=; b=o/Qd8ts4vVH6NMEmSNaYzlewTSLJCFNV7MaSHj2JMH3dB5mSpJP7huP1tGH5TigX6F C9gI8of32wzQe+m/KK0x0Zt+36gZfAagrjfoYUzXMuMNCXMeJ74MluQtaltC6Osiyp24 8OZQMJb7XD2UByObvgXPWwBqfj7D8vyehAvK8NKYkt/2KscBsxfCFTdxevi20Izeeqk9 w2YPwe+NlsaUGUmwL4gWP5ByUlHROrX2wZCXxOxhBRW4lBKJG2wXQp+mmYNMzvp5Ihpz f6oa86uIEgXnUWbE7s66THZV3Ls19Lxu/uykFywZ+giI7vrsA0xv+Nad5c7oYXPK8xO7 Y6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hLBmoaBa; 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 hs22si243995ejc.85.2021.09.01.09.46.48; Wed, 01 Sep 2021 09:47:36 -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=20210112 header.b=hLBmoaBa; 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 S1344004AbhIAQoE (ORCPT + 99 others); Wed, 1 Sep 2021 12:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245462AbhIAQoB (ORCPT ); Wed, 1 Sep 2021 12:44:01 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0DC4C061575 for ; Wed, 1 Sep 2021 09:43:04 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x19so271534pfu.4 for ; Wed, 01 Sep 2021 09:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LyE0QH6lNCVSo0W1WYh5ma87v3T6xS6WMQH4anjXxD8=; b=hLBmoaBaCbcq4MvyxjT0txS3dClmupWfLraSUXa87Blj+fBXUpstu5fZGMefAsjWyF GaGh/WXcyIhTgVjxST9LNOfr/YvXRIW3jRhIfozyvOrAB/8ZL0Ir2cU8nk//MZu7cmsS uY6fbGDumAJKvWObaHteP2TtA8l73i68XsfQCWocTyG/ZQiLd7BgZyMShwwtkcOMLGjt lUFxZ6BFleL5n+19+/X5QLITDaT4g0cuI/5clkl1KDsihH2+LRvFTvbbL5Y8LQt8td2Q 7XBCZY2cgaCemvCom+nXRVSuvw0ukt9QiMntBw1NXc1G39EY9Hyz5lP6WsjXCdyGCrA1 CWWg== 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; bh=LyE0QH6lNCVSo0W1WYh5ma87v3T6xS6WMQH4anjXxD8=; b=mnal8OGoqxnGR8zElHXOYMR5+mgSZC+ZX/2dOGAEQUuKqqeAGnt3wSqBt7rtvAHJyp oKI7VCqyJIQGu18zcmmoeerQLjZO354oTj88KzDl6Lfp/k3e5v1HYVPjG+0oDV0HZf0a Pe1FAI+EC/gd37Ewc2pXXnHJe5FEKaVN9bZ27mUWYxP3rqS/cc9n2qtdZs2nM1RBZSyD WHHSxRPoxWytT8GK0SP6ZrsY2lmsqHU2XmpF+bnFZ4cFVd18cuuBsQBIeva+w3yns6a9 IJjFoHEAoUufMdL/yyilpf4t/xwSTVgD6DqSQS1bWbObOdhZjaxyTxokq1glEd+6caiB DgLw== X-Gm-Message-State: AOAM533AXDRpvXdjZhmyoNzOfBLD1qrYYSnbRtOwPKTJTTNSpJbtannd oVgjJGbdvV5wXDRYz3wmsjA= X-Received: by 2002:a63:e40a:: with SMTP id a10mr24243pgi.414.1630514584228; Wed, 01 Sep 2021 09:43:04 -0700 (PDT) Received: from adolin ([49.207.225.208]) by smtp.gmail.com with ESMTPSA id h4sm254632pgn.6.2021.09.01.09.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 09:43:03 -0700 (PDT) Date: Wed, 1 Sep 2021 22:11:39 +0530 From: Sumera Priyadarsini To: melissa.srw@gmail.com Cc: rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH V6 1/2] drm/vkms: Refactor vkms_composer_worker() to prep for virtual_hw mode Message-ID: <2a8e24370f0e5f8df1e103a3aa40aee015e7f874.1630512292.git.sylphrenadin@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new function vkms_composer_common(). The actual plane composition work has been moved to the helper function, vkms_composer_common() which is called by vkms_composer_worker() and will be called in the implementation of virtual_hw mode as well. Signed-off-by: Sumera Priyadarsini --- Changes in V5: - Move vkms_crtc_composer() to the patch that introduces virtual_hw mode (Melissa) - Fix checkpatch errors(Melissa) Changes in V4: - Fix warning Changes in V3: - Refactor patchset (Melissa) Change in V2: - Add vkms_composer_common() (Daniel) --- drivers/gpu/drm/vkms/vkms_composer.c | 75 ++++++++++++++++------------ drivers/gpu/drm/vkms/vkms_drv.h | 2 + 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 9e8204be9a14..bca746fb5b53 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -206,6 +206,47 @@ static int compose_active_planes(void **vaddr_out, return 0; } +int vkms_composer_common(struct vkms_crtc_state *crtc_state, + struct vkms_output *out, bool wb_pending, uint32_t *crc32) +{ + struct vkms_composer *primary_composer = NULL; + struct vkms_plane_state *act_plane = NULL; + void *vaddr_out = NULL; + int ret; + + if (crtc_state->num_active_planes >= 1) { + act_plane = crtc_state->active_planes[0]; + if (act_plane->base.base.plane->type == DRM_PLANE_TYPE_PRIMARY) + primary_composer = act_plane->composer; + } + + if (!primary_composer) + return -EINVAL; + if (wb_pending) + vaddr_out = crtc_state->active_writeback->data[0].vaddr; + + ret = compose_active_planes(&vaddr_out, primary_composer, crtc_state); + + if (ret) { + if ((ret == -EINVAL || ret == -ENOMEM) && !wb_pending) + kfree(vaddr_out); + return ret; + } + + *crc32 = compute_crc(vaddr_out, primary_composer); + + if (wb_pending) { + drm_writeback_signal_completion(&out->wb_connector, 0); + spin_lock_irq(&out->composer_lock); + crtc_state->wb_pending = false; + spin_unlock_irq(&out->composer_lock); + } else { + kfree(vaddr_out); + } + + return 0; +} + /** * vkms_composer_worker - ordered work_struct to compute CRC * @@ -222,10 +263,7 @@ void vkms_composer_worker(struct work_struct *work) composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); - struct vkms_composer *primary_composer = NULL; - struct vkms_plane_state *act_plane = NULL; bool crc_pending, wb_pending; - void *vaddr_out = NULL; u32 crc32 = 0; u64 frame_start, frame_end; int ret; @@ -247,37 +285,10 @@ void vkms_composer_worker(struct work_struct *work) if (!crc_pending) return; - if (crtc_state->num_active_planes >= 1) { - act_plane = crtc_state->active_planes[0]; - if (act_plane->base.base.plane->type == DRM_PLANE_TYPE_PRIMARY) - primary_composer = act_plane->composer; - } - - if (!primary_composer) + ret = vkms_composer_common(crtc_state, out, wb_pending, &crc32); + if (ret == -EINVAL) return; - if (wb_pending) - vaddr_out = crtc_state->active_writeback->data[0].vaddr; - - ret = compose_active_planes(&vaddr_out, primary_composer, - crtc_state); - if (ret) { - if (ret == -EINVAL && !wb_pending) - kfree(vaddr_out); - return; - } - - crc32 = compute_crc(vaddr_out, primary_composer); - - if (wb_pending) { - drm_writeback_signal_completion(&out->wb_connector, 0); - spin_lock_irq(&out->composer_lock); - crtc_state->wb_pending = false; - spin_unlock_irq(&out->composer_lock); - } else { - kfree(vaddr_out); - } - /* * The worker can fall behind the vblank hrtimer, make sure we catch up. */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d48c23d40ce5..6f5f63591c20 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -137,6 +137,8 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, size_t *values_cnt); /* Composer Support */ +int vkms_composer_common(struct vkms_crtc_state *crtc_state, struct vkms_output *out, + bool wb_pending, uint32_t *crcs); void vkms_composer_worker(struct work_struct *work); void vkms_set_composer(struct vkms_output *out, bool enabled); -- 2.31.1