Commit Graph

3656 Commits

Author SHA1 Message Date
Rahul Kumar Yadav
d415b45bdc LF-15637: drivers: firmware: imx: se: fix ELE Get FW version API
Fix ELE Get FW version API, to get invoked only for ELE platforms.

Signed-off-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
2025-06-20 08:11:02 +02:00
Meenakshi Aggarwal
7fcf608527 LF-14837: Unregister ELE TRNG
Issue: ELE TRNG register with hwrng and open a kthread
which remains running after suspend also and results in
random interrupts from ELE.

Fix: unregister hwrng in suspend and re-register in resume

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2025-06-11 08:05:04 +02:00
Meenakshi Aggarwal
296c64f096 LF-15348: firmware: imx: Add ioctl flag
Add ioctl flag to reset the shared memory position.

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2025-06-11 08:04:56 +02:00
Pankaj Gupta
89391c3b3d LF-14885-2: drivers: firmware: imx: se: enable dual FW support
Enables dual FW support for i.MX95
- loading of runtime fw from rootfs.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:40:15 +08:00
Pankaj Gupta
8406270373 LF-14885: drivers: firmware: imx: se: add ele-get-fw-version
Adds a new API ELE_GET_FW_VERSION, to fetch the FW version and other
misc. details.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:40:10 +08:00
Pankaj Gupta
934c85903f LF-15060: drivers: firmware: imx: se: Enables support of i.MX95 rev B0
Enables the support for V2X-SG#0 & V2X-SG#1 on i.MX95 B0.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:40:06 +08:00
Pankaj Gupta
9d86c4874b LF-14029-1: drivers: firmware: imx: new api v2x debug dump
New API support is added for dumping v2x debug logs.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:40:02 +08:00
Pankaj Gupta
d97abaf3e7 LF-14029: drivers: firmware: imx: v2x suspend resume
As part linux suspend resume, v2x-fw is requested to:
- power-down as part of suspend.
- power-up as part of resume.

Squash: 8fd2c1e95e24a ("TBS: drivers: firmware: imx: replace the hardcoded debugging address.")
 4a6e34427205b TBS: LF-14638: driver: firmware: imx: v2x suspend-resume snd-rcv error checking

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:56 +08:00
Pankaj Gupta
af7dddaced LF-14060-1: drivers: firmware: imx: msg-seq flow applied
imx: Enforcing the msg-seq flow feature is applied
to change voltage API(s).

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Tested-by: Ye Li <ye.li@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:49 +08:00
Pankaj Gupta
9773681cdd LF-14060: drivers: firmware: imx: enforce msg-seq flow
New kernel feature to enforce the msg-seq flow:
- Once started before the first API,
- will continue for all the intermediate participating API(s),
- will halt after the last API successfully exchanged.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Tested-by: Ye Li <ye.li@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:39 +08:00
Pankaj Gupta
88996dad6b LF-13910-9: drivers: firmware: imx: add IOCTL for performance benchmarking
add IOCTL for performance benchmarking

Squash: 1937148af0929 ("TBS: drivers: firmware: imx: ioctl: includes header file")
Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Signed-off-by: Nikhil Singla <nikhil.singla@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:31 +08:00
Pankaj Gupta
4faa6aeb8b LF-13910-8: drivers: firmware: imx: add support for i.MX8DXL/QXP/QM
add support for i.MX8DXL/QXP/QM

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:24 +08:00
Pankaj Gupta
9e7d5cc9f6 LF-13910-7: drivers: firmware: imx: add support for i.MX95 soc
add support for i.MX95 soc

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:18 +08:00
Pankaj Gupta
b47a70ecb1 LF-13910-6: drivers: firmware: imx: export se-api(s) in se_api.h
export se-api(s) in se_api.h:
- for reading/writing fuses
- for voltage control interface.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:11 +08:00
Pankaj Gupta
c44540c6a8 LF-13910-5: drivers: firmware: imx: add support for imx93 soc
Add support for imx93 soc and its platforms.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:39:03 +08:00
Pankaj Gupta
2c2034c656 LF-13910-4: drivers: firmware: imx: se debug dump log file
Debugging feature to enable time synchronised logging of:
- the Message exchange over MU with FW.
- IOCTL(s)
- any user articulated debug messages.

