linux/drivers/firmware
Tudor Ambarus 8d2c2fa220 firmware: exynos-acpm: fix timeouts on xfers handling
The mailbox framework has a single inflight request at a time. If
a request is sent while another is still active, it will be queued
to the mailbox core ring buffer.

ACPM protocol did not serialize the calls to the mailbox subsystem so we
could start the timeout ticks in parallel for multiple requests, while
just one was being inflight.

Consider a hypothetical case where the xfer timeout is 100ms and an ACPM
transaction takes 90ms:
      | 0ms: Message #0 is queued in mailbox layer and sent out, then sits
      |      at acpm_dequeue_by_polling() with a timeout of 100ms
      | 1ms: Message #1 is queued in mailbox layer but not sent out yet.
      |      Since send_message() doesn't block, it also sits at
      |      acpm_dequeue_by_polling() with a timeout of 100ms
      |  ...
      | 90ms: Message #0 is completed, txdone is called and message #1 is sent
      | 101ms: Message #1 times out since the count started at 1ms. Even though
      |       it has only been inflight for 11ms.

Fix the problem by moving mbox_send_message() and mbox_client_txdone()
immediately after the message has been written to the TX queue and while
still keeping the ACPM TX queue lock. We thus tie together the TX write
with the doorbell ring and mark the TX as done after the doorbell has
been rung. This guarantees that the doorbell has been rang before
starting the timeout ticks. We should also see some performance
improvement as we no longer wait to receive a response before ringing
the doorbell for the next request, so the ACPM firmware shall be able to
drain faster the TX queue. Another benefit is that requests are no
longer able to ring the doorbell one for the other, so it eases
debugging. Finally, the mailbox software queue will always contain a
single doorbell request due to the serialization done at the ACPM TX
queue level. Protocols like ACPM, that handle their own hardware queues
need a passthrough mailbox API, where they are able to just ring the
doorbell or flip a bit directly into the mailbox controller. The mailbox
software queue mechanism, the locking done into the mailbox core is not
really needed, so hopefully this lays the foundation for a passthrough
mailbox API.

Reported-by: André Draszik <andre.draszik@linaro.org>
Fixes: a88927b534 ("firmware: add Exynos ACPM protocol driver")
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20250606-acpm-timeout-v2-1-306b1aa07a6c@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2025-06-10 10:20:16 +02:00
..
arm_ffa firmware: arm_ffa: Skip Rx buffer ownership release if not acquired 2025-04-08 10:32:15 +01:00
arm_scmi soc: drivers for 6.16 2025-05-31 07:53:30 -07:00
broadcom
cirrus firmware: cs_dsp: Fix OOB memory read access in KUnit test (ctl cache) 2025-05-26 11:33:52 +01:00
efi Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
google firmware: google: vpd: Use const 'struct bin_attribute' callback 2024-12-17 03:59:31 +00:00
imx firmware: imx: Add i.MX95 SCMI CPU driver 2025-04-14 13:55:04 +01:00
meson firmware: meson_sm: add missing MODULE_DESCRIPTION() macro 2024-06-24 10:08:53 +02:00
microchip firmware: microchip: fix UL_IAP lock check in mpfs_auto_update_state() 2024-12-05 15:08:51 +00:00
psci arm64 updates for 6.16 2025-05-28 14:55:35 -07:00
qcom docs: firmware: qcom_scm: Fix kernel-doc warning 2025-05-19 18:04:28 -05:00
samsung firmware: exynos-acpm: fix timeouts on xfers handling 2025-06-10 10:20:16 +02:00
smccc arm64: kvm, smccc: Introduce and use API for getting hypervisor UUID 2025-05-23 16:30:55 +00:00
tegra Revert "firmware: tegra: bpmp: Use scoped device node handling to simplify error paths" 2024-10-24 18:38:07 +02:00
xilinx firmware: xilinx: Dont send linux address to get fpga config get status 2025-02-17 15:40:01 +01:00
arm_scpi.c Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
arm_sdei.c firmware: SDEI: Allow sdei initialization without ACPI_APEI_GHES 2025-05-08 13:35:22 +01:00
dmi_scan.c firmware: dmi: Mark bin_attributes as __ro_after_init 2025-02-21 09:20:30 +01:00
dmi-id.c
dmi-sysfs.c firmware: dmi: Constify 'struct bin_attribute' 2025-02-21 09:20:30 +01:00
edd.c
iscsi_ibft_find.c
iscsi_ibft.c iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic() 2025-01-29 14:58:31 -05:00
Kconfig soc: drivers for 6.16 2025-05-31 07:53:30 -07:00
Makefile soc: driver updates for 6.15, part 1 2025-03-27 09:05:55 -07:00
memmap.c firmware: memmap: Constify memmap_ktype 2024-10-13 17:22:33 +02:00
mtk-adsp-ipc.c firmware: Switch back to struct platform_driver::remove() 2024-11-12 12:55:56 +01:00
qemu_fw_cfg.c firmware: qemu_fw_cfg: constify 'struct bin_attribute' 2025-02-21 09:20:32 +01:00
raspberrypi.c firmware: Switch back to struct platform_driver::remove() 2024-11-12 12:55:56 +01:00
stratix10-rsu.c firmware: Switch back to struct platform_driver::remove() 2024-11-12 12:55:56 +01:00
stratix10-svc.c firmware: stratix10-svc: Add of_platform_default_populate() 2025-04-15 18:23:02 +02:00
sysfb_simplefb.c firmware: sysfb: Move bpp-depth calculation into screen_info helper 2025-04-07 11:02:07 +02:00
sysfb.c sysfb: Fix screen_info type check for VGA 2025-06-05 17:54:31 +02:00
thead,th1520-aon.c firmware: thead,th1520-aon: Fix use after free in th1520_aon_init() 2025-03-18 13:09:00 +01:00
ti_sci.c firmware: ti_sci: Convert CPU latency constraint from us to ms 2025-05-06 07:25:51 -05:00
ti_sci.h firmware: ti_sci: Introduce Power Management Ops 2024-10-25 10:45:07 -05:00
trusted_foundations.c
turris-mox-rwtm.c firmware: turris-mox-rwtm: Add support for ECDSA signatures with HW private key 2025-03-20 17:56:57 +01:00