From: David Zhang <yidong.zhang@amd.com>
To: <quic_jhugo@quicinc.com>, <karol.wachowski@linux.intel.com>,
<max.zhen@amd.com>, <lizhi.hou@amd.com>, <ogabbay@kernel.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Cc: David Zhang <yidong.zhang@amd.com>, <sonal.santan@amd.com>,
<mario.limonciello@amd.com>
Subject: [PATCH V2 20/20] accel/amdxdna: Enable AIE4 firmware logging to DRAM
Date: Mon, 5 Oct 2026 21:22:30 -0700 [thread overview]
Message-ID: <20261006042230.547807-21-yidong.zhang@amd.com> (raw)
In-Reply-To: <20261006042230.547807-1-yidong.zhang@amd.com>
Allocate a DRAM buffer for firmware logging, and also set the log level
to less verbose. This will give the best performance numbers.
Signed-off-by: David Zhang <yidong.zhang@amd.com>
---
drivers/accel/amdxdna/aie4_message.c | 20 ++++++++++
drivers/accel/amdxdna/aie4_msg_priv.h | 24 ++++++++++++
drivers/accel/amdxdna/aie4_pci.c | 53 +++++++++++++++++++++++++++
drivers/accel/amdxdna/aie4_pci.h | 5 +++
4 files changed, 102 insertions(+)
diff --git a/drivers/accel/amdxdna/aie4_message.c b/drivers/accel/amdxdna/aie4_message.c
index 5720aa88e6d6..89902492502c 100644
--- a/drivers/accel/amdxdna/aie4_message.c
+++ b/drivers/accel/amdxdna/aie4_message.c
@@ -246,6 +246,26 @@ int aie4_attach_work_buffer(struct amdxdna_dev_hdl *ndev)
return ret;
}
+int aie4_start_fw_log(struct amdxdna_dev_hdl *ndev, u32 level)
+{
+ DECLARE_AIE_MSG(aie4_msg_start_fw_log, AIE4_MSG_OP_START_FW_LOG);
+ struct amdxdna_dev *xdna = ndev->aie.xdna;
+ int ret;
+
+ req.buff_addr = ndev->fw_log_buf_addr;
+ req.buff_size = ndev->fw_log_buf_size;
+ req.log_level = level;
+
+ ret = aie_send_mgmt_msg_wait(&ndev->aie, &msg);
+ if (ret)
+ XDNA_WARN(xdna, "Failed to start fw log, ret %d", ret);
+ else
+ XDNA_DBG(xdna, "Started fw log, level %u size 0x%x",
+ level, ndev->fw_log_buf_size);
+
+ return ret;
+}
+
int aie4_msg_set_power_mode(struct amdxdna_dev_hdl *ndev, u8 power_mode)
{
DECLARE_AIE_MSG(aie4_msg_power_override, AIE4_MSG_OP_POWER_OVERRIDE);
diff --git a/drivers/accel/amdxdna/aie4_msg_priv.h b/drivers/accel/amdxdna/aie4_msg_priv.h
index 636bf8d04c76..566f6abc9e2d 100644
--- a/drivers/accel/amdxdna/aie4_msg_priv.h
+++ b/drivers/accel/amdxdna/aie4_msg_priv.h
@@ -29,6 +29,7 @@ enum aie4_msg_opcode {
AIE4_MSG_OP_GET_CURRENT_DPM_LEVEL = 0x30013,
AIE4_MSG_OP_ATTACH_WORK_BUFFER = 0x40001,
+ AIE4_MSG_OP_START_FW_LOG = 0x40003,
};
enum aie4_msg_status {
@@ -263,4 +264,27 @@ struct aie4_msg_attach_work_buffer_resp {
enum aie4_msg_status status;
} __packed;
+/* Dynamic firmware log levels. */
+enum aie4_fw_log_level {
+ AIE4_FW_LOG_LEVEL_OFF,
+ AIE4_FW_LOG_LEVEL_ERR,
+ AIE4_FW_LOG_LEVEL_WRN,
+ AIE4_FW_LOG_LEVEL_INF,
+ AIE4_FW_LOG_LEVEL_DBG,
+ AIE4_FW_LOG_LEVEL_MAX,
+};
+
+#define AIE4_FW_LOG_BUF_SIZE SZ_1M
+
+struct aie4_msg_start_fw_log_req {
+ __u64 buff_addr;
+ __u32 buff_size;
+ __u32 log_level;
+ __u32 reserved;
+} __packed;
+
+struct aie4_msg_start_fw_log_resp {
+ enum aie4_msg_status status;
+} __packed;
+
#endif /* _AIE4_MSG_PRIV_H_ */
diff --git a/drivers/accel/amdxdna/aie4_pci.c b/drivers/accel/amdxdna/aie4_pci.c
index c395052eb6fd..d2c3b48e8ec3 100644
--- a/drivers/accel/amdxdna/aie4_pci.c
+++ b/drivers/accel/amdxdna/aie4_pci.c
@@ -376,6 +376,16 @@ static int aie4_config_fw(struct amdxdna_dev_hdl *ndev)
if (ret == -ETIME)
return ret;
+ /*
+ * Give the firmware high performance DRAM to log into with less
+ * verbose level.
+ */
+ if (ndev->fw_log_buf) {
+ ret = aie4_start_fw_log(ndev, AIE4_FW_LOG_LEVEL_ERR);
+ if (ret == -ETIME)
+ return ret;
+ }
+
return 0;
}
@@ -934,6 +944,41 @@ static void aie4_free_work_buffer(struct amdxdna_dev_hdl *ndev)
ndev->work_buf = NULL;
}
+/*
+ * Firmware logging is best effort: a device that cannot spare the buffer still
+ * runs, it just does not log. Never fail hw start or probe on this.
+ */
+static void aie4_alloc_fw_log_buffer(struct amdxdna_dev_hdl *ndev)
+{
+ struct amdxdna_dev *xdna = ndev->aie.xdna;
+ u32 buf_size = AIE4_FW_LOG_BUF_SIZE;
+
+ ndev->fw_log_buf = amdxdna_alloc_msg_buffer(xdna, &buf_size,
+ &ndev->fw_log_buf_addr);
+ if (IS_ERR(ndev->fw_log_buf)) {
+ XDNA_WARN(xdna, "Failed to alloc fw log buffer, size 0x%x",
+ AIE4_FW_LOG_BUF_SIZE);
+ ndev->fw_log_buf = NULL;
+ return;
+ }
+
+ ndev->fw_log_buf_size = buf_size;
+ XDNA_DBG(xdna, "FW log buffer allocated: size 0x%x", buf_size);
+}
+
+/* Free logging buffer after firmware execution has stopped. */
+static void aie4_free_fw_log_buffer(struct amdxdna_dev_hdl *ndev)
+{
+ struct amdxdna_dev *xdna = ndev->aie.xdna;
+
+ if (!ndev->fw_log_buf)
+ return;
+
+ amdxdna_free_msg_buffer(xdna, ndev->fw_log_buf_size, ndev->fw_log_buf,
+ ndev->fw_log_buf_addr);
+ ndev->fw_log_buf = NULL;
+}
+
static int aie4_pf_init(struct amdxdna_dev *xdna)
{
int ret;
@@ -946,6 +991,8 @@ static int aie4_pf_init(struct amdxdna_dev *xdna)
if (ret)
return ret;
+ aie4_alloc_fw_log_buffer(xdna->dev_handle);
+
ret = aie4_pf_hw_start(xdna->dev_handle);
if (ret)
goto free_work_buf;
@@ -953,6 +1000,7 @@ static int aie4_pf_init(struct amdxdna_dev *xdna)
return 0;
free_work_buf:
+ aie4_free_fw_log_buffer(xdna->dev_handle);
aie4_free_work_buffer(xdna->dev_handle);
return ret;
}
@@ -980,6 +1028,8 @@ static int aie4_classic_init(struct amdxdna_dev *xdna)
if (ret)
return ret;
+ aie4_alloc_fw_log_buffer(xdna->dev_handle);
+
ret = aie4_classic_hw_start(xdna->dev_handle);
if (ret)
goto free_work_buf;
@@ -987,6 +1037,7 @@ static int aie4_classic_init(struct amdxdna_dev *xdna)
return 0;
free_work_buf:
+ aie4_free_fw_log_buffer(xdna->dev_handle);
aie4_free_work_buffer(xdna->dev_handle);
return ret;
}
@@ -995,6 +1046,7 @@ static void aie4_pf_fini(struct amdxdna_dev *xdna)
{
aie4_sriov_stop(xdna->dev_handle);
aie4_pf_hw_stop(xdna->dev_handle);
+ aie4_free_fw_log_buffer(xdna->dev_handle);
aie4_free_work_buffer(xdna->dev_handle);
}
@@ -1006,6 +1058,7 @@ static void aie4_vf_fini(struct amdxdna_dev *xdna)
static void aie4_classic_fini(struct amdxdna_dev *xdna)
{
aie4_classic_hw_stop(xdna->dev_handle);
+ aie4_free_fw_log_buffer(xdna->dev_handle);
aie4_free_work_buffer(xdna->dev_handle);
}
diff --git a/drivers/accel/amdxdna/aie4_pci.h b/drivers/accel/amdxdna/aie4_pci.h
index a03c39457ab8..b6cca62abcbc 100644
--- a/drivers/accel/amdxdna/aie4_pci.h
+++ b/drivers/accel/amdxdna/aie4_pci.h
@@ -108,6 +108,10 @@ struct amdxdna_dev_hdl {
dma_addr_t work_buf_addr;
u32 work_buf_size;
+ void *fw_log_buf;
+ dma_addr_t fw_log_buf_addr;
+ u32 fw_log_buf_size;
+
u8 pw_mode;
/* Context switch hysteresis timeout in microseconds. */
@@ -128,6 +132,7 @@ int aie4_query_aie_version(struct amdxdna_dev_hdl *ndev,
struct amdxdna_drm_query_aie_version *version);
int aie4_suspend_fw(struct amdxdna_dev_hdl *ndev);
int aie4_attach_work_buffer(struct amdxdna_dev_hdl *ndev);
+int aie4_start_fw_log(struct amdxdna_dev_hdl *ndev, u32 level);
int aie4_query_npu_firmware_version(struct amdxdna_dev_hdl *ndev,
struct amdxdna_drm_query_firmware_version *fw_version);
int aie4_query_cert_firmware_version(struct amdxdna_dev_hdl *ndev,
--
2.34.1
prev parent reply other threads:[~2026-10-06 4:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 4:22 [PATCH V2 00/20] accel/amdxdna: Kernel submission and PM for AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 01/20] accel/amdxdna: Rename NPU3 firmware files David Zhang
2026-10-06 4:22 ` [PATCH V2 02/20] accel/amdxdna: Remove mmap for doorbell David Zhang
2026-10-06 4:22 ` [PATCH V2 03/20] accel/amdxdna: Add CERT firmware version support David Zhang
2026-10-06 4:22 ` [PATCH V2 04/20] accel/amdxdna: Upgrade firmware version to 6.0 David Zhang
2026-10-06 4:22 ` [PATCH V2 05/20] accel/amdxdna: Add NPU3 classic device support David Zhang
2026-10-06 4:22 ` [PATCH V2 06/20] accel/amdxdna: Add AIE version query to aie4_get_info David Zhang
2026-10-06 4:22 ` [PATCH V2 07/20] accel/amdxdna: Add get and set power_mode for AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 08/20] accel/amdxdna: Add clock, DPM frequency, and resource info queries " David Zhang
2026-10-06 4:22 ` [PATCH V2 09/20] accel/amdxdna: Add context switch hysteresis with debugfs control David Zhang
2026-10-06 4:22 ` [PATCH V2 10/20] accel/amdxdna: Refactor AIE4 hardware initialization sequence David Zhang
2026-10-06 4:22 ` [PATCH V2 11/20] accel/amdxdna: Decouple AIE4 doorbell and MSI-X notify transport hooks David Zhang
2026-10-06 4:22 ` [PATCH V2 12/20] accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout David Zhang
2026-10-06 4:22 ` [PATCH V2 13/20] accel/amdxdna: Prepare for AIE4 command submission David Zhang
2026-10-06 4:22 ` [PATCH V2 14/20] accel/amdxdna: Implement AIE4 command packet building and submission David Zhang
2026-10-06 7:12 ` Eva Crystal
2026-10-07 22:54 ` Zhang, Yidong (David)
2026-10-06 4:22 ` [PATCH V2 15/20] accel/amdxdna: Make hmm_invalidate common for AIE2 and AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 16/20] accel/amdxdna: Finalize runtime PM before acquiring dev_lock on removal David Zhang
2026-10-06 7:13 ` Eva Crystal
2026-10-06 17:01 ` Lizhi Hou
2026-10-07 1:18 ` Eva Crystal
2026-10-06 4:22 ` [PATCH V2 17/20] accel/amdxdna: Implement AIE4 suspend and resume David Zhang
2026-10-06 4:22 ` [PATCH V2 18/20] accel/amdxdna: Link SR-IOV VFs for power management sequencing David Zhang
2026-10-06 4:22 ` [PATCH V2 19/20] accel/amdxdna: Implement runtime suspend and resume support David Zhang
2026-10-06 4:22 ` David Zhang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261006042230.547807-21-yidong.zhang@amd.com \
--to=yidong.zhang@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karol.wachowski@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=mario.limonciello@amd.com \
--cc=max.zhen@amd.com \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.com \
--cc=sonal.santan@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®