[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bb9bbb03-30c8-48e4-bde7-e75c933c9685@amd.com>
Date: Mon, 13 Jan 2025 15:40:13 -0600
From: Mario Limonciello <mario.limonciello@....com>
To: Lizhi Hou <lizhi.hou@....com>, ogabbay@...nel.org,
quic_jhugo@...cinc.com, dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org, min.ma@....com, max.zhen@....com,
sonal.santan@....com, king.tam@....com, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH 1/2] accel/amdxdna: Remove casting mailbox payload pointer
On 1/13/2025 12:26, Lizhi Hou wrote:
> The mailbox payload pointer is void __iomem *. Casting it to u32 * is
> incorrect and causes sparse warning.
> cast removes address space '__iomem' of expression
>
> Fixes: b87f920b9344 ("accel/amdxdna: Support hardware mailbox")
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501130921.ktqwsMLH-lkp@intel.com/
> Signed-off-by: Lizhi Hou <lizhi.hou@....com>
Thanks for the fixes. They look good.
Reviewed-by: Mario Limonciello <mario.limonciello@....com>
I've added them to drm-misc-next.
b3dff598e72f5 accel/amdxdna: Declare sched_ops as static
412576293cca1 accel/amdxdna: Remove casting mailbox payload pointer
> ---
> drivers/accel/amdxdna/aie2_ctx.c | 22 +++++++++----------
> drivers/accel/amdxdna/aie2_error.c | 8 +++----
> drivers/accel/amdxdna/aie2_message.c | 10 ++++-----
> drivers/accel/amdxdna/aie2_pci.h | 10 ++++-----
> drivers/accel/amdxdna/amdxdna_mailbox.c | 6 ++---
> drivers/accel/amdxdna/amdxdna_mailbox.h | 2 +-
> .../accel/amdxdna/amdxdna_mailbox_helper.c | 6 ++---
> .../accel/amdxdna/amdxdna_mailbox_helper.h | 2 +-
> 8 files changed, 32 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
> index 5f43db02b240..5c69ae3c40f8 100644
> --- a/drivers/accel/amdxdna/aie2_ctx.c
> +++ b/drivers/accel/amdxdna/aie2_ctx.c
> @@ -185,7 +185,7 @@ aie2_sched_notify(struct amdxdna_sched_job *job)
> }
>
> static int
> -aie2_sched_resp_handler(void *handle, const u32 *data, size_t size)
> +aie2_sched_resp_handler(void *handle, void __iomem *data, size_t size)
> {
> struct amdxdna_sched_job *job = handle;
> struct amdxdna_gem_obj *cmd_abo;
> @@ -203,7 +203,7 @@ aie2_sched_resp_handler(void *handle, const u32 *data, size_t size)
> goto out;
> }
>
> - status = *data;
> + status = readl(data);
> XDNA_DBG(job->hwctx->client->xdna, "Resp status 0x%x", status);
> if (status == AIE2_STATUS_SUCCESS)
> amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_COMPLETED);
> @@ -216,7 +216,7 @@ aie2_sched_resp_handler(void *handle, const u32 *data, size_t size)
> }
>
> static int
> -aie2_sched_nocmd_resp_handler(void *handle, const u32 *data, size_t size)
> +aie2_sched_nocmd_resp_handler(void *handle, void __iomem *data, size_t size)
> {
> struct amdxdna_sched_job *job = handle;
> u32 ret = 0;
> @@ -230,7 +230,7 @@ aie2_sched_nocmd_resp_handler(void *handle, const u32 *data, size_t size)
> goto out;
> }
>
> - status = *data;
> + status = readl(data);
> XDNA_DBG(job->hwctx->client->xdna, "Resp status 0x%x", status);
>
> out:
> @@ -239,14 +239,14 @@ aie2_sched_nocmd_resp_handler(void *handle, const u32 *data, size_t size)
> }
>
> static int
> -aie2_sched_cmdlist_resp_handler(void *handle, const u32 *data, size_t size)
> +aie2_sched_cmdlist_resp_handler(void *handle, void __iomem *data, size_t size)
> {
> struct amdxdna_sched_job *job = handle;
> struct amdxdna_gem_obj *cmd_abo;
> - struct cmd_chain_resp *resp;
> struct amdxdna_dev *xdna;
> u32 fail_cmd_status;
> u32 fail_cmd_idx;
> + u32 cmd_status;
> u32 ret = 0;
>
> cmd_abo = job->cmd_bo;
> @@ -256,17 +256,17 @@ aie2_sched_cmdlist_resp_handler(void *handle, const u32 *data, size_t size)
> goto out;
> }
>
> - resp = (struct cmd_chain_resp *)data;
> + cmd_status = readl(data + offsetof(struct cmd_chain_resp, status));
> xdna = job->hwctx->client->xdna;
> - XDNA_DBG(xdna, "Status 0x%x", resp->status);
> - if (resp->status == AIE2_STATUS_SUCCESS) {
> + XDNA_DBG(xdna, "Status 0x%x", cmd_status);
> + if (cmd_status == AIE2_STATUS_SUCCESS) {
> amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_COMPLETED);
> goto out;
> }
>
> /* Slow path to handle error, read from ringbuf on BAR */
> - fail_cmd_idx = resp->fail_cmd_idx;
> - fail_cmd_status = resp->fail_cmd_status;
> + fail_cmd_idx = readl(data + offsetof(struct cmd_chain_resp, fail_cmd_idx));
> + fail_cmd_status = readl(data + offsetof(struct cmd_chain_resp, fail_cmd_status));
> XDNA_DBG(xdna, "Failed cmd idx %d, status 0x%x",
> fail_cmd_idx, fail_cmd_status);
>
> diff --git a/drivers/accel/amdxdna/aie2_error.c b/drivers/accel/amdxdna/aie2_error.c
> index b1defaa8513b..5ee905632a39 100644
> --- a/drivers/accel/amdxdna/aie2_error.c
> +++ b/drivers/accel/amdxdna/aie2_error.c
> @@ -209,16 +209,14 @@ static u32 aie2_error_backtrack(struct amdxdna_dev_hdl *ndev, void *err_info, u3
> return err_col;
> }
>
> -static int aie2_error_async_cb(void *handle, const u32 *data, size_t size)
> +static int aie2_error_async_cb(void *handle, void __iomem *data, size_t size)
> {
> - struct async_event_msg_resp *resp;
> struct async_event *e = handle;
>
> if (data) {
> - resp = (struct async_event_msg_resp *)data;
> - e->resp.type = resp->type;
> + e->resp.type = readl(data + offsetof(struct async_event_msg_resp, type));
> wmb(); /* Update status in the end, so that no lock for here */
> - e->resp.status = resp->status;
> + e->resp.status = readl(data + offsetof(struct async_event_msg_resp, status));
> }
> queue_work(e->wq, &e->work);
> return 0;
> diff --git a/drivers/accel/amdxdna/aie2_message.c b/drivers/accel/amdxdna/aie2_message.c
> index 9e2c9a44f76a..bf4219e32cc1 100644
> --- a/drivers/accel/amdxdna/aie2_message.c
> +++ b/drivers/accel/amdxdna/aie2_message.c
> @@ -356,7 +356,7 @@ int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf,
> }
>
> int aie2_register_asyn_event_msg(struct amdxdna_dev_hdl *ndev, dma_addr_t addr, u32 size,
> - void *handle, int (*cb)(void*, const u32 *, size_t))
> + void *handle, int (*cb)(void*, void __iomem *, size_t))
> {
> struct async_event_msg_req req = { 0 };
> struct xdna_mailbox_msg msg = {
> @@ -435,7 +435,7 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx)
> }
>
> int aie2_execbuf(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t))
> + int (*notify_cb)(void *, void __iomem *, size_t))
> {
> struct mailbox_channel *chann = hwctx->priv->mbox_chann;
> struct amdxdna_dev *xdna = hwctx->client->xdna;
> @@ -640,7 +640,7 @@ aie2_cmd_op_to_msg_op(u32 op)
>
> int aie2_cmdlist_multi_execbuf(struct amdxdna_hwctx *hwctx,
> struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t))
> + int (*notify_cb)(void *, void __iomem *, size_t))
> {
> struct amdxdna_gem_obj *cmdbuf_abo = aie2_cmdlist_get_cmd_buf(job);
> struct mailbox_channel *chann = hwctx->priv->mbox_chann;
> @@ -705,7 +705,7 @@ int aie2_cmdlist_multi_execbuf(struct amdxdna_hwctx *hwctx,
>
> int aie2_cmdlist_single_execbuf(struct amdxdna_hwctx *hwctx,
> struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t))
> + int (*notify_cb)(void *, void __iomem *, size_t))
> {
> struct amdxdna_gem_obj *cmdbuf_abo = aie2_cmdlist_get_cmd_buf(job);
> struct mailbox_channel *chann = hwctx->priv->mbox_chann;
> @@ -740,7 +740,7 @@ int aie2_cmdlist_single_execbuf(struct amdxdna_hwctx *hwctx,
> }
>
> int aie2_sync_bo(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t))
> + int (*notify_cb)(void *, void __iomem *, size_t))
> {
> struct mailbox_channel *chann = hwctx->priv->mbox_chann;
> struct amdxdna_gem_obj *abo = to_xdna_obj(job->bos[0]);
> diff --git a/drivers/accel/amdxdna/aie2_pci.h b/drivers/accel/amdxdna/aie2_pci.h
> index f2d95531ddc2..385914840eaa 100644
> --- a/drivers/accel/amdxdna/aie2_pci.h
> +++ b/drivers/accel/amdxdna/aie2_pci.h
> @@ -271,18 +271,18 @@ int aie2_destroy_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwc
> int aie2_map_host_buf(struct amdxdna_dev_hdl *ndev, u32 context_id, u64 addr, u64 size);
> int aie2_query_status(struct amdxdna_dev_hdl *ndev, char __user *buf, u32 size, u32 *cols_filled);
> int aie2_register_asyn_event_msg(struct amdxdna_dev_hdl *ndev, dma_addr_t addr, u32 size,
> - void *handle, int (*cb)(void*, const u32 *, size_t));
> + void *handle, int (*cb)(void*, void __iomem *, size_t));
> int aie2_config_cu(struct amdxdna_hwctx *hwctx);
> int aie2_execbuf(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t));
> + int (*notify_cb)(void *, void __iomem *, size_t));
> int aie2_cmdlist_single_execbuf(struct amdxdna_hwctx *hwctx,
> struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t));
> + int (*notify_cb)(void *, void __iomem *, size_t));
> int aie2_cmdlist_multi_execbuf(struct amdxdna_hwctx *hwctx,
> struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t));
> + int (*notify_cb)(void *, void __iomem *, size_t));
> int aie2_sync_bo(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
> - int (*notify_cb)(void *, const u32 *, size_t));
> + int (*notify_cb)(void *, void __iomem *, size_t));
>
> /* aie2_hwctx.c */
> int aie2_hwctx_init(struct amdxdna_hwctx *hwctx);
> diff --git a/drivers/accel/amdxdna/amdxdna_mailbox.c b/drivers/accel/amdxdna/amdxdna_mailbox.c
> index 814b16bb1953..de7bf0fb4594 100644
> --- a/drivers/accel/amdxdna/amdxdna_mailbox.c
> +++ b/drivers/accel/amdxdna/amdxdna_mailbox.c
> @@ -90,7 +90,7 @@ struct mailbox_pkg {
>
> struct mailbox_msg {
> void *handle;
> - int (*notify_cb)(void *handle, const u32 *data, size_t size);
> + int (*notify_cb)(void *handle, void __iomem *data, size_t size);
> size_t pkg_size; /* package size in bytes */
> struct mailbox_pkg pkg;
> };
> @@ -243,7 +243,7 @@ mailbox_send_msg(struct mailbox_channel *mb_chann, struct mailbox_msg *mb_msg)
>
> static int
> mailbox_get_resp(struct mailbox_channel *mb_chann, struct xdna_msg_header *header,
> - void *data)
> + void __iomem *data)
> {
> struct mailbox_msg *mb_msg;
> int msg_id;
> @@ -331,7 +331,7 @@ static int mailbox_get_msg(struct mailbox_channel *mb_chann)
> memcpy_fromio((u32 *)&header + 1, read_addr, rest);
> read_addr += rest;
>
> - ret = mailbox_get_resp(mb_chann, &header, (u32 *)read_addr);
> + ret = mailbox_get_resp(mb_chann, &header, read_addr);
>
> mailbox_set_headptr(mb_chann, head + msg_size);
> /* After update head, it can equal to ringbuf_size. This is expected. */
> diff --git a/drivers/accel/amdxdna/amdxdna_mailbox.h b/drivers/accel/amdxdna/amdxdna_mailbox.h
> index 57954c303bdd..ea367f2fb738 100644
> --- a/drivers/accel/amdxdna/amdxdna_mailbox.h
> +++ b/drivers/accel/amdxdna/amdxdna_mailbox.h
> @@ -25,7 +25,7 @@ struct mailbox_channel;
> struct xdna_mailbox_msg {
> u32 opcode;
> void *handle;
> - int (*notify_cb)(void *handle, const u32 *data, size_t size);
> + int (*notify_cb)(void *handle, void __iomem *data, size_t size);
> u8 *send_data;
> size_t send_size;
> };
> diff --git a/drivers/accel/amdxdna/amdxdna_mailbox_helper.c b/drivers/accel/amdxdna/amdxdna_mailbox_helper.c
> index 5139a9c96a91..6d0c24513476 100644
> --- a/drivers/accel/amdxdna/amdxdna_mailbox_helper.c
> +++ b/drivers/accel/amdxdna/amdxdna_mailbox_helper.c
> @@ -16,7 +16,7 @@
> #include "amdxdna_mailbox_helper.h"
> #include "amdxdna_pci_drv.h"
>
> -int xdna_msg_cb(void *handle, const u32 *data, size_t size)
> +int xdna_msg_cb(void *handle, void __iomem *data, size_t size)
> {
> struct xdna_notify *cb_arg = handle;
> int ret;
> @@ -29,9 +29,9 @@ int xdna_msg_cb(void *handle, const u32 *data, size_t size)
> goto out;
> }
>
> + memcpy_fromio(cb_arg->data, data, cb_arg->size);
> print_hex_dump_debug("resp data: ", DUMP_PREFIX_OFFSET,
> - 16, 4, data, cb_arg->size, true);
> - memcpy(cb_arg->data, data, cb_arg->size);
> + 16, 4, cb_arg->data, cb_arg->size, true);
> out:
> ret = cb_arg->error;
> complete(&cb_arg->comp);
> diff --git a/drivers/accel/amdxdna/amdxdna_mailbox_helper.h b/drivers/accel/amdxdna/amdxdna_mailbox_helper.h
> index 23e1317b79fe..710ff8873d61 100644
> --- a/drivers/accel/amdxdna/amdxdna_mailbox_helper.h
> +++ b/drivers/accel/amdxdna/amdxdna_mailbox_helper.h
> @@ -35,7 +35,7 @@ struct xdna_notify {
> .notify_cb = xdna_msg_cb, \
> }
>
> -int xdna_msg_cb(void *handle, const u32 *data, size_t size);
> +int xdna_msg_cb(void *handle, void __iomem *data, size_t size);
> int xdna_send_msg_wait(struct amdxdna_dev *xdna, struct mailbox_channel *chann,
> struct xdna_mailbox_msg *msg);
>
Powered by blists - more mailing lists