Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp67524rwi; Sun, 9 Oct 2022 18:38:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LPpoh4OGMG4OyHGzD+dB+Mt8eCP+mF2yyAGBVXfCABHF92q0CWGXPqd41Y/IiO7TWV7+7 X-Received: by 2002:a17:902:7598:b0:178:3f96:4ffc with SMTP id j24-20020a170902759800b001783f964ffcmr17103638pll.53.1665365927687; Sun, 09 Oct 2022 18:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365927; cv=none; d=google.com; s=arc-20160816; b=QSluPSsK03tDm21nRGzXqQjXUX46QH6bQQnuNclfqiur+6/eFh0uwcR62fpHfSt/Y3 UDFChNYBP6VWQS8x/7oBn9W9bpkkNWHAoeQnJA5cAa/f3+Wh8bsyoJz8uR2AG24b87K7 TgLBLbE9j+Ex5hqBdbpPkoznlx+mlWD3vg87rLw+Tr+XvPUX4uJgvVe5FyqY5C2MOnBI qDRh7vnxERDOySV09YxQ69G2OfRuX7ENFCLU7IpgVADAH6G8HygaXjhhSkSkpvVCl7Td 8b4lzKcUc4PPUcKB52wd9KfydzQiRkIsxVuxVq1JcntnLh/JP+2xCbRN+qptghU1nlLV OfrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vvCixcDJmG2KQ3HDk9TFA6MUvf6/aLV54kMTPUwcDYI=; b=EdyuKDEFEY9fwOggm8KL/aPZif65skTvdNafqCrPxJZOvOvsSO43XlE6qT+z9Cj3x0 TyJP2h+r/hpmQbN6zxSaJ3P7pPpg2tzD4meG/9kgcXkmh6O9npDkuXasy10ZCzx1NQhL gjTBNWBSnN2utVMA4gG0oNaTTc/515EcZIbD8wevfQtBGTZ4kRiJrPrTywP0MIl+mBCT QNYTqaObypWuctmQn7SuBMspl66SmvXlCrDrF0ImtiaEVyYe+Jvnfg+zCpF4HWSzdOx9 5LDkr+fFzPBtfaNgWzsPUR60YfIA+FeqA4GXqaeltWtwdOoFzKiwmg1h4lk6khv1ct7F nknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8/KGa16"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902f70b00b0017f5eb2cf6csi9955582plo.375.2022.10.09.18.38.36; Sun, 09 Oct 2022 18:38:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8/KGa16"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbiJJAVc (ORCPT + 99 others); Sun, 9 Oct 2022 20:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232422AbiJJAUA (ORCPT ); Sun, 9 Oct 2022 20:20:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE112C8; Sun, 9 Oct 2022 16:54:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5D29A60CF5; Sun, 9 Oct 2022 23:54:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 578B8C43142; Sun, 9 Oct 2022 23:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359673; bh=a+sMAFLjX68L2kxSVMElN69vaO37Vkarqiw6jNLmAIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8/KGa16yoT0k6h0IbAF0jlZCycBbaRG0vhziVUzhMhzRyIXkkMbVXc8RtTM5Ppef QMy0Y10oSVpAPuQNhQ2K2y0w0FXYoQ+DHvAL3bDQdlZ5kZk0P5RAGqiz5Jip0Kx6zU A36DxT25K6NkxP8Og9NV+BwTSkx9FR0ALMR4gNuXa016cVIsLUdUPatNHqf75IKT/P eVDgRiK3OQj83vtvxRWFJx/iFkJU/VbGpiyJbFwJJEL1MhViMF43i3X7DfVQzpxb0g KIo+QA52P5gTnH6ZLl9ZIJ2SFeLTaiwnAQmI8E8oc/LAXF8ts295C1X27pMVGnuuko RI4Mucvuv5Gqw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Liviu Dudau , Carsten Haitzler , Sasha Levin , james.qian.wang@arm.com, mihail.atanassov@arm.com, brian.starkey@arm.com, airlied@gmail.com, daniel@ffwll.ch, sumit.semwal@linaro.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH AUTOSEL 5.15 04/25] drm/komeda: Fix handling of atomic commits in the atomic_commit_tail hook Date: Sun, 9 Oct 2022 19:54:04 -0400 Message-Id: <20221009235426.1231313-4-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235426.1231313-1-sashal@kernel.org> References: <20221009235426.1231313-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liviu Dudau [ Upstream commit eaa225b6b52233d45457fd33730e1528c604d92d ] Komeda driver relies on the generic DRM atomic helper functions to handle commits. It only implements an atomic_commit_tail hook for the mode_config_helper_funcs and even that one is pretty close to the generic implementation with the exception of additional dma_fence signalling. What the generic helper framework doesn't do is waiting for the actual hardware to signal that the commit parameters have been written into the appropriate registers. As we signal CRTC events only on the irq handlers, we need to flush the configuration and wait for the hardware to respond. Add the Komeda specific implementation for atomic_commit_hw_done() that flushes and waits for flip done before calling drm_atomic_helper_commit_hw_done(). The fix was prompted by a patch from Carsten Haitzler where he was trying to solve the same issue but in a different way that I think can lead to wrong event signaling to userspace. Reported-by: Carsten Haitzler Tested-by: Carsten Haitzler Reviewed-by: Carsten Haitzler Signed-off-by: Liviu Dudau Link: https://patchwork.freedesktop.org/patch/msgid/20220722122139.288486-1-liviu.dudau@arm.com Signed-off-by: Sasha Levin --- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 4 ++-- .../gpu/drm/arm/display/komeda/komeda_kms.c | 21 ++++++++++++++++++- .../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index 59172acb9738..292f533d8cf0 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -235,7 +235,7 @@ void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, crtc->state->event = NULL; drm_crtc_send_vblank_event(crtc, event); } else { - DRM_WARN("CRTC[%d]: FLIP happen but no pending commit.\n", + DRM_WARN("CRTC[%d]: FLIP happened but no pending commit.\n", drm_crtc_index(&kcrtc->base)); } spin_unlock_irqrestore(&crtc->dev->event_lock, flags); @@ -286,7 +286,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc, komeda_crtc_do_flush(crtc, old); } -static void +void komeda_crtc_flush_and_wait_for_flip_done(struct komeda_crtc *kcrtc, struct completion *input_flip_done) { diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index 93b7f09b96ca..327051bba5b6 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -69,6 +69,25 @@ static const struct drm_driver komeda_kms_driver = { .minor = 1, }; +static void komeda_kms_atomic_commit_hw_done(struct drm_atomic_state *state) +{ + struct drm_device *dev = state->dev; + struct komeda_kms_dev *kms = to_kdev(dev); + int i; + + for (i = 0; i < kms->n_crtcs; i++) { + struct komeda_crtc *kcrtc = &kms->crtcs[i]; + + if (kcrtc->base.state->active) { + struct completion *flip_done = NULL; + if (kcrtc->base.state->event) + flip_done = kcrtc->base.state->event->base.completion; + komeda_crtc_flush_and_wait_for_flip_done(kcrtc, flip_done); + } + } + drm_atomic_helper_commit_hw_done(state); +} + static void komeda_kms_commit_tail(struct drm_atomic_state *old_state) { struct drm_device *dev = old_state->dev; @@ -81,7 +100,7 @@ static void komeda_kms_commit_tail(struct drm_atomic_state *old_state) drm_atomic_helper_commit_modeset_enables(dev, old_state); - drm_atomic_helper_commit_hw_done(old_state); + komeda_kms_atomic_commit_hw_done(old_state); drm_atomic_helper_wait_for_flip_done(dev, old_state); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index 456f3c435719..bf6e8fba5061 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -182,6 +182,8 @@ void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms); void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, struct komeda_events *evts); +void komeda_crtc_flush_and_wait_for_flip_done(struct komeda_crtc *kcrtc, + struct completion *input_flip_done); struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev); void komeda_kms_detach(struct komeda_kms_dev *kms); -- 2.35.1