The logs are saved to a file in the linux filesystem.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:38:55 +08:00
Pankaj Gupta
ad497d1c5b LF-13910-3: firmware: imx: additional changes to the upstream driver.
additional changes to the upstream driver.
- construct se_name from se_type_id and instance id
- move soc_register to info_list
- move fetch soc info function pointer to info_list
- ele soc fetch generalization
- ele debug dump

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:38:49 +08:00
Pankaj Gupta
9dfd27b6b2 LF-13910-2: firmware: imx: add miscdev
Add the driver for communication interface to secure-enclave,
for exchanging messages with NXP secure enclave HW IP(s) like
EdgeLock Enclave from:
- User-Space Applications via character driver.

ABI documentation for the NXP secure-enclave driver.

User-space library using this driver:
- i.MX Secure Enclave library:
  -- URL: https://github.com/nxp-imx/imx-secure-enclave.git,
- i.MX Secure Middle-Ware:
  -- URL: https://github.com/nxp-imx/imx-smw.git

Squash: <8e91220ab110> ("drivers: fw: imx: increased wait-timeout value")
Squash: <a0c004d35ef4> ("firmware:imx: Fix cleanup of SE driver")
Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:38:41 +08:00
Pankaj Gupta
a21e6e64e3 LF-13910-1: firmware: imx: add driver for NXP EdgeLock Enclave
NXP hardware IP(s) for secure-enclaves like Edgelock Enclave(ELE),
are embedded in the SoC to support the features like HSM, SHE & V2X,
using message based communication interface.

The secure enclave FW communicates on a dedicated messaging unit(MU)
based interface(s) with application core, where kernel is running.
It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93.

This patch adds the driver for communication interface to secure-enclave,
for exchanging messages with NXP secure enclave HW IP(s) like EdgeLock
Enclave (ELE) from Kernel-space, used by kernel management layers like
- DM-Crypt.

squash e7d2fac2d1ceb TBS: LF-14067: drivers: firmware: imx: se suspend-resume
squash c4c9b2f7cf710 TBS: drivers: firmware: imx: correct macro ELE_DEBUG_DUMP_RSP_SZ value

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Acked-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Acked-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:38:08 +08:00
Pankaj Gupta
bdeff7cd56 LF-13910: remove base driver for secure-enclave
remove base driver for secure-enclave

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-28 10:37:55 +08:00
Rahul Kumar Yadav
aa31dd8e0b LF-13853: firmware: imx: se-fw: fix uninitialized err variable
Initialized the err variable to fix the coverity issue,
"Uninitialized scalar variable"

Signed-off-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-11-11 14:20:22 +01:00
Pankaj Gupta
acc316c606 LF-13448 : drivers: firmware: imx: FW abort indication
Secure-enclave FW drivers enhanced to publish the FW abort
indication with an error print.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2024-10-22 15:47:22 +05:30
Meenakshi Aggarwal
fcab0c7e9b LF-13675: imx: Support to run SHE NVM on debug MU
Change CMD and RSP tag id of dubug MU for i.MX95
to support running SHE NVM on Debug MU

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
2024-10-17 11:32:44 +02:00
Peng Fan
606344d6d5 LF-13374 firmware: arm_scmi: mailbox: enlarge rx timeout to 5000ms
When doing jailhouse test, there is possibility that interrupts are
disabled for long time. So enlarge rx timeout to avoid scmi timeout.

Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2024-10-09 17:48:37 +08:00
Jason Liu
239f62168d This is the 6.6.51 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmbisF0ACgkQONu9yGCS
 aT5Y8xAAqS/rmrC+/qlFvbtAqK+KXLq9BIGvDHW2QHfCyMpSZ6isehVhh64apHE/
 /XvJ6a+2iPVp5o52iDTUKzbcDr3Jx/QwhS8Xa/HyQQy1rXIPpJNJb8Vuvkn/B2Cq
 cPCfTtfPZUUQTd09uAdBhy5NT8hsT2kSVpmSXDnahn9ih8k0tR40udw5Qf7xpWcf
 HqljbfonLP86mF/SB9m+VhDGF9fekujyb+0iS0OPE+TdvSjKB9ySoeL4PIeTSxrz
 goZdp9ygAYy8Bks825ztbfQszqIwceHU/xZRaUrGfOOk4A5kwTmbdUQu7ooMc+5F
 kbpifbewmY1UGn2KTxgj59xCjQ7HLQe+sqacy0/gALzRSajUNyjLn0n4w3UqaJWb
 pf+gwqHBLgDRfvWctggEdY2ApKgOlM9D7TTpWWB9uv1oR/g3PGfgehZgrMMPgPUw
 EZ8JiwnITfRaRFiH/vSR3aJKRj6qjb4mX3/U8HgGcACtyFfHgtuI7jzhnX36fRNO
 FG38bxSUMrJnlohghfBl6zyaruZBMHVaoQzs6MYZ7qrVvCbt3CHivJdaQ85nw0h7
 YHa2zYFfT0ztyaSMzWq6JatgI7BZfd8PjobhbRZADBBD39KC8aL8XLoDPnpzWMUY
 UDlK8n96gOKo0t8ILDWcIisCVGNogcHJlGppC8Fu7ZyKzYsMhN4=
 =OEL/
 -----END PGP SIGNATURE-----

