Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1002583pxy; Sun, 1 Aug 2021 09:06:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxFc8ZnLuBAvRLg0b622VWWbDId64BMqCUCF66QuGiisPWjCZkmKuQTaVGxmy8qtErei+Z X-Received: by 2002:a05:6638:218:: with SMTP id e24mr10824849jaq.38.1627834003794; Sun, 01 Aug 2021 09:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627834003; cv=none; d=google.com; s=arc-20160816; b=F5QjN8fMszInMI1l6W4nf/H+0+3pJ/4osvyDHTIjyPE4VLPMe+VYdJ2iyK73G6YYQ0 x5ZysyZZAMpHMBCWCQxh7VuIArNrPIty/FevTyMAYSE7n7Bomz09s2GZmdeoCm+QFsl5 GO+eFnghnH0C4svRj+7vYg5AhMsjJzXas2WUPr3thY/GSdpOimQh/l69pciUbFG0y2UI uXFNTkMAmfNxLp85y9/QKayHjTTGkiBggbtH7a0Z8PJYuvbAobXsqKoTFYy64y980pPv 3BQJOYkIK/Xvz2iF7TNAkvqPOOzg3HJBK+YdoQ8i9OU/YM2JxstfyVvPoBlmm0hqXnYx oOvw== 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=qWjHcNc9/cKIzWTM8p61ItynnbVxNw2Lx8bEmqmAetI=; b=rUMXV6sK5/vvfPPqZ9MWCgXy3aFRxs6RkIlSkSMRcuXrxJD+8H+DTDHSTnp6fVhAjk 4KlJXc2kaljDendXagO2zeZEYiCysDmUpSWXZuulBCGz87tulIUgdT9SzkjTbf2+wR+P vdVgBWSeH7vfmMxkVULJ1I2NaNYaqg0d8b+RoOZ4PyEZ7xVDvhJIouHzqj3bda2QmC4S UDBqZK84sW1n3Q1peaqhuOrWmZEOZEZGefgpiXpSq+IfodokbSfgIi+nYPtZI050GF3d XZxxI4+1OH6L9pEfyKDfz6sZCsr67MyLX5UhT5ZTS7ucBaqd5yL9XQutXww55jx2f9ol E/eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nE+QduxE; 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 g6si9166960ilk.97.2021.08.01.09.06.27; Sun, 01 Aug 2021 09:06:43 -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=nE+QduxE; 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 S231517AbhHAQEU (ORCPT + 99 others); Sun, 1 Aug 2021 12:04:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbhHAQET (ORCPT ); Sun, 1 Aug 2021 12:04:19 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7DE6C06175F for ; Sun, 1 Aug 2021 09:04:10 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so10778933pjb.2 for ; Sun, 01 Aug 2021 09:04:10 -0700 (PDT) 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; bh=qWjHcNc9/cKIzWTM8p61ItynnbVxNw2Lx8bEmqmAetI=; b=nE+QduxE8NhfYgjAcdepIT+KzHO6Mq/IoqdxRNSSwCEBZvfdHRRWQtcX3Hc+Jor5P3 Ofavidc15wIUeDkwgXQrg1cUp19fsaK+L92bB6li95L1O6C4cXVzHP7vhDF/8MvMyR64 oHc7npopMH4HfjORPUyr8vPmuyc3Oj37PB/QEtet94g98Ph++ft2Ho85zLBQfuWyJ9Eo eCezJFfhd4ZHR5dhbrpZabX/5LjXJnokC+BIH5Z+bKNGPZJVNIw3A1CeibtSRx22k1jK +YBKa18RoVZuTtCVe470RKEmFmoCA/OnIoEc45KSYpB4Py+guTJMtF/bDMTVsRa7eK21 JOyQ== 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=qWjHcNc9/cKIzWTM8p61ItynnbVxNw2Lx8bEmqmAetI=; b=PeNliFB93MOYDwtgXyddHRrvqgbxj0WKP8Ai6Dv+553JOxt2X5l+Wj+cHiHhUovzJW MEy++y0aMIlst5QvoFZA3EbSFta1cUqQIZ5jprDBP41nprI5fX5j42h3nICj7g0qlYHP ScwF+gkPm71maBVHCDyiI5k2/NTRfknpFOZpu6zCUmQplXJpJccrlsXkO9JOq0afuRHq 6CJhzdeV0sVM8+yZLxLXRIP5Rpkr2NgKN8KZyhsEWSfVRw1FRjOVW7fumXmSCxqicpu2 brDaVv/AhmXE10eBa6b7E2jdZFDyH2k8p2GvLs9Z/w6HNEqopr8JV7+CEMwPU3ueL/cV QEQw== X-Gm-Message-State: AOAM533iu1gCi/CHFMEu2oByDEpiLBycviVdwjxZPh7EgibOvCbALCl0 080Mv1IjGBlNnQVUWjxhE+Y= X-Received: by 2002:a17:90a:ba8e:: with SMTP id t14mr13385953pjr.176.1627833850298; Sun, 01 Aug 2021 09:04:10 -0700 (PDT) Received: from adolin ([49.207.203.94]) by smtp.gmail.com with ESMTPSA id x7sm8581978pfn.70.2021.08.01.09.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 09:04:10 -0700 (PDT) Date: Sun, 1 Aug 2021 21:33:00 +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 V5 1/2] drm/vkms: Refactor vkms_composer_worker() to prep for virtual_hw mode Message-ID: <8aadb60b4d4768dc5518f12a5952909a388212c2.1627831087.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 | 76 ++++++++++++++++------------ drivers/gpu/drm/vkms/vkms_drv.h | 2 + 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index ead8fff81f30..bf3d576db225 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; + + 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,9 @@ 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) - return; - - if (wb_pending) - vaddr_out = crtc_state->active_writeback; - - ret = compose_active_planes(&vaddr_out, primary_composer, - crtc_state); - if (ret) { - if (ret == -EINVAL && !wb_pending) - kfree(vaddr_out); + ret = vkms_composer_common(crtc_state, out, wb_pending, &crc32); + if (ret == -EINVAL) 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 8c731b6dcba7..01beba424f18 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -132,6 +132,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