Commit dcddad6c authored by Boris Brezillon's avatar Boris Brezillon
Browse files

drm/panthor: Be robust against runtime PM resume failures in the suspend path



The runtime PM resume operation is not guaranteed to succeed, but if it
fails, the device should be in a suspended state. Make sure we're robust
to resume failures in the unplug path.

v3:
- Fix typo
- Add R-bs

v2:
- Move the bit that belonged in the next commit
- Drop the panthor_device_unplug() changes

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: default avatarAdrian Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241211075419.2333731-3-boris.brezillon@collabora.com
parent 4bd56ca8
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/iosys-map.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>

#include <drm/drm_drv.h>
#include <drm/drm_managed.h>
@@ -1190,11 +1191,13 @@ void panthor_fw_unplug(struct panthor_device *ptdev)

	cancel_delayed_work_sync(&ptdev->fw->watchdog.ping_work);

	/* Make sure the IRQ handler can be called after that point. */
	if (!IS_ENABLED(CONFIG_PM) || pm_runtime_active(ptdev->base.dev)) {
		/* Make sure the IRQ handler cannot be called after that point. */
		if (ptdev->fw->irq.irq)
			panthor_job_irq_suspend(&ptdev->fw->irq);

		panthor_fw_stop(ptdev);
	}

	list_for_each_entry(section, &ptdev->fw->sections, node)
		panthor_kernel_bo_destroy(section->mem);
@@ -1207,6 +1210,7 @@ void panthor_fw_unplug(struct panthor_device *ptdev)
	panthor_vm_put(ptdev->fw->vm);
	ptdev->fw->vm = NULL;

	if (!IS_ENABLED(CONFIG_PM) || pm_runtime_active(ptdev->base.dev))
		panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000);
}

+2 −1
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ void panthor_gpu_unplug(struct panthor_device *ptdev)
	unsigned long flags;

	/* Make sure the IRQ handler is not running after that point. */
	if (!IS_ENABLED(CONFIG_PM) || pm_runtime_active(ptdev->base.dev))
		panthor_gpu_irq_suspend(&ptdev->gpu->irq);

	/* Wake-up all waiters. */
+2 −1
Original line number Diff line number Diff line
@@ -2672,6 +2672,7 @@ int panthor_vm_prepare_mapped_bos_resvs(struct drm_exec *exec, struct panthor_vm
 */
void panthor_mmu_unplug(struct panthor_device *ptdev)
{
	if (!IS_ENABLED(CONFIG_PM) || pm_runtime_active(ptdev->base.dev))
		panthor_mmu_irq_suspend(&ptdev->mmu->irq);

	mutex_lock(&ptdev->mmu->as.slots_lock);