Merge tag 'v6.6.51' into lf-6.6.y

This is the 6.6.51 stable release

* tag 'v6.6.51': (2369 commits)
  Linux 6.6.51
  Bluetooth: hci_sync: Fix UAF on hci_abort_conn_sync
  Bluetooth: hci_sync: Fix UAF on create_le_conn_complete
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/imx8mp.dtsi
	arch/arm64/boot/dts/freescale/imx93.dtsi
	drivers/dma/fsl-edma-common.c
	drivers/dma/fsl-edma-common.h
	drivers/dma/fsl-edma.c
	drivers/irqchip/irq-imx-irqsteer.c
	drivers/perf/fsl_imx9_ddr_perf.c
	drivers/spi/spi-fsl-lpspi.c
	sound/soc/sof/imx/imx8m.c
2024-09-24 11:49:41 +08:00
Richard Fitzgerald
441e6f5829 firmware: cs_dsp: Don't allow writes to read-only controls
[ Upstream commit 62412a9357 ]

Add a check to cs_dsp_coeff_write_ctrl() to abort if the control
is not writeable.

The cs_dsp code originated as an ASoC driver (wm_adsp) where all
controls were exported as ALSA controls. It relied on ALSA to
enforce the read-only permission. Now that the code has been
separated from ALSA/ASoC it must perform its own permission check.

This isn't currently causing any problems so there shouldn't be any
need to backport this. If the client of cs_dsp exposes the control as
an ALSA control, it should set permissions on that ALSA control to
protect it. The few uses of cs_dsp_coeff_write_ctrl() inside drivers
are for writable controls.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20240702110809.16836-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-09-12 11:11:35 +02:00
Murali Nalajala
cdf7efe4b0 firmware: qcom: scm: Mark get_wq_ctx() as atomic call
commit 9960085a3a upstream.

Currently get_wq_ctx() is wrongly configured as a standard call. When two
SMC calls are in sleep and one SMC wakes up, it calls get_wq_ctx() to
resume the corresponding sleeping thread. But if get_wq_ctx() is
interrupted, goes to sleep and another SMC call is waiting to be allocated
a waitq context, it leads to a deadlock.

To avoid this get_wq_ctx() must be an atomic call and can't be a standard
SMC call. Hence mark get_wq_ctx() as a fast call.

Fixes: 6bf3259922 ("firmware: qcom: scm: Add wait-queue handling logic")
Cc: stable@vger.kernel.org
Signed-off-by: Murali Nalajala <quic_mnalajal@quicinc.com>
Signed-off-by: Unnathi Chalicheemala <quic_uchalich@quicinc.com>
Reviewed-by: Elliot Berman <quic_eberman@quicinc.com>
Link: https://lore.kernel.org/r/20240814223244.40081-1-quic_uchalich@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-04 13:28:28 +02:00
Vabhav Sharma
3da9266a17 LF-12610: drivers: se_fw: fix signed message support
signed message ioctl() is not available due to which
test will fail on i.MX8X SECO that have signed message
 not null.

Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-09-03 09:22:23 +02:00
Meenakshi Aggarwal
b6ee9559b3 LF-13063:imx:se_fw: Add board_type information in soc info structure
Update soc_info structure to have board_type information.
board_type is deduced by reading fuse values using nvmem framework

get_soc_info ioctl is updated to return board_type for i.MX8dxl

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2024-08-30 11:14:20 +02:00
Richard Fitzgerald
664ad87c36 firmware: cirrus: cs_dsp: Initialize debugfs_root to invalid
[ Upstream commit 66626b1563 ]

