From patchwork Sat Oct 22 07:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1121351wrr; Sat, 22 Oct 2022 02:28:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5a7WoWtbmXsRhK2hOoyrliho16n3bgJVZVMxWLdLcFasDw6+gOFs43oaHCrCAZqEOpWAAf X-Received: by 2002:a05:6a00:198e:b0:566:9207:d340 with SMTP id d14-20020a056a00198e00b005669207d340mr23605992pfl.83.1666430899839; Sat, 22 Oct 2022 02:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430899; cv=none; d=google.com; s=arc-20160816; b=oVZFtaQPCPe3ZIneD+re93TYQSNH11hiZD33x/Texk3HUT4myHbZ5Zrww+aLWFgpgg f4WWYeUXO71Dl0SvRhmEiNDlt7QAM0JKvkYc81YdCdlrJ0+LZtoH+PaHg7YMILMK48M9 /qh9FSyjRNT1w8MI4JaC9RJ/D0hAIutPX9Nv8KSxxjvJ71jRGb82ufVln5x++bRBTKNq itLDCjYFg6BvnimEvM7DGbVkgZwTRmilCNa2hL1SLFtgfpUNIveyWxXqBz8ZCsCPJNMp 9a71YTnxk4TgJYZcA6wJxYby/jDjfgysvTxsOQQrVS94COteCUCKqx+wWUKnIt4X8mni cO4w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vvCixcDJmG2KQ3HDk9TFA6MUvf6/aLV54kMTPUwcDYI=; b=hz5ZJCmRxe+hw5W1CNTVDsqq20wRh2b0kZvpxa0t3Lwpiiz1PvJQVzGiyJ1B4xuopo Ccnm2oHLn76GzPviRyv4HRRskk8rGXiySmaciTGwBY15hqup7wSLTbnkHvY0aZSuA/OK 6DvVBJMFbE96qBV9n6cJ6VBLzQSiMA7mcNpwuC5HqwC6XSsGyPHDd3VyISSyf/V0WnVE sKyx72aL5+H/3le1qQebovcjmiDdDKje/NOhRlvYiFj11D1h2moh3RryW4DZOxJW/Ba5 6Rwu8/lvwyI3AkZDKXIvWpDhOCJC5u6EGqPmAqeAEhCkYtm6NaLd3Lsc37b4La46ZOSf rV5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VG3d+tXW; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 68-20020a630347000000b0046ef00e6afbsi5801pgd.793.2022.10.22.02.28.07; Sat, 22 Oct 2022 02:28:19 -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=@linuxfoundation.org header.s=korg header.b=VG3d+tXW; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbiJVJHE (ORCPT + 99 others); Sat, 22 Oct 2022 05:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235031AbiJVJFl (ORCPT ); Sat, 22 Oct 2022 05:05:41 -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 A46AC39BA5; Sat, 22 Oct 2022 01:19:49 -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 50D8760BA1; Sat, 22 Oct 2022 08:02:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 617AEC4347C; Sat, 22 Oct 2022 08:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425740; bh=a+sMAFLjX68L2kxSVMElN69vaO37Vkarqiw6jNLmAIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VG3d+tXWVZUidNHZvcg8Ho+v20XQfFFMZfNrQ2DBOUPm83WjfumKYgPogLTUL33cr JgqBr8WyupSMsr7+wohKFvY9WHmOVDi9maySd7xZ6P+R+kKBjHjoEPG3Yzr/PFZ2L4 yle8jDuMHCu/ozj3k4H3zkmVg9CMtFFvzdmpLFDQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Carsten Haitzler , Liviu Dudau , Sasha Levin Subject: [PATCH 5.19 601/717] drm/komeda: Fix handling of atomic commits in the atomic_commit_tail hook Date: Sat, 22 Oct 2022 09:28:00 +0200 Message-Id: <20221022072525.038007820@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747379447258982632?= X-GMAIL-MSGID: =?utf-8?q?1747379447258982632?= 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);