From nobody Wed Apr 15 18:09:01 2026 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBA4533689F for ; Tue, 3 Mar 2026 22:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772577890; cv=none; b=BxODXvGid1mPdwxIKZZehhDQuuGwEd4DhAhYPWbgwY2ZKdn8eLWp73g+LjPNi7L/ED5eiyUDR3dLkm9Uui5IOmBOJppRK+UyK2WUh9QOemNJoswA2WCFY4Py9ZfumFsAzVQMpmusTJQexi2OjLyu8HDCGKRW1vdPCHzAIdaEXk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772577890; c=relaxed/simple; bh=vocxs+BPqLJQE6NcG0LaZ1x2NcKOp7F8SoxvbumZRdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hCJmXBF6eggkEmiG9XhXtvSTQMjiKktxskGGIJBC9mxFJ2W6JTL2anpRNk/x6C0Nx8iom442xyEVdTKpis1Bg4aOxYhDtddAKgtjO+5Kt8ks6oIksAJ5dS2dC4JC7duwwJrUd6gHCPGQ75ujD/f9E9UKQMABvsGR+jJKTw/5UoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k8xHhWbv; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k8xHhWbv" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-8c710439535so401512985a.1 for ; Tue, 03 Mar 2026 14:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772577888; x=1773182688; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XWqHm0lK8kD8q+CNsdN3MvQwv8WuKF8UZ6conx+K6xw=; b=k8xHhWbvO3exEq6dWyRZ7DtuKYCkYhTKC6RL4jxk7bMLeXQlWMbAhC0/PC/T0pJ4lO HtdbcikhbuRtTh4h/ffSgeN7z1tZ65G7/oHoradmyLZ4ZwgzqkDh6z7tZHaU11VQflCr 9hEFoZSqFQ1+gpzuy+uQt4B7Rh/nbUyZqOIU0u9PMG4Is/jXrR/XI4gaXKVmKShQQXnF Y0usBZtYUvj8J8QUVXKSN37MAOusBsp7ZNPx94QbMfRRQHo+/VnND2ArJH0bKD+VcVbx DVNxAdwV0vVRetu626NmtLgFkIqgFWRNw0qM/OcI6im48fXcEPNGNeC0UCmoaSSgKcl0 JFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772577888; x=1773182688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XWqHm0lK8kD8q+CNsdN3MvQwv8WuKF8UZ6conx+K6xw=; b=ugUqg43O5hQEAfS8J4jYqr/o1LvjbHP6f5u8ns25LaFfLulGnVpPfUnWSNwn11R/pL Iz/pb2lcx2g08f9F5pu99lrLVcXn4kbPJCzPR2otaLz7UvH1rl/MkVs9VbJOrpy7hzXf 96+pGuIAb7lYxTerKxEXVWOzsl4IIHgn5ZOa5RJVboJBaVriUI0Ml5GGDDCdgTjeEX13 3+VVXAHxdEEyKpIYg0uXnhBeTLKWfK610AdzrpLfdBNAFw9ipzo0tjs1VPAfh5R0JEbD PtamGG1IjBhwGmePMuzZoPLCmSwyoZHOb8QixG6T08p9G+pbkW7wkm6maYwdc6eXWtKA KCcQ== X-Forwarded-Encrypted: i=1; AJvYcCVm+n+swy8oIcm8vs3+Ft/3ip/VE0fud2XLoEnxwN1qL1m/FSqLCUIMYqsoAeK6HDg/OM2u9fu6ZjGxmsg=@vger.kernel.org X-Gm-Message-State: AOJu0YzUx/FyTjYgCFSm3q/3dGG6XoADfpdHGtllav+EvPRBPk8ymXt1 o3o4sJdxkGT6lnxDFNUsuh2PBV1fyoy6wwsvz64Nd0mSZhdHbFWEX0d0 X-Gm-Gg: ATEYQzzKH9Wy6GAzJTQX2tB/JYipvRxQSoTYpmsoxD4N64v3PpC8YfUUy7Q8n8CodsC y9oSy6QkbGP5gU+da/PIsovkfVfWE2Uc+7sSsn+oTI0IshOB4pN4FbgrPHnG84eXJ93tlXciQfL EhqDyoOV8wpjZ04d2IB8g6bZ9DUnLyuoMa/0IlcqUrzjSvrZJDQ1VCJQzBgsYKu2v98dqXE5tnV 9WqXW0+IA+QcEdwDqsynNhn0ZPy5UWOOs8Gs6aqtBaEOtuvTPoVSRobWiE6MUKwAJepRBT5iIb8 XFCVQRruWbolmjBrRU4vqZeknrwNg/RA2SJVWClORqOjUoUiWCb3YFAmgVKBNhWP4z7r84tjqh3 GNr7vUHcohcg1FMhv/qJeOWBv6FtLuvESmWfb9ZQpYAB1qzBP1l7HTG71pDaRMWpD3/KilrZbUu sTxQXFwYeOj5Je/nVETwa2wWUKisrujxSoB9u0UfP+cjBZ5dxZq9y5gugTKcPl4Ze44aRZswoP X-Received: by 2002:a05:620a:4481:b0:8c6:ee09:5eae with SMTP id af79cd13be357-8cd5adb8d1cmr12815285a.0.1772577887713; Tue, 03 Mar 2026 14:44:47 -0800 (PST) Received: from hp-strix-cachyos.localdomain ([174.95.22.172]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-899fc21676fsm54778816d6.22.2026.03.03.14.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 14:44:47 -0800 (PST) From: Kinn Coelho Juliao To: linux-media@vger.kernel.org Cc: Bin.Du@amd.com, pratap.nirujogi@amd.com, mario.limonciello@amd.com, sultan@kerneltoast.com, linux-kernel@vger.kernel.org, Kinn Coelho Juliao Subject: [PATCH] media: amd: isp4: add system suspend/resume support Date: Tue, 3 Mar 2026 17:44:33 -0500 Message-ID: <20260303224433.87242-1-kinncj@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302073020.148277-1-Bin.Du@amd.com> References: <20260302073020.148277-1-Bin.Du@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The ISP4 capture platform driver currently has no dev_pm_ops. When the driver is loaded during a session, the ISP hardware is left in an active state on s2idle suspend, causing the system to hang and requiring a hard power-off. Add suspend and resume callbacks that properly tear down the ISP firmware and hardware state before sleep via isp4sd_pwroff_and_deinit(). On resume, the device is marked so that userspace re-opens the camera, which triggers isp4sd_pwron_and_init() to reinitialize the hardware. Tested on HP ZBook Ultra G1a (AMD Ryzen AI MAX+ PRO 395, Strix Halo) with CachyOS kernel 6.19.5 =E2=80=94 multiple suspend/resume cycles with the camera active before suspend complete successfully. Signed-off-by: Kinn Coelho Juliao --- drivers/media/platform/amd/isp4/isp4.c | 48 ++++++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 1 + 2 files changed, 49 insertions(+) diff --git a/drivers/media/platform/amd/isp4/isp4.c b/drivers/media/platfor= m/amd/isp4/isp4.c index bf6b8e2..3e2c3bc 100644 --- a/drivers/media/platform/amd/isp4/isp4.c +++ b/drivers/media/platform/amd/isp4/isp4.c @@ -4,6 +4,7 @@ */ =20 #include +#include #include #include #include @@ -221,11 +222,58 @@ static void isp4_capture_remove(struct platform_devic= e *pdev) media_device_cleanup(&isp_dev->mdev); } =20 +static int isp4_capture_suspend(struct device *dev) +{ + struct isp4_device *isp_dev =3D dev_get_drvdata(dev); + struct isp4_subdev *isp_subdev; + struct isp4_interface *ispif; + int ret; + + if (!isp_dev) + return 0; + + isp_subdev =3D &isp_dev->isp_subdev; + ispif =3D &isp_subdev->ispif; + + if (ispif->status =3D=3D ISP4IF_STATUS_PWR_OFF) + return 0; + + dev_info(dev, "tearing down fw and hw state for suspend\n"); + + ret =3D isp4sd_pwroff_and_deinit(&isp_subdev->sdev); + if (ret) + dev_err(dev, "suspend teardown failed: %d\n", ret); + + isp_dev->was_powered_before_suspend =3D true; + + return 0; +} + +static int isp4_capture_resume(struct device *dev) +{ + struct isp4_device *isp_dev =3D dev_get_drvdata(dev); + + if (!isp_dev) + return 0; + + if (isp_dev->was_powered_before_suspend) { + dev_info(dev, "ISP was active before suspend, camera must be reopened\n"= ); + isp_dev->was_powered_before_suspend =3D false; + } + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(isp4_capture_pm_ops, + isp4_capture_suspend, + isp4_capture_resume); + static struct platform_driver isp4_capture_drv =3D { .probe =3D isp4_capture_probe, .remove =3D isp4_capture_remove, .driver =3D { .name =3D ISP4_DRV_NAME, + .pm =3D pm_sleep_ptr(&isp4_capture_pm_ops), } }; =20 diff --git a/drivers/media/platform/amd/isp4/isp4.h b/drivers/media/platfor= m/amd/isp4/isp4.h index 2db6683..f39be96 100644 --- a/drivers/media/platform/amd/isp4/isp4.h +++ b/drivers/media/platform/amd/isp4/isp4.h @@ -13,6 +13,7 @@ struct isp4_device { struct v4l2_device v4l2_dev; struct isp4_subdev isp_subdev; struct media_device mdev; + bool was_powered_before_suspend; }; =20 void isp4_intr_enable(struct isp4_subdev *isp_subdev, u32 index, bool enab= le); --=20 2.53.0