From patchwork Mon Aug 7 00:04:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 13342912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DB4CC0015E for ; Mon, 7 Aug 2023 00:05:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CF3E89FC9; Mon, 7 Aug 2023 00:05:13 +0000 (UTC) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9526B10E048 for ; Mon, 7 Aug 2023 00:05:05 +0000 (UTC) Received: from workpc.. (109-252-150-127.dynamic.spd-mgts.ru [109.252.150.127]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7D27A660711A; Mon, 7 Aug 2023 01:05:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691366704; bh=zxAsuZOqI5T9dSHzdfn9q25oiwiUf0oORASmCnorRKs=; h=From:To:Cc:Subject:Date:From; b=HRStPPOmPmcRYmy16V3Yif2MhylntUx0MSOU6dqy4iQJmQV9cpyKvwMkwidvbDDkB REo4Ju0loyZlofyAUGCjWxPvnu+hOxVmeYeQql5EiMLKuDJMFSlU6lG5snEKk0/HXb bi5WlKrP+NLd6c6/RHTn1amblRyBof4IFcXAS/wZWiOmu3KjXNH5yxwlUXkgcVMnIv 0CAdrsmWGfNIak6gwiIieA4mvsvZg+Dr3iURPvaUBkmLZy6ybyqYjMNQyH3SdAXzJC mTqI+FEiR1NI1DLgoZnLMm8TxqZozMPTDd8APBphlINNeU8qIuCLfzRMQ7iL+VdX5v 8bMouR/Y1szQQ== From: Dmitry Osipenko To: AngeloGioacchino Del Regno , Rob Herring , Steven Price , Boris Brezillon Subject: [PATCH v4] drm/panfrost: Sync IRQ by job's timeout handler Date: Mon, 7 Aug 2023 03:04:44 +0300 Message-ID: <20230807000444.14926-1-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Panfrost IRQ handler may stuck for a long time, for example this happens when there is a bad HDMI connection and HDMI handler takes a long time to finish processing, holding Panfrost. Make Panfrost's job timeout handler to sync IRQ before checking fence signal status in order to prevent spurious job timeouts due to a slow IRQ processing. Reviewed-by: Steven Price Reviewed-by: Boris Brezillon Reviewed-by: AngeloGioacchino Del Regno Tested-by: AngeloGioacchino Del Regno # MediaTek MT8192 and MT8195 Chromebooks Signed-off-by: Dmitry Osipenko --- Changelog: v4: - Improved comment like was suggested by Boris and added his r-b. v3: - Added comment to the code as was suggested by Boris - Added r-b/t-b from Steven and Angelo v2: - Moved synchronize_irq() after first signal-check to avoid unnecessary blocking on syncing. - Added warn message about high interrupt latency. drivers/gpu/drm/panfrost/panfrost_job.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index dbc597ab46fb..db6d9a17004f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -720,6 +720,22 @@ static enum drm_gpu_sched_stat panfrost_job_timedout(struct drm_sched_job if (dma_fence_is_signaled(job->done_fence)) return DRM_GPU_SCHED_STAT_NOMINAL; + /* + * Panfrost IRQ handler may take a long time to process an interrupt + * if there is another IRQ handler hogging the processing. + * For example, the HDMI encoder driver might be stuck in the IRQ + * handler for a significant time in a case of bad cable connection. + * In order to catch such cases and not report spurious Panfrost + * job timeouts, synchronize the IRQ handler and re-check the fence + * status. + */ + synchronize_irq(pfdev->js->irq); + + if (dma_fence_is_signaled(job->done_fence)) { + dev_warn(pfdev->dev, "unexpectedly high interrupt latency\n"); + return DRM_GPU_SCHED_STAT_NOMINAL; + } + dev_err(pfdev->dev, "gpu sched timeout, js=%d, config=0x%x, status=0x%x, head=0x%x, tail=0x%x, sched_job=%p", js, job_read(pfdev, JS_CONFIG(js)),