Re: [PATCH v5 10/13] drm/panthor: Use a copy of suspend buffer sizes
From: Boris Brezillon
Date: Tue Dec 01 2026 - 06:07:39 EST
On Mon, 16 Nov 2026 12:25:58 +0100
Ketil Johnsen <ketil.johnsen@xxxxxxx> wrote:
> Store the suspend buffer sizes (normal and protected) provided by FW
> after FW start. Unsafe to read directly from FW as these will return
> zero between FW load and FW start.
>
> Signed-off-by: Ketil Johnsen <ketil.johnsen@xxxxxxx>
Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
>
> ---
>
> v5:
> - First version of this patch in this patch set.
> - This change was previously in a different patch in the set.
> ---
> drivers/gpu/drm/panthor/panthor_fw.c | 25 +++++++++++++++++++++++++
> drivers/gpu/drm/panthor/panthor_fw.h | 3 +++
> drivers/gpu/drm/panthor/panthor_sched.c | 6 +++---
> 3 files changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
> index fc07796fc9ef7..b565b362f401f 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw.c
> +++ b/drivers/gpu/drm/panthor/panthor_fw.c
> @@ -255,6 +255,12 @@ struct panthor_fw {
> /** @iface: FW interfaces. */
> struct panthor_fw_iface iface;
>
> + /** @suspend_size: Size of regular suspend buffer */
> + u32 suspend_size;
> +
> + /** @protm_suspend_size: Size of protected suspend buffer size */
> + u32 protm_suspend_size;
> +
> /** @watchdog: Collection of fields relating to the FW watchdog. */
> struct {
> /** @ping_work: Delayed work used to ping the FW. */
> @@ -549,6 +555,16 @@ panthor_fw_alloc_suspend_buf_mem(struct panthor_device *ptdev, size_t size)
> "FW suspend buffer");
> }
>
> +u32 panthor_fw_suspend_size(struct panthor_device *ptdev)
> +{
> + return ptdev->fw->suspend_size;
> +}
> +
> +u32 panthor_fw_protm_suspend_size(struct panthor_device *ptdev)
> +{
> + return ptdev->fw->protm_suspend_size;
> +}
> +
> static u32 section_vm_map_flags(const struct panthor_fw_section *section)
> {
> u32 cache_mode = section->flags &
> @@ -985,6 +1001,15 @@ static int panthor_init_csg_iface(struct panthor_device *ptdev,
> return -EINVAL;
> }
>
> + if (!csg_idx) {
> + /* We make a copy of these sizes, as csg_iface can read these
> + * as zero during full GPU reset, between FW sections being
> + * reloaded and FW fully booted.
> + */
> + ptdev->fw->suspend_size = csg_iface->control->suspend_size;
> + ptdev->fw->protm_suspend_size = csg_iface->control->protm_suspend_size;
> + }
> +
> if (csg_idx > 0) {
> struct panthor_fw_csg_iface *first_csg_iface =
> panthor_fw_get_csg_iface(ptdev, 0);
> diff --git a/drivers/gpu/drm/panthor/panthor_fw.h b/drivers/gpu/drm/panthor/panthor_fw.h
> index 4eda8f8e714c1..b3bf00191a96b 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw.h
> +++ b/drivers/gpu/drm/panthor/panthor_fw.h
> @@ -511,6 +511,9 @@ panthor_fw_alloc_queue_iface_mem(struct panthor_device *ptdev,
> struct panthor_kernel_bo *
> panthor_fw_alloc_suspend_buf_mem(struct panthor_device *ptdev, size_t size);
>
> +u32 panthor_fw_suspend_size(struct panthor_device *ptdev);
> +u32 panthor_fw_protm_suspend_size(struct panthor_device *ptdev);
> +
> struct panthor_vm *panthor_fw_vm(struct panthor_device *ptdev);
>
> void panthor_fw_pre_reset(struct panthor_device *ptdev, bool on_hang);
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index ca6aa6a55661a..9c78f04d4f30a 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -4058,7 +4058,7 @@ int panthor_group_create(struct drm_file *file,
> struct panthor_scheduler *sched = ptdev->scheduler;
> struct panthor_fw_csg_iface *csg_iface = panthor_fw_get_csg_iface(ptdev, 0);
> struct panthor_group *group = NULL;
> - u32 gid, i, suspend_size;
> + u32 gid, i;
> int ret;
>
> if (group_args->pad)
> @@ -4109,8 +4109,8 @@ int panthor_group_create(struct drm_file *file,
> goto err_put_group;
> }
>
> - suspend_size = csg_iface->control->suspend_size;
> - group->suspend_buf = panthor_fw_alloc_suspend_buf_mem(ptdev, suspend_size);
> + group->suspend_buf =
> + panthor_fw_alloc_suspend_buf_mem(ptdev, panthor_fw_suspend_size(ptdev));
> if (IS_ERR(group->suspend_buf)) {
> ret = PTR_ERR(group->suspend_buf);
> group->suspend_buf = NULL;