accel/amdxdna: Remove casting mailbox payload pointer
authorLizhi Hou <lizhi.hou@amd.com>
Mon, 13 Jan 2025 18:26:16 +0000 (10:26 -0800)
committerMario Limonciello <mario.limonciello@amd.com>
Mon, 13 Jan 2025 20:21:39 +0000 (14:21 -0600)
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@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501130921.ktqwsMLH-lkp@intel.com/
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250113182617.1256094-1-lizhi.hou@amd.com
drivers/accel/amdxdna/aie2_ctx.c
drivers/accel/amdxdna/aie2_error.c
drivers/accel/amdxdna/aie2_message.c
drivers/accel/amdxdna/aie2_pci.h
drivers/accel/amdxdna/amdxdna_mailbox.c
drivers/accel/amdxdna/amdxdna_mailbox.h
drivers/accel/amdxdna/amdxdna_mailbox_helper.c
drivers/accel/amdxdna/amdxdna_mailbox_helper.h

index 5f43db02b240467f9de653488c8dfcefd9a96167..5c69ae3c40f8e7042b2ed8444ca461c849aa8e5f 100644 (file)
@@ -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 @@ out:
 }
 
 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 @@ out:
 }
 
 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);
 
index b1defaa8513bb465203d431ad02647a62b97c1e5..5ee905632a39301ca62c6ec49ad798d0197eb841 100644 (file)
@@ -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;
index 9e2c9a44f76a4f26f05745508f006b1c3374ffc0..bf4219e32cc19d92a7c44fafb70c0ae0bbb86e3b 100644 (file)
@@ -356,7 +356,7 @@ fail:
 }
 
 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]);
index f2d95531ddc243d952f6c814f58f09df800b7695..385914840eaa612d2ae899da31f0d34bc8ea28a3 100644 (file)
@@ -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);
index 814b16bb1953f27617fb8a604fa0390e6bf98b39..de7bf0fb45944d95615eae21bee23f4439d9b453 100644 (file)
@@ -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 @@ no_space:
 
 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. */
index 57954c303bdd7b9444411bbe7e6a3d5538e7998e..ea367f2fb73831fdf2be77e9875291e25c2dbe7a 100644 (file)
@@ -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;
 };
index 5139a9c96a91619d7abebe1f385daa555d8286e3..6d0c24513476d1f80e774a4b983ddd4d23bf814b 100644 (file)
@@ -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);
index 23e1317b79fe65fe7a44e6a4e8e95f39383b80b5..710ff8873d6172ec6592a6d4cead5396a046b9d1 100644 (file)
@@ -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);