AMD NPU driver improvements
Lizhi Hou
maintainerv3 cover AMD NPU driver improvements
Add recent improvements and bug fixes for amdxdna driver (depends on [1])
1. Support recent hardware and firmware.
2. Replace idr APIs with xarray.
3. Fix the bugs been found.
[1]: https://lore.kernel.org/all/[email protected]/
Changes since v2:
- Remove merged patches from this set
- Add MBZ check for pad member of input ioctl structure
- Fix for code review comments
Changes since v1:
- Add one patch to fix possible compiling failure
- Minor fixes for code review comments
Lizhi Hou (5):
accel/amdxdna: Add RyzenAI-npu6 support accel/amdxdna: Replace idr api with xarray accel/amdxdna: Enhance power management settings accel/amdxdna: Read firmware interface version from registers accel/amdxdna: Add zero check for pad in ioctl input structures
drivers/accel/amdxdna/Makefile | 4 +- drivers/accel/amdxdna/TODO | 2 - drivers/accel/amdxdna/aie2_ctx.c | 14 +- drivers/accel/amdxdna/aie2_message.c | 41 ++--- drivers/accel/amdxdna/aie2_pci.c | 219 +++++++++++++++++++----- drivers/accel/amdxdna/aie2_pci.h | 61 +++++-- drivers/accel/amdxdna/aie2_pm.c | 108 ++++++++++++ drivers/accel/amdxdna/aie2_smu.c | 85 +++++---- drivers/accel/amdxdna/aie2_solver.c | 59 ++++++- drivers/accel/amdxdna/aie2_solver.h | 1 + drivers/accel/amdxdna/amdxdna_ctx.c | 53 +++--- drivers/accel/amdxdna/amdxdna_gem.c | 2 +- drivers/accel/amdxdna/amdxdna_mailbox.c | 56 +++--- drivers/accel/amdxdna/amdxdna_pci_drv.c | 24 ++- drivers/accel/amdxdna/amdxdna_pci_drv.h | 26 ++- drivers/accel/amdxdna/npu1_regs.c | 31 +++- drivers/accel/amdxdna/npu2_regs.c | 17 +- drivers/accel/amdxdna/npu4_regs.c | 34 +++- drivers/accel/amdxdna/npu5_regs.c | 17 +- drivers/accel/amdxdna/npu6_regs.c | 114 ++++++++++++ include/uapi/drm/amdxdna_accel.h | 63 ++++++- 21 files changed, 787 insertions(+), 244 deletions(-) create mode 100644 drivers/accel/amdxdna/aie2_pm.c create mode 100644 drivers/accel/amdxdna/npu6_regs.c
Signature · 1 line
2.34.1
Lizhi Hou
maintainerPATCH v3 1/5 accel/amdxdna: Add RyzenAI-npu6 support
Add NPU6 registers and other private configurations.
--- drivers/accel/amdxdna/Makefile | 3 +- drivers/accel/amdxdna/amdxdna_pci_drv.c | 1 + drivers/accel/amdxdna/amdxdna_pci_drv.h | 1 + drivers/accel/amdxdna/npu6_regs.c | 121 ++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 drivers/accel/amdxdna/npu6_regs.c
drivers/accel/amdxdna/Makefile +2 -1
@@ -17,5 +17,6 @@ amdxdna-y := \ npu1_regs.o \ npu2_regs.o \ npu4_regs.o \ - npu5_regs.o + npu5_regs.o \ + npu6_regs.o obj-$(CONFIG_DRM_ACCEL_AMDXDNA) = amdxdna.o
drivers/accel/amdxdna/amdxdna_pci_drv.c +1 -0
@@ -39,6 +39,7 @@ static const struct amdxdna_device_id amdxdna_ids[] = { { 0x17f0, 0x0, &dev_npu2_info }, { 0x17f0, 0x10, &dev_npu4_info }, { 0x17f0, 0x11, &dev_npu5_info }, + { 0x17f0, 0x20, &dev_npu6_info }, {0} };
drivers/accel/amdxdna/amdxdna_pci_drv.h +1 -0
@@ -116,6 +116,7 @@ extern const struct amdxdna_dev_info dev_npu1_info;extern const struct amdxdna_dev_info dev_npu2_info;extern const struct amdxdna_dev_info dev_npu4_info;extern const struct amdxdna_dev_info dev_npu5_info; +extern const struct amdxdna_dev_info dev_npu6_info;int amdxdna_sysfs_init (struct amdxdna_dev *xdna);void amdxdna_sysfs_fini (struct amdxdna_dev *xdna);
drivers/accel/amdxdna/npu6_regs.c new file +121 -0
121 lines not on this page · raw message
Signature · 1 line
2.34.1
Lizhi Hou
maintainerPATCH v3 2/5 accel/amdxdna: Replace idr api with xarray
In reply to Lizhi HouSwitch mailbox message id and hardware context id management over from the idr api to the xarray api.
--- drivers/accel/amdxdna/TODO | 1 - drivers/accel/amdxdna/aie2_ctx.c | 5 ++- drivers/accel/amdxdna/aie2_message.c | 5 ++- drivers/accel/amdxdna/aie2_pci.c | 6 +-- drivers/accel/amdxdna/amdxdna_ctx.c | 47 +++++++++------------ drivers/accel/amdxdna/amdxdna_mailbox.c | 56 ++++++++++--------------- drivers/accel/amdxdna/amdxdna_pci_drv.c | 4 +- drivers/accel/amdxdna/amdxdna_pci_drv.h | 8 +++- 8 files changed, 60 insertions(+), 72 deletions(-)
drivers/accel/amdxdna/TODO +0 -1
@@ -1,4 +1,3 @@ -- Replace idr with xa - Add import and export BO support - Add debugfs support - Add debug BO support
drivers/accel/amdxdna/aie2_ctx.c +3 -2
@@ -11,6 +11,7 @@#include <drm/drm_syncobj.h> #include <linux/hmm.h> #include <linux/types.h> +#include <linux/xarray.h> #include <trace/events/amdxdna.h> #include "aie2_msg_priv.h"
@@ -90,11 +91,11 @@ void aie2_restart_ctx(struct amdxdna_client *client) {struct amdxdna_dev *xdna = client->xdna;struct amdxdna_hwctx *hwctx; -int next =0 ; +unsigned long hwctx_id;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));mutex_lock (&client->hwctx_lock); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) { +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) {if (hwctx->status !=HWCTX_STAT_STOP )continue ;
drivers/accel/amdxdna/aie2_message.c +3 -2
@@ -14,6 +14,7 @@#include <linux/errno.h> #include <linux/pci.h> #include <linux/types.h> +#include <linux/xarray.h> #include "aie2_msg_priv.h" #include "aie2_pci.h"
@@ -315,10 +316,10 @@ int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf,struct amdxdna_dev *xdna = ndev->xdna;struct amdxdna_client *client;struct amdxdna_hwctx *hwctx; +unsigned long hwctx_id;dma_addr_t dma_addr;u32 aie_bitmap =0 ;u8 *buff_addr; -int next =0 ;int ret, idx; buff_addr = dma_alloc_noncoherent(xdna->ddev.dev, size, &dma_addr,
@@ -329,7 +330,7 @@ int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf,/* Go through each hardware context and mark the AIE columns that are active */ list_for_each_entry (client, &xdna->client_list, node) { idx =srcu_read_lock (&client->hwctx_srcu); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) aie_bitmap |=amdxdna_hwctx_col_map (hwctx);srcu_read_unlock (&client->hwctx_srcu, idx); }
drivers/accel/amdxdna/aie2_pci.c +3 -3
@@ -15,6 +15,7 @@#include <linux/iommu.h> #include <linux/iopoll.h> #include <linux/pci.h> +#include <linux/xarray.h> #include "aie2_msg_priv.h" #include "aie2_pci.h"
@@ -691,11 +692,11 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client,struct amdxdna_drm_query_hwctx *tmp;struct amdxdna_client *tmp_client;struct amdxdna_hwctx *hwctx; +unsigned long hwctx_id;bool overflow = false;u32 req_bytes =0 ;u32 hw_i =0 ;int ret =0 ; -int next;int idx;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));
@@ -707,8 +708,7 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client, buf =u64_to_user_ptr (args->buffer);list_for_each_entry (tmp_client, &xdna->client_list, node) { idx =srcu_read_lock (&tmp_client->hwctx_srcu); - next =0 ; -idr_for_each_entry_continue (&tmp_client->hwctx_idr, hwctx, next) { +amdxdna_for_each_hwctx (tmp_client, hwctx_id, hwctx) { req_bytes +=sizeof (*tmp);if (args->buffer_size < req_bytes) {/* Continue iterating to get the required size */
drivers/accel/amdxdna/amdxdna_ctx.c +19 -28
122 lines not on this page · raw message
drivers/accel/amdxdna/amdxdna_mailbox.c +23 -33
124 lines not on this page · raw message
drivers/accel/amdxdna/amdxdna_pci_drv.c +2 -2
@@ -78,7 +78,7 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp) }mutex_init (&client->hwctx_lock);init_srcu_struct (&client->hwctx_srcu); -idr_init_base (&client->hwctx_idr,AMDXDNA_INVALID_CTX_HANDLE +1 ); +xa_init_flags (&client->hwctx_xa,XA_FLAGS_ALLOC );mutex_init (&client->mm_lock);mutex_lock (&xdna->dev_lock);
@@ -109,7 +109,7 @@ static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp)XDNA_DBG (xdna,"closing pid %d" , client->pid); -idr_destroy (&client->hwctx_idr); +xa_destroy (&client->hwctx_xa);cleanup_srcu_struct (&client->hwctx_srcu);mutex_destroy (&client->hwctx_lock);mutex_destroy (&client->mm_lock);
drivers/accel/amdxdna/amdxdna_pci_drv.h +7 -1
@@ -6,6 +6,8 @@#ifndef _AMDXDNA_PCI_DRV_H_#define _AMDXDNA_PCI_DRV_H_ +#include <linux/xarray.h> + #define XDNA_INFO(xdna, fmt, args...) drm_info(&(xdna)->ddev, fmt, ##args) #define XDNA_WARN(xdna, fmt, args...) drm_warn(&(xdna)->ddev, "%s: "fmt, __func__, ##args) #define XDNA_ERR(xdna, fmt, args...) drm_err(&(xdna)->ddev, "%s: "fmt, __func__, ##args)
@@ -100,7 +102,8 @@ struct amdxdna_client {struct mutex hwctx_lock;/* protect hwctx */ /* do NOT wait this srcu when hwctx_lock is held */ struct srcu_struct hwctx_srcu; -struct idr hwctx_idr; +struct xarray hwctx_xa; +u32 next_hwctxid;struct amdxdna_dev *xdna;struct drm_file *filp;
@@ -111,6 +114,9 @@ struct amdxdna_client {int pasid; }; +#define amdxdna_for_each_hwctx (client, hwctx_id, entry) \ + xa_for_each(&(client)->hwctx_xa, hwctx_id, entry) +/* Add device info below */ extern const struct amdxdna_dev_info dev_npu1_info;extern const struct amdxdna_dev_info dev_npu2_info;
Signature · 1 line
2.34.1
Re: [PATCH V3 2/5] accel/amdxdna: Replace idr api with xarray
Quoted 4 lines · Lizhi Hou
Switch mailbox message id and hardware context id management over from the idr api to the xarray api.
Signed-off-by Lizhi Hou <[email protected]>
Quoted 440 lines
--- drivers/accel/amdxdna/TODO | 1 - drivers/accel/amdxdna/aie2_ctx.c | 5 ++- drivers/accel/amdxdna/aie2_message.c | 5 ++- drivers/accel/amdxdna/aie2_pci.c | 6 +-- drivers/accel/amdxdna/amdxdna_ctx.c | 47 +++++++++------------ drivers/accel/amdxdna/amdxdna_mailbox.c | 56 ++++++++++--------------- drivers/accel/amdxdna/amdxdna_pci_drv.c | 4 +- drivers/accel/amdxdna/amdxdna_pci_drv.h | 8 +++- 8 files changed, 60 insertions(+), 72 deletions(-)drivers/accel/amdxdna/TODO +0
-1@@ -1,4 +1,3 @@ -- Replace idr with xa - Add import and export BO support - Add debugfs support - Add debug BO supportdrivers/accel/amdxdna/aie2_ctx.c +3
-2@@ -11,6 +11,7 @@#include <drm/drm_syncobj.h> #include <linux/hmm.h> #include <linux/types.h> +#include <linux/xarray.h> #include <trace/events/amdxdna.h> #include "aie2_msg_priv.h" @@ -90,11 +91,11 @@ void aie2_restart_ctx(struct amdxdna_client *client) {struct amdxdna_dev *xdna = client->xdna;struct amdxdna_hwctx *hwctx; -int next =0 ; +unsigned long hwctx_id;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));mutex_lock (&client->hwctx_lock); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) { +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) {if (hwctx->status !=HWCTX_STAT_STOP )continue ;drivers/accel/amdxdna/aie2_message.c +3
-2@@ -14,6 +14,7 @@#include <linux/errno.h> #include <linux/pci.h> #include <linux/types.h> +#include <linux/xarray.h> #include "aie2_msg_priv.h" #include "aie2_pci.h" @@ -315,10 +316,10 @@ int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf,struct amdxdna_dev *xdna = ndev->xdna;struct amdxdna_client *client;struct amdxdna_hwctx *hwctx; +unsigned long hwctx_id;dma_addr_t dma_addr;u32 aie_bitmap =0 ;u8 *buff_addr; -int next =0 ;int ret, idx; buff_addr = dma_alloc_noncoherent(xdna->ddev.dev, size, &dma_addr,@@ -329,7 +330,7 @@ int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf,/* Go through each hardware context and mark the AIE columns that are active */ list_for_each_entry (client, &xdna->client_list, node) { idx =srcu_read_lock (&client->hwctx_srcu); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) aie_bitmap |=amdxdna_hwctx_col_map (hwctx);srcu_read_unlock (&client->hwctx_srcu, idx); }drivers/accel/amdxdna/aie2_pci.c +3
-3@@ -15,6 +15,7 @@#include <linux/iommu.h> #include <linux/iopoll.h> #include <linux/pci.h> +#include <linux/xarray.h> #include "aie2_msg_priv.h" #include "aie2_pci.h" @@ -691,11 +692,11 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client,struct amdxdna_drm_query_hwctx *tmp;struct amdxdna_client *tmp_client;struct amdxdna_hwctx *hwctx; +unsigned long hwctx_id;bool overflow = false;u32 req_bytes =0 ;u32 hw_i =0 ;int ret =0 ; -int next;int idx;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));@@ -707,8 +708,7 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client, buf =u64_to_user_ptr (args->buffer);list_for_each_entry (tmp_client, &xdna->client_list, node) { idx =srcu_read_lock (&tmp_client->hwctx_srcu); - next =0 ; -idr_for_each_entry_continue (&tmp_client->hwctx_idr, hwctx, next) { +amdxdna_for_each_hwctx (tmp_client, hwctx_id, hwctx) { req_bytes +=sizeof (*tmp);if (args->buffer_size < req_bytes) {/* Continue iterating to get the required size */ drivers/accel/amdxdna/amdxdna_ctx.c +19
-28@@ -11,6 +11,7 @@#include <drm/drm_gem_shmem_helper.h> #include <drm/drm_print.h> #include <drm/gpu_scheduler.h> +#include <linux/xarray.h> #include <trace/events/amdxdna.h> #include "amdxdna_ctx.h" @@ -63,11 +64,11 @@ void amdxdna_hwctx_suspend(struct amdxdna_client *client) {struct amdxdna_dev *xdna = client->xdna;struct amdxdna_hwctx *hwctx; -int next =0 ; +unsigned long hwctx_id;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));mutex_lock (&client->hwctx_lock); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) xdna->dev_info->ops->hwctx_suspend (hwctx);mutex_unlock (&client->hwctx_lock); }@@ -76,11 +77,11 @@ void amdxdna_hwctx_resume(struct amdxdna_client *client) {struct amdxdna_dev *xdna = client->xdna;struct amdxdna_hwctx *hwctx; -int next =0 ; +unsigned long hwctx_id;drm_WARN_ON (&xdna->ddev, !mutex_is_locked (&xdna->dev_lock));mutex_lock (&client->hwctx_lock); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) xdna->dev_info->ops->hwctx_resume (hwctx);mutex_unlock (&client->hwctx_lock); }@@ -149,13 +150,13 @@ int amdxdna_cmd_get_cu_idx(struct amdxdna_gem_obj *abo)void amdxdna_hwctx_remove_all (struct amdxdna_client *client) {struct amdxdna_hwctx *hwctx; -int next =0 ; +unsigned long hwctx_id;mutex_lock (&client->hwctx_lock); -idr_for_each_entry_continue (&client->hwctx_idr, hwctx, next) { +amdxdna_for_each_hwctx (client, hwctx_id, hwctx) {XDNA_DBG (client->xdna,"PID %d close HW context %d" , client->pid, hwctx->id); -idr_remove (&client->hwctx_idr, hwctx->id); +xa_erase (&client->hwctx_xa, hwctx->id);mutex_unlock (&client->hwctx_lock);amdxdna_hwctx_destroy_rcu (hwctx, &client->hwctx_srcu);mutex_lock (&client->hwctx_lock);@@ -194,15 +195,13 @@ int amdxdna_drm_create_hwctx_ioctl(struct drm_device *dev, void *data, struct dr hwctx->num_tiles = args->num_tiles; hwctx->mem_size = args->mem_size; hwctx->max_opc = args->max_opc; -mutex_lock (&client->hwctx_lock); - ret =idr_alloc_cyclic (&client->hwctx_idr, hwctx,0 ,MAX_HWCTX_ID ,GFP_KERNEL ); + ret =xa_alloc_cyclic (&client->hwctx_xa, &hwctx->id, hwctx, +XA_LIMIT (AMDXDNA_INVALID_CTX_HANDLE +1 ,MAX_HWCTX_ID ), + &client->next_hwctxid,GFP_KERNEL );if (ret <0 ) { -mutex_unlock (&client->hwctx_lock);XDNA_ERR (xdna,"Allocate hwctx ID failed, ret %d" , ret); goto free_hwctx; } - hwctx->id = ret; -mutex_unlock (&client->hwctx_lock); hwctx->name =kasprintf (GFP_KERNEL ,"hwctx.%d.%d" , client->pid, hwctx->id);if (!hwctx->name) {@@ -228,9 +227,7 @@ int amdxdna_drm_create_hwctx_ioctl(struct drm_device *dev, void *data, struct dr free_name:kfree (hwctx->name); rm_id: -mutex_lock (&client->hwctx_lock); -idr_remove (&client->hwctx_idr, hwctx->id); -mutex_unlock (&client->hwctx_lock); +xa_erase (&client->hwctx_xa, hwctx->id); free_hwctx:kfree (hwctx); exit:@@ -249,24 +246,18 @@ int amdxdna_drm_destroy_hwctx_ioctl(struct drm_device *dev, void *data, struct dif (!drm_dev_enter (dev, &idx))return -ENODEV ; -/* -* Use hwctx_lock to achieve exclusion with other hwctx writers, -* SRCU to synchronize with exec/wait command ioctls. -* -* The pushed jobs are handled by DRM scheduler during destroy. -*/ -mutex_lock (&client->hwctx_lock); - hwctx =idr_find (&client->hwctx_idr, args->handle); + hwctx =xa_erase (&client->hwctx_xa, args->handle);if (!hwctx) { -mutex_unlock (&client->hwctx_lock); ret = -EINVAL ;XDNA_DBG (xdna,"PID %d HW context %d not exist" , client->pid, args->handle); goto out; } -idr_remove (&client->hwctx_idr, hwctx->id); -mutex_unlock (&client->hwctx_lock); +/* +* The pushed jobs are handled by DRM scheduler during destroy. +* SRCU to synchronize with exec command ioctls. +*/ amdxdna_hwctx_destroy_rcu (hwctx, &client->hwctx_srcu);XDNA_DBG (xdna,"PID %d destroyed HW context %d" , client->pid, args->handle);@@ -324,7 +315,7 @@ int amdxdna_drm_config_hwctx_ioctl(struct drm_device *dev, void *data, struct drmutex_lock (&xdna->dev_lock); idx =srcu_read_lock (&client->hwctx_srcu); - hwctx =idr_find (&client->hwctx_idr, args->handle); + hwctx =xa_load (&client->hwctx_xa, args->handle);if (!hwctx) {XDNA_DBG (xdna,"PID %d failed to get hwctx %d" , client->pid, args->handle); ret = -EINVAL ;@@ -436,7 +427,7 @@ int amdxdna_cmd_submit(struct amdxdna_client *client, } idx =srcu_read_lock (&client->hwctx_srcu); - hwctx =idr_find (&client->hwctx_idr, hwctx_hdl); + hwctx =xa_load (&client->hwctx_xa, hwctx_hdl);if (!hwctx) {XDNA_DBG (xdna,"PID %d failed to get hwctx %d" , client->pid, hwctx_hdl);drivers/accel/amdxdna/amdxdna_mailbox.c +23
-33@@ -8,6 +8,7 @@#include <linux/bitfield.h> #include <linux/interrupt.h> #include <linux/iopoll.h> +#include <linux/xarray.h> #define CREATE_TRACE_POINTS #include <trace/events/amdxdna.h> @@ -55,8 +56,8 @@ struct mailbox_channel {struct xdna_mailbox_chann_res res[CHAN_RES_NUM ];int msix_irq;u32 iohub_int_addr; -struct idr chan_idr; -spinlock_t chan_idr_lock;/* protect chan_idr */ +struct xarray chan_xa; +u32 next_msgid;u32 x2i_tail;/* Received msg related fields */ @@ -165,19 +166,17 @@ static inline int mailbox_validate_msgid(int msg_id)static int mailbox_acquire_msgid (struct mailbox_channel *mb_chann,struct mailbox_msg *mb_msg) { -unsigned long flags; -int msg_id; +u32 msg_id; +int ret; -spin_lock_irqsave (&mb_chann->chan_idr_lock, flags); - msg_id =idr_alloc_cyclic (&mb_chann->chan_idr, mb_msg,0 , -MAX_MSG_ID_ENTRIES ,GFP_NOWAIT ); -spin_unlock_irqrestore (&mb_chann->chan_idr_lock, flags); -if (msg_id <0 ) -return msg_id; + ret =xa_alloc_cyclic_irq (&mb_chann->chan_xa, &msg_id, mb_msg, +XA_LIMIT (0 ,MAX_MSG_ID_ENTRIES -1 ), + &mb_chann->next_msgid,GFP_NOWAIT ); +if (ret <0 ) +return ret;/* -* The IDR becomes less efficient when dealing with larger IDs. -* Thus, add MAGIC_VAL to the higher bits. +* Add MAGIC_VAL to the higher bits. */ msg_id |=MAGIC_VAL ;return msg_id;@@ -185,25 +184,17 @@ static int mailbox_acquire_msgid(struct mailbox_channel *mb_chann, struct mailbostatic void mailbox_release_msgid (struct mailbox_channel *mb_chann,int msg_id) { -unsigned long flags; - msg_id &= ~MAGIC_VAL_MASK ; -spin_lock_irqsave (&mb_chann->chan_idr_lock, flags); -idr_remove (&mb_chann->chan_idr, msg_id); -spin_unlock_irqrestore (&mb_chann->chan_idr_lock, flags); +xa_erase_irq (&mb_chann->chan_xa, msg_id); } -static int mailbox_release_msg (int id,void *p,void *data) +static void mailbox_release_msg (struct mailbox_channel *mb_chann, +struct mailbox_msg *mb_msg) { -struct mailbox_channel *mb_chann = data; -struct mailbox_msg *mb_msg = p; -MB_DBG (mb_chann,"msg_id 0x%x msg opcode 0x%x" , mb_msg->pkg.header.id, mb_msg->pkg.header.opcode); mb_msg->notify_cb (mb_msg->handle,NULL ,0 );kfree (mb_msg); - -return 0 ; } static int@@ -255,7 +246,6 @@ mailbox_get_resp(struct mailbox_channel *mb_chann, struct xdna_msg_header *heade void *data) {struct mailbox_msg *mb_msg; -unsigned long flags;int msg_id;int ret;@@ -266,15 +256,11 @@ mailbox_get_resp(struct mailbox_channel *mb_chann, struct xdna_msg_header *heade } msg_id &= ~MAGIC_VAL_MASK ; -spin_lock_irqsave (&mb_chann->chan_idr_lock, flags); - mb_msg =idr_find (&mb_chann->chan_idr, msg_id); + mb_msg =xa_erase_irq (&mb_chann->chan_xa, msg_id);if (!mb_msg) {MB_ERR (mb_chann,"Cannot find msg 0x%x" , msg_id); -spin_unlock_irqrestore (&mb_chann->chan_idr_lock, flags);return -EINVAL ; } -idr_remove (&mb_chann->chan_idr, msg_id); -spin_unlock_irqrestore (&mb_chann->chan_idr_lock, flags);MB_DBG (mb_chann,"opcode 0x%x size %d id 0x%x" , header->opcode, header->total_size, header->id);@@ -498,8 +484,7 @@ xdna_mailbox_create_channel(struct mailbox *mb,memcpy (&mb_chann->res[CHAN_RES_X2I ], x2i,sizeof (*x2i));memcpy (&mb_chann->res[CHAN_RES_I2X ], i2x,sizeof (*i2x)); -spin_lock_init (&mb_chann->chan_idr_lock); -idr_init (&mb_chann->chan_idr); +xa_init_flags (&mb_chann->chan_xa,XA_FLAGS_ALLOC |XA_FLAGS_LOCK_IRQ ); mb_chann->x2i_tail =mailbox_get_tailptr (mb_chann,CHAN_RES_X2I ); mb_chann->i2x_head =mailbox_get_headptr (mb_chann,CHAN_RES_I2X );@@ -531,13 +516,18 @@ xdna_mailbox_create_channel(struct mailbox *mb,int xdna_mailbox_destroy_channel (struct mailbox_channel *mb_chann) { +struct mailbox_msg *mb_msg; +unsigned long msg_id; +MB_DBG (mb_chann,"IRQ disabled and RX work cancelled" );free_irq (mb_chann->msix_irq, mb_chann);destroy_workqueue (mb_chann->work_q);/* We can clean up and release resources */ -idr_for_each (&mb_chann->chan_idr, mailbox_release_msg, mb_chann); -idr_destroy (&mb_chann->chan_idr); +xa_for_each (&mb_chann->chan_xa, msg_id, mb_msg) +mailbox_release_msg (mb_chann, mb_msg); + +xa_destroy (&mb_chann->chan_xa);MB_DBG (mb_chann,"Mailbox channel destroyed, irq: %d" , mb_chann->msix_irq);kfree (mb_chann);drivers/accel/amdxdna/amdxdna_pci_drv.c +2
-2@@ -78,7 +78,7 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp) }mutex_init (&client->hwctx_lock);init_srcu_struct (&client->hwctx_srcu); -idr_init_base (&client->hwctx_idr,AMDXDNA_INVALID_CTX_HANDLE +1 ); +xa_init_flags (&client->hwctx_xa,XA_FLAGS_ALLOC );mutex_init (&client->mm_lock);mutex_lock (&xdna->dev_lock);@@ -109,7 +109,7 @@ static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp)XDNA_DBG (xdna,"closing pid %d" , client->pid); -idr_destroy (&client->hwctx_idr); +xa_destroy (&client->hwctx_xa);cleanup_srcu_struct (&client->hwctx_srcu);mutex_destroy (&client->hwctx_lock);mutex_destroy (&client->mm_lock);drivers/accel/amdxdna/amdxdna_pci_drv.h +7
-1@@ -6,6 +6,8 @@#ifndef _AMDXDNA_PCI_DRV_H_#define _AMDXDNA_PCI_DRV_H_ +#include <linux/xarray.h> + #define XDNA_INFO(xdna, fmt, args...) drm_info(&(xdna)->ddev, fmt, ##args) #define XDNA_WARN(xdna, fmt, args...) drm_warn(&(xdna)->ddev, "%s: "fmt, __func__, ##args) #define XDNA_ERR(xdna, fmt, args...) drm_err(&(xdna)->ddev, "%s: "fmt, __func__, ##args)@@ -100,7 +102,8 @@ struct amdxdna_client {struct mutex hwctx_lock;/* protect hwctx */ /* do NOT wait this srcu when hwctx_lock is held */ struct srcu_struct hwctx_srcu; -struct idr hwctx_idr; +struct xarray hwctx_xa; +u32 next_hwctxid;struct amdxdna_dev *xdna;struct drm_file *filp;@@ -111,6 +114,9 @@ struct amdxdna_client {int pasid; }; +#define amdxdna_for_each_hwctx (client, hwctx_id, entry) \ + xa_for_each(&(client)->hwctx_xa, hwctx_id, entry) +/* Add device info below */ extern const struct amdxdna_dev_info dev_npu1_info;extern const struct amdxdna_dev_info dev_npu2_info;
Lizhi Hou
maintainerPATCH v3 3/5 accel/amdxdna: Enhance power management settings
In reply to Lizhi HouAdd SET_STATE ioctl to configure device power mode for aie2 device. Three modes are supported initially.
POWER_MODE_DEFAULT: Enable clock gating and set DPM (Dynamic Power Management) level to value which has been set by resource solver or maximum DPM level the device supports.
POWER_MODE_HIGH: Enable clock gating and set DPM level to maximum DPM level the device supports.
POWER_MODE_TURBO: Disable clock gating and set DPM level to maximum DPM level the device supports.
Disabling clock gating means all clocks always run on full speed. And the different clock frequency are used based on DPM level been set. Initially, the driver set the power mode to default mode.
--- drivers/accel/amdxdna/Makefile | 1 + drivers/accel/amdxdna/TODO | 1 - drivers/accel/amdxdna/aie2_ctx.c | 6 + drivers/accel/amdxdna/aie2_message.c | 9 +- drivers/accel/amdxdna/aie2_pci.c | 139 +++++++++++++++++++----- drivers/accel/amdxdna/aie2_pci.h | 55 ++++++++-- drivers/accel/amdxdna/aie2_pm.c | 108 ++++++++++++++++++ drivers/accel/amdxdna/aie2_smu.c | 85 +++++++++------ drivers/accel/amdxdna/aie2_solver.c | 59 +++++++++- drivers/accel/amdxdna/aie2_solver.h | 1 + drivers/accel/amdxdna/amdxdna_pci_drv.c | 19 ++++ drivers/accel/amdxdna/amdxdna_pci_drv.h | 17 +++ drivers/accel/amdxdna/npu1_regs.c | 29 +++-- drivers/accel/amdxdna/npu2_regs.c | 15 +-- drivers/accel/amdxdna/npu4_regs.c | 32 ++++-- drivers/accel/amdxdna/npu5_regs.c | 15 +-- drivers/accel/amdxdna/npu6_regs.c | 19 +--- include/uapi/drm/amdxdna_accel.h | 52 +++++++++ 18 files changed, 534 insertions(+), 128 deletions(-) create mode 100644 drivers/accel/amdxdna/aie2_pm.c
drivers/accel/amdxdna/Makefile +1 -0
@@ -5,6 +5,7 @@ amdxdna-y := \ aie2_error.o \ aie2_message.o \ aie2_pci.o \ + aie2_pm.o \ aie2_psp.o \ aie2_smu.o \ aie2_solver.o \
drivers/accel/amdxdna/TODO +0 -1
@@ -1,4 +1,3 @@ - Add import and export BO support - Add debugfs support - Add debug BO support -- Improve power management
drivers/accel/amdxdna/aie2_ctx.c +6 -0
@@ -519,6 +519,7 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)struct drm_gpu_scheduler *sched;struct amdxdna_hwctx_priv *priv;struct amdxdna_gem_obj *heap; +struct amdxdna_dev_hdl *ndev;int i, ret; priv =kzalloc (sizeof (*hwctx->priv),GFP_KERNEL );
@@ -613,6 +614,8 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx) } hwctx->status =HWCTX_STAT_INIT ; + ndev = xdna->dev_handle; + ndev->hwctx_num++;XDNA_DBG (xdna,"hwctx %s init completed" , hwctx->name);
@@ -642,10 +645,13 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)void aie2_hwctx_fini (struct amdxdna_hwctx *hwctx) { +struct amdxdna_dev_hdl *ndev;struct amdxdna_dev *xdna;int idx; xdna = hwctx->client->xdna; + ndev = xdna->dev_handle; + ndev->hwctx_num--;drm_sched_wqueue_stop (&hwctx->priv->sched);/* Now, scheduler will not send command to device. */
drivers/accel/amdxdna/aie2_message.c +8 -1
@@ -71,11 +71,18 @@ int aie2_resume_fw(struct amdxdna_dev_hdl *ndev)int aie2_set_runtime_cfg (struct amdxdna_dev_hdl *ndev,u32 type,u64 value) {DECLARE_AIE2_MSG (set_runtime_cfg,MSG_OP_SET_RUNTIME_CONFIG ); +int ret; req.type = type; req.value = value; -return aie2_send_mgmt_msg_wait (ndev, &msg); + ret =aie2_send_mgmt_msg_wait (ndev, &msg); +if (ret) { +XDNA_ERR (ndev->xdna,"Failed to set runtime config, ret %d" , ret); +return ret; + } + +return 0 ; }int aie2_get_runtime_cfg (struct amdxdna_dev_hdl *ndev,u32 type,u64 *value)
drivers/accel/amdxdna/aie2_pci.c +113 -26
208 lines not on this page · raw message
drivers/accel/amdxdna/aie2_pci.h +44 -11
119 lines not on this page · raw message
drivers/accel/amdxdna/aie2_pm.c new file +108 -0
108 lines not on this page · raw message
drivers/accel/amdxdna/aie2_smu.c +50 -35
134 lines not on this page · raw message
drivers/accel/amdxdna/aie2_solver.c +54 -5
90 lines not on this page · raw message
drivers/accel/amdxdna/aie2_solver.h +1 -0
@@ -99,6 +99,7 @@ struct clk_list_info {struct xrs_action_ops {int (*load)(void *cb_arg,struct xrs_action_load *action);int (*unload)(void *cb_arg); +int (*set_dft_dpm_level)(struct drm_device *ddev,u32 level); };/*
drivers/accel/amdxdna/amdxdna_pci_drv.c +19 -0
@@ -161,6 +161,24 @@ static int amdxdna_drm_get_info_ioctl(struct drm_device *dev, void *data, structreturn ret; } +static int amdxdna_drm_set_state_ioctl (struct drm_device *dev,void *data,struct drm_file *filp) +{ +struct amdxdna_client *client = filp->driver_priv; +struct amdxdna_dev *xdna =to_xdna_dev (dev); +struct amdxdna_drm_set_state *args = data; +int ret; + +if (!xdna->dev_info->ops->set_aie_state) +return -EOPNOTSUPP ; + +XDNA_DBG (xdna,"Request parameter %u" , args->param); +mutex_lock (&xdna->dev_lock); + ret = xdna->dev_info->ops->set_aie_state (client, args); +mutex_unlock (&xdna->dev_lock); + +return ret; +} +static const struct drm_ioctl_desc amdxdna_drm_ioctls[] = {/* Context */ DRM_IOCTL_DEF_DRV (AMDXDNA_CREATE_HWCTX , amdxdna_drm_create_hwctx_ioctl,0 ),
@@ -174,6 +192,7 @@ static const struct drm_ioctl_desc amdxdna_drm_ioctls[] = {DRM_IOCTL_DEF_DRV (AMDXDNA_EXEC_CMD , amdxdna_drm_submit_cmd_ioctl,0 ),/* AIE hardware */ DRM_IOCTL_DEF_DRV (AMDXDNA_GET_INFO , amdxdna_drm_get_info_ioctl,0 ), + DRM_IOCTL_DEF_DRV(AMDXDNA_SET_STATE, amdxdna_drm_set_state_ioctl, DRM_ROOT_ONLY), }; static const struct file_operations amdxdna_fops = {
drivers/accel/amdxdna/amdxdna_pci_drv.h +17 -0
@@ -14,6 +14,21 @@ #define XDNA_DBG(xdna, fmt, args...) drm_dbg(&(xdna)->ddev, fmt, ##args) #define XDNA_INFO_ONCE(xdna, fmt, args...) drm_info_once(&(xdna)->ddev, fmt, ##args) +#define XDNA_MBZ_DBG (xdna, ptr, sz) \ + ({ \ + int __i; \ + int __ret = 0; \ + u8 *__ptr = (u8 *)(ptr); \ + for (__i = 0; __i < (sz); __i++) { \ + if (__ptr[__i]) { \ + XDNA_DBG(xdna, "MBZ check failed"); \ + __ret = -EINVAL; \ + break; \ + } \ + } \ + __ret; \ + }) +#define to_xdna_dev (drm_dev) \ ((struct amdxdna_dev *)container_of(drm_dev, struct amdxdna_dev, ddev))
@@ -22,6 +37,7 @@ extern const struct drm_driver amdxdna_drm_drv;struct amdxdna_client ;struct amdxdna_dev ;struct amdxdna_drm_get_info ; +struct amdxdna_drm_set_state ;struct amdxdna_gem_obj ;struct amdxdna_hwctx ;struct amdxdna_sched_job ;
@@ -42,6 +58,7 @@ struct amdxdna_dev_ops {void (*hwctx_resume)(struct amdxdna_hwctx *hwctx);int (*cmd_submit)(struct amdxdna_hwctx *hwctx,struct amdxdna_sched_job *job,u64 *seq);int (*get_aie_info)(struct amdxdna_client *client,struct amdxdna_drm_get_info *args); +int (*set_aie_state)(struct amdxdna_client *client,struct amdxdna_drm_set_state *args); };/*
drivers/accel/amdxdna/npu1_regs.c +21 -8
@@ -44,18 +44,30 @@#define NPU1_SMU_BAR_BASE MPNPU_APERTURE0_BASE#define NPU1_SRAM_BAR_BASE MPNPU_APERTURE1_BASE -#define NPU1_RT_CFG_TYPE_PDI_LOAD 2 -#define NPU1_RT_CFG_VAL_PDI_LOAD_MGMT 0 -#define NPU1_RT_CFG_VAL_PDI_LOAD_APP 1 +const struct rt_config npu1_default_rt_cfg[] = { + {2 ,1 ,AIE2_RT_CFG_INIT },/* PDI APP LOAD MODE */ + {1 ,1 ,AIE2_RT_CFG_CLK_GATING },/* Clock gating on */ + {0 }, +}; -#define NPU1_MPNPUCLK_FREQ_MAX 600 -#define NPU1_HCLK_FREQ_MAX 1024 +const struct dpm_clk_freq npu1_dpm_clk_table[] = { + {400 ,800 }, + {600 ,1024 }, + {600 ,1024 }, + {600 ,1024 }, + {600 ,1024 }, + {720 ,1309 }, + {720 ,1309 }, + {847 ,1600 }, + {0 } +};const struct amdxdna_dev_priv npu1_dev_priv = { .fw_path ="amdnpu/1502_00/npu.sbin" , .protocol_major =0x5 , .protocol_minor =0x1 , - .rt_config = {NPU1_RT_CFG_TYPE_PDI_LOAD ,NPU1_RT_CFG_VAL_PDI_LOAD_APP }, + .rt_config = npu1_default_rt_cfg, + .dpm_clk_tbl = npu1_dpm_clk_table, .col_align =COL_ALIGN_NONE , .mbox_dev_addr =NPU1_MBOX_BAR_BASE , .mbox_size =0 ,/* Use BAR size */
@@ -80,8 +92,9 @@ const struct amdxdna_dev_priv npu1_dev_priv = {DEFINE_BAR_OFFSET (SMU_RESP_REG ,NPU1_SMU ,MPNPU_PUB_SCRATCH6 ), DEFINE_BAR_OFFSET(SMU_OUT_REG, NPU1_SMU, MPNPU_PUB_SCRATCH7), }, - .smu_mpnpuclk_freq_max =NPU1_MPNPUCLK_FREQ_MAX , - .smu_hclk_freq_max = NPU1_HCLK_FREQ_MAX, + .hw_ops = { + .set_dpm = npu1_set_dpm, + }, }; const struct amdxdna_dev_info dev_npu1_info = {
drivers/accel/amdxdna/npu2_regs.c +5 -10
@@ -61,18 +61,12 @@#define NPU2_SMU_BAR_BASE MMNPU_APERTURE4_BASE#define NPU2_SRAM_BAR_BASE MMNPU_APERTURE1_BASE -#define NPU2_RT_CFG_TYPE_PDI_LOAD 5 -#define NPU2_RT_CFG_VAL_PDI_LOAD_MGMT 0 -#define NPU2_RT_CFG_VAL_PDI_LOAD_APP 1 - -#define NPU2_MPNPUCLK_FREQ_MAX 1267 -#define NPU2_HCLK_FREQ_MAX 1800 -const struct amdxdna_dev_priv npu2_dev_priv = { .fw_path ="amdnpu/17f0_00/npu.sbin" , .protocol_major =0x6 , .protocol_minor =0x1 , - .rt_config = {NPU2_RT_CFG_TYPE_PDI_LOAD ,NPU2_RT_CFG_VAL_PDI_LOAD_APP }, + .rt_config = npu4_default_rt_cfg, + .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE , .mbox_dev_addr =NPU2_MBOX_BAR_BASE , .mbox_size =0 ,/* Use BAR size */
@@ -97,8 +91,9 @@ const struct amdxdna_dev_priv npu2_dev_priv = {DEFINE_BAR_OFFSET (SMU_RESP_REG ,NPU2_SMU ,MP1_C2PMSG_61 ), DEFINE_BAR_OFFSET(SMU_OUT_REG, NPU2_SMU, MP1_C2PMSG_60), }, - .smu_mpnpuclk_freq_max =NPU2_MPNPUCLK_FREQ_MAX , - .smu_hclk_freq_max = NPU2_HCLK_FREQ_MAX, + .hw_ops = { + .set_dpm = npu4_set_dpm, + }, }; const struct amdxdna_dev_info dev_npu2_info = {
drivers/accel/amdxdna/npu4_regs.c +24 -8
@@ -61,18 +61,33 @@#define NPU4_SMU_BAR_BASE MMNPU_APERTURE4_BASE#define NPU4_SRAM_BAR_BASE MMNPU_APERTURE1_BASE -#define NPU4_RT_CFG_TYPE_PDI_LOAD 5 -#define NPU4_RT_CFG_VAL_PDI_LOAD_MGMT 0 -#define NPU4_RT_CFG_VAL_PDI_LOAD_APP 1 +const struct rt_config npu4_default_rt_cfg[] = { + {5 ,1 ,AIE2_RT_CFG_INIT },/* PDI APP LOAD MODE */ + {1 ,1 ,AIE2_RT_CFG_CLK_GATING },/* Clock gating on */ + {2 ,1 ,AIE2_RT_CFG_CLK_GATING },/* Clock gating on */ + {3 ,1 ,AIE2_RT_CFG_CLK_GATING },/* Clock gating on */ + {4 ,1 ,AIE2_RT_CFG_CLK_GATING },/* Clock gating on */ + {0 }, +}; -#define NPU4_MPNPUCLK_FREQ_MAX 1267 -#define NPU4_HCLK_FREQ_MAX 1800 +const struct dpm_clk_freq npu4_dpm_clk_table[] = { + {396 ,792 }, + {600 ,1056 }, + {792 ,1152 }, + {975 ,1267 }, + {975 ,1267 }, + {1056 ,1408 }, + {1152 ,1584 }, + {1267 ,1800 }, + {0 } +};const struct amdxdna_dev_priv npu4_dev_priv = { .fw_path ="amdnpu/17f0_10/npu.sbin" , .protocol_major =0x6 , .protocol_minor =0x1 , - .rt_config = {NPU4_RT_CFG_TYPE_PDI_LOAD ,NPU4_RT_CFG_VAL_PDI_LOAD_APP }, + .rt_config = npu4_default_rt_cfg, + .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE , .mbox_dev_addr =NPU4_MBOX_BAR_BASE , .mbox_size =0 ,/* Use BAR size */
@@ -97,8 +112,9 @@ const struct amdxdna_dev_priv npu4_dev_priv = {DEFINE_BAR_OFFSET (SMU_RESP_REG ,NPU4_SMU ,MP1_C2PMSG_61 ), DEFINE_BAR_OFFSET(SMU_OUT_REG, NPU4_SMU, MP1_C2PMSG_60), }, - .smu_mpnpuclk_freq_max =NPU4_MPNPUCLK_FREQ_MAX , - .smu_hclk_freq_max = NPU4_HCLK_FREQ_MAX, + .hw_ops = { + .set_dpm = npu4_set_dpm, + }, }; const struct amdxdna_dev_info dev_npu4_info = {
drivers/accel/amdxdna/npu5_regs.c +5 -10
@@ -61,18 +61,12 @@#define NPU5_SMU_BAR_BASE MMNPU_APERTURE4_BASE#define NPU5_SRAM_BAR_BASE MMNPU_APERTURE1_BASE -#define NPU5_RT_CFG_TYPE_PDI_LOAD 5 -#define NPU5_RT_CFG_VAL_PDI_LOAD_MGMT 0 -#define NPU5_RT_CFG_VAL_PDI_LOAD_APP 1 - -#define NPU5_MPNPUCLK_FREQ_MAX 1267 -#define NPU5_HCLK_FREQ_MAX 1800 -const struct amdxdna_dev_priv npu5_dev_priv = { .fw_path ="amdnpu/17f0_11/npu.sbin" , .protocol_major =0x6 , .protocol_minor =0x1 , - .rt_config = {NPU5_RT_CFG_TYPE_PDI_LOAD ,NPU5_RT_CFG_VAL_PDI_LOAD_APP }, + .rt_config = npu4_default_rt_cfg, + .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE , .mbox_dev_addr =NPU5_MBOX_BAR_BASE , .mbox_size =0 ,/* Use BAR size */
@@ -97,8 +91,9 @@ const struct amdxdna_dev_priv npu5_dev_priv = {DEFINE_BAR_OFFSET (SMU_RESP_REG ,NPU5_SMU ,MP1_C2PMSG_61 ), DEFINE_BAR_OFFSET(SMU_OUT_REG, NPU5_SMU, MP1_C2PMSG_60), }, - .smu_mpnpuclk_freq_max =NPU5_MPNPUCLK_FREQ_MAX , - .smu_hclk_freq_max = NPU5_HCLK_FREQ_MAX, + .hw_ops = { + .set_dpm = npu4_set_dpm, + }, }; const struct amdxdna_dev_info dev_npu5_info = {
drivers/accel/amdxdna/npu6_regs.c +6 -13
@@ -61,23 +61,12 @@#define NPU6_SMU_BAR_BASE MMNPU_APERTURE4_BASE#define NPU6_SRAM_BAR_BASE MMNPU_APERTURE1_BASE -#define NPU6_RT_CFG_TYPE_PDI_LOAD 5 -#define NPU6_RT_CFG_TYPE_DEBUG_BO 10 - -#define NPU6_RT_CFG_VAL_PDI_LOAD_MGMT 0 -#define NPU6_RT_CFG_VAL_PDI_LOAD_APP 1 - -#define NPU6_RT_CFG_VAL_DEBUG_BO_DEFAULT 0 -#define NPU6_RT_CFG_VAL_DEBUG_BO_LARGE 1 - -#define NPU6_MPNPUCLK_FREQ_MAX 1267 -#define NPU6_HCLK_FREQ_MAX 1800 -const struct amdxdna_dev_priv npu6_dev_priv = { .fw_path ="amdnpu/17f0_10/npu.sbin" , .protocol_major =0x6 , .protocol_minor =12 , - .rt_config = {NPU6_RT_CFG_TYPE_PDI_LOAD ,NPU6_RT_CFG_VAL_PDI_LOAD_APP }, + .rt_config = npu4_default_rt_cfg, + .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE , .mbox_dev_addr =NPU6_MBOX_BAR_BASE , .mbox_size =0 ,/* Use BAR size */
@@ -102,6 +91,10 @@ const struct amdxdna_dev_priv npu6_dev_priv = {DEFINE_BAR_OFFSET (SMU_RESP_REG ,NPU6_SMU ,MP1_C2PMSG_61 ), DEFINE_BAR_OFFSET(SMU_OUT_REG, NPU6_SMU, MP1_C2PMSG_60), }, + .hw_ops = { + .set_dpm = npu4_set_dpm, + }, + }; const struct amdxdna_dev_info dev_npu6_info = {
include/uapi/drm/amdxdna_accel.h +52 -0
82 lines not on this page · raw message
Signature · 1 line
2.34.1
Lizhi Hou
maintainerPATCH v3 4/5 accel/amdxdna: Read firmware interface version from registers
In reply to Lizhi HouThe latest released firmware supports reading firmware interface version from registers directly. The driver's probe routine reads the major and minor version numbers. If the firmware interface is not compatible with the driver, the driver's probe routine returns failure.
--- drivers/accel/amdxdna/aie2_message.c | 26 ---------- drivers/accel/amdxdna/aie2_pci.c | 74 ++++++++++++++++++++++------ drivers/accel/amdxdna/aie2_pci.h | 6 +-- drivers/accel/amdxdna/npu1_regs.c | 2 +- drivers/accel/amdxdna/npu2_regs.c | 2 +- drivers/accel/amdxdna/npu4_regs.c | 2 +- drivers/accel/amdxdna/npu5_regs.c | 2 +- 7 files changed, 64 insertions(+), 50 deletions(-)
drivers/accel/amdxdna/aie2_message.c +0 -26
@@ -101,32 +101,6 @@ int aie2_get_runtime_cfg(struct amdxdna_dev_hdl *ndev, u32 type, u64 *value)return 0 ; } -int aie2_check_protocol_version (struct amdxdna_dev_hdl *ndev) -{ -DECLARE_AIE2_MSG (protocol_version,MSG_OP_GET_PROTOCOL_VERSION ); -struct amdxdna_dev *xdna = ndev->xdna; -int ret; - - ret =aie2_send_mgmt_msg_wait (ndev, &msg); -if (ret) { -XDNA_ERR (xdna,"Failed to get protocol version, ret %d" , ret); -return ret; - } - -if (resp.major != ndev->priv->protocol_major) { -XDNA_ERR (xdna,"Incompatible firmware protocol version major %d minor %d" , - resp.major, resp.minor); -return -EINVAL ; - } - -if (resp.minor < ndev->priv->protocol_minor) { -XDNA_ERR (xdna,"Firmware minor version smaller than supported" ); -return -EINVAL ; - } - -return 0 ; -} -int aie2_assign_mgmt_pasid (struct amdxdna_dev_hdl *ndev,u16 pasid) {DECLARE_AIE2_MSG (assign_mgmt_pasid,MSG_OP_ASSIGN_MGMT_PASID );
drivers/accel/amdxdna/aie2_pci.c +58 -16
113 lines not on this page · raw message
drivers/accel/amdxdna/aie2_pci.h +2 -4
@@ -39,9 +39,6 @@ })#define CHAN_SLOT_SZ SZ_8K -#define CHANN_INDEX (ndev, rbuf_off) \ - (((rbuf_off) - SRAM_REG_OFF((ndev), MBOX_CHANN_OFF)) / CHAN_SLOT_SZ) -#define MBOX_SIZE (ndev) \ ({ \ typeof(ndev) _ndev = (ndev); \
@@ -170,6 +167,8 @@ struct amdxdna_dev_hdl {struct xdna_mailbox_chann_res mgmt_x2i;struct xdna_mailbox_chann_res mgmt_i2x;u32 mgmt_chan_idx; +u32 mgmt_prot_major; +u32 mgmt_prot_minor;u32 total_col;struct aie_version version;
@@ -262,7 +261,6 @@ int aie2_suspend_fw(struct amdxdna_dev_hdl *ndev);int aie2_resume_fw (struct amdxdna_dev_hdl *ndev);int aie2_set_runtime_cfg (struct amdxdna_dev_hdl *ndev,u32 type,u64 value);int aie2_get_runtime_cfg (struct amdxdna_dev_hdl *ndev,u32 type,u64 *value); -int aie2_check_protocol_version (struct amdxdna_dev_hdl *ndev);int aie2_assign_mgmt_pasid (struct amdxdna_dev_hdl *ndev,u16 pasid);int aie2_query_aie_version (struct amdxdna_dev_hdl *ndev,struct aie_version *version);int aie2_query_aie_metadata (struct amdxdna_dev_hdl *ndev,struct aie_metadata *metadata);
drivers/accel/amdxdna/npu1_regs.c +1 -1
@@ -65,7 +65,7 @@ const struct dpm_clk_freq npu1_dpm_clk_table[] = {const struct amdxdna_dev_priv npu1_dev_priv = { .fw_path ="amdnpu/1502_00/npu.sbin" , .protocol_major =0x5 , - .protocol_minor =0x1 , + .protocol_minor =0x7 , .rt_config = npu1_default_rt_cfg, .dpm_clk_tbl = npu1_dpm_clk_table, .col_align =COL_ALIGN_NONE ,
drivers/accel/amdxdna/npu2_regs.c +1 -1
@@ -64,7 +64,7 @@const struct amdxdna_dev_priv npu2_dev_priv = { .fw_path ="amdnpu/17f0_00/npu.sbin" , .protocol_major =0x6 , - .protocol_minor =0x1 , + .protocol_minor =0x6 , .rt_config = npu4_default_rt_cfg, .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE ,
drivers/accel/amdxdna/npu4_regs.c +1 -1
@@ -85,7 +85,7 @@ const struct dpm_clk_freq npu4_dpm_clk_table[] = {const struct amdxdna_dev_priv npu4_dev_priv = { .fw_path ="amdnpu/17f0_10/npu.sbin" , .protocol_major =0x6 , - .protocol_minor =0x1 , + .protocol_minor =12 , .rt_config = npu4_default_rt_cfg, .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE ,
drivers/accel/amdxdna/npu5_regs.c +1 -1
@@ -64,7 +64,7 @@const struct amdxdna_dev_priv npu5_dev_priv = { .fw_path ="amdnpu/17f0_11/npu.sbin" , .protocol_major =0x6 , - .protocol_minor =0x1 , + .protocol_minor =12 , .rt_config = npu4_default_rt_cfg, .dpm_clk_tbl = npu4_dpm_clk_table, .col_align =COL_ALIGN_NATURE ,
Signature · 1 line
2.34.1
Lizhi Hou
maintainerPATCH v3 5/5 accel/amdxdna: Add zero check for pad in ioctl input structures
In reply to Lizhi HouFor input structures, it is better to check if the pad is zero. Thus, the pad bytes might be usable in the future.
--- drivers/accel/amdxdna/aie2_ctx.c | 3 +++ drivers/accel/amdxdna/aie2_message.c | 3 +++ drivers/accel/amdxdna/amdxdna_ctx.c | 6 ++++++ drivers/accel/amdxdna/amdxdna_gem.c | 2 +- include/uapi/drm/amdxdna_accel.h | 11 +++++------ 5 files changed, 18 insertions(+), 7 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +3 -0
@@ -690,6 +690,9 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 sizeint ret;XDNA_DBG (xdna,"Config %d CU to %s" , config->num_cus, hwctx->name); +if (XDNA_MBZ_DBG (xdna, config->pad,sizeof (config->pad))) +return -EINVAL ; +if (hwctx->status !=HWCTX_STAT_INIT ) {XDNA_ERR (xdna,"Not support re-config CU" );return -EINVAL ;
drivers/accel/amdxdna/aie2_message.c +3 -0
@@ -395,6 +395,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx)for (i =0 ; i < hwctx->cus->num_cus; i++) {struct amdxdna_cu_config *cu = &hwctx->cus->cu_configs[i]; +if (XDNA_MBZ_DBG (xdna, cu->pad,sizeof (cu->pad))) +return -EINVAL ; + gobj =drm_gem_object_lookup (hwctx->client->filp, cu->cu_bo);if (!gobj) {XDNA_ERR (xdna,"Lookup GEM object failed" );
drivers/accel/amdxdna/amdxdna_ctx.c +6 -0
@@ -243,6 +243,9 @@ int amdxdna_drm_destroy_hwctx_ioctl(struct drm_device *dev, void *data, struct dstruct amdxdna_hwctx *hwctx;int ret =0 , idx; +if (XDNA_MBZ_DBG (xdna, &args->pad,sizeof (args->pad))) +return -EINVAL ; +if (!drm_dev_enter (dev, &idx))return -ENODEV ;
@@ -277,6 +280,9 @@ int amdxdna_drm_config_hwctx_ioctl(struct drm_device *dev, void *data, struct drvoid *buf;u64 val; +if (XDNA_MBZ_DBG (xdna, &args->pad,sizeof (args->pad))) +return -EINVAL ; +if (!xdna->dev_info->ops->hwctx_config)return -EOPNOTSUPP ;
drivers/accel/amdxdna/amdxdna_gem.c +1 -1
@@ -552,7 +552,7 @@ int amdxdna_drm_get_bo_info_ioctl(struct drm_device *dev, void *data, struct drmstruct drm_gem_object *gobj;int ret =0 ; -if (args->ext || args->ext_flags) +if (args->ext || args->ext_flags || args->pad)return -EINVAL ; gobj =drm_gem_object_lookup (filp, args->handle);
include/uapi/drm/amdxdna_accel.h +5 -6
@@ -87,7 +87,7 @@ struct amdxdna_drm_create_hwctx {/** * struct amdxdna_drm_destroy_hwctx - Destroy hardware context. * @handle: Hardware context handle. -* @pad: Structure padding. +* @pad: MBZ. */ struct amdxdna_drm_destroy_hwctx {__u32 handle;
@@ -98,7 +98,7 @@ struct amdxdna_drm_destroy_hwctx {* struct amdxdna_cu_config - configuration for one CU * @cu_bo: CU configuration buffer bo handle. * @cu_func: Function of a CU. -* @pad: Structure padding. +* @pad: MBZ. */ struct amdxdna_cu_config {__u32 cu_bo;
@@ -109,7 +109,7 @@ struct amdxdna_cu_config {/** * struct amdxdna_hwctx_param_config_cu - configuration for CUs in hardware context * @num_cus: Number of CUs to configure. -* @pad: Structure padding. +* @pad: MBZ. * @cu_configs: Array of CU configurations of struct amdxdna_cu_config. */ struct amdxdna_hwctx_param_config_cu {
@@ -122,7 +122,6 @@ enum amdxdna_drm_config_hwctx_param {DRM_AMDXDNA_HWCTX_CONFIG_CU ,DRM_AMDXDNA_HWCTX_ASSIGN_DBG_BUF , DRM_AMDXDNA_HWCTX_REMOVE_DBG_BUF, - DRM_AMDXDNA_HWCTX_CONFIG_NUM };/**
@@ -133,7 +132,7 @@ enum amdxdna_drm_config_hwctx_param {* @param_val: A structure specified by the param_type struct member. * @param_val_size: Size of the parameter buffer pointed to by the param_val. * If param_val is not a pointer, driver can ignore this. -* @pad: Structure padding. +* @pad: MBZ. * * Note: if the param_val is a pointer pointing to a buffer, the maximum size * of the buffer is 4KiB(PAGE_SIZE).
@@ -175,7 +174,7 @@ struct amdxdna_drm_create_bo {* @ext: MBZ. * @ext_flags: MBZ. * @handle: DRM buffer object handle. -* @pad: Structure padding. +* @pad: MBZ. * @map_offset: Returned DRM fake offset for mmap(). * @vaddr: Returned user VA of buffer. 0 in case user needs mmap(). * @xdna_addr: Returned XDNA device virtual address.
Signature · 1 line
2.34.1
Re: [PATCH V3 5/5] accel/amdxdna: Add zero check for pad in ioctl input structures
Quoted 3 lines · Lizhi Hou
For input structures, it is better to check if the pad is zero. Thus, the pad bytes might be usable in the future.
IIRC you should pick up:
Quoted 106 lines
Signed-off-by Lizhi Hou <[email protected]>--- drivers/accel/amdxdna/aie2_ctx.c | 3 +++ drivers/accel/amdxdna/aie2_message.c | 3 +++ drivers/accel/amdxdna/amdxdna_ctx.c | 6 ++++++ drivers/accel/amdxdna/amdxdna_gem.c | 2 +- include/uapi/drm/amdxdna_accel.h | 11 +++++------ 5 files changed, 18 insertions(+), 7 deletions(-)drivers/accel/amdxdna/aie2_ctx.c +3
-0@@ -690,6 +690,9 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 sizeint ret;XDNA_DBG (xdna,"Config %d CU to %s" , config->num_cus, hwctx->name); +if (XDNA_MBZ_DBG (xdna, config->pad,sizeof (config->pad))) +return -EINVAL ; +if (hwctx->status !=HWCTX_STAT_INIT ) {XDNA_ERR (xdna,"Not support re-config CU" );return -EINVAL ;drivers/accel/amdxdna/aie2_message.c +3
-0@@ -395,6 +395,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx)for (i =0 ; i < hwctx->cus->num_cus; i++) {struct amdxdna_cu_config *cu = &hwctx->cus->cu_configs[i]; +if (XDNA_MBZ_DBG (xdna, cu->pad,sizeof (cu->pad))) +return -EINVAL ; + gobj =drm_gem_object_lookup (hwctx->client->filp, cu->cu_bo);if (!gobj) {XDNA_ERR (xdna,"Lookup GEM object failed" );drivers/accel/amdxdna/amdxdna_ctx.c +6
-0@@ -243,6 +243,9 @@ int amdxdna_drm_destroy_hwctx_ioctl(struct drm_device *dev, void *data, struct dstruct amdxdna_hwctx *hwctx;int ret =0 , idx; +if (XDNA_MBZ_DBG (xdna, &args->pad,sizeof (args->pad))) +return -EINVAL ; +if (!drm_dev_enter (dev, &idx))return -ENODEV ;@@ -277,6 +280,9 @@ int amdxdna_drm_config_hwctx_ioctl(struct drm_device *dev, void *data, struct drvoid *buf;u64 val; +if (XDNA_MBZ_DBG (xdna, &args->pad,sizeof (args->pad))) +return -EINVAL ; +if (!xdna->dev_info->ops->hwctx_config)return -EOPNOTSUPP ;drivers/accel/amdxdna/amdxdna_gem.c +1
-1@@ -552,7 +552,7 @@ int amdxdna_drm_get_bo_info_ioctl(struct drm_device *dev, void *data, struct drmstruct drm_gem_object *gobj;int ret =0 ; -if (args->ext || args->ext_flags) +if (args->ext || args->ext_flags || args->pad)return -EINVAL ; gobj =drm_gem_object_lookup (filp, args->handle);include/uapi/drm/amdxdna_accel.h +3
-3@@ -87,7 +87,7 @@ struct amdxdna_drm_create_hwctx {/** * struct amdxdna_drm_destroy_hwctx - Destroy hardware context. * @handle: Hardware context handle. -* @pad: Structure padding. +* @pad: MBZ. */ struct amdxdna_drm_destroy_hwctx {__u32 handle;@@ -98,7 +98,7 @@ struct amdxdna_drm_destroy_hwctx {* struct amdxdna_cu_config - configuration for one CU * @cu_bo: CU configuration buffer bo handle. * @cu_func: Function of a CU. -* @pad: Structure padding. +* @pad: MBZ. */ struct amdxdna_cu_config {__u32 cu_bo;@@ -109,7 +109,7 @@ struct amdxdna_cu_config {/** * struct amdxdna_hwctx_param_config_cu - configuration for CUs in hardware context * @num_cus: Number of CUs to configure. -* @pad: Structure padding. +* @pad: MBZ. * @cu_configs: Array of CU configurations of struct amdxdna_cu_config. */ struct amdxdna_hwctx_param_config_cu {
include/uapi/drm/amdxdna_accel.h enum amdxdna_drm_config_hwctx_param { · line 125
Quoted 4 lines
include/uapi/drm/amdxdna_accel.h +0
-1@@ -122,7 +122,6 @@ enum amdxdna_drm_config_hwctx_param {DRM_AMDXDNA_HWCTX_CONFIG_CU ,DRM_AMDXDNA_HWCTX_ASSIGN_DBG_BUF , DRM_AMDXDNA_HWCTX_REMOVE_DBG_BUF, -DRM_AMDXDNA_HWCTX_CONFIG_NUM
This change actually meant here? It seems like it should be it's own change.
Quoted 21 lines
include/uapi/drm/amdxdna_accel.h +2
-2};/** @@ -133,7 +132,7 @@ enum amdxdna_drm_config_hwctx_param {* @param_val: A structure specified by the param_type struct member. * @param_val_size: Size of the parameter buffer pointed to by the param_val. * If param_val is not a pointer, driver can ignore this. -* @pad: Structure padding. +* @pad: MBZ. * * Note: if the param_val is a pointer pointing to a buffer, the maximum size * of the buffer is 4KiB(PAGE_SIZE). @@ -175,7 +174,7 @@ struct amdxdna_drm_create_bo {* @ext: MBZ. * @ext_flags: MBZ. * @handle: DRM buffer object handle. -* @pad: Structure padding. +* @pad: MBZ. * @map_offset: Returned DRM fake offset for mmap(). * @vaddr: Returned user VA of buffer. 0 in case user needs mmap(). * @xdna_addr: Returned XDNA device virtual address.
Lizhi Hou
maintainerRe: [PATCH V3 5/5] accel/amdxdna: Add zero check for pad in ioctl input structures
Quoted 7 lines · Mario Limonciello
Quoted 3 lines · Lizhi Hou
For input structures, it is better to check if the pad is zero. Thus, the pad bytes might be usable in the future.
IIRC you should pick up:
Suggested-by Jeffrey Hugo <[email protected]>
Sure. Will add it.
Quoted 100 lines
Quoted 100 lines
Signed-off-by Lizhi Hou <[email protected]>---
drivers/accel/amdxdna/aie2_ctx.c | 3 +++drivers/accel/amdxdna/aie2_message.c| 3 +++ drivers/accel/amdxdna/amdxdna_ctx.c | 6 ++++++ drivers/accel/amdxdna/amdxdna_gem.c | 2 +- include/uapi/drm/amdxdna_accel.h | 11 +++++------5 files changed, 18 insertions(+), 7 deletions(-)drivers/accel/amdxdna/aie2_ctx.c +0
-0@@ -690,6 +690,9 @@ static int aie2_hwctx_cu_config(struct
amdxdna_hwctx*hwctx, void *buf, u32 size
int ret;
XDNA_DBG(xdna, "Config %d CU to %s", config->num_cus, hwctx->name); + if (XDNA_MBZ_DBG(xdna, config->pad, sizeof(config->pad))) + return-EINVAL;
+
if (hwctx->status!=HWCTX_STAT_INIT) {
XDNA_ERR(xdna, "Not support re-config CU");
return-EINVAL;drivers/accel/amdxdna/aie2_message.c +2
-0@@ -395,6 +395,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx) for (i = 0; i < hwctx->cus->num_cus; i++) { struct amdxdna_cu_config *cu = &hwctx->cus->cu_configs[i]; + if (XDNA_MBZ_DBG(xdna, cu->pad, sizeof(cu->pad))) + return -EINVAL; + gobj = drm_gem_object_lookup(hwctx->client->filp, cu->cu_bo); if (!gobj) { XDNA_ERR(xdna, "Lookup GEM object failed");drivers/accel/amdxdna/amdxdna_ctx.c +0
-0@@ -243,6 +243,9 @@ int amdxdna_drm_destroy_hwctx_ioctl(struct
drm_device*dev, void *data, struct d
structamdxdna_hwctx*hwctx;
int ret = 0, idx;
+ if (XDNA_MBZ_DBG(xdna, &args->pad, sizeof(args->pad)))
+ return-EINVAL;
+
if (!drm_dev_enter(dev, &idx))
return-ENODEV;
@@ -277,6 +280,9 @@ int amdxdna_drm_config_hwctx_ioctl(structdrm_device*dev, void *data, struct dr void *buf;
u64 val;
+ if (XDNA_MBZ_DBG(xdna, &args->pad, sizeof(args->pad)))
+ return-EINVAL;
+
if (!xdna->dev_info->ops->hwctx_config)
return-EOPNOTSUPP;
diff --gita/drivers/accel/amdxdna/amdxdna_gem.cb/drivers/accel/amdxdna/amdxdna_gem.cindex4dfeca306d98..606433d73236100644drivers/accel/amdxdna/amdxdna_gem.c +0
-0@@ -552,7 +552,7 @@ int amdxdna_drm_get_bo_info_ioctl(struct
drm_device*dev, void *data, struct drm
structdrm_gem_object*gobj;
int ret = 0;
- if (args->ext||args->ext_flags)
+ if (args->ext||args->ext_flags||args->pad) return-EINVAL;
gobj =drm_gem_object_lookup(filp, args->handle);include/uapi/drm/amdxdna_accel.h +3
-3@@ -87,7 +87,7 @@ struct amdxdna_drm_create_hwctx { /** * struct amdxdna_drm_destroy_hwctx - Destroy hardware context. * @handle: Hardware context handle. - * @pad: Structure padding. + * @pad: MBZ. */ struct amdxdna_drm_destroy_hwctx { __u32 handle;@@ -98,7 +98,7 @@ struct amdxdna_drm_destroy_hwctx {* struct amdxdna_cu_config - configuration for one CU * @cu_bo: CU configuration buffer bo handle. * @cu_func: Function of a CU. -* @pad: Structure padding. +* @pad: MBZ. */ struct amdxdna_cu_config { __u32 cu_bo;@@ -109,7 +109,7 @@ struct amdxdna_cu_config { /*** struct amdxdna_hwctx_param_config_cu - configuration for CUs in hardware context * @num_cus: Number of CUs to configure. -* @pad: Structure padding. +* @pad: MBZ. * @cu_configs: Array of CU configurations of struct amdxdna_cu_config. */
Quoted 8 lines
include/uapi/drm/amdxdna_accel.h enum amdxdna_drm_config_hwctx_param { · line 125
Quoted 6 lines
include/uapi/drm/amdxdna_accel.h +0
-1struct amdxdna_hwctx_param_config_cu {@@ -122,7 +122,6 @@ enum amdxdna_drm_config_hwctx_param { DRM_AMDXDNA_HWCTX_CONFIG_CU, DRM_AMDXDNA_HWCTX_ASSIGN_DBG_BUF, DRM_AMDXDNA_HWCTX_REMOVE_DBG_BUF, - DRM_AMDXDNA_HWCTX_CONFIG_NUMThis change actually meant here? It seems like it should be it's own change.
Agree. Hopefully, the patch 1 - 4 are good to go and I do not need to resend them. :)
Thanks,
Lizhi
Quoted 22 lines
Quoted 21 lines
include/uapi/drm/amdxdna_accel.h +2
-2}; /**@@ -133,7 +132,7 @@ enum amdxdna_drm_config_hwctx_param { * @param_val: A structure specified by the param_type struct member. * @param_val_size: Size of the parameter buffer pointed to by the param_val. * If param_val is not a pointer, driver can ignore this. - * @pad: Structure padding. + * @pad: MBZ. * * Note: if the param_val is a pointer pointing to a buffer, the maximum size * of the buffer is 4KiB(PAGE_SIZE).@@ -175,7 +174,7 @@ struct amdxdna_drm_create_bo { * @ext: MBZ. * @ext_flags: MBZ. * @handle: DRM buffer object handle. - * @pad: Structure padding. + * @pad: MBZ. * @map_offset: Returned DRM fake offset for mmap(). * @vaddr: Returned user VA of buffer. 0 in case user needs mmap(). * @xdna_addr: Returned XDNA device virtual address.
Re: [PATCH V3 5/5] accel/amdxdna: Add zero check for pad in ioctl input structures
Quoted 5 lines
Quoted 1 line
This change actually meant here? It seems like it should be it's own change.
Agree. Hopefully, the patch 1 - 4 are good to go and I do not need to resend them. :)
Yeah those are fine at this point. They've gotten good feedback, no complaints from LKP robot. I think you can just send the fixed up patch 5 separately.
I've just added 1-4 to drm-misc-next. Here are the hashes.
b1dcfe620574b accel/amdxdna: Read firmware interface version from registers f4d7b8a6bc8c9 accel/amdxdna: Enhance power management settings a37d78470bcc8 accel/amdxdna: Replace idr api with xarray 273b5176ac178 accel/amdxdna: Add RyzenAI-npu6 support