Skip to content

Instantly share code, notes, and snippets.

@lategoodbye
Created May 19, 2025 14:28
Show Gist options
  • Save lategoodbye/444af7d8ccb1f888645b28ebc1f27f53 to your computer and use it in GitHub Desktop.
Save lategoodbye/444af7d8ccb1f888645b28ebc1f27f53 to your computer and use it in GitHub Desktop.
firmware: raspberrypi: log firmware response time
diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 7ecde6921a0a..9ca5c2cd5408 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -58,7 +58,7 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
reinit_completion(&fw->c);
ret = mbox_send_message(fw->chan, &message);
if (ret >= 0) {
- if (wait_for_completion_timeout(&fw->c, HZ)) {
+ if (wait_for_completion_timeout(&fw->c, 5 * HZ)) {
ret = 0;
} else {
ret = -ETIMEDOUT;
@@ -90,6 +90,8 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
{
size_t size = tag_size + 12;
u32 *buf;
+ ktime_t start;
+ s64 actual_time;
dma_addr_t bus_addr;
int ret;
@@ -109,11 +111,13 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
buf[1] = RPI_FIRMWARE_STATUS_REQUEST;
memcpy(&buf[2], data, tag_size);
buf[size / 4 - 1] = RPI_FIRMWARE_PROPERTY_END;
+ start = ktime_get();
wmb();
ret = rpi_firmware_transaction(fw, MBOX_CHAN_PROPERTY, bus_addr);
rmb();
+ actual_time = ktime_to_ms(ktime_sub(ktime_get(), start));
memcpy(data, &buf[2], tag_size);
if (ret == 0 && buf[1] != RPI_FIRMWARE_STATUS_SUCCESS) {
/*
@@ -128,6 +132,9 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
WARN_ONCE(1, "Firmware transaction 0x%08x timeout", buf[2]);
}
+ if (buf[2] == 0x30066)
+ dev_warn(fw->cl.dev, "transaction 0x%08x, reply: %lld ms\n", buf[2], actual_time);
+
dma_free_coherent(fw->chan->mbox->dev, PAGE_ALIGN(size), buf, bus_addr);
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment