Loading drivers/gpu/msm/kgsl.c +6 −0 Original line number Diff line number Diff line Loading @@ -300,6 +300,9 @@ static void kgsl_destroy_ion(struct kgsl_memdesc *memdesc) struct kgsl_mem_entry, memdesc); struct kgsl_dma_buf_meta *meta = entry->priv_data; if (memdesc->priv & KGSL_MEMDESC_MAPPED) return; if (meta != NULL) { remove_dmabuf_list(meta); dma_buf_unmap_attachment(meta->attach, meta->table, Loading Loading @@ -328,6 +331,9 @@ static void kgsl_destroy_anon(struct kgsl_memdesc *memdesc) struct scatterlist *sg; struct page *page; if (memdesc->priv & KGSL_MEMDESC_MAPPED) return; for_each_sg(memdesc->sgt->sgl, sg, memdesc->sgt->nents, i) { page = sg_page(sg); for (j = 0; j < (sg->length >> PAGE_SHIFT); j++) { Loading drivers/gpu/msm/kgsl_drawobj.c +9 −2 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved. */ /* Loading Loading @@ -508,6 +508,8 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, /* Set pending flag before adding callback to avoid race */ set_bit(event->id, &syncobj->pending); /* Get a dma_fence refcount to hand over to the callback */ dma_fence_get(event->fence); ret = dma_fence_add_callback(event->fence, &event->cb, drawobj_sync_timeline_fence_callback); Loading @@ -520,10 +522,15 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, ret = 0; } /* Put the refcount from fence creation */ dma_fence_put(event->fence); kgsl_drawobj_put(drawobj); return ret; } return ret; /* Put the refcount from fence creation */ dma_fence_put(event->fence); return 0; } static int drawobj_add_sync_fence(struct kgsl_device *device, Loading drivers/media/platform/msm/npu/npu_common.h +0 −6 Original line number Diff line number Diff line Loading @@ -109,12 +109,6 @@ struct npu_debugfs_ctx { struct dentry *root; uint32_t reg_off; uint32_t reg_cnt; uint8_t *log_buf; struct mutex log_lock; uint32_t log_num_bytes_buffered; uint32_t log_read_index; uint32_t log_write_index; uint32_t log_buf_size; }; struct npu_debugfs_reg_ctx { Loading drivers/media/platform/msm/npu/npu_debugfs.c +0 −78 Original line number Diff line number Diff line Loading @@ -13,12 +13,6 @@ #include "npu_hw_access.h" #include "npu_common.h" /* ------------------------------------------------------------------------- * Defines * ------------------------------------------------------------------------- */ #define NPU_LOG_BUF_SIZE 4096 /* ------------------------------------------------------------------------- * Function Prototypes * ------------------------------------------------------------------------- Loading @@ -33,8 +27,6 @@ static ssize_t npu_debug_off_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_off_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_ctrl_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos); Loading @@ -57,13 +49,6 @@ static const struct file_operations npu_off_fops = { .write = npu_debug_off_write, }; static const struct file_operations npu_log_fops = { .open = npu_debug_open, .release = npu_debug_release, .read = npu_debug_log_read, .write = NULL, }; static const struct file_operations npu_ctrl_fops = { .open = npu_debug_open, .release = npu_debug_release, Loading Loading @@ -248,48 +233,6 @@ static ssize_t npu_debug_off_read(struct file *file, return len; } /* ------------------------------------------------------------------------- * Function Implementations - DebugFS Log * ------------------------------------------------------------------------- */ static ssize_t npu_debug_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { size_t len = 0; struct npu_device *npu_dev = file->private_data; struct npu_debugfs_ctx *debugfs; NPU_DBG("npu_dev %pK %pK\n", npu_dev, g_npu_dev); npu_dev = g_npu_dev; debugfs = &npu_dev->debugfs_ctx; /* mutex log lock */ mutex_lock(&debugfs->log_lock); if (debugfs->log_num_bytes_buffered != 0) { len = min(debugfs->log_num_bytes_buffered, debugfs->log_buf_size - debugfs->log_read_index); len = min(count, len); if (copy_to_user(user_buf, (debugfs->log_buf + debugfs->log_read_index), len)) { NPU_ERR("failed to copy to user\n"); mutex_unlock(&debugfs->log_lock); return -EFAULT; } debugfs->log_read_index += len; if (debugfs->log_read_index == debugfs->log_buf_size) debugfs->log_read_index = 0; debugfs->log_num_bytes_buffered -= len; *ppos += len; } /* mutex log unlock */ mutex_unlock(&debugfs->log_lock); return len; } /* ------------------------------------------------------------------------- * Function Implementations - DebugFS Control * ------------------------------------------------------------------------- Loading Loading @@ -373,12 +316,6 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } if (!debugfs_create_file("log", 0644, debugfs->root, npu_dev, &npu_log_fops)) { NPU_ERR("debugfs_create_file log fail\n"); goto err; } if (!debugfs_create_file("ctrl", 0644, debugfs->root, npu_dev, &npu_ctrl_fops)) { NPU_ERR("debugfs_create_file ctrl fail\n"); Loading Loading @@ -421,15 +358,6 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } debugfs->log_num_bytes_buffered = 0; debugfs->log_read_index = 0; debugfs->log_write_index = 0; debugfs->log_buf_size = NPU_LOG_BUF_SIZE; debugfs->log_buf = kzalloc(debugfs->log_buf_size, GFP_KERNEL); if (!debugfs->log_buf) goto err; mutex_init(&debugfs->log_lock); return 0; err: Loading @@ -441,12 +369,6 @@ void npu_debugfs_deinit(struct npu_device *npu_dev) { struct npu_debugfs_ctx *debugfs = &npu_dev->debugfs_ctx; debugfs->log_num_bytes_buffered = 0; debugfs->log_read_index = 0; debugfs->log_write_index = 0; debugfs->log_buf_size = 0; kfree(debugfs->log_buf); if (!IS_ERR_OR_NULL(debugfs->root)) { debugfs_remove_recursive(debugfs->root); debugfs->root = NULL; Loading drivers/media/platform/msm/npu/npu_host_ipc.c +33 −7 Original line number Diff line number Diff line Loading @@ -31,15 +31,16 @@ struct npu_queue_tuple { uint32_t size; uint32_t hdr; uint32_t start_offset; }; static const struct npu_queue_tuple npu_q_setup[6] = { { 1024, IPC_QUEUE_CMD_HIGH_PRIORITY | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_APPS_EXEC | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_DSP_EXEC | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_APPS_RSP | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_DSP_RSP | TX_HDR_TYPE | RX_HDR_TYPE }, { 1024, IPC_QUEUE_LOG | TX_HDR_TYPE | RX_HDR_TYPE }, static struct npu_queue_tuple npu_q_setup[6] = { { 1024, IPC_QUEUE_CMD_HIGH_PRIORITY | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_APPS_EXEC | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_DSP_EXEC | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_APPS_RSP | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_DSP_RSP | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 1024, IPC_QUEUE_LOG | TX_HDR_TYPE | RX_HDR_TYPE, 0}, }; /* ------------------------------------------------------------------------- Loading Loading @@ -111,6 +112,7 @@ static int npu_host_ipc_init_hfi(struct npu_device *npu_dev) /* queue is active */ q_hdr->qhdr_status = 0x01; q_hdr->qhdr_start_offset = cur_start_offset; npu_q_setup[q_idx].start_offset = cur_start_offset; q_size = npu_q_setup[q_idx].size; q_hdr->qhdr_type = npu_q_setup[q_idx].hdr; /* in bytes */ Loading Loading @@ -217,6 +219,18 @@ static int ipc_queue_read(struct npu_device *npu_dev, /* Read the queue */ MEMR(npu_dev, (void *)((size_t)offset), (uint8_t *)&queue, HFI_QUEUE_HEADER_SIZE); if (queue.qhdr_type != npu_q_setup[target_que].hdr || queue.qhdr_q_size != npu_q_setup[target_que].size || queue.qhdr_read_idx >= queue.qhdr_q_size || queue.qhdr_write_idx >= queue.qhdr_q_size || queue.qhdr_start_offset != npu_q_setup[target_que].start_offset) { NPU_ERR("Invalid Queue header\n"); status = -EIO; goto exit; } /* check if queue is empty */ if (queue.qhdr_read_idx == queue.qhdr_write_idx) { /* Loading Loading @@ -314,6 +328,18 @@ static int ipc_queue_write(struct npu_device *npu_dev, MEMR(npu_dev, (void *)((size_t)offset), (uint8_t *)&queue, HFI_QUEUE_HEADER_SIZE); if (queue.qhdr_type != npu_q_setup[target_que].hdr || queue.qhdr_q_size != npu_q_setup[target_que].size || queue.qhdr_read_idx >= queue.qhdr_q_size || queue.qhdr_write_idx >= queue.qhdr_q_size || queue.qhdr_start_offset != npu_q_setup[target_que].start_offset) { NPU_ERR("Invalid Queue header\n"); status = -EIO; goto exit; } packet_size = (*(uint32_t *)packet); if (packet_size == 0) { /* assign failed status and return */ Loading Loading
drivers/gpu/msm/kgsl.c +6 −0 Original line number Diff line number Diff line Loading @@ -300,6 +300,9 @@ static void kgsl_destroy_ion(struct kgsl_memdesc *memdesc) struct kgsl_mem_entry, memdesc); struct kgsl_dma_buf_meta *meta = entry->priv_data; if (memdesc->priv & KGSL_MEMDESC_MAPPED) return; if (meta != NULL) { remove_dmabuf_list(meta); dma_buf_unmap_attachment(meta->attach, meta->table, Loading Loading @@ -328,6 +331,9 @@ static void kgsl_destroy_anon(struct kgsl_memdesc *memdesc) struct scatterlist *sg; struct page *page; if (memdesc->priv & KGSL_MEMDESC_MAPPED) return; for_each_sg(memdesc->sgt->sgl, sg, memdesc->sgt->nents, i) { page = sg_page(sg); for (j = 0; j < (sg->length >> PAGE_SHIFT); j++) { Loading
drivers/gpu/msm/kgsl_drawobj.c +9 −2 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved. */ /* Loading Loading @@ -508,6 +508,8 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, /* Set pending flag before adding callback to avoid race */ set_bit(event->id, &syncobj->pending); /* Get a dma_fence refcount to hand over to the callback */ dma_fence_get(event->fence); ret = dma_fence_add_callback(event->fence, &event->cb, drawobj_sync_timeline_fence_callback); Loading @@ -520,10 +522,15 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, ret = 0; } /* Put the refcount from fence creation */ dma_fence_put(event->fence); kgsl_drawobj_put(drawobj); return ret; } return ret; /* Put the refcount from fence creation */ dma_fence_put(event->fence); return 0; } static int drawobj_add_sync_fence(struct kgsl_device *device, Loading
drivers/media/platform/msm/npu/npu_common.h +0 −6 Original line number Diff line number Diff line Loading @@ -109,12 +109,6 @@ struct npu_debugfs_ctx { struct dentry *root; uint32_t reg_off; uint32_t reg_cnt; uint8_t *log_buf; struct mutex log_lock; uint32_t log_num_bytes_buffered; uint32_t log_read_index; uint32_t log_write_index; uint32_t log_buf_size; }; struct npu_debugfs_reg_ctx { Loading
drivers/media/platform/msm/npu/npu_debugfs.c +0 −78 Original line number Diff line number Diff line Loading @@ -13,12 +13,6 @@ #include "npu_hw_access.h" #include "npu_common.h" /* ------------------------------------------------------------------------- * Defines * ------------------------------------------------------------------------- */ #define NPU_LOG_BUF_SIZE 4096 /* ------------------------------------------------------------------------- * Function Prototypes * ------------------------------------------------------------------------- Loading @@ -33,8 +27,6 @@ static ssize_t npu_debug_off_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_off_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); static ssize_t npu_debug_ctrl_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos); Loading @@ -57,13 +49,6 @@ static const struct file_operations npu_off_fops = { .write = npu_debug_off_write, }; static const struct file_operations npu_log_fops = { .open = npu_debug_open, .release = npu_debug_release, .read = npu_debug_log_read, .write = NULL, }; static const struct file_operations npu_ctrl_fops = { .open = npu_debug_open, .release = npu_debug_release, Loading Loading @@ -248,48 +233,6 @@ static ssize_t npu_debug_off_read(struct file *file, return len; } /* ------------------------------------------------------------------------- * Function Implementations - DebugFS Log * ------------------------------------------------------------------------- */ static ssize_t npu_debug_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { size_t len = 0; struct npu_device *npu_dev = file->private_data; struct npu_debugfs_ctx *debugfs; NPU_DBG("npu_dev %pK %pK\n", npu_dev, g_npu_dev); npu_dev = g_npu_dev; debugfs = &npu_dev->debugfs_ctx; /* mutex log lock */ mutex_lock(&debugfs->log_lock); if (debugfs->log_num_bytes_buffered != 0) { len = min(debugfs->log_num_bytes_buffered, debugfs->log_buf_size - debugfs->log_read_index); len = min(count, len); if (copy_to_user(user_buf, (debugfs->log_buf + debugfs->log_read_index), len)) { NPU_ERR("failed to copy to user\n"); mutex_unlock(&debugfs->log_lock); return -EFAULT; } debugfs->log_read_index += len; if (debugfs->log_read_index == debugfs->log_buf_size) debugfs->log_read_index = 0; debugfs->log_num_bytes_buffered -= len; *ppos += len; } /* mutex log unlock */ mutex_unlock(&debugfs->log_lock); return len; } /* ------------------------------------------------------------------------- * Function Implementations - DebugFS Control * ------------------------------------------------------------------------- Loading Loading @@ -373,12 +316,6 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } if (!debugfs_create_file("log", 0644, debugfs->root, npu_dev, &npu_log_fops)) { NPU_ERR("debugfs_create_file log fail\n"); goto err; } if (!debugfs_create_file("ctrl", 0644, debugfs->root, npu_dev, &npu_ctrl_fops)) { NPU_ERR("debugfs_create_file ctrl fail\n"); Loading Loading @@ -421,15 +358,6 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } debugfs->log_num_bytes_buffered = 0; debugfs->log_read_index = 0; debugfs->log_write_index = 0; debugfs->log_buf_size = NPU_LOG_BUF_SIZE; debugfs->log_buf = kzalloc(debugfs->log_buf_size, GFP_KERNEL); if (!debugfs->log_buf) goto err; mutex_init(&debugfs->log_lock); return 0; err: Loading @@ -441,12 +369,6 @@ void npu_debugfs_deinit(struct npu_device *npu_dev) { struct npu_debugfs_ctx *debugfs = &npu_dev->debugfs_ctx; debugfs->log_num_bytes_buffered = 0; debugfs->log_read_index = 0; debugfs->log_write_index = 0; debugfs->log_buf_size = 0; kfree(debugfs->log_buf); if (!IS_ERR_OR_NULL(debugfs->root)) { debugfs_remove_recursive(debugfs->root); debugfs->root = NULL; Loading
drivers/media/platform/msm/npu/npu_host_ipc.c +33 −7 Original line number Diff line number Diff line Loading @@ -31,15 +31,16 @@ struct npu_queue_tuple { uint32_t size; uint32_t hdr; uint32_t start_offset; }; static const struct npu_queue_tuple npu_q_setup[6] = { { 1024, IPC_QUEUE_CMD_HIGH_PRIORITY | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_APPS_EXEC | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_DSP_EXEC | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_APPS_RSP | TX_HDR_TYPE | RX_HDR_TYPE }, { 4096, IPC_QUEUE_DSP_RSP | TX_HDR_TYPE | RX_HDR_TYPE }, { 1024, IPC_QUEUE_LOG | TX_HDR_TYPE | RX_HDR_TYPE }, static struct npu_queue_tuple npu_q_setup[6] = { { 1024, IPC_QUEUE_CMD_HIGH_PRIORITY | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_APPS_EXEC | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_DSP_EXEC | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_APPS_RSP | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 4096, IPC_QUEUE_DSP_RSP | TX_HDR_TYPE | RX_HDR_TYPE, 0}, { 1024, IPC_QUEUE_LOG | TX_HDR_TYPE | RX_HDR_TYPE, 0}, }; /* ------------------------------------------------------------------------- Loading Loading @@ -111,6 +112,7 @@ static int npu_host_ipc_init_hfi(struct npu_device *npu_dev) /* queue is active */ q_hdr->qhdr_status = 0x01; q_hdr->qhdr_start_offset = cur_start_offset; npu_q_setup[q_idx].start_offset = cur_start_offset; q_size = npu_q_setup[q_idx].size; q_hdr->qhdr_type = npu_q_setup[q_idx].hdr; /* in bytes */ Loading Loading @@ -217,6 +219,18 @@ static int ipc_queue_read(struct npu_device *npu_dev, /* Read the queue */ MEMR(npu_dev, (void *)((size_t)offset), (uint8_t *)&queue, HFI_QUEUE_HEADER_SIZE); if (queue.qhdr_type != npu_q_setup[target_que].hdr || queue.qhdr_q_size != npu_q_setup[target_que].size || queue.qhdr_read_idx >= queue.qhdr_q_size || queue.qhdr_write_idx >= queue.qhdr_q_size || queue.qhdr_start_offset != npu_q_setup[target_que].start_offset) { NPU_ERR("Invalid Queue header\n"); status = -EIO; goto exit; } /* check if queue is empty */ if (queue.qhdr_read_idx == queue.qhdr_write_idx) { /* Loading Loading @@ -314,6 +328,18 @@ static int ipc_queue_write(struct npu_device *npu_dev, MEMR(npu_dev, (void *)((size_t)offset), (uint8_t *)&queue, HFI_QUEUE_HEADER_SIZE); if (queue.qhdr_type != npu_q_setup[target_que].hdr || queue.qhdr_q_size != npu_q_setup[target_que].size || queue.qhdr_read_idx >= queue.qhdr_q_size || queue.qhdr_write_idx >= queue.qhdr_q_size || queue.qhdr_start_offset != npu_q_setup[target_que].start_offset) { NPU_ERR("Invalid Queue header\n"); status = -EIO; goto exit; } packet_size = (*(uint32_t *)packet); if (packet_size == 0) { /* assign failed status and return */ Loading