From patchwork Fri Oct 11 22:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 13833230 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 1121ED1A427 for ; Fri, 11 Oct 2024 22:59:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A5A610EB37; Fri, 11 Oct 2024 22:59:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="NxfrxLdI"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DD6710EB37 for ; Fri, 11 Oct 2024 22:59:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1728687559; cv=none; d=zohomail.com; s=zohoarc; b=WjW1abGkQwA8Dk2uzIEWnYG5zIpa0GwBrr2rYJVVNUTtOanm6iKZVZpV2947o9yqGEwxvA7Ukvzz5uw97e18m5k4BjV2JxdmvmGlh22ILPFYEAKfGr6H2M63dw6pbuI7x83kp5hACFpl0/F69xJg3gHdDxKIcR8fo/CXXdC314k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728687559; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=jFfN6A7FKfkWOXVC2socfrJvDAKg5lUtpPic1FuxX5U=; b=TrQj6XseIwomwOlebXPGiD8nU2XnRc053EnIXqaqyz6G8uLRloJBcyplaZjpdd6d4gt7YagwsWt1XyMwm1p2GTQf1m6Bi0o0SZ8NSqs3HxzY5O/5OgE+HkqxbBByiQIlmkvYj9KXPBYaSOArGKH/jFQWbLQMKWLGyjEPVfKaqrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1728687559; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=jFfN6A7FKfkWOXVC2socfrJvDAKg5lUtpPic1FuxX5U=; b=NxfrxLdIRQ5g1iShqyqs8xqJIAYs3ge7+YFbiXJK2vDzmN3OLFcuEabizvlD6E93 eT8g7Bb9UBCVhlKPanzpzLZAG+YUFVGQTshF7VCUg67TMa79191cZgvKR7UM07UZFcc o1DQhYH9TuLyNfqBav5WhbSZfkR2Ht3WWwqN5jTM= Received: by mx.zohomail.com with SMTPS id 1728687557745482.7109764290499; Fri, 11 Oct 2024 15:59:17 -0700 (PDT) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, =?utf-8?q?Adri=C3=A1n_Larumbe?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/panthor: Fix runtime suspend sequence after OPP transition error Date: Fri, 11 Oct 2024 23:56:59 +0100 Message-ID: <20241011225906.3789965-1-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.46.2 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In case an OPP transition to a suspension state fails during the runtime PM suspend call, if the driver's subsystems were successfully resumed, we should return -EAGAIN so that the device's runtime PM status remains 'active'. If FW reload failed, then we should fall through, so that the PM core can flag the device as having suffered a runtime error. Signed-off-by: Adrián Larumbe Acked-by: Liviu Dudau for this patch. For the other two --- drivers/gpu/drm/panthor/panthor_device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c index 4082c8f2951d..cedd3cbcb47d 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -528,8 +528,13 @@ int panthor_device_suspend(struct device *dev) drm_dev_enter(&ptdev->base, &cookie)) { panthor_gpu_resume(ptdev); panthor_mmu_resume(ptdev); - drm_WARN_ON(&ptdev->base, panthor_fw_resume(ptdev)); - panthor_sched_resume(ptdev); + ret = panthor_fw_resume(ptdev); + if (!ret) { + panthor_sched_resume(ptdev); + ret = -EAGAIN; + } else { + drm_err(&ptdev->base, "FW resume failed at runtime suspend: %d\n", ret); + } drm_dev_exit(cookie); } From patchwork Fri Oct 11 22:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 13833231 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 55FF3D0EE3F for ; Fri, 11 Oct 2024 22:59:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D2E8010EB35; Fri, 11 Oct 2024 22:59:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="Emtr4hgR"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0148110EB30 for ; Fri, 11 Oct 2024 22:59:28 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1728687561; cv=none; d=zohomail.com; s=zohoarc; b=d6lOPDDbsXYajpqnWAEGCYjrycH1l1qhEpNvqkoVWLmToca0BxO5VFf6fqV/mzNhgej9vHJ8949vm40IpNZDiSCBBeFA69CBWf7X76N2yct8EKZUJQw9vcYUMbJOGiXIQUkidF/81CvlJ/Y8iy7tKLw1Vgd32oHuGjdjIPCvDZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728687561; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=sHHKPfHgZRs5gMzNFp3u//pQRXS+IebqOoINdKrWbgo=; b=ZNx4EaDIwYEQ3GeKyohIpzX/18QeBuMnr4jh4hTHyl00kXnMx7XM74OQhPlFNYxviO6Ubu+dhbDVXzrknIy5kgrXIMmBptpOpL/11Hg5jLSc2LM3AbjIISs3EOq0T9wlj/eZq0fq9tYd1/L5QU17hRNUzoR5+eXt/GUjp+zO6p4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1728687561; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=sHHKPfHgZRs5gMzNFp3u//pQRXS+IebqOoINdKrWbgo=; b=Emtr4hgRDMBCc0t7YaHcTnOylDr2tk60m9iWlDz//DIHiwOp1F+akQeOUkj3j6HI PIFM1CXDMG+D1GbKkRI12ew4CyEvSSx1+nAFQLoLRAfgpQisNZPp1YviDuISAX1JZ9I iy9HUm2QRo6SpccAtZ3wUEFBg/xZXhkq+cj1z988= Received: by mx.zohomail.com with SMTPS id 1728687560568724.2057795814977; Fri, 11 Oct 2024 15:59:20 -0700 (PDT) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, =?utf-8?q?Adri=C3=A1n_Larumbe?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] drm/panthor: Retry OPP transition to suspension state a few times Date: Fri, 11 Oct 2024 23:57:00 +0100 Message-ID: <20241011225906.3789965-2-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241011225906.3789965-1-adrian.larumbe@collabora.com> References: <20241011225906.3789965-1-adrian.larumbe@collabora.com> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the device's runtime PM suspend callback is invoked, the switch to a suspension OPP might sometimes fail. Although this is beyond the control of the Panthor driver, we can attempt suspending it more than once as a defensive strategy. Signed-off-by: Adrián Larumbe --- drivers/gpu/drm/panthor/panthor_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c index cedd3cbcb47d..5430557bd0b8 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -490,6 +490,7 @@ int panthor_device_resume(struct device *dev) int panthor_device_suspend(struct device *dev) { struct panthor_device *ptdev = dev_get_drvdata(dev); + unsigned int susp_retries; int ret, cookie; if (atomic_read(&ptdev->pm.state) != PANTHOR_DEVICE_PM_STATE_ACTIVE) @@ -522,7 +523,12 @@ int panthor_device_suspend(struct device *dev) drm_dev_exit(cookie); } - ret = panthor_devfreq_suspend(ptdev); + for (susp_retries = 0; susp_retries < 5; susp_retries++) { + ret = panthor_devfreq_suspend(ptdev); + if (!ret) + break; + } + if (ret) { if (panthor_device_is_initialized(ptdev) && drm_dev_enter(&ptdev->base, &cookie)) { From patchwork Fri Oct 11 22:57:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 13833232 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 3EF28D0EE3F for ; Fri, 11 Oct 2024 22:59:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B064910EB30; Fri, 11 Oct 2024 22:59:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="jV6OSLAC"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A3EC10EB30 for ; Fri, 11 Oct 2024 22:59:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1728687565; cv=none; d=zohomail.com; s=zohoarc; b=L/DkJbT2fEVZh3m/Sthe5Wrto6eOepPoX/wkMqTiaWKDduRVbcdCEU9cSMsoC5sEYOWTYP+DiX41NpBCLQVdQPUCfnXIOs6jLsc46vo/lhrTgudPOdtUbCTBjMyXoJLzuoXmBnD+e0OZm0zvhSdHcJ9RBrbZe5pLdpJpHcYs2Q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728687565; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=yrZlf5QwOEdnfLB/WKbk+uAHUVygWYrAIalCbzVETTc=; b=iH781o8qFyT4VbCsq6j3Jbelou3dRrlftsRuhlvPGt3ichCx7zgbO60YLKkxwWwZ7jNn2hCnzH20na+UJB90TiIEBcG4HNgtAw497nteVmVAKj+YyN6AhRCRFIEGpJsEhNvs6Ui3ls4INofeXei9wsY3SKMAoE6vsTnmV5U+HLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1728687565; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=yrZlf5QwOEdnfLB/WKbk+uAHUVygWYrAIalCbzVETTc=; b=jV6OSLACowetuJB2r5KCPPMT6tAJDig4MlQM+zeCXflCDO3edBgv0AwKc30wRzN9 B3JZjbNV/0jJFSxPuvskTUBdm4IuR94GiNou9NL6hRr2S76J//pb6fSLpIm4mFdnc1P z3+pjTwuhKJU9+uXgIVjbdO1/ZyPBvWzvL5/eTe4= Received: by mx.zohomail.com with SMTPS id 1728687563354474.83172060251206; Fri, 11 Oct 2024 15:59:23 -0700 (PDT) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, =?utf-8?q?Adri=C3=A1n_Larumbe?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/panthor: Rreset device and load FW after failed PM suspend Date: Fri, 11 Oct 2024 23:57:01 +0100 Message-ID: <20241011225906.3789965-3-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241011225906.3789965-1-adrian.larumbe@collabora.com> References: <20241011225906.3789965-1-adrian.larumbe@collabora.com> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On rk3588 SoCs, during a runtime PM suspend, the transition to the lowest voltage/frequency pair might sometimes fail for reasons not yet understood. In that case, even a slow FW reset will fail, leaving the device's PM runtime status as unusuable. When that happens, successive attempts to resume the device upon running a job will always fail. Fix it by forcing a synchronous device reset, which will lead to a successful FW reload, and also reset the device's PM runtime error status before resuming it. Signed-off-by: Adrián Larumbe --- drivers/gpu/drm/panthor/panthor_device.c | 10 ++++++++++ drivers/gpu/drm/panthor/panthor_device.h | 2 ++ drivers/gpu/drm/panthor/panthor_sched.c | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c index 5430557bd0b8..ec6fed5e996b 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -105,6 +105,16 @@ static void panthor_device_reset_cleanup(struct drm_device *ddev, void *data) destroy_workqueue(ptdev->reset.wq); } +int panthor_device_reset_sync(struct panthor_device *ptdev) +{ + panthor_fw_pre_reset(ptdev, false); + panthor_mmu_pre_reset(ptdev); + panthor_gpu_soft_reset(ptdev); + panthor_gpu_l2_power_on(ptdev); + panthor_mmu_post_reset(ptdev); + return panthor_fw_post_reset(ptdev); +} + static void panthor_device_reset_work(struct work_struct *work) { struct panthor_device *ptdev = container_of(work, struct panthor_device, reset.work); diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h index 0e68f5a70d20..05a5a7233378 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -217,6 +217,8 @@ struct panthor_file { int panthor_device_init(struct panthor_device *ptdev); void panthor_device_unplug(struct panthor_device *ptdev); +int panthor_device_reset_sync(struct panthor_device *ptdev); + /** * panthor_device_schedule_reset() - Schedules a reset operation */ diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index c7b350fc3eba..9a854c8c5718 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -3101,6 +3101,13 @@ queue_run_job(struct drm_sched_job *sched_job) return dma_fence_get(job->done_fence); } + if (ptdev->base.dev->power.runtime_error) { + ret = panthor_device_reset_sync(ptdev); + if (drm_WARN_ON(&ptdev->base, ret)) + return ERR_PTR(ret); + drm_WARN_ON(&ptdev->base, pm_runtime_set_active(ptdev->base.dev)); + } + ret = pm_runtime_resume_and_get(ptdev->base.dev); if (drm_WARN_ON(&ptdev->base, ret)) return ERR_PTR(ret);