Re: [PATCH RFC 3/4] firmware: arm: Add PFDI run, result, and error injection support

From: Sudeep Holla

Date: Sun Nov 22 2026 - 16:06:22 EST


On Thu, Nov 19, 2026 at 03:36:05PM +0000, Ahmed Azeem wrote:
> From: Divin Raj <divin.raj@xxxxxxx>
>
> Extend the PFDI driver with ioctls to execute tests and manage results.
>
> Add support for PFDI_IOCTL_PE_TEST_RUN, PFDI_IOCTL_PE_TEST_RESULT, and
> PFDI_IOCTL_FORCE_ERROR, along with per-CPU state to serialize test
> execution. When firmware reports PFDI_RET_FAULT_FOUND, return the
> failing test identifier to userspace.
>
> Signed-off-by: Divin Raj <divin.raj@xxxxxxx>
> Signed-off-by: Ahmed Azeem <ahmed.azeem@xxxxxxx>
> ---
> drivers/firmware/arm_pfdi.c | 225 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 225 insertions(+)
>
> diff --git a/drivers/firmware/arm_pfdi.c b/drivers/firmware/arm_pfdi.c
> index 8c6d315b0572..22a69b12dbc8 100644
> --- a/drivers/firmware/arm_pfdi.c
> +++ b/drivers/firmware/arm_pfdi.c
> @@ -350,9 +543,35 @@ static long arm_pfdi_ioctl(struct file *file, unsigned int cmd,
> sizeof(count)))
> err = -EFAULT;
> break;
> + case PFDI_IOCTL_PE_TEST_RUN:
> + if (copy_from_user(&test_run, (void __user *)arg,
> + sizeof(test_run)))
> + return -EFAULT;
> +
> + err = pfdi_pe_run_tests(cpu, &test_run);
> + if (err == -EFAULT &&
> + copy_to_user((void __user *)arg, &test_run,
> + sizeof(test_run)))
> + err = -EFAULT;
> + break;
> + case PFDI_IOCTL_PE_TEST_RESULT:
> + err = pfdi_pe_get_result(cpu, &ft_id);
> + if (err == -EFAULT && copy_to_user((void __user *)arg, &ft_id,
> + sizeof(ft_id)))
> + err = -EFAULT;
> + break;
> case PFDI_IOCTL_FW_CHECK:
> err = pfdi_pe_fw_check(cpu);
> break;
> + case PFDI_IOCTL_FORCE_ERROR:
> + if (copy_from_user(&error_info, (void __user *)arg,
> + sizeof(error_info)))
> + return -EFAULT;
> + if (error_info.reserved)
> + return -EINVAL;

Do we really need a strict 1:1 mapping between the userspace IOCTLs and the
underlying firmware interface? Looking at the proposed commands, we might be
able to simplify things significantly:

1. RUN and TEST_RESULT could likely be combined into a single interface from a
userspace perspective.
2. I'm still unclear on the intended use case for FORCE_ERROR (echoing the
earlier question on the cover letter).
3 FW_CHECK feels like it belongs in driver initialization to catch boot-time
errors. Since it's hard to see how firmware could safely execute runtime tests
without OSPM awareness - despite what the spec suggests - exposing FW_CHECK to
userspace doesn't seem necessary.

Given that RUN appears to be the primary userspace entry point, would a simple
sysfs attribute be a better fit here than adding a new set of IOCTLs?

--
Regards,
Sudeep