diff options
| author | David Zhang <yidong.zhang@amd.com> | 2026-05-05 09:09:32 -0700 |
|---|---|---|
| committer | Lizhi Hou <lizhi.hou@amd.com> | 2026-05-07 14:07:34 -0700 |
| commit | ce9414d0c0be7377aab5a6d3a30da5b6c032a720 (patch) | |
| tree | daa9f05c8939546069cd9bfdba92df6a8a99d472 | |
| parent | 7b1a245b180579a844e506193f1f714edaf24bc1 (diff) | |
accel/amdxdna: Init AIE4 device partition
Send partition creation command to firmware during VF initialization.
Co-developed-by: Hayden Laccabue <Hayden.Laccabue@amd.com>
Signed-off-by: Hayden Laccabue <Hayden.Laccabue@amd.com>
Signed-off-by: David Zhang <yidong.zhang@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20260505160936.3917732-3-lizhi.hou@amd.com
| -rw-r--r-- | drivers/accel/amdxdna/aie4_msg_priv.h | 21 | ||||
| -rw-r--r-- | drivers/accel/amdxdna/aie4_pci.c | 52 | ||||
| -rw-r--r-- | drivers/accel/amdxdna/aie4_pci.h | 1 |
3 files changed, 73 insertions, 1 deletions
diff --git a/drivers/accel/amdxdna/aie4_msg_priv.h b/drivers/accel/amdxdna/aie4_msg_priv.h index 88463cc3a98a..cada53257921 100644 --- a/drivers/accel/amdxdna/aie4_msg_priv.h +++ b/drivers/accel/amdxdna/aie4_msg_priv.h @@ -13,6 +13,9 @@ enum aie4_msg_opcode { AIE4_MSG_OP_CREATE_VFS = 0x20001, AIE4_MSG_OP_DESTROY_VFS = 0x20002, + + AIE4_MSG_OP_CREATE_PARTITION = 0x30001, + AIE4_MSG_OP_DESTROY_PARTITION = 0x30002, }; enum aie4_msg_status { @@ -46,4 +49,22 @@ struct aie4_msg_destroy_vfs_resp { enum aie4_msg_status status; } __packed; +struct aie4_msg_create_partition_req { + __u32 partition_col_start; + __u32 partition_col_count; +} __packed; + +struct aie4_msg_create_partition_resp { + enum aie4_msg_status status; + __u32 partition_id; +} __packed; + +struct aie4_msg_destroy_partition_req { + __u32 partition_id; +} __packed; + +struct aie4_msg_destroy_partition_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 a967e2db7ebd..13f5d45e388d 100644 --- a/drivers/accel/amdxdna/aie4_pci.c +++ b/drivers/accel/amdxdna/aie4_pci.c @@ -9,11 +9,16 @@ #include <linux/firmware.h> #include <linux/sizes.h> +#include "aie.h" +#include "aie4_msg_priv.h" #include "aie4_pci.h" +#include "amdxdna_mailbox.h" +#include "amdxdna_mailbox_helper.h" #include "amdxdna_pci_drv.h" #define NO_IOHUB 0 #define PSP_NOTIFY_INTR 0xD007BE11 +#define AIE4_TOTAL_COLUMN 3 /* * The management mailbox channel is allocated by firmware. @@ -234,6 +239,36 @@ static int aie4_fw_start(struct amdxdna_dev_hdl *ndev) return ret; } +static int aie4_partition_init(struct amdxdna_dev_hdl *ndev) +{ + DECLARE_AIE_MSG(aie4_msg_create_partition, AIE4_MSG_OP_CREATE_PARTITION); + struct amdxdna_dev *xdna = ndev->aie.xdna; + int ret; + + req.partition_col_start = 0; + req.partition_col_count = AIE4_TOTAL_COLUMN; + ret = aie_send_mgmt_msg_wait(&ndev->aie, &msg); + if (ret) { + XDNA_ERR(xdna, "partition init failed: %d", ret); + return ret; + } + + ndev->partition_id = resp.partition_id; + return 0; +} + +static void aie4_partition_fini(struct amdxdna_dev_hdl *ndev) +{ + DECLARE_AIE_MSG(aie4_msg_destroy_partition, AIE4_MSG_OP_DESTROY_PARTITION); + struct amdxdna_dev *xdna = ndev->aie.xdna; + int ret; + + req.partition_id = ndev->partition_id; + ret = aie_send_mgmt_msg_wait(&ndev->aie, &msg); + if (ret) + XDNA_ERR(xdna, "partition fini failed: %d", ret); +} + static int aie4_pf_hw_start(struct amdxdna_dev_hdl *ndev) { int ret; @@ -267,7 +302,21 @@ static void aie4_pf_hw_stop(struct amdxdna_dev_hdl *ndev) static int aie4_vf_hw_start(struct amdxdna_dev_hdl *ndev) { - return aie4_mailbox_init(ndev); + int ret; + + ret = aie4_mailbox_init(ndev); + if (ret) + return ret; + + ret = aie4_partition_init(ndev); + if (ret) + goto mailbox_fini; + + return 0; + +mailbox_fini: + aie4_mailbox_fini(ndev); + return ret; } static void aie4_vf_hw_stop(struct amdxdna_dev_hdl *ndev) @@ -276,6 +325,7 @@ static void aie4_vf_hw_stop(struct amdxdna_dev_hdl *ndev) drm_WARN_ON(&xdna->ddev, !mutex_is_locked(&xdna->dev_lock)); + aie4_partition_fini(ndev); aie4_mailbox_fini(ndev); } diff --git a/drivers/accel/amdxdna/aie4_pci.h b/drivers/accel/amdxdna/aie4_pci.h index cbf3424a4341..620fb5bd23e4 100644 --- a/drivers/accel/amdxdna/aie4_pci.h +++ b/drivers/accel/amdxdna/aie4_pci.h @@ -31,6 +31,7 @@ struct amdxdna_dev_hdl { void __iomem *rbuf_base; struct mailbox *mbox; + u32 partition_id; }; /* aie4_message.c */ |
