-
Notifications
You must be signed in to change notification settings - Fork 76
ve2: add support for create/destroy hw context #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
-Support hw context create/destroy ioctls -Add new ve2 resourse solver drivers to manage aie columns resources among hw contexts. -Add new ve2 management driver for cert firmware Signed-off-by: Raj Kumar Rampelli <[email protected]>
Can one of the admins verify this patch? |
Internal review in progress, so marked as draft. |
@@ -0,0 +1,219 @@ | |||
/* SPDX-License-Identifier: GPL-2.0 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Handshake region is got updated in CERT. Could you please check once and update accordingly
src/driver/amdxdna/amdxdna_of_drv.c
Outdated
xrs_cfg.ddev = &xdna->ddev; | ||
xrs_cfg.total_col = XRS_MAX_COL; | ||
|
||
if (xdna->dev_handle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xdna->dev_handle
This one checks twice.
if (xdna->dev_handle) | |
if (xdna->dev_handle) { | |
xdna->dev_handle->xrs_hdl = xrsm_init(&xrs_cfg); | |
if (!xdna->dev_handle->xrs_hdl) { | |
XDNA_ERR(xdna, "Initialize resolver failed"); | |
drm_dev_put(&xdna->ddev); | |
return -EINVAL; | |
} | |
} | |
src/driver/amdxdna/ve2_mgmt.c
Outdated
|
||
total_col = xrs_get_total_cols(xdna->dev_handle->xrs_hdl); | ||
if (total_col < 0) | ||
return -EINVAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before return we should free xrs_req memory also unlock the lock
src/driver/amdxdna/ve2_mgmt.c
Outdated
ret = cert_setup_partition(aie_dev, col, start_col, num_col, hsa_addr); | ||
if (ret < 0) { | ||
XDNA_ERR(xdna, "cert_setup_partition() err %d for col %d", ret, start_col); | ||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are returning from here please teardown and release the aie partition
src/driver/amdxdna/ve2_mgmt.c
Outdated
for (u32 col = start_col; col < start_col + num_col; col++) { | ||
rel_col = col - start_col; | ||
ret = cert_clear_partition(xdna, priv->aie_dev, rel_col); | ||
if (ret < 0) | ||
XDNA_ERR(xdna, "cert_clear_partition() err %d for col %d", ret, rel_col); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the loop.
for (u32 col = start_col; col < start_col + num_col; col++) { | |
rel_col = col - start_col; | |
ret = cert_clear_partition(xdna, priv->aie_dev, rel_col); | |
if (ret < 0) | |
XDNA_ERR(xdna, "cert_clear_partition() err %d for col %d", ret, rel_col); | |
} | |
for (u32 col = 0; col < num_col; col++) { | |
ret = cert_clear_partition(xdna, priv->aie_dev, col); | |
if (ret < 0) | |
XDNA_ERR(xdna, "cert_clear_partition() err %d for col %d", ret, col); | |
} |
src/driver/amdxdna/ve2_mgmt.c
Outdated
aie_dev = aie_partition_request(&request); | ||
if (IS_ERR(aie_dev)) { | ||
XDNA_ERR(xdna, "aie parition request failed, error %ld", PTR_ERR(aie_dev)); | ||
return -ENODEV; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please release the resource if failed case xrs_release_resource
Same subsequently
Signed-off-by: Raj Kumar Rampelli <[email protected]>
ok to test |
Signed-off-by: Raj Kumar Rampelli <[email protected]>
Signed-off-by: Raj Kumar Rampelli <[email protected]>
if (!xdna->dev_info->ops->ctx_init) | ||
return -EOPNOTSUPP; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding this check? I don't think we need this check. I don't see any device that doesn't support this ctx_init() callback.
Please let me know what the justification for this is. Otherwise, please remove.
@@ -9,6 +9,7 @@ | |||
#include <drm/drm_managed.h> | |||
|
|||
#include "amdxdna_of_drv.h" | |||
#include "ve2_res_solver.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NEVER include aie2_, aie4_ and ve2_ header in amdxdna_ files. Please remove this line and make necessary changes.
} | ||
} | ||
|
||
queue->hsa_queue_p->hq_header.capacity = nslots; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw a comment about this must be power of two. If this is the case, please put a WARN_ON() for this check. You can ref the WARN_ON in aie2_map_host_buf().
u16 minor; | ||
} | ||
version; | ||
//Queue capacity, must be a power of two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use WARN_ON() instead of comment. Delete this comment pls.
union { | ||
struct { | ||
u16 type: 8; | ||
u16 barrier: 1; | ||
u16 acquire_fence_scope: 2; | ||
u16 release_fence_scope: 2; | ||
}; | ||
u16 header; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not suggesting coding style. Ref aie2_msg_priv.h
If this triggers many codes change, we can merge this for open source. But this needs to be refine when upstreaming.
u32 size; //5c | ||
} | ||
dbg_buf; | ||
volatile struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a comment to explain why 'volatile' is needed for this but not for above fields?
// number of checks whether there are jobs ready | ||
u32 c_job_readiness_checked; | ||
// number of opcode run | ||
u32 c_opcode; | ||
u32 c_job_launched; | ||
u32 c_job_finished; | ||
// number of hsa pkt handled | ||
u32 c_hsa_pkt; | ||
// number of pages loaded | ||
u32 c_page; | ||
// number of hsa doorbell ring | ||
u32 c_doorbell; | ||
// number of uc memory(PM) scrub | ||
u32 c_uc_scrub; | ||
// number of tct requested | ||
u32 c_tct_requested; | ||
// number of tct received | ||
u32 c_tct_received; | ||
// run out of wait handle UC_DMA_WRITE_DES opcode | ||
u16 c_preemption_ucdma; | ||
// run out of wait handle UC_DMA_WRITE_DES_SYNC opcode | ||
u16 c_preemption_ucdma_sync; | ||
// POLL_32 opcode retry times | ||
u16 c_preemption_poll; | ||
// MASK_POLL_32 opcode retry times | ||
u16 c_preemption_mask_poll; | ||
// run out of physical barrier REMOTE_BARRIER opcode | ||
u16 c_preemption_remote_barrier; | ||
// actor entry overflow or run out of wait handle WAIT_TCTS opcode | ||
u16 c_preemption_wait_tct; | ||
// block UC_DMA_WRITE_DES opcode | ||
u16 c_block_ucdma; | ||
// block UC_DMA_WRITE_DES_SYNC opcode | ||
u16 c_block_ucdma_sync; | ||
// block local_barrier opcode | ||
u16 c_block_local_barrier; | ||
// block REMOTE_BARRIER opcode | ||
u16 c_block_remote_barrier; | ||
// block WAIT_TCTS opcode | ||
u16 c_block_wait_tct; | ||
// number of slow actor entry lookup | ||
u16 c_actor_hash_conflict; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of comment, use readable field name is prefer.
free_host_queue: | ||
ve2_free_hsa_queue(xdna, &hwctx->priv->hwctx_hsa_queue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are host_queue and hsa_queu the same? Even they are the same, please use consistent terminology to avoid confusion.
static void ve2_irq_handler(u32 partition_id, void *cb_arg) | ||
{ | ||
struct amdxdna_ctx *hwctx = (struct amdxdna_ctx *)cb_arg; | ||
struct amdxdna_dev *xdna = hwctx->client->xdna; | ||
|
||
XDNA_DBG(xdna, "Created partition for start_col %d, num_col %d with partition_id %d\n", | ||
hwctx->start_col, hwctx->num_col, partition_id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does nothing but only print a debug message. Is this expected?
This function doesn't look like a Linux IRQ handler. If my understanding is correct, please rename this to something else. This is more like a callback function.
u32 start, end; | ||
int idx; | ||
|
||
list_for_each_entry(client, &xdna->client_list, node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xdna->dev_lock needs to be acquired. Can you put a drm_WARN_ON() check in front of loop?
-Support hw context create/destroy ioctls
-Add new ve2 resourse solver drivers to manage aie columns
resources among hw contexts.
-Add new ve2 management driver for cert firmware