Initialize debugfs_root to -ENODEV so that if the client never sets a
valid debugfs root the debugfs files will not be created.

A NULL pointer passed to any of the debugfs_create_*() functions means
"create in the root of debugfs". It doesn't mean "ignore".

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://msgid.link/r/20240307105353.40067-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-29 17:33:38 +02:00
Thomas Zimmermann
a168da3182 firmware/sysfb: Update screen_info for relocated EFI framebuffers
[ Upstream commit 78aa89d1df ]

On ARM PCI systems, the PCI hierarchy might be reconfigured during
boot and the firmware framebuffer might move as a result of that.
The values in screen_info will then be invalid.

Work around this problem by tracking the framebuffer's initial
location before it get relocated; then fix the screen_info state
between reloaction and creating the firmware framebuffer's device.

This functionality has been lifted from efifb. See the commit message
of commit 55d728a40d ("efi/fb: Avoid reconfiguration of BAR that
covers the framebuffer") for more information.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240212090736.11464-8-tzimmermann@suse.de
Stable-dep-of: c2bc958b2b ("fbdev: vesafb: Detect VGA compatibility from screen info's VESA attributes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-11 12:47:16 +02:00
Thomas Zimmermann
5b4d995dfd video: Add helpers for decoding screen_info
[ Upstream commit 75fa9b7e37 ]

The plain values as stored in struct screen_info need to be decoded
before being used. Add helpers that decode the type of video output
and the framebuffer I/O aperture.

Old or non-x86 systems may not set the type of video directly, but
only indicate the presence by storing 0x01 in orig_video_isVGA. The
decoding logic in screen_info_video_type() takes this into account.
It then follows similar code in vgacon's vgacon_startup() to detect
the video type from the given values.

A call to screen_info_resources() returns all known resources of the
given screen_info. The resources' values have been taken from existing
code in vgacon and vga16fb. These drivers can later be converted to
use the new interfaces.

v2:
	* return ssize_t from screen_info_resources()
	* don't call __screen_info_has_lfb() unnecessarily

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240212090736.11464-2-tzimmermann@suse.de
Stable-dep-of: c2bc958b2b ("fbdev: vesafb: Detect VGA compatibility from screen info's VESA attributes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-11 12:47:15 +02:00
Ye Li
128b768e49 LF-13112 firmware: se_fw: Re-install FW for 8ULP ELE iMEM lost
When running below low power case on 8ULP dual boot, we meet Linux fail to
restore ELE imem from file

APD: Linux boot, then “poweroff” to DPD.
RTD: After linux “poweroff”, enter DPD and wake up by timer (G+T+2)
     then enter PD and wake up by timer (F+T+2), wake up APD (W).

The root cause is when RTD is waken up from DPD, it is booted from ROM,
and ROM reloads the ELE FW and RTD image. Then when RTD is waken up from PD
and wake up APD, APD will try to restore the ELE imem which was saved
before ELE FW reloading. So this imem restore is failed.

To avoid moving ELE imem save/restore to M33, because of RAM size problem
and big codes change. The proposed solution is replacing the imem restore
from file with re-install ELE FW. This patch needs to work with ELE FW
which supports the re-install feature.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2024-08-07 18:27:26 +08:00
Qiang Ma
f17cbe5545 efi/libstub: Zero initialize heap allocated struct screen_info
commit ee8b8f5d83 upstream.

After calling uefi interface allocate_pool to apply for memory, we
should clear 0 to prevent the possibility of using random values.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
Cc: <stable@vger.kernel.org> # v6.6+
Fixes: 732ea9db9d ("efi: libstub: Move screen_info handling to common code")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-03 08:54:22 +02:00
Ard Biesheuvel
d849da88f7 x86/efistub: Revert to heap allocated boot_params for PE entrypoint
commit ae835a96d7 upstream.

This is a partial revert of commit

  8117961d98 ("x86/efi: Disregard setup header of loaded image")

which triggers boot issues on older Dell laptops. As it turns out,
switching back to a heap allocation for the struct boot_params
constructed by the EFI stub works around this, even though it is unclear
why.

Cc: Christian Heusel <christian@heusel.eu>
Reported-by: <mavrix#kernel@simplelogin.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-03 08:54:12 +02:00
Ard Biesheuvel
c12db5aa54 x86/efistub: Avoid returning EFI_SUCCESS on error
commit fb318ca0a5 upstream.

The fail label is only used in a situation where the previous EFI API
call succeeded, and so status will be set to EFI_SUCCESS. Fix this, by
dropping the goto entirely, and call efi_exit() with the correct error
code.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-03 08:54:12 +02:00
Marek Behún
d027ac4a08 firmware: turris-mox-rwtm: Initialize completion before mailbox
[ Upstream commit 49e24c80d3 ]

Initialize the completion before the mailbox channel is requested.

Fixes: 389711b374 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:35 +02:00
Marek Behún
6173dd13f6 firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout()
[ Upstream commit 8467cfe821 ]

The wait_for_completion_timeout() function returns 0 if timed out, and a
positive value if completed. Fix the usage of this function.

Fixes: 389711b374 ("firmware: Add Turris Mox rWTM firmware driver")
Fixes: 2eab59cf0d ("firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:35 +02:00
Marek Behún
2f4f8d171e firmware: turris-mox-rwtm: Do not complete if there are no waiters
[ Upstream commit 0bafb172b1 ]

Do not complete the "command done" completion if there are no waiters.
This can happen if a wait_for_completion() timed out or was interrupted.

Fixes: 389711b374 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:35 +02:00
Rahul Kumar Yadav
1b51a84995 LF-12931: firmware: imx: se-fw: fetch SoC Info for i.MX8DXL and i.MX8QXP
Modified IOCTL to provide SoC ID and SoC Rev for i.MX8DXL and i.MX8QXP

Signed-off-by: Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>
2024-08-01 08:48:32 +02:00
Ranjani Vaidyanathan
8def1c8cc9 LF-13035 firmware: arm_scmi: clock: Fix bug associated with SCMI clock protocol version
The current code fails to select the scmi_clock_config_set_v2 when
the clock protocol returned from the System Manager is 3.0.

Signed-off-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
2024-07-30 14:55:43 -05:00
Nathan Chancellor
113fa39675 efi/libstub: zboot.lds: Discard .discard sections
[ Upstream commit 5134acb15d ]

When building ARCH=loongarch defconfig + CONFIG_UNWINDER_ORC=y using
LLVM, there is a warning from ld.lld when linking the EFI zboot image
due to the use of unreachable() in number() in vsprintf.c:

  ld.lld: warning: drivers/firmware/efi/libstub/lib.a(vsprintf.stub.o):(.discard.unreachable+0x0): has non-ABS relocation R_LARCH_32_PCREL against symbol ''

If the compiler cannot eliminate the default case for any reason, the
.discard.unreachable section will remain in the final binary but the
entire point of any section prefixed with .discard is that it is only
used at compile time, so it can be discarded via /DISCARD/ in a linker
script. The asm-generic vmlinux.lds.h includes .discard and .discard.*
in the COMMON_DISCARDS macro but that is not used for zboot.lds, as it
is not a kernel image linker script.

Add .discard and .discard.* to /DISCARD/ in zboot.lds, so that any
sections meant to be discarded at link time are not included in the
final zboot image. This issue is not specific to LoongArch, it is just
the first architecture to select CONFIG_OBJTOOL, which defines
annotate_unreachable() as an asm statement to add the
.discard.unreachable section, and use the EFI stub.

Closes: https://github.com/ClangBuiltLinux/linux/issues/2023
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-25 09:50:40 +02:00
Ye Li
4207e96647 LF-11663-1 firmware: imx: ele_fw: Support Voltage start and finish API
To support iMX93 GDET enabled part, it needs to isolate GDET when VDD_SOC
changing between OD and LD. ELE introduces two new APIs: voltage start and
finish for this purpose.

Voltage change start:
 - This command isolates GDET and launches a 5 ms timer.
   During the 5 ms, the voltage needs to be changed and voltage change
   finish command must be called to remove GDET isolation (no other command
   will be accepted). A GDET software reset is done before removing the
   isolation in voltage change finish.

Voltage change finish:
 - This command can’t be called without voltage change start.

To support above commands, especailly no other command will be accepted
after voltage change start issued, so adjust the mu_cmd_lock to each
command begin, this also resolves potential issue in imx_se_alloc_tx_rx_buf
since the buf pointer is not locked.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2024-07-19 13:43:36 +08:00
Peng Fan
0dc334f2dd LF-12944 firmware: arm_scmi: bus: bypass set fwnode for scmi cpufreq
Two drivers scmi_cpufreq.c and scmi_perf_domain.c both use
SCMI_PROTCOL_PERF protocol, but with different name, so two scmi devices
will be created. But the fwnode->dev could only point to one device.

If scmi cpufreq device created earlier, the fwnode->dev will point to
the scmi cpufreq device. Then the fw_devlink will link performance
domain user device(consumer) to the scmi cpufreq device(supplier).
But actually the performance domain user device, such as GPU, should use
the scmi perf device as supplier. Also if 'cpufreq.off=1' in bootargs,
the GPU driver will defer probe always, because of the scmi cpufreq
device not ready.

Because for cpufreq, no need use fw_devlink. So bypass setting fwnode
for scmi cpufreq device.

Tested-by: Jiyu Yang <jiyu.yang@nxp.com>
Tested-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2024-07-18 21:46:26 +08:00
Richard Fitzgerald
392cff2f86 firmware: cs_dsp: Use strnlen() on name fields in V1 wmfw files
[ Upstream commit 680e126ec0 ]

Use strnlen() instead of strlen() on the algorithm and coefficient name
string arrays in V1 wmfw files.

In V1 wmfw files the name is a NUL-terminated string in a fixed-size
array. cs_dsp should protect against overrunning the array if the NUL
terminator is missing.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e76 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240708144855.385332-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:21:16 +02:00
Richard Fitzgerald
76ea8e13aa firmware: cs_dsp: Prevent buffer overrun when processing V2 alg headers
[ Upstream commit 2163aff6be ]

Check that all fields of a V2 algorithm header fit into the available
firmware data buffer.

The wmfw V2 format introduced variable-length strings in the algorithm
block header. This means the overall header length is variable, and the
position of most fields varies depending on the length of the string
fields. Each field must be checked to ensure that it does not overflow
the firmware data buffer.

As this ia bugfix patch, the fixes avoid making any significant change to
the existing code. This makes it easier to review and less likely to
introduce new bugs.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e76 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240627141432.93056-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:21:15 +02:00
Richard Fitzgerald
3a9cd924ae firmware: cs_dsp: Validate payload length before processing block
[ Upstream commit 6598afa932 ]

Move the payload length check in cs_dsp_load() and cs_dsp_coeff_load()
to be done before the block is processed.

The check that the length of a block payload does not exceed the number
of remaining bytes in the firwmware file buffer was being done near the
end of the loop iteration. However, some code before that check used the
length field without validating it.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e76 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240627141432.93056-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:21:15 +02:00
Richard Fitzgerald
90ab191b7d firmware: cs_dsp: Return error if block header overflows file
[ Upstream commit 959fe01e85 ]

Return an error from cs_dsp_power_up() if a block header is longer
than the amount of data left in the file.

The previous code in cs_dsp_load() and cs_dsp_load_coeff() would loop
while there was enough data left in the file for a valid region. This
protected against overrunning the end of the file data, but it didn't
abort the file processing with an error.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e76 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240627141432.93056-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:21:15 +02:00
Richard Fitzgerald
9c9877a96e firmware: cs_dsp: Fix overflow checking of wmfw header
[ Upstream commit 3019b86bce ]

Fix the checking that firmware file buffer is large enough for the
wmfw header, to prevent overrunning the buffer.

The original code tested that the firmware data buffer contained
enough bytes for the sums of the size of the structs

	wmfw_header + wmfw_adsp1_sizes + wmfw_footer

But wmfw_adsp1_sizes is only used on ADSP1 firmware. For ADSP2 and
Halo Core the equivalent struct is wmfw_adsp2_sizes, which is
4 bytes longer. So the length check didn't guarantee that there
are enough bytes in the firmware buffer for a header with
wmfw_adsp2_sizes.

This patch splits the length check into three separate parts. Each
of the wmfw_header, wmfw_adsp?_sizes and wmfw_footer are checked
separately before they are used.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e76 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240627141432.93056-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:21:15 +02:00
Pankaj Gupta
f44e7ab360 LF-11066: firmware: imx: se-fw: fix for ctrl + c
Clean-up, when signal interrupt from ctrl + c, is received
by se-fw kernel driver; in order to achieve the graceful
exit to any application based on se-lib.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
2024-07-15 11:29:34 +02:00