已合并
clang-format: format trs and trsdrv module #107
liyonghong创建于 6月30日
clang-format: format trs and trsdrv module #107
已合并
共 162 个文件变更+3269-2908
| @@ -77,7 +77,10 @@ int trs_cb_event_init(uint32_t dev_id) | |||
| 77 | return DRV_ERROR_NONE; | 77 | return DRV_ERROR_NONE; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | -void trs_cb_event_uninit(uint32_t dev_id) { (void)halEschedDettachDevice(dev_id); } | 80 | +void trs_cb_event_uninit(uint32_t dev_id) |
| 81 | +{ | ||
| 82 | + (void)halEschedDettachDevice(dev_id); | ||
| 83 | +} | ||
| 81 | 84 | ||
| 82 | static void trs_cb_event_to_cqe(struct trs_cb_stars_event *event, struct trs_cb_cqe *cqe) | 85 | static void trs_cb_event_to_cqe(struct trs_cb_stars_event *event, struct trs_cb_cqe *cqe) |
| 83 | { | 86 | { |
| @@ -21,13 +21,23 @@ void trs_cb_event_uninit(uint32_t dev_id); | |||
| 21 | int trs_cb_event_submit(uint32_t dev_id, char *sqe, uint32_t e_size); | 21 | int trs_cb_event_submit(uint32_t dev_id, char *sqe, uint32_t e_size); |
| 22 | int trs_cb_event_wait(uint32_t dev_id, uint32_t tid, int32_t timeout, uint8_t *buff); | 22 | int trs_cb_event_wait(uint32_t dev_id, uint32_t tid, int32_t timeout, uint8_t *buff); |
| 23 | 23 | ||
| 24 | -static inline int trs_cb_event_init(uint32_t dev_id) { return 0; } | 24 | +static inline int trs_cb_event_init(uint32_t dev_id) |
| 25 | +{ | ||
| 26 | + return 0; | ||
| 27 | +} | ||
| 25 | 28 | ||
| 26 | -static inline void trs_cb_event_uninit(uint32_t dev_id) {} | 29 | +static inline void trs_cb_event_uninit(uint32_t dev_id) |
| 30 | +{} | ||
| 27 | 31 | ||
| 28 | -static inline int trs_cb_event_submit(uint32_t dev_id, char *sqe, uint32_t e_size) { return 0; } | 32 | +static inline int trs_cb_event_submit(uint32_t dev_id, char *sqe, uint32_t e_size) |
| 33 | +{ | ||
| 34 | + return 0; | ||
| 35 | +} | ||
| 29 | 36 | ||
| 30 | -static inline int trs_cb_event_wait(uint32_t dev_id, uint32_t tid, int32_t timeout, uint8_t *buff) { return 0; } | 37 | +static inline int trs_cb_event_wait(uint32_t dev_id, uint32_t tid, int32_t timeout, uint8_t *buff) |
| 38 | +{ | ||
| 39 | + return 0; | ||
| 40 | +} | ||
| 31 | 41 | ||
| 32 | 42 | ||
| 33 | 43 | ||
| @@ -133,13 +133,25 @@ signed int __attribute__((constructor)) trs_core_init_user(void) // lint !e527 | |||
| 133 | return 0; | 133 | return 0; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | -static void trs_set_dev_fd(uint32_t dev_id, int fd) { trs_dev_fd[dev_id] = fd; } | 136 | +static void trs_set_dev_fd(uint32_t dev_id, int fd) |
| 137 | +{ | ||
| 138 | + trs_dev_fd[dev_id] = fd; | ||
| 139 | +} | ||
| 137 | 140 | ||
| 138 | -static int trs_get_dev_fd(uint32_t dev_id) { return trs_dev_fd[dev_id]; } | 141 | +static int trs_get_dev_fd(uint32_t dev_id) |
| 142 | +{ | ||
| 143 | + return trs_dev_fd[dev_id]; | ||
| 144 | +} | ||
| 139 | 145 | ||
| 140 | -static void trs_set_dev_mmap_fd(uint32_t dev_id, int fd) { trs_dev_mmap_fd[dev_id] = fd; } | 146 | +static void trs_set_dev_mmap_fd(uint32_t dev_id, int fd) |
| 147 | +{ | ||
| 148 | + trs_dev_mmap_fd[dev_id] = fd; | ||
| 149 | +} | ||
| 141 | 150 | ||
| 142 | -static int trs_get_dev_mmap_fd(uint32_t dev_id) { return trs_dev_mmap_fd[dev_id]; } | 151 | +static int trs_get_dev_mmap_fd(uint32_t dev_id) |
| 152 | +{ | ||
| 153 | + return trs_dev_mmap_fd[dev_id]; | ||
| 154 | +} | ||
| 143 | 155 | ||
| 144 | void *trs_dev_mmap(uint32_t dev_id, void *addr, size_t length, int prot, int flags) | 156 | void *trs_dev_mmap(uint32_t dev_id, void *addr, size_t length, int prot, int flags) |
| 145 | { | 157 | { |
| @@ -152,7 +164,10 @@ void *trs_dev_mmap(uint32_t dev_id, void *addr, size_t length, int prot, int fla | |||
| 152 | return trs_mmap_user(addr, length, prot, flags, fd, 0); | 164 | return trs_mmap_user(addr, length, prot, flags, fd, 0); |
| 153 | } | 165 | } |
| 154 | 166 | ||
| 155 | -int trs_dev_munmap(void *addr, size_t length) { return trs_munmap(addr, length); } | 167 | +int trs_dev_munmap(void *addr, size_t length) |
| 168 | +{ | ||
| 169 | + return trs_munmap(addr, length); | ||
| 170 | +} | ||
| 156 | 171 | ||
| 157 | 172 | ||
| 158 | 173 | ||
| @@ -172,8 +187,8 @@ static int _trs_char_dev_open(uint32_t v_dev_id, int *fd, const char *intf_modul | |||
| 172 | *fd = trs_file_open(davinci_intf_get_dev_path(), O_RDWR | O_CLOEXEC); | 187 | *fd = trs_file_open(davinci_intf_get_dev_path(), O_RDWR | O_CLOEXEC); |
| 173 | if (*fd < 0) { | 188 | if (*fd < 0) { |
| 174 | ret = errno; | 189 | ret = errno; |
| 175 | - trs_err( | 190 | + trs_err("Open device failed. (v_dev_id=%u; fd=%d; errno=%d, error=%s)\n", v_dev_id, *fd, errno, |
| 176 | - "Open device failed. (v_dev_id=%u; fd=%d; errno=%d, error=%s)\n", v_dev_id, *fd, errno, strerror(errno)); | 191 | + strerror(errno)); |
| 177 | return ret; | 192 | return ret; |
| 178 | } | 193 | } |
| 179 | 194 | ||
| @@ -244,7 +259,10 @@ drvError_t __attribute__((weak)) trs_urma_proc_ctx_init_by_devid(uint32_t dev_id | |||
| 244 | return DRV_ERROR_NONE; | 259 | return DRV_ERROR_NONE; |
| 245 | } | 260 | } |
| 246 | 261 | ||
| 247 | -void __attribute__((weak)) trs_urma_proc_ctx_uninit_by_devid(uint32_t dev_id) { (void)dev_id; } | 262 | +void __attribute__((weak)) trs_urma_proc_ctx_uninit_by_devid(uint32_t dev_id) |
| 263 | +{ | ||
| 264 | + (void)dev_id; | ||
| 265 | +} | ||
| 248 | 266 | ||
| 249 | static int trs_dev_init(uint32_t dev_id) | 267 | static int trs_dev_init(uint32_t dev_id) |
| 250 | { | 268 | { |
| @@ -327,8 +345,8 @@ static drvError_t drvDeviceOpenComm(void **dev_info, uint32_t dev_id) | |||
| 327 | int fd, mmap_fd, ret; | 345 | int fd, mmap_fd, ret; |
| 328 | 346 | ||
| 329 | if ((dev_info == NULL) || (dev_id >= TRS_DEV_NUM)) { | 347 | if ((dev_info == NULL) || (dev_id >= TRS_DEV_NUM)) { |
| 330 | - trs_err( | 348 | + trs_err("Invalid ptr or dev_id. (dev_info_Null=%d; devid=%u; max=%d)\n", (dev_info == NULL), dev_id, |
| 331 | - "Invalid ptr or dev_id. (dev_info_Null=%d; devid=%u; max=%d)\n", (dev_info == NULL), dev_id, TRS_DEV_NUM); | 349 | + TRS_DEV_NUM); |
| 332 | return DRV_ERROR_INVALID_VALUE; | 350 | return DRV_ERROR_INVALID_VALUE; |
| 333 | } | 351 | } |
| 334 | 352 | ||
| @@ -403,7 +421,10 @@ drvError_t drvDeviceOpenInner(uint32_t dev_id, halDevOpenIn *in, halDevOpenOut * | |||
| 403 | return drvDeviceOpenComm((void **)(&dev_info), dev_id); | 421 | return drvDeviceOpenComm((void **)(&dev_info), dev_id); |
| 404 | } | 422 | } |
| 405 | 423 | ||
| 406 | -drvError_t drvDeviceOpen(void **devInfo, uint32_t devId) { return drvDeviceOpenComm(devInfo, devId); } | 424 | +drvError_t drvDeviceOpen(void **devInfo, uint32_t devId) |
| 425 | +{ | ||
| 426 | + return drvDeviceOpenComm(devInfo, devId); | ||
| 427 | +} | ||
| 407 | 428 | ||
| 408 | static int trs_set_close_type(uint32_t dev_id, uint32_t ts_id, uint32_t close_type) | 429 | static int trs_set_close_type(uint32_t dev_id, uint32_t ts_id, uint32_t close_type) |
| 409 | { | 430 | { |
| @@ -780,6 +801,12 @@ static drvError_t trs_mode_op_by_urd(struct trs_mode_info *info, enum urd_main_c | |||
| 780 | return ret; | 801 | return ret; |
| 781 | } | 802 | } |
| 782 | 803 | ||
| 783 | -drvError_t trs_mode_config(struct trs_mode_info *info) { return trs_mode_op_by_urd(info, URD_TRS_MODE_CONFIG_CMD); } | 804 | +drvError_t trs_mode_config(struct trs_mode_info *info) |
| 805 | +{ | ||
| 806 | + return trs_mode_op_by_urd(info, URD_TRS_MODE_CONFIG_CMD); | ||
| 807 | +} | ||
| 784 | 808 | ||
| 785 | -drvError_t trs_mode_query(struct trs_mode_info *info) { return trs_mode_op_by_urd(info, URD_TRS_MODE_QUERY_CMD); } | 809 | +drvError_t trs_mode_query(struct trs_mode_info *info) |
| 810 | +{ | ||
| 811 | + return trs_mode_op_by_urd(info, URD_TRS_MODE_QUERY_CMD); | ||
| 812 | +} | ||
| @@ -20,8 +20,8 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | -drvError_t __attribute__((weak)) trs_urma_res_config( | 23 | +drvError_t __attribute__((weak)) trs_urma_res_config(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 24 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para) | 24 | + struct halResourceConfigInfo *para) |
| 25 | { | 25 | { |
| 26 | (void)dev_id; | 26 | (void)dev_id; |
| 27 | (void)in; | 27 | (void)in; |
| @@ -29,8 +29,8 @@ drvError_t __attribute__((weak)) trs_urma_res_config( | |||
| 29 | return DRV_ERROR_NOT_SUPPORT; | 29 | return DRV_ERROR_NOT_SUPPORT; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | -drvError_t __attribute__((weak)) trs_sqcq_urma_alloc( | 32 | +drvError_t __attribute__((weak)) trs_sqcq_urma_alloc(uint32_t dev_id, struct halSqCqInputInfo *in, |
| 33 | - uint32_t dev_id, struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out) | 33 | + struct halSqCqOutputInfo *out) |
| 34 | { | 34 | { |
| 35 | (void)dev_id; | 35 | (void)dev_id; |
| 36 | (void)in; | 36 | (void)in; |
| @@ -38,8 +38,8 @@ drvError_t __attribute__((weak)) trs_sqcq_urma_alloc( | |||
| 38 | return DRV_ERROR_NOT_SUPPORT; | 38 | return DRV_ERROR_NOT_SUPPORT; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -drvError_t __attribute__((weak)) trs_sqcq_urma_free( | 41 | +drvError_t __attribute__((weak)) trs_sqcq_urma_free(uint32_t dev_id, struct halSqCqFreeInfo *info, |
| 42 | - uint32_t dev_id, struct halSqCqFreeInfo *info, bool remote_free_flag) | 42 | + bool remote_free_flag) |
| 43 | { | 43 | { |
| 44 | (void)dev_id; | 44 | (void)dev_id; |
| 45 | (void)info; | 45 | (void)info; |
| @@ -61,8 +61,8 @@ drvError_t __attribute__((weak)) trs_sq_cq_config_sync(uint32_t dev_id, struct h | |||
| 61 | return DRV_ERROR_NOT_SUPPORT; | 61 | return DRV_ERROR_NOT_SUPPORT; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | -drvError_t __attribute__((weak)) trs_sq_task_args_async_copy( | 64 | +drvError_t __attribute__((weak)) trs_sq_task_args_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo *info, |
| 65 | - uint32_t dev_id, struct halSqTaskArgsInfo *info, struct sqcq_usr_info *sq_info) | 65 | + struct sqcq_usr_info *sq_info) |
| 66 | { | 66 | { |
| 67 | (void)dev_id; | 67 | (void)dev_id; |
| 68 | (void)info; | 68 | (void)info; |
| @@ -70,8 +70,8 @@ drvError_t __attribute__((weak)) trs_sq_task_args_async_copy( | |||
| 70 | return DRV_ERROR_NOT_SUPPORT; | 70 | return DRV_ERROR_NOT_SUPPORT; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | -drvError_t __attribute__((weak)) trs_async_dma_wqe_create( | 73 | +drvError_t __attribute__((weak)) trs_async_dma_wqe_create(uint32_t dev_id, struct trs_async_dma_input_para *in, |
| 74 | - uint32_t dev_id, struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 74 | + struct halAsyncDmaOutputPara *out) |
| 75 | { | 75 | { |
| 76 | (void)dev_id; | 76 | (void)dev_id; |
| 77 | (void)in; | 77 | (void)in; |
| @@ -86,8 +86,8 @@ drvError_t __attribute__((weak)) trs_async_dma_wqe_destory(uint32_t dev_id, stru | |||
| 86 | return DRV_ERROR_NOT_SUPPORT; | 86 | return DRV_ERROR_NOT_SUPPORT; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | -drvError_t __attribute__((weak)) trs_sq_task_send_urma( | 89 | +drvError_t __attribute__((weak)) trs_sq_task_send_urma(uint32_t dev_id, struct halTaskSendInfo *info, |
| 90 | - uint32_t dev_id, struct halTaskSendInfo *info, struct sqcq_usr_info *sq_info) | 90 | + struct sqcq_usr_info *sq_info) |
| 91 | { | 91 | { |
| 92 | (void)dev_id; | 92 | (void)dev_id; |
| 93 | (void)info; | 93 | (void)info; |
| @@ -95,8 +95,8 @@ drvError_t __attribute__((weak)) trs_sq_task_send_urma( | |||
| 95 | return DRV_ERROR_NOT_SUPPORT; | 95 | return DRV_ERROR_NOT_SUPPORT; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | -drvError_t __attribute__((weak)) trs_get_urma_tseg_info_by_va( | 98 | +drvError_t __attribute__((weak)) trs_get_urma_tseg_info_by_va(uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, |
| 99 | - uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, struct halTsegInfo *tsegInfo) | 99 | + struct halTsegInfo *tsegInfo) |
| 100 | { | 100 | { |
| 101 | (void)devid; | 101 | (void)devid; |
| 102 | (void)va; | 102 | (void)va; |
| @@ -120,8 +120,8 @@ drvError_t __attribute__((weak)) trs_sq_jetty_info_query(uint32_t devid, struct | |||
| 120 | return DRV_ERROR_NOT_SUPPORT; | 120 | return DRV_ERROR_NOT_SUPPORT; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | -drvError_t __attribute__((weak)) trs_async_dma_jetty_create( | 123 | +drvError_t __attribute__((weak)) trs_async_dma_jetty_create(uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, |
| 124 | - uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, struct halAsyncDmaJettyCreateOut *out) | 124 | + struct halAsyncDmaJettyCreateOut *out) |
| 125 | { | 125 | { |
| 126 | (void)dev_id; | 126 | (void)dev_id; |
| 127 | (void)in; | 127 | (void)in; |
| @@ -136,8 +136,8 @@ drvError_t __attribute__((weak)) trs_async_dma_jetty_destroy(uint32_t dev_id, st | |||
| 136 | return DRV_ERROR_NOT_SUPPORT; | 136 | return DRV_ERROR_NOT_SUPPORT; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | -drvError_t __attribute__((weak)) trs_async_dma_jetty_query( | 139 | +drvError_t __attribute__((weak)) trs_async_dma_jetty_query(uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, |
| 140 | - uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, struct halAsyncDmaJettyQueryOut *out) | 140 | + struct halAsyncDmaJettyQueryOut *out) |
| 141 | { | 141 | { |
| 142 | (void)dev_id; | 142 | (void)dev_id; |
| 143 | (void)in; | 143 | (void)in; |
| @@ -145,8 +145,8 @@ drvError_t __attribute__((weak)) trs_async_dma_jetty_query( | |||
| 145 | return DRV_ERROR_NOT_SUPPORT; | 145 | return DRV_ERROR_NOT_SUPPORT; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | -drvError_t __attribute__((weak)) trs_async_dma_wqe_convert( | 148 | +drvError_t __attribute__((weak)) trs_async_dma_wqe_convert(uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, |
| 149 | - uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, struct halAsyncDmaWqeOutputPara *out) | 149 | + struct halAsyncDmaWqeOutputPara *out) |
| 150 | { | 150 | { |
| 151 | (void)dev_id; | 151 | (void)dev_id; |
| 152 | (void)in; | 152 | (void)in; |
| @@ -411,9 +411,8 @@ static drvError_t trs_sq_cq_urma_config(uint32_t devId, struct halSqCqConfigInfo | |||
| 411 | if (info->type == DRV_NORMAL_TYPE) { | 411 | if (info->type == DRV_NORMAL_TYPE) { |
| 412 | struct sqcq_usr_info *sq_info = trs_get_sq_info(devId, info->tsId, info->type, info->sqId); | 412 | struct sqcq_usr_info *sq_info = trs_get_sq_info(devId, info->tsId, info->type, info->sqId); |
| 413 | if (sq_info == NULL) { | 413 | if (sq_info == NULL) { |
| 414 | - trs_err( | 414 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", devId, info->tsId, info->type, |
| 415 | - "Invalid para. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", devId, info->tsId, info->type, | 415 | + info->sqId); |
| 416 | - info->sqId); | ||
| 417 | return DRV_ERROR_INVALID_VALUE; | 416 | return DRV_ERROR_INVALID_VALUE; |
| 418 | } | 417 | } |
| 419 | 418 | ||
| @@ -483,9 +482,8 @@ drvError_t halSqTaskArgsAsyncCopy(uint32_t devId, struct halSqTaskArgsInfo *info | |||
| 483 | 482 | ||
| 484 | if ((devId >= TRS_DEV_NUM) || (info->tsId >= TRS_TS_NUM) || (info->src == 0) || (info->dst == 0) || | 483 | if ((devId >= TRS_DEV_NUM) || (info->tsId >= TRS_TS_NUM) || (info->src == 0) || (info->dst == 0) || |
| 485 | (info->size == 0) || (info->type != DRV_NORMAL_TYPE)) { | 484 | (info->size == 0) || (info->type != DRV_NORMAL_TYPE)) { |
| 486 | - trs_err( | 485 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; src=0x%llx; dst=0x%llx; size=%u; type=%d)\n", devId, info->tsId, |
| 487 | - "Invalid para. (dev_id=%u; ts_id=%u; src=0x%llx; dst=0x%llx; size=%u; type=%d)\n", devId, info->tsId, | 486 | + info->src, info->dst, info->size, info->type); |
| 488 | - info->src, info->dst, info->size, info->type); | ||
| 489 | return DRV_ERROR_INVALID_VALUE; | 487 | return DRV_ERROR_INVALID_VALUE; |
| 490 | } | 488 | } |
| 491 | 489 | ||
| @@ -508,8 +506,8 @@ drvError_t halSqTaskArgsAsyncCopy(uint32_t devId, struct halSqTaskArgsInfo *info | |||
| 508 | 506 | ||
| 509 | } | 507 | } |
| 510 | 508 | ||
| 511 | -static drvError_t trs_async_para_check( | 509 | +static drvError_t trs_async_para_check(uint32_t dev_id, struct halAsyncDmaInputPara *in, |
| 512 | - uint32_t dev_id, struct halAsyncDmaInputPara *in, struct halAsyncDmaOutputPara *out) | 510 | + struct halAsyncDmaOutputPara *out) |
| 513 | { | 511 | { |
| 514 | if ((in == NULL) || (out == NULL)) { | 512 | if ((in == NULL) || (out == NULL)) { |
| 515 | trs_err("Invalid para.\n"); | 513 | trs_err("Invalid para.\n"); |
| @@ -551,8 +549,8 @@ drvError_t halAsyncDmaCreate(uint32_t devId, struct halAsyncDmaInputPara *in, st | |||
| 551 | case TRS_CONNECT_PROTOCOL_PCIE: | 549 | case TRS_CONNECT_PROTOCOL_PCIE: |
| 552 | return trs_async_dma_desc_create(devId, in, out); | 550 | return trs_async_dma_desc_create(devId, in, out); |
| 553 | case TRS_CONNECT_PROTOCOL_UB: | 551 | case TRS_CONNECT_PROTOCOL_UB: |
| 554 | - input_para = trs_pack_async_dma_input_para( | 552 | + input_para = trs_pack_async_dma_input_para(in, (enum trs_async_dma_type)in->async_dma_type, in->type, |
| 555 | - in, (enum trs_async_dma_type)in->async_dma_type, in->type, in->tsId, in->sqId); | 553 | + in->tsId, in->sqId); |
| 556 | return trs_async_dma_wqe_create(devId, &input_para, out); | 554 | return trs_async_dma_wqe_create(devId, &input_para, out); |
| 557 | default: | 555 | default: |
| 558 | return DRV_ERROR_NOT_SUPPORT; | 556 | return DRV_ERROR_NOT_SUPPORT; |
| @@ -589,8 +587,8 @@ drvError_t halAsyncDmaDestory(uint32_t devId, struct halAsyncDmaDestoryPara *par | |||
| 589 | case TRS_CONNECT_PROTOCOL_PCIE: | 587 | case TRS_CONNECT_PROTOCOL_PCIE: |
| 590 | return trs_async_dma_destory(devId, para); | 588 | return trs_async_dma_destory(devId, para); |
| 591 | case TRS_CONNECT_PROTOCOL_UB: | 589 | case TRS_CONNECT_PROTOCOL_UB: |
| 592 | - destroy_para = | 590 | + destroy_para = trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_NORMAL, para->type, para->tsId, |
| 593 | - trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_NORMAL, para->type, para->tsId, para->sqId); | 591 | + para->sqId); |
| 594 | return trs_async_dma_wqe_destory(devId, &destroy_para); | 592 | return trs_async_dma_wqe_destory(devId, &destroy_para); |
| 595 | default: | 593 | default: |
| 596 | return DRV_ERROR_NOT_SUPPORT; | 594 | return DRV_ERROR_NOT_SUPPORT; |
| @@ -607,24 +605,21 @@ static int _trs_async_2d_para_check(struct drv2dWqeInputPara *para) | |||
| 607 | { | 605 | { |
| 608 | if ((para->src == NULL) || (para->dst == NULL) || (para->width == 0) || (para->height == 0) || | 606 | if ((para->src == NULL) || (para->dst == NULL) || (para->width == 0) || (para->height == 0) || |
| 609 | (para->dpitch < para->width) || (para->spitch < para->width) || (para->height > TRS_2D_HEIGHT_MAX)) { | 607 | (para->dpitch < para->width) || (para->spitch < para->width) || (para->height > TRS_2D_HEIGHT_MAX)) { |
| 610 | - trs_err( | 608 | + trs_err("Invalid para. (src_null=%d; dst_null=%d; width=%llu; height=%llu; dpitch=%llu; spitch=%llu)\n", |
| 611 | - "Invalid para. (src_null=%d; dst_null=%d; width=%llu; height=%llu; dpitch=%llu; spitch=%llu)\n", | 609 | + (para->src == NULL), (para->dst == NULL), para->width, para->height, para->dpitch, para->spitch); |
| 612 | - (para->src == NULL), (para->dst == NULL), para->width, para->height, para->dpitch, para->spitch); | ||
| 613 | return DRV_ERROR_INVALID_VALUE; | 610 | return DRV_ERROR_INVALID_VALUE; |
| 614 | } | 611 | } |
| 615 | 612 | ||
| 616 | if (para->fixedSize >= (para->height * para->width)) { | 613 | if (para->fixedSize >= (para->height * para->width)) { |
| 617 | - trs_err( | 614 | + trs_err("Invalid fixedSize. (fixedSize=0x%llx; height=%llu; width=%llu)\n", para->fixedSize, para->height, |
| 618 | - "Invalid fixedSize. (fixedSize=0x%llx; height=%llu; width=%llu)\n", para->fixedSize, para->height, | 615 | + para->width); |
| 619 | - para->width); | ||
| 620 | return DRV_ERROR_INVALID_VALUE; | 616 | return DRV_ERROR_INVALID_VALUE; |
| 621 | } | 617 | } |
| 622 | 618 | ||
| 623 | if ((para->height != 1) && (((uintptr_t)((char *)para->src + para->spitch) < (uintptr_t)para->src) || | 619 | if ((para->height != 1) && (((uintptr_t)((char *)para->src + para->spitch) < (uintptr_t)para->src) || |
| 624 | ((uintptr_t)((char *)para->dst + para->dpitch) < (uintptr_t)para->dst))) { | 620 | ((uintptr_t)((char *)para->dst + para->dpitch) < (uintptr_t)para->dst))) { |
| 625 | - trs_err( | 621 | + trs_err("Invalid para. (src=%p; dst=%p; spitch=%llu; dpitch=%llu)\n", para->src, para->dst, para->spitch, |
| 626 | - "Invalid para. (src=%p; dst=%p; spitch=%llu; dpitch=%llu)\n", para->src, para->dst, para->spitch, | 622 | + para->dpitch); |
| 627 | - para->dpitch); | ||
| 628 | return DRV_ERROR_INVALID_VALUE; | 623 | return DRV_ERROR_INVALID_VALUE; |
| 629 | } | 624 | } |
| 630 | 625 | ||
| @@ -704,8 +699,8 @@ drvError_t halAsyncDmaDestroy2D(uint32_t devId, struct halAsyncDmaDestroy2DPara | |||
| 704 | case TRS_CONNECT_PROTOCOL_PCIE: | 699 | case TRS_CONNECT_PROTOCOL_PCIE: |
| 705 | return DRV_ERROR_NOT_SUPPORT; | 700 | return DRV_ERROR_NOT_SUPPORT; |
| 706 | case TRS_CONNECT_PROTOCOL_UB: | 701 | case TRS_CONNECT_PROTOCOL_UB: |
| 707 | - destroy_para = | 702 | + destroy_para = trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_2D, para->type, para->tsId, |
| 708 | - trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_2D, para->type, para->tsId, para->sqId); | 703 | + para->sqId); |
| 709 | return trs_async_dma_wqe_destory(devId, &destroy_para); | 704 | return trs_async_dma_wqe_destory(devId, &destroy_para); |
| 710 | default: | 705 | default: |
| 711 | return DRV_ERROR_NOT_SUPPORT; | 706 | return DRV_ERROR_NOT_SUPPORT; |
| @@ -713,13 +708,12 @@ drvError_t halAsyncDmaDestroy2D(uint32_t devId, struct halAsyncDmaDestroy2DPara | |||
| 713 | } | 708 | } |
| 714 | 709 | ||
| 715 | 710 | ||
| 716 | -static int _trs_async_batch_para_check( | 711 | +static int _trs_async_batch_para_check(unsigned long long *src, unsigned long long *dst, unsigned long long *len, |
| 717 | - unsigned long long *src, unsigned long long *dst, unsigned long long *len, unsigned long long count) | 712 | + unsigned long long count) |
| 718 | { | 713 | { |
| 719 | if ((src == NULL) || (dst == NULL) || (len == NULL)) { | 714 | if ((src == NULL) || (dst == NULL) || (len == NULL)) { |
| 720 | - trs_err( | 715 | + trs_err("Invalid para. (src_is_null=%d; dst_is_null=%d; size_is_null=%d)\n", (src == NULL), (dst == NULL), |
| 721 | - "Invalid para. (src_is_null=%d; dst_is_null=%d; size_is_null=%d)\n", (src == NULL), (dst == NULL), | 716 | + (len == NULL)); |
| 722 | - (len == NULL)); | ||
| 723 | return DRV_ERROR_INVALID_VALUE; | 717 | return DRV_ERROR_INVALID_VALUE; |
| 724 | } | 718 | } |
| 725 | 719 | ||
| @@ -731,8 +725,8 @@ static int _trs_async_batch_para_check( | |||
| 731 | return 0; | 725 | return 0; |
| 732 | } | 726 | } |
| 733 | 727 | ||
| 734 | -static int trs_async_batch_para_check( | 728 | +static int trs_async_batch_para_check(uint32_t devId, struct halAsyncDmaInputBatchPara *in, |
| 735 | - uint32_t devId, struct halAsyncDmaInputBatchPara *in, struct halAsyncDmaOutputPara *out) | 729 | + struct halAsyncDmaOutputPara *out) |
| 736 | { | 730 | { |
| 737 | if ((in == NULL) || (out == NULL)) { | 731 | if ((in == NULL) || (out == NULL)) { |
| 738 | trs_err("Invalid para.\n"); | 732 | trs_err("Invalid para.\n"); |
| @@ -751,8 +745,8 @@ static int trs_async_batch_para_check( | |||
| 751 | return _trs_async_batch_para_check(in->src, in->dst, in->len, in->count); | 745 | return _trs_async_batch_para_check(in->src, in->dst, in->len, in->count); |
| 752 | } | 746 | } |
| 753 | 747 | ||
| 754 | -drvError_t halAsyncDmaCreateBatch( | 748 | +drvError_t halAsyncDmaCreateBatch(uint32_t devId, struct halAsyncDmaInputBatchPara *in, |
| 755 | - uint32_t devId, struct halAsyncDmaInputBatchPara *in, struct halAsyncDmaOutputPara *out) | 749 | + struct halAsyncDmaOutputPara *out) |
| 756 | { | 750 | { |
| 757 | struct trs_async_dma_input_para input_para = {0}; | 751 | struct trs_async_dma_input_para input_para = {0}; |
| 758 | int connection_type; | 752 | int connection_type; |
| @@ -797,8 +791,8 @@ drvError_t halAsyncDmaDestroyBatch(uint32_t devId, struct halAsyncDmaDestroyBatc | |||
| 797 | case TRS_CONNECT_PROTOCOL_PCIE: | 791 | case TRS_CONNECT_PROTOCOL_PCIE: |
| 798 | return DRV_ERROR_NOT_SUPPORT; | 792 | return DRV_ERROR_NOT_SUPPORT; |
| 799 | case TRS_CONNECT_PROTOCOL_UB: | 793 | case TRS_CONNECT_PROTOCOL_UB: |
| 800 | - destroy_para = | 794 | + destroy_para = trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_BATCH, para->type, para->tsId, |
| 801 | - trs_pack_async_dma_destroy_para(para, TRS_ASYNC_DMA_TYPE_BATCH, para->type, para->tsId, para->sqId); | 795 | + para->sqId); |
| 802 | return trs_async_dma_wqe_destory(devId, &destroy_para); | 796 | return trs_async_dma_wqe_destory(devId, &destroy_para); |
| 803 | default: | 797 | default: |
| 804 | return DRV_ERROR_NOT_SUPPORT; | 798 | return DRV_ERROR_NOT_SUPPORT; |
| @@ -817,8 +811,8 @@ static inline int trs_interface_para_rsv_check(uint32_t *rsv, int rsv_cnt) | |||
| 817 | return 0; | 811 | return 0; |
| 818 | } | 812 | } |
| 819 | 813 | ||
| 820 | -static int trs_async_jetty_create_para_check( | 814 | +static int trs_async_jetty_create_para_check(uint32_t devId, struct halAsyncDmaJettyCreateIn *in, |
| 821 | - uint32_t devId, struct halAsyncDmaJettyCreateIn *in, struct halAsyncDmaJettyCreateOut *out) | 815 | + struct halAsyncDmaJettyCreateOut *out) |
| 822 | { | 816 | { |
| 823 | if ((in == NULL) || (out == NULL)) { | 817 | if ((in == NULL) || (out == NULL)) { |
| 824 | trs_err("Invalid null para.\n"); | 818 | trs_err("Invalid null para.\n"); |
| @@ -827,9 +821,8 @@ static int trs_async_jetty_create_para_check( | |||
| 827 | 821 | ||
| 828 | if ((devId >= TRS_DEV_NUM) || (in->jettyType >= DRV_ASYNC_DMA_JETTY_TYPE_MAX) || | 822 | if ((devId >= TRS_DEV_NUM) || (in->jettyType >= DRV_ASYNC_DMA_JETTY_TYPE_MAX) || |
| 829 | (in->piMode >= DRV_ASYNC_DMA_JETTY_PI_MODE_MAX) || (in->depth == 0)) { | 823 | (in->piMode >= DRV_ASYNC_DMA_JETTY_PI_MODE_MAX) || (in->depth == 0)) { |
| 830 | - trs_err( | 824 | + trs_err("Invalid para. (dev_id=%u; jetty_type=%d; pi_mode=%d; dir=%d; depth=%u)\n", devId, in->jettyType, |
| 831 | - "Invalid para. (dev_id=%u; jetty_type=%d; pi_mode=%d; dir=%d; depth=%u)\n", devId, in->jettyType, | 825 | + in->piMode, in->dir, in->depth); |
| 832 | - in->piMode, in->dir, in->depth); | ||
| 833 | return DRV_ERROR_INVALID_VALUE; | 826 | return DRV_ERROR_INVALID_VALUE; |
| 834 | } | 827 | } |
| 835 | 828 | ||
| @@ -845,8 +838,8 @@ static int trs_async_jetty_create_para_check( | |||
| 845 | return 0; | 838 | return 0; |
| 846 | } | 839 | } |
| 847 | 840 | ||
| 848 | -drvError_t halAsyncDmaJettyCreate( | 841 | +drvError_t halAsyncDmaJettyCreate(uint32_t devId, struct halAsyncDmaJettyCreateIn *in, |
| 849 | - uint32_t devId, struct halAsyncDmaJettyCreateIn *in, struct halAsyncDmaJettyCreateOut *out) | 842 | + struct halAsyncDmaJettyCreateOut *out) |
| 850 | { | 843 | { |
| 851 | int connection_type; | 844 | int connection_type; |
| 852 | drvError_t ret = 0; | 845 | drvError_t ret = 0; |
| @@ -901,8 +894,8 @@ drvError_t halAsyncDmaJettyDestroy(uint32_t devId, struct halAsyncJettyDestroyPa | |||
| 901 | return trs_async_dma_jetty_destroy(devId, para); | 894 | return trs_async_dma_jetty_destroy(devId, para); |
| 902 | } | 895 | } |
| 903 | 896 | ||
| 904 | -drvError_t halAsyncDmaJettyQuery( | 897 | +drvError_t halAsyncDmaJettyQuery(uint32_t devId, struct halAsyncDmaJettyQueryIn *in, |
| 905 | - uint32_t devId, struct halAsyncDmaJettyQueryIn *in, struct halAsyncDmaJettyQueryOut *out) | 898 | + struct halAsyncDmaJettyQueryOut *out) |
| 906 | { | 899 | { |
| 907 | int connection_type; | 900 | int connection_type; |
| 908 | 901 | ||
| @@ -929,8 +922,8 @@ drvError_t halAsyncDmaJettyQuery( | |||
| 929 | return trs_async_dma_jetty_query(devId, in, out); | 922 | return trs_async_dma_jetty_query(devId, in, out); |
| 930 | } | 923 | } |
| 931 | 924 | ||
| 932 | -static int trs_async_wqe_convert_para_check( | 925 | +static int trs_async_wqe_convert_para_check(uint32_t devId, struct halAsyncDmaWqeInputPara *in, |
| 933 | - uint32_t devId, struct halAsyncDmaWqeInputPara *in, struct halAsyncDmaWqeOutputPara *out) | 926 | + struct halAsyncDmaWqeOutputPara *out) |
| 934 | { | 927 | { |
| 935 | if ((in == NULL) || (out == NULL)) { | 928 | if ((in == NULL) || (out == NULL)) { |
| 936 | trs_err("Invalid null para.\n"); | 929 | trs_err("Invalid null para.\n"); |
| @@ -942,9 +935,8 @@ static int trs_async_wqe_convert_para_check( | |||
| 942 | } | 935 | } |
| 943 | 936 | ||
| 944 | if ((devId >= TRS_DEV_NUM) || (in->wqeBuffer == NULL) || (in->wqeBufferLen == 0)) { | 937 | if ((devId >= TRS_DEV_NUM) || (in->wqeBuffer == NULL) || (in->wqeBufferLen == 0)) { |
| 945 | - trs_err( | 938 | + trs_err("Invalid para. (dev_id=%u; wqe_buffer_null=%d; wqe_buffer_len=0x%llx)\n", devId, |
| 946 | - "Invalid para. (dev_id=%u; wqe_buffer_null=%d; wqe_buffer_len=0x%llx)\n", devId, (in->wqeBuffer == NULL), | 939 | + (in->wqeBuffer == NULL), in->wqeBufferLen); |
| 947 | - in->wqeBufferLen); | ||
| 948 | return DRV_ERROR_INVALID_VALUE; | 940 | return DRV_ERROR_INVALID_VALUE; |
| 949 | } | 941 | } |
| 950 | 942 | ||
| @@ -957,9 +949,8 @@ static int trs_async_wqe_convert_para_check( | |||
| 957 | case DRV_ASYNC_DMA_TYPE_NORMAL: | 949 | case DRV_ASYNC_DMA_TYPE_NORMAL: |
| 958 | if ((in->normal.src == NULL) || (in->normal.dst == NULL) || (in->normal.len == 0) || | 950 | if ((in->normal.src == NULL) || (in->normal.dst == NULL) || (in->normal.len == 0) || |
| 959 | (in->normal.asyncDmaType != DRV_ASYNC_DMA_TYPE_NORMAL)) { | 951 | (in->normal.asyncDmaType != DRV_ASYNC_DMA_TYPE_NORMAL)) { |
| 960 | - trs_err( | 952 | + trs_err("Invalid para. (src_is_null=%d; dst_is_null=%d; len=0x%llx)\n", (in->normal.src == NULL), |
| 961 | - "Invalid para. (src_is_null=%d; dst_is_null=%d; len=0x%llx)\n", (in->normal.src == NULL), | 953 | + (in->normal.dst == NULL), in->normal.len); |
| 962 | - (in->normal.dst == NULL), in->normal.len); | ||
| 963 | return DRV_ERROR_INVALID_VALUE; | 954 | return DRV_ERROR_INVALID_VALUE; |
| 964 | } | 955 | } |
| 965 | break; | 956 | break; |
| @@ -980,8 +971,8 @@ static int trs_async_wqe_convert_para_check( | |||
| 980 | return 0; | 971 | return 0; |
| 981 | } | 972 | } |
| 982 | 973 | ||
| 983 | -drvError_t halAsyncDmaWqeConvert( | 974 | +drvError_t halAsyncDmaWqeConvert(uint32_t devId, struct halAsyncDmaWqeInputPara *in, |
| 984 | - uint32_t devId, struct halAsyncDmaWqeInputPara *in, struct halAsyncDmaWqeOutputPara *out) | 975 | + struct halAsyncDmaWqeOutputPara *out) |
| 985 | { | 976 | { |
| 986 | int connection_type; | 977 | int connection_type; |
| 987 | drvError_t ret = 0; | 978 | drvError_t ret = 0; |
| @@ -1047,9 +1038,8 @@ drvError_t halSqTaskSend(uint32_t devId, struct halTaskSendInfo *info) | |||
| 1047 | } | 1038 | } |
| 1048 | 1039 | ||
| 1049 | if ((!trs_is_sq_support_send(sq_info)) || (trs_is_sq_init_without_sq_mem(sq_info->flag))) { | 1040 | if ((!trs_is_sq_support_send(sq_info)) || (trs_is_sq_init_without_sq_mem(sq_info->flag))) { |
| 1050 | - trs_warn( | 1041 | + trs_warn("Sq is only id type, not support task send. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, |
| 1051 | - "Sq is only id type, not support task send. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, info->tsId, | 1042 | + info->tsId, info->sqId, sq_info->flag); |
| 1052 | - info->sqId, sq_info->flag); | ||
| 1053 | return DRV_ERROR_NOT_SUPPORT; | 1043 | return DRV_ERROR_NOT_SUPPORT; |
| 1054 | } | 1044 | } |
| 1055 | 1045 | ||
| @@ -108,8 +108,8 @@ void __attribute__((weak)) trs_unregister_reg(uint32_t dev_id, uint64_t va, uint | |||
| 108 | (void)size; | 108 | (void)size; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | -drvError_t __attribute__((weak)) halResAddrMap( | 111 | +drvError_t __attribute__((weak)) halResAddrMap(unsigned int devId, struct res_addr_info *res_info, unsigned long *va, |
| 112 | - unsigned int devId, struct res_addr_info *res_info, unsigned long *va, unsigned int *len) | 112 | + unsigned int *len) |
| 113 | { | 113 | { |
| 114 | (void)devId; | 114 | (void)devId; |
| 115 | (void)res_info; | 115 | (void)res_info; |
| @@ -126,8 +126,8 @@ drvError_t __attribute__((weak)) halResAddrUnmap(unsigned int devId, struct res_ | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | -int trs_res_map_reg_init( | 129 | +int trs_res_map_reg_init(uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, |
| 130 | - uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, struct res_id_usr_info *id_info) | 130 | + struct res_id_usr_info *id_info) |
| 131 | { | 131 | { |
| 132 | struct res_addr_info res_info = {0}; | 132 | struct res_addr_info res_info = {0}; |
| 133 | unsigned long notify_va; | 133 | unsigned long notify_va; |
| @@ -140,8 +140,8 @@ int trs_res_map_reg_init( | |||
| 140 | res_info.id = ts_id; | 140 | res_info.id = ts_id; |
| 141 | res_info.res_id = res_id; | 141 | res_info.res_id = res_id; |
| 142 | res_info.target_proc_type = PROCESS_CP1; | 142 | res_info.target_proc_type = PROCESS_CP1; |
| 143 | - res_info.res_type = | 143 | + res_info.res_type = (type == DRV_NOTIFY_ID) ? RES_ADDR_TYPE_STARS_NOTIFY_RECORD : |
| 144 | - (type == DRV_NOTIFY_ID) ? RES_ADDR_TYPE_STARS_NOTIFY_RECORD : RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD; | 144 | + RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD; |
| 145 | ret = halResAddrMap(dev_id, &res_info, ¬ify_va, ¬ify_len); | 145 | ret = halResAddrMap(dev_id, &res_info, ¬ify_va, ¬ify_len); |
| 146 | if (ret != DRV_ERROR_NONE) { | 146 | if (ret != DRV_ERROR_NONE) { |
| 147 | 147 | ||
| @@ -154,19 +154,17 @@ int trs_res_map_reg_init( | |||
| 154 | id_info->res_len = notify_len; | 154 | id_info->res_len = notify_len; |
| 155 | ret = trs_register_reg(dev_id, id_info->res_addr, id_info->res_len); | 155 | ret = trs_register_reg(dev_id, id_info->res_addr, id_info->res_len); |
| 156 | if (ret != 0) { | 156 | if (ret != 0) { |
| 157 | - trs_err( | 157 | + trs_err("Register addr failed. (dev_id=%u; type=%d; addr=0x%llx; len=%u; id=%u; ret=%d)\n", dev_id, type, |
| 158 | - "Register addr failed. (dev_id=%u; type=%d; addr=0x%llx; len=%u; id=%u; ret=%d)\n", dev_id, type, | 158 | + (unsigned long long)id_info->res_addr, id_info->res_len, res_id, ret); |
| 159 | - (unsigned long long)id_info->res_addr, id_info->res_len, res_id, ret); | ||
| 160 | return ret; | 159 | return ret; |
| 161 | } | 160 | } |
| 162 | - trs_debug( | 161 | + trs_debug("Id map reg init. (dev_id=%u; type=%d; id=%u; addr=0x%llx; len=%u)\n", dev_id, type, res_id, |
| 163 | - "Id map reg init. (dev_id=%u; type=%d; id=%u; addr=0x%llx; len=%u)\n", dev_id, type, res_id, | 162 | + (unsigned long long)id_info->res_addr, id_info->res_len); |
| 164 | - (unsigned long long)id_info->res_addr, id_info->res_len); | ||
| 165 | return DRV_ERROR_NONE; | 163 | return DRV_ERROR_NONE; |
| 166 | } | 164 | } |
| 167 | 165 | ||
| 168 | -void trs_res_map_reg_un_init( | 166 | +void trs_res_map_reg_un_init(uint32_t dev_id, uint32_t tsid, uint32_t res_id, drvIdType_t type, |
| 169 | - uint32_t dev_id, uint32_t tsid, uint32_t res_id, drvIdType_t type, struct res_id_usr_info *id_info) | 167 | + struct res_id_usr_info *id_info) |
| 170 | { | 168 | { |
| 171 | struct res_addr_info res_info = {0}; | 169 | struct res_addr_info res_info = {0}; |
| 172 | int ret; | 170 | int ret; |
| @@ -180,8 +178,8 @@ void trs_res_map_reg_un_init( | |||
| 180 | res_info.id = tsid; | 178 | res_info.id = tsid; |
| 181 | res_info.target_proc_type = PROCESS_CP1; | 179 | res_info.target_proc_type = PROCESS_CP1; |
| 182 | res_info.res_id = res_id; | 180 | res_info.res_id = res_id; |
| 183 | - res_info.res_type = | 181 | + res_info.res_type = (type == DRV_NOTIFY_ID) ? RES_ADDR_TYPE_STARS_NOTIFY_RECORD : |
| 184 | - (type == DRV_NOTIFY_ID) ? RES_ADDR_TYPE_STARS_NOTIFY_RECORD : RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD; | 182 | + RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD; |
| 185 | ret = halResAddrUnmap(dev_id, &res_info); | 183 | ret = halResAddrUnmap(dev_id, &res_info); |
| 186 | if (ret != DRV_ERROR_NONE) { | 184 | if (ret != DRV_ERROR_NONE) { |
| 187 | trs_warn("Unmap failed. (dev_id=%u; ts_id=%u; notify_id=%u; ret=%d)\n", dev_id, tsid, res_id, ret); | 185 | trs_warn("Unmap failed. (dev_id=%u; ts_id=%u; notify_id=%u; ret=%d)\n", dev_id, tsid, res_id, ret); |
| @@ -207,8 +205,8 @@ static void trs_res_id_info_un_init(uint32_t dev_id, uint32_t ts_id, uint32_t re | |||
| 207 | id_info->priv = 0; | 205 | id_info->priv = 0; |
| 208 | } | 206 | } |
| 209 | 207 | ||
| 210 | -static int _trs_res_id_info_init( | 208 | +static int _trs_res_id_info_init(uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, |
| 211 | - uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, struct res_id_info_val *id_info_val) | 209 | + struct res_id_info_val *id_info_val) |
| 212 | { | 210 | { |
| 213 | struct res_id_usr_info *id_info = NULL; | 211 | struct res_id_usr_info *id_info = NULL; |
| 214 | 212 | ||
| @@ -223,8 +221,8 @@ static int _trs_res_id_info_init( | |||
| 223 | return DRV_ERROR_NONE; | 221 | return DRV_ERROR_NONE; |
| 224 | } | 222 | } |
| 225 | 223 | ||
| 226 | -int trs_res_id_info_init( | 224 | +int trs_res_id_info_init(uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, |
| 227 | - uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, struct res_id_info_val *id_info_val) | 225 | + struct res_id_info_val *id_info_val) |
| 228 | { | 226 | { |
| 229 | struct trs_res_id_ctx *ctx = NULL; | 227 | struct trs_res_id_ctx *ctx = NULL; |
| 230 | int ret = 0; | 228 | int ret = 0; |
| @@ -240,8 +238,8 @@ int trs_res_id_info_init( | |||
| 240 | return _trs_res_id_info_init(dev_id, ts_id, res_id, type, id_info_val); | 238 | return _trs_res_id_info_init(dev_id, ts_id, res_id, type, id_info_val); |
| 241 | } | 239 | } |
| 242 | 240 | ||
| 243 | -static int trs_res_type_init( | 241 | +static int trs_res_type_init(uint32_t dev_id, uint32_t ts_id, int id_type, struct res_id_usr_info **id_info, |
| 244 | - uint32_t dev_id, uint32_t ts_id, int id_type, struct res_id_usr_info **id_info, uint32_t *id_num) | 242 | + uint32_t *id_num) |
| 245 | { | 243 | { |
| 246 | struct trs_res_id_para para = {.tsid = ts_id, .res_type = id_type}; | 244 | struct trs_res_id_para para = {.tsid = ts_id, .res_type = id_type}; |
| 247 | struct res_id_usr_info *info = NULL; | 245 | struct res_id_usr_info *info = NULL; |
| @@ -276,8 +274,8 @@ static int trs_res_type_init( | |||
| 276 | return DRV_ERROR_NONE; | 274 | return DRV_ERROR_NONE; |
| 277 | } | 275 | } |
| 278 | 276 | ||
| 279 | -static void trs_res_type_un_init( | 277 | +static void trs_res_type_un_init(uint32_t dev_id, uint32_t ts_id, drvIdType_t id_type, struct res_id_usr_info **id_info, |
| 280 | - uint32_t dev_id, uint32_t ts_id, drvIdType_t id_type, struct res_id_usr_info **id_info, uint32_t *id_num) | 278 | + uint32_t *id_num) |
| 281 | { | 279 | { |
| 282 | struct res_id_usr_info *info = *id_info; | 280 | struct res_id_usr_info *info = *id_info; |
| 283 | uint32_t i = 0; | 281 | uint32_t i = 0; |
| @@ -393,9 +391,15 @@ void trs_dev_res_id_uninit(uint32_t dev_id) | |||
| 393 | } | 391 | } |
| 394 | 392 | ||
| 395 | struct trs_res_remote_ops g_res_remote_ops; | 393 | struct trs_res_remote_ops g_res_remote_ops; |
| 396 | -void trs_register_res_remote_ops(struct trs_res_remote_ops *ops) { g_res_remote_ops = *ops; } | 394 | +void trs_register_res_remote_ops(struct trs_res_remote_ops *ops) |
| 395 | +{ | ||
| 396 | + g_res_remote_ops = *ops; | ||
| 397 | +} | ||
| 397 | 398 | ||
| 398 | -static struct trs_res_remote_ops *trs_get_res_remote_ops(void) { return &g_res_remote_ops; } | 399 | +static struct trs_res_remote_ops *trs_get_res_remote_ops(void) |
| 400 | +{ | ||
| 401 | + return &g_res_remote_ops; | ||
| 402 | +} | ||
| 399 | 403 | ||
| 400 | static void trs_res_fill_ioctrl_para(struct halResourceIdInputInfo *in, struct trs_res_id_para *para) | 404 | static void trs_res_fill_ioctrl_para(struct halResourceIdInputInfo *in, struct trs_res_id_para *para) |
| 401 | { | 405 | { |
| @@ -410,8 +414,8 @@ static void trs_res_fill_ioctrl_para(struct halResourceIdInputInfo *in, struct t | |||
| 410 | } | 414 | } |
| 411 | } | 415 | } |
| 412 | 416 | ||
| 413 | -static drvError_t trs_res_alloc_para_check( | 417 | +static drvError_t trs_res_alloc_para_check(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 414 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out) | 418 | + struct halResourceIdOutputInfo *out) |
| 415 | { | 419 | { |
| 416 | if ((in == NULL) || (out == NULL)) { | 420 | if ((in == NULL) || (out == NULL)) { |
| 417 | trs_err("Null ptr.\n"); | 421 | trs_err("Null ptr.\n"); |
| @@ -437,8 +441,8 @@ static bool trs_is_remote_res_ops(uint32_t flag) | |||
| 437 | return false; | 441 | return false; |
| 438 | } | 442 | } |
| 439 | 443 | ||
| 440 | -static drvError_t trs_remote_res_alloc( | 444 | +static drvError_t trs_remote_res_alloc(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 441 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out) | 445 | + struct halResourceIdOutputInfo *out) |
| 442 | { | 446 | { |
| 443 | if (trs_get_res_remote_ops()->resid_alloc != NULL) { | 447 | if (trs_get_res_remote_ops()->resid_alloc != NULL) { |
| 444 | return trs_get_res_remote_ops()->resid_alloc(dev_id, in, out); | 448 | return trs_get_res_remote_ops()->resid_alloc(dev_id, in, out); |
| @@ -448,8 +452,8 @@ static drvError_t trs_remote_res_alloc( | |||
| 448 | } | 452 | } |
| 449 | } | 453 | } |
| 450 | 454 | ||
| 451 | -static drvError_t trs_local_res_alloc( | 455 | +static drvError_t trs_local_res_alloc(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 452 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out) | 456 | + struct halResourceIdOutputInfo *out) |
| 453 | { | 457 | { |
| 454 | static int trs_res_errcode[DRV_INVALID_ID] = { | 458 | static int trs_res_errcode[DRV_INVALID_ID] = { |
| 455 | [DRV_STREAM_ID] = DRV_ERROR_NO_STREAM_RESOURCES, [DRV_EVENT_ID] = DRV_ERROR_NO_EVENT_RESOURCES, | 459 | [DRV_STREAM_ID] = DRV_ERROR_NO_STREAM_RESOURCES, [DRV_EVENT_ID] = DRV_ERROR_NO_EVENT_RESOURCES, |
| @@ -647,8 +651,8 @@ drvError_t halResourceDisable(uint32_t devId, struct halResourceIdInputInfo *in) | |||
| 647 | return halResourceIdComm(devId, TRS_RES_ID_DISABLE, in); | 651 | return halResourceIdComm(devId, TRS_RES_ID_DISABLE, in); |
| 648 | } | 652 | } |
| 649 | 653 | ||
| 650 | -drvError_t trs_res_config_para_check( | 654 | +drvError_t trs_res_config_para_check(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 651 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para) | 655 | + struct halResourceConfigInfo *para) |
| 652 | { | 656 | { |
| 653 | if ((in == NULL) || (para == NULL)) { | 657 | if ((in == NULL) || (para == NULL)) { |
| 654 | trs_err("Null ptr.\n"); | 658 | trs_err("Null ptr.\n"); |
| @@ -785,8 +789,8 @@ drvError_t halResourceInfoQuery(uint32_t devId, uint32_t tsId, drvResourceType_t | |||
| 785 | return ret; | 789 | return ret; |
| 786 | } | 790 | } |
| 787 | 791 | ||
| 788 | -static int trs_get_res_id_by_stream( | 792 | +static int trs_get_res_id_by_stream(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 789 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceDetailInfo *info) | 793 | + struct halResourceDetailInfo *info) |
| 790 | { | 794 | { |
| 791 | struct halSqCqInputInfo input_info = {0}; | 795 | struct halSqCqInputInfo input_info = {0}; |
| 792 | int ret; | 796 | int ret; |
| @@ -860,9 +864,8 @@ drvError_t halResourceDetailQuery(uint32_t devId, struct halResourceIdInputInfo | |||
| 860 | return halNotifyGetInfo(devId, in->tsId, DRV_NOTIFY_TYPE_NUM, &(info->value0)); | 864 | return halNotifyGetInfo(devId, in->tsId, DRV_NOTIFY_TYPE_NUM, &(info->value0)); |
| 861 | } | 865 | } |
| 862 | default: | 866 | default: |
| 863 | - trs_err( | 867 | + trs_err("Invalid para. (devid=%u; tsid=%u; id_type=%d; query_type=%d)\n", devId, in->tsId, in->type, |
| 864 | - "Invalid para. (devid=%u; tsid=%u; id_type=%d; query_type=%d)\n", devId, in->tsId, in->type, | 868 | + info->type); |
| 865 | - info->type); | ||
| 866 | return DRV_ERROR_INVALID_VALUE; | 869 | return DRV_ERROR_INVALID_VALUE; |
| 867 | } | 870 | } |
| 868 | } | 871 | } |
| @@ -34,14 +34,14 @@ void trs_dev_res_id_uninit(uint32_t dev_id); | |||
| 34 | struct res_id_usr_info *trs_get_res_id_info(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t id); | 34 | struct res_id_usr_info *trs_get_res_id_info(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t id); |
| 35 | uint32_t trs_get_res_id_num(uint32_t dev_id, uint32_t ts_id, drvIdType_t type); | 35 | uint32_t trs_get_res_id_num(uint32_t dev_id, uint32_t ts_id, drvIdType_t type); |
| 36 | int trs_id_query(uint32_t dev_id, uint32_t cmd, struct trs_res_id_para *para, uint32_t *value); | 36 | int trs_id_query(uint32_t dev_id, uint32_t cmd, struct trs_res_id_para *para, uint32_t *value); |
| 37 | -int trs_res_id_info_init( | 37 | +int trs_res_id_info_init(uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, |
| 38 | - uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, struct res_id_info_val *id_info_val); | 38 | + struct res_id_info_val *id_info_val); |
| 39 | 39 | ||
| 40 | drvError_t _halResourceIdAlloc(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out); | 40 | drvError_t _halResourceIdAlloc(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out); |
| 41 | drvError_t _halResourceIdFree(uint32_t dev_id, struct halResourceIdInputInfo *in); | 41 | drvError_t _halResourceIdFree(uint32_t dev_id, struct halResourceIdInputInfo *in); |
| 42 | drvError_t _halResourceConfig(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); | 42 | drvError_t _halResourceConfig(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); |
| 43 | -drvError_t trs_res_config_para_check( | 43 | +drvError_t trs_res_config_para_check(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 44 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); | 44 | + struct halResourceConfigInfo *para); |
| 45 | drvError_t trs_local_res_config(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); | 45 | drvError_t trs_local_res_config(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); |
| 46 | 46 | ||
| 47 | struct trs_res_remote_ops { | 47 | struct trs_res_remote_ops { |
| @@ -49,13 +49,13 @@ struct trs_res_remote_ops { | |||
| 49 | drvError_t (*resid_free)(uint32_t dev_id, struct halResourceIdInputInfo *in); | 49 | drvError_t (*resid_free)(uint32_t dev_id, struct halResourceIdInputInfo *in); |
| 50 | drvError_t (*resid_config)(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); | 50 | drvError_t (*resid_config)(uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); |
| 51 | }; | 51 | }; |
| 52 | -drvError_t trs_remote_res_config( | 52 | +drvError_t trs_remote_res_config(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 53 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para); | 53 | + struct halResourceConfigInfo *para); |
| 54 | 54 | ||
| 55 | void trs_register_res_remote_ops(struct trs_res_remote_ops *ops); | 55 | void trs_register_res_remote_ops(struct trs_res_remote_ops *ops); |
| 56 | 56 | ||
| 57 | -int trs_res_map_reg_init( | 57 | +int trs_res_map_reg_init(uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, |
| 58 | - uint32_t dev_id, uint32_t ts_id, uint32_t res_id, drvIdType_t type, struct res_id_usr_info *id_info); | 58 | + struct res_id_usr_info *id_info); |
| 59 | -void trs_res_map_reg_un_init( | 59 | +void trs_res_map_reg_un_init(uint32_t dev_id, uint32_t tsid, uint32_t res_id, drvIdType_t type, |
| 60 | - uint32_t dev_id, uint32_t tsid, uint32_t res_id, drvIdType_t type, struct res_id_usr_info *id_info); | 60 | + struct res_id_usr_info *id_info); |
| 61 | 61 | ||
| @@ -80,27 +80,60 @@ static struct trs_dev_ctx dev_ctx[TRS_DEV_NUM]; | |||
| 80 | static struct trs_sqcq_ctx cqcq_ctxs[TRS_DEV_NUM][TRS_TS_NUM][DRV_INVALID_TYPE]; | 80 | static struct trs_sqcq_ctx cqcq_ctxs[TRS_DEV_NUM][TRS_TS_NUM][DRV_INVALID_TYPE]; |
| 81 | static struct trs_sq_bp_ctx g_bp_sq_info[TRS_DEV_NUM]; | 81 | static struct trs_sq_bp_ctx g_bp_sq_info[TRS_DEV_NUM]; |
| 82 | 82 | ||
| 83 | -void trs_dev_ctx_mutex_lock(uint32_t dev_id) { (void)pthread_mutex_lock(&dev_ctx[dev_id].dev_mutex); } | 83 | +void trs_dev_ctx_mutex_lock(uint32_t dev_id) |
| 84 | +{ | ||
| 85 | + (void)pthread_mutex_lock(&dev_ctx[dev_id].dev_mutex); | ||
| 86 | +} | ||
| 84 | 87 | ||
| 85 | -void trs_dev_ctx_mutex_un_lock(uint32_t dev_id) { (void)pthread_mutex_unlock(&dev_ctx[dev_id].dev_mutex); } | 88 | +void trs_dev_ctx_mutex_un_lock(uint32_t dev_id) |
| 89 | +{ | ||
| 90 | + (void)pthread_mutex_unlock(&dev_ctx[dev_id].dev_mutex); | ||
| 91 | +} | ||
| 86 | 92 | ||
| 87 | -void trs_dev_ctx_stream_mutex_lock(uint32_t dev_id) { (void)pthread_mutex_lock(&dev_ctx[dev_id].stream_mutex); } | 93 | +void trs_dev_ctx_stream_mutex_lock(uint32_t dev_id) |
| 94 | +{ | ||
| 95 | + (void)pthread_mutex_lock(&dev_ctx[dev_id].stream_mutex); | ||
| 96 | +} | ||
| 88 | 97 | ||
| 89 | -void trs_dev_ctx_stream_mutex_unlock(uint32_t dev_id) { (void)pthread_mutex_unlock(&dev_ctx[dev_id].stream_mutex); } | 98 | +void trs_dev_ctx_stream_mutex_unlock(uint32_t dev_id) |
| 99 | +{ | ||
| 100 | + (void)pthread_mutex_unlock(&dev_ctx[dev_id].stream_mutex); | ||
| 101 | +} | ||
| 90 | 102 | ||
| 91 | -void *trs_get_d2d_dev_ctx(uint32_t recv_dev_id) { return dev_ctx[recv_dev_id].d2d_dev_ctx; } | 103 | +void *trs_get_d2d_dev_ctx(uint32_t recv_dev_id) |
| 104 | +{ | ||
| 105 | + return dev_ctx[recv_dev_id].d2d_dev_ctx; | ||
| 106 | +} | ||
| 92 | 107 | ||
| 93 | -void trs_set_d2d_dev_ctx(uint32_t recv_dev_id, void *ctx) { dev_ctx[recv_dev_id].d2d_dev_ctx = ctx; } | 108 | +void trs_set_d2d_dev_ctx(uint32_t recv_dev_id, void *ctx) |
| 109 | +{ | ||
| 110 | + dev_ctx[recv_dev_id].d2d_dev_ctx = ctx; | ||
| 111 | +} | ||
| 94 | 112 | ||
| 95 | -void trs_set_dev_open_status(uint32_t dev_id, bool dev_open) { dev_ctx[dev_id].dev_open = dev_open; } | 113 | +void trs_set_dev_open_status(uint32_t dev_id, bool dev_open) |
| 114 | +{ | ||
| 115 | + dev_ctx[dev_id].dev_open = dev_open; | ||
| 116 | +} | ||
| 96 | 117 | ||
| 97 | -bool trs_is_dev_open(uint32_t dev_id) { return dev_ctx[dev_id].dev_open; } | 118 | +bool trs_is_dev_open(uint32_t dev_id) |
| 119 | +{ | ||
| 120 | + return dev_ctx[dev_id].dev_open; | ||
| 121 | +} | ||
| 98 | 122 | ||
| 99 | -int trs_get_connection_type(uint32_t dev_id) { return dev_ctx[dev_id].connection_type; } | 123 | +int trs_get_connection_type(uint32_t dev_id) |
| 124 | +{ | ||
| 125 | + return dev_ctx[dev_id].connection_type; | ||
| 126 | +} | ||
| 100 | 127 | ||
| 101 | -int trs_get_sq_send_mode(uint32_t dev_id) { return dev_ctx[dev_id].sq_send_mode; } | 128 | +int trs_get_sq_send_mode(uint32_t dev_id) |
| 129 | +{ | ||
| 130 | + return dev_ctx[dev_id].sq_send_mode; | ||
| 131 | +} | ||
| 102 | 132 | ||
| 103 | -uint32_t trs_get_ts_num(uint32_t dev_id) { return dev_ctx[dev_id].ts_num; } | 133 | +uint32_t trs_get_ts_num(uint32_t dev_id) |
| 134 | +{ | ||
| 135 | + return dev_ctx[dev_id].ts_num; | ||
| 136 | +} | ||
| 104 | 137 | ||
| 105 | static int trs_sq_type_trans[DRV_INVALID_TYPE] = { | 138 | static int trs_sq_type_trans[DRV_INVALID_TYPE] = { |
| 106 | [DRV_NORMAL_TYPE] = TRS_HW_SQ, [DRV_CALLBACK_TYPE] = TRS_CB_SQ, [DRV_LOGIC_TYPE] = TRS_MAX_ID_TYPE, | 139 | [DRV_NORMAL_TYPE] = TRS_HW_SQ, [DRV_CALLBACK_TYPE] = TRS_CB_SQ, [DRV_LOGIC_TYPE] = TRS_MAX_ID_TYPE, |
| @@ -111,14 +144,26 @@ static int trs_cq_type_trans[DRV_INVALID_TYPE] = { | |||
| 111 | [DRV_SHM_TYPE] = TRS_MAX_ID_TYPE, [DRV_CTRL_TYPE] = TRS_SW_CQ, [DRV_GDB_TYPE] = TRS_MAINT_CQ}; | 144 | [DRV_SHM_TYPE] = TRS_MAX_ID_TYPE, [DRV_CTRL_TYPE] = TRS_SW_CQ, [DRV_GDB_TYPE] = TRS_MAINT_CQ}; |
| 112 | 145 | ||
| 113 | struct trs_sqcq_remote_ops g_sqcq_remote_ops; | 146 | struct trs_sqcq_remote_ops g_sqcq_remote_ops; |
| 114 | -void trs_register_sqcq_remote_ops(struct trs_sqcq_remote_ops *ops) { g_sqcq_remote_ops = *ops; } | 147 | +void trs_register_sqcq_remote_ops(struct trs_sqcq_remote_ops *ops) |
| 148 | +{ | ||
| 149 | + g_sqcq_remote_ops = *ops; | ||
| 150 | +} | ||
| 115 | 151 | ||
| 116 | -static struct trs_sqcq_remote_ops *trs_get_sqcq_remote_ops(void) { return &g_sqcq_remote_ops; } | 152 | +static struct trs_sqcq_remote_ops *trs_get_sqcq_remote_ops(void) |
| 153 | +{ | ||
| 154 | + return &g_sqcq_remote_ops; | ||
| 155 | +} | ||
| 117 | 156 | ||
| 118 | static struct trs_sqcq_mem_ops g_sqcq_mem_ops = {NULL}; | 157 | static struct trs_sqcq_mem_ops g_sqcq_mem_ops = {NULL}; |
| 119 | -void trs_register_sqcq_mem_ops(struct trs_sqcq_mem_ops *ops) { g_sqcq_mem_ops = *ops; } | 158 | +void trs_register_sqcq_mem_ops(struct trs_sqcq_mem_ops *ops) |
| 159 | +{ | ||
| 160 | + g_sqcq_mem_ops = *ops; | ||
| 161 | +} | ||
| 120 | 162 | ||
| 121 | -static struct trs_sqcq_mem_ops *trs_get_sqcq_mem_ops(void) { return &g_sqcq_mem_ops; } | 163 | +static struct trs_sqcq_mem_ops *trs_get_sqcq_mem_ops(void) |
| 164 | +{ | ||
| 165 | + return &g_sqcq_mem_ops; | ||
| 166 | +} | ||
| 122 | 167 | ||
| 123 | void devdrv_flush_cache(uint64_t base, uint32_t len); | 168 | void devdrv_flush_cache(uint64_t base, uint32_t len); |
| 124 | 169 | ||
| @@ -130,10 +175,9 @@ static bool trs_is_stars_inst(uint32_t dev_id, uint32_t ts_id) | |||
| 130 | 175 | ||
| 131 | static bool trs_is_mmap_sq(struct halSqCqInputInfo *in) | 176 | static bool trs_is_mmap_sq(struct halSqCqInputInfo *in) |
| 132 | { | 177 | { |
| 133 | - return ( | 178 | + return (((in->type == DRV_NORMAL_TYPE) && ((in->flag & TSDRV_FLAG_REUSE_SQ) == 0) && |
| 134 | - ((in->type == DRV_NORMAL_TYPE) && ((in->flag & TSDRV_FLAG_REUSE_SQ) == 0) && | 179 | + ((in->flag & TSDRV_FLAG_ONLY_SQCQ_ID) == 0)) || |
| 135 | - ((in->flag & TSDRV_FLAG_ONLY_SQCQ_ID) == 0)) || | 180 | + (in->type == DRV_SHM_TYPE) || (in->type == DRV_CTRL_TYPE)); |
| 136 | - (in->type == DRV_SHM_TYPE) || (in->type == DRV_CTRL_TYPE)); | ||
| 137 | } | 181 | } |
| 138 | 182 | ||
| 139 | static uint32_t trs_get_sq_que_len(uint32_t sqe_depth, uint32_t sqe_size) | 183 | static uint32_t trs_get_sq_que_len(uint32_t sqe_depth, uint32_t sqe_size) |
| @@ -204,26 +248,26 @@ int trs_sq_mmap(uint32_t dev_id, struct halSqCqInputInfo *in, struct trs_sq_map | |||
| 204 | // set ctrl | 248 | // set ctrl |
| 205 | for (i = 0; i < TRS_UIO_ADDR_MAX; i++) { | 249 | for (i = 0; i < TRS_UIO_ADDR_MAX; i++) { |
| 206 | if (i < TRS_UIO_HEAD_REG) { | 250 | if (i < TRS_UIO_HEAD_REG) { |
| 207 | - sq_map->ctrl[i].addr = | 251 | + sq_map->ctrl[i].addr = (void *)((uintptr_t)sq_map->non_reg_addr.addr + que_mmap_len + |
| 208 | - (void *)((uintptr_t)sq_map->non_reg_addr.addr + que_mmap_len + (size_t)(i * page_size)); | 252 | + (size_t)(i * page_size)); |
| 209 | } else { | 253 | } else { |
| 210 | - sq_map->ctrl[i].addr = | 254 | + sq_map->ctrl[i].addr = (void *)((uintptr_t)sq_map->reg_addr.addr + |
| 211 | - (void *)((uintptr_t)sq_map->reg_addr.addr + (size_t)((i - TRS_UIO_HEAD_REG) * page_size)); | 255 | + (size_t)((i - TRS_UIO_HEAD_REG) * page_size)); |
| 212 | } | 256 | } |
| 213 | } | 257 | } |
| 214 | 258 | ||
| 215 | return 0; | 259 | return 0; |
| 216 | } | 260 | } |
| 217 | 261 | ||
| 218 | -static void trs_fill_sq_alloc_info( | 262 | +static void trs_fill_sq_alloc_info(struct halSqCqInputInfo *in, struct trs_uio_info *uio_info, |
| 219 | - struct halSqCqInputInfo *in, struct trs_uio_info *uio_info, struct trs_sq_map *sq_map, void *sq_que_va) | 263 | + struct trs_sq_map *sq_map, void *sq_que_va) |
| 220 | { | 264 | { |
| 221 | struct trs_alloc_para *para = get_alloc_para_addr(in); | 265 | struct trs_alloc_para *para = get_alloc_para_addr(in); |
| 222 | int i; | 266 | int i; |
| 223 | 267 | ||
| 224 | para->uio_info = uio_info; | 268 | para->uio_info = uio_info; |
| 225 | - uio_info->sq_que_addr = | 269 | + uio_info->sq_que_addr = ((sq_que_va != NULL) ? (unsigned long)(uintptr_t)sq_que_va : |
| 226 | - ((sq_que_va != NULL) ? (unsigned long)(uintptr_t)sq_que_va : (unsigned long)(uintptr_t)sq_map->que.addr); | 270 | + (unsigned long)(uintptr_t)sq_map->que.addr); |
| 227 | for (i = 0; i < TRS_UIO_ADDR_MAX; i++) { | 271 | for (i = 0; i < TRS_UIO_ADDR_MAX; i++) { |
| 228 | uio_info->sq_ctrl_addr[i] = (unsigned long)(uintptr_t)sq_map->ctrl[i].addr; | 272 | uio_info->sq_ctrl_addr[i] = (unsigned long)(uintptr_t)sq_map->ctrl[i].addr; |
| 229 | } | 273 | } |
| @@ -273,9 +317,8 @@ struct sqcq_usr_info *_trs_get_sq_info(uint32_t dev_id, uint32_t ts_id, drvSqCqT | |||
| 273 | struct trs_sqcq_ctx *sqcq_ctx = trs_get_sqcq_ctx(dev_id, ts_id, type); | 317 | struct trs_sqcq_ctx *sqcq_ctx = trs_get_sqcq_ctx(dev_id, ts_id, type); |
| 274 | 318 | ||
| 275 | if (id >= sqcq_ctx->sq_num) { | 319 | if (id >= sqcq_ctx->sq_num) { |
| 276 | - trs_err( | 320 | + trs_err("Invalid id. (dev_id=%u; ts_id=%u; type=%d; id=%u; sq_num=%u)\n", dev_id, ts_id, type, id, |
| 277 | - "Invalid id. (dev_id=%u; ts_id=%u; type=%d; id=%u; sq_num=%u)\n", dev_id, ts_id, type, id, | 321 | + sqcq_ctx->sq_num); |
| 278 | - sqcq_ctx->sq_num); | ||
| 279 | return NULL; | 322 | return NULL; |
| 280 | } | 323 | } |
| 281 | 324 | ||
| @@ -384,8 +427,8 @@ static void trs_sqcq_info_locks_destroy(struct sqcq_usr_info *info, uint32_t num | |||
| 384 | } | 427 | } |
| 385 | } | 428 | } |
| 386 | 429 | ||
| 387 | -static int trs_id_type_init( | 430 | +static int trs_id_type_init(uint32_t dev_id, uint32_t ts_id, int id_type, struct sqcq_usr_info **sqcq_info, |
| 388 | - uint32_t dev_id, uint32_t ts_id, int id_type, struct sqcq_usr_info **sqcq_info, uint32_t *sqcq_num) | 431 | + uint32_t *sqcq_num) |
| 389 | { | 432 | { |
| 390 | struct trs_res_id_para para = {.tsid = ts_id, .res_type = id_type}; | 433 | struct trs_res_id_para para = {.tsid = ts_id, .res_type = id_type}; |
| 391 | struct sqcq_usr_info *info = NULL; | 434 | struct sqcq_usr_info *info = NULL; |
| @@ -427,8 +470,8 @@ static int trs_id_type_init( | |||
| 427 | ret = trs_sqcq_info_locks_init(info, num); | 470 | ret = trs_sqcq_info_locks_init(info, num); |
| 428 | if (ret != DRV_ERROR_NONE) { | 471 | if (ret != DRV_ERROR_NONE) { |
| 429 | free(info); | 472 | free(info); |
| 430 | - trs_err( | 473 | + trs_err("Mutex init failed. (dev_id=%u; ts_id=%u; id_type=%d; num=%u; ret=%d)\n", dev_id, ts_id, id_type, num, |
| 431 | - "Mutex init failed. (dev_id=%u; ts_id=%u; id_type=%d; num=%u; ret=%d)\n", dev_id, ts_id, id_type, num, ret); | 474 | + ret); |
| 432 | return ret; | 475 | return ret; |
| 433 | } | 476 | } |
| 434 | 477 | ||
| @@ -487,8 +530,8 @@ error: | |||
| 487 | return ret; | 530 | return ret; |
| 488 | } | 531 | } |
| 489 | 532 | ||
| 490 | -int __attribute__((weak)) trs_recycle_sq_cq_with_urma( | 533 | +int __attribute__((weak)) trs_recycle_sq_cq_with_urma(uint32_t dev_id, uint32_t ts_id, uint32_t sq_id, uint32_t cq_id, |
| 491 | - uint32_t dev_id, uint32_t ts_id, uint32_t sq_id, uint32_t cq_id, bool remote_free_flag) | 534 | + bool remote_free_flag) |
| 492 | { | 535 | { |
| 493 | (void)dev_id; | 536 | (void)dev_id; |
| 494 | (void)ts_id; | 537 | (void)ts_id; |
| @@ -550,9 +593,15 @@ void trs_dev_sq_cq_uninit(uint32_t dev_id, uint32_t close_type) | |||
| 550 | } | 593 | } |
| 551 | } | 594 | } |
| 552 | 595 | ||
| 553 | -static bool trs_is_sq_surport_uio(struct sqcq_usr_info *info) { return (info->sq_ctrl.que_addr != NULL); } | 596 | +static bool trs_is_sq_surport_uio(struct sqcq_usr_info *info) |
| 597 | +{ | ||
| 598 | + return (info->sq_ctrl.que_addr != NULL); | ||
| 599 | +} | ||
| 554 | 600 | ||
| 555 | -static UINT64 trs_get_sq_que_addr(struct sqcq_usr_info *info) { return (uintptr_t)info->sq_ctrl.que_addr; } | 601 | +static UINT64 trs_get_sq_que_addr(struct sqcq_usr_info *info) |
| 602 | +{ | ||
| 603 | + return (uintptr_t)info->sq_ctrl.que_addr; | ||
| 604 | +} | ||
| 556 | 605 | ||
| 557 | static UINT64 trs_get_sq_bind_que_addr(uint32_t dev_id, uint32_t ts_id, struct sqcq_usr_info *sq_info) | 606 | static UINT64 trs_get_sq_bind_que_addr(uint32_t dev_id, uint32_t ts_id, struct sqcq_usr_info *sq_info) |
| 558 | { | 607 | { |
| @@ -570,11 +619,20 @@ static UINT64 trs_get_sq_bind_que_addr(uint32_t dev_id, uint32_t ts_id, struct s | |||
| 570 | return (uintptr_t)NULL; | 619 | return (uintptr_t)NULL; |
| 571 | } | 620 | } |
| 572 | 621 | ||
| 573 | -static uint32_t trs_get_sq_mem_attr(struct sqcq_usr_info *info) { return info->sq_ctrl.mem_local_flag; } | 622 | +static uint32_t trs_get_sq_mem_attr(struct sqcq_usr_info *info) |
| 623 | +{ | ||
| 624 | + return info->sq_ctrl.mem_local_flag; | ||
| 625 | +} | ||
| 574 | 626 | ||
| 575 | -static bool trs_is_cq_support_recv(struct sqcq_usr_info *info) { return ((info->flag & TSDRV_FLAG_ONLY_SQCQ_ID) == 0); } | 627 | +static bool trs_is_cq_support_recv(struct sqcq_usr_info *info) |
| 628 | +{ | ||
| 629 | + return ((info->flag & TSDRV_FLAG_ONLY_SQCQ_ID) == 0); | ||
| 630 | +} | ||
| 576 | 631 | ||
| 577 | -static inline uint32_t trs_get_sq_head(struct sqcq_usr_info *sq_info) { return *((UINT16 *)sq_info->sq_ctrl.head); } | 632 | +static inline uint32_t trs_get_sq_head(struct sqcq_usr_info *sq_info) |
| 633 | +{ | ||
| 634 | + return *((UINT16 *)sq_info->sq_ctrl.head); | ||
| 635 | +} | ||
| 578 | 636 | ||
| 579 | static inline void trs_set_sq_head(struct sqcq_usr_info *sq_info, uint32_t head) | 637 | static inline void trs_set_sq_head(struct sqcq_usr_info *sq_info, uint32_t head) |
| 580 | { | 638 | { |
| @@ -593,7 +651,10 @@ static inline void trs_set_sq_tail(struct sqcq_usr_info *sq_info, uint32_t tail) | |||
| 593 | *((UINT16 *)sq_info->sq_ctrl.tail) = (UINT16)tail; | 651 | *((UINT16 *)sq_info->sq_ctrl.tail) = (UINT16)tail; |
| 594 | } | 652 | } |
| 595 | 653 | ||
| 596 | -static inline uint32_t trs_get_sqtail(struct sqcq_usr_info *sq_info) { return *((UINT16 *)sq_info->sq_ctrl.tail); } | 654 | +static inline uint32_t trs_get_sqtail(struct sqcq_usr_info *sq_info) |
| 655 | +{ | ||
| 656 | + return *((UINT16 *)sq_info->sq_ctrl.tail); | ||
| 657 | +} | ||
| 597 | 658 | ||
| 598 | static inline uint32_t trs_get_sq_tail_reg(struct sqcq_usr_info *sq_info) | 659 | static inline uint32_t trs_get_sq_tail_reg(struct sqcq_usr_info *sq_info) |
| 599 | { | 660 | { |
| @@ -606,7 +667,10 @@ static inline void trs_set_sq_db(struct sqcq_usr_info *sq_info, uint32_t value) | |||
| 606 | *((uint32_t *)sq_info->sq_ctrl.db) = value; | 667 | *((uint32_t *)sq_info->sq_ctrl.db) = value; |
| 607 | } | 668 | } |
| 608 | 669 | ||
| 609 | -static inline uint32_t trs_get_sq_db(struct sqcq_usr_info *sq_info) { return *((UINT16 *)sq_info->sq_ctrl.db); } | 670 | +static inline uint32_t trs_get_sq_db(struct sqcq_usr_info *sq_info) |
| 671 | +{ | ||
| 672 | + return *((UINT16 *)sq_info->sq_ctrl.db); | ||
| 673 | +} | ||
| 610 | 674 | ||
| 611 | static inline bool trs_is_sq_use_soft_que(struct sqcq_usr_info *sq_info) | 675 | static inline bool trs_is_sq_use_soft_que(struct sqcq_usr_info *sq_info) |
| 612 | { | 676 | { |
| @@ -649,8 +713,8 @@ static inline bool trs_is_support_sq_mem_ops(uint32_t dev_id, struct halSqCqInpu | |||
| 649 | return false; | 713 | return false; |
| 650 | } | 714 | } |
| 651 | 715 | ||
| 652 | -static void trs_sq_usr_info_init( | 716 | +static void trs_sq_usr_info_init(uint32_t dev_id, struct sqcq_usr_info *info, struct halSqCqInputInfo *in, |
| 653 | - uint32_t dev_id, struct sqcq_usr_info *info, struct halSqCqInputInfo *in, struct trs_sq_map *sq_map) | 717 | + struct trs_sq_map *sq_map) |
| 654 | { | 718 | { |
| 655 | (void)dev_id; | 719 | (void)dev_id; |
| 656 | struct trs_alloc_para *para = get_alloc_para_addr(in); | 720 | struct trs_alloc_para *para = get_alloc_para_addr(in); |
| @@ -708,8 +772,8 @@ static void trs_sq_usr_info_init( | |||
| 708 | static void trs_sq_usr_info_un_init(uint32_t dev_id, struct sqcq_usr_info *info) | 772 | static void trs_sq_usr_info_un_init(uint32_t dev_id, struct sqcq_usr_info *info) |
| 709 | { | 773 | { |
| 710 | if ((info->sq_que_spec_addr != NULL) && (trs_get_sqcq_mem_ops()->mem_free != NULL)) { | 774 | if ((info->sq_que_spec_addr != NULL) && (trs_get_sqcq_mem_ops()->mem_free != NULL)) { |
| 711 | - trs_get_sqcq_mem_ops()->mem_free( | 775 | + trs_get_sqcq_mem_ops()->mem_free(dev_id, (uint64_t)info->sq_que_spec_addr, |
| 712 | - dev_id, (uint64_t)info->sq_que_spec_addr, trs_get_sq_que_len(info->depth, info->e_size)); | 776 | + trs_get_sq_que_len(info->depth, info->e_size)); |
| 713 | info->sq_que_spec_addr = NULL; | 777 | info->sq_que_spec_addr = NULL; |
| 714 | } | 778 | } |
| 715 | 779 | ||
| @@ -872,8 +936,8 @@ static struct sqcq_usr_info *trs_get_sq_bp_ctx(uint32_t dev_id, uint32_t sq_id) | |||
| 872 | 936 | ||
| 873 | static bool trs_is_alloc_sq(drvSqCqType_t type) | 937 | static bool trs_is_alloc_sq(drvSqCqType_t type) |
| 874 | { | 938 | { |
| 875 | - return ( | 939 | + return ((type == DRV_NORMAL_TYPE) || (type == DRV_CALLBACK_TYPE) || (type == DRV_SHM_TYPE) || |
| 876 | - (type == DRV_NORMAL_TYPE) || (type == DRV_CALLBACK_TYPE) || (type == DRV_SHM_TYPE) || (type == DRV_CTRL_TYPE)); | 940 | + (type == DRV_CTRL_TYPE)); |
| 877 | } | 941 | } |
| 878 | 942 | ||
| 879 | bool trs_is_remote_sqcq_ops(drvSqCqType_t type, uint32_t flag) | 943 | bool trs_is_remote_sqcq_ops(drvSqCqType_t type, uint32_t flag) |
| @@ -895,9 +959,8 @@ drvError_t trs_sqcq_alloc_para_check(uint32_t dev_id, struct halSqCqInputInfo *i | |||
| 895 | 959 | ||
| 896 | if ((trs_is_alloc_sq(in->type) && (in->sqeSize > TRS_SQCQ_BUFF_LEN)) || (in->cqeSize > TRS_SQCQ_BUFF_LEN) || | 960 | if ((trs_is_alloc_sq(in->type) && (in->sqeSize > TRS_SQCQ_BUFF_LEN)) || (in->cqeSize > TRS_SQCQ_BUFF_LEN) || |
| 897 | (in->type >= DRV_INVALID_TYPE)) { | 961 | (in->type >= DRV_INVALID_TYPE)) { |
| 898 | - trs_err( | 962 | + trs_err("Invalid para. (dev_id=%u; type=%u; sqe_depth=%u; sqe_size=%u; cqe_depth=%u; cqe_size=%u)\n", dev_id, |
| 899 | - "Invalid para. (dev_id=%u; type=%u; sqe_depth=%u; sqe_size=%u; cqe_depth=%u; cqe_size=%u)\n", dev_id, | 963 | + in->type, in->sqeDepth, in->sqeSize, in->cqeDepth, in->cqeSize); |
| 900 | - in->type, in->sqeDepth, in->sqeSize, in->cqeDepth, in->cqeSize); | ||
| 901 | return DRV_ERROR_INVALID_VALUE; | 964 | return DRV_ERROR_INVALID_VALUE; |
| 902 | } | 965 | } |
| 903 | return DRV_ERROR_NONE; | 966 | return DRV_ERROR_NONE; |
| @@ -929,14 +992,13 @@ drvError_t trs_local_sqcq_alloc(uint32_t dev_id, struct halSqCqInputInfo *in, st | |||
| 929 | struct sqcq_usr_info *sq_info = trs_get_sq_bp_ctx(dev_id, in->sqId); | 992 | struct sqcq_usr_info *sq_info = trs_get_sq_bp_ctx(dev_id, in->sqId); |
| 930 | if ((sq_info != NULL) && (sq_info->valid == 1)) { | 993 | if ((sq_info != NULL) && (sq_info->valid == 1)) { |
| 931 | sq_que_va = sq_info->sq_ctrl.que_addr; | 994 | sq_que_va = sq_info->sq_ctrl.que_addr; |
| 932 | - trs_debug( | 995 | + trs_debug("Use svm restored memory. (dev_id=%u; sq_id=%u; sq_que_va=0x%llx)\n", dev_id, in->sqId, |
| 933 | - "Use svm restored memory. (dev_id=%u; sq_id=%u; sq_que_va=0x%llx)\n", dev_id, in->sqId, | 996 | + (unsigned long long)(uintptr_t)sq_que_va); |
| 934 | - (unsigned long long)(uintptr_t)sq_que_va); | ||
| 935 | } | 997 | } |
| 936 | } | 998 | } |
| 937 | if (sq_que_va == NULL) { | 999 | if (sq_que_va == NULL) { |
| 938 | - ret = trs_get_sqcq_mem_ops()->mem_alloc( | 1000 | + ret = trs_get_sqcq_mem_ops()->mem_alloc(dev_id, (uint64_t *)&sq_que_va, |
| 939 | - dev_id, (uint64_t *)&sq_que_va, trs_get_sq_que_len(in->sqeDepth, in->sqeSize)); | 1001 | + trs_get_sq_que_len(in->sqeDepth, in->sqeSize)); |
| 940 | if (ret != DRV_ERROR_NONE) { | 1002 | if (ret != DRV_ERROR_NONE) { |
| 941 | return ret; | 1003 | return ret; |
| 942 | } | 1004 | } |
| @@ -1115,9 +1177,8 @@ static drvError_t trs_sq_cq_config_uio(uint32_t dev_id, struct halSqCqConfigInfo | |||
| 1115 | (void)pthread_rwlock_rdlock(&sq_info->mutex); | 1177 | (void)pthread_rwlock_rdlock(&sq_info->mutex); |
| 1116 | if ((!sq_info->valid) || (!sq_info->status)) { | 1178 | if ((!sq_info->valid) || (!sq_info->status)) { |
| 1117 | (void)pthread_rwlock_unlock(&sq_info->mutex); | 1179 | (void)pthread_rwlock_unlock(&sq_info->mutex); |
| 1118 | - trs_err( | 1180 | + trs_err("Invalid status. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; status=%u; prop=%d)\n", dev_id, info->tsId, |
| 1119 | - "Invalid status. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; status=%u; prop=%d)\n", dev_id, info->tsId, | 1181 | + info->type, info->sqId, sq_info->status, info->prop); |
| 1120 | - info->type, info->sqId, sq_info->status, info->prop); | ||
| 1121 | return DRV_ERROR_STATUS_FAIL; | 1182 | return DRV_ERROR_STATUS_FAIL; |
| 1122 | } | 1183 | } |
| 1123 | 1184 | ||
| @@ -1149,18 +1210,16 @@ static drvError_t trs_sq_info_reset(uint32_t dev_id, struct halSqCqConfigInfo *i | |||
| 1149 | 1210 | ||
| 1150 | (void)pthread_rwlock_rdlock(&sq_info->mutex); | 1211 | (void)pthread_rwlock_rdlock(&sq_info->mutex); |
| 1151 | if (sq_info->status == 1) { | 1212 | if (sq_info->status == 1) { |
| 1152 | - trs_warn( | 1213 | + trs_warn("Invalid status. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; status=%u)\n", dev_id, info->tsId, |
| 1153 | - "Invalid status. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; status=%u)\n", dev_id, info->tsId, info->type, | 1214 | + info->type, info->sqId, sq_info->status); |
| 1154 | - info->sqId, sq_info->status); | ||
| 1155 | /* unlock and return DRV_ERROR_STATUS_FAIL after runtime done */ | 1215 | /* unlock and return DRV_ERROR_STATUS_FAIL after runtime done */ |
| 1156 | } | 1216 | } |
| 1157 | sq_info->head = 0; | 1217 | sq_info->head = 0; |
| 1158 | sq_info->tail = 0; | 1218 | sq_info->tail = 0; |
| 1159 | sq_info->pos = 0; | 1219 | sq_info->pos = 0; |
| 1160 | (void)pthread_rwlock_unlock(&sq_info->mutex); | 1220 | (void)pthread_rwlock_unlock(&sq_info->mutex); |
| 1161 | - trs_debug( | 1221 | + trs_debug("Reset success. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; cq_id=%u)\n", dev_id, info->tsId, info->type, |
| 1162 | - "Reset success. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u; cq_id=%u)\n", dev_id, info->tsId, info->type, | 1222 | + info->sqId, info->cqId); |
| 1163 | - info->sqId, info->cqId); | ||
| 1164 | 1223 | ||
| 1165 | return DRV_ERROR_NONE; | 1224 | return DRV_ERROR_NONE; |
| 1166 | } | 1225 | } |
| @@ -1205,9 +1264,8 @@ static drvError_t trs_sq_ctrl(uint32_t dev_id, struct halSqCqConfigInfo *info) | |||
| 1205 | } | 1264 | } |
| 1206 | ret = trs_single_sq_ctrl(dev_id, info->tsId, info->sqId, info->prop); | 1265 | ret = trs_single_sq_ctrl(dev_id, info->tsId, info->sqId, info->prop); |
| 1207 | if (ret != DRV_ERROR_NONE) { | 1266 | if (ret != DRV_ERROR_NONE) { |
| 1208 | - trs_err( | 1267 | + trs_err("Pause failed. (dev_id=%u; ts_id=%u; sq_id=%u; prop=%d; ret=%d)\n", dev_id, info->tsId, info->sqId, |
| 1209 | - "Pause failed. (dev_id=%u; ts_id=%u; sq_id=%u; prop=%d; ret=%d)\n", dev_id, info->tsId, info->sqId, | 1268 | + info->prop, ret); |
| 1210 | - info->prop, ret); | ||
| 1211 | } | 1269 | } |
| 1212 | return ret; | 1270 | return ret; |
| 1213 | } | 1271 | } |
| @@ -1231,9 +1289,8 @@ static drvError_t trs_sq_cq_config_para_check(uint32_t dev_id, struct halSqCqCon | |||
| 1231 | } | 1289 | } |
| 1232 | if (((sq_info->flag & TSDRV_FLAG_REMOTE_ID) == 0) && | 1290 | if (((sq_info->flag & TSDRV_FLAG_REMOTE_ID) == 0) && |
| 1233 | ((info->value[SQCQ_CONFIG_INFO_FLAG] & TSDRV_FLAG_REMOTE_ID) != 0)) { | 1291 | ((info->value[SQCQ_CONFIG_INFO_FLAG] & TSDRV_FLAG_REMOTE_ID) != 0)) { |
| 1234 | - trs_err( | 1292 | + trs_err("Local sqcq but config remote flag. (dev_id=%u; sq_id=%u; sq_flag=0x%x; config_flag=0x%x)\n", |
| 1235 | - "Local sqcq but config remote flag. (dev_id=%u; sq_id=%u; sq_flag=0x%x; config_flag=0x%x)\n", dev_id, | 1293 | + dev_id, info->sqId, sq_info->flag, info->value[SQCQ_CONFIG_INFO_FLAG]); |
| 1236 | - info->sqId, sq_info->flag, info->value[SQCQ_CONFIG_INFO_FLAG]); | ||
| 1237 | return DRV_ERROR_INVALID_VALUE; | 1294 | return DRV_ERROR_INVALID_VALUE; |
| 1238 | } | 1295 | } |
| 1239 | } | 1296 | } |
| @@ -1262,9 +1319,8 @@ drvError_t trs_sq_cq_config(uint32_t dev_id, struct halSqCqConfigInfo *info) | |||
| 1262 | if ((info->type == DRV_NORMAL_TYPE) && (info->prop == DRV_SQCQ_PROP_SQCQ_RESET)) { | 1319 | if ((info->type == DRV_NORMAL_TYPE) && (info->prop == DRV_SQCQ_PROP_SQCQ_RESET)) { |
| 1263 | ret = trs_sq_info_reset(dev_id, info); | 1320 | ret = trs_sq_info_reset(dev_id, info); |
| 1264 | if (ret != DRV_ERROR_NONE) { | 1321 | if (ret != DRV_ERROR_NONE) { |
| 1265 | - trs_err( | 1322 | + trs_err("Sq_info reset failed. (ret=%d; dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", ret, dev_id, info->tsId, |
| 1266 | - "Sq_info reset failed. (ret=%d; dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", ret, dev_id, info->tsId, | 1323 | + info->type, info->sqId); |
| 1267 | - info->type, info->sqId); | ||
| 1268 | return ret; | 1324 | return ret; |
| 1269 | } | 1325 | } |
| 1270 | } | 1326 | } |
| @@ -1347,8 +1403,8 @@ drvError_t trs_sq_cq_query_uio(uint32_t dev_id, struct halSqCqQueryInfo *info) | |||
| 1347 | (void)pthread_rwlock_rdlock(&sq_info->mutex); | 1403 | (void)pthread_rwlock_rdlock(&sq_info->mutex); |
| 1348 | if (!sq_info->valid) { | 1404 | if (!sq_info->valid) { |
| 1349 | (void)pthread_rwlock_unlock(&sq_info->mutex); | 1405 | (void)pthread_rwlock_unlock(&sq_info->mutex); |
| 1350 | - trs_err( | 1406 | + trs_err("Invalid sq_info. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, info->tsId, info->type, |
| 1351 | - "Invalid sq_info. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, info->tsId, info->type, info->sqId); | 1407 | + info->sqId); |
| 1352 | return DRV_ERROR_INVALID_VALUE; | 1408 | return DRV_ERROR_INVALID_VALUE; |
| 1353 | } | 1409 | } |
| 1354 | 1410 | ||
| @@ -1386,8 +1442,8 @@ static drvError_t trs_cq_info_query(uint32_t dev_id, struct halSqCqQueryInfo *in | |||
| 1386 | 1442 | ||
| 1387 | if (cq_info->valid == 0) { | 1443 | if (cq_info->valid == 0) { |
| 1388 | 1444 | ||
| 1389 | - trs_err( | 1445 | + trs_err("Invalid cq_info. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u)\n", dev_id, info->tsId, info->type, |
| 1390 | - "Invalid cq_info. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u)\n", dev_id, info->tsId, info->type, info->cqId); | 1446 | + info->cqId); |
| 1391 | return DRV_ERROR_INVALID_VALUE; | 1447 | return DRV_ERROR_INVALID_VALUE; |
| 1392 | 1448 | ||
| 1393 | } | 1449 | } |
| @@ -1519,9 +1575,8 @@ static drvError_t trs_sq_credit_check(uint32_t dev_id, struct halTaskSendInfo *i | |||
| 1519 | } | 1575 | } |
| 1520 | 1576 | ||
| 1521 | if (credit < info->sqe_num) { | 1577 | if (credit < info->sqe_num) { |
| 1522 | - trs_run_info_limit( | 1578 | + trs_run_info_limit("No idle credit. (credit=%u; sqe_num=%u; devid=%u; sq_id=%u; head=%u; tail=%u; depth=%u)\n", |
| 1523 | - "No idle credit. (credit=%u; sqe_num=%u; devid=%u; sq_id=%u; head=%u; tail=%u; depth=%u)\n", credit, | 1579 | + credit, info->sqe_num, dev_id, info->sqId, sq_info->head, sq_info->tail, sq_info->depth); |
| 1524 | - info->sqe_num, dev_id, info->sqId, sq_info->head, sq_info->tail, sq_info->depth); | ||
| 1525 | trs_sq_send_full_inc(sq_info); | 1580 | trs_sq_send_full_inc(sq_info); |
| 1526 | return DRV_ERROR_NO_RESOURCES; | 1581 | return DRV_ERROR_NO_RESOURCES; |
| 1527 | } | 1582 | } |
| @@ -1539,12 +1594,11 @@ drvError_t trs_sq_task_send_check(uint32_t dev_id, struct halTaskSendInfo *info, | |||
| 1539 | return DRV_ERROR_INVALID_VALUE; | 1594 | return DRV_ERROR_INVALID_VALUE; |
| 1540 | } | 1595 | } |
| 1541 | 1596 | ||
| 1542 | - user_ctrl_sq_tail = | 1597 | + user_ctrl_sq_tail = (uint32_t)(((uintptr_t)info->sqe_addr - (uintptr_t)sq_info->sq_ctrl.que_addr) / |
| 1543 | - (uint32_t)(((uintptr_t)info->sqe_addr - (uintptr_t)sq_info->sq_ctrl.que_addr) / sq_info->e_size); | 1598 | + sq_info->e_size); |
| 1544 | if (user_ctrl_sq_tail != sq_info->tail) { | 1599 | if (user_ctrl_sq_tail != sq_info->tail) { |
| 1545 | - trs_err( | 1600 | + trs_err("Sqe addr not at sq tail. (dev_id=%u; ts_id=%u; sq_id=%u; user_ctrl_tail=%u; tail=%u)\n", dev_id, |
| 1546 | - "Sqe addr not at sq tail. (dev_id=%u; ts_id=%u; sq_id=%u; user_ctrl_tail=%u; tail=%u)\n", dev_id, | 1601 | + info->tsId, info->sqId, user_ctrl_sq_tail, sq_info->tail); |
| 1547 | - info->tsId, info->sqId, user_ctrl_sq_tail, sq_info->tail); | ||
| 1548 | return DRV_ERROR_INVALID_VALUE; | 1602 | return DRV_ERROR_INVALID_VALUE; |
| 1549 | } | 1603 | } |
| 1550 | } | 1604 | } |
| @@ -1695,8 +1749,8 @@ drvError_t trs_sq_switch_stream_batch(uint32_t dev_id, struct sq_switch_stream_i | |||
| 1695 | return DRV_ERROR_NONE; | 1749 | return DRV_ERROR_NONE; |
| 1696 | } | 1750 | } |
| 1697 | 1751 | ||
| 1698 | -drvError_t trs_stream_task_fill( | 1752 | +drvError_t trs_stream_task_fill(uint32_t dev_id, uint32_t stream_id, void *stream_mem, void *task_info, |
| 1699 | - uint32_t dev_id, uint32_t stream_id, void *stream_mem, void *task_info, uint32_t task_cnt) | 1753 | + uint32_t task_cnt) |
| 1700 | { | 1754 | { |
| 1701 | drvError_t ret = 0; | 1755 | drvError_t ret = 0; |
| 1702 | 1756 | ||
| @@ -1705,23 +1759,21 @@ drvError_t trs_stream_task_fill( | |||
| 1705 | 1759 | ||
| 1706 | stream_usr_info = trs_get_res_id_info(dev_id, 0, DRV_STREAM_ID, stream_id); | 1760 | stream_usr_info = trs_get_res_id_info(dev_id, 0, DRV_STREAM_ID, stream_id); |
| 1707 | if ((stream_usr_info == NULL) || (stream_usr_info->valid == 0)) { | 1761 | if ((stream_usr_info == NULL) || (stream_usr_info->valid == 0)) { |
| 1708 | - trs_err( | 1762 | + trs_err("Not init or null addr. (devid=%u; id=%u; addr_is_null=%d)\n", dev_id, stream_id, |
| 1709 | - "Not init or null addr. (devid=%u; id=%u; addr_is_null=%d)\n", dev_id, stream_id, | 1763 | + (stream_usr_info == NULL) ? 1 : 0); |
| 1710 | - (stream_usr_info == NULL) ? 1 : 0); | ||
| 1711 | return DRV_ERROR_INVALID_VALUE; | 1764 | return DRV_ERROR_INVALID_VALUE; |
| 1712 | } | 1765 | } |
| 1713 | 1766 | ||
| 1714 | if (((uintptr_t)stream_mem < stream_usr_info->res_addr) || | 1767 | if (((uintptr_t)stream_mem < stream_usr_info->res_addr) || |
| 1715 | ((uintptr_t)stream_mem + task_cnt * TRS_HW_SQE_SIZE) > | 1768 | ((uintptr_t)stream_mem + task_cnt * TRS_HW_SQE_SIZE) > |
| 1716 | (stream_usr_info->res_addr + stream_usr_info->res_len)) { | 1769 | (stream_usr_info->res_addr + stream_usr_info->res_len)) { |
| 1717 | - trs_err( | 1770 | + trs_err("Fill task exceed stream queue. (devid=%u; streamid=%u; queue_len=0x%x; addr=%p; task_cnt=%u)\n", |
| 1718 | - "Fill task exceed stream queue. (devid=%u; streamid=%u; queue_len=0x%x; addr=%p; task_cnt=%u)\n", | 1771 | + dev_id, stream_id, stream_usr_info->res_len, stream_mem, task_cnt); |
| 1719 | - dev_id, stream_id, stream_usr_info->res_len, stream_mem, task_cnt); | ||
| 1720 | return DRV_ERROR_NO_RESOURCES; | 1772 | return DRV_ERROR_NO_RESOURCES; |
| 1721 | } | 1773 | } |
| 1722 | 1774 | ||
| 1723 | - ret = drvMemcpy( | 1775 | + ret = drvMemcpy((uintptr_t)stream_mem, task_cnt * TRS_HW_SQE_SIZE, (uintptr_t)task_info, |
| 1724 | - (uintptr_t)stream_mem, task_cnt * TRS_HW_SQE_SIZE, (uintptr_t)task_info, task_cnt * TRS_HW_SQE_SIZE); | 1776 | + task_cnt * TRS_HW_SQE_SIZE); |
| 1725 | if (ret != DRV_ERROR_NONE) { | 1777 | if (ret != DRV_ERROR_NONE) { |
| 1726 | trs_err("Memcpy failed. (ret=%d).\n", ret); | 1778 | trs_err("Memcpy failed. (ret=%d).\n", ret); |
| 1727 | return DRV_ERROR_INNER_ERR; | 1779 | return DRV_ERROR_INNER_ERR; |
| @@ -1753,15 +1805,14 @@ drvError_t trs_cq_report_recv(uint32_t dev_id, struct halReportRecvInfo *info) | |||
| 1753 | } else { | 1805 | } else { |
| 1754 | cq_info = trs_get_cq_info(dev_id, info->tsId, info->type, info->cqId); | 1806 | cq_info = trs_get_cq_info(dev_id, info->tsId, info->type, info->cqId); |
| 1755 | if (cq_info == NULL) { | 1807 | if (cq_info == NULL) { |
| 1756 | - trs_err( | 1808 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u)\n", dev_id, info->tsId, info->type, |
| 1757 | - "Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u)\n", dev_id, info->tsId, info->type, info->cqId); | 1809 | + info->cqId); |
| 1758 | return DRV_ERROR_INVALID_VALUE; | 1810 | return DRV_ERROR_INVALID_VALUE; |
| 1759 | } | 1811 | } |
| 1760 | 1812 | ||
| 1761 | if (!trs_is_cq_support_recv(cq_info)) { | 1813 | if (!trs_is_cq_support_recv(cq_info)) { |
| 1762 | - trs_warn( | 1814 | + trs_warn("Cq is only id type, not support recv. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", dev_id, |
| 1763 | - "Cq is only id type, not support recv. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", dev_id, info->tsId, | 1815 | + info->tsId, info->cqId, cq_info->flag); |
| 1764 | - info->cqId, cq_info->flag); | ||
| 1765 | return DRV_ERROR_NOT_SUPPORT; | 1816 | return DRV_ERROR_NOT_SUPPORT; |
| 1766 | } | 1817 | } |
| 1767 | 1818 | ||
| @@ -1809,9 +1860,8 @@ drvError_t halSqMemGet(uint32_t devId, struct halSqMemGetInput *in, struct halSq | |||
| 1809 | } | 1860 | } |
| 1810 | 1861 | ||
| 1811 | if (!trs_is_sq_support_send(sq_info)) { | 1862 | if (!trs_is_sq_support_send(sq_info)) { |
| 1812 | - trs_warn( | 1863 | + trs_warn("Sq is only id type, not support mem get. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, in->tsId, |
| 1813 | - "Sq is only id type, not support mem get. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, in->tsId, | 1864 | + in->sqId, sq_info->flag); |
| 1814 | - in->sqId, sq_info->flag); | ||
| 1815 | return DRV_ERROR_NOT_SUPPORT; | 1865 | return DRV_ERROR_NOT_SUPPORT; |
| 1816 | } | 1866 | } |
| 1817 | 1867 | ||
| @@ -1860,16 +1910,14 @@ drvError_t halSqMsgSend(uint32_t devId, struct halSqMsgInfo *info) | |||
| 1860 | } | 1910 | } |
| 1861 | 1911 | ||
| 1862 | if ((!trs_is_sq_support_send(sq_info)) || (trs_is_sq_init_without_sq_mem(sq_info->flag))) { | 1912 | if ((!trs_is_sq_support_send(sq_info)) || (trs_is_sq_init_without_sq_mem(sq_info->flag))) { |
| 1863 | - trs_warn( | 1913 | + trs_warn("Sq is only id type, not support send. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, info->tsId, |
| 1864 | - "Sq is only id type, not support send. (dev_id=%u; ts_id=%u; sq_id=%u; flag=%u)\n", devId, info->tsId, | 1914 | + info->sqId, sq_info->flag); |
| 1865 | - info->sqId, sq_info->flag); | ||
| 1866 | return DRV_ERROR_NOT_SUPPORT; | 1915 | return DRV_ERROR_NOT_SUPPORT; |
| 1867 | } | 1916 | } |
| 1868 | 1917 | ||
| 1869 | if (info->cmdCount != sq_info->cur_num) { | 1918 | if (info->cmdCount != sq_info->cur_num) { |
| 1870 | - trs_err( | 1919 | + trs_err("Invalid para. (dev_id=%u; sq_id=%u; cmd_count=%u; cur_num=%u)\n", devId, info->sqId, info->cmdCount, |
| 1871 | - "Invalid para. (dev_id=%u; sq_id=%u; cmd_count=%u; cur_num=%u)\n", devId, info->sqId, info->cmdCount, | 1920 | + sq_info->cur_num); |
| 1872 | - sq_info->cur_num); | ||
| 1873 | return DRV_ERROR_INVALID_VALUE; | 1921 | return DRV_ERROR_INVALID_VALUE; |
| 1874 | } | 1922 | } |
| 1875 | 1923 | ||
| @@ -1951,9 +1999,8 @@ static int trs_cb_cq_recv(uint32_t dev_id, struct halReportInfoInput *in, struct | |||
| 1951 | } | 1999 | } |
| 1952 | 2000 | ||
| 1953 | if ((cqe.cq_id / 64) >= out->cqIdBitmapSize) { /* u64 has 64 bit, echo bit one cq */ | 2001 | if ((cqe.cq_id / 64) >= out->cqIdBitmapSize) { /* u64 has 64 bit, echo bit one cq */ |
| 1954 | - trs_err( | 2002 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u; cq_id_bitmap_size=%u)\n", dev_id, in->tsId, |
| 1955 | - "Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u; cq_id_bitmap_size=%u)\n", dev_id, in->tsId, | 2003 | + in->type, cqe.cq_id, out->cqIdBitmapSize); |
| 1956 | - in->type, cqe.cq_id, out->cqIdBitmapSize); | ||
| 1957 | return DRV_ERROR_INVALID_VALUE; | 2004 | return DRV_ERROR_INVALID_VALUE; |
| 1958 | } | 2005 | } |
| 1959 | 2006 | ||
| @@ -2014,9 +2061,8 @@ drvError_t halCqReportGet(uint32_t devId, struct halReportGetInput *in, struct h | |||
| 2014 | } | 2061 | } |
| 2015 | 2062 | ||
| 2016 | if (!trs_is_cq_support_recv(cq_info)) { | 2063 | if (!trs_is_cq_support_recv(cq_info)) { |
| 2017 | - trs_warn( | 2064 | + trs_warn("Cq is only id type, not support report get. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", devId, |
| 2018 | - "Cq is only id type, not support report get. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", devId, in->tsId, | 2065 | + in->tsId, in->cqId, cq_info->flag); |
| 2019 | - in->cqId, cq_info->flag); | ||
| 2020 | return DRV_ERROR_NOT_SUPPORT; | 2066 | return DRV_ERROR_NOT_SUPPORT; |
| 2021 | } | 2067 | } |
| 2022 | 2068 | ||
| @@ -2046,16 +2092,14 @@ drvError_t halReportRelease(uint32_t devId, struct halReportReleaseInfo *info) | |||
| 2046 | } | 2092 | } |
| 2047 | 2093 | ||
| 2048 | if (!trs_is_cq_support_recv(cq_info)) { | 2094 | if (!trs_is_cq_support_recv(cq_info)) { |
| 2049 | - trs_warn( | 2095 | + trs_warn("Cq is only id type, not support release. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", devId, |
| 2050 | - "Cq is only id type, not support release. (dev_id=%u; ts_id=%u; cq_id=%u; flag=%u)\n", devId, info->tsId, | 2096 | + info->tsId, info->cqId, cq_info->flag); |
| 2051 | - info->cqId, cq_info->flag); | ||
| 2052 | return DRV_ERROR_NOT_SUPPORT; | 2097 | return DRV_ERROR_NOT_SUPPORT; |
| 2053 | } | 2098 | } |
| 2054 | 2099 | ||
| 2055 | if ((info->count == 0) || (info->count != cq_info->cur_num)) { | 2100 | if ((info->count == 0) || (info->count != cq_info->cur_num)) { |
| 2056 | - trs_err( | 2101 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u; count=%u; cur_num=%u)\n", devId, info->tsId, |
| 2057 | - "Invalid para. (dev_id=%u; ts_id=%u; type=%d; cq_id=%u; count=%u; cur_num=%u)\n", devId, info->tsId, | 2102 | + info->type, info->cqId, info->count, cq_info->cur_num); |
| 2058 | - info->type, info->cqId, info->count, cq_info->cur_num); | ||
| 2059 | return DRV_ERROR_INVALID_VALUE; | 2103 | return DRV_ERROR_INVALID_VALUE; |
| 2060 | } | 2104 | } |
| 2061 | 2105 | ||
| @@ -2064,8 +2108,8 @@ drvError_t halReportRelease(uint32_t devId, struct halReportReleaseInfo *info) | |||
| 2064 | return DRV_ERROR_NONE; | 2108 | return DRV_ERROR_NONE; |
| 2065 | } | 2109 | } |
| 2066 | 2110 | ||
| 2067 | -drvError_t trs_async_dma_desc_create( | 2111 | +drvError_t trs_async_dma_desc_create(uint32_t dev_id, struct halAsyncDmaInputPara *in, |
| 2068 | - uint32_t dev_id, struct halAsyncDmaInputPara *in, struct halAsyncDmaOutputPara *out) | 2112 | + struct halAsyncDmaOutputPara *out) |
| 2069 | { | 2113 | { |
| 2070 | int ret; | 2114 | int ret; |
| 2071 | 2115 | ||
| @@ -2079,16 +2123,15 @@ drvError_t trs_async_dma_desc_create( | |||
| 2079 | 2123 | ||
| 2080 | sq_info = trs_get_sq_info(dev_id, in->tsId, in->type, in->info.sq_id); | 2124 | sq_info = trs_get_sq_info(dev_id, in->tsId, in->type, in->info.sq_id); |
| 2081 | if (sq_info == NULL) { | 2125 | if (sq_info == NULL) { |
| 2082 | - trs_err( | 2126 | + trs_err("Invalid para. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, |
| 2083 | - "Invalid para. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, in->info.sq_id); | 2127 | + in->info.sq_id); |
| 2084 | return DRV_ERROR_INVALID_VALUE; | 2128 | return DRV_ERROR_INVALID_VALUE; |
| 2085 | } | 2129 | } |
| 2086 | 2130 | ||
| 2087 | sq_base_addr = trs_get_sq_bind_que_addr(dev_id, in->tsId, sq_info); | 2131 | sq_base_addr = trs_get_sq_bind_que_addr(dev_id, in->tsId, sq_info); |
| 2088 | if (sq_base_addr == 0) { | 2132 | if (sq_base_addr == 0) { |
| 2089 | - trs_err( | 2133 | + trs_err("Get sq addr failed. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, |
| 2090 | - "Get sq addr failed. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, | 2134 | + in->info.sq_id); |
| 2091 | - in->info.sq_id); | ||
| 2092 | return DRV_ERROR_INVALID_VALUE; | 2135 | return DRV_ERROR_INVALID_VALUE; |
| 2093 | } | 2136 | } |
| 2094 | 2137 | ||
| @@ -2096,9 +2139,8 @@ drvError_t trs_async_dma_desc_create( | |||
| 2096 | out->dma_addr.offsetAddr.devid = dev_id; /* sqe update h2d only, use dev addr devid */ | 2139 | out->dma_addr.offsetAddr.devid = dev_id; /* sqe update h2d only, use dev addr devid */ |
| 2097 | ret = drvMemConvertAddr((uintptr_t)in->src, dst_addr, in->len, &out->dma_addr); | 2140 | ret = drvMemConvertAddr((uintptr_t)in->src, dst_addr, in->len, &out->dma_addr); |
| 2098 | if (ret != 0) { | 2141 | if (ret != 0) { |
| 2099 | - trs_err( | 2142 | + trs_err("Convert dma failed. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, |
| 2100 | - "Convert dma failed. (dev_id=%u; ts_id=%u; type=%d; sq_id=%u)\n", dev_id, in->tsId, in->type, | 2143 | + in->info.sq_id); |
| 2101 | - in->info.sq_id); | ||
| 2102 | return ret; | 2144 | return ret; |
| 2103 | } | 2145 | } |
| 2104 | } else { /* check and convert dma desc in kernel when high security mode */ | 2146 | } else { /* check and convert dma desc in kernel when high security mode */ |
| @@ -2145,7 +2187,10 @@ drvError_t trs_async_dma_destory(uint32_t dev_id, struct halAsyncDmaDestoryPara | |||
| 2145 | return DRV_ERROR_NONE; | 2187 | return DRV_ERROR_NONE; |
| 2146 | } | 2188 | } |
| 2147 | 2189 | ||
| 2148 | -void drvDfxShowReport(uint32_t devId) { (void)devId; } | 2190 | +void drvDfxShowReport(uint32_t devId) |
| 2191 | +{ | ||
| 2192 | + (void)devId; | ||
| 2193 | +} | ||
| 2149 | 2194 | ||
| 2150 | static void *g_backup_sq_mem[TRS_DEV_NUM] = {NULL}; | 2195 | static void *g_backup_sq_mem[TRS_DEV_NUM] = {NULL}; |
| 2151 | static int trs_sq_info_back_up(u32 dev_id) | 2196 | static int trs_sq_info_back_up(u32 dev_id) |
| @@ -2219,12 +2264,11 @@ static int trs_sq_backup_uio(uint32_t dev_id, struct stream_backup_info *in) | |||
| 2219 | } | 2264 | } |
| 2220 | que_va = (char *)g_backup_sq_mem[dev_id] + sq_id * sq_info->e_size * sq_info->depth; | 2265 | que_va = (char *)g_backup_sq_mem[dev_id] + sq_id * sq_info->e_size * sq_info->depth; |
| 2221 | if (sq_info->sq_que_spec_addr == sq_info->sq_ctrl.que_addr) { | 2266 | if (sq_info->sq_que_spec_addr == sq_info->sq_ctrl.que_addr) { |
| 2222 | - ret = drvMemcpy( | 2267 | + ret = drvMemcpy((DVdeviceptr)(uintptr_t)que_va, sq_info->e_size * sq_info->depth, |
| 2223 | - (DVdeviceptr)(uintptr_t)que_va, sq_info->e_size * sq_info->depth, | 2268 | + (DVdeviceptr)(uintptr_t)sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->tail); |
| 2224 | - (DVdeviceptr)(uintptr_t)sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->tail); | ||
| 2225 | } else { | 2269 | } else { |
| 2226 | - ret = memcpy_s( | 2270 | + ret = memcpy_s(que_va, sq_info->e_size * sq_info->depth, sq_info->sq_ctrl.que_addr, |
| 2227 | - que_va, sq_info->e_size * sq_info->depth, sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->tail); | 2271 | + sq_info->e_size * sq_info->tail); |
| 2228 | } | 2272 | } |
| 2229 | if (ret != 0) { | 2273 | if (ret != 0) { |
| 2230 | trs_err("Memcpy fail. (ret=%d; dev_id=%u; sq_id=%u)\n", ret, dev_id, sq_id); | 2274 | trs_err("Memcpy fail. (ret=%d; dev_id=%u; sq_id=%u)\n", ret, dev_id, sq_id); |
| @@ -2258,9 +2302,8 @@ static int trs_get_common_sq_info(uint32_t dev_id, struct stream_backup_info *in | |||
| 2258 | sq_depth = (*sq_info)->depth; | 2302 | sq_depth = (*sq_info)->depth; |
| 2259 | } else { | 2303 | } else { |
| 2260 | if (((*sq_info)->e_size != sqe_size) || ((*sq_info)->depth != sq_depth)) { | 2304 | if (((*sq_info)->e_size != sqe_size) || ((*sq_info)->depth != sq_depth)) { |
| 2261 | - trs_err( | 2305 | + trs_err("Invalid sq info. (sqid=%u; sqe_size=%u; sq_depth=%u)\n", sq_id, (*sq_info)->e_size, |
| 2262 | - "Invalid sq info. (sqid=%u; sqe_size=%u; sq_depth=%u)\n", sq_id, (*sq_info)->e_size, | 2306 | + (*sq_info)->depth); |
| 2263 | - (*sq_info)->depth); | ||
| 2264 | return DRV_ERROR_INVALID_VALUE; | 2307 | return DRV_ERROR_INVALID_VALUE; |
| 2265 | } | 2308 | } |
| 2266 | } | 2309 | } |
| @@ -2324,8 +2367,8 @@ drvError_t halStreamBackup(uint32_t dev_id, struct stream_backup_info *in) | |||
| 2324 | return ret; | 2367 | return ret; |
| 2325 | } | 2368 | } |
| 2326 | 2369 | ||
| 2327 | -drvError_t __attribute__((weak)) trs_sq_task_send_with_urma( | 2370 | +drvError_t __attribute__((weak)) trs_sq_task_send_with_urma(uint32_t dev_id, uint32_t sqe_num, |
| 2328 | - uint32_t dev_id, uint32_t sqe_num, struct sqcq_usr_info *sq_info) | 2371 | + struct sqcq_usr_info *sq_info) |
| 2329 | { | 2372 | { |
| 2330 | (void)dev_id; | 2373 | (void)dev_id; |
| 2331 | (void)sqe_num; | 2374 | (void)sqe_num; |
| @@ -2357,12 +2400,11 @@ static int trs_sq_restore_uio(uint32_t dev_id, struct stream_backup_info *in) | |||
| 2357 | } | 2400 | } |
| 2358 | que_va = (char *)g_backup_sq_mem[dev_id] + sq_id * sq_info->e_size * sq_info->depth; | 2401 | que_va = (char *)g_backup_sq_mem[dev_id] + sq_id * sq_info->e_size * sq_info->depth; |
| 2359 | if (sq_info->sq_que_spec_addr == sq_info->sq_ctrl.que_addr) { | 2402 | if (sq_info->sq_que_spec_addr == sq_info->sq_ctrl.que_addr) { |
| 2360 | - ret = drvMemcpy( | 2403 | + ret = drvMemcpy((DVdeviceptr)(uintptr_t)sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->depth, |
| 2361 | - (DVdeviceptr)(uintptr_t)sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->depth, | 2404 | + (DVdeviceptr)(uintptr_t)que_va, sq_info->tail * sq_info->e_size); |
| 2362 | - (DVdeviceptr)(uintptr_t)que_va, sq_info->tail * sq_info->e_size); | ||
| 2363 | } else { | 2405 | } else { |
| 2364 | - ret = memcpy_s( | 2406 | + ret = memcpy_s(sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->depth, que_va, |
| 2365 | - sq_info->sq_ctrl.que_addr, sq_info->e_size * sq_info->depth, que_va, sq_info->tail * sq_info->e_size); | 2407 | + sq_info->tail * sq_info->e_size); |
| 2366 | } | 2408 | } |
| 2367 | if (ret != 0) { | 2409 | if (ret != 0) { |
| 2368 | trs_err("Memcpy fail. (dev_id=%u; sq_id=%u)\n", dev_id, sq_id); | 2410 | trs_err("Memcpy fail. (dev_id=%u; sq_id=%u)\n", dev_id, sq_id); |
| @@ -2383,9 +2425,8 @@ static int trs_sq_restore_uio(uint32_t dev_id, struct stream_backup_info *in) | |||
| 2383 | trs_sq_task_send_set_db(sq_info, sq_id, sq_info->tail); | 2425 | trs_sq_task_send_set_db(sq_info, sq_id, sq_info->tail); |
| 2384 | } | 2426 | } |
| 2385 | } | 2427 | } |
| 2386 | - trs_debug( | 2428 | + trs_debug("Sq restore success with uio. (dev_id=%u; id_num=%u; connection_type=%d)\n", dev_id, in->id_num, |
| 2387 | - "Sq restore success with uio. (dev_id=%u; id_num=%u; connection_type=%d)\n", dev_id, in->id_num, | 2429 | + connection_type); |
| 2388 | - connection_type); | ||
| 2389 | return DRV_ERROR_NONE; | 2430 | return DRV_ERROR_NONE; |
| 2390 | } | 2431 | } |
| 2391 | 2432 | ||
| @@ -132,8 +132,8 @@ drvError_t trs_sq_cq_config(uint32_t dev_id, struct halSqCqConfigInfo *info); | |||
| 132 | int trs_set_sq_info_head(uint32_t dev_id, uint32_t ts_id, int type, uint32_t sq_id, uint32_t head); | 132 | int trs_set_sq_info_head(uint32_t dev_id, uint32_t ts_id, int type, uint32_t sq_id, uint32_t head); |
| 133 | int trs_set_sq_info_tail(uint32_t dev_id, uint32_t ts_id, int type, uint32_t sq_id, uint32_t tail); | 133 | int trs_set_sq_info_tail(uint32_t dev_id, uint32_t ts_id, int type, uint32_t sq_id, uint32_t tail); |
| 134 | int trs_recycle_sq_cq_with_urma(uint32_t dev_id, uint32_t ts_id, uint32_t sq_id, uint32_t cq_id, bool remote_free_flag); | 134 | int trs_recycle_sq_cq_with_urma(uint32_t dev_id, uint32_t ts_id, uint32_t sq_id, uint32_t cq_id, bool remote_free_flag); |
| 135 | -drvError_t trs_async_dma_desc_create( | 135 | +drvError_t trs_async_dma_desc_create(uint32_t dev_id, struct halAsyncDmaInputPara *in, |
| 136 | - uint32_t dev_id, struct halAsyncDmaInputPara *in, struct halAsyncDmaOutputPara *out); | 136 | + struct halAsyncDmaOutputPara *out); |
| 137 | drvError_t trs_async_dma_destory(uint32_t dev_id, struct halAsyncDmaDestoryPara *para); | 137 | drvError_t trs_async_dma_destory(uint32_t dev_id, struct halAsyncDmaDestoryPara *para); |
| 138 | struct trs_sqcq_remote_ops { | 138 | struct trs_sqcq_remote_ops { |
| 139 | drvError_t (*sqcq_alloc)(uint32_t dev_id, struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out); | 139 | drvError_t (*sqcq_alloc)(uint32_t dev_id, struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out); |
| @@ -149,7 +149,10 @@ struct trs_sqcq_mem_ops { | |||
| 149 | 149 | ||
| 150 | void trs_register_sqcq_mem_ops(struct trs_sqcq_mem_ops *ops); | 150 | void trs_register_sqcq_mem_ops(struct trs_sqcq_mem_ops *ops); |
| 151 | 151 | ||
| 152 | -static inline bool trs_is_sq_init_without_sq_mem(uint32_t flag) { return ((flag & TSDRV_FLAG_NO_SQ_MEM) != 0); } | 152 | +static inline bool trs_is_sq_init_without_sq_mem(uint32_t flag) |
| 153 | +{ | ||
| 154 | + return ((flag & TSDRV_FLAG_NO_SQ_MEM) != 0); | ||
| 155 | +} | ||
| 153 | 156 | ||
| 154 | static inline bool trs_is_sq_support_send(struct sqcq_usr_info *info) | 157 | static inline bool trs_is_sq_support_send(struct sqcq_usr_info *info) |
| 155 | { | 158 | { |
| @@ -92,9 +92,8 @@ struct trs_async_jetty_mng_ctx { | |||
| 92 | static struct trs_async_jetty_mng_ctx g_jetty_mng_ctx[TRS_DEV_NUM]; | 92 | static struct trs_async_jetty_mng_ctx g_jetty_mng_ctx[TRS_DEV_NUM]; |
| 93 | 93 | ||
| 94 | extern int halMemGetSeg(uint32_t dev_id, uint64_t va, uint64_t size, urma_seg_t *seg, urma_token_t *token); | 94 | extern int halMemGetSeg(uint32_t dev_id, uint64_t va, uint64_t size, urma_seg_t *seg, urma_token_t *token); |
| 95 | -static int trs_get_segment( | 95 | +static int trs_get_segment(struct trs_urma_ctx *urma_ctx, uint64_t va, uint64_t size, |
| 96 | - struct trs_urma_ctx *urma_ctx, uint64_t va, uint64_t size, struct trs_async_dma_wqe_info *wqe_info, urma_seg_t *seg, | 96 | + struct trs_async_dma_wqe_info *wqe_info, urma_seg_t *seg, urma_token_t *token) |
| 97 | - urma_token_t *token) | ||
| 98 | { | 97 | { |
| 99 | int ret = 0; | 98 | int ret = 0; |
| 100 | 99 | ||
| @@ -119,8 +118,8 @@ void trs_swap_endian(uint8_t dst[], uint8_t src[], uint32_t size) | |||
| 119 | 118 | ||
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | -static inline void trs_get_async_send_recv_addr( | 121 | +static inline void trs_get_async_send_recv_addr(struct trs_async_devid *async_devid, uint64_t src, uint64_t dst, |
| 123 | - struct trs_async_devid *async_devid, uint64_t src, uint64_t dst, uint64_t *send_addr, uint64_t *recv_addr) | 122 | + uint64_t *send_addr, uint64_t *recv_addr) |
| 124 | { | 123 | { |
| 125 | if (async_devid->local_devid == async_devid->dst_devid) { | 124 | if (async_devid->local_devid == async_devid->dst_devid) { |
| 126 | *send_addr = dst; | 125 | *send_addr = dst; |
| @@ -131,8 +130,8 @@ static inline void trs_get_async_send_recv_addr( | |||
| 131 | } | 130 | } |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | -static struct trs_async_ctx *trs_get_async_ctx( | 133 | +static struct trs_async_ctx *trs_get_async_ctx(struct trs_urma_ctx *urma_ctx, uint32_t dir, |
| 135 | - struct trs_urma_ctx *urma_ctx, uint32_t dir, enum trs_async_dma_type async_dma_type) | 134 | + enum trs_async_dma_type async_dma_type) |
| 136 | { | 135 | { |
| 137 | if (dir == TRS_ASYNC_DEVICE_TO_DEVICE) { | 136 | if (dir == TRS_ASYNC_DEVICE_TO_DEVICE) { |
| 138 | if (urma_ctx->d2d_async_ctx.init_flag) { | 137 | if (urma_ctx->d2d_async_ctx.init_flag) { |
| @@ -148,9 +147,9 @@ static struct trs_async_ctx *trs_get_async_ctx( | |||
| 148 | } | 147 | } |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | -static void trs_get_async_input_src_dst_len_array( | 150 | +static void trs_get_async_input_src_dst_len_array(struct trs_async_dma_input_para *in, unsigned long long **src_array, |
| 152 | - struct trs_async_dma_input_para *in, unsigned long long **src_array, unsigned long long **dst_array, | 151 | + unsigned long long **dst_array, unsigned long long **src_len_array, |
| 153 | - unsigned long long **src_len_array, unsigned long long **dst_len_array) | 152 | + unsigned long long **dst_len_array) |
| 154 | { | 153 | { |
| 155 | enum trs_async_dma_type async_type = in->async_dma_type; | 154 | enum trs_async_dma_type async_type = in->async_dma_type; |
| 156 | 155 | ||
| @@ -199,8 +198,8 @@ static drvError_t trs_check_d2d_async_devid(uint32_t dev_id, uint32_t src_dev_id | |||
| 199 | 198 | ||
| 200 | (void)halGetHostID(&host_dev_id); | 199 | (void)halGetHostID(&host_dev_id); |
| 201 | if ((src_dev_id == host_dev_id) || (dst_dev_id == host_dev_id)) { | 200 | if ((src_dev_id == host_dev_id) || (dst_dev_id == host_dev_id)) { |
| 202 | - trs_err( | 201 | + trs_err("Invalid dev_id. (host_dev_id=%u; src_dev_id=%u; dst_dev_id=%u)\n", host_dev_id, src_dev_id, |
| 203 | - "Invalid dev_id. (host_dev_id=%u; src_dev_id=%u; dst_dev_id=%u)\n", host_dev_id, src_dev_id, dst_dev_id); | 202 | + dst_dev_id); |
| 204 | return DRV_ERROR_PARA_ERROR; | 203 | return DRV_ERROR_PARA_ERROR; |
| 205 | } | 204 | } |
| 206 | 205 | ||
| @@ -211,8 +210,8 @@ static drvError_t trs_check_d2d_async_devid(uint32_t dev_id, uint32_t src_dev_id | |||
| 211 | return DRV_ERROR_NONE; | 210 | return DRV_ERROR_NONE; |
| 212 | } | 211 | } |
| 213 | 212 | ||
| 214 | -static int trs_check_async_devid_dir( | 213 | +static int trs_check_async_devid_dir(struct trs_async_dma_input_para *in, uint32_t local_devid, uint32_t src_devid, |
| 215 | - struct trs_async_dma_input_para *in, uint32_t local_devid, uint32_t src_devid, uint32_t dst_devid, uint32_t dir) | 214 | + uint32_t dst_devid, uint32_t dir) |
| 216 | { | 215 | { |
| 217 | enum trs_async_dma_type async_type = in->async_dma_type; | 216 | enum trs_async_dma_type async_type = in->async_dma_type; |
| 218 | int ret = 0; | 217 | int ret = 0; |
| @@ -222,9 +221,8 @@ static int trs_check_async_devid_dir( | |||
| 222 | for (i = 1; i < in->async_batch_in.count; i++) { | 221 | for (i = 1; i < in->async_batch_in.count; i++) { |
| 223 | if ((trs_check_batch_async_devid(in->async_batch_in.src[i], src_devid) != DRV_ERROR_NONE) || | 222 | if ((trs_check_batch_async_devid(in->async_batch_in.src[i], src_devid) != DRV_ERROR_NONE) || |
| 224 | (trs_check_batch_async_devid(in->async_batch_in.dst[i], dst_devid) != DRV_ERROR_NONE)) { | 223 | (trs_check_batch_async_devid(in->async_batch_in.dst[i], dst_devid) != DRV_ERROR_NONE)) { |
| 225 | - trs_err( | 224 | + trs_err("Addr invalid. (src_addr=0x%llx; dst_addr=0x%llx; src_devid=%u; dst_devid=%u; index=%u)\n", |
| 226 | - "Addr invalid. (src_addr=0x%llx; dst_addr=0x%llx; src_devid=%u; dst_devid=%u; index=%u)\n", | 225 | + in->async_batch_in.src[i], in->async_batch_in.dst[i], src_devid, dst_devid, i); |
| 227 | - in->async_batch_in.src[i], in->async_batch_in.dst[i], src_devid, dst_devid, i); | ||
| 228 | return DRV_ERROR_PARA_ERROR; | 226 | return DRV_ERROR_PARA_ERROR; |
| 229 | } | 227 | } |
| 230 | } | 228 | } |
| @@ -255,8 +253,8 @@ static int trs_check_async_devid_dir( | |||
| 255 | return 0; | 253 | return 0; |
| 256 | } | 254 | } |
| 257 | 255 | ||
| 258 | -static int trs_get_check_async_devid_dir( | 256 | +static int trs_get_check_async_devid_dir(uint32_t dev_id, struct trs_async_dma_input_para *in, |
| 259 | - uint32_t dev_id, struct trs_async_dma_input_para *in, struct trs_async_devid *async_devid, uint32_t *dir) | 257 | + struct trs_async_devid *async_devid, uint32_t *dir) |
| 260 | { | 258 | { |
| 261 | enum trs_async_dma_type async_type = in->async_dma_type; | 259 | enum trs_async_dma_type async_type = in->async_dma_type; |
| 262 | struct DVattribute srcAttr, dstAttr; | 260 | struct DVattribute srcAttr, dstAttr; |
| @@ -291,9 +289,8 @@ static int trs_get_check_async_devid_dir( | |||
| 291 | } else if ((dstAttr.devId != host_id) && (srcAttr.devId != host_id)) { | 289 | } else if ((dstAttr.devId != host_id) && (srcAttr.devId != host_id)) { |
| 292 | *dir = TRS_ASYNC_DEVICE_TO_DEVICE; | 290 | *dir = TRS_ASYNC_DEVICE_TO_DEVICE; |
| 293 | } else { | 291 | } else { |
| 294 | - trs_err( | 292 | + trs_err("Invalid va. (src=0x%llx; srcMemType=%u; dst=0x%llx; dstMemType=%u; asyncType=%d)\n", src_array[0], |
| 295 | - "Invalid va. (src=0x%llx; srcMemType=%u; dst=0x%llx; dstMemType=%u; asyncType=%d)\n", src_array[0], | 293 | + srcAttr.memType, dst_array[0], dstAttr.memType, async_type); |
| 296 | - srcAttr.memType, dst_array[0], dstAttr.memType, async_type); | ||
| 297 | return DRV_ERROR_PARA_ERROR; | 294 | return DRV_ERROR_PARA_ERROR; |
| 298 | } | 295 | } |
| 299 | 296 | ||
| @@ -303,10 +300,9 @@ static int trs_get_check_async_devid_dir( | |||
| 303 | } | 300 | } |
| 304 | 301 | ||
| 305 | trs_pack_async_devid(dev_id, srcAttr.devId, dstAttr.devId, async_devid); | 302 | trs_pack_async_devid(dev_id, srcAttr.devId, dstAttr.devId, async_devid); |
| 306 | - trs_debug( | 303 | + trs_debug("(src=0x%llx; src_devid=%u; srcType=%u; dst=0x%llx; dst_devid=%u; dstType=%u; asyncType=%d; devid=%u)\n", |
| 307 | - "(src=0x%llx; src_devid=%u; srcType=%u; dst=0x%llx; dst_devid=%u; dstType=%u; asyncType=%d; devid=%u)\n", | 304 | + src_array[0], async_devid->src_devid, srcAttr.memType, dst_array[0], async_devid->dst_devid, |
| 308 | - src_array[0], async_devid->src_devid, srcAttr.memType, dst_array[0], async_devid->dst_devid, dstAttr.memType, | 305 | + dstAttr.memType, async_type, dev_id); |
| 309 | - async_type, dev_id); | ||
| 310 | return 0; | 306 | return 0; |
| 311 | } | 307 | } |
| 312 | 308 | ||
| @@ -323,9 +319,8 @@ static urma_opcode_t trs_get_async_urma_opcode(uint32_t dev_id, uint32_t dst_dev | |||
| 323 | } | 319 | } |
| 324 | } | 320 | } |
| 325 | 321 | ||
| 326 | -static int trs_fill_remote_wr_batch_info( | 322 | +static int trs_fill_remote_wr_batch_info(struct trs_urma_ctx *urma_ctx, struct trs_async_dma_input_para *in, |
| 327 | - struct trs_urma_ctx *urma_ctx, struct trs_async_dma_input_para *in, uint64_t fixedVal, | 323 | + uint64_t fixedVal, struct trs_remote_fill_wqe_info *wqe_fill_info) |
| 328 | - struct trs_remote_fill_wqe_info *wqe_fill_info) | ||
| 329 | { | 324 | { |
| 330 | urma_opcode_t urma_opcode = wqe_fill_info->urma_opcode; | 325 | urma_opcode_t urma_opcode = wqe_fill_info->urma_opcode; |
| 331 | unsigned long long *src_array, *dst_array; | 326 | unsigned long long *src_array, *dst_array; |
| @@ -337,8 +332,9 @@ static int trs_fill_remote_wr_batch_info( | |||
| 337 | 332 | ||
| 338 | trs_get_async_input_src_dst_len_array(in, &src_array, &dst_array, &src_len_array, &dst_len_array); | 333 | trs_get_async_input_src_dst_len_array(in, &src_array, &dst_array, &src_len_array, &dst_len_array); |
| 339 | 334 | ||
| 340 | - start_index = | 335 | + start_index = (uint32_t)((async_type == TRS_ASYNC_DMA_TYPE_2D) ? |
| 341 | - (uint32_t)((async_type == TRS_ASYNC_DMA_TYPE_2D) ? (in->async_2d_in.fixedSize / in->async_2d_in.width) : 0); | 336 | + (in->async_2d_in.fixedSize / in->async_2d_in.width) : |
| 337 | + 0); | ||
| 342 | 338 | ||
| 343 | for (i = 0; i < wqe_fill_info->batch_num; i++) { | 339 | for (i = 0; i < wqe_fill_info->batch_num; i++) { |
| 344 | uint64_t src, dst, len; | 340 | uint64_t src, dst, len; |
| @@ -388,26 +384,25 @@ static int trs_fill_remote_wr_batch_info( | |||
| 388 | return ret; | 384 | return ret; |
| 389 | } | 385 | } |
| 390 | 386 | ||
| 391 | -static inline void trs_get_async_batch_num( | 387 | +static inline void trs_get_async_batch_num(struct trs_async_dma_input_para *in, uint64_t fixedVal, |
| 392 | - struct trs_async_dma_input_para *in, uint64_t fixedVal, uint64_t partial_fixed_size, uint32_t *batch_num) | 388 | + uint64_t partial_fixed_size, uint32_t *batch_num) |
| 393 | { | 389 | { |
| 394 | if (in->async_dma_type == TRS_ASYNC_DMA_TYPE_BATCH) { | 390 | if (in->async_dma_type == TRS_ASYNC_DMA_TYPE_BATCH) { |
| 395 | *batch_num = (uint32_t)(fixedVal + ((partial_fixed_size == 0) ? 0 : 1)); | 391 | *batch_num = (uint32_t)(fixedVal + ((partial_fixed_size == 0) ? 0 : 1)); |
| 396 | } else if (in->async_dma_type == TRS_ASYNC_DMA_TYPE_2D) { | 392 | } else if (in->async_dma_type == TRS_ASYNC_DMA_TYPE_2D) { |
| 397 | uint64_t align_fixed_size = align_up(in->async_2d_in.fixedSize, in->async_2d_in.width); | 393 | uint64_t align_fixed_size = align_up(in->async_2d_in.fixedSize, in->async_2d_in.width); |
| 398 | - *batch_num = | 394 | + *batch_num = (uint32_t)((fixedVal > align_fixed_size) ? |
| 399 | - (uint32_t)((fixedVal > align_fixed_size) ? | 395 | + ((align_up(fixedVal - align_fixed_size, in->async_2d_in.width) / |
| 400 | - ((align_up(fixedVal - align_fixed_size, in->async_2d_in.width) / in->async_2d_in.width)) : | 396 | + in->async_2d_in.width)) : |
| 401 | - 0); | 397 | + 0); |
| 402 | (*batch_num) += (uint32_t)((in->async_2d_in.fixedSize % in->async_2d_in.width == 0) ? 0 : 1); | 398 | (*batch_num) += (uint32_t)((in->async_2d_in.fixedSize % in->async_2d_in.width == 0) ? 0 : 1); |
| 403 | } else { | 399 | } else { |
| 404 | *batch_num = 1; | 400 | *batch_num = 1; |
| 405 | } | 401 | } |
| 406 | } | 402 | } |
| 407 | 403 | ||
| 408 | -static int trs_remote_fill_async_dma_wqe( | 404 | +static int trs_remote_fill_async_dma_wqe(struct trs_async_devid *async_devid, struct trs_urma_ctx *urma_ctx, |
| 409 | - struct trs_async_devid *async_devid, struct trs_urma_ctx *urma_ctx, struct trs_async_dma_input_para *in, | 405 | + struct trs_async_dma_input_para *in, uint64_t fixedVal) |
| 410 | - uint64_t fixedVal) | ||
| 411 | { | 406 | { |
| 412 | struct trs_remote_fill_wqe_info *wqe_fill_info = NULL; | 407 | struct trs_remote_fill_wqe_info *wqe_fill_info = NULL; |
| 413 | unsigned long long wqe_fill_info_size = 0; | 408 | unsigned long long wqe_fill_info_size = 0; |
| @@ -505,16 +500,16 @@ static void _trs_fill_async_dma_direct_wqe(struct trs_urma_dwqe_fill_para *fill_ | |||
| 505 | sge->va = fill_para->send_addr; | 500 | sge->va = fill_para->send_addr; |
| 506 | } | 501 | } |
| 507 | 502 | ||
| 508 | -static int trs_fill_async_dma_direct_wqe( | 503 | +static int trs_fill_async_dma_direct_wqe(struct trs_async_devid *async_devid, struct trs_urma_ctx *urma_ctx, |
| 509 | - struct trs_async_devid *async_devid, struct trs_urma_ctx *urma_ctx, struct trs_async_ctx *async_ctx, | 504 | + struct trs_async_ctx *async_ctx, struct trs_async_dma_wqe_info *wqe_info, |
| 510 | - struct trs_async_dma_wqe_info *wqe_info, struct trs_async_dma_input_para *in) | 505 | + struct trs_async_dma_input_para *in) |
| 511 | { | 506 | { |
| 512 | struct trs_urma_dwqe_fill_para fill_para = {0}; | 507 | struct trs_urma_dwqe_fill_para fill_para = {0}; |
| 513 | int ret = 0; | 508 | int ret = 0; |
| 514 | 509 | ||
| 515 | - trs_get_async_send_recv_addr( | 510 | + trs_get_async_send_recv_addr(async_devid, (uint64_t)(uintptr_t)in->async_normal_in.src, |
| 516 | - async_devid, (uint64_t)(uintptr_t)in->async_normal_in.src, (uint64_t)(uintptr_t)in->async_normal_in.dst, | 511 | + (uint64_t)(uintptr_t)in->async_normal_in.dst, &fill_para.send_addr, |
| 517 | - &fill_para.send_addr, &fill_para.recv_addr); | 512 | + &fill_para.recv_addr); |
| 518 | fill_para.len = in->async_normal_in.len; | 513 | fill_para.len = in->async_normal_in.len; |
| 519 | fill_para.op_code = trs_get_async_dwqe_opcode(async_devid->local_devid, async_devid, in->dir); | 514 | fill_para.op_code = trs_get_async_dwqe_opcode(async_devid->local_devid, async_devid, in->dir); |
| 520 | fill_para.sqe_bb_idx = async_ctx->pi; | 515 | fill_para.sqe_bb_idx = async_ctx->pi; |
| @@ -552,16 +547,14 @@ static inline uint32_t trs_get_async_jetty_credit(struct trs_async_ctx *async_ct | |||
| 552 | if (is_direct_wqe == true) { /* dwqe not post wr, just pack */ | 547 | if (is_direct_wqe == true) { /* dwqe not post wr, just pack */ |
| 553 | return trs_jetty_get_credit(async_ctx->pi, async_ctx->ci, TRS_UB_PI_CI_DEPTH); | 548 | return trs_jetty_get_credit(async_ctx->pi, async_ctx->ci, TRS_UB_PI_CI_DEPTH); |
| 554 | } else { | 549 | } else { |
| 555 | - return trs_jetty_get_credit( | 550 | + return trs_jetty_get_credit(async_ctx->pi % TRS_STARS_NORMAL_JETTY_DEPTH, |
| 556 | - async_ctx->pi % TRS_STARS_NORMAL_JETTY_DEPTH, async_ctx->ci % TRS_STARS_NORMAL_JETTY_DEPTH, | 551 | + async_ctx->ci % TRS_STARS_NORMAL_JETTY_DEPTH, TRS_STARS_NORMAL_JETTY_DEPTH); |
| 557 | - TRS_STARS_NORMAL_JETTY_DEPTH); | ||
| 558 | } | 552 | } |
| 559 | } | 553 | } |
| 560 | 554 | ||
| 561 | /* fixedVal: means fixedCnt for batch/nop; fixedSIze for others */ | 555 | /* fixedVal: means fixedCnt for batch/nop; fixedSIze for others */ |
| 562 | -static void trs_get_async_post_wr_num( | 556 | +static void trs_get_async_post_wr_num(struct trs_async_dma_input_para *in, uint32_t credit, bool is_normal_use_fixedVal, |
| 563 | - struct trs_async_dma_input_para *in, uint32_t credit, bool is_normal_use_fixedVal, uint32_t *wr_num, | 557 | + uint32_t *wr_num, uint64_t *fixedVal, uint64_t *partial_fixed_size) |
| 564 | - uint64_t *fixedVal, uint64_t *partial_fixed_size) | ||
| 565 | { | 558 | { |
| 566 | *wr_num = 0; | 559 | *wr_num = 0; |
| 567 | 560 | ||
| @@ -576,8 +569,8 @@ static void trs_get_async_post_wr_num( | |||
| 576 | 569 | ||
| 577 | *fixedVal = 0; | 570 | *fixedVal = 0; |
| 578 | for (i = 0; i < in->async_batch_in.count; i++) { | 571 | for (i = 0; i < in->async_batch_in.count; i++) { |
| 579 | - uint32_t tmp = | 572 | + uint32_t tmp = (uint32_t)(align_up(in->async_batch_in.len[i], TRS_URMA_WR_CPY_MAX_SIZE) / |
| 580 | - (uint32_t)(align_up(in->async_batch_in.len[i], TRS_URMA_WR_CPY_MAX_SIZE) / TRS_URMA_WR_CPY_MAX_SIZE); | 573 | + TRS_URMA_WR_CPY_MAX_SIZE); |
| 581 | if ((*wr_num + tmp) <= credit) { | 574 | if ((*wr_num + tmp) <= credit) { |
| 582 | (*wr_num) += tmp; | 575 | (*wr_num) += tmp; |
| 583 | (*fixedVal)++; | 576 | (*fixedVal)++; |
| @@ -595,8 +588,8 @@ static void trs_get_async_post_wr_num( | |||
| 595 | u64 width_offset = (in->async_2d_in.fixedSize % in->async_2d_in.width); | 588 | u64 width_offset = (in->async_2d_in.fixedSize % in->async_2d_in.width); |
| 596 | u64 align_fixed_width = align_up(in->async_2d_in.width - width_offset, TRS_URMA_WR_CPY_MAX_SIZE); | 589 | u64 align_fixed_width = align_up(in->async_2d_in.width - width_offset, TRS_URMA_WR_CPY_MAX_SIZE); |
| 597 | u32 align_fixed_width_wr_num = (uint32_t)(align_fixed_width / TRS_URMA_WR_CPY_MAX_SIZE); | 590 | u32 align_fixed_width_wr_num = (uint32_t)(align_fixed_width / TRS_URMA_WR_CPY_MAX_SIZE); |
| 598 | - u32 align_width_wr_num = | 591 | + u32 align_width_wr_num = (uint32_t)(align_up(in->async_2d_in.width, TRS_URMA_WR_CPY_MAX_SIZE) / |
| 599 | - (uint32_t)(align_up(in->async_2d_in.width, TRS_URMA_WR_CPY_MAX_SIZE) / TRS_URMA_WR_CPY_MAX_SIZE); | 592 | + TRS_URMA_WR_CPY_MAX_SIZE); |
| 600 | 593 | ||
| 601 | *fixedVal = in->async_2d_in.fixedSize; | 594 | *fixedVal = in->async_2d_in.fixedSize; |
| 602 | if (align_fixed_width_wr_num > credit) { /* credit not meet the the-fixedSize-row */ | 595 | if (align_fixed_width_wr_num > credit) { /* credit not meet the the-fixedSize-row */ |
| @@ -606,10 +599,10 @@ static void trs_get_async_post_wr_num( | |||
| 606 | if ((remain_height - 1) * align_width_wr_num > | 599 | if ((remain_height - 1) * align_width_wr_num > |
| 607 | (credit - align_fixed_width_wr_num)) { /* credit not meet the whole 2d size */ | 600 | (credit - align_fixed_width_wr_num)) { /* credit not meet the whole 2d size */ |
| 608 | *wr_num = credit; | 601 | *wr_num = credit; |
| 609 | - (*fixedVal) += | 602 | + (*fixedVal) += ((in->async_2d_in.width - width_offset) + |
| 610 | - ((in->async_2d_in.width - width_offset) + | 603 | + (((credit - align_fixed_width_wr_num) / align_width_wr_num) * in->async_2d_in.width) + |
| 611 | - (((credit - align_fixed_width_wr_num) / align_width_wr_num) * in->async_2d_in.width) + | 604 | + (((credit - align_fixed_width_wr_num) % align_width_wr_num) * |
| 612 | - (((credit - align_fixed_width_wr_num) % align_width_wr_num) * TRS_URMA_WR_CPY_MAX_SIZE)); | 605 | + TRS_URMA_WR_CPY_MAX_SIZE)); |
| 613 | } else { /* credit meet the whole 2d size */ | 606 | } else { /* credit meet the whole 2d size */ |
| 614 | (*wr_num) = (uint32_t)(align_fixed_width_wr_num + (remain_height - 1) * align_width_wr_num); | 607 | (*wr_num) = (uint32_t)(align_fixed_width_wr_num + (remain_height - 1) * align_width_wr_num); |
| 615 | *fixedVal = in->async_2d_in.height * in->async_2d_in.width; | 608 | *fixedVal = in->async_2d_in.height * in->async_2d_in.width; |
| @@ -621,9 +614,9 @@ static void trs_get_async_post_wr_num( | |||
| 621 | } | 614 | } |
| 622 | } | 615 | } |
| 623 | 616 | ||
| 624 | -static int trs_fill_async_dma_wqe( | 617 | +static int trs_fill_async_dma_wqe(struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, |
| 625 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_wqe_info *wqe_info, | 618 | + struct trs_async_dma_wqe_info *wqe_info, struct trs_async_dma_input_para *in, |
| 626 | - struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 619 | + struct halAsyncDmaOutputPara *out) |
| 627 | { | 620 | { |
| 628 | struct trs_urma_ctx *urma_ctx = sq_info->urma_ctx; | 621 | struct trs_urma_ctx *urma_ctx = sq_info->urma_ctx; |
| 629 | bool is_direct_wqe = trs_is_async_direct_wqe(sq_info->flag, in->async_dma_type); | 622 | bool is_direct_wqe = trs_is_async_direct_wqe(sq_info->flag, in->async_dma_type); |
| @@ -637,9 +630,8 @@ static int trs_fill_async_dma_wqe( | |||
| 637 | 630 | ||
| 638 | trs_get_async_post_wr_num(in, credit, false, &wr_num, &fixedVal, NULL); | 631 | trs_get_async_post_wr_num(in, credit, false, &wr_num, &fixedVal, NULL); |
| 639 | if (credit < wr_num) { | 632 | if (credit < wr_num) { |
| 640 | - trs_err( | 633 | + trs_err("Jetty Credit not enough. (pi=%u; ci=%u; credit=%u; wr_num=%u)\n", async_ctx->pi, async_ctx->ci, credit, |
| 641 | - "Jetty Credit not enough. (pi=%u; ci=%u; credit=%u; wr_num=%u)\n", async_ctx->pi, async_ctx->ci, credit, | 634 | + wr_num); |
| 642 | - wr_num); | ||
| 643 | return DRV_ERROR_NO_RESOURCES; | 635 | return DRV_ERROR_NO_RESOURCES; |
| 644 | } | 636 | } |
| 645 | 637 | ||
| @@ -684,9 +676,9 @@ static inline uint64_t trs_get_sq_bind_remote_que_addr(uint32_t dev_id, uint32_t | |||
| 684 | return (uintptr_t)NULL; | 676 | return (uintptr_t)NULL; |
| 685 | } | 677 | } |
| 686 | 678 | ||
| 687 | -static int trs_fill_h2d_async_dma_wqe( | 679 | +static int trs_fill_h2d_async_dma_wqe(struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, |
| 688 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_wqe_info *wqe_info, | 680 | + struct trs_async_dma_wqe_info *wqe_info, struct trs_async_dma_input_para *in, |
| 689 | - struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 681 | + struct halAsyncDmaOutputPara *out) |
| 690 | { | 682 | { |
| 691 | uint32_t sqid = in->async_normal_in.info.sq_id; | 683 | uint32_t sqid = in->async_normal_in.info.sq_id; |
| 692 | uint32_t sqe_pos = 0; | 684 | uint32_t sqe_pos = 0; |
| @@ -698,18 +690,16 @@ static int trs_fill_h2d_async_dma_wqe( | |||
| 698 | 690 | ||
| 699 | update_sq_info = trs_get_sq_info(async_devid->local_devid, in->tsId, in->type, sqid); | 691 | update_sq_info = trs_get_sq_info(async_devid->local_devid, in->tsId, in->type, sqid); |
| 700 | if ((update_sq_info == NULL) || (update_sq_info->urma_ctx == NULL)) { | 692 | if ((update_sq_info == NULL) || (update_sq_info->urma_ctx == NULL)) { |
| 701 | - trs_err( | 693 | + trs_err("Invalid para. (devid=%u; tsId=%u; type=%d; sqid=%u)\n", async_devid->local_devid, in->tsId, |
| 702 | - "Invalid para. (devid=%u; tsId=%u; type=%d; sqid=%u)\n", async_devid->local_devid, in->tsId, in->type, | 694 | + in->type, sqid); |
| 703 | - sqid); | ||
| 704 | return DRV_ERROR_INVALID_VALUE; | 695 | return DRV_ERROR_INVALID_VALUE; |
| 705 | } | 696 | } |
| 706 | 697 | ||
| 707 | sqe_pos = in->async_normal_in.info.sqe_pos; | 698 | sqe_pos = in->async_normal_in.info.sqe_pos; |
| 708 | if ((sqe_pos >= update_sq_info->depth) || | 699 | if ((sqe_pos >= update_sq_info->depth) || |
| 709 | (in->async_normal_in.len > (update_sq_info->depth - sqe_pos) * update_sq_info->e_size)) { | 700 | (in->async_normal_in.len > (update_sq_info->depth - sqe_pos) * update_sq_info->e_size)) { |
| 710 | - trs_err( | 701 | + trs_err("Invalid para. (sqid=%u; sqe_pos=%u; len=%u; depth=%u, sqe_size=%u)\n", sqid, sqe_pos, |
| 711 | - "Invalid para. (sqid=%u; sqe_pos=%u; len=%u; depth=%u, sqe_size=%u)\n", sqid, sqe_pos, | 702 | + in->async_normal_in.len, update_sq_info->depth, update_sq_info->e_size); |
| 712 | - in->async_normal_in.len, update_sq_info->depth, update_sq_info->e_size); | ||
| 713 | return DRV_ERROR_PARA_ERROR; | 703 | return DRV_ERROR_PARA_ERROR; |
| 714 | } | 704 | } |
| 715 | 705 | ||
| @@ -720,10 +710,9 @@ static int trs_fill_h2d_async_dma_wqe( | |||
| 720 | } | 710 | } |
| 721 | 711 | ||
| 722 | in->async_normal_in.dst = (u8 *)(uintptr_t)remote_sq_que_addr + sqe_pos * update_sq_info->e_size; | 712 | in->async_normal_in.dst = (u8 *)(uintptr_t)remote_sq_que_addr + sqe_pos * update_sq_info->e_size; |
| 723 | - trs_debug( | 713 | + trs_debug("(devid=%u; sqid=%u; sqe_pos=%u; sqe_size=%u; len=%u; remote_sq_que_addr=0x%llx; dst=0x%llx)\n", |
| 724 | - "(devid=%u; sqid=%u; sqe_pos=%u; sqe_size=%u; len=%u; remote_sq_que_addr=0x%llx; dst=0x%llx)\n", | 714 | + async_devid->local_devid, sqid, sqe_pos, update_sq_info->e_size, in->async_normal_in.len, |
| 725 | - async_devid->local_devid, sqid, sqe_pos, update_sq_info->e_size, in->async_normal_in.len, | 715 | + remote_sq_que_addr, (u64)(uintptr_t)in->async_normal_in.dst); |
| 726 | - remote_sq_que_addr, (u64)(uintptr_t)in->async_normal_in.dst); | ||
| 727 | } | 716 | } |
| 728 | 717 | ||
| 729 | ret = trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); | 718 | ret = trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); |
| @@ -735,15 +724,15 @@ static int trs_fill_h2d_async_dma_wqe( | |||
| 735 | return ret; | 724 | return ret; |
| 736 | } | 725 | } |
| 737 | 726 | ||
| 738 | -static int trs_fill_d2h_async_dma_wqe( | 727 | +static int trs_fill_d2h_async_dma_wqe(struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, |
| 739 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_wqe_info *wqe_info, | 728 | + struct trs_async_dma_wqe_info *wqe_info, struct trs_async_dma_input_para *in, |
| 740 | - struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 729 | + struct halAsyncDmaOutputPara *out) |
| 741 | { | 730 | { |
| 742 | return trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); | 731 | return trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); |
| 743 | } | 732 | } |
| 744 | 733 | ||
| 745 | -static int trs_alloc_device_jetty( | 734 | +static int trs_alloc_device_jetty(uint32_t dev_id, struct trs_d2d_send_info *alloc_info, |
| 746 | - uint32_t dev_id, struct trs_d2d_send_info *alloc_info, struct trs_d2d_sync_info *sync_msg) | 735 | + struct trs_d2d_sync_info *sync_msg) |
| 747 | { | 736 | { |
| 748 | struct event_reply reply; | 737 | struct event_reply reply; |
| 749 | int ret, result; | 738 | int ret, result; |
| @@ -755,8 +744,8 @@ static int trs_alloc_device_jetty( | |||
| 755 | return DRV_ERROR_OUT_OF_MEMORY; | 744 | return DRV_ERROR_OUT_OF_MEMORY; |
| 756 | } | 745 | } |
| 757 | 746 | ||
| 758 | - ret = trs_local_mem_event_sync( | 747 | + ret = trs_local_mem_event_sync(dev_id, alloc_info, sizeof(struct trs_d2d_send_info), |
| 759 | - dev_id, alloc_info, sizeof(struct trs_d2d_send_info), DRV_SUBEVENT_TRS_CREATE_ASYNC_JETTY_MSG, &reply); | 748 | + DRV_SUBEVENT_TRS_CREATE_ASYNC_JETTY_MSG, &reply); |
| 760 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 749 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 761 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { | 750 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { |
| 762 | 751 | ||
| @@ -765,9 +754,8 @@ static int trs_alloc_device_jetty( | |||
| 765 | return (ret != DRV_ERROR_NONE) ? ret : result; | 754 | return (ret != DRV_ERROR_NONE) ? ret : result; |
| 766 | 755 | ||
| 767 | } | 756 | } |
| 768 | - (void)memcpy_s( | 757 | + (void)memcpy_s(sync_msg, sizeof(struct trs_d2d_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 769 | - sync_msg, sizeof(struct trs_d2d_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 758 | + sizeof(struct trs_d2d_sync_info)); |
| 770 | - sizeof(struct trs_d2d_sync_info)); | ||
| 771 | 759 | ||
| 772 | free(reply.buf); | 760 | free(reply.buf); |
| 773 | return 0; | 761 | return 0; |
| @@ -780,8 +768,8 @@ static int trs_free_device_jetty(uint32_t dev_id, struct trs_d2d_send_info *free | |||
| 780 | 768 | ||
| 781 | reply.buf_len = sizeof(result); | 769 | reply.buf_len = sizeof(result); |
| 782 | reply.buf = (char *)&result; | 770 | reply.buf = (char *)&result; |
| 783 | - ret = trs_local_mem_event_sync( | 771 | + ret = trs_local_mem_event_sync(dev_id, free_info, sizeof(struct trs_d2d_send_info), |
| 784 | - dev_id, free_info, sizeof(struct trs_d2d_send_info), DRV_SUBEVENT_TRS_DESTROY_ASYNC_JETTY_MSG, &reply); | 772 | + DRV_SUBEVENT_TRS_DESTROY_ASYNC_JETTY_MSG, &reply); |
| 785 | if ((ret != 0) || (result != 0)) { | 773 | if ((ret != 0) || (result != 0)) { |
| 786 | trs_err("Failed to sync destroy async jetty. (ret=%d; result=%d; dev_id=%u)\n", ret, result, dev_id); | 774 | trs_err("Failed to sync destroy async jetty. (ret=%d; result=%d; dev_id=%u)\n", ret, result, dev_id); |
| 787 | return (ret != 0) ? ret : result; | 775 | return (ret != 0) ? ret : result; |
| @@ -809,8 +797,8 @@ static int trs_import_remote_d2d_jetty(uint32_t dev_id, uint32_t remote_dev_id, | |||
| 809 | return DRV_ERROR_OUT_OF_MEMORY; | 797 | return DRV_ERROR_OUT_OF_MEMORY; |
| 810 | } | 798 | } |
| 811 | 799 | ||
| 812 | - ret = trs_local_mem_event_sync( | 800 | + ret = trs_local_mem_event_sync(dev_id, &info, sizeof(struct trs_import_jetty_info), |
| 813 | - dev_id, &info, sizeof(struct trs_import_jetty_info), DRV_SUBEVENT_TRS_IMPORT_ASYNC_JETTY_MSG, &reply); | 801 | + DRV_SUBEVENT_TRS_IMPORT_ASYNC_JETTY_MSG, &reply); |
| 814 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 802 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 815 | if ((ret != 0) || (result != 0)) { | 803 | if ((ret != 0) || (result != 0)) { |
| 816 | free(reply.buf); | 804 | free(reply.buf); |
| @@ -818,9 +806,8 @@ static int trs_import_remote_d2d_jetty(uint32_t dev_id, uint32_t remote_dev_id, | |||
| 818 | return (ret != 0) ? ret : result; | 806 | return (ret != 0) ? ret : result; |
| 819 | } | 807 | } |
| 820 | 808 | ||
| 821 | - (void)memcpy_s( | 809 | + (void)memcpy_s(&sync_msg, sizeof(struct trs_d2d_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 822 | - &sync_msg, sizeof(struct trs_d2d_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 810 | + sizeof(struct trs_d2d_sync_info)); |
| 823 | - sizeof(struct trs_d2d_sync_info)); | ||
| 824 | d2d_dev_ctx->tpn[dev_id] = sync_msg.tpn; | 811 | d2d_dev_ctx->tpn[dev_id] = sync_msg.tpn; |
| 825 | d2d_dev_ctx->tpn_valid[dev_id] = true; | 812 | d2d_dev_ctx->tpn_valid[dev_id] = true; |
| 826 | 813 | ||
| @@ -828,8 +815,8 @@ static int trs_import_remote_d2d_jetty(uint32_t dev_id, uint32_t remote_dev_id, | |||
| 828 | return 0; | 815 | return 0; |
| 829 | } | 816 | } |
| 830 | 817 | ||
| 831 | -static int trs_create_local_d2d_jetty( | 818 | +static int trs_create_local_d2d_jetty(struct trs_async_devid *d2d_async_devid, uint32_t sq_id, uint32_t flag, |
| 832 | - struct trs_async_devid *d2d_async_devid, uint32_t sq_id, uint32_t flag, struct trs_async_ctx *async_ctx) | 819 | + struct trs_async_ctx *async_ctx) |
| 833 | { | 820 | { |
| 834 | struct trs_d2d_sync_info sync_msg; | 821 | struct trs_d2d_sync_info sync_msg; |
| 835 | struct trs_d2d_send_info alloc_info = {0}; | 822 | struct trs_d2d_send_info alloc_info = {0}; |
| @@ -873,9 +860,8 @@ static int trs_create_remote_d2d_jetty(uint32_t remote_devid, uint32_t flag, str | |||
| 873 | d2d_dev_ctx->dst_jfr_id = sync_msg.jfr_id; | 860 | d2d_dev_ctx->dst_jfr_id = sync_msg.jfr_id; |
| 874 | d2d_dev_ctx->token_value = sync_msg.token_value; | 861 | d2d_dev_ctx->token_value = sync_msg.token_value; |
| 875 | 862 | ||
| 876 | - trs_debug( | 863 | + trs_debug("Create jetty success. (remote_devid=%u; jfr_id=%u; flag=0x%x)\n", remote_devid, |
| 877 | - "Create jetty success. (remote_devid=%u; jfr_id=%u; flag=0x%x)\n", remote_devid, d2d_dev_ctx->dst_jfr_id.id, | 864 | + d2d_dev_ctx->dst_jfr_id.id, flag); |
| 878 | - flag); | ||
| 879 | return 0; | 865 | return 0; |
| 880 | } | 866 | } |
| 881 | 867 | ||
| @@ -906,17 +892,15 @@ static int trs_d2d_dev_ctx_check_init(struct trs_async_devid *d2d_async_devid, u | |||
| 906 | 892 | ||
| 907 | ret = trs_create_remote_d2d_jetty(remote_devid, flag, d2d_dev_ctx); | 893 | ret = trs_create_remote_d2d_jetty(remote_devid, flag, d2d_dev_ctx); |
| 908 | if (ret != 0) { | 894 | if (ret != 0) { |
| 909 | - trs_err( | 895 | + trs_err("Failed to create remote jetty. (local_devid=%u; remote_devid=%u; ret=%d; flag=0x%x)\n", |
| 910 | - "Failed to create remote jetty. (local_devid=%u; remote_devid=%u; ret=%d; flag=0x%x)\n", local_devid, | 896 | + local_devid, remote_devid, ret, flag); |
| 911 | - remote_devid, ret, flag); | ||
| 912 | free(d2d_dev_ctx); | 897 | free(d2d_dev_ctx); |
| 913 | goto exit; | 898 | goto exit; |
| 914 | } | 899 | } |
| 915 | 900 | ||
| 916 | trs_set_d2d_dev_ctx(remote_devid, (void *)d2d_dev_ctx); | 901 | trs_set_d2d_dev_ctx(remote_devid, (void *)d2d_dev_ctx); |
| 917 | - trs_debug( | 902 | + trs_debug("Create remote jetty success. (remote_devid=%u; flag=0x%x; jetty_id=%u)\n", remote_devid, flag, |
| 918 | - "Create remote jetty success. (remote_devid=%u; flag=0x%x; jetty_id=%u)\n", remote_devid, flag, | 903 | + d2d_dev_ctx->dst_jfr_id.id); |
| 919 | - d2d_dev_ctx->dst_jfr_id.id); | ||
| 920 | } | 904 | } |
| 921 | 905 | ||
| 922 | if (d2d_dev_ctx->tpn_valid[local_devid] == false) { | 906 | if (d2d_dev_ctx->tpn_valid[local_devid] == false) { |
| @@ -931,8 +915,8 @@ exit: | |||
| 931 | return ret; | 915 | return ret; |
| 932 | } | 916 | } |
| 933 | 917 | ||
| 934 | -static int trs_d2d_async_ctx_create( | 918 | +static int trs_d2d_async_ctx_create(struct trs_urma_ctx *urma_ctx, struct trs_async_devid *d2d_async_devid, |
| 935 | - struct trs_urma_ctx *urma_ctx, struct trs_async_devid *d2d_async_devid, uint32_t sq_id, uint32_t flag) | 919 | + uint32_t sq_id, uint32_t flag) |
| 936 | { | 920 | { |
| 937 | uint32_t local_devid = d2d_async_devid->local_devid; | 921 | uint32_t local_devid = d2d_async_devid->local_devid; |
| 938 | struct trs_async_ctx *async_ctx = &urma_ctx->d2d_async_ctx; | 922 | struct trs_async_ctx *async_ctx = &urma_ctx->d2d_async_ctx; |
| @@ -948,9 +932,8 @@ static int trs_d2d_async_ctx_create( | |||
| 948 | } | 932 | } |
| 949 | async_ctx->init_flag = true; | 933 | async_ctx->init_flag = true; |
| 950 | create_local_flag = 1; | 934 | create_local_flag = 1; |
| 951 | - trs_debug( | 935 | + trs_debug("Create local jetty success. (devid=%u; flag=0x%x; sq_id=%u; jetty_id=%u; fun_id=%u; die_id=%u)\n", |
| 952 | - "Create local jetty success. (devid=%u; flag=0x%x; sq_id=%u; jetty_id=%u; fun_id=%u; die_id=%u)\n", | 936 | + local_devid, flag, sq_id, async_ctx->src_jetty_id.id, async_ctx->func_id, async_ctx->die_id); |
| 953 | - local_devid, flag, sq_id, async_ctx->src_jetty_id.id, async_ctx->func_id, async_ctx->die_id); | ||
| 954 | } | 937 | } |
| 955 | (void)pthread_mutex_unlock(&urma_ctx->ctx_mutex); | 938 | (void)pthread_mutex_unlock(&urma_ctx->ctx_mutex); |
| 956 | 939 | ||
| @@ -988,25 +971,26 @@ static int trs_d2d_async_ctx_destroy(uint32_t dev_id, uint32_t sq_id, struct trs | |||
| 988 | return 0; | 971 | return 0; |
| 989 | } | 972 | } |
| 990 | 973 | ||
| 991 | -static int trs_fill_d2d_async_dma_wqe( | 974 | +static int trs_fill_d2d_async_dma_wqe(struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, |
| 992 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_wqe_info *wqe_info, | 975 | + struct trs_async_dma_wqe_info *wqe_info, struct trs_async_dma_input_para *in, |
| 993 | - struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 976 | + struct halAsyncDmaOutputPara *out) |
| 994 | { | 977 | { |
| 995 | wqe_info->remote_dev_id = async_devid->remote_devid; | 978 | wqe_info->remote_dev_id = async_devid->remote_devid; |
| 996 | return trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); | 979 | return trs_fill_async_dma_wqe(async_devid, sq_info, wqe_info, in, out); |
| 997 | } | 980 | } |
| 998 | 981 | ||
| 999 | -static int (*const trs_async_dma_wqe_fill_handles[TRS_ASYNC_MAX_DIR])( | 982 | +static int (*const trs_async_dma_wqe_fill_handles[TRS_ASYNC_MAX_DIR])(struct trs_async_devid *async_devid, |
| 1000 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_wqe_info *wqe_info, | 983 | + struct sqcq_usr_info *sq_info, |
| 1001 | - struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) = { | 984 | + struct trs_async_dma_wqe_info *wqe_info, |
| 985 | + struct trs_async_dma_input_para *in, | ||
| 986 | + struct halAsyncDmaOutputPara *out) = { | ||
| 1002 | [TRS_ASYNC_HOST_TO_DEVICE] = trs_fill_h2d_async_dma_wqe, | 987 | [TRS_ASYNC_HOST_TO_DEVICE] = trs_fill_h2d_async_dma_wqe, |
| 1003 | [TRS_ASYNC_DEVICE_TO_HOST] = trs_fill_d2h_async_dma_wqe, | 988 | [TRS_ASYNC_DEVICE_TO_HOST] = trs_fill_d2h_async_dma_wqe, |
| 1004 | [TRS_ASYNC_DEVICE_TO_DEVICE] = trs_fill_d2d_async_dma_wqe, | 989 | [TRS_ASYNC_DEVICE_TO_DEVICE] = trs_fill_d2d_async_dma_wqe, |
| 1005 | }; | 990 | }; |
| 1006 | 991 | ||
| 1007 | -static int trs_h2d2h_async_ctx_init( | 992 | +static int trs_h2d2h_async_ctx_init(uint32_t dev_id, struct trs_urma_ctx *urma_ctx, uint32_t sqId, uint32_t subevent_id, |
| 1008 | - uint32_t dev_id, struct trs_urma_ctx *urma_ctx, uint32_t sqId, uint32_t subevent_id, | 993 | + struct trs_async_ctx *async_ctx) |
| 1009 | - struct trs_async_ctx *async_ctx) | ||
| 1010 | { | 994 | { |
| 1011 | struct trs_async_jetty_init_para jetty_para = {0}; | 995 | struct trs_async_jetty_init_para jetty_para = {0}; |
| 1012 | uint32_t sq_id = sqId; | 996 | uint32_t sq_id = sqId; |
| @@ -1024,15 +1008,14 @@ static int trs_h2d2h_async_ctx_init( | |||
| 1024 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 1008 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 1025 | 1009 | ||
| 1026 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { | 1010 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { |
| 1027 | - trs_err( | 1011 | + trs_err("Failed to sync event. (dev_id=%u; subevent_id=%u; ret=%d; result=%d)\n", dev_id, subevent_id, ret, |
| 1028 | - "Failed to sync event. (dev_id=%u; subevent_id=%u; ret=%d; result=%d)\n", dev_id, subevent_id, ret, result); | 1012 | + result); |
| 1029 | free(reply.buf); | 1013 | free(reply.buf); |
| 1030 | return (ret != DRV_ERROR_NONE) ? ret : result; | 1014 | return (ret != DRV_ERROR_NONE) ? ret : result; |
| 1031 | } | 1015 | } |
| 1032 | 1016 | ||
| 1033 | - (void)memcpy_s( | 1017 | + (void)memcpy_s(&jetty_para, sizeof(struct trs_async_jetty_init_para), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 1034 | - &jetty_para, sizeof(struct trs_async_jetty_init_para), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 1018 | + sizeof(struct trs_async_jetty_init_para)); |
| 1035 | - sizeof(struct trs_async_jetty_init_para)); | ||
| 1036 | free(reply.buf); | 1019 | free(reply.buf); |
| 1037 | 1020 | ||
| 1038 | async_ctx->src_jetty_id = jetty_para.jetty_id; | 1021 | async_ctx->src_jetty_id = jetty_para.jetty_id; |
| @@ -1043,8 +1026,8 @@ static int trs_h2d2h_async_ctx_init( | |||
| 1043 | return 0; | 1026 | return 0; |
| 1044 | } | 1027 | } |
| 1045 | 1028 | ||
| 1046 | -static int trs_async_init_async_ctx( | 1029 | +static int trs_async_init_async_ctx(struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, |
| 1047 | - struct trs_async_devid *async_devid, struct sqcq_usr_info *sq_info, struct trs_async_dma_input_para *in) | 1030 | + struct trs_async_dma_input_para *in) |
| 1048 | { | 1031 | { |
| 1049 | struct trs_urma_ctx *urma_ctx = sq_info->urma_ctx; | 1032 | struct trs_urma_ctx *urma_ctx = sq_info->urma_ctx; |
| 1050 | int ret = 0; | 1033 | int ret = 0; |
| @@ -1092,8 +1075,8 @@ int trs_async_uninit_async_ctx(uint32_t dev_id, uint32_t sq_id, void *master_ctx | |||
| 1092 | return trs_d2d_async_ctx_destroy(dev_id, sq_id, urma_ctx); | 1075 | return trs_d2d_async_ctx_destroy(dev_id, sq_id, urma_ctx); |
| 1093 | } | 1076 | } |
| 1094 | 1077 | ||
| 1095 | -drvError_t trs_async_dma_wqe_create( | 1078 | +drvError_t trs_async_dma_wqe_create(uint32_t dev_id, struct trs_async_dma_input_para *in, |
| 1096 | - uint32_t dev_id, struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out) | 1079 | + struct halAsyncDmaOutputPara *out) |
| 1097 | { | 1080 | { |
| 1098 | struct sqcq_usr_info *sq_info = NULL; | 1081 | struct sqcq_usr_info *sq_info = NULL; |
| 1099 | struct trs_async_dma_wqe_info *wqe_info = NULL; | 1082 | struct trs_async_dma_wqe_info *wqe_info = NULL; |
| @@ -1146,14 +1129,13 @@ drvError_t trs_async_dma_wqe_create( | |||
| 1146 | free(wqe_info); | 1129 | free(wqe_info); |
| 1147 | } | 1130 | } |
| 1148 | 1131 | ||
| 1149 | - trs_debug( | 1132 | + trs_debug("Create async dma wqe. (dev_id=%u; dir=%u; sq_id=%u; dieid=%u; func_id=%u; jetty_id=%u)\n", dev_id, |
| 1150 | - "Create async dma wqe. (dev_id=%u; dir=%u; sq_id=%u; dieid=%u; func_id=%u; jetty_id=%u)\n", dev_id, in->dir, | 1133 | + in->dir, in->sqId, out->dieId, out->functionId, out->jettyId); |
| 1151 | - in->sqId, out->dieId, out->functionId, out->jettyId); | ||
| 1152 | return DRV_ERROR_NONE; | 1134 | return DRV_ERROR_NONE; |
| 1153 | } | 1135 | } |
| 1154 | 1136 | ||
| 1155 | -static drvError_t trs_async_dma_wqe_normal_destory( | 1137 | +static drvError_t trs_async_dma_wqe_normal_destory(uint32_t dev_id, struct trs_urma_ctx *urma_ctx, |
| 1156 | - uint32_t dev_id, struct trs_urma_ctx *urma_ctx, struct halAsyncDmaDestoryPara *para) | 1138 | + struct halAsyncDmaDestoryPara *para) |
| 1157 | { | 1139 | { |
| 1158 | struct trs_async_dma_wqe_info *wqe_info = NULL; | 1140 | struct trs_async_dma_wqe_info *wqe_info = NULL; |
| 1159 | struct trs_async_ctx *async_ctx = NULL; | 1141 | struct trs_async_ctx *async_ctx = NULL; |
| @@ -1179,22 +1161,20 @@ static drvError_t trs_async_dma_wqe_normal_destory( | |||
| 1179 | } | 1161 | } |
| 1180 | 1162 | ||
| 1181 | async_ctx->ci = (async_ctx->ci + 1) % trs_get_async_pi_ci_max(false); | 1163 | async_ctx->ci = (async_ctx->ci + 1) % trs_get_async_pi_ci_max(false); |
| 1182 | - trs_debug( | 1164 | + trs_debug("Async dma wqe destroy. (dev_id=%u; sq_id=%u; ci=%u; dir=%u)\n", dev_id, para->sqId, async_ctx->ci, |
| 1183 | - "Async dma wqe destroy. (dev_id=%u; sq_id=%u; ci=%u; dir=%u)\n", dev_id, para->sqId, async_ctx->ci, | 1165 | + wqe_info->dir); |
| 1184 | - wqe_info->dir); | ||
| 1185 | free(wqe_info); | 1166 | free(wqe_info); |
| 1186 | return 0; | 1167 | return 0; |
| 1187 | } | 1168 | } |
| 1188 | 1169 | ||
| 1189 | -static drvError_t trs_async_dma_wqe_batch_2d_destory( | 1170 | +static drvError_t trs_async_dma_wqe_batch_2d_destory(uint32_t dev_id, struct trs_urma_ctx *urma_ctx, |
| 1190 | - uint32_t dev_id, struct trs_urma_ctx *urma_ctx, struct trs_async_dma_destroy_para *para) | 1171 | + struct trs_async_dma_destroy_para *para) |
| 1191 | { | 1172 | { |
| 1192 | struct trs_async_ctx *async_ctx = NULL; | 1173 | struct trs_async_ctx *async_ctx = NULL; |
| 1193 | 1174 | ||
| 1194 | if (para->async_batch_para->ci >= TRS_UB_PI_CI_DEPTH) { | 1175 | if (para->async_batch_para->ci >= TRS_UB_PI_CI_DEPTH) { |
| 1195 | - trs_err( | 1176 | + trs_err("The ci exceed. (dev_id=%u; sq_id=%u; ci=%u; max=%d)\n", dev_id, para->sqId, para->async_batch_para->ci, |
| 1196 | - "The ci exceed. (dev_id=%u; sq_id=%u; ci=%u; max=%d)\n", dev_id, para->sqId, para->async_batch_para->ci, | 1177 | + TRS_UB_PI_CI_DEPTH); |
| 1197 | - TRS_UB_PI_CI_DEPTH); | ||
| 1198 | return DRV_ERROR_PARA_ERROR; | 1178 | return DRV_ERROR_PARA_ERROR; |
| 1199 | } | 1179 | } |
| 1200 | 1180 | ||
| @@ -1264,15 +1244,14 @@ drvError_t trs_sq_jetty_info_query(uint32_t dev_id, struct halSqCqQueryInfo *inf | |||
| 1264 | info->value[1] = async_ctx->src_jetty_id.id; /* 1: jetty id */ | 1244 | info->value[1] = async_ctx->src_jetty_id.id; /* 1: jetty id */ |
| 1265 | info->value[2] = async_ctx->func_id; /* 2: func id */ | 1245 | info->value[2] = async_ctx->func_id; /* 2: func id */ |
| 1266 | info->value[3] = async_ctx->die_id; /* 3: die id*/ | 1246 | info->value[3] = async_ctx->die_id; /* 3: die id*/ |
| 1267 | - trs_debug( | 1247 | + trs_debug("Query jetty info. (devid=%u; sqid=%u; prop=%d; nop_num=%u; jetty_id=%u; func_id=%u; die_id=%u)\n", |
| 1268 | - "Query jetty info. (devid=%u; sqid=%u; prop=%d; nop_num=%u; jetty_id=%u; func_id=%u; die_id=%u)\n", dev_id, | 1248 | + dev_id, info->sqId, info->prop, info->value[0], info->value[1], info->value[2], info->value[3]); |
| 1269 | - info->sqId, info->prop, info->value[0], info->value[1], info->value[2], info->value[3]); | ||
| 1270 | 1249 | ||
| 1271 | return DRV_ERROR_NONE; | 1250 | return DRV_ERROR_NONE; |
| 1272 | } | 1251 | } |
| 1273 | 1252 | ||
| 1274 | -static int trs_async_dma_jetty_remote_alloc( | 1253 | +static int trs_async_dma_jetty_remote_alloc(uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, |
| 1275 | - uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, struct trs_async_jetty_info *jetty_info) | 1254 | + struct trs_async_jetty_info *jetty_info) |
| 1276 | { | 1255 | { |
| 1277 | struct trs_urma_proc_ctx *urma_proc_ctx = NULL; | 1256 | struct trs_urma_proc_ctx *urma_proc_ctx = NULL; |
| 1278 | struct trs_remote_alloc_jetty_para jetty_para = {0}; | 1257 | struct trs_remote_alloc_jetty_para jetty_para = {0}; |
| @@ -1291,8 +1270,8 @@ static int trs_async_dma_jetty_remote_alloc( | |||
| 1291 | jetty_para.in = *in; | 1270 | jetty_para.in = *in; |
| 1292 | jetty_para.jfr_id = urma_proc_ctx->trs_jfr.jfr->jfr_id; | 1271 | jetty_para.jfr_id = urma_proc_ctx->trs_jfr.jfr->jfr_id; |
| 1293 | jetty_para.token = urma_proc_ctx->token; | 1272 | jetty_para.token = urma_proc_ctx->token; |
| 1294 | - ret = trs_svm_mem_event_sync( | 1273 | + ret = trs_svm_mem_event_sync(dev_id, &jetty_para, sizeof(struct trs_remote_alloc_jetty_para), |
| 1295 | - dev_id, &jetty_para, sizeof(struct trs_remote_alloc_jetty_para), DRV_SUBEVENT_TRS_ALLOC_JETTY_MSG, &reply); | 1274 | + DRV_SUBEVENT_TRS_ALLOC_JETTY_MSG, &reply); |
| 1296 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 1275 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 1297 | 1276 | ||
| 1298 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { | 1277 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { |
| @@ -1301,9 +1280,8 @@ static int trs_async_dma_jetty_remote_alloc( | |||
| 1301 | return (ret != DRV_ERROR_NONE) ? (int)ret : result; | 1280 | return (ret != DRV_ERROR_NONE) ? (int)ret : result; |
| 1302 | } | 1281 | } |
| 1303 | 1282 | ||
| 1304 | - (void)memcpy_s( | 1283 | + (void)memcpy_s(jetty_info, sizeof(struct trs_async_jetty_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 1305 | - jetty_info, sizeof(struct trs_async_jetty_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 1284 | + sizeof(struct trs_async_jetty_info)); |
| 1306 | - sizeof(struct trs_async_jetty_info)); | ||
| 1307 | free(reply.buf); | 1285 | free(reply.buf); |
| 1308 | 1286 | ||
| 1309 | return 0; | 1287 | return 0; |
| @@ -1318,8 +1296,8 @@ static int trs_async_dma_jetty_remote_free(uint32_t dev_id, struct trs_urma_star | |||
| 1318 | reply.buf_len = sizeof(result); | 1296 | reply.buf_len = sizeof(result); |
| 1319 | reply.buf = (char *)&result; | 1297 | reply.buf = (char *)&result; |
| 1320 | 1298 | ||
| 1321 | - ret = trs_local_mem_event_sync( | 1299 | + ret = trs_local_mem_event_sync(dev_id, &slave_jetty_addr, sizeof(struct trs_urma_stars_jetty *), |
| 1322 | - dev_id, &slave_jetty_addr, sizeof(struct trs_urma_stars_jetty *), DRV_SUBEVENT_TRS_FREE_JETTY_MSG, &reply); | 1300 | + DRV_SUBEVENT_TRS_FREE_JETTY_MSG, &reply); |
| 1323 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { | 1301 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { |
| 1324 | trs_err("Failed to sync event. (dev_id=%u; ret=%d; result=%d)\n", dev_id, ret, result); | 1302 | trs_err("Failed to sync event. (dev_id=%u; ret=%d; result=%d)\n", dev_id, ret, result); |
| 1325 | return (ret != DRV_ERROR_NONE) ? (int)ret : result; | 1303 | return (ret != DRV_ERROR_NONE) ? (int)ret : result; |
| @@ -1346,8 +1324,8 @@ static inline void trs_async_jetty_node_free(void *jetty_node) | |||
| 1346 | } | 1324 | } |
| 1347 | } | 1325 | } |
| 1348 | 1326 | ||
| 1349 | -drvError_t trs_async_dma_jetty_create( | 1327 | +drvError_t trs_async_dma_jetty_create(uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, |
| 1350 | - uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, struct halAsyncDmaJettyCreateOut *out) | 1328 | + struct halAsyncDmaJettyCreateOut *out) |
| 1351 | { | 1329 | { |
| 1352 | struct trs_async_jetty_node *jetty_node = NULL; | 1330 | struct trs_async_jetty_node *jetty_node = NULL; |
| 1353 | struct trs_async_jetty_info *jetty_info = NULL; | 1331 | struct trs_async_jetty_info *jetty_info = NULL; |
| @@ -1370,9 +1348,8 @@ drvError_t trs_async_dma_jetty_create( | |||
| 1370 | return ret; | 1348 | return ret; |
| 1371 | } | 1349 | } |
| 1372 | 1350 | ||
| 1373 | - ret = snprintf_s( | 1351 | + ret = snprintf_s(jetty_node->jettyHandle.handle, TRS_ASYNC_DMA_JETTY_HANDLE_LEN, TRS_ASYNC_DMA_JETTY_HANDLE_LEN - 1, |
| 1374 | - jetty_node->jettyHandle.handle, TRS_ASYNC_DMA_JETTY_HANDLE_LEN, TRS_ASYNC_DMA_JETTY_HANDLE_LEN - 1, | 1352 | + "%08x%08x%08x", jetty_info->die_id, jetty_info->func_id, jetty_info->jetty_id); |
| 1375 | - "%08x%08x%08x", jetty_info->die_id, jetty_info->func_id, jetty_info->jetty_id); | ||
| 1376 | if (ret < 0) { | 1353 | if (ret < 0) { |
| 1377 | trs_err("Failed to format jetty handle. (dev_id=%u; ret=%d)\n", dev_id, ret); | 1354 | trs_err("Failed to format jetty handle. (dev_id=%u; ret=%d)\n", dev_id, ret); |
| 1378 | ret = DRV_ERROR_INNER_ERR; | 1355 | ret = DRV_ERROR_INNER_ERR; |
| @@ -1385,8 +1362,8 @@ drvError_t trs_async_dma_jetty_create( | |||
| 1385 | } | 1362 | } |
| 1386 | 1363 | ||
| 1387 | (void)pthread_rwlock_wrlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1364 | (void)pthread_rwlock_wrlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1388 | - ret = hash_table_put2( | 1365 | + ret = hash_table_put2(g_jetty_mng_ctx[dev_id].hash_table, jetty_node->jettyHandle.handle, jetty_node, |
| 1389 | - g_jetty_mng_ctx[dev_id].hash_table, jetty_node->jettyHandle.handle, jetty_node, trs_async_jetty_node_free); | 1366 | + trs_async_jetty_node_free); |
| 1390 | if (ret != 0) { | 1367 | if (ret != 0) { |
| 1391 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1368 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1392 | trs_err("Failed to instert jetty node. (dev_id=%u; ret=%d)\n", dev_id, ret); | 1369 | trs_err("Failed to instert jetty node. (dev_id=%u; ret=%d)\n", dev_id, ret); |
| @@ -1436,8 +1413,8 @@ drvError_t trs_async_dma_jetty_destroy(uint32_t dev_id, struct halAsyncJettyDest | |||
| 1436 | if (ret != 0) { | 1413 | if (ret != 0) { |
| 1437 | trs_register_reg(dev_id, jetty_node->jetty_info.jetty_queue_base, jetty_node->jetty_info.jetty_queue_len); | 1414 | trs_register_reg(dev_id, jetty_node->jetty_info.jetty_queue_base, jetty_node->jetty_info.jetty_queue_len); |
| 1438 | (void)pthread_rwlock_wrlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1415 | (void)pthread_rwlock_wrlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1439 | - (void)hash_table_put2( | 1416 | + (void)hash_table_put2(g_jetty_mng_ctx[dev_id].hash_table, jetty_node->jettyHandle.handle, jetty_node, |
| 1440 | - g_jetty_mng_ctx[dev_id].hash_table, jetty_node->jettyHandle.handle, jetty_node, trs_async_jetty_node_free); | 1417 | + trs_async_jetty_node_free); |
| 1441 | g_jetty_mng_ctx[dev_id].node_num++; | 1418 | g_jetty_mng_ctx[dev_id].node_num++; |
| 1442 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1419 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1443 | return ret; | 1420 | return ret; |
| @@ -1447,8 +1424,8 @@ drvError_t trs_async_dma_jetty_destroy(uint32_t dev_id, struct halAsyncJettyDest | |||
| 1447 | return 0; | 1424 | return 0; |
| 1448 | } | 1425 | } |
| 1449 | 1426 | ||
| 1450 | -drvError_t trs_async_dma_jetty_query( | 1427 | +drvError_t trs_async_dma_jetty_query(uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, |
| 1451 | - uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, struct halAsyncDmaJettyQueryOut *out) | 1428 | + struct halAsyncDmaJettyQueryOut *out) |
| 1452 | { | 1429 | { |
| 1453 | struct trs_async_jetty_node *jetty_node = NULL; | 1430 | struct trs_async_jetty_node *jetty_node = NULL; |
| 1454 | 1431 | ||
| @@ -1473,9 +1450,8 @@ drvError_t trs_async_dma_jetty_query( | |||
| 1473 | return 0; | 1450 | return 0; |
| 1474 | } | 1451 | } |
| 1475 | 1452 | ||
| 1476 | -static int trs_async_dma_nop_wqe_convert( | 1453 | +static int trs_async_dma_nop_wqe_convert(struct trs_async_dma_input_para *input, uint8_t *wqe_buffer, |
| 1477 | - struct trs_async_dma_input_para *input, uint8_t *wqe_buffer, uint64_t wqe_bufferLen, | 1454 | + uint64_t wqe_bufferLen, struct halAsyncDmaWqeOutputPara *out) |
| 1478 | - struct halAsyncDmaWqeOutputPara *out) | ||
| 1479 | { | 1455 | { |
| 1480 | struct trs_urma_dwqe_fill_para fill_para = {0}; | 1456 | struct trs_urma_dwqe_fill_para fill_para = {0}; |
| 1481 | uint32_t credit = (uint32_t)(wqe_bufferLen / TRS_URMA_DWQE_LEN); | 1457 | uint32_t credit = (uint32_t)(wqe_bufferLen / TRS_URMA_DWQE_LEN); |
| @@ -1501,9 +1477,9 @@ static int trs_async_dma_nop_wqe_convert( | |||
| 1501 | return 0; | 1477 | return 0; |
| 1502 | } | 1478 | } |
| 1503 | 1479 | ||
| 1504 | -static int _trs_async_dma_copy_wqe_convert( | 1480 | +static int _trs_async_dma_copy_wqe_convert(struct trs_async_devid *async_devid, uint32_t dir, |
| 1505 | - struct trs_async_devid *async_devid, uint32_t dir, struct trs_async_addr_pack *addr_pack, uint8_t *wqe_buffer, | 1481 | + struct trs_async_addr_pack *addr_pack, uint8_t *wqe_buffer, |
| 1506 | - bool is_last_batch) | 1482 | + bool is_last_batch) |
| 1507 | { | 1483 | { |
| 1508 | struct trs_urma_dwqe_fill_para fill_para = {0}; | 1484 | struct trs_urma_dwqe_fill_para fill_para = {0}; |
| 1509 | uint32_t devid = async_devid->local_devid; | 1485 | uint32_t devid = async_devid->local_devid; |
| @@ -1537,9 +1513,8 @@ static int _trs_async_dma_copy_wqe_convert( | |||
| 1537 | 1513 | ||
| 1538 | ret = halMemGetSeg(devid, recv_addr, addr_pack->len, &fill_para.seg, &fill_para.token); | 1514 | ret = halMemGetSeg(devid, recv_addr, addr_pack->len, &fill_para.seg, &fill_para.token); |
| 1539 | if (ret != 0) { | 1515 | if (ret != 0) { |
| 1540 | - trs_err( | 1516 | + trs_err("Get token_id from svm failed. (devid=%u; va=0x%llx; len=0x%llx; ret=%d)\n", devid, recv_addr, |
| 1541 | - "Get token_id from svm failed. (devid=%u; va=0x%llx; len=0x%llx; ret=%d)\n", devid, recv_addr, | 1517 | + addr_pack->len, ret); |
| 1542 | - addr_pack->len, ret); | ||
| 1543 | return ret; | 1518 | return ret; |
| 1544 | } | 1519 | } |
| 1545 | 1520 | ||
| @@ -1547,8 +1522,8 @@ static int _trs_async_dma_copy_wqe_convert( | |||
| 1547 | for (i = 0; i < wqe_num; i++) { | 1522 | for (i = 0; i < wqe_num; i++) { |
| 1548 | fill_para.send_addr = send_addr + i * TRS_URMA_WR_CPY_MAX_SIZE; | 1523 | fill_para.send_addr = send_addr + i * TRS_URMA_WR_CPY_MAX_SIZE; |
| 1549 | fill_para.recv_addr = recv_addr + i * TRS_URMA_WR_CPY_MAX_SIZE; | 1524 | fill_para.recv_addr = recv_addr + i * TRS_URMA_WR_CPY_MAX_SIZE; |
| 1550 | - fill_para.len = | 1525 | + fill_para.len = (i == (wqe_num - 1)) ? (addr_pack->len - i * TRS_URMA_WR_CPY_MAX_SIZE) : |
| 1551 | - (i == (wqe_num - 1)) ? (addr_pack->len - i * TRS_URMA_WR_CPY_MAX_SIZE) : TRS_URMA_WR_CPY_MAX_SIZE; | 1526 | + TRS_URMA_WR_CPY_MAX_SIZE; |
| 1552 | fill_para.cqe_report = ((i == (wqe_num - 1)) && is_last_batch) ? 1 : 0; | 1527 | fill_para.cqe_report = ((i == (wqe_num - 1)) && is_last_batch) ? 1 : 0; |
| 1553 | _trs_fill_async_dma_direct_wqe(&fill_para, wqe_buffer + i * STARS_ASYNC_DMA_WQE_SIZE); | 1528 | _trs_fill_async_dma_direct_wqe(&fill_para, wqe_buffer + i * STARS_ASYNC_DMA_WQE_SIZE); |
| 1554 | } | 1529 | } |
| @@ -1570,9 +1545,9 @@ static inline bool trs_is_async_wqe_convert_complete(struct trs_async_dma_input_ | |||
| 1570 | } | 1545 | } |
| 1571 | } | 1546 | } |
| 1572 | 1547 | ||
| 1573 | -static int trs_async_dma_copy_wqe_convert( | 1548 | +static int trs_async_dma_copy_wqe_convert(struct trs_async_devid *async_devid, struct trs_async_dma_input_para *input, |
| 1574 | - struct trs_async_devid *async_devid, struct trs_async_dma_input_para *input, uint8_t *wqe_buffer, | 1549 | + uint8_t *wqe_buffer, uint64_t wqe_bufferLen, |
| 1575 | - uint64_t wqe_bufferLen, struct halAsyncDmaWqeOutputPara *out) | 1550 | + struct halAsyncDmaWqeOutputPara *out) |
| 1576 | { | 1551 | { |
| 1577 | unsigned long long *src_array, *dst_array, *src_len_array, *dst_len_array; | 1552 | unsigned long long *src_array, *dst_array, *src_len_array, *dst_len_array; |
| 1578 | uint8_t *dst_wqe_addr = wqe_buffer; | 1553 | uint8_t *dst_wqe_addr = wqe_buffer; |
| @@ -1613,14 +1588,14 @@ static int trs_async_dma_copy_wqe_convert( | |||
| 1613 | ((i == fixedVal) ? partial_fixed_size : src_len_array[absolute_index]); /* batch */ | 1588 | ((i == fixedVal) ? partial_fixed_size : src_len_array[absolute_index]); /* batch */ |
| 1614 | } | 1589 | } |
| 1615 | 1590 | ||
| 1616 | - ret = | 1591 | + ret = _trs_async_dma_copy_wqe_convert(async_devid, input->dir, &addr_pack, dst_wqe_addr, |
| 1617 | - _trs_async_dma_copy_wqe_convert(async_devid, input->dir, &addr_pack, dst_wqe_addr, (i == (batch_num - 1))); | 1592 | + (i == (batch_num - 1))); |
| 1618 | if (ret != 0) { | 1593 | if (ret != 0) { |
| 1619 | return ret; | 1594 | return ret; |
| 1620 | } | 1595 | } |
| 1621 | 1596 | ||
| 1622 | - dst_wqe_addr += | 1597 | + dst_wqe_addr += (align_up(addr_pack.len, TRS_URMA_WR_CPY_MAX_SIZE) / TRS_URMA_WR_CPY_MAX_SIZE) * |
| 1623 | - (align_up(addr_pack.len, TRS_URMA_WR_CPY_MAX_SIZE) / TRS_URMA_WR_CPY_MAX_SIZE) * STARS_ASYNC_DMA_WQE_SIZE; | 1598 | + STARS_ASYNC_DMA_WQE_SIZE; |
| 1624 | } | 1599 | } |
| 1625 | 1600 | ||
| 1626 | out->wqeCnt = wr_num; | 1601 | out->wqeCnt = wr_num; |
| @@ -1635,8 +1610,8 @@ static int trs_async_dma_copy_wqe_convert( | |||
| 1635 | return 0; | 1610 | return 0; |
| 1636 | } | 1611 | } |
| 1637 | 1612 | ||
| 1638 | -drvError_t trs_async_dma_wqe_convert( | 1613 | +drvError_t trs_async_dma_wqe_convert(uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, |
| 1639 | - uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, struct halAsyncDmaWqeOutputPara *out) | 1614 | + struct halAsyncDmaWqeOutputPara *out) |
| 1640 | { | 1615 | { |
| 1641 | struct trs_async_dma_input_para input = {0}; | 1616 | struct trs_async_dma_input_para input = {0}; |
| 1642 | struct trs_async_devid async_devid = {0}; | 1617 | struct trs_async_devid async_devid = {0}; |
| @@ -1692,20 +1667,17 @@ drvError_t trs_async_dma_jetty_fill(uint32_t dev_id, struct halAsyncDmaJettyFill | |||
| 1692 | 1667 | ||
| 1693 | if ((para->offset + para->size) > jetty_node->jetty_info.jetty_queue_len) { | 1668 | if ((para->offset + para->size) > jetty_node->jetty_info.jetty_queue_len) { |
| 1694 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1669 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1695 | - trs_err( | 1670 | + trs_err("Failed to fill jetty queue. (dev_id=%u; offset=0x%llx; size=0x%llx; len=0x%x; ret=%d)\n", dev_id, |
| 1696 | - "Failed to fill jetty queue. (dev_id=%u; offset=0x%llx; size=0x%llx; len=0x%x; ret=%d)\n", dev_id, | 1671 | + para->offset, para->size, jetty_node->jetty_info.jetty_queue_len, ret); |
| 1697 | - para->offset, para->size, jetty_node->jetty_info.jetty_queue_len, ret); | ||
| 1698 | return DRV_ERROR_PARA_ERROR; | 1672 | return DRV_ERROR_PARA_ERROR; |
| 1699 | } | 1673 | } |
| 1700 | 1674 | ||
| 1701 | - ret = halSvmAccess( | 1675 | + ret = halSvmAccess(dev_id, jetty_node->jetty_info.jetty_queue_base + para->offset, |
| 1702 | - dev_id, jetty_node->jetty_info.jetty_queue_base + para->offset, (uint64_t)(uintptr_t)para->srcWqe, para->size, | 1676 | + (uint64_t)(uintptr_t)para->srcWqe, para->size, SVM_MEM_ACCESS_WRITE); |
| 1703 | - SVM_MEM_ACCESS_WRITE); | ||
| 1704 | if (ret != DRV_ERROR_NONE) { | 1677 | if (ret != DRV_ERROR_NONE) { |
| 1705 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); | 1678 | (void)pthread_rwlock_unlock(&g_jetty_mng_ctx[dev_id].rw_mutex); |
| 1706 | - trs_err( | 1679 | + trs_err("Failed to fill jetty queue. (dev_id=%u; addr=0x%llx; offset=0x%llx; src=%px; len=0x%llx; ret=%d)\n", |
| 1707 | - "Failed to fill jetty queue. (dev_id=%u; addr=0x%llx; offset=0x%llx; src=%px; len=0x%llx; ret=%d)\n", | 1680 | + dev_id, jetty_node->jetty_info.jetty_queue_base, para->offset, para->srcWqe, para->size, ret); |
| 1708 | - dev_id, jetty_node->jetty_info.jetty_queue_base, para->offset, para->srcWqe, para->size, ret); | ||
| 1709 | return ret; | 1681 | return ret; |
| 1710 | } | 1682 | } |
| 1711 | 1683 | ||
| @@ -20,8 +20,8 @@ struct trs_async_devid { | |||
| 20 | uint32_t remote_devid; | 20 | uint32_t remote_devid; |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | -static inline void trs_pack_async_devid( | 23 | +static inline void trs_pack_async_devid(uint32_t local_devid, uint32_t src_devid, uint32_t dst_devid, |
| 24 | - uint32_t local_devid, uint32_t src_devid, uint32_t dst_devid, struct trs_async_devid *async_devid) | 24 | + struct trs_async_devid *async_devid) |
| 25 | { | 25 | { |
| 26 | async_devid->local_devid = local_devid; | 26 | async_devid->local_devid = local_devid; |
| 27 | async_devid->remote_devid = (src_devid == local_devid) ? dst_devid : src_devid; | 27 | async_devid->remote_devid = (src_devid == local_devid) ? dst_devid : src_devid; |
| @@ -29,16 +29,16 @@ static inline void trs_pack_async_devid( | |||
| 29 | async_devid->dst_devid = dst_devid; | 29 | async_devid->dst_devid = dst_devid; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | -drvError_t trs_async_dma_wqe_create( | 32 | +drvError_t trs_async_dma_wqe_create(uint32_t dev_id, struct trs_async_dma_input_para *in, |
| 33 | - uint32_t dev_id, struct trs_async_dma_input_para *in, struct halAsyncDmaOutputPara *out); | 33 | + struct halAsyncDmaOutputPara *out); |
| 34 | drvError_t trs_async_dma_wqe_destory(uint32_t dev_id, struct trs_async_dma_destroy_para *para); | 34 | drvError_t trs_async_dma_wqe_destory(uint32_t dev_id, struct trs_async_dma_destroy_para *para); |
| 35 | -drvError_t trs_async_dma_wqe_convert( | 35 | +drvError_t trs_async_dma_wqe_convert(uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, |
| 36 | - uint32_t dev_id, struct halAsyncDmaWqeInputPara *in, struct halAsyncDmaWqeOutputPara *out); | 36 | + struct halAsyncDmaWqeOutputPara *out); |
| 37 | -drvError_t trs_async_dma_jetty_create( | 37 | +drvError_t trs_async_dma_jetty_create(uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, |
| 38 | - uint32_t dev_id, struct halAsyncDmaJettyCreateIn *in, struct halAsyncDmaJettyCreateOut *out); | 38 | + struct halAsyncDmaJettyCreateOut *out); |
| 39 | drvError_t trs_async_dma_jetty_destroy(uint32_t dev_id, struct halAsyncJettyDestroyPara *para); | 39 | drvError_t trs_async_dma_jetty_destroy(uint32_t dev_id, struct halAsyncJettyDestroyPara *para); |
| 40 | -drvError_t trs_async_dma_jetty_query( | 40 | +drvError_t trs_async_dma_jetty_query(uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, |
| 41 | - uint32_t dev_id, struct halAsyncDmaJettyQueryIn *in, struct halAsyncDmaJettyQueryOut *out); | 41 | + struct halAsyncDmaJettyQueryOut *out); |
| 42 | drvError_t trs_async_dma_jetty_fill(uint32_t dev_id, struct halAsyncDmaJettyFillInfo *para); | 42 | drvError_t trs_async_dma_jetty_fill(uint32_t dev_id, struct halAsyncDmaJettyFillInfo *para); |
| 43 | int trs_destroy_remote_d2d_jetty(uint32_t dev_id); | 43 | int trs_destroy_remote_d2d_jetty(uint32_t dev_id); |
| 44 | int trs_async_uninit_async_ctx(uint32_t dev_id, uint32_t sq_id, void *master_ctx); | 44 | int trs_async_uninit_async_ctx(uint32_t dev_id, uint32_t sq_id, void *master_ctx); |
| @@ -31,7 +31,10 @@ | |||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | -#define trs_smp_wmb { asm volatile("dmb st" ::: "memory"); } | 34 | +#define trs_smp_wmb \ |
| 35 | + { \ | ||
| 36 | + asm volatile("dmb st" ::: "memory"); \ | ||
| 37 | + } | ||
| 35 | 38 | ||
| 36 | 39 | ||
| 37 | 40 | ||
| @@ -56,8 +59,8 @@ static urma_jfc_t **g_wait_jfc_buffer = NULL; | |||
| 56 | static uint32_t g_wait_jfc_buffer_num = 0; | 59 | static uint32_t g_wait_jfc_buffer_num = 0; |
| 57 | static urma_cr_t *g_poll_jfc_cr = NULL; | 60 | static urma_cr_t *g_poll_jfc_cr = NULL; |
| 58 | 61 | ||
| 59 | -drvError_t __attribute__((weak)) halSvmAccessRegister( | 62 | +drvError_t __attribute__((weak)) halSvmAccessRegister(uint32_t dev_id, uint64_t va, uint64_t size, uint64_t flag, |
| 60 | - uint32_t dev_id, uint64_t va, uint64_t size, uint64_t flag, uint64_t *access_va) | 63 | + uint64_t *access_va) |
| 61 | { | 64 | { |
| 62 | (void)dev_id; | 65 | (void)dev_id; |
| 63 | (void)size; | 66 | (void)size; |
| @@ -96,8 +99,8 @@ drvError_t trs_register_reg(uint32_t dev_id, uint64_t va, uint32_t size) | |||
| 96 | 99 | ||
| 97 | ret = halSvmAccessRegister(dev_id, align_va, align_len, SVM_REGISTER_FLAG_ACCESS_BY_DMA, &addr); | 100 | ret = halSvmAccessRegister(dev_id, align_va, align_len, SVM_REGISTER_FLAG_ACCESS_BY_DMA, &addr); |
| 98 | if (ret != DRV_ERROR_NONE) { | 101 | if (ret != DRV_ERROR_NONE) { |
| 99 | - trs_err( | 102 | + trs_err("Failed to register SVM. (dev_id=%u; va=0x%llx; len=%u; ret=%d)\n", dev_id, align_va, align_len, |
| 100 | - "Failed to register SVM. (dev_id=%u; va=0x%llx; len=%u; ret=%d)\n", dev_id, align_va, align_len, ret); | 103 | + ret); |
| 101 | return DRV_ERROR_INNER_ERR; | 104 | return DRV_ERROR_INNER_ERR; |
| 102 | } | 105 | } |
| 103 | 106 | ||
| @@ -116,8 +119,8 @@ void trs_unregister_reg(uint32_t dev_id, uint64_t va, uint32_t size) | |||
| 116 | } | 119 | } |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 119 | -static drvError_t trs_urma_res_id_config( | 122 | +static drvError_t trs_urma_res_id_config(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t resource_id, |
| 120 | - uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t resource_id, uint32_t value) | 123 | + uint32_t value) |
| 121 | { | 124 | { |
| 122 | struct res_id_usr_info *info = NULL; | 125 | struct res_id_usr_info *info = NULL; |
| 123 | int ret; | 126 | int ret; |
| @@ -134,12 +137,11 @@ static drvError_t trs_urma_res_id_config( | |||
| 134 | return ret; | 137 | return ret; |
| 135 | } | 138 | } |
| 136 | } | 139 | } |
| 137 | - ret = halSvmAccess( | 140 | + ret = halSvmAccess(dev_id, (uint64_t)info->res_addr, (uint64_t)(uintptr_t)&value, info->res_len, |
| 138 | - dev_id, (uint64_t)info->res_addr, (uint64_t)(uintptr_t)&value, info->res_len, SVM_MEM_ACCESS_WRITE); | 141 | + SVM_MEM_ACCESS_WRITE); |
| 139 | if (ret != DRV_ERROR_NONE) { | 142 | if (ret != DRV_ERROR_NONE) { |
| 140 | - trs_err( | 143 | + trs_err("Failed to config res. (dev_id=%u; ts_id=%u; res_type=%d; res_id=%u; va=0x%llx; len=%u; ret=%d)\n", |
| 141 | - "Failed to config res. (dev_id=%u; ts_id=%u; res_type=%d; res_id=%u; va=0x%llx; len=%u; ret=%d)\n", dev_id, | 144 | + dev_id, ts_id, type, resource_id, info->res_addr, info->res_len, ret); |
| 142 | - ts_id, type, resource_id, info->res_addr, info->res_len, ret); | ||
| 143 | } | 145 | } |
| 144 | return ret; | 146 | return ret; |
| 145 | } | 147 | } |
| @@ -168,9 +170,15 @@ uint32_t trs_get_jfs_depth(void) | |||
| 168 | return 8192U; /* 8192U: max jetty depth, which * (max_sge * 16 / 64 + 1) equal to 32k */ | 170 | return 8192U; /* 8192U: max jetty depth, which * (max_sge * 16 / 64 + 1) equal to 32k */ |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | -uint32_t trs_get_jfc_depth(void) { return 5000U; /* 64: minimum jfc depth in urma */ } | 173 | +uint32_t trs_get_jfc_depth(void) |
| 174 | +{ | ||
| 175 | + return 5000U; /* 64: minimum jfc depth in urma */ | ||
| 176 | +} | ||
| 172 | 177 | ||
| 173 | -uint32_t trs_get_jfr_depth(void) { return 64U; /* 64: minimum jfr depth in urma */ } | 178 | +uint32_t trs_get_jfr_depth(void) |
| 179 | +{ | ||
| 180 | + return 64U; /* 64: minimum jfr depth in urma */ | ||
| 181 | +} | ||
| 174 | 182 | ||
| 175 | extern int halMemGetSeg(uint32_t dev_id, uint64_t va, uint64_t size, urma_seg_t *seg, urma_token_t *token); | 183 | extern int halMemGetSeg(uint32_t dev_id, uint64_t va, uint64_t size, urma_seg_t *seg, urma_token_t *token); |
| 176 | drvError_t trs_master_register_segment(uint32_t dev_id, struct sqcq_usr_info *sq_info, uint32_t sq_id) | 184 | drvError_t trs_master_register_segment(uint32_t dev_id, struct sqcq_usr_info *sq_info, uint32_t sq_id) |
| @@ -181,13 +189,12 @@ drvError_t trs_master_register_segment(uint32_t dev_id, struct sqcq_usr_info *sq | |||
| 181 | void *notify_buffer = NULL; | 189 | void *notify_buffer = NULL; |
| 182 | urma_seg_cfg_t seg_cfg = {0}; | 190 | urma_seg_cfg_t seg_cfg = {0}; |
| 183 | int ret = 0; | 191 | int ret = 0; |
| 184 | - urma_reg_seg_flag_t flag = { | 192 | + urma_reg_seg_flag_t flag = {.bs.token_policy = URMA_TOKEN_PLAIN_TEXT, |
| 185 | - .bs.token_policy = URMA_TOKEN_PLAIN_TEXT, | 193 | + .bs.cacheable = URMA_NON_CACHEABLE, |
| 186 | - .bs.cacheable = URMA_NON_CACHEABLE, | 194 | + .bs.access = URMA_ACCESS_READ | URMA_ACCESS_WRITE | URMA_ACCESS_ATOMIC, |
| 187 | - .bs.access = URMA_ACCESS_READ | URMA_ACCESS_WRITE | URMA_ACCESS_ATOMIC, | 195 | + .bs.non_pin = 1, /* alloc_pages memory need non pin, malloc need pin */ |
| 188 | - .bs.non_pin = 1, /* alloc_pages memory need non pin, malloc need pin */ | 196 | + .bs.token_id_valid = 1, |
| 189 | - .bs.token_id_valid = 1, | 197 | + .bs.reserved = 0}; |
| 190 | - .bs.reserved = 0}; | ||
| 191 | 198 | ||
| 192 | if (trs_is_sq_init_without_sq_mem(sq_info->flag)) { | 199 | if (trs_is_sq_init_without_sq_mem(sq_info->flag)) { |
| 193 | return 0; | 200 | return 0; |
| @@ -206,9 +213,8 @@ drvError_t trs_master_register_segment(uint32_t dev_id, struct sqcq_usr_info *sq | |||
| 206 | return DRV_ERROR_INNER_ERR; | 213 | return DRV_ERROR_INNER_ERR; |
| 207 | } | 214 | } |
| 208 | 215 | ||
| 209 | - ret = halMemAlloc( | 216 | + ret = halMemAlloc(¬ify_buffer, (sq_info->depth * 8), |
| 210 | - ¬ify_buffer, (sq_info->depth * 8), | 217 | + MEM_HOST | MEM_TYPE_DDR | ((uint64_t)TSDRV_MODULE_ID << MEM_MODULE_ID_BIT)); |
| 211 | - MEM_HOST | MEM_TYPE_DDR | ((uint64_t)TSDRV_MODULE_ID << MEM_MODULE_ID_BIT)); | ||
| 212 | if (ret != DRV_ERROR_NONE) { | 218 | if (ret != DRV_ERROR_NONE) { |
| 213 | (void)urma_unregister_seg(urma_ctx->local_tseg); | 219 | (void)urma_unregister_seg(urma_ctx->local_tseg); |
| 214 | trs_err("Alloc host notify buffer mem fail. (devid=%u; ret=%d)\n", dev_id, ret); | 220 | trs_err("Alloc host notify buffer mem fail. (devid=%u; ret=%d)\n", dev_id, ret); |
| @@ -219,9 +225,8 @@ drvError_t trs_master_register_segment(uint32_t dev_id, struct sqcq_usr_info *sq | |||
| 219 | if (ret != 0) { | 225 | if (ret != 0) { |
| 220 | (void)halMemFree(notify_buffer); | 226 | (void)halMemFree(notify_buffer); |
| 221 | (void)urma_unregister_seg(urma_ctx->local_tseg); | 227 | (void)urma_unregister_seg(urma_ctx->local_tseg); |
| 222 | - trs_err( | 228 | + trs_err("Failed to get src segment. (ret=%d; va=0x%llx; depth=%u)\n", ret, (uint64_t)(uintptr_t)notify_buffer, |
| 223 | - "Failed to get src segment. (ret=%d; va=0x%llx; depth=%u)\n", ret, (uint64_t)(uintptr_t)notify_buffer, | 229 | + sq_info->depth); |
| 224 | - sq_info->depth); | ||
| 225 | return ret; | 230 | return ret; |
| 226 | } | 231 | } |
| 227 | 232 | ||
| @@ -244,8 +249,8 @@ static void trs_master_unregister_segment(struct trs_urma_ctx *urma_ctx) | |||
| 244 | } | 249 | } |
| 245 | } | 250 | } |
| 246 | 251 | ||
| 247 | -int trs_remote_urma_info_init( | 252 | +int trs_remote_urma_info_init(struct trs_urma_ctx *urma_ctx, struct halSqCqInputInfo *in, |
| 248 | - struct trs_urma_ctx *urma_ctx, struct halSqCqInputInfo *in, struct trs_remote_sync_info *sync_info) | 253 | + struct trs_remote_sync_info *sync_info) |
| 249 | { | 254 | { |
| 250 | urma_import_seg_flag_t flag = trs_get_seg_import_flag(); | 255 | urma_import_seg_flag_t flag = trs_get_seg_import_flag(); |
| 251 | struct trs_urma_proc_ctx *proc_ctx = trs_get_urma_proc_ctx(urma_ctx->devid); | 256 | struct trs_urma_proc_ctx *proc_ctx = trs_get_urma_proc_ctx(urma_ctx->devid); |
| @@ -291,8 +296,8 @@ int trs_remote_urma_info_init( | |||
| 291 | trs_err("Failed to import remote sq queue segment.\n"); | 296 | trs_err("Failed to import remote sq queue segment.\n"); |
| 292 | return DRV_ERROR_INNER_ERR; | 297 | return DRV_ERROR_INNER_ERR; |
| 293 | } | 298 | } |
| 294 | - urma_ctx->sq_tail_tseg = | 299 | + urma_ctx->sq_tail_tseg = urma_import_seg(urma_ctx->urma_ctx, &sync_info->sq_tail_seg, &sync_info->token, 0, |
| 295 | - urma_import_seg(urma_ctx->urma_ctx, &sync_info->sq_tail_seg, &sync_info->token, 0, flag); | 300 | + flag); |
| 296 | if (urma_ctx->sq_tail_tseg == NULL) { | 301 | if (urma_ctx->sq_tail_tseg == NULL) { |
| 297 | trs_err("Failed to import remote sq tail segment.\n"); | 302 | trs_err("Failed to import remote sq tail segment.\n"); |
| 298 | (void)urma_unimport_seg(urma_ctx->sq_que_tseg); | 303 | (void)urma_unimport_seg(urma_ctx->sq_que_tseg); |
| @@ -394,8 +399,8 @@ static inline void trs_master_urma_ctx_jfs_uninit(struct trs_urma_ctx *master_ct | |||
| 394 | trs_destroy_jfs(&master_ctx->trs_jfs); | 399 | trs_destroy_jfs(&master_ctx->trs_jfs); |
| 395 | } | 400 | } |
| 396 | 401 | ||
| 397 | -static int trs_sqcq_remote_alloc_with_urma( | 402 | +static int trs_sqcq_remote_alloc_with_urma(uint32_t dev_id, struct halSqCqInputInfo *in, struct trs_urma_ctx *urma_ctx, |
| 398 | - uint32_t dev_id, struct halSqCqInputInfo *in, struct trs_urma_ctx *urma_ctx, struct trs_remote_sync_info *sync_info) | 403 | + struct trs_remote_sync_info *sync_info) |
| 399 | { | 404 | { |
| 400 | struct event_reply reply; | 405 | struct event_reply reply; |
| 401 | void *sync_msg = NULL; | 406 | void *sync_msg = NULL; |
| @@ -417,18 +422,17 @@ static int trs_sqcq_remote_alloc_with_urma( | |||
| 417 | return DRV_ERROR_OUT_OF_MEMORY; | 422 | return DRV_ERROR_OUT_OF_MEMORY; |
| 418 | } | 423 | } |
| 419 | ret = memcpy_s(sync_msg, sync_msg_len, in, sizeof(struct halSqCqInputInfo)); | 424 | ret = memcpy_s(sync_msg, sync_msg_len, in, sizeof(struct halSqCqInputInfo)); |
| 420 | - ret |= memcpy_s( | 425 | + ret |= memcpy_s((void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo)), |
| 421 | - (void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo)), sync_msg_len - sizeof(struct halSqCqInputInfo), | 426 | + sync_msg_len - sizeof(struct halSqCqInputInfo), &urma_ctx->trs_jfr.jfr->jfr_id, |
| 422 | - &urma_ctx->trs_jfr.jfr->jfr_id, sizeof(urma_jfr_id_t)); | 427 | + sizeof(urma_jfr_id_t)); |
| 423 | - ret |= memcpy_s( | 428 | + ret |= memcpy_s((void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo) + sizeof(urma_jfr_id_t)), |
| 424 | - (void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo) + sizeof(urma_jfr_id_t)), | 429 | + sync_msg_len - sizeof(struct halSqCqInputInfo) - sizeof(urma_jfr_id_t), &urma_ctx->token, |
| 425 | - sync_msg_len - sizeof(struct halSqCqInputInfo) - sizeof(urma_jfr_id_t), &urma_ctx->token, sizeof(urma_token_t)); | 430 | + sizeof(urma_token_t)); |
| 426 | if ((in->ext_info != NULL) && (in->ext_info_len != 0)) { | 431 | if ((in->ext_info != NULL) && (in->ext_info_len != 0)) { |
| 427 | - ret |= memcpy_s( | 432 | + ret |= memcpy_s((void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo) + sizeof(urma_jfr_id_t) + |
| 428 | - (void *)((uintptr_t)sync_msg + sizeof(struct halSqCqInputInfo) + sizeof(urma_jfr_id_t) + | 433 | + sizeof(urma_token_t)), |
| 429 | - sizeof(urma_token_t)), | 434 | + sync_msg_len - sizeof(struct halSqCqInputInfo) - sizeof(urma_jfr_id_t) - sizeof(urma_token_t), |
| 430 | - sync_msg_len - sizeof(struct halSqCqInputInfo) - sizeof(urma_jfr_id_t) - sizeof(urma_token_t), in->ext_info, | 435 | + in->ext_info, in->ext_info_len); |
| 431 | - in->ext_info_len); | ||
| 432 | } | 436 | } |
| 433 | if (ret != 0) { | 437 | if (ret != 0) { |
| 434 | free(reply.buf); | 438 | free(reply.buf); |
| @@ -440,16 +444,15 @@ static int trs_sqcq_remote_alloc_with_urma( | |||
| 440 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 444 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 441 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { | 445 | if ((ret != DRV_ERROR_NONE) || (result != 0)) { |
| 442 | trs_err_if(((ret != DRV_ERROR_NONE) || (result != DRV_ERROR_NO_RESOURCES)), | 446 | trs_err_if(((ret != DRV_ERROR_NONE) || (result != DRV_ERROR_NO_RESOURCES)), |
| 443 | - "Sync event. (dev_id=%u; ret=%d; result=%d)\n", dev_id, ret, result); | 447 | + "Sync event. (dev_id=%u; ret=%d; result=%d)\n", dev_id, ret, result); |
| 444 | ret = (ret != DRV_ERROR_NONE) ? ret : result; | 448 | ret = (ret != DRV_ERROR_NONE) ? ret : result; |
| 445 | free(reply.buf); | 449 | free(reply.buf); |
| 446 | free(sync_msg); | 450 | free(sync_msg); |
| 447 | return ret; | 451 | return ret; |
| 448 | } | 452 | } |
| 449 | 453 | ||
| 450 | - (void)memcpy_s( | 454 | + (void)memcpy_s(sync_info, sizeof(struct trs_remote_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 451 | - sync_info, sizeof(struct trs_remote_sync_info), DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 455 | + sizeof(struct trs_remote_sync_info)); |
| 452 | - sizeof(struct trs_remote_sync_info)); | ||
| 453 | 456 | ||
| 454 | free(reply.buf); | 457 | free(reply.buf); |
| 455 | free(sync_msg); | 458 | free(sync_msg); |
| @@ -464,8 +467,8 @@ static int trs_sqcq_remote_free_with_urma(uint32_t dev_id, struct halSqCqFreeInf | |||
| 464 | 467 | ||
| 465 | reply.buf_len = sizeof(result); | 468 | reply.buf_len = sizeof(result); |
| 466 | reply.buf = (char *)&result; | 469 | reply.buf = (char *)&result; |
| 467 | - ret = trs_local_mem_event_sync( | 470 | + ret = trs_local_mem_event_sync(dev_id, in, sizeof(struct halSqCqFreeInfo), DRV_SUBEVENT_TRS_FREE_SQCQ_WITH_URMA_MSG, |
| 468 | - dev_id, in, sizeof(struct halSqCqFreeInfo), DRV_SUBEVENT_TRS_FREE_SQCQ_WITH_URMA_MSG, &reply); | 471 | + &reply); |
| 469 | if ((ret != 0) || (result != 0)) { | 472 | if ((ret != 0) || (result != 0)) { |
| 470 | trs_err("Failed to sync sqcq free event. (ret=%d; result=%d)\n", ret, result); | 473 | trs_err("Failed to sync sqcq free event. (ret=%d; result=%d)\n", ret, result); |
| 471 | return (ret != 0) ? ret : result; | 474 | return (ret != 0) ? ret : result; |
| @@ -474,8 +477,8 @@ static int trs_sqcq_remote_free_with_urma(uint32_t dev_id, struct halSqCqFreeInf | |||
| 474 | return 0; | 477 | return 0; |
| 475 | } | 478 | } |
| 476 | 479 | ||
| 477 | -static drvError_t trs_remote_sqcq_alloc_with_urma( | 480 | +static drvError_t trs_remote_sqcq_alloc_with_urma(uint32_t dev_id, struct trs_urma_ctx *master_ctx, |
| 478 | - uint32_t dev_id, struct trs_urma_ctx *master_ctx, struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out) | 481 | + struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out) |
| 479 | { | 482 | { |
| 480 | struct trs_remote_sync_info sync_info = {0}; | 483 | struct trs_remote_sync_info sync_info = {0}; |
| 481 | struct halSqCqFreeInfo free_in; | 484 | struct halSqCqFreeInfo free_in; |
| @@ -506,8 +509,8 @@ static drvError_t trs_remote_sqcq_alloc_with_urma( | |||
| 506 | return DRV_ERROR_NONE; | 509 | return DRV_ERROR_NONE; |
| 507 | } | 510 | } |
| 508 | 511 | ||
| 509 | -drvError_t trs_remote_sq_cq_free_with_urma( | 512 | +drvError_t trs_remote_sq_cq_free_with_urma(uint32_t dev_id, struct halSqCqFreeInfo *in, struct trs_urma_ctx *urma_ctx, |
| 510 | - uint32_t dev_id, struct halSqCqFreeInfo *in, struct trs_urma_ctx *urma_ctx, bool remote_free_flag) | 513 | + bool remote_free_flag) |
| 511 | { | 514 | { |
| 512 | drvError_t ret; | 515 | drvError_t ret; |
| 513 | 516 | ||
| @@ -515,8 +518,8 @@ drvError_t trs_remote_sq_cq_free_with_urma( | |||
| 515 | if (remote_free_flag) { | 518 | if (remote_free_flag) { |
| 516 | ret = trs_sqcq_remote_free_with_urma(dev_id, in); | 519 | ret = trs_sqcq_remote_free_with_urma(dev_id, in); |
| 517 | if (ret != 0) { | 520 | if (ret != 0) { |
| 518 | - trs_err( | 521 | + trs_err("Failed free sqcq with urma. (ret=%d; dev_id=%u; sqid=%u; cqid=%u)\n", ret, dev_id, in->sqId, |
| 519 | - "Failed free sqcq with urma. (ret=%d; dev_id=%u; sqid=%u; cqid=%u)\n", ret, dev_id, in->sqId, in->cqId); | 522 | + in->cqId); |
| 520 | return ret; | 523 | return ret; |
| 521 | } | 524 | } |
| 522 | } | 525 | } |
| @@ -526,8 +529,8 @@ drvError_t trs_remote_sq_cq_free_with_urma( | |||
| 526 | return DRV_ERROR_NONE; | 529 | return DRV_ERROR_NONE; |
| 527 | } | 530 | } |
| 528 | 531 | ||
| 529 | -static drvError_t trs_local_sq_cq_alloc_with_urma( | 532 | +static drvError_t trs_local_sq_cq_alloc_with_urma(uint32_t dev_id, struct trs_urma_ctx *master_ctx, |
| 530 | - uint32_t dev_id, struct trs_urma_ctx *master_ctx, struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out) | 533 | + struct halSqCqInputInfo *in, struct halSqCqOutputInfo *out) |
| 531 | { | 534 | { |
| 532 | struct sqcq_usr_info *sq_info = NULL; | 535 | struct sqcq_usr_info *sq_info = NULL; |
| 533 | struct halSqCqFreeInfo free_in; | 536 | struct halSqCqFreeInfo free_in; |
| @@ -538,8 +541,8 @@ static drvError_t trs_local_sq_cq_alloc_with_urma( | |||
| 538 | in->flag &= (uint32_t)(~TSDRV_FLAG_RANGE_ID); | 541 | in->flag &= (uint32_t)(~TSDRV_FLAG_RANGE_ID); |
| 539 | ret = trs_local_sqcq_alloc(dev_id, in, out); | 542 | ret = trs_local_sqcq_alloc(dev_id, in, out); |
| 540 | if (ret != DRV_ERROR_NONE) { | 543 | if (ret != DRV_ERROR_NONE) { |
| 541 | - trs_err( | 544 | + trs_err("Failed to alloc sqcq with specified id. (dev_id=%u; sq_id=%u; cq_id=%u)\n", dev_id, in->sqId, |
| 542 | - "Failed to alloc sqcq with specified id. (dev_id=%u; sq_id=%u; cq_id=%u)\n", dev_id, in->sqId, in->cqId); | 545 | + in->cqId); |
| 543 | return ret; | 546 | return ret; |
| 544 | } | 547 | } |
| 545 | 548 | ||
| @@ -564,8 +567,8 @@ static drvError_t trs_local_sq_cq_alloc_with_urma( | |||
| 564 | return ret; | 567 | return ret; |
| 565 | } | 568 | } |
| 566 | 569 | ||
| 567 | -static drvError_t trs_local_sq_cq_free_with_urma( | 570 | +static drvError_t trs_local_sq_cq_free_with_urma(uint32_t dev_id, struct halSqCqFreeInfo *info, |
| 568 | - uint32_t dev_id, struct halSqCqFreeInfo *info, struct trs_urma_ctx *urma_ctx) | 571 | + struct trs_urma_ctx *urma_ctx) |
| 569 | { | 572 | { |
| 570 | uint32_t flag = info->flag; | 573 | uint32_t flag = info->flag; |
| 571 | drvError_t ret; | 574 | drvError_t ret; |
| @@ -620,13 +623,13 @@ drvError_t trs_sqcq_urma_alloc(uint32_t dev_id, struct halSqCqInputInfo *in, str | |||
| 620 | in->cqId = remote_out.cqId; | 623 | in->cqId = remote_out.cqId; |
| 621 | ret = trs_local_sq_cq_alloc_with_urma(dev_id, master_ctx, in, out); | 624 | ret = trs_local_sq_cq_alloc_with_urma(dev_id, master_ctx, in, out); |
| 622 | if (ret != 0) { | 625 | if (ret != 0) { |
| 623 | - trs_err("Failed to alloc sqcq with specified id. (ret=%d; dev_id=%u; sq_id=%u; cq_id=%u)\n", | 626 | + trs_err("Failed to alloc sqcq with specified id. (ret=%d; dev_id=%u; sq_id=%u; cq_id=%u)\n", ret, dev_id, |
| 624 | - ret, dev_id, remote_out.sqId, remote_out.cqId); | 627 | + remote_out.sqId, remote_out.cqId); |
| 625 | goto local_sqcq_alloc_fail; | 628 | goto local_sqcq_alloc_fail; |
| 626 | } | 629 | } |
| 627 | 630 | ||
| 628 | - trs_debug("Alloc sqcq success. (dev_id=%u; sqid=%u; cqid=%u; jfs_id=%u; jfc_id=%u)\n", | 631 | + trs_debug("Alloc sqcq success. (dev_id=%u; sqid=%u; cqid=%u; jfs_id=%u; jfc_id=%u)\n", dev_id, in->sqId, in->cqId, |
| 629 | - dev_id, in->sqId, in->cqId, master_ctx->trs_jfs.jfs->jfs_id.id , master_ctx->trs_jfs.trs_jfc.jfc->jfc_id.id); | 632 | + master_ctx->trs_jfs.jfs->jfs_id.id, master_ctx->trs_jfs.trs_jfc.jfc->jfc_id.id); |
| 630 | return DRV_ERROR_NONE; | 633 | return DRV_ERROR_NONE; |
| 631 | 634 | ||
| 632 | local_sqcq_alloc_fail: | 635 | local_sqcq_alloc_fail: |
| @@ -722,8 +725,8 @@ static int trs_jfs_wqe_credit_poll(uint32_t dev_id, struct trs_urma_jfs *trs_jfs | |||
| 722 | if (g_poll_jfc_cr[i].status != URMA_CR_SUCCESS) { | 725 | if (g_poll_jfc_cr[i].status != URMA_CR_SUCCESS) { |
| 723 | poll_failed = true; | 726 | poll_failed = true; |
| 724 | trs_err("Cr status abnormal. (index=%d, cr_status=%d; cnt=%u; jfs_id=%u; jfc_id=%u; sq_id=%u; dev_id=%u)", | 727 | trs_err("Cr status abnormal. (index=%d, cr_status=%d; cnt=%u; jfs_id=%u; jfc_id=%u; sq_id=%u; dev_id=%u)", |
| 725 | - i, g_poll_jfc_cr[i].status, cnt, trs_jfs->jfs->jfs_id.id , trs_jfs->trs_jfc.jfc->jfc_id.id, | 728 | + i, g_poll_jfc_cr[i].status, cnt, trs_jfs->jfs->jfs_id.id, trs_jfs->trs_jfc.jfc->jfc_id.id, |
| 726 | - trs_jfs->trs_jfc.jfc->jfc_cfg.user_ctx, dev_id); | 729 | + trs_jfs->trs_jfc.jfc->jfc_cfg.user_ctx, dev_id); |
| 727 | } | 730 | } |
| 728 | } | 731 | } |
| 729 | 732 | ||
| @@ -731,8 +734,8 @@ static int trs_jfs_wqe_credit_poll(uint32_t dev_id, struct trs_urma_jfs *trs_jfs | |||
| 731 | trs_urma_get_jfc_opt(trs_jfs->trs_jfc.jfc); | 734 | trs_urma_get_jfc_opt(trs_jfs->trs_jfc.jfc); |
| 732 | } | 735 | } |
| 733 | 736 | ||
| 734 | - trs_debug("Polled jfc cqe. (jfs_id=%u; jfc_id=%u; sq_id=%u; dev_id=%u; cnt=%d)\n", | 737 | + trs_debug("Polled jfc cqe. (jfs_id=%u; jfc_id=%u; sq_id=%u; dev_id=%u; cnt=%d)\n", trs_jfs->jfs->jfs_id.id, |
| 735 | - trs_jfs->jfs->jfs_id.id , trs_jfs->trs_jfc.jfc->jfc_id.id, trs_jfs->trs_jfc.jfc->jfc_cfg.user_ctx, dev_id, cnt); | 738 | + trs_jfs->trs_jfc.jfc->jfc_id.id, trs_jfs->trs_jfc.jfc->jfc_cfg.user_ctx, dev_id, cnt); |
| 736 | return DRV_ERROR_NONE; | 739 | return DRV_ERROR_NONE; |
| 737 | } | 740 | } |
| 738 | 741 | ||
| @@ -796,8 +799,7 @@ static void trs_urma_poll_waited_jfc(uint32_t dev_id, urma_jfc_t *wait_jfc) | |||
| 796 | trs_debug("Start to poll. (dev_id=%u; sq_id=%u)\n", dev_id, (uint32_t)wait_jfc->jfc_cfg.user_ctx); | 799 | trs_debug("Start to poll. (dev_id=%u; sq_id=%u)\n", dev_id, (uint32_t)wait_jfc->jfc_cfg.user_ctx); |
| 797 | ret = trs_jfs_wqe_credit_poll(dev_id, trs_jfs); | 800 | ret = trs_jfs_wqe_credit_poll(dev_id, trs_jfs); |
| 798 | if (ret != 0) { | 801 | if (ret != 0) { |
| 799 | - trs_warn_limit("Thread poll jfc credit update failed. (ret=%d; jfc_id=%u)\n", | 802 | + trs_warn_limit("Thread poll jfc credit update failed. (ret=%d; jfc_id=%u)\n", ret, wait_jfc->jfc_id.id); |
| 800 | - ret, wait_jfc->jfc_id.id); | ||
| 801 | } | 803 | } |
| 802 | 804 | ||
| 803 | (void)trs_urma_jfc_ack_rearm(wait_jfc); | 805 | (void)trs_urma_jfc_ack_rearm(wait_jfc); |
| @@ -853,8 +855,8 @@ static void trs_jfs_write_src_notify_sge_init(struct sqcq_usr_info *sq_info, urm | |||
| 853 | 855 | ||
| 854 | } | 856 | } |
| 855 | 857 | ||
| 856 | -static void trs_jfs_write_src_sge_init( | 858 | +static void trs_jfs_write_src_sge_init(struct sqcq_usr_info *sq_info, urma_sge_t *src_sge_buf, uint32_t tail, |
| 857 | - struct sqcq_usr_info *sq_info, urma_sge_t *src_sge_buf, uint32_t tail, uint32_t sqe_num) | 859 | + uint32_t sqe_num) |
| 858 | { | 860 | { |
| 859 | 861 | ||
| 860 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; | 862 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; |
| @@ -864,8 +866,8 @@ static void trs_jfs_write_src_sge_init( | |||
| 864 | 866 | ||
| 865 | } | 867 | } |
| 866 | 868 | ||
| 867 | -static void trs_jfs_write_dst_sge_init( | 869 | +static void trs_jfs_write_dst_sge_init(struct sqcq_usr_info *sq_info, urma_sge_t *dst_sge_sqe, uint32_t tail, |
| 868 | - struct sqcq_usr_info *sq_info, urma_sge_t *dst_sge_sqe, uint32_t tail, uint32_t sqe_num) | 870 | + uint32_t sqe_num) |
| 869 | { | 871 | { |
| 870 | 872 | ||
| 871 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; | 873 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; |
| @@ -875,8 +877,8 @@ static void trs_jfs_write_dst_sge_init( | |||
| 875 | 877 | ||
| 876 | } | 878 | } |
| 877 | 879 | ||
| 878 | -static void trs_jfs_write_with_notify_dst_sge_init( | 880 | +static void trs_jfs_write_with_notify_dst_sge_init(struct sqcq_usr_info *sq_info, urma_sge_t *dst_sge_sqe, |
| 879 | - struct sqcq_usr_info *sq_info, urma_sge_t *dst_sge_sqe, urma_sge_t *dst_sge_notify, uint32_t tail, uint32_t sqe_num) | 881 | + urma_sge_t *dst_sge_notify, uint32_t tail, uint32_t sqe_num) |
| 880 | { | 882 | { |
| 881 | 883 | ||
| 882 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; | 884 | struct trs_urma_ctx *urma_ctx = (struct trs_urma_ctx *)sq_info->urma_ctx; |
| @@ -1033,9 +1035,8 @@ drvError_t trs_sq_task_send_urma(uint32_t dev_id, struct halTaskSendInfo *info, | |||
| 1033 | 1035 | ||
| 1034 | sq_info->tail = (sq_info->tail + info->sqe_num) % sq_info->depth; | 1036 | sq_info->tail = (sq_info->tail + info->sqe_num) % sq_info->depth; |
| 1035 | trs_sq_send_ok_stat(sq_info, info->sqe_num); | 1037 | trs_sq_send_ok_stat(sq_info, info->sqe_num); |
| 1036 | - trs_debug( | 1038 | + trs_debug("Send sqe success. (dev_id=%u; sq_id=%u; jfs=%u; jfc=%u; sqe_num=%u; sq_tail=%u)\n", dev_id, info->sqId, |
| 1037 | - "Send sqe success. (dev_id=%u; sq_id=%u; jfs=%u; jfc=%u; sqe_num=%u; sq_tail=%u)\n", dev_id, info->sqId, | 1039 | + urma_ctx->trs_jfs.jfs->jfs_id.id, urma_ctx->trs_jfs.trs_jfc.jfc->jfc_id.id, info->sqe_num, sq_info->tail); |
| 1038 | - urma_ctx->trs_jfs.jfs->jfs_id.id, urma_ctx->trs_jfs.trs_jfc.jfc->jfc_id.id, info->sqe_num, sq_info->tail); | ||
| 1039 | return ret; | 1040 | return ret; |
| 1040 | } | 1041 | } |
| 1041 | 1042 | ||
| @@ -1059,9 +1060,8 @@ static int trs_args_async_copy_info_check(struct halSqTaskArgsInfo *info) | |||
| 1059 | } | 1060 | } |
| 1060 | 1061 | ||
| 1061 | if ((srcTsegInfo->tseg_ptr == NULL) || (dstTsegInfo->tseg_ptr == NULL)) { | 1062 | if ((srcTsegInfo->tseg_ptr == NULL) || (dstTsegInfo->tseg_ptr == NULL)) { |
| 1062 | - trs_err( | 1063 | + trs_err("Invalid NULL TsegInfo tseg_ptr. (src_tseg_ptr=%p; dst_tseg_ptr=%p)\n", srcTsegInfo->tseg_ptr, |
| 1063 | - "Invalid NULL TsegInfo tseg_ptr. (src_tseg_ptr=%p; dst_tseg_ptr=%p)\n", srcTsegInfo->tseg_ptr, | 1064 | + dstTsegInfo->tseg_ptr); |
| 1064 | - dstTsegInfo->tseg_ptr); | ||
| 1065 | return DRV_ERROR_INVALID_VALUE; | 1065 | return DRV_ERROR_INVALID_VALUE; |
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| @@ -1088,8 +1088,8 @@ drvError_t trs_sq_task_args_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo | |||
| 1088 | 1088 | ||
| 1089 | for (i = 0; i < wr_num; i++) { | 1089 | for (i = 0; i < wr_num; i++) { |
| 1090 | urma_jfs_wr_t *wr = &urma_ctx->trs_jfs.wr_sge_array[i].wr; | 1090 | urma_jfs_wr_t *wr = &urma_ctx->trs_jfs.wr_sge_array[i].wr; |
| 1091 | - u32 size = | 1091 | + u32 size = (i == (wr_num - 1)) ? (info->size - i * (u32)TRS_URMA_WR_CPY_MAX_SIZE) : |
| 1092 | - (i == (wr_num - 1)) ? (info->size - i * (u32)TRS_URMA_WR_CPY_MAX_SIZE) : (u32)TRS_URMA_WR_CPY_MAX_SIZE; | 1092 | + (u32)TRS_URMA_WR_CPY_MAX_SIZE; |
| 1093 | 1093 | ||
| 1094 | (void)memset_s(wr, sizeof(urma_jfs_wr_t), 0, sizeof(urma_jfs_wr_t)); | 1094 | (void)memset_s(wr, sizeof(urma_jfs_wr_t), 0, sizeof(urma_jfs_wr_t)); |
| 1095 | wr->opcode = URMA_OPC_WRITE; | 1095 | wr->opcode = URMA_OPC_WRITE; |
| @@ -1101,10 +1101,10 @@ drvError_t trs_sq_task_args_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo | |||
| 1101 | wr->rw.dst.sge = &urma_ctx->trs_jfs.wr_sge_array[i].dst_sge; | 1101 | wr->rw.dst.sge = &urma_ctx->trs_jfs.wr_sge_array[i].dst_sge; |
| 1102 | wr->rw.dst.num_sge = 1; | 1102 | wr->rw.dst.num_sge = 1; |
| 1103 | trs_set_urma_resp_cqe(wr); | 1103 | trs_set_urma_resp_cqe(wr); |
| 1104 | - trs_jfs_write_sge_init( | 1104 | + trs_jfs_write_sge_init(info->src + i * TRS_URMA_WR_CPY_MAX_SIZE, (uint64_t)size, info->srcTsegInfo->tseg_ptr, |
| 1105 | - info->src + i * TRS_URMA_WR_CPY_MAX_SIZE, (uint64_t)size, info->srcTsegInfo->tseg_ptr, wr->rw.src.sge); | 1105 | + wr->rw.src.sge); |
| 1106 | - trs_jfs_write_sge_init( | 1106 | + trs_jfs_write_sge_init(info->dst + i * TRS_URMA_WR_CPY_MAX_SIZE, (uint64_t)size, info->dstTsegInfo->tseg_ptr, |
| 1107 | - info->dst + i * TRS_URMA_WR_CPY_MAX_SIZE, (uint64_t)size, info->dstTsegInfo->tseg_ptr, wr->rw.dst.sge); | 1107 | + wr->rw.dst.sge); |
| 1108 | wr->next = (i == (wr_num - 1)) ? NULL : &urma_ctx->trs_jfs.wr_sge_array[i + 1].wr; | 1108 | wr->next = (i == (wr_num - 1)) ? NULL : &urma_ctx->trs_jfs.wr_sge_array[i + 1].wr; |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| @@ -1120,8 +1120,8 @@ drvError_t trs_sq_task_args_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo | |||
| 1120 | 1120 | ||
| 1121 | } | 1121 | } |
| 1122 | 1122 | ||
| 1123 | -drvError_t trs_get_urma_tseg_info_by_va( | 1123 | +drvError_t trs_get_urma_tseg_info_by_va(uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, |
| 1124 | - uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, struct halTsegInfo *tsegInfo) | 1124 | + struct halTsegInfo *tsegInfo) |
| 1125 | { | 1125 | { |
| 1126 | urma_target_seg_t *tseg = NULL; | 1126 | urma_target_seg_t *tseg = NULL; |
| 1127 | urma_seg_t seg; | 1127 | urma_seg_t seg; |
| @@ -1186,8 +1186,8 @@ static void *trs_urma_poll_thread_func(void *arg) | |||
| 1186 | } while ((event_num == -1) && (errno == EINTR)); | 1186 | } while ((event_num == -1) && (errno == EINTR)); |
| 1187 | 1187 | ||
| 1188 | if ((event_num < 0) || (event_num > TRS_DEV_NUM)) { | 1188 | if ((event_num < 0) || (event_num > TRS_DEV_NUM)) { |
| 1189 | - trs_warn("Call epoll_wait error. (epfd=%d; strerror=\"%s\"; errno=%d)\n", | 1189 | + trs_warn("Call epoll_wait error. (epfd=%d; strerror=\"%s\"; errno=%d)\n", g_trs_urma_epoll.epfd, |
| 1190 | - g_trs_urma_epoll.epfd, strerror(errno), errno); | 1190 | + strerror(errno), errno); |
| 1191 | continue; | 1191 | continue; |
| 1192 | } | 1192 | } |
| 1193 | 1193 | ||
| @@ -18,7 +18,7 @@ drvError_t trs_sqcq_urma_alloc(uint32_t dev_id, struct halSqCqInputInfo *in, str | |||
| 18 | drvError_t trs_sqcq_urma_free(uint32_t dev_id, struct halSqCqFreeInfo *info, bool remote_free_flag); | 18 | drvError_t trs_sqcq_urma_free(uint32_t dev_id, struct halSqCqFreeInfo *info, bool remote_free_flag); |
| 19 | drvError_t trs_sq_task_send_urma(uint32_t dev_id, struct halTaskSendInfo *info, struct sqcq_usr_info *sq_info); | 19 | drvError_t trs_sq_task_send_urma(uint32_t dev_id, struct halTaskSendInfo *info, struct sqcq_usr_info *sq_info); |
| 20 | drvError_t trs_sq_task_srgs_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo *info, struct sqcq_usr_info *sq_info); | 20 | drvError_t trs_sq_task_srgs_async_copy(uint32_t dev_id, struct halSqTaskArgsInfo *info, struct sqcq_usr_info *sq_info); |
| 21 | -drvError_t trs_get_urma_tseg_info_by_va( | 21 | +drvError_t trs_get_urma_tseg_info_by_va(uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, |
| 22 | - uint32_t devid, uint64_t va, uint64_t size, uint32_t flag, struct halTsegInfo *tsegInfo); | 22 | + struct halTsegInfo *tsegInfo); |
| 23 | drvError_t trs_put_urma_tseg_info(uint32_t devid, struct halTsegInfo *tsegInfo); | 23 | drvError_t trs_put_urma_tseg_info(uint32_t devid, struct halTsegInfo *tsegInfo); |
| 24 | 24 | ||
| @@ -298,8 +298,8 @@ static int _trs_destroy_stars_jetty(urma_context_t *urma_ctx, struct trs_urma_st | |||
| 298 | return 0; | 298 | return 0; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | -static int _trs_create_stars_jetty( | 301 | +static int _trs_create_stars_jetty(urma_context_t *urma_ctx, struct trs_urma_jfr *trs_jfr, uint32_t depth, |
| 302 | - urma_context_t *urma_ctx, struct trs_urma_jfr *trs_jfr, uint32_t depth, struct trs_urma_stars_jetty *trs_jetty) | 302 | + struct trs_urma_stars_jetty *trs_jetty) |
| 303 | { | 303 | { |
| 304 | struct udma_u_jetty_cfg_ex jetty_ex_cfg = {0}; | 304 | struct udma_u_jetty_cfg_ex jetty_ex_cfg = {0}; |
| 305 | urma_jetty_cfg_t jetty_cfg = {0}; | 305 | urma_jetty_cfg_t jetty_cfg = {0}; |
| @@ -345,9 +345,8 @@ static int _trs_create_stars_jetty( | |||
| 345 | return 0; | 345 | return 0; |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | -int trs_create_stars_jetty( | 348 | +int trs_create_stars_jetty(urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfr *trs_jfr, uint32_t depth, |
| 349 | - urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfr *trs_jfr, uint32_t depth, | 349 | + struct trs_urma_stars_jetty *trs_jetty) |
| 350 | - struct trs_urma_stars_jetty *trs_jetty) | ||
| 351 | { | 350 | { |
| 352 | int ret = 0; | 351 | int ret = 0; |
| 353 | 352 | ||
| @@ -372,9 +371,8 @@ int trs_create_stars_jetty( | |||
| 372 | } | 371 | } |
| 373 | 372 | ||
| 374 | trs_jetty->init_flag = true; | 373 | trs_jetty->init_flag = true; |
| 375 | - trs_debug( | 374 | + trs_debug("Create stars jetty success. (jetty_id=%u; jfr_id=%u; jfc_id=%u)\n", trs_jetty->jetty->jetty_id.id, |
| 376 | - "Create stars jetty success. (jetty_id=%u; jfr_id=%u; jfc_id=%u)\n", trs_jetty->jetty->jetty_id.id, | 375 | + trs_jfr->jfr->jfr_id.id, trs_jetty->trs_jfc.jfc->jfc_id.id); |
| 377 | - trs_jfr->jfr->jfr_id.id, trs_jetty->trs_jfc.jfc->jfc_id.id); | ||
| 378 | 376 | ||
| 379 | return 0; | 377 | return 0; |
| 380 | } | 378 | } |
| @@ -523,9 +521,8 @@ drvError_t trs_urma_proc_ctx_init(struct trs_urma_proc_ctx *proc_ctx) | |||
| 523 | return DRV_ERROR_INNER_ERR; | 521 | return DRV_ERROR_INNER_ERR; |
| 524 | } | 522 | } |
| 525 | proc_ctx->eid = proc_ctx->urma_ctx->eid; | 523 | proc_ctx->eid = proc_ctx->urma_ctx->eid; |
| 526 | - trs_debug( | 524 | + trs_debug("Get eid list. (dev_name=%s; eid_index=%d; " EID_FMT ").\n", proc_ctx->urma_dev->name, |
| 527 | - "Get eid list. (dev_name=%s; eid_index=%d; " EID_FMT ").\n", proc_ctx->urma_dev->name, proc_ctx->eid_index, | 525 | + proc_ctx->eid_index, EID_ARGS(proc_ctx->eid)); |
| 528 | - EID_ARGS(proc_ctx->eid)); | ||
| 529 | 526 | ||
| 530 | proc_ctx->jfce = urma_create_jfce(proc_ctx->urma_ctx); | 527 | proc_ctx->jfce = urma_create_jfce(proc_ctx->urma_ctx); |
| 531 | if (proc_ctx->jfce == NULL) { | 528 | if (proc_ctx->jfce == NULL) { |
| @@ -202,15 +202,20 @@ static inline uint32_t trs_get_async_pi_ci_max(bool is_wqe_sink) | |||
| 202 | return (is_wqe_sink == false) ? TRS_UB_PI_CI_DEPTH : TRS_STARS_NORMAL_JETTY_DEPTH; | 202 | return (is_wqe_sink == false) ? TRS_UB_PI_CI_DEPTH : TRS_STARS_NORMAL_JETTY_DEPTH; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | -static inline bool trs_is_async_jetty_wqe_sink(uint32_t flag) { return ((flag & TSDRV_FLAG_TASK_SINK_SQ) != 0); } | 205 | +static inline bool trs_is_async_jetty_wqe_sink(uint32_t flag) |
| 206 | +{ | ||
| 207 | + return ((flag & TSDRV_FLAG_TASK_SINK_SQ) != 0); | ||
| 208 | +} | ||
| 206 | 209 | ||
| 207 | -static inline bool trs_is_async_jetty_pre_alloc(uint32_t flag) { return ((flag & TSDRV_FLAG_PRE_ASYNC_SQ) != 0); } | 210 | +static inline bool trs_is_async_jetty_pre_alloc(uint32_t flag) |
| 211 | +{ | ||
| 212 | + return ((flag & TSDRV_FLAG_PRE_ASYNC_SQ) != 0); | ||
| 213 | +} | ||
| 208 | 214 | ||
| 209 | static inline bool trs_is_async_direct_wqe(uint32_t flag, enum trs_async_dma_type async_type) | 215 | static inline bool trs_is_async_direct_wqe(uint32_t flag, enum trs_async_dma_type async_type) |
| 210 | { | 216 | { |
| 211 | - return ( | 217 | + return (((flag & TSDRV_FLAG_TASK_SINK_SQ) == 0) && (async_type != TRS_ASYNC_DMA_TYPE_2D) && |
| 212 | - ((flag & TSDRV_FLAG_TASK_SINK_SQ) == 0) && (async_type != TRS_ASYNC_DMA_TYPE_2D) && | 218 | + (async_type != TRS_ASYNC_DMA_TYPE_BATCH)); |
| 213 | - (async_type != TRS_ASYNC_DMA_TYPE_BATCH)); | ||
| 214 | } | 219 | } |
| 215 | 220 | ||
| 216 | static inline urma_import_seg_flag_t trs_get_seg_import_flag(void) | 221 | static inline urma_import_seg_flag_t trs_get_seg_import_flag(void) |
| @@ -236,9 +241,8 @@ static inline uint32_t trs_jetty_get_credit(uint32_t pi, uint32_t ci, uint32_t d | |||
| 236 | 241 | ||
| 237 | int trs_create_jfs(urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfs *trs_jfs, void *priv); | 242 | int trs_create_jfs(urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfs *trs_jfs, void *priv); |
| 238 | void trs_destroy_jfs(struct trs_urma_jfs *trs_jfs); | 243 | void trs_destroy_jfs(struct trs_urma_jfs *trs_jfs); |
| 239 | -int trs_create_stars_jetty( | 244 | +int trs_create_stars_jetty(urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfr *trs_jfr, uint32_t depth, |
| 240 | - urma_context_t *urma_ctx, urma_jfce_t *jfce, struct trs_urma_jfr *trs_jfr, uint32_t depth, | 245 | + struct trs_urma_stars_jetty *trs_jetty); |
| 241 | - struct trs_urma_stars_jetty *trs_jetty); | ||
| 242 | void trs_destroy_stars_jetty(urma_context_t *urma_ctx, struct trs_urma_stars_jetty *trs_jetty); | 246 | void trs_destroy_stars_jetty(urma_context_t *urma_ctx, struct trs_urma_stars_jetty *trs_jetty); |
| 243 | int trs_create_jfr(urma_context_t *urma_ctx, urma_jfce_t *jfce, urma_token_t token, struct trs_urma_jfr *trs_jfr); | 247 | int trs_create_jfr(urma_context_t *urma_ctx, urma_jfce_t *jfce, urma_token_t token, struct trs_urma_jfr *trs_jfr); |
| 244 | void trs_destroy_jfr(struct trs_urma_jfr *trs_jfr); | 248 | void trs_destroy_jfr(struct trs_urma_jfr *trs_jfr); |
| @@ -53,8 +53,10 @@ struct trs_async_dma_destroy_para { | |||
| 53 | }; | 53 | }; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | -static inline struct trs_async_dma_input_para trs_pack_async_dma_input_para( | 56 | +static inline struct trs_async_dma_input_para trs_pack_async_dma_input_para(void *input_para, |
| 57 | - void *input_para, enum trs_async_dma_type async_dma_type, drvSqCqType_t type, uint32_t tsId, uint32_t sqId) | 57 | + enum trs_async_dma_type async_dma_type, |
| 58 | + drvSqCqType_t type, uint32_t tsId, | ||
| 59 | + uint32_t sqId) | ||
| 58 | { | 60 | { |
| 59 | struct trs_async_dma_input_para async_input = {0}; | 61 | struct trs_async_dma_input_para async_input = {0}; |
| 60 | async_input.async_dma_type = async_dma_type; | 62 | async_input.async_dma_type = async_dma_type; |
| @@ -88,8 +90,10 @@ static inline struct trs_async_dma_input_para trs_pack_async_dma_input_para( | |||
| 88 | return async_input; | 90 | return async_input; |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | -static inline struct trs_async_dma_destroy_para trs_pack_async_dma_destroy_para( | 93 | +static inline struct trs_async_dma_destroy_para trs_pack_async_dma_destroy_para(void *in, |
| 92 | - void *in, enum trs_async_dma_type async_dma_type, drvSqCqType_t type, uint32_t tsId, uint32_t sqId) | 94 | + enum trs_async_dma_type async_dma_type, |
| 95 | + drvSqCqType_t type, uint32_t tsId, | ||
| 96 | + uint32_t sqId) | ||
| 93 | { | 97 | { |
| 94 | struct trs_async_dma_destroy_para destroy_para = {0}; | 98 | struct trs_async_dma_destroy_para destroy_para = {0}; |
| 95 | destroy_para.async_dma_type = async_dma_type; | 99 | destroy_para.async_dma_type = async_dma_type; |
| @@ -83,13 +83,13 @@ | |||
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | -#define trs_err_if(cond, fmt, ...) \ | 86 | +#define trs_err_if(cond, fmt, ...) \ |
| 87 | - do { \ | 87 | + do { \ |
| 88 | - if (cond) { \ | 88 | + if (cond) { \ |
| 89 | - trs_err(fmt, ##__VA_ARGS__); \ | 89 | + trs_err(fmt, ##__VA_ARGS__); \ |
| 90 | - } else { \ | 90 | + } else { \ |
| 91 | - trs_debug(fmt, ##__VA_ARGS__); \ | 91 | + trs_debug(fmt, ##__VA_ARGS__); \ |
| 92 | - } \ | 92 | + } \ |
| 93 | } while (0) | 93 | } while (0) |
| 94 | 94 | ||
| 95 | 95 | ||
| @@ -100,12 +100,12 @@ | |||
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | -static inline void trs_operation_not_supported_err_msg(const char* func_name, const char* type) | 103 | +static inline void trs_operation_not_supported_err_msg(const char *func_name, const char *type) |
| 104 | { | 104 | { |
| 105 | char func_name_str[TRS_REPORT_ERR_MSG_STR_LEN] = {0}; | 105 | char func_name_str[TRS_REPORT_ERR_MSG_STR_LEN] = {0}; |
| 106 | char reason_str[TRS_REPORT_ERR_MSG_STR_LEN] = {0}; | 106 | char reason_str[TRS_REPORT_ERR_MSG_STR_LEN] = {0}; |
| 107 | - const char* key[] = {"func_name", "reason"}; | 107 | + const char *key[] = {"func_name", "reason"}; |
| 108 | - const char* value[] = {func_name_str, reason_str}; | 108 | + const char *value[] = {func_name_str, reason_str}; |
| 109 | int ret; | 109 | int ret; |
| 110 | 110 | ||
| 111 | ret = snprintf_s(func_name_str, sizeof(func_name_str), sizeof(func_name_str) - 1, "%s", func_name); | 111 | ret = snprintf_s(func_name_str, sizeof(func_name_str), sizeof(func_name_str) - 1, "%s", func_name); |
| @@ -113,8 +113,9 @@ static inline void trs_operation_not_supported_err_msg(const char* func_name, co | |||
| 113 | return; | 113 | return; |
| 114 | } | 114 | } |
| 115 | ret = snprintf_s(reason_str, sizeof(reason_str), sizeof(reason_str) - 1, | 115 | ret = snprintf_s(reason_str, sizeof(reason_str), sizeof(reason_str) - 1, |
| 116 | - "The process where the shared %s resides is not added to the trustlist. " | 116 | + "The process where the shared %s resides is not added to the trustlist. " |
| 117 | - "Add the process to the trustlist or disable trustlist verification", type); | 117 | + "Add the process to the trustlist or disable trustlist verification", |
| 118 | + type); | ||
| 118 | if (ret < 0) { | 119 | if (ret < 0) { |
| 119 | return; | 120 | return; |
| 120 | } | 121 | } |
| @@ -149,17 +150,15 @@ static inline void trs_print_time_consume_warning_log(int timeout, unsigned long | |||
| 149 | int ret, i; | 150 | int ret, i; |
| 150 | 151 | ||
| 151 | for (i = 1; i < len; i++) { | 152 | for (i = 1; i < len; i++) { |
| 152 | - ret = sprintf_s( | 153 | + ret = sprintf_s(time_str + index, (TRS_TIMESTAMP_BUFF_LEN - (unsigned int)index), "%lld ", |
| 153 | - time_str + index, (TRS_TIMESTAMP_BUFF_LEN - (unsigned int)index), "%lld ", | 154 | + (long long)time_stamp[i] - (long long)time_stamp[i - 1]); |
| 154 | - (long long)time_stamp[i] - (long long)time_stamp[i - 1]); | ||
| 155 | if (ret > 0) { | 155 | if (ret > 0) { |
| 156 | index += ret; | 156 | index += ret; |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | - trs_warn( | 160 | + trs_warn("Time consume warning. (start_time=%lluns; total_time=%lluns; limit=%uns; time_interval=%s(ns))\n", |
| 161 | - "Time consume warning. (start_time=%lluns; total_time=%lluns; limit=%uns; time_interval=%s(ns))\n", | 161 | + time_stamp[0], time_stamp[len - 1] - time_stamp[0], timeout, time_str); |
| 162 | - time_stamp[0], time_stamp[len - 1] - time_stamp[0], timeout, time_str); | ||
| 163 | } | 162 | } |
| 164 | 163 | ||
| 165 | 164 | ||
| @@ -60,14 +60,12 @@ static pid_t trs_get_dev_pid(uint32_t dev_id) | |||
| 60 | hostpidinfo.vfid = 0; | 60 | hostpidinfo.vfid = 0; |
| 61 | ret = halQueryDevpid(hostpidinfo, &devpid); | 61 | ret = halQueryDevpid(hostpidinfo, &devpid); |
| 62 | if (ret) { | 62 | if (ret) { |
| 63 | - trs_err( | 63 | + trs_err("Query devpid failed. (dev_id=%u; vfid=%u; hostpid=%d; proc_type=%u; ret=%d).\n", dev_id, 0, |
| 64 | - "Query devpid failed. (dev_id=%u; vfid=%u; hostpid=%d; proc_type=%u; ret=%d).\n", dev_id, 0, | 64 | + trs_get_hostpid(dev_id), hostpidinfo.proc_type, ret); |
| 65 | - trs_get_hostpid(dev_id), hostpidinfo.proc_type, ret); | ||
| 66 | } else { | 65 | } else { |
| 67 | g_trs_devpid[dev_id] = devpid; | 66 | g_trs_devpid[dev_id] = devpid; |
| 68 | - trs_info( | 67 | + trs_info("Query devpid succ. (dev_id=%u; vfid=%u; hostpid=%d; proc_type=%u; devpid=%d).\n", dev_id, 0, |
| 69 | - "Query devpid succ. (dev_id=%u; vfid=%u; hostpid=%d; proc_type=%u; devpid=%d).\n", dev_id, 0, | 68 | + trs_get_hostpid(dev_id), hostpidinfo.proc_type, devpid); |
| 70 | - trs_get_hostpid(dev_id), hostpidinfo.proc_type, devpid); | ||
| 71 | } | 69 | } |
| 72 | } | 70 | } |
| 73 | 71 | ||
| @@ -128,8 +126,8 @@ static uint32_t trs_get_dst_engine(uint32_t subevent_id) | |||
| 128 | return ACPU_DEVICE; | 126 | return ACPU_DEVICE; |
| 129 | } | 127 | } |
| 130 | 128 | ||
| 131 | -static drvError_t trs_fill_event( | 129 | +static drvError_t trs_fill_event(struct event_summary *event_info, uint32_t devid, uint32_t subevent_id, |
| 132 | - struct event_summary *event_info, uint32_t devid, uint32_t subevent_id, const char *msg, uint32_t msg_len) | 130 | + const char *msg, uint32_t msg_len) |
| 133 | { | 131 | { |
| 134 | struct event_sync_msg *msg_head = NULL; | 132 | struct event_sync_msg *msg_head = NULL; |
| 135 | drvError_t ret; | 133 | drvError_t ret; |
| @@ -251,11 +249,14 @@ static int trs_sq_cq_event_init(uint32_t dev_id) | |||
| 251 | return DRV_ERROR_NONE; | 249 | return DRV_ERROR_NONE; |
| 252 | } | 250 | } |
| 253 | 251 | ||
| 254 | -static void trs_sq_cq_event_un_init(uint32_t dev_id) { (void)halEschedDettachDevice(dev_id); } | 252 | +static void trs_sq_cq_event_un_init(uint32_t dev_id) |
| 253 | +{ | ||
| 254 | + (void)halEschedDettachDevice(dev_id); | ||
| 255 | +} | ||
| 255 | 256 | ||
| 256 | 257 | ||
| 257 | -static drvError_t trs_submit_event_sync( | 258 | +static drvError_t trs_submit_event_sync(uint32_t dev_id, struct event_summary *event, int32_t timeout, |
| 258 | - uint32_t dev_id, struct event_summary *event, int32_t timeout, struct event_reply *reply) | 259 | + struct event_reply *reply) |
| 259 | { | 260 | { |
| 260 | struct event_info back_event_info = {0}; | 261 | struct event_info back_event_info = {0}; |
| 261 | esched_event_buffer *event_buffer = (esched_event_buffer *)back_event_info.priv.msg; | 262 | esched_event_buffer *event_buffer = (esched_event_buffer *)back_event_info.priv.msg; |
| @@ -282,9 +283,8 @@ static drvError_t trs_submit_event_sync( | |||
| 282 | ret = halEschedSubmitEvent(dev_id, event); | 283 | ret = halEschedSubmitEvent(dev_id, event); |
| 283 | if (ret != DRV_ERROR_NONE) { | 284 | if (ret != DRV_ERROR_NONE) { |
| 284 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); | 285 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); |
| 285 | - trs_warn( | 286 | + trs_warn("Unable to invoke the halEschedSubmitEvent. (dev_id=%u, event_id=%u; ret=%d)\n", dev_id, |
| 286 | - "Unable to invoke the halEschedSubmitEvent. (dev_id=%u, event_id=%u; ret=%d)\n", dev_id, event->event_id, | 287 | + event->event_id, ret); |
| 287 | - ret); | ||
| 288 | return ret; | 288 | return ret; |
| 289 | } | 289 | } |
| 290 | 290 | ||
| @@ -295,9 +295,8 @@ static drvError_t trs_submit_event_sync( | |||
| 295 | ret = esched_wait_event_ex(dev_id, res.gid, res.tid, timeout, &back_event_info); | 295 | ret = esched_wait_event_ex(dev_id, res.gid, res.tid, timeout, &back_event_info); |
| 296 | if (ret != DRV_ERROR_NONE) { | 296 | if (ret != DRV_ERROR_NONE) { |
| 297 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); | 297 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); |
| 298 | - trs_err( | 298 | + trs_err("Failed. (ret=%d; event_id=%u; gid=%u; tid=%u; timeout=%dms; subevent_id=%u)\n", ret, res.event_id, |
| 299 | - "Failed. (ret=%d; event_id=%u; gid=%u; tid=%u; timeout=%dms; subevent_id=%u)\n", ret, res.event_id, | 299 | + res.gid, res.tid, timeout, res.subevent_id); |
| 300 | - res.gid, res.tid, timeout, res.subevent_id); | ||
| 301 | return ret; | 300 | return ret; |
| 302 | } | 301 | } |
| 303 | 302 | ||
| @@ -306,10 +305,9 @@ static drvError_t trs_submit_event_sync( | |||
| 306 | break; | 305 | break; |
| 307 | } | 306 | } |
| 308 | 307 | ||
| 309 | - trs_warn( | 308 | + trs_warn("Successfully waited for an event but the condition was not met. (devid=%u; gid=%u; " |
| 310 | - "Successfully waited for an event but the condition was not met. (devid=%u; gid=%u; " | 309 | + "tid=%u; cnt=%d; check_subevent=%u; back_subevent=%u)\n", |
| 311 | - "tid=%u; cnt=%d; check_subevent=%u; back_subevent=%u)\n", | 310 | + dev_id, res.gid, res.tid, wait_succ_cnt, res.subevent_id, back_event_info.comm.subevent_id); |
| 312 | - dev_id, res.gid, res.tid, wait_succ_cnt, res.subevent_id, back_event_info.comm.subevent_id); | ||
| 313 | } while (1); | 311 | } while (1); |
| 314 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); | 312 | (void)pthread_mutex_unlock(&g_trs_event_sync_mutex[dev_id]); |
| 315 | 313 | ||
| @@ -324,8 +322,8 @@ static drvError_t trs_submit_event_sync( | |||
| 324 | 322 | ||
| 325 | 323 | ||
| 326 | 324 | ||
| 327 | -drvError_t trs_svm_mem_event_sync( | 325 | +drvError_t trs_svm_mem_event_sync(uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, |
| 328 | - uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, struct event_reply *reply) | 326 | + struct event_reply *reply) |
| 329 | { | 327 | { |
| 330 | struct event_summary event_info = {0}; | 328 | struct event_summary event_info = {0}; |
| 331 | void *msg = NULL; | 329 | void *msg = NULL; |
| @@ -388,8 +386,8 @@ drvError_t trs_svm_mem_event_sync( | |||
| 388 | return ret; | 386 | return ret; |
| 389 | } | 387 | } |
| 390 | 388 | ||
| 391 | -static drvError_t trs_res_id_alloc_sync( | 389 | +static drvError_t trs_res_id_alloc_sync(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 392 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceIdOutputInfo *out) | 390 | + struct halResourceIdOutputInfo *out) |
| 393 | { | 391 | { |
| 394 | struct event_proc_result result; | 392 | struct event_proc_result result; |
| 395 | struct event_reply reply; | 393 | struct event_reply reply; |
| @@ -397,8 +395,8 @@ static drvError_t trs_res_id_alloc_sync( | |||
| 397 | 395 | ||
| 398 | reply.buf_len = sizeof(struct event_proc_result); | 396 | reply.buf_len = sizeof(struct event_proc_result); |
| 399 | reply.buf = (char *)&result; | 397 | reply.buf = (char *)&result; |
| 400 | - ret = trs_svm_mem_event_sync( | 398 | + ret = trs_svm_mem_event_sync(dev_id, in, sizeof(struct halResourceIdInputInfo), DRV_SUBEVENT_TRS_ALLOC_RES_ID_MSG, |
| 401 | - dev_id, in, sizeof(struct halResourceIdInputInfo), DRV_SUBEVENT_TRS_ALLOC_RES_ID_MSG, &reply); | 399 | + &reply); |
| 402 | if (ret != DRV_ERROR_NONE) { | 400 | if (ret != DRV_ERROR_NONE) { |
| 403 | return ret; | 401 | return ret; |
| 404 | } | 402 | } |
| @@ -422,8 +420,8 @@ static drvError_t trs_res_id_free_sync(uint32_t dev_id, struct halResourceIdInpu | |||
| 422 | 420 | ||
| 423 | reply.buf_len = sizeof(struct event_proc_result); | 421 | reply.buf_len = sizeof(struct event_proc_result); |
| 424 | reply.buf = (char *)&result; | 422 | reply.buf = (char *)&result; |
| 425 | - ret = trs_svm_mem_event_sync( | 423 | + ret = trs_svm_mem_event_sync(dev_id, in, sizeof(struct halResourceIdInputInfo), DRV_SUBEVENT_TRS_FREE_RES_ID_MSG, |
| 426 | - dev_id, in, sizeof(struct halResourceIdInputInfo), DRV_SUBEVENT_TRS_FREE_RES_ID_MSG, &reply); | 424 | + &reply); |
| 427 | if (ret != DRV_ERROR_NONE) { | 425 | if (ret != DRV_ERROR_NONE) { |
| 428 | return ret; | 426 | return ret; |
| 429 | } | 427 | } |
| @@ -433,8 +431,8 @@ static drvError_t trs_res_id_free_sync(uint32_t dev_id, struct halResourceIdInpu | |||
| 433 | return (drvError_t)result.ret; | 431 | return (drvError_t)result.ret; |
| 434 | } | 432 | } |
| 435 | 433 | ||
| 436 | -static drvError_t trs_res_id_config_sync( | 434 | +static drvError_t trs_res_id_config_sync(uint32_t dev_id, struct halResourceIdInputInfo *in, |
| 437 | - uint32_t dev_id, struct halResourceIdInputInfo *in, struct halResourceConfigInfo *para) | 435 | + struct halResourceConfigInfo *para) |
| 438 | { | 436 | { |
| 439 | struct trs_resid_config_msg config_info; | 437 | struct trs_resid_config_msg config_info; |
| 440 | struct event_proc_result result; | 438 | struct event_proc_result result; |
| @@ -446,8 +444,8 @@ static drvError_t trs_res_id_config_sync( | |||
| 446 | 444 | ||
| 447 | reply.buf_len = sizeof(struct event_proc_result); | 445 | reply.buf_len = sizeof(struct event_proc_result); |
| 448 | reply.buf = (char *)&result; | 446 | reply.buf = (char *)&result; |
| 449 | - ret = trs_svm_mem_event_sync( | 447 | + ret = trs_svm_mem_event_sync(dev_id, &config_info, sizeof(struct trs_resid_config_msg), |
| 450 | - dev_id, &config_info, sizeof(struct trs_resid_config_msg), DRV_SUBEVENT_TRS_RES_ID_CONFIG_MSG, &reply); | 448 | + DRV_SUBEVENT_TRS_RES_ID_CONFIG_MSG, &reply); |
| 451 | if (ret != DRV_ERROR_NONE) { | 449 | if (ret != DRV_ERROR_NONE) { |
| 452 | return ret; | 450 | return ret; |
| 453 | } | 451 | } |
| @@ -468,8 +466,8 @@ drvError_t trs_sq_cq_query_sync(uint32_t dev_id, struct halSqCqQueryInfo *info) | |||
| 468 | trs_err("Malloc reply buffer failed.\n"); | 466 | trs_err("Malloc reply buffer failed.\n"); |
| 469 | return DRV_ERROR_OUT_OF_MEMORY; | 467 | return DRV_ERROR_OUT_OF_MEMORY; |
| 470 | }; | 468 | }; |
| 471 | - ret = | 469 | + ret = trs_svm_mem_event_sync(dev_id, info, sizeof(struct halSqCqQueryInfo), DRV_SUBEVENT_TRS_SQCQ_QUERY_MSG, |
| 472 | - trs_svm_mem_event_sync(dev_id, info, sizeof(struct halSqCqQueryInfo), DRV_SUBEVENT_TRS_SQCQ_QUERY_MSG, &reply); | 470 | + &reply); |
| 473 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); | 471 | result = DRV_EVENT_REPLY_BUFFER_RET(reply.buf); |
| 474 | if ((ret != 0) || (result != 0)) { | 472 | if ((ret != 0) || (result != 0)) { |
| 475 | trs_err("Failed to sync sqcq query event. (ret=%d; result=%d)\n", ret, result); | 473 | trs_err("Failed to sync sqcq query event. (ret=%d; result=%d)\n", ret, result); |
| @@ -477,13 +475,11 @@ drvError_t trs_sq_cq_query_sync(uint32_t dev_id, struct halSqCqQueryInfo *info) | |||
| 477 | return (ret != 0) ? ret : (drvError_t)result; | 475 | return (ret != 0) ? ret : (drvError_t)result; |
| 478 | } | 476 | } |
| 479 | 477 | ||
| 480 | - ret = memcpy_s( | 478 | + ret = memcpy_s(info->value, sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH, DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), |
| 481 | - info->value, sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH, DRV_EVENT_REPLY_BUFFER_DATA_PTR(reply.buf), | 479 | + sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH); |
| 482 | - sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH); | ||
| 483 | if (ret != DRV_ERROR_NONE) { | 480 | if (ret != DRV_ERROR_NONE) { |
| 484 | - trs_err( | 481 | + trs_err("Memcpy_s failed. (devid=%u; dst_size=%u; src_size=%u)\n", dev_id, |
| 485 | - "Memcpy_s failed. (devid=%u; dst_size=%u; src_size=%u)\n", dev_id, | 482 | + sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH, sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH); |
| 486 | - sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH, sizeof(uint32_t) * SQCQ_QUERY_INFO_LENGTH); | ||
| 487 | free(reply.buf); | 483 | free(reply.buf); |
| 488 | return ret; | 484 | return ret; |
| 489 | } | 485 | } |
| @@ -501,8 +497,8 @@ drvError_t trs_sq_cq_config_sync(uint32_t dev_id, struct halSqCqConfigInfo *info | |||
| 501 | 497 | ||
| 502 | reply.buf_len = sizeof(int); | 498 | reply.buf_len = sizeof(int); |
| 503 | reply.buf = (char *)&result; | 499 | reply.buf = (char *)&result; |
| 504 | - ret = | 500 | + ret = trs_svm_mem_event_sync(dev_id, info, sizeof(struct halSqCqQueryInfo), DRV_SUBEVENT_TRS_SQCQ_CONFIG_MSG, |
| 505 | - trs_svm_mem_event_sync(dev_id, info, sizeof(struct halSqCqQueryInfo), DRV_SUBEVENT_TRS_SQCQ_CONFIG_MSG, &reply); | 501 | + &reply); |
| 506 | if ((ret != 0) || (result != 0)) { | 502 | if ((ret != 0) || (result != 0)) { |
| 507 | trs_err("Failed to sync sqcq config event. (ret=%d; result=%d)\n", ret, result); | 503 | trs_err("Failed to sync sqcq config event. (ret=%d; result=%d)\n", ret, result); |
| 508 | return (ret != 0) ? ret : (drvError_t)result; | 504 | return (ret != 0) ? ret : (drvError_t)result; |
| @@ -536,9 +532,8 @@ static drvError_t trs_sq_cq_alloc_sync(uint32_t dev_id, struct halSqCqInputInfo | |||
| 536 | return DRV_ERROR_PARA_ERROR; | 532 | return DRV_ERROR_PARA_ERROR; |
| 537 | } | 533 | } |
| 538 | if ((in->ext_info != NULL) && (in->ext_info_len != 0)) { | 534 | if ((in->ext_info != NULL) && (in->ext_info_len != 0)) { |
| 539 | - memcpy_ret = memcpy_s( | 535 | + memcpy_ret = memcpy_s((char *)sync_msg + sizeof(struct halSqCqInputInfo), |
| 540 | - (char *)sync_msg + sizeof(struct halSqCqInputInfo), sync_msg_len - sizeof(struct halSqCqInputInfo), | 536 | + sync_msg_len - sizeof(struct halSqCqInputInfo), in->ext_info, in->ext_info_len); |
| 541 | - in->ext_info, in->ext_info_len); | ||
| 542 | if (memcpy_ret != 0) { | 537 | if (memcpy_ret != 0) { |
| 543 | trs_err("Failed to memcpy_s. (ret=%d)\n", memcpy_ret); | 538 | trs_err("Failed to memcpy_s. (ret=%d)\n", memcpy_ret); |
| 544 | free(sync_msg); | 539 | free(sync_msg); |
| @@ -593,8 +588,8 @@ static drvError_t trs_sq_cq_free_sync(uint32_t dev_id, struct halSqCqFreeInfo *i | |||
| 593 | return (drvError_t)result.ret; | 588 | return (drvError_t)result.ret; |
| 594 | } | 589 | } |
| 595 | 590 | ||
| 596 | -drvError_t trs_local_mem_event_sync( | 591 | +drvError_t trs_local_mem_event_sync(uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, |
| 597 | - uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, struct event_reply *reply) | 592 | + struct event_reply *reply) |
| 598 | { | 593 | { |
| 599 | struct event_summary event_info = {0}; | 594 | struct event_summary event_info = {0}; |
| 600 | const char *msg = (char *)in; | 595 | const char *msg = (char *)in; |
| @@ -644,14 +639,14 @@ static int trs_shr_id_config(uint32_t dev_id, struct drvShrIdInfo *info) | |||
| 644 | 639 | ||
| 645 | reply.buf_len = sizeof(struct event_proc_result); | 640 | reply.buf_len = sizeof(struct event_proc_result); |
| 646 | reply.buf = (char *)&result; | 641 | reply.buf = (char *)&result; |
| 647 | - ret = | 642 | + ret = trs_local_mem_event_sync(dev_id, info, sizeof(struct drvShrIdInfo), DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG, |
| 648 | - trs_local_mem_event_sync(dev_id, info, sizeof(struct drvShrIdInfo), DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG, &reply); | 643 | + &reply); |
| 649 | if (ret != DRV_ERROR_NONE) { | 644 | if (ret != DRV_ERROR_NONE) { |
| 650 | return ret; | 645 | return ret; |
| 651 | } | 646 | } |
| 652 | 647 | ||
| 653 | - trs_debug( | 648 | + trs_debug("Res info. (dev_id=%u; rudevid=%u; id_type=%u; shrid=%u)\n", dev_id, info->devid, info->id_type, |
| 654 | - "Res info. (dev_id=%u; rudevid=%u; id_type=%u; shrid=%u)\n", dev_id, info->devid, info->id_type, info->shrid); | 649 | + info->shrid); |
| 655 | 650 | ||
| 656 | return (drvError_t)result.ret; | 651 | return (drvError_t)result.ret; |
| 657 | } | 652 | } |
| @@ -664,14 +659,14 @@ static int trs_shr_id_deonfig(uint32_t dev_id, struct drvShrIdInfo *info) | |||
| 664 | 659 | ||
| 665 | reply.buf_len = sizeof(struct event_proc_result); | 660 | reply.buf_len = sizeof(struct event_proc_result); |
| 666 | reply.buf = (char *)&result; | 661 | reply.buf = (char *)&result; |
| 667 | - ret = trs_local_mem_event_sync( | 662 | + ret = trs_local_mem_event_sync(dev_id, info, sizeof(struct drvShrIdInfo), DRV_SUBEVENT_TRS_SHR_ID_DECONFIG_MSG, |
| 668 | - dev_id, info, sizeof(struct drvShrIdInfo), DRV_SUBEVENT_TRS_SHR_ID_DECONFIG_MSG, &reply); | 663 | + &reply); |
| 669 | if (ret != DRV_ERROR_NONE) { | 664 | if (ret != DRV_ERROR_NONE) { |
| 670 | return ret; | 665 | return ret; |
| 671 | } | 666 | } |
| 672 | 667 | ||
| 673 | - trs_debug( | 668 | + trs_debug("Res info. (dev_id=%u; rudevid=%u; id_type=%u; shrid=%u)\n", dev_id, info->devid, info->id_type, |
| 674 | - "Res info. (dev_id=%u; rudevid=%u; id_type=%u; shrid=%u)\n", dev_id, info->devid, info->id_type, info->shrid); | 669 | + info->shrid); |
| 675 | 670 | ||
| 676 | return (drvError_t)result.ret; | 671 | return (drvError_t)result.ret; |
| 677 | } | 672 | } |
| @@ -13,10 +13,10 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | -drvError_t trs_local_mem_event_sync( | 16 | +drvError_t trs_local_mem_event_sync(uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, |
| 17 | - uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, struct event_reply *reply); | 17 | + struct event_reply *reply); |
| 18 | -drvError_t trs_svm_mem_event_sync( | 18 | +drvError_t trs_svm_mem_event_sync(uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, |
| 19 | - uint32_t dev_id, void *in, UINT64 size, uint32_t subevent_id, struct event_reply *reply); | 19 | + struct event_reply *reply); |
| 20 | drvError_t trs_sq_cq_query_sync(uint32_t dev_id, struct halSqCqQueryInfo *info); | 20 | drvError_t trs_sq_cq_query_sync(uint32_t dev_id, struct halSqCqQueryInfo *info); |
| 21 | drvError_t trs_sq_cq_config_sync(uint32_t dev_id, struct halSqCqConfigInfo *info); | 21 | drvError_t trs_sq_cq_config_sync(uint32_t dev_id, struct halSqCqConfigInfo *info); |
| 22 | 22 | ||
| @@ -38,7 +38,10 @@ struct trs_sq_mem_ca { | |||
| 38 | static pthread_rwlock_t g_rwlock = PTHREAD_RWLOCK_INITIALIZER; | 38 | static pthread_rwlock_t g_rwlock = PTHREAD_RWLOCK_INITIALIZER; |
| 39 | struct trs_sq_mem_ca *g_ca[TRS_DEV_NUM]; | 39 | struct trs_sq_mem_ca *g_ca[TRS_DEV_NUM]; |
| 40 | 40 | ||
| 41 | -static uint64_t trs_sq_mem_ca_get_align(void) { return (uint64_t)getpagesize(); } | 41 | +static uint64_t trs_sq_mem_ca_get_align(void) |
| 42 | +{ | ||
| 43 | + return (uint64_t)getpagesize(); | ||
| 44 | +} | ||
| 42 | 45 | ||
| 43 | static int trs_sq_mem_ca_va_to_bit(struct trs_sq_mem_ca *ca, uint64_t va) | 46 | static int trs_sq_mem_ca_va_to_bit(struct trs_sq_mem_ca *ca, uint64_t va) |
| 44 | { | 47 | { |
| @@ -130,7 +133,10 @@ static void trs_sq_mem_ca_destroy(uint32_t devid) | |||
| 130 | (void)pthread_rwlock_unlock(&g_rwlock); | 133 | (void)pthread_rwlock_unlock(&g_rwlock); |
| 131 | } | 134 | } |
| 132 | 135 | ||
| 133 | -static struct trs_sq_mem_ca *trs_sq_mem_get_ca(uint32_t devid) { return g_ca[devid]; } | 136 | +static struct trs_sq_mem_ca *trs_sq_mem_get_ca(uint32_t devid) |
| 137 | +{ | ||
| 138 | + return g_ca[devid]; | ||
| 139 | +} | ||
| 134 | 140 | ||
| 135 | static int _trs_sq_mem_cache_alloc(struct trs_sq_mem_ca *ca, uint64_t *va, uint64_t size) | 141 | static int _trs_sq_mem_cache_alloc(struct trs_sq_mem_ca *ca, uint64_t *va, uint64_t size) |
| 136 | { | 142 | { |
| @@ -159,9 +165,8 @@ static void _trs_sq_mem_cache_free(struct trs_sq_mem_ca *ca, uint64_t va, uint64 | |||
| 159 | 165 | ||
| 160 | static bool trs_sq_mem_cache_is_support(uint32_t devid, uint64_t size) | 166 | static bool trs_sq_mem_cache_is_support(uint32_t devid, uint64_t size) |
| 161 | { | 167 | { |
| 162 | - return ( | 168 | + return ((devid < TRS_DEV_NUM) && (size <= TRS_SQ_MEM_CACHE_ALLOC_THRES) && |
| 163 | - (devid < TRS_DEV_NUM) && (size <= TRS_SQ_MEM_CACHE_ALLOC_THRES) && | 169 | + TRS_IS_ALIGNED(size, trs_sq_mem_ca_get_align())); |
| 164 | - TRS_IS_ALIGNED(size, trs_sq_mem_ca_get_align())); | ||
| 165 | } | 170 | } |
| 166 | 171 | ||
| 167 | int trs_sq_mem_cache_alloc(uint32_t devid, uint64_t *va, uint64_t size) | 172 | int trs_sq_mem_cache_alloc(uint32_t devid, uint64_t *va, uint64_t size) |
| @@ -231,10 +236,13 @@ static int trs_sq_mem_cache_dev_init(uint32_t devid) | |||
| 231 | return DRV_ERROR_NONE; | 236 | return DRV_ERROR_NONE; |
| 232 | } | 237 | } |
| 233 | 238 | ||
| 234 | -static void trs_sq_mem_cache_dev_uninit(uint32_t devid) { trs_sq_mem_ca_destroy(devid); } | 239 | +static void trs_sq_mem_cache_dev_uninit(uint32_t devid) |
| 240 | +{ | ||
| 241 | + trs_sq_mem_ca_destroy(devid); | ||
| 242 | +} | ||
| 235 | 243 | ||
| 236 | -static struct trs_dev_init_ops trs_sq_mem_cache_dev_ops = { | 244 | +static struct trs_dev_init_ops trs_sq_mem_cache_dev_ops = {.dev_init = trs_sq_mem_cache_dev_init, |
| 237 | - .dev_init = trs_sq_mem_cache_dev_init, .dev_uninit = trs_sq_mem_cache_dev_uninit}; | 245 | + .dev_uninit = trs_sq_mem_cache_dev_uninit}; |
| 238 | 246 | ||
| 239 | static void __attribute__((constructor)) trs_sq_mem_cache_set_up(void) | 247 | static void __attribute__((constructor)) trs_sq_mem_cache_set_up(void) |
| 240 | { | 248 | { |
| @@ -30,22 +30,40 @@ static THREAD__ int shrid_fd = -1; | |||
| 30 | static THREAD__ pid_t shrid_pid = -1; | 30 | static THREAD__ pid_t shrid_pid = -1; |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | -static int _shrid_open(const char *pathname, int flags) { return open(pathname, flags); } | 33 | +static int _shrid_open(const char *pathname, int flags) |
| 34 | +{ | ||
| 35 | + return open(pathname, flags); | ||
| 36 | +} | ||
| 34 | 37 | ||
| 35 | -static int _shrid_close(int fd) { return close(fd); } | 38 | +static int _shrid_close(int fd) |
| 39 | +{ | ||
| 40 | + return close(fd); | ||
| 41 | +} | ||
| 36 | 42 | ||
| 37 | -static int _shrid_ioctl(int fd, unsigned int cmd, void *para) { return ioctl(fd, cmd, para); } | 43 | +static int _shrid_ioctl(int fd, unsigned int cmd, void *para) |
| 44 | +{ | ||
| 45 | + return ioctl(fd, cmd, para); | ||
| 46 | +} | ||
| 38 | 47 | ||
| 39 | int _shrid_open(const char *pathname, int flags); | 48 | int _shrid_open(const char *pathname, int flags); |
| 40 | int _shrid_close(int fd); | 49 | int _shrid_close(int fd); |
| 41 | int _shrid_ioctl(int fd, unsigned int cmd, void *para); | 50 | int _shrid_ioctl(int fd, unsigned int cmd, void *para); |
| 42 | 51 | ||
| 43 | 52 | ||
| 44 | -static void shrid_set_pid(pid_t pid) { shrid_pid = pid; } | 53 | +static void shrid_set_pid(pid_t pid) |
| 54 | +{ | ||
| 55 | + shrid_pid = pid; | ||
| 56 | +} | ||
| 45 | 57 | ||
| 46 | -static int shrid_get_pid(void) { return shrid_pid; } | 58 | +static int shrid_get_pid(void) |
| 59 | +{ | ||
| 60 | + return shrid_pid; | ||
| 61 | +} | ||
| 47 | 62 | ||
| 48 | -void shrid_set_fd(int fd) { shrid_fd = fd; } | 63 | +void shrid_set_fd(int fd) |
| 64 | +{ | ||
| 65 | + shrid_fd = fd; | ||
| 66 | +} | ||
| 49 | 67 | ||
| 50 | static int _shrid_get_fd(void) | 68 | static int _shrid_get_fd(void) |
| 51 | { | 69 | { |
| @@ -164,7 +182,7 @@ drvError_t shrid_ioctl(u32 cmd, void *para) | |||
| 164 | } else if (errno == EPERM) { | 182 | } else if (errno == EPERM) { |
| 165 | return DRV_ERROR_OPER_NOT_PERMITTED; | 183 | return DRV_ERROR_OPER_NOT_PERMITTED; |
| 166 | } else { | 184 | } else { |
| 167 | - if ((errno == EACCES) && (cmd == SHR_ID_OPEN)){ | 185 | + if ((errno == EACCES) && (cmd == SHR_ID_OPEN)) { |
| 168 | ret = get_type_by_name(((struct shr_id_ioctl_info *)para)->name, &type); | 186 | ret = get_type_by_name(((struct shr_id_ioctl_info *)para)->name, &type); |
| 169 | if (ret != 0) { | 187 | if (ret != 0) { |
| 170 | trs_err("get type by name failed. (ret=%d)\n", ret); | 188 | trs_err("get type by name failed. (ret=%d)\n", ret); |
| @@ -21,9 +21,15 @@ int trs_res_reg_offset_query(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, | |||
| 21 | int trs_res_reg_total_size_query(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t *value); | 21 | int trs_res_reg_total_size_query(uint32_t dev_id, uint32_t ts_id, drvIdType_t type, uint32_t *value); |
| 22 | 22 | ||
| 23 | struct trs_shrid_remote_ops g_shrid_remote_ops; | 23 | struct trs_shrid_remote_ops g_shrid_remote_ops; |
| 24 | -void trs_register_shrid_remote_ops(struct trs_shrid_remote_ops *ops) { g_shrid_remote_ops = *ops; } | 24 | +void trs_register_shrid_remote_ops(struct trs_shrid_remote_ops *ops) |
| 25 | +{ | ||
| 26 | + g_shrid_remote_ops = *ops; | ||
| 27 | +} | ||
| 25 | 28 | ||
| 26 | -static struct trs_shrid_remote_ops *trs_get_shrid_remote_ops(void) { return &g_shrid_remote_ops; } | 29 | +static struct trs_shrid_remote_ops *trs_get_shrid_remote_ops(void) |
| 30 | +{ | ||
| 31 | + return &g_shrid_remote_ops; | ||
| 32 | +} | ||
| 27 | 33 | ||
| 28 | static drvError_t shrid_proc(uint32_t cmd, const char *name, struct shr_id_ioctl_info *ioctl_info) | 34 | static drvError_t shrid_proc(uint32_t cmd, const char *name, struct shr_id_ioctl_info *ioctl_info) |
| 29 | { | 35 | { |
| @@ -254,9 +260,8 @@ drvError_t halShrIdOpen(const char *name, struct drvShrIdInfo *info) | |||
| 254 | trs_err("Param invalid. (devid=%u)\n", dev_id); | 260 | trs_err("Param invalid. (devid=%u)\n", dev_id); |
| 255 | return DRV_ERROR_INVALID_VALUE; | 261 | return DRV_ERROR_INVALID_VALUE; |
| 256 | } | 262 | } |
| 257 | - trs_debug( | 263 | + trs_debug("Shr Info. (devid=%u; tsid=%u; shrid=%u; type=%d; flag=0x%x)\n", info->devid, info->tsid, |
| 258 | - "Shr Info. (devid=%u; tsid=%u; shrid=%u; type=%d; flag=0x%x)\n", info->devid, info->tsid, info->shrid, | 264 | + info->shrid, info->id_type, info->flag); |
| 259 | - info->id_type, info->flag); | ||
| 260 | err = trs_shrid_remote_config(dev_id, info); | 265 | err = trs_shrid_remote_config(dev_id, info); |
| 261 | if (err != DRV_ERROR_NONE) { | 266 | if (err != DRV_ERROR_NONE) { |
| 262 | (void)halShrIdClose(name); | 267 | (void)halShrIdClose(name); |
| @@ -282,9 +287,8 @@ drvError_t halShrIdClose(const char *name) | |||
| 282 | info.shrid = ioctl_info.shr_id; | 287 | info.shrid = ioctl_info.shr_id; |
| 283 | info.id_type = ioctl_info.id_type; | 288 | info.id_type = ioctl_info.id_type; |
| 284 | info.flag = ioctl_info.flag; /* for spod */ | 289 | info.flag = ioctl_info.flag; /* for spod */ |
| 285 | - trs_debug( | 290 | + trs_debug("Shr Info. (devid=%u; tsid=%u; shrid=%u; type=%d; flag=0x%x)\n", info.devid, info.tsid, |
| 286 | - "Shr Info. (devid=%u; tsid=%u; shrid=%u; type=%d; flag=0x%x)\n", info.devid, info.tsid, info.shrid, | 291 | + info.shrid, info.id_type, info.flag); |
| 287 | - info.id_type, info.flag); | ||
| 288 | return trs_shrid_remote_deconfig(ioctl_info.opened_devid, &info); | 292 | return trs_shrid_remote_deconfig(ioctl_info.opened_devid, &info); |
| 289 | } | 293 | } |
| 290 | } | 294 | } |
| @@ -301,8 +305,8 @@ drvError_t halShrIdSetPid(const char *name, pid_t pid[], uint32_t pid_num) | |||
| 301 | 305 | ||
| 302 | /* pass in only one parameter at a time in the current scene */ | 306 | /* pass in only one parameter at a time in the current scene */ |
| 303 | if ((name == NULL) || (pid == NULL) || (pid_num != 1)) { | 307 | if ((name == NULL) || (pid == NULL) || (pid_num != 1)) { |
| 304 | - trs_err( | 308 | + trs_err("invalid parameter. (name_is_null=%d, pid_is_null=%d, num=%d)\n", (name == NULL), (pid == NULL), |
| 305 | - "invalid parameter. (name_is_null=%d, pid_is_null=%d, num=%d)\n", (name == NULL), (pid == NULL), pid_num); | 309 | + pid_num); |
| 306 | return DRV_ERROR_INVALID_VALUE; | 310 | return DRV_ERROR_INVALID_VALUE; |
| 307 | } | 311 | } |
| 308 | 312 | ||
| @@ -427,7 +431,10 @@ drvError_t drvSetIpcNotifyPid(const char *name, pid_t pid[], int num) | |||
| 427 | } | 431 | } |
| 428 | 432 | ||
| 429 | /* Sunset interface: external statement has been removed from ascend_hal.h. */ | 433 | /* Sunset interface: external statement has been removed from ascend_hal.h. */ |
| 430 | -drvError_t drvRecordIpcNotify(const char *name) { return halShrIdRecord(name); } | 434 | +drvError_t drvRecordIpcNotify(const char *name) |
| 435 | +{ | ||
| 436 | + return halShrIdRecord(name); | ||
| 437 | +} | ||
| 431 | 438 | ||
| 432 | /* Sunset interface: external statement has been removed from ascend_hal.h. */ | 439 | /* Sunset interface: external statement has been removed from ascend_hal.h. */ |
| 433 | drvError_t drvNotifyIdAddrOffset(uint32_t devId, struct drvNotifyInfo *info) | 440 | drvError_t drvNotifyIdAddrOffset(uint32_t devId, struct drvNotifyInfo *info) |
| @@ -21,8 +21,9 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -static inline struct trs_core_ts_inst *trs_core_inst_get_for_res_map( | 24 | +static inline struct trs_core_ts_inst *trs_core_inst_get_for_res_map(struct trs_id_inst *id_inst, |
| 25 | - struct trs_id_inst *id_inst, struct trs_proc_ctx *proc_ctx, struct trs_cmd_res_map para) | 25 | + struct trs_proc_ctx *proc_ctx, |
| 26 | + struct trs_cmd_res_map para) | ||
| 26 | { | 27 | { |
| 27 | (void)para; | 28 | (void)para; |
| 28 | id_inst->devid = proc_ctx->devid; | 29 | id_inst->devid = proc_ctx->devid; |
| @@ -147,8 +147,8 @@ struct trs_core_adapt_ops { | |||
| 147 | int (*get_sq_trigger_irq)(struct trs_id_inst *inst, u32 *irq, u32 *irq_type); /* not must */ | 147 | int (*get_sq_trigger_irq)(struct trs_id_inst *inst, u32 *irq, u32 *irq_type); /* not must */ |
| 148 | int (*get_trigger_sqid)(struct trs_id_inst *inst, u32 *sqid); /* not must */ | 148 | int (*get_trigger_sqid)(struct trs_id_inst *inst, u32 *sqid); /* not must */ |
| 149 | void (*set_trigger_irq_affinity)(struct trs_id_inst *inst, u32 irq, u32 op); /* not must */ | 149 | void (*set_trigger_irq_affinity)(struct trs_id_inst *inst, u32 irq, u32 op); /* not must */ |
| 150 | - int (*request_irq)( | 150 | + int (*request_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, |
| 151 | - struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, ka_irqreturn_t (*handler)(int irq, void *para)); | 151 | + ka_irqreturn_t (*handler)(int irq, void *para)); |
| 152 | void (*free_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); | 152 | void (*free_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); |
| 153 | void (*set_thread_affinity)(struct trs_id_inst *inst, ka_task_struct_t *thread); | 153 | void (*set_thread_affinity)(struct trs_id_inst *inst, ka_task_struct_t *thread); |
| 154 | int (*ts_rpc_call)(struct trs_id_inst *inst, u8 *msg, u32 len); | 154 | int (*ts_rpc_call)(struct trs_id_inst *inst, u8 *msg, u32 len); |
| @@ -183,8 +183,8 @@ enum { | |||
| 183 | 183 | ||
| 184 | 184 | ||
| 185 | 185 | ||
| 186 | -int trs_core_ts_inst_register( | 186 | +int trs_core_ts_inst_register(struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, |
| 187 | - struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, struct trs_core_adapt_ops *ops); | 187 | + struct trs_core_adapt_ops *ops); |
| 188 | void trs_core_ts_inst_unregister(struct trs_id_inst *inst); | 188 | void trs_core_ts_inst_unregister(struct trs_id_inst *inst); |
| 189 | 189 | ||
| 190 | int trs_stream_bind_remote_sqcq(struct trs_id_inst *inst, u32 stream_id, u32 sqid, u32 cqid, int host_pid); | 190 | int trs_stream_bind_remote_sqcq(struct trs_id_inst *inst, u32 stream_id, u32 sqid, u32 cqid, int host_pid); |
| @@ -40,29 +40,26 @@ int trs_device_get_id_range(struct trs_id_inst *inst, int type, u32 *start, u32 | |||
| 40 | int trs_device_get_id_total_num(struct trs_id_inst *inst, int type, u32 *total_num); | 40 | int trs_device_get_id_total_num(struct trs_id_inst *inst, int type, u32 *total_num); |
| 41 | int trs_device_get_id_split(struct trs_id_inst *inst, int type, u32 *split); | 41 | int trs_device_get_id_split(struct trs_id_inst *inst, int type, u32 *split); |
| 42 | int trs_device_get_id_isolate_num(int type, u32 *isolate_num); | 42 | int trs_device_get_id_isolate_num(int type, u32 *isolate_num); |
| 43 | -int trs_device_get_id_range_by_isolate_num( | 43 | +int trs_device_get_id_range_by_isolate_num(struct id_pool_inst *inst, int type, u32 start, u32 end, u32 req_num, |
| 44 | - struct id_pool_inst *inst, int type, u32 start, u32 end, u32 req_num, u32 *alloc_num, u32 *id); | 44 | + u32 *alloc_num, u32 *id); |
| 45 | int trs_device_get_id_by_isolate_num(struct id_pool_inst *inst, int type, int req_num, u32 *alloc_num, u32 *id); | 45 | int trs_device_get_id_by_isolate_num(struct id_pool_inst *inst, int type, int req_num, u32 *alloc_num, u32 *id); |
| 46 | void trs_device_put_id_by_isolate_num(struct id_pool_inst *inst, int type, int batch_num, u32 *free_num, u32 *id); | 46 | void trs_device_put_id_by_isolate_num(struct id_pool_inst *inst, int type, int batch_num, u32 *free_num, u32 *id); |
| 47 | 47 | ||
| 48 | /* chan ops */ | 48 | /* chan ops */ |
| 49 | void trs_chan_update_ssid(struct trs_id_inst *inst, struct trs_chan_info *chan_info); | 49 | void trs_chan_update_ssid(struct trs_id_inst *inst, struct trs_chan_info *chan_info); |
| 50 | -void *trs_chan_ops_sq_mem_alloc( | 50 | +void *trs_chan_ops_sq_mem_alloc(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, |
| 51 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, | 51 | + struct trs_chan_mem_attr *mem_attr); |
| 52 | - struct trs_chan_mem_attr *mem_attr); | 52 | +void trs_chan_ops_sq_mem_free(struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, |
| 53 | -void trs_chan_ops_sq_mem_free( | 53 | + struct trs_chan_mem_attr *mem_attr); |
| 54 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, struct trs_chan_mem_attr *mem_attr); | 54 | +void *trs_chan_ops_cq_mem_alloc(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, |
| 55 | -void *trs_chan_ops_cq_mem_alloc( | 55 | + struct trs_chan_mem_attr *mem_attr); |
| 56 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, | 56 | +void trs_chan_ops_cq_mem_free(struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, |
| 57 | - struct trs_chan_mem_attr *mem_attr); | 57 | + struct trs_chan_mem_attr *mem_attr); |
| 58 | -void trs_chan_ops_cq_mem_free( | ||
| 59 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, struct trs_chan_mem_attr *mem_attr); | ||
| 60 | void trs_chan_ops_flush_sqe_cache(struct trs_id_inst *inst, u32 mem_type, void *addr, u64 pa, u32 len); | 58 | void trs_chan_ops_flush_sqe_cache(struct trs_id_inst *inst, u32 mem_type, void *addr, u64 pa, u32 len); |
| 61 | void trs_chan_ops_invalid_cqe_cache(struct trs_id_inst *inst, u32 mem_type, void *addr, u64 pa, u32 len); | 59 | void trs_chan_ops_invalid_cqe_cache(struct trs_id_inst *inst, u32 mem_type, void *addr, u64 pa, u32 len); |
| 62 | int trs_chan_get_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, u32 *valid_irq_num); | 60 | int trs_chan_get_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, u32 *valid_irq_num); |
| 63 | -int trs_chan_ops_request_irq( | 61 | +int trs_chan_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 64 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 62 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); |
| 65 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); | ||
| 66 | int trs_chan_free_irq(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); | 63 | int trs_chan_free_irq(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); |
| 67 | 64 | ||
| 68 | int trs_chan_ops_get_valid_cq_list(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num); | 65 | int trs_chan_ops_get_valid_cq_list(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num); |
| @@ -47,7 +47,12 @@ | |||
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | -enum { TRS_INST_STATUS_UNINIT = 0, TRS_INST_STATUS_NORMAL, TRS_INST_STATUS_ABNORMAL, TRS_INST_STATUS_MAX }; | 50 | +enum { |
| 51 | + TRS_INST_STATUS_UNINIT = 0, | ||
| 52 | + TRS_INST_STATUS_NORMAL, | ||
| 53 | + TRS_INST_STATUS_ABNORMAL, | ||
| 54 | + TRS_INST_STATUS_MAX | ||
| 55 | +}; | ||
| 51 | 56 | ||
| 52 | enum trsSqSendMode { | 57 | enum trsSqSendMode { |
| 53 | TRS_MODE_TYPE_SQ_SEND_HIGH_SECURITY = 0x0, /* sq use uik mode */ | 58 | TRS_MODE_TYPE_SQ_SEND_HIGH_SECURITY = 0x0, /* sq use uik mode */ |
| @@ -55,7 +60,10 @@ enum trsSqSendMode { | |||
| 55 | TRS_MODE_TYPE_SQ_SEND_MAX | 60 | TRS_MODE_TYPE_SQ_SEND_MAX |
| 56 | }; | 61 | }; |
| 57 | 62 | ||
| 58 | -typedef enum tagTrsModeType { TRS_MODE_TYPE_SQ_SEND = 0, TRS_MODE_TYPE_MAX } trsModeType_t; | 63 | +typedef enum tagTrsModeType { |
| 64 | + TRS_MODE_TYPE_SQ_SEND = 0, | ||
| 65 | + TRS_MODE_TYPE_MAX | ||
| 66 | +} trsModeType_t; | ||
| 59 | 67 | ||
| 60 | struct trsModeInfo { | 68 | struct trsModeInfo { |
| 61 | uint32_t devId; | 69 | uint32_t devId; |
| @@ -66,43 +74,38 @@ struct trsModeInfo { | |||
| 66 | 74 | ||
| 67 | 75 | ||
| 68 | 76 | ||
| 69 | -#define trs_err(fmt, ...) \ | 77 | +#define trs_err(fmt, ...) \ |
| 70 | - do { \ | 78 | + do { \ |
| 71 | - drv_err( \ | 79 | + drv_err(module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ |
| 72 | - module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ | 80 | + ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ |
| 73 | - ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ | 81 | + share_log_err(TSDRV_SHARE_LOG_START, fmt, ##__VA_ARGS__); \ |
| 74 | - share_log_err(TSDRV_SHARE_LOG_START, fmt, ##__VA_ARGS__); \ | ||
| 75 | } while (0) | 82 | } while (0) |
| 76 | -#define trs_warn(fmt, ...) \ | 83 | +#define trs_warn(fmt, ...) \ |
| 77 | - do { \ | 84 | + do { \ |
| 78 | - drv_warn( \ | 85 | + drv_warn(module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ |
| 79 | - module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ | 86 | + ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ |
| 80 | - ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ | ||
| 81 | } while (0) | 87 | } while (0) |
| 82 | 88 | ||
| 83 | 89 | ||
| 84 | 90 | ||
| 85 | 91 | ||
| 86 | -#define trs_info(fmt, ...) \ | 92 | +#define trs_info(fmt, ...) \ |
| 87 | - do { \ | 93 | + do { \ |
| 88 | - drv_info( \ | 94 | + drv_info(module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ |
| 89 | - module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ | 95 | + ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ |
| 90 | - ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ | ||
| 91 | } while (0) | 96 | } while (0) |
| 92 | -#define trs_debug(fmt, ...) \ | 97 | +#define trs_debug(fmt, ...) \ |
| 93 | - do { \ | 98 | + do { \ |
| 94 | - drv_pr_debug( \ | 99 | + drv_pr_debug(module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ |
| 95 | - module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ | 100 | + ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ |
| 96 | - ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ | ||
| 97 | } while (0) | 101 | } while (0) |
| 98 | 102 | ||
| 99 | 103 | ||
| 100 | 104 | ||
| 101 | -#define trs_info_ratelimited(fmt, ...) \ | 105 | +#define trs_info_ratelimited(fmt, ...) \ |
| 102 | - do { \ | 106 | + do { \ |
| 103 | - drv_info_ratelimited( \ | 107 | + drv_info_ratelimited(module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ |
| 104 | - module_trs, "<%s:%d:%d:%d> " fmt, ka_task_get_current_comm(), ka_task_get_current_tgid(), \ | 108 | + ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ |
| 105 | - ka_task_get_current_pid(), ka_system_raw_smp_processor_id(), ##__VA_ARGS__); \ | ||
| 106 | } while (0) | 109 | } while (0) |
| 107 | 110 | ||
| 108 | 111 | ||
| @@ -184,7 +187,11 @@ static const char *trs_id_type_name[TRS_ID_TYPE_MAX] = { | |||
| 184 | [TRS_CB_SQ_ID] = "CbSqId", [TRS_CB_CQ_ID] = "CbCqId", [TRS_CDQM_ID] = "CdqmId", | 187 | [TRS_CB_SQ_ID] = "CbSqId", [TRS_CB_CQ_ID] = "CbCqId", [TRS_CDQM_ID] = "CdqmId", |
| 185 | [TRS_CNT_NOTIFY_ID] = "CntNotify"}; | 188 | [TRS_CNT_NOTIFY_ID] = "CntNotify"}; |
| 186 | 189 | ||
| 187 | -enum { TRS_ID_NODE_DEFAULT_LEVEL = 0, TRS_ID_NODE_SECOND_LEVEL, TRS_ID_NODE_LEVEL_MAX }; | 190 | +enum { |
| 191 | + TRS_ID_NODE_DEFAULT_LEVEL = 0, | ||
| 192 | + TRS_ID_NODE_SECOND_LEVEL, | ||
| 193 | + TRS_ID_NODE_LEVEL_MAX | ||
| 194 | +}; | ||
| 188 | 195 | ||
| 189 | static inline bool trs_id_is_local_type(int type) | 196 | static inline bool trs_id_is_local_type(int type) |
| 190 | { | 197 | { |
| @@ -198,10 +205,9 @@ static inline bool trs_id_need_divide_type(int type) | |||
| 198 | 205 | ||
| 199 | static inline bool trs_id_is_hw_divide_type(int type) | 206 | static inline bool trs_id_is_hw_divide_type(int type) |
| 200 | { | 207 | { |
| 201 | - return ( | 208 | + return ((type == TRS_EVENT_ID) || (type == TRS_NOTIFY_ID) || (type == TRS_CNT_NOTIFY_ID) || (type == TRS_CMO_ID) || |
| 202 | - (type == TRS_EVENT_ID) || (type == TRS_NOTIFY_ID) || (type == TRS_CNT_NOTIFY_ID) || (type == TRS_CMO_ID) || | 209 | + (type == TRS_HW_SQ_ID) || (type == TRS_HW_CQ_ID) || (type == TRS_RSV_HW_SQ_ID) || |
| 203 | - (type == TRS_HW_SQ_ID) || (type == TRS_HW_CQ_ID) || (type == TRS_RSV_HW_SQ_ID) || (type == TRS_RSV_HW_CQ_ID) || | 210 | + (type == TRS_RSV_HW_CQ_ID) || (type == TRS_CDQM_ID)); |
| 204 | - (type == TRS_CDQM_ID)); | ||
| 205 | } | 211 | } |
| 206 | 212 | ||
| 207 | static inline int trs_id_type_replace(int type) | 213 | static inline int trs_id_type_replace(int type) |
| @@ -233,7 +239,10 @@ static inline void trs_id_inst_pack(struct trs_id_inst *inst, u32 devid, u32 tsi | |||
| 233 | inst->tsid = tsid; | 239 | inst->tsid = tsid; |
| 234 | } | 240 | } |
| 235 | 241 | ||
| 236 | -static inline u32 trs_id_inst_to_ts_inst(struct trs_id_inst *inst) { return inst->devid * TRS_TS_MAX_NUM + inst->tsid; } | 242 | +static inline u32 trs_id_inst_to_ts_inst(struct trs_id_inst *inst) |
| 243 | +{ | ||
| 244 | + return inst->devid * TRS_TS_MAX_NUM + inst->tsid; | ||
| 245 | +} | ||
| 237 | 246 | ||
| 238 | static inline void trs_ts_inst_to_id_inst(u32 ts_inst_id, struct trs_id_inst *inst) | 247 | static inline void trs_ts_inst_to_id_inst(u32 ts_inst_id, struct trs_id_inst *inst) |
| 239 | { | 248 | { |
| @@ -256,7 +265,10 @@ static inline int trs_id_inst_check(struct trs_id_inst *inst) | |||
| 256 | return 0; | 265 | return 0; |
| 257 | } | 266 | } |
| 258 | 267 | ||
| 259 | -static inline bool trs_bitmap_bit_is_vaild(u32 bitmap, u32 bit) { return (bitmap & (1ul << bit)); } | 268 | +static inline bool trs_bitmap_bit_is_vaild(u32 bitmap, u32 bit) |
| 269 | +{ | ||
| 270 | + return (bitmap & (1ul << bit)); | ||
| 271 | +} | ||
| 260 | 272 | ||
| 261 | static inline void trs_try_resched(unsigned long *cur_jiffies, unsigned long timeout_ms) | 273 | static inline void trs_try_resched(unsigned long *cur_jiffies, unsigned long timeout_ms) |
| 262 | { | 274 | { |
| @@ -288,7 +300,10 @@ bool trs_is_reboot_active(void); | |||
| 288 | .priority = 1, \ | 300 | .priority = 1, \ |
| 289 | }; \ | 301 | }; \ |
| 290 | \ | 302 | \ |
| 291 | - bool trs_is_reboot_active(void) { return (g_trs_active_reboot == true); } | 303 | + bool trs_is_reboot_active(void) \ |
| 304 | + { \ | ||
| 305 | + return (g_trs_active_reboot == true); \ | ||
| 306 | + } | ||
| 292 | 307 | ||
| 293 | 308 | ||
| 294 | 309 | ||
| @@ -20,7 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | -bool hal_kernel_trs_is_belong_to_pod_proc( | 23 | +bool hal_kernel_trs_is_belong_to_pod_proc(unsigned int sdid, unsigned int tsid, int pid, int res_type, |
| 24 | - unsigned int sdid, unsigned int tsid, int pid, int res_type, unsigned int res_id); | 24 | + unsigned int res_id); |
| 25 | int trs_pod_msg_recv_async(u32 devid, u32 sdid, void *msg, size_t size, int *cmd_result, u32 mode); | 25 | int trs_pod_msg_recv_async(u32 devid, u32 sdid, void *msg, size_t size, int *cmd_result, u32 mode); |
| 26 | 26 | ||
| @@ -53,8 +53,8 @@ struct trs_dma_desc { | |||
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | /* sqid sqeid --key */ | 55 | /* sqid sqeid --key */ |
| 56 | -int hal_kernel_sqe_update_desc_create( | 56 | +int hal_kernel_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 57 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc); | 57 | + struct trs_dma_desc *dma_desc); |
| 58 | void hal_kernel_sqe_update_desc_destroy(u32 devid, u32 tsid, u32 sqid); | 58 | void hal_kernel_sqe_update_desc_destroy(u32 devid, u32 tsid, u32 sqid); |
| 59 | 59 | ||
| 60 | int hal_kernel_trs_get_ssid(u32 devid, u32 tsid, int pid, u32 *passid); | 60 | int hal_kernel_trs_get_ssid(u32 devid, u32 tsid, int pid, u32 *passid); |
| @@ -62,6 +62,6 @@ int hal_kernel_trs_get_ssid(u32 devid, u32 tsid, int pid, u32 *passid); | |||
| 62 | int trs_sqe_update_init(u32 devid); | 62 | int trs_sqe_update_init(u32 devid); |
| 63 | void trs_sqe_update_uninit(u32 devid); | 63 | void trs_sqe_update_uninit(u32 devid); |
| 64 | 64 | ||
| 65 | -int trs_sqe_update_desc_create( | 65 | +int trs_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 66 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc, bool is_src_secure); | 66 | + struct trs_dma_desc *dma_desc, bool is_src_secure); |
| 67 | 67 | ||
| @@ -25,5 +25,8 @@ static inline u64 trs_get_us_timestamp(void) | |||
| 25 | 25 | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | -static inline u64 trs_get_s_timestamp(void) { return (ka_jiffies / KA_HZ); } | 28 | +static inline u64 trs_get_s_timestamp(void) |
| 29 | +{ | ||
| 30 | + return (ka_jiffies / KA_HZ); | ||
| 31 | +} | ||
| 29 | 32 | ||
| @@ -36,7 +36,10 @@ void trs_stars_trace_cqe_fill(struct trs_id_inst *inst, struct trs_chan_cq_trace | |||
| 36 | cq_trace->sq_head = cqe_->sq_head; | 36 | cq_trace->sq_head = cqe_->sq_head; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | -void trs_stars_cqe_get_sqid(struct trs_id_inst *inst, void *cqe, u32 *sqid) { *sqid = ((rt_stars_cqe_t *)cqe)->sq_id; } | 39 | +void trs_stars_cqe_get_sqid(struct trs_id_inst *inst, void *cqe, u32 *sqid) |
| 40 | +{ | ||
| 41 | + *sqid = ((rt_stars_cqe_t *)cqe)->sq_id; | ||
| 42 | +} | ||
| 40 | 43 | ||
| 41 | void trs_stars_cqe_get_sq_head(struct trs_id_inst *inst, void *cqe, u32 *sq_head) | 44 | void trs_stars_cqe_get_sq_head(struct trs_id_inst *inst, void *cqe, u32 *sq_head) |
| 42 | { | 45 | { |
| @@ -64,7 +67,10 @@ static inline u64 trs_stars_cq_get_timestamp(rt_stars_cqe_t *cqe) | |||
| 64 | return timestamp; | 67 | return timestamp; |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | -static inline u8 trs_stars_cq_get_sqe_type(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.sqe_type; } | 70 | +static inline u8 trs_stars_cq_get_sqe_type(rt_stars_cqe_t *cqe) |
| 71 | +{ | ||
| 72 | + return cqe->cqe_status.error_info.sqe_type; | ||
| 73 | +} | ||
| 68 | 74 | ||
| 69 | static inline u8 trs_stars_cq_get_warn_type(rt_stars_cqe_t *cqe) | 75 | static inline u8 trs_stars_cq_get_warn_type(rt_stars_cqe_t *cqe) |
| 70 | { | 76 | { |
| @@ -76,13 +82,25 @@ static inline u8 trs_stars_cq_get_err_type(rt_stars_cqe_t *cqe) | |||
| 76 | return (u8)((cqe->cqe_status.sys_cnt.syscnt_low & 0x3F) | trs_stars_cq_get_warn_type(cqe)); | 82 | return (u8)((cqe->cqe_status.sys_cnt.syscnt_low & 0x3F) | trs_stars_cq_get_warn_type(cqe)); |
| 77 | } | 83 | } |
| 78 | 84 | ||
| 79 | -static inline u8 trs_stars_cq_get_drop_flag(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.drop_flag; } | 85 | +static inline u8 trs_stars_cq_get_drop_flag(rt_stars_cqe_t *cqe) |
| 86 | +{ | ||
| 87 | + return cqe->cqe_status.error_info.drop_flag; | ||
| 88 | +} | ||
| 80 | 89 | ||
| 81 | -static inline u32 trs_stars_cq_get_err_code(rt_stars_cqe_t *cqe) { return cqe->cqe_status.sys_cnt.syscnt_high; } | 90 | +static inline u32 trs_stars_cq_get_err_code(rt_stars_cqe_t *cqe) |
| 91 | +{ | ||
| 92 | + return cqe->cqe_status.sys_cnt.syscnt_high; | ||
| 93 | +} | ||
| 82 | 94 | ||
| 83 | -static inline u16 trs_stars_cq_get_acc_error(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.acc_error; } | 95 | +static inline u16 trs_stars_cq_get_acc_error(rt_stars_cqe_t *cqe) |
| 96 | +{ | ||
| 97 | + return cqe->cqe_status.error_info.acc_error; | ||
| 98 | +} | ||
| 84 | 99 | ||
| 85 | -static inline u16 trs_stars_cq_get_sqe_index(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.sqe_index; } | 100 | +static inline u16 trs_stars_cq_get_sqe_index(rt_stars_cqe_t *cqe) |
| 101 | +{ | ||
| 102 | + return cqe->cqe_status.error_info.sqe_index; | ||
| 103 | +} | ||
| 86 | 104 | ||
| 87 | static inline bool trs_stars_cq_has_syscnt(rt_stars_cqe_t *cqe) | 105 | static inline bool trs_stars_cq_has_syscnt(rt_stars_cqe_t *cqe) |
| 88 | { | 106 | { |
| @@ -25,8 +25,8 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | -int trs_stars_v2_chan_ops_get_valid_cq_list( | 28 | +int trs_stars_v2_chan_ops_get_valid_cq_list(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, |
| 29 | - struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num) | 29 | + u32 *valid_cq_num) |
| 30 | { | 30 | { |
| 31 | 31 | ||
| 32 | return trs_stars_v2_cq_get_valid_list(inst, group, cqid, cq_id_num, valid_cq_num); | 32 | return trs_stars_v2_cq_get_valid_list(inst, group, cqid, cq_id_num, valid_cq_num); |
| @@ -23,8 +23,8 @@ int trs_stars_v2_chan_ops_ctrl_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u | |||
| 23 | int trs_stars_v2_chan_ops_query_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u64 *value); | 23 | int trs_stars_v2_chan_ops_query_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u64 *value); |
| 24 | int trs_stars_chan_ops_ctrl_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u32 para); | 24 | int trs_stars_chan_ops_ctrl_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u32 para); |
| 25 | int trs_stars_chan_ops_query_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u64 *value); | 25 | int trs_stars_chan_ops_query_sqcq(struct trs_id_inst *inst, u32 id, u32 cmd, u64 *value); |
| 26 | -int trs_stars_v2_chan_ops_get_valid_cq_list( | 26 | +int trs_stars_v2_chan_ops_get_valid_cq_list(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, |
| 27 | - struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num); | 27 | + u32 *valid_cq_num); |
| 28 | void trs_stars_v2_chan_ops_intr_mask_config(struct trs_id_inst *inst, u32 group, u32 irq, int val); | 28 | void trs_stars_v2_chan_ops_intr_mask_config(struct trs_id_inst *inst, u32 group, u32 irq, int val); |
| 29 | int trs_stars_v2_chan_ops_get_sq_head_paddr(struct trs_id_inst *inst, u32 sqid, u64 *paddr); | 29 | int trs_stars_v2_chan_ops_get_sq_head_paddr(struct trs_id_inst *inst, u32 sqid, u64 *paddr); |
| 30 | int trs_stars_v2_chan_ops_get_sq_tail_paddr(struct trs_id_inst *inst, u32 sqid, u64 *paddr); | 30 | int trs_stars_v2_chan_ops_get_sq_tail_paddr(struct trs_id_inst *inst, u32 sqid, u64 *paddr); |
| @@ -68,7 +68,10 @@ static inline u64 trs_stars_cq_get_timestamp(rt_stars_cqe_t *cqe) | |||
| 68 | return timestamp; | 68 | return timestamp; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | -static inline u8 trs_stars_cq_get_sqe_type(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.sqe_type; } | 71 | +static inline u8 trs_stars_cq_get_sqe_type(rt_stars_cqe_t *cqe) |
| 72 | +{ | ||
| 73 | + return cqe->cqe_status.error_info.sqe_type; | ||
| 74 | +} | ||
| 72 | 75 | ||
| 73 | static inline bool trs_stars_cq_is_dvpp_type(rt_stars_cqe_t *cqe) | 76 | static inline bool trs_stars_cq_is_dvpp_type(rt_stars_cqe_t *cqe) |
| 74 | { | 77 | { |
| @@ -95,10 +98,16 @@ static inline u8 trs_stars_cq_get_next_task_vld(rt_stars_cqe_t *cqe) | |||
| 95 | return cqe->cqe_status.error_info.next_task_vld; | 98 | return cqe->cqe_status.error_info.next_task_vld; |
| 96 | } | 99 | } |
| 97 | 100 | ||
| 98 | -static inline u32 trs_stars_cq_get_err_code(rt_stars_cqe_t *cqe) { return cqe->cqe_status.sys_cnt.syscnt_high; } | 101 | +static inline u32 trs_stars_cq_get_err_code(rt_stars_cqe_t *cqe) |
| 102 | +{ | ||
| 103 | + return cqe->cqe_status.sys_cnt.syscnt_high; | ||
| 104 | +} | ||
| 99 | 105 | ||
| 100 | 106 | ||
| 101 | -static inline u32 trs_stars_cq_get_int_err(rt_stars_cqe_t *cqe) { return cqe->cqe_status.dvpp_info.int_err; } | 107 | +static inline u32 trs_stars_cq_get_int_err(rt_stars_cqe_t *cqe) |
| 108 | +{ | ||
| 109 | + return cqe->cqe_status.dvpp_info.int_err; | ||
| 110 | +} | ||
| 102 | 111 | ||
| 103 | 112 | ||
| 104 | static inline u16 trs_stars_cq_get_notify_attached(rt_stars_cqe_t *cqe) | 113 | static inline u16 trs_stars_cq_get_notify_attached(rt_stars_cqe_t *cqe) |
| @@ -106,14 +115,20 @@ static inline u16 trs_stars_cq_get_notify_attached(rt_stars_cqe_t *cqe) | |||
| 106 | return cqe->cqe_status.error_info.notify_attached; | 115 | return cqe->cqe_status.error_info.notify_attached; |
| 107 | } | 116 | } |
| 108 | 117 | ||
| 109 | -static inline u16 trs_stars_cq_get_sqe_index(rt_stars_cqe_t *cqe) { return cqe->cqe_status.error_info.sqe_index; } | 118 | +static inline u16 trs_stars_cq_get_sqe_index(rt_stars_cqe_t *cqe) |
| 119 | +{ | ||
| 120 | + return cqe->cqe_status.error_info.sqe_index; | ||
| 121 | +} | ||
| 110 | 122 | ||
| 111 | static inline bool trs_stars_cq_has_syscnt(rt_stars_cqe_t *cqe) | 123 | static inline bool trs_stars_cq_has_syscnt(rt_stars_cqe_t *cqe) |
| 112 | { | 124 | { |
| 113 | return (((cqe->evt == 1) || (cqe->place_hold == 1)) && (cqe->error_bit == 0)); | 125 | return (((cqe->evt == 1) || (cqe->place_hold == 1)) && (cqe->error_bit == 0)); |
| 114 | } | 126 | } |
| 115 | 127 | ||
| 116 | -u16 trs_stars_v2_cqe_get_match_flag(rt_stars_cqe_t *cqe) { return 0; } | 128 | +u16 trs_stars_v2_cqe_get_match_flag(rt_stars_cqe_t *cqe) |
| 129 | +{ | ||
| 130 | + return 0; | ||
| 131 | +} | ||
| 117 | 132 | ||
| 118 | /* need to adapt stars_v2 */ | 133 | /* need to adapt stars_v2 */ |
| 119 | void trs_stars_v2_cqe_to_logic_cqe(void *hw_cqe, struct trs_logic_cqe *logic_cqe) | 134 | void trs_stars_v2_cqe_to_logic_cqe(void *hw_cqe, struct trs_logic_cqe *logic_cqe) |
| @@ -90,8 +90,8 @@ static void trs_chan_irq_tasklet(unsigned long data) | |||
| 90 | 90 | ||
| 91 | while (1) { | 91 | while (1) { |
| 92 | if (chan_irq->attr.get_valid_cq != NULL) { | 92 | if (chan_irq->attr.get_valid_cq != NULL) { |
| 93 | - ret = chan_irq->attr.get_valid_cq( | 93 | + ret = chan_irq->attr.get_valid_cq(&chan_irq->inst, chan_irq->attr.group, chan_irq->cqid_list, |
| 94 | - &chan_irq->inst, chan_irq->attr.group, chan_irq->cqid_list, MAX_PROC_CQ_NUM, &cq_num); | 94 | + MAX_PROC_CQ_NUM, &cq_num); |
| 95 | if (ret == 0) { | 95 | if (ret == 0) { |
| 96 | cqid_list = chan_irq->cqid_list; | 96 | cqid_list = chan_irq->cqid_list; |
| 97 | } | 97 | } |
| @@ -143,8 +143,8 @@ static ka_irqreturn_t trs_adapt_chan_irq_proc(int irq, void *para) | |||
| 143 | return KA_IRQ_HANDLED; | 143 | return KA_IRQ_HANDLED; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | -static struct trs_chan_irq *trs_create_chan_irq( | 146 | +static struct trs_chan_irq *trs_create_chan_irq(struct trs_id_inst *inst, u32 irq, int irq_type, |
| 147 | - struct trs_id_inst *inst, u32 irq, int irq_type, struct trs_chan_irq_attr *attr) | 147 | + struct trs_chan_irq_attr *attr) |
| 148 | { | 148 | { |
| 149 | struct trs_chan_irq *chan_irq = trs_vzalloc(sizeof(struct trs_chan_irq)); | 149 | struct trs_chan_irq *chan_irq = trs_vzalloc(sizeof(struct trs_chan_irq)); |
| 150 | 150 | ||
| @@ -30,8 +30,8 @@ struct trs_chan_irq_attr { | |||
| 30 | int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num); | 30 | int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num); |
| 31 | int (*get_valid_cq)(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num); | 31 | int (*get_valid_cq)(struct trs_id_inst *inst, u32 group, u32 cqid[], u32 cq_id_num, u32 *valid_cq_num); |
| 32 | void (*intr_mask_config)(struct trs_id_inst *inst, u32 group, u32 irq, int val); | 32 | void (*intr_mask_config)(struct trs_id_inst *inst, u32 group, u32 irq, int val); |
| 33 | - int (*request_chan_irq)( | 33 | + int (*request_chan_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, |
| 34 | - struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, ka_irqreturn_t (*handler)(int irq, void *para)); | 34 | + ka_irqreturn_t (*handler)(int irq, void *para)); |
| 35 | void (*free_chan_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); | 35 | void (*free_chan_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| @@ -92,8 +92,8 @@ static void trs_chan_ops_hw_create_mbox_pack_host_streamid(struct trs_id_inst *i | |||
| 92 | *host_ssid = pcie_vfid; /* see swapbuffer host streamid */ | 92 | *host_ssid = pcie_vfid; /* see swapbuffer host streamid */ |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | -static void trs_chan_ops_hw_create_mbox_fill_ext_info( | 95 | +static void trs_chan_ops_hw_create_mbox_fill_ext_info(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 96 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_normal_cqsq_mailbox *mbox_data) | 96 | + struct trs_normal_cqsq_mailbox *mbox_data) |
| 97 | { | 97 | { |
| 98 | struct trs_ext_info_header *header = NULL; | 98 | struct trs_ext_info_header *header = NULL; |
| 99 | 99 | ||
| @@ -118,31 +118,31 @@ static void trs_chan_ops_hw_create_mbox_fill_ext_info( | |||
| 118 | header->hccp_pid = (ret == 0) ? hccp_tgid : 0; | 118 | header->hccp_pid = (ret == 0) ? hccp_tgid : 0; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | - trs_debug( | 121 | + trs_debug("(device_pid=%d; host_pid=%d; hccp_pid=%d)\n", ka_task_get_current_tgid(), master_tgid, |
| 122 | - "(device_pid=%d; host_pid=%d; hccp_pid=%d)\n", ka_task_get_current_tgid(), master_tgid, hccp_tgid); | 122 | + hccp_tgid); |
| 123 | 123 | ||
| 124 | } else { | 124 | } else { |
| 125 | 125 | ||
| 126 | - ret = hal_kernel_apm_query_slave_tgid_by_master( | 126 | + ret = hal_kernel_apm_query_slave_tgid_by_master(ka_task_get_current_tgid(), inst->devid, PROCESS_CP1, |
| 127 | - ka_task_get_current_tgid(), inst->devid, PROCESS_CP1, &slave_tgid); | 127 | + &slave_tgid); |
| 128 | if (ret == 0) { | 128 | if (ret == 0) { |
| 129 | header->cp_pid = slave_tgid; | 129 | header->cp_pid = slave_tgid; |
| 130 | } | 130 | } |
| 131 | - ret = hal_kernel_apm_query_slave_tgid_by_master( | 131 | + ret = hal_kernel_apm_query_slave_tgid_by_master(ka_task_get_current_tgid(), inst->devid, PROCESS_HCCP, |
| 132 | - ka_task_get_current_tgid(), inst->devid, PROCESS_HCCP, &slave_tgid); | 132 | + &slave_tgid); |
| 133 | if (ret == 0) { | 133 | if (ret == 0) { |
| 134 | header->hccp_pid = slave_tgid; | 134 | header->hccp_pid = slave_tgid; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | 137 | ||
| 138 | - ret = devdrv_query_process_by_host_pid( | 138 | + ret = devdrv_query_process_by_host_pid(ka_task_get_current_tgid(), inst->devid, DEVDRV_PROCESS_CP1, 0, |
| 139 | - ka_task_get_current_tgid(), inst->devid, DEVDRV_PROCESS_CP1, 0, &slave_tgid); | 139 | + &slave_tgid); |
| 140 | if (ret == 0) { | 140 | if (ret == 0) { |
| 141 | header->cp_pid = slave_tgid; | 141 | header->cp_pid = slave_tgid; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | - trs_debug( | 144 | + trs_debug("(current=%d; cp_pid=%d; hccp_pid=%d)\n", ka_task_get_current_tgid(), header->cp_pid, |
| 145 | - "(current=%d; cp_pid=%d; hccp_pid=%d)\n", ka_task_get_current_tgid(), header->cp_pid, header->hccp_pid); | 145 | + header->hccp_pid); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | trs_chan_ops_hw_create_mbox_pack_host_streamid(inst, &header->host_ssid); | 148 | trs_chan_ops_hw_create_mbox_pack_host_streamid(inst, &header->host_ssid); |
| @@ -159,14 +159,14 @@ static void trs_chan_ops_hw_create_mbox_fill_ext_info( | |||
| 159 | mbox_data->cq_irq, mbox_data->ssid, mbox_data->ts_info.info[0], mbox_data->ts_info.ext_msg_len); | 159 | mbox_data->cq_irq, mbox_data->ssid, mbox_data->ts_info.info[0], mbox_data->ts_info.ext_msg_len); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | - trs_debug( | 162 | + trs_debug("Mailbox msg. (pid=%d; device_pid=%u; is_convert_pid=%u; host_ssid=%u; ext_msg_len=%u)\n", |
| 163 | - "Mailbox msg. (pid=%d; device_pid=%u; is_convert_pid=%u; host_ssid=%u; ext_msg_len=%u)\n", mbox_data->pid, | 163 | + mbox_data->pid, header->cp_pid, mbox_data->is_convert_pid, header->host_ssid, |
| 164 | - header->cp_pid, mbox_data->is_convert_pid, header->host_ssid, mbox_data->ts_info.ext_msg_len); | 164 | + mbox_data->ts_info.ext_msg_len); |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | -static int trs_chan_ops_hw_create_mbox_send( | 168 | +static int trs_chan_ops_hw_create_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 169 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 169 | + struct trs_chan_adapt_info *adapt) |
| 170 | { | 170 | { |
| 171 | struct trs_normal_cqsq_mailbox mbox_data; | 171 | struct trs_normal_cqsq_mailbox mbox_data; |
| 172 | u32 cq_irq; | 172 | u32 cq_irq; |
| @@ -219,16 +219,15 @@ static int trs_chan_ops_hw_create_mbox_send( | |||
| 219 | 219 | ||
| 220 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_normal_cqsq_mailbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 220 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_normal_cqsq_mailbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 221 | if ((ret != 0) || (mbox_data.header.result != 0)) { | 221 | if ((ret != 0) || (mbox_data.header.result != 0)) { |
| 222 | - trs_err( | 222 | + trs_err("Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 223 | - "Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 223 | + mbox_data.header.result, ret); |
| 224 | - mbox_data.header.result, ret); | ||
| 225 | ret = -EFAULT; | 224 | ret = -EFAULT; |
| 226 | } | 225 | } |
| 227 | return ret; | 226 | return ret; |
| 228 | } | 227 | } |
| 229 | 228 | ||
| 230 | -static int trs_chan_ops_hw_release_mbox_send( | 229 | +static int trs_chan_ops_hw_release_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 231 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 230 | + struct trs_chan_adapt_info *adapt) |
| 232 | { | 231 | { |
| 233 | struct trs_normal_cqsq_mailbox mbox_data; | 232 | struct trs_normal_cqsq_mailbox mbox_data; |
| 234 | u16 cmd; | 233 | u16 cmd; |
| @@ -262,17 +261,16 @@ static int trs_chan_ops_hw_release_mbox_send( | |||
| 262 | if (ret == -ENXIO) { | 261 | if (ret == -ENXIO) { |
| 263 | trs_warn("Mb chan is not exist. (devid=%u; tsid=%u; cmd=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, ret); | 262 | trs_warn("Mb chan is not exist. (devid=%u; tsid=%u; cmd=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, ret); |
| 264 | } else { | 263 | } else { |
| 265 | - trs_err( | 264 | + trs_err("Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 266 | - "Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 265 | + mbox_data.header.result, ret); |
| 267 | - mbox_data.header.result, ret); | ||
| 268 | ret = -EFAULT; | 266 | ret = -EFAULT; |
| 269 | } | 267 | } |
| 270 | } | 268 | } |
| 271 | return ret; | 269 | return ret; |
| 272 | } | 270 | } |
| 273 | 271 | ||
| 274 | -static int trs_chan_ops_maint_create_mbox_send( | 272 | +static int trs_chan_ops_maint_create_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 275 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 273 | + struct trs_chan_adapt_info *adapt) |
| 276 | { | 274 | { |
| 277 | struct trs_maint_sqcq_mbox mbox_data; | 275 | struct trs_maint_sqcq_mbox mbox_data; |
| 278 | u32 cq_irq; | 276 | u32 cq_irq; |
| @@ -303,16 +301,15 @@ static int trs_chan_ops_maint_create_mbox_send( | |||
| 303 | 301 | ||
| 304 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_maint_sqcq_mbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 302 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_maint_sqcq_mbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 305 | if ((ret != 0) || (mbox_data.header.result != 0)) { | 303 | if ((ret != 0) || (mbox_data.header.result != 0)) { |
| 306 | - trs_err( | 304 | + trs_err("Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 307 | - "Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 305 | + mbox_data.header.result, ret); |
| 308 | - mbox_data.header.result, ret); | ||
| 309 | ret = -EFAULT; | 306 | ret = -EFAULT; |
| 310 | } | 307 | } |
| 311 | return ret; | 308 | return ret; |
| 312 | } | 309 | } |
| 313 | 310 | ||
| 314 | -static int trs_chan_ops_maint_release_mbox_send( | 311 | +static int trs_chan_ops_maint_release_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 315 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 312 | + struct trs_chan_adapt_info *adapt) |
| 316 | { | 313 | { |
| 317 | struct trs_maint_sqcq_mbox mbox_data; | 314 | struct trs_maint_sqcq_mbox mbox_data; |
| 318 | int ret; | 315 | int ret; |
| @@ -330,16 +327,15 @@ static int trs_chan_ops_maint_release_mbox_send( | |||
| 330 | 327 | ||
| 331 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_maint_sqcq_mbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 328 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_maint_sqcq_mbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 332 | if ((ret != 0) || (mbox_data.header.result != 0)) { | 329 | if ((ret != 0) || (mbox_data.header.result != 0)) { |
| 333 | - trs_err( | 330 | + trs_err("Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 334 | - "Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 331 | + mbox_data.header.result, ret); |
| 335 | - mbox_data.header.result, ret); | ||
| 336 | ret = -EFAULT; | 332 | ret = -EFAULT; |
| 337 | } | 333 | } |
| 338 | return ret; | 334 | return ret; |
| 339 | } | 335 | } |
| 340 | 336 | ||
| 341 | -static int trs_chan_ops_hw_ts_mbox_send( | 337 | +static int trs_chan_ops_hw_ts_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 342 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 338 | + struct trs_chan_adapt_info *adapt) |
| 343 | { | 339 | { |
| 344 | u32 chip_type = uda_get_chip_type(inst->devid); | 340 | u32 chip_type = uda_get_chip_type(inst->devid); |
| 345 | struct trs_ts_sqcq_mbox mbox_data; | 341 | struct trs_ts_sqcq_mbox mbox_data; |
| @@ -381,16 +377,15 @@ static int trs_chan_ops_hw_ts_mbox_send( | |||
| 381 | } | 377 | } |
| 382 | 378 | ||
| 383 | if (ret != 0 || mbox_data.header.result != 0) { | 379 | if (ret != 0 || mbox_data.header.result != 0) { |
| 384 | - trs_err( | 380 | + trs_err("Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 385 | - "Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 381 | + mbox_data.header.result, ret); |
| 386 | - mbox_data.header.result, ret); | ||
| 387 | ret = -EFAULT; | 382 | ret = -EFAULT; |
| 388 | } | 383 | } |
| 389 | return ret; | 384 | return ret; |
| 390 | } | 385 | } |
| 391 | 386 | ||
| 392 | -static int trs_chan_ops_task_sched_create_mbox_send( | 387 | +static int trs_chan_ops_task_sched_create_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 393 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 388 | + struct trs_chan_adapt_info *adapt) |
| 394 | { | 389 | { |
| 395 | struct trs_task_sched_sqcq_alloc_mbox mbox_data; | 390 | struct trs_task_sched_sqcq_alloc_mbox mbox_data; |
| 396 | u16 cmd; | 391 | u16 cmd; |
| @@ -419,17 +414,16 @@ static int trs_chan_ops_task_sched_create_mbox_send( | |||
| 419 | 414 | ||
| 420 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(mbox_data), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 415 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(mbox_data), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 421 | if (ret != 0 || mbox_data.header.result != 0) { | 416 | if (ret != 0 || mbox_data.header.result != 0) { |
| 422 | - trs_err( | 417 | + trs_err("Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 423 | - "Mbox send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 418 | + mbox_data.header.result, ret); |
| 424 | - mbox_data.header.result, ret); | ||
| 425 | ret = -EFAULT; | 419 | ret = -EFAULT; |
| 426 | } | 420 | } |
| 427 | 421 | ||
| 428 | return ret; | 422 | return ret; |
| 429 | } | 423 | } |
| 430 | 424 | ||
| 431 | -static int trs_chan_ops_task_sched_release_mbox_send( | 425 | +static int trs_chan_ops_task_sched_release_mbox_send(struct trs_id_inst *inst, struct trs_chan_info *chan_info, |
| 432 | - struct trs_id_inst *inst, struct trs_chan_info *chan_info, struct trs_chan_adapt_info *adapt) | 426 | + struct trs_chan_adapt_info *adapt) |
| 433 | { | 427 | { |
| 434 | struct trs_task_sched_sqcq_free_mbox mbox_data; | 428 | struct trs_task_sched_sqcq_free_mbox mbox_data; |
| 435 | u16 cmd; | 429 | u16 cmd; |
| @@ -444,9 +438,8 @@ static int trs_chan_ops_task_sched_release_mbox_send( | |||
| 444 | 438 | ||
| 445 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(mbox_data), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 439 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(mbox_data), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 446 | if (ret != 0 || mbox_data.header.result != 0) { | 440 | if (ret != 0 || mbox_data.header.result != 0) { |
| 447 | - trs_err( | 441 | + trs_err("Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, |
| 448 | - "Mbos send fail. (devid=%u; tsid=%u; cmd=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, cmd, | 442 | + mbox_data.header.result, ret); |
| 449 | - mbox_data.header.result, ret); | ||
| 450 | ret = -EFAULT; | 443 | ret = -EFAULT; |
| 451 | } | 444 | } |
| 452 | 445 | ||
| @@ -84,9 +84,8 @@ void *trs_chan_mem_alloc_rsv(struct trs_id_inst *inst, int type, size_t size, ph | |||
| 84 | if (ret != 0) { | 84 | if (ret != 0) { |
| 85 | trs_rsv_mem_free(inst, type, vaddr, size); | 85 | trs_rsv_mem_free(inst, type, vaddr, size); |
| 86 | 86 | ||
| 87 | - trs_err( | 87 | + trs_err("Rcv mem v2p fail. (devid=%u; tsid=%u; type=%d; size=%lu; ret=%d)\n", inst->devid, inst->tsid, type, |
| 88 | - "Rcv mem v2p fail. (devid=%u; tsid=%u; type=%d; size=%lu; ret=%d)\n", inst->devid, inst->tsid, type, size, | 88 | + size, ret); |
| 89 | - ret); | ||
| 90 | 89 | ||
| 91 | return NULL; | 90 | return NULL; |
| 92 | } | 91 | } |
| @@ -265,4 +265,7 @@ void trs_chan_mem_node_proc_fs_init(void) | |||
| 265 | (void)ka_fs_proc_create_data("magic_check_enable", PROC_FS_MODE, top_entry, &mem_node_ops, NULL); | 265 | (void)ka_fs_proc_create_data("magic_check_enable", PROC_FS_MODE, top_entry, &mem_node_ops, NULL); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | -void trs_chan_mem_node_proc_fs_uninit(void) { (void)ka_fs_remove_proc_subtree("trs_chan_mem_node", NULL); } | 268 | +void trs_chan_mem_node_proc_fs_uninit(void) |
| 269 | +{ | ||
| 270 | + (void)ka_fs_remove_proc_subtree("trs_chan_mem_node", NULL); | ||
| 271 | +} | ||
| @@ -169,8 +169,8 @@ bool trs_is_proc_has_res(u32 devid, u32 tsid, int pid, int res_type, int res_id) | |||
| 169 | struct trs_id_inst inst = {.devid = devid, .tsid = tsid}; | 169 | struct trs_id_inst inst = {.devid = devid, .tsid = tsid}; |
| 170 | 170 | ||
| 171 | if ((res_type < (int)TRS_STREAM) || (res_type >= (int)TRS_MAX_ID_TYPE) || (devid >= TRS_DEV_MAX_NUM)) { | 171 | if ((res_type < (int)TRS_STREAM) || (res_type >= (int)TRS_MAX_ID_TYPE) || (devid >= TRS_DEV_MAX_NUM)) { |
| 172 | - trs_err( | 172 | + trs_err("Invalid para. (devid=%u; tsid=%u; pid=%u; res_type=%d; res_id=%d)\n", devid, tsid, pid, res_type, |
| 173 | - "Invalid para. (devid=%u; tsid=%u; pid=%u; res_type=%d; res_id=%d)\n", devid, tsid, pid, res_type, res_id); | 173 | + res_id); |
| 174 | return false; | 174 | return false; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| @@ -162,7 +162,10 @@ static struct trs_mbox_chan *trs_mbox_chan_get(struct trs_id_inst *inst) | |||
| 162 | return chan; | 162 | return chan; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | -static void trs_mbox_chan_put(struct trs_mbox_chan *chan) { kref_safe_put(&chan->ref, trs_mbox_chan_release); } | 165 | +static void trs_mbox_chan_put(struct trs_mbox_chan *chan) |
| 166 | +{ | ||
| 167 | + kref_safe_put(&chan->ref, trs_mbox_chan_release); | ||
| 168 | +} | ||
| 166 | 169 | ||
| 167 | void *trs_mbox_chan_init(struct trs_id_inst *inst, struct trs_mbox_chan_attr *attr) | 170 | void *trs_mbox_chan_init(struct trs_id_inst *inst, struct trs_mbox_chan_attr *attr) |
| 168 | { | 171 | { |
| @@ -183,7 +186,10 @@ void *trs_mbox_chan_init(struct trs_id_inst *inst, struct trs_mbox_chan_attr *at | |||
| 183 | return chan; | 186 | return chan; |
| 184 | } | 187 | } |
| 185 | 188 | ||
| 186 | -void trs_mbox_chan_uninit(struct trs_id_inst *inst) { trs_mbox_chan_del(inst); } | 189 | +void trs_mbox_chan_uninit(struct trs_id_inst *inst) |
| 190 | +{ | ||
| 191 | + trs_mbox_chan_del(inst); | ||
| 192 | +} | ||
| 187 | 193 | ||
| 188 | static void trs_mbox_chan_write(struct trs_mbox_chan *chan, void *data, size_t size) | 194 | static void trs_mbox_chan_write(struct trs_mbox_chan *chan, void *data, size_t size) |
| 189 | { | 195 | { |
| @@ -211,9 +217,8 @@ static void trs_mbox_chan_get_result(struct trs_mbox_chan *chan, void *data) | |||
| 211 | 217 | ||
| 212 | ka_rmb(); | 218 | ka_rmb(); |
| 213 | if ((header->result != 0) && (header->cmd_type != TRS_MBOX_RECYCLE_CHECK)) { | 219 | if ((header->result != 0) && (header->cmd_type != TRS_MBOX_RECYCLE_CHECK)) { |
| 214 | - trs_warn( | 220 | + trs_warn("Pay attention to result. (result=%u; tx_time_us=%llu; txdone_time_us=%llu; wakeup_time_us=%llu)\n", |
| 215 | - "Pay attention to result. (result=%u; tx_time_us=%llu; txdone_time_us=%llu; wakeup_time_us=%llu)\n", | 221 | + header->result, chan->tx_time_us, chan->txdone_time_us, chan->wakeup_time_us); |
| 216 | - header->result, chan->tx_time_us, chan->txdone_time_us, chan->wakeup_time_us); | ||
| 217 | } | 222 | } |
| 218 | } | 223 | } |
| 219 | 224 | ||
| @@ -272,10 +277,9 @@ static bool trs_mbox_chan_is_available(struct trs_mbox_chan *chan) | |||
| 272 | } | 277 | } |
| 273 | 278 | ||
| 274 | if (ka_system_jiffies_to_msecs(ka_jiffies - chan->fault.broken_timestamp) < chan->fault.retry_duration) { | 279 | if (ka_system_jiffies_to_msecs(ka_jiffies - chan->fault.broken_timestamp) < chan->fault.retry_duration) { |
| 275 | - trs_err( | 280 | + trs_err("Mbox chan not available. (devid=%u; tsid=%u; cur_jiffies=%lu; broken_timestamp=%lu; interval=%u(ms)\n", |
| 276 | - "Mbox chan not available. (devid=%u; tsid=%u; cur_jiffies=%lu; broken_timestamp=%lu; interval=%u(ms)\n", | 281 | + chan->inst.devid, chan->inst.tsid, ka_jiffies, chan->fault.broken_timestamp, |
| 277 | - chan->inst.devid, chan->inst.tsid, ka_jiffies, chan->fault.broken_timestamp, | 282 | + ka_system_jiffies_to_msecs(ka_jiffies - chan->fault.broken_timestamp)); |
| 278 | - ka_system_jiffies_to_msecs(ka_jiffies - chan->fault.broken_timestamp)); | ||
| 279 | return false; | 283 | return false; |
| 280 | } | 284 | } |
| 281 | 285 | ||
| @@ -293,7 +297,10 @@ static void trs_mbox_chan_fault_record(struct trs_mbox_chan_fault *fault, int ti | |||
| 293 | } | 297 | } |
| 294 | } | 298 | } |
| 295 | 299 | ||
| 296 | -static void trs_mbox_chan_fault_clear(struct trs_mbox_chan_fault *fault) { fault->cont_tx_timeout = 0; } | 300 | +static void trs_mbox_chan_fault_clear(struct trs_mbox_chan_fault *fault) |
| 301 | +{ | ||
| 302 | + fault->cont_tx_timeout = 0; | ||
| 303 | +} | ||
| 297 | 304 | ||
| 298 | static int trs_mbox_chan_send(struct trs_mbox_chan *chan, void *data, size_t size, int timeout) | 305 | static int trs_mbox_chan_send(struct trs_mbox_chan *chan, void *data, size_t size, int timeout) |
| 299 | { | 306 | { |
| @@ -327,9 +334,8 @@ static int trs_mbox_chan_send(struct trs_mbox_chan *chan, void *data, size_t siz | |||
| 327 | (void)trs_set_ts_status(&chan->inst, TRS_INST_STATUS_ABNORMAL); | 334 | (void)trs_set_ts_status(&chan->inst, TRS_INST_STATUS_ABNORMAL); |
| 328 | } | 335 | } |
| 329 | trs_mbox_chan_fault_record(&chan->fault, timeout); | 336 | trs_mbox_chan_fault_record(&chan->fault, timeout); |
| 330 | - trs_err( | 337 | + trs_err("Mbox wait fail. (ret=%d; valid=0x%x; tx_time_us=%llu; txdone_time_us=%llu; wakeup_time_us=%llu)\n", |
| 331 | - "Mbox wait fail. (ret=%d; valid=0x%x; tx_time_us=%llu; txdone_time_us=%llu; wakeup_time_us=%llu)\n", ret, | 338 | + ret, trs_mbox_chan_get_valid(chan), chan->tx_time_us, chan->txdone_time_us, chan->wakeup_time_us); |
| 332 | - trs_mbox_chan_get_valid(chan), chan->tx_time_us, chan->txdone_time_us, chan->wakeup_time_us); | ||
| 333 | return ret; | 339 | return ret; |
| 334 | } | 340 | } |
| 335 | } | 341 | } |
| @@ -23,7 +23,10 @@ struct trs_mbox_ops { | |||
| 23 | void (*free_irq)(void *priv); | 23 | void (*free_irq)(void *priv); |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | -enum trs_mbox_mem_type { TRS_MBOX_MEM_TYPE_DEVICE, TRS_MBOX_MEM_TYPE_NORMAL }; | 26 | +enum trs_mbox_mem_type { |
| 27 | + TRS_MBOX_MEM_TYPE_DEVICE, | ||
| 28 | + TRS_MBOX_MEM_TYPE_NORMAL | ||
| 29 | +}; | ||
| 27 | 30 | ||
| 28 | struct trs_mbox_chan_attr { | 31 | struct trs_mbox_chan_attr { |
| 29 | phys_addr_t base; | 32 | phys_addr_t base; |
| @@ -68,9 +68,8 @@ static int trs_id_get_res_bitmap(struct trs_id_inst *inst, int type, u32 vfid, u | |||
| 68 | } | 68 | } |
| 69 | if ((grp_info.valid == 1) && (vfid == grp_info.vfid)) { | 69 | if ((grp_info.valid == 1) && (vfid == grp_info.vfid)) { |
| 70 | *bitmap = trs_get_id_bitmap_in_grp_with_type(&grp_info, type); | 70 | *bitmap = trs_get_id_bitmap_in_grp_with_type(&grp_info, type); |
| 71 | - trs_debug( | 71 | + trs_debug("Get bitmap in group. (udevid=%u; vfid=%u; grp_id=%u; type=%u; bitmap=%u)\n", inst->devid, vfid, |
| 72 | - "Get bitmap in group. (udevid=%u; vfid=%u; grp_id=%u; type=%u; bitmap=%u)\n", inst->devid, vfid, grp_id, | 72 | + grp_id, type, *bitmap); |
| 73 | - type, *bitmap); | ||
| 74 | return 0; | 73 | return 0; |
| 75 | } | 74 | } |
| 76 | } | 75 | } |
| @@ -86,16 +85,15 @@ int trs_id_alloc_in_range(struct trs_id_inst *inst, int type, u32 *id, u32 vfid) | |||
| 86 | 85 | ||
| 87 | ret = trs_id_get_res_bitmap(inst, type, vfid, &bitmap); | 86 | ret = trs_id_get_res_bitmap(inst, type, vfid, &bitmap); |
| 88 | if (ret != 0) { | 87 | if (ret != 0) { |
| 89 | - trs_err( | 88 | + trs_err("Failed to get res range. (devid=%u; vfid=%u; type=%s; ret=%d)\n", inst->devid, vfid, |
| 90 | - "Failed to get res range. (devid=%u; vfid=%u; type=%s; ret=%d)\n", inst->devid, vfid, | 89 | + trs_id_type_to_name(type), ret); |
| 91 | - trs_id_type_to_name(type), ret); | ||
| 92 | return ret; | 90 | return ret; |
| 93 | } | 91 | } |
| 94 | 92 | ||
| 95 | ret = trs_id_get_num_per_bit(inst, type, &num_per_bit); | 93 | ret = trs_id_get_num_per_bit(inst, type, &num_per_bit); |
| 96 | if (ret != 0) { | 94 | if (ret != 0) { |
| 97 | - trs_err( | 95 | + trs_err("Failed to get num_per_bit. (devid=%u; type=%s; ret=%d)\n", inst->devid, trs_id_type_to_name(type), |
| 98 | - "Failed to get num_per_bit. (devid=%u; type=%s; ret=%d)\n", inst->devid, trs_id_type_to_name(type), ret); | 96 | + ret); |
| 99 | return ret; | 97 | return ret; |
| 100 | } | 98 | } |
| 101 | 99 | ||
| @@ -105,15 +103,13 @@ int trs_id_alloc_in_range(struct trs_id_inst *inst, int type, u32 *id, u32 vfid) | |||
| 105 | *id = ((u32)bit) * num_per_bit; | 103 | *id = ((u32)bit) * num_per_bit; |
| 106 | ret = trs_id_alloc_ex(inst, type, flag, id, num_per_bit); | 104 | ret = trs_id_alloc_ex(inst, type, flag, id, num_per_bit); |
| 107 | if (ret == 0) { | 105 | if (ret == 0) { |
| 108 | - trs_debug( | 106 | + trs_debug("Alloc id in range success. (devid=%u; vfid=%u; type=%s; bitmap=0x%x; bit=%d; id=%u)\n", |
| 109 | - "Alloc id in range success. (devid=%u; vfid=%u; type=%s; bitmap=0x%x; bit=%d; id=%u)\n", | 107 | + inst->devid, vfid, trs_id_type_to_name(type), bitmap, bit, *id); |
| 110 | - inst->devid, vfid, trs_id_type_to_name(type), bitmap, bit, *id); | ||
| 111 | return 0; | 108 | return 0; |
| 112 | } | 109 | } |
| 113 | } | 110 | } |
| 114 | } | 111 | } |
| 115 | - trs_err( | 112 | + trs_err("Failed to allloc id in range. (devid=%u; vfid=%u; type=%s; bitmap=0x%x; bit=%d; ret=%d)\n", inst->devid, |
| 116 | - "Failed to allloc id in range. (devid=%u; vfid=%u; type=%s; bitmap=0x%x; bit=%d; ret=%d)\n", inst->devid, vfid, | 113 | + vfid, trs_id_type_to_name(type), bitmap, bit, ret); |
| 117 | - trs_id_type_to_name(type), bitmap, bit, ret); | ||
| 118 | return ret; | 114 | return ret; |
| 119 | } | 115 | } |
| @@ -23,14 +23,20 @@ void trs_register_soft_mbox_send_ops(u32 devid, struct trs_mbox_send_ops *ops) | |||
| 23 | g_trs_soft_mbox_send_ops[devid] = ops; | 23 | g_trs_soft_mbox_send_ops[devid] = ops; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | -void trs_unregister_soft_mbox_send_ops(u32 devid) { g_trs_soft_mbox_send_ops[devid] = NULL; } | 26 | +void trs_unregister_soft_mbox_send_ops(u32 devid) |
| 27 | +{ | ||
| 28 | + g_trs_soft_mbox_send_ops[devid] = NULL; | ||
| 29 | +} | ||
| 27 | 30 | ||
| 28 | void trs_register_hard_mbox_send_ops(u32 devid, struct trs_mbox_send_ops *ops) | 31 | void trs_register_hard_mbox_send_ops(u32 devid, struct trs_mbox_send_ops *ops) |
| 29 | { | 32 | { |
| 30 | g_trs_hard_mbox_send_ops[devid] = ops; | 33 | g_trs_hard_mbox_send_ops[devid] = ops; |
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | -void trs_unregister_hard_mbox_send_ops(u32 devid) { g_trs_hard_mbox_send_ops[devid] = NULL; } | 36 | +void trs_unregister_hard_mbox_send_ops(u32 devid) |
| 37 | +{ | ||
| 38 | + g_trs_hard_mbox_send_ops[devid] = NULL; | ||
| 39 | +} | ||
| 34 | 40 | ||
| 35 | int trs_mbox_send(struct trs_id_inst *inst, u32 chan_id, void *data, size_t size, int timeout) | 41 | int trs_mbox_send(struct trs_id_inst *inst, u32 chan_id, void *data, size_t size, int timeout) |
| 36 | { | 42 | { |
| @@ -57,9 +57,8 @@ static struct trs_rsv_mem *trs_rsv_mem_create(struct trs_id_inst *inst, int type | |||
| 57 | if (ret != 0) { | 57 | if (ret != 0) { |
| 58 | ka_base_gen_pool_destroy(pool); | 58 | ka_base_gen_pool_destroy(pool); |
| 59 | trs_kfree(rsv_mem); | 59 | trs_kfree(rsv_mem); |
| 60 | - trs_err( | 60 | + trs_err("Get pool add virt fail. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", inst->devid, inst->tsid, |
| 61 | - "Get pool add virt fail. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", inst->devid, inst->tsid, type, | 61 | + type, attr->total_size); |
| 62 | - attr->total_size); | ||
| 63 | return NULL; | 62 | return NULL; |
| 64 | } | 63 | } |
| 65 | 64 | ||
| @@ -109,9 +108,8 @@ static void trs_rsv_mem_release(struct kref_safe *kref) | |||
| 109 | g_rsv_mem[ts_inst][rsv_mem->type] = NULL; | 108 | g_rsv_mem[ts_inst][rsv_mem->type] = NULL; |
| 110 | ka_task_write_unlock_bh(&rsv_mem_lock); | 109 | ka_task_write_unlock_bh(&rsv_mem_lock); |
| 111 | 110 | ||
| 112 | - trs_info( | 111 | + trs_info("Trs rsv mem uninit. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", rsv_mem->inst.devid, |
| 113 | - "Trs rsv mem uninit. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", rsv_mem->inst.devid, rsv_mem->inst.tsid, | 112 | + rsv_mem->inst.tsid, rsv_mem->type, rsv_mem->attr.total_size); |
| 114 | - rsv_mem->type, rsv_mem->attr.total_size); | ||
| 115 | ka_mm_iounmap(rsv_mem->attr.vaddr); | 113 | ka_mm_iounmap(rsv_mem->attr.vaddr); |
| 116 | trs_rsv_mem_destroy(rsv_mem); | 114 | trs_rsv_mem_destroy(rsv_mem); |
| 117 | } | 115 | } |
| @@ -138,7 +136,10 @@ static struct trs_rsv_mem *trs_rsv_mem_get(struct trs_id_inst *inst, int type) | |||
| 138 | return rsv_mem; | 136 | return rsv_mem; |
| 139 | } | 137 | } |
| 140 | 138 | ||
| 141 | -static void trs_rsv_mem_put(struct trs_rsv_mem *rsv_mem) { kref_safe_put(&rsv_mem->ref, trs_rsv_mem_release); } | 139 | +static void trs_rsv_mem_put(struct trs_rsv_mem *rsv_mem) |
| 140 | +{ | ||
| 141 | + kref_safe_put(&rsv_mem->ref, trs_rsv_mem_release); | ||
| 142 | +} | ||
| 142 | 143 | ||
| 143 | static void trs_rsv_mem_clear(struct trs_rsv_mem *rsv_mem, void *vaddr, size_t size) | 144 | static void trs_rsv_mem_clear(struct trs_rsv_mem *rsv_mem, void *vaddr, size_t size) |
| 144 | { | 145 | { |
| @@ -195,9 +196,8 @@ void *trs_rsv_mem_alloc(struct trs_id_inst *inst, int type, size_t size, u32 fla | |||
| 195 | vaddr = (void *)ka_base_gen_pool_alloc(rsv_mem->pool, size); | 196 | vaddr = (void *)ka_base_gen_pool_alloc(rsv_mem->pool, size); |
| 196 | if (vaddr == NULL) { | 197 | if (vaddr == NULL) { |
| 197 | 198 | ||
| 198 | - trs_debug( | 199 | + trs_debug("No rsv mem resource. (devid=%u; tsid=%u; type=%d; total=0x%lx; avail=0x%lx)\n", inst->devid, |
| 199 | - "No rsv mem resource. (devid=%u; tsid=%u; type=%d; total=0x%lx; avail=0x%lx)\n", inst->devid, | 200 | + inst->tsid, type, rsv_mem->attr.total_size, ka_base_gen_pool_avail(rsv_mem->pool)); |
| 200 | - inst->tsid, type, rsv_mem->attr.total_size, ka_base_gen_pool_avail(rsv_mem->pool)); | ||
| 201 | 201 | ||
| 202 | trs_rsv_mem_put(rsv_mem); | 202 | trs_rsv_mem_put(rsv_mem); |
| 203 | return NULL; | 203 | return NULL; |
| @@ -265,10 +265,12 @@ int trs_rsv_mem_init(struct trs_id_inst *inst, int type, struct trs_rsv_mem_attr | |||
| 265 | return -ENODEV; | 265 | return -ENODEV; |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | - trs_debug( | 268 | + trs_debug("Trs rsv mem init. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", inst->devid, inst->tsid, type, |
| 269 | - "Trs rsv mem init. (devid=%u; tsid=%u; type=%d; total_size=0x%lx)\n", inst->devid, inst->tsid, type, | 269 | + attr->total_size); |
| 270 | - attr->total_size); | ||
| 271 | return 0; | 270 | return 0; |
| 272 | } | 271 | } |
| 273 | 272 | ||
| 274 | -void trs_rsv_mem_uninit(struct trs_id_inst *inst, int type) { trs_rsv_mem_del(inst, type); } | 273 | +void trs_rsv_mem_uninit(struct trs_id_inst *inst, int type) |
| 274 | +{ | ||
| 275 | + trs_rsv_mem_del(inst, type); | ||
| 276 | +} | ||
| @@ -28,7 +28,11 @@ struct trs_rsv_mem_attr { | |||
| 28 | u32 flag; | 28 | u32 flag; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | -enum { RSV_MEM_HW_SQCQ = 0, RSV_MEM_MAINT_SQCQ, RSV_MEM_MAX }; | 31 | +enum { |
| 32 | + RSV_MEM_HW_SQCQ = 0, | ||
| 33 | + RSV_MEM_MAINT_SQCQ, | ||
| 34 | + RSV_MEM_MAX | ||
| 35 | +}; | ||
| 32 | 36 | ||
| 33 | void *trs_rsv_mem_alloc(struct trs_id_inst *inst, int type, size_t size, u32 flag); | 37 | void *trs_rsv_mem_alloc(struct trs_id_inst *inst, int type, size_t size, u32 flag); |
| 34 | void trs_rsv_mem_free(struct trs_id_inst *inst, int type, void *vaddr, size_t size); | 38 | void trs_rsv_mem_free(struct trs_id_inst *inst, int type, void *vaddr, size_t size); |
| @@ -74,7 +74,10 @@ static void trs_stars_destroy(struct trs_stars *stars) | |||
| 74 | trs_kfree(stars); | 74 | trs_kfree(stars); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | -int trs_stars_test_bit(u32 nr, u32 val) { return val & (1U << nr); } | 77 | +int trs_stars_test_bit(u32 nr, u32 val) |
| 78 | +{ | ||
| 79 | + return val & (1U << nr); | ||
| 80 | +} | ||
| 78 | 81 | ||
| 79 | static int trs_stars_add(struct trs_stars *stars) | 82 | static int trs_stars_add(struct trs_stars *stars) |
| 80 | { | 83 | { |
| @@ -690,4 +693,7 @@ int trs_stars_init(struct trs_id_inst *inst, int type, struct trs_stars_attr *at | |||
| 690 | return ret; | 693 | return ret; |
| 691 | } | 694 | } |
| 692 | 695 | ||
| 693 | -void trs_stars_uninit(struct trs_id_inst *inst, int type) { trs_stars_del(inst, type); } | 696 | +void trs_stars_uninit(struct trs_id_inst *inst, int type) |
| 697 | +{ | ||
| 698 | + trs_stars_del(inst, type); | ||
| 699 | +} | ||
| @@ -239,14 +239,16 @@ int trs_ts_db_cfg(struct trs_id_inst *inst, phys_addr_t paddr, size_t size, u32 | |||
| 239 | trs_db_cfg_destroy(db_cfg); | 239 | trs_db_cfg_destroy(db_cfg); |
| 240 | return ret; | 240 | return ret; |
| 241 | } | 241 | } |
| 242 | - trs_debug( | 242 | + trs_debug("Ts doorbell config. (devid=%u; tsid=%u; db_size=0x%lx(B); db_stride=0x%x(B); db_num=%u)\n", inst->devid, |
| 243 | - "Ts doorbell config. (devid=%u; tsid=%u; db_size=0x%lx(B); db_stride=0x%x(B); db_num=%u)\n", inst->devid, | 243 | + inst->tsid, size, stride, (u32)(size / stride)); |
| 244 | - inst->tsid, size, stride, (u32)(size / stride)); | ||
| 245 | return 0; | 244 | return 0; |
| 246 | } | 245 | } |
| 247 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_cfg); | 246 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_cfg); |
| 248 | 247 | ||
| 249 | -void trs_ts_db_decfg(struct trs_id_inst *inst) { trs_ts_db_del(inst); } | 248 | +void trs_ts_db_decfg(struct trs_id_inst *inst) |
| 249 | +{ | ||
| 250 | + trs_ts_db_del(inst); | ||
| 251 | +} | ||
| 250 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_decfg); | 252 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_decfg); |
| 251 | 253 | ||
| 252 | static struct trs_db_cfg *trs_ts_db_cfg_get(struct trs_id_inst *inst) | 254 | static struct trs_db_cfg *trs_ts_db_cfg_get(struct trs_id_inst *inst) |
| @@ -264,7 +266,10 @@ static struct trs_db_cfg *trs_ts_db_cfg_get(struct trs_id_inst *inst) | |||
| 264 | return db_cfg; | 266 | return db_cfg; |
| 265 | } | 267 | } |
| 266 | 268 | ||
| 267 | -static void trs_ts_db_cfg_put(struct trs_db_cfg *db_cfg) { ka_base_kref_put(&db_cfg->ref, trs_db_cfg_release); } | 269 | +static void trs_ts_db_cfg_put(struct trs_db_cfg *db_cfg) |
| 270 | +{ | ||
| 271 | + ka_base_kref_put(&db_cfg->ref, trs_db_cfg_release); | ||
| 272 | +} | ||
| 268 | 273 | ||
| 269 | int trs_ring_ts_db(struct trs_id_inst *inst, int type, u32 offset, u32 val) | 274 | int trs_ring_ts_db(struct trs_id_inst *inst, int type, u32 offset, u32 val) |
| 270 | { | 275 | { |
| @@ -64,17 +64,16 @@ KA_EXPORT_SYMBOL_GPL(trs_get_ts_status); | |||
| 64 | int trs_get_ts_status_ioctl(void *feature, char *in, u32 in_len, char *out, u32 out_len) | 64 | int trs_get_ts_status_ioctl(void *feature, char *in, u32 in_len, char *out, u32 out_len) |
| 65 | { | 65 | { |
| 66 | enum devdrv_device_status { /* Keep consistent with the ascend_hal.h */ | 66 | enum devdrv_device_status { /* Keep consistent with the ascend_hal.h */ |
| 67 | - DRV_STATUS_INITING = 0x0, | 67 | + DRV_STATUS_INITING = 0x0, |
| 68 | - DRV_STATUS_WORK, | 68 | + DRV_STATUS_WORK, |
| 69 | - DRV_STATUS_EXCEPTION, | 69 | + DRV_STATUS_EXCEPTION, |
| 70 | - DRV_STATUS_SLEEP, | 70 | + DRV_STATUS_SLEEP, |
| 71 | - DRV_STATUS_COMMUNICATION_LOST, | 71 | + DRV_STATUS_COMMUNICATION_LOST, |
| 72 | - DRV_STATUS_RESERVED | 72 | + DRV_STATUS_RESERVED |
| 73 | }; | 73 | }; |
| 74 | - u32 trs_ts_status_tansfrom[TRS_INST_STATUS_MAX] = { | 74 | + u32 trs_ts_status_tansfrom[TRS_INST_STATUS_MAX] = {[TRS_INST_STATUS_UNINIT] = DRV_STATUS_INITING, |
| 75 | - [TRS_INST_STATUS_UNINIT] = DRV_STATUS_INITING, | 75 | + [TRS_INST_STATUS_NORMAL] = DRV_STATUS_WORK, |
| 76 | - [TRS_INST_STATUS_NORMAL] = DRV_STATUS_WORK, | 76 | + [TRS_INST_STATUS_ABNORMAL] = DRV_STATUS_EXCEPTION}; |
| 77 | - [TRS_INST_STATUS_ABNORMAL] = DRV_STATUS_EXCEPTION}; | ||
| 78 | struct tsdrv_id_inst tsdrv_inst; | 77 | struct tsdrv_id_inst tsdrv_inst; |
| 79 | struct trs_id_inst inst; | 78 | struct trs_id_inst inst; |
| 80 | u32 phys_id = DEVDRV_MAX_DAVINCI_NUM; | 79 | u32 phys_id = DEVDRV_MAX_DAVINCI_NUM; |
| @@ -117,9 +116,8 @@ int trs_get_ts_status_ioctl(void *feature, char *in, u32 in_len, char *out, u32 | |||
| 117 | 116 | ||
| 118 | BEGIN_DMS_MODULE_DECLARATION(DMS_MODULE_TRS_ADAPT) | 117 | BEGIN_DMS_MODULE_DECLARATION(DMS_MODULE_TRS_ADAPT) |
| 119 | BEGIN_FEATURE_COMMAND() | 118 | BEGIN_FEATURE_COMMAND() |
| 120 | -ADD_FEATURE_COMMAND( | 119 | +ADD_FEATURE_COMMAND(DMS_MODULE_TRS_ADAPT, DMS_MAIN_CMD_TRS, DMS_SUBCMD_GET_TS_HB_STATUS, NULL, NULL, |
| 121 | - DMS_MODULE_TRS_ADAPT, DMS_MAIN_CMD_TRS, DMS_SUBCMD_GET_TS_HB_STATUS, NULL, NULL, DMS_SUPPORT_ALL_USER, | 120 | + DMS_SUPPORT_ALL_USER, trs_get_ts_status_ioctl) |
| 122 | - trs_get_ts_status_ioctl) | ||
| 123 | END_FEATURE_COMMAND() | 121 | END_FEATURE_COMMAND() |
| 124 | END_MODULE_DECLARATION() | 122 | END_MODULE_DECLARATION() |
| 125 | 123 | ||
| @@ -79,25 +79,22 @@ static int trs_ts_mbox_irq_setup(struct trs_ts_mbox *ts_mbox) | |||
| 79 | ret = trs_host_request_irq(&ts_mbox->inst, &attr, (void *)ts_mbox, name, trs_ts_mbox_ack_handler); | 79 | ret = trs_host_request_irq(&ts_mbox->inst, &attr, (void *)ts_mbox, name, trs_ts_mbox_ack_handler); |
| 80 | if (ret != 0) { | 80 | if (ret != 0) { |
| 81 | trs_kfree(name); | 81 | trs_kfree(name); |
| 82 | - trs_err( | 82 | + trs_err("Request irq fail. (devid=%u; tsid=%u; irq=%u; ret=%d)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, |
| 83 | - "Request irq fail. (devid=%u; tsid=%u; irq=%u; ret=%d)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, | 83 | + ts_mbox->irq, ret); |
| 84 | - ts_mbox->irq, ret); | ||
| 85 | return ret; | 84 | return ret; |
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | ts_mbox->name = name; | 87 | ts_mbox->name = name; |
| 89 | - trs_debug( | 88 | + trs_debug("Mbox irq register. (devid=%u; tsid=%u; irq=%u; name=%s)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, |
| 90 | - "Mbox irq register. (devid=%u; tsid=%u; irq=%u; name=%s)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, | 89 | + ts_mbox->irq, name); |
| 91 | - ts_mbox->irq, name); | ||
| 92 | return 0; | 90 | return 0; |
| 93 | } | 91 | } |
| 94 | 92 | ||
| 95 | static void trs_ts_mbox_irq_cleanup(struct trs_ts_mbox *ts_mbox) | 93 | static void trs_ts_mbox_irq_cleanup(struct trs_ts_mbox *ts_mbox) |
| 96 | { | 94 | { |
| 97 | struct trs_adapt_irq_attr attr; | 95 | struct trs_adapt_irq_attr attr; |
| 98 | - trs_info( | 96 | + trs_info("Mbox irq unregister. (devid=%u, tsid=%u; irq=%u; name=%s)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, |
| 99 | - "Mbox irq unregister. (devid=%u, tsid=%u; irq=%u; name=%s)\n", ts_mbox->inst.devid, ts_mbox->inst.tsid, | 97 | + ts_mbox->irq, ts_mbox->name); |
| 100 | - ts_mbox->irq, ts_mbox->name); | ||
| 101 | 98 | ||
| 102 | attr.irq_type = ts_mbox->irq_type; | 99 | attr.irq_type = ts_mbox->irq_type; |
| 103 | attr.irq = ts_mbox->irq; | 100 | attr.irq = ts_mbox->irq; |
| @@ -144,9 +141,8 @@ static int trs_ts_mbox_db_init(struct trs_id_inst *inst) | |||
| 144 | 141 | ||
| 145 | ret = trs_soc_get_db_cfg(inst, TRS_DB_ONLINE_MBOX, &start, &end); | 142 | ret = trs_soc_get_db_cfg(inst, TRS_DB_ONLINE_MBOX, &start, &end); |
| 146 | if ((ret != 0) || (start >= end)) { | 143 | if ((ret != 0) || (start >= end)) { |
| 147 | - trs_err( | 144 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 148 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 145 | + start, end); |
| 149 | - end); | ||
| 150 | return -ENODEV; | 146 | return -ENODEV; |
| 151 | } | 147 | } |
| 152 | 148 | ||
| @@ -158,7 +154,10 @@ static int trs_ts_mbox_db_init(struct trs_id_inst *inst) | |||
| 158 | return ret; | 154 | return ret; |
| 159 | } | 155 | } |
| 160 | 156 | ||
| 161 | -static void trs_ts_mbox_db_uninit(struct trs_id_inst *inst) { trs_ts_db_uninit(inst, TRS_DB_ONLINE_MBOX); } | 157 | +static void trs_ts_mbox_db_uninit(struct trs_id_inst *inst) |
| 158 | +{ | ||
| 159 | + trs_ts_db_uninit(inst, TRS_DB_ONLINE_MBOX); | ||
| 160 | +} | ||
| 162 | 161 | ||
| 163 | static struct trs_ts_mbox *trs_ts_mbox_create(struct trs_id_inst *inst) | 162 | static struct trs_ts_mbox *trs_ts_mbox_create(struct trs_id_inst *inst) |
| 164 | { | 163 | { |
| @@ -256,9 +255,8 @@ static void trs_mbox_chan_attr_pack(struct trs_ts_mbox *ts_mbox, struct trs_mbox | |||
| 256 | attr->ops.free_irq = trs_ts_mbox_cleanup; | 255 | attr->ops.free_irq = trs_ts_mbox_cleanup; |
| 257 | attr->mem_type = trs_mbox_get_mem_type(&ts_mbox->inst); | 256 | attr->mem_type = trs_mbox_get_mem_type(&ts_mbox->inst); |
| 258 | attr->cont_tx_timeout_max = trs_mbox_get_cont_tx_timeout_max(&ts_mbox->inst); | 257 | attr->cont_tx_timeout_max = trs_mbox_get_cont_tx_timeout_max(&ts_mbox->inst); |
| 259 | - trs_info( | 258 | + trs_info("devid=%u; attr->mem_type=%u; cont_tx_timeout_max=%u(ms)\n", ts_mbox->inst.devid, attr->mem_type, |
| 260 | - "devid=%u; attr->mem_type=%u; cont_tx_timeout_max=%u(ms)\n", ts_mbox->inst.devid, attr->mem_type, | 259 | + attr->cont_tx_timeout_max); |
| 261 | - attr->cont_tx_timeout_max); | ||
| 262 | } | 260 | } |
| 263 | 261 | ||
| 264 | static int trs_ts_mbox_ack_irq_send(struct trs_ts_mbox *ts_mbox) | 262 | static int trs_ts_mbox_ack_irq_send(struct trs_ts_mbox *ts_mbox) |
| @@ -18,8 +18,8 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -static int trs_soft_mbox_sqcq_ext_info_copy( | 21 | +static int trs_soft_mbox_sqcq_ext_info_copy(struct trs_id_inst *inst, void *data, size_t size, |
| 22 | - struct trs_id_inst *inst, void *data, size_t size, struct trs_msg_data *msg_data) | 22 | + struct trs_msg_data *msg_data) |
| 23 | { | 23 | { |
| 24 | struct trs_normal_cqsq_mailbox *mbox_data = (struct trs_normal_cqsq_mailbox *)data; | 24 | struct trs_normal_cqsq_mailbox *mbox_data = (struct trs_normal_cqsq_mailbox *)data; |
| 25 | u32 info_len = sizeof(u32) * SQCQ_INFO_LENGTH; | 25 | u32 info_len = sizeof(u32) * SQCQ_INFO_LENGTH; |
| @@ -31,30 +31,27 @@ static int trs_soft_mbox_sqcq_ext_info_copy( | |||
| 31 | return ret; | 31 | return ret; |
| 32 | } | 32 | } |
| 33 | msg_data->data_len += info_len; | 33 | msg_data->data_len += info_len; |
| 34 | - trs_debug( | 34 | + trs_debug("Copy info success. (devid=%u; info[0]=%u; data_len=%llu)\n", inst->devid, mbox_data->ts_info.info[0], |
| 35 | - "Copy info success. (devid=%u; info[0]=%u; data_len=%llu)\n", inst->devid, mbox_data->ts_info.info[0], | 35 | + msg_data->data_len); |
| 36 | - msg_data->data_len); | ||
| 37 | 36 | ||
| 38 | if ((mbox_data->ts_info.ext_msg != NULL) && (mbox_data->ts_info.ext_msg_len > 0)) { | 37 | if ((mbox_data->ts_info.ext_msg != NULL) && (mbox_data->ts_info.ext_msg_len > 0)) { |
| 39 | - ret = memcpy_s( | 38 | + ret = memcpy_s(msg_data->payload + size + info_len, TRS_MSG_DATA_LEN - size - info_len, |
| 40 | - msg_data->payload + size + info_len, TRS_MSG_DATA_LEN - size - info_len, mbox_data->ts_info.ext_msg, | 39 | + mbox_data->ts_info.ext_msg, mbox_data->ts_info.ext_msg_len); |
| 41 | - mbox_data->ts_info.ext_msg_len); | ||
| 42 | if (ret != 0) { | 40 | if (ret != 0) { |
| 43 | - trs_err( | 41 | + trs_err("Failed to memcpy ext_msg. (devid=%u; ext_msg_len=%u)\n", inst->devid, |
| 44 | - "Failed to memcpy ext_msg. (devid=%u; ext_msg_len=%u)\n", inst->devid, mbox_data->ts_info.ext_msg_len); | 42 | + mbox_data->ts_info.ext_msg_len); |
| 45 | return ret; | 43 | return ret; |
| 46 | } | 44 | } |
| 47 | msg_data->data_len += mbox_data->ts_info.ext_msg_len; | 45 | msg_data->data_len += mbox_data->ts_info.ext_msg_len; |
| 48 | - trs_debug( | 46 | + trs_debug("Copy ext_msg success. (devid=%u; ext_msg_len=%u; data_len=%llu)\n", inst->devid, |
| 49 | - "Copy ext_msg success. (devid=%u; ext_msg_len=%u; data_len=%llu)\n", inst->devid, | 47 | + mbox_data->ts_info.ext_msg_len, msg_data->data_len); |
| 50 | - mbox_data->ts_info.ext_msg_len, msg_data->data_len); | ||
| 51 | } | 48 | } |
| 52 | 49 | ||
| 53 | return 0; | 50 | return 0; |
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | -static int trs_soft_mbox_mem_dispatch_ext_info_copy( | 53 | +static int trs_soft_mbox_mem_dispatch_ext_info_copy(struct trs_id_inst *inst, void *data, size_t size, |
| 57 | - struct trs_id_inst *inst, void *data, size_t size, struct trs_msg_data *msg_data) | 54 | + struct trs_msg_data *msg_data) |
| 58 | { | 55 | { |
| 59 | struct trs_mem_dispatch_msg *mbox_data = (struct trs_mem_dispatch_msg *)data; | 56 | struct trs_mem_dispatch_msg *mbox_data = (struct trs_mem_dispatch_msg *)data; |
| 60 | if (mbox_data->is_addr_ext) { | 57 | if (mbox_data->is_addr_ext) { |
| @@ -119,11 +116,10 @@ int trs_soft_mbox_send(struct trs_id_inst *inst, u32 chan_id, void *data, size_t | |||
| 119 | if (ret == -ENODEV) { | 116 | if (ret == -ENODEV) { |
| 120 | return -ENXIO; | 117 | return -ENXIO; |
| 121 | } | 118 | } |
| 122 | - trs_warn( | 119 | + trs_warn("Mbox send warn. (ret=%d; devid=%u; tsid=%u; msg_result=%d; cmd_type=%d; mbox_result=%d; " |
| 123 | - "Mbox send warn. (ret=%d; devid=%u; tsid=%u; msg_result=%d; cmd_type=%d; mbox_result=%d; " | 120 | + "data_len=%llu; msg_len=%u)\n", |
| 124 | - "data_len=%llu; msg_len=%u)\n", | 121 | + ret, inst->devid, inst->tsid, msg_data.header.result, header->cmd_type, header->result, |
| 125 | - ret, inst->devid, inst->tsid, msg_data.header.result, header->cmd_type, header->result, msg_data.data_len, | 122 | + msg_data.data_len, (u32)msg_len); |
| 126 | - (u32)msg_len); | ||
| 127 | return ((ret != 0) ? ret : msg_data.header.result); | 123 | return ((ret != 0) ? ret : msg_data.header.result); |
| 128 | } | 124 | } |
| 129 | 125 | ||
| @@ -132,9 +128,8 @@ int trs_soft_mbox_send(struct trs_id_inst *inst, u32 chan_id, void *data, size_t | |||
| 132 | rpc_call_msg = (struct trs_rpc_call_msg *)msg_data.payload; | 128 | rpc_call_msg = (struct trs_rpc_call_msg *)msg_data.payload; |
| 133 | ret = memcpy_s(data, size, rpc_call_msg, msg_data.data_len); | 129 | ret = memcpy_s(data, size, rpc_call_msg, msg_data.data_len); |
| 134 | if (ret != 0) { | 130 | if (ret != 0) { |
| 135 | - trs_err( | 131 | + trs_err("Failed to memcpy. (devid=%u; dest_size=0x%x; src_size=0x%x)\n", inst->devid, (u32)size, |
| 136 | - "Failed to memcpy. (devid=%u; dest_size=0x%x; src_size=0x%x)\n", inst->devid, (u32)size, | 132 | + (u32)msg_data.data_len); |
| 137 | - (u32)msg_data.data_len); | ||
| 138 | return ret; | 133 | return ret; |
| 139 | } | 134 | } |
| 140 | ((struct trs_rpc_call_msg *)data)->rpc_call_header.len = TRS_RPC_MAX_DATA_LEN; | 135 | ((struct trs_rpc_call_msg *)data)->rpc_call_header.len = TRS_RPC_MAX_DATA_LEN; |
| @@ -54,7 +54,10 @@ u32 trs_soc_get_cloud_v2_notify_offset(u32 id) | |||
| 54 | (id / TRS_CLOUD_V2_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V2_NOTIFY_SLICE_SIZE; | 54 | (id / TRS_CLOUD_V2_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V2_NOTIFY_SLICE_SIZE; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | -size_t trs_soc_get_cloud_v2_notify_size(void) { return (size_t)TRS_CLOUD_V2_NOTIFY_AVG_SIZE_PER_NOTIFY; } | 57 | +size_t trs_soc_get_cloud_v2_notify_size(void) |
| 58 | +{ | ||
| 59 | + return (size_t)TRS_CLOUD_V2_NOTIFY_AVG_SIZE_PER_NOTIFY; | ||
| 60 | +} | ||
| 58 | 61 | ||
| 59 | u32 trs_soc_get_cloud_v2_event_offset(u32 event_id) | 62 | u32 trs_soc_get_cloud_v2_event_offset(u32 event_id) |
| 60 | { | 63 | { |
| @@ -62,9 +65,15 @@ u32 trs_soc_get_cloud_v2_event_offset(u32 event_id) | |||
| 62 | (event_id / TRS_CLOUD_V2_EVENT_NUM_PER_SLICE) * TRS_CLOUD_V2_EVENT_SLICE_SIZE; | 65 | (event_id / TRS_CLOUD_V2_EVENT_NUM_PER_SLICE) * TRS_CLOUD_V2_EVENT_SLICE_SIZE; |
| 63 | } | 66 | } |
| 64 | 67 | ||
| 65 | -size_t trs_soc_get_cloud_v2_db_stride(void) { return (size_t)TRS_SOC_CLOUD_V2_DB_STRIDE; } | 68 | +size_t trs_soc_get_cloud_v2_db_stride(void) |
| 69 | +{ | ||
| 70 | + return (size_t)TRS_SOC_CLOUD_V2_DB_STRIDE; | ||
| 71 | +} | ||
| 66 | 72 | ||
| 67 | -size_t trs_soc_get_cloud_v2_stars_sched_stride(void) { return (u32)TRS_CLOUD_V2_STARS_SCHED_STRIDE; } | 73 | +size_t trs_soc_get_cloud_v2_stars_sched_stride(void) |
| 74 | +{ | ||
| 75 | + return (u32)TRS_CLOUD_V2_STARS_SCHED_STRIDE; | ||
| 76 | +} | ||
| 68 | 77 | ||
| 69 | int trs_soc_get_cloud_v2_db_cfg(int db_type, u32 *start, u32 *end) | 78 | int trs_soc_get_cloud_v2_db_cfg(int db_type, u32 *start, u32 *end) |
| 70 | { | 79 | { |
| @@ -151,14 +160,32 @@ void trs_soc_cloud_v2_chan_stars_uninit(struct trs_id_inst *inst) | |||
| 151 | trs_chan_stars_v1_ops_uninit(inst); | 160 | trs_chan_stars_v1_ops_uninit(inst); |
| 152 | } | 161 | } |
| 153 | 162 | ||
| 154 | -int trs_soc_cloud_v2_chan_stars_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v1_ops_init(inst); } | 163 | +int trs_soc_cloud_v2_chan_stars_ops_init(struct trs_id_inst *inst) |
| 164 | +{ | ||
| 165 | + return trs_chan_stars_v1_ops_init(inst); | ||
| 166 | +} | ||
| 155 | 167 | ||
| 156 | -void trs_soc_cloud_v2_chan_stars_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v1_ops_uninit(inst); } | 168 | +void trs_soc_cloud_v2_chan_stars_ops_uninit(struct trs_id_inst *inst) |
| 169 | +{ | ||
| 170 | + trs_chan_stars_v1_ops_uninit(inst); | ||
| 171 | +} | ||
| 157 | 172 | ||
| 158 | -struct trs_chan_adapt_ops *trs_chan_cloud_v2_get_stars_adapt_ops(void) { return trs_chan_get_stars_v1_adapt_ops(); } | 173 | +struct trs_chan_adapt_ops *trs_chan_cloud_v2_get_stars_adapt_ops(void) |
| 174 | +{ | ||
| 175 | + return trs_chan_get_stars_v1_adapt_ops(); | ||
| 176 | +} | ||
| 159 | 177 | ||
| 160 | -struct trs_core_adapt_ops *trs_core_cloud_v2_get_stars_adapt_ops(void) { return trs_core_get_stars_v1_adapt_ops(); } | 178 | +struct trs_core_adapt_ops *trs_core_cloud_v2_get_stars_adapt_ops(void) |
| 179 | +{ | ||
| 180 | + return trs_core_get_stars_v1_adapt_ops(); | ||
| 181 | +} | ||
| 161 | 182 | ||
| 162 | -int trs_soc_cloud_v2_sq_send_trigger_db_init(struct trs_id_inst *inst) { return trs_sq_send_trigger_db_init(inst); } | 183 | +int trs_soc_cloud_v2_sq_send_trigger_db_init(struct trs_id_inst *inst) |
| 184 | +{ | ||
| 185 | + return trs_sq_send_trigger_db_init(inst); | ||
| 186 | +} | ||
| 163 | 187 | ||
| 164 | -void trs_soc_cloud_v2_sq_send_trigger_db_uninit(struct trs_id_inst *inst) { trs_sq_send_trigger_db_uninit(inst); } | 188 | +void trs_soc_cloud_v2_sq_send_trigger_db_uninit(struct trs_id_inst *inst) |
| 189 | +{ | ||
| 190 | + trs_sq_send_trigger_db_uninit(inst); | ||
| 191 | +} | ||
| @@ -37,17 +37,38 @@ struct trs_chan_adapt_ops *trs_chan_cloud_v2_get_stars_adapt_ops(void); | |||
| 37 | int trs_soc_cloud_v2_sq_send_trigger_db_init(struct trs_id_inst *inst); | 37 | int trs_soc_cloud_v2_sq_send_trigger_db_init(struct trs_id_inst *inst); |
| 38 | void trs_soc_cloud_v2_sq_send_trigger_db_uninit(struct trs_id_inst *inst); | 38 | void trs_soc_cloud_v2_sq_send_trigger_db_uninit(struct trs_id_inst *inst); |
| 39 | 39 | ||
| 40 | -static inline int trs_soc_get_cloud_v2_hwcq_rsv_mem_type(void) { return RSV_MEM_HW_SQCQ; } | 40 | +static inline int trs_soc_get_cloud_v2_hwcq_rsv_mem_type(void) |
| 41 | +{ | ||
| 42 | + return RSV_MEM_HW_SQCQ; | ||
| 43 | +} | ||
| 41 | 44 | ||
| 42 | -static inline int trs_soc_get_cloud_v2_sq_head_reg_offset(void) { return TRS_STARS_SCHED_SQ_HEAD_OFFSET; } | 45 | +static inline int trs_soc_get_cloud_v2_sq_head_reg_offset(void) |
| 46 | +{ | ||
| 47 | + return TRS_STARS_SCHED_SQ_HEAD_OFFSET; | ||
| 48 | +} | ||
| 43 | 49 | ||
| 44 | -static inline int trs_soc_get_cloud_v2_sq_tail_reg_offset(void) { return TRS_STARS_SCHED_SQ_TAIL_OFFSET; } | 50 | +static inline int trs_soc_get_cloud_v2_sq_tail_reg_offset(void) |
| 51 | +{ | ||
| 52 | + return TRS_STARS_SCHED_SQ_TAIL_OFFSET; | ||
| 53 | +} | ||
| 45 | 54 | ||
| 46 | -static inline int trs_soc_get_cloud_v2_sq_status_reg_offset(void) { return TRS_STARS_SCHED_SQ_STATUS_OFFSET; } | 55 | +static inline int trs_soc_get_cloud_v2_sq_status_reg_offset(void) |
| 56 | +{ | ||
| 57 | + return TRS_STARS_SCHED_SQ_STATUS_OFFSET; | ||
| 58 | +} | ||
| 47 | 59 | ||
| 48 | -static inline int trs_soc_get_cloud_v2_cq_head_reg_offset(void) { return TRS_STARS_SCHED_CQ_HEAD_OFFSET; } | 60 | +static inline int trs_soc_get_cloud_v2_cq_head_reg_offset(void) |
| 61 | +{ | ||
| 62 | + return TRS_STARS_SCHED_CQ_HEAD_OFFSET; | ||
| 63 | +} | ||
| 49 | 64 | ||
| 50 | -static inline int trs_soc_get_cloud_v2_cq_tail_reg_offset(void) { return TRS_STARS_SCHED_CQ_TAIL_OFFSET; } | 65 | +static inline int trs_soc_get_cloud_v2_cq_tail_reg_offset(void) |
| 66 | +{ | ||
| 67 | + return TRS_STARS_SCHED_CQ_TAIL_OFFSET; | ||
| 68 | +} | ||
| 51 | 69 | ||
| 52 | -static inline bool trs_cloud_v2_is_support_soft_mbox(void) { return false; } | 70 | +static inline bool trs_cloud_v2_is_support_soft_mbox(void) |
| 71 | +{ | ||
| 72 | + return false; | ||
| 73 | +} | ||
| 53 | 74 | ||
| @@ -28,8 +28,8 @@ int trs_soc_cloud_v4_chan_stars_init(struct trs_id_inst *inst) | |||
| 28 | return ret; | 28 | return ret; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - ret = | 31 | + ret = trs_chan_ts_inst_register(inst, trs_soc_get_hw_type(inst->devid), UDA_NEAR, |
| 32 | - trs_chan_ts_inst_register(inst, trs_soc_get_hw_type(inst->devid), UDA_NEAR, trs_chan_get_stars_v2_adapt_ops()); | 32 | + trs_chan_get_stars_v2_adapt_ops()); |
| 33 | if (ret != 0) { | 33 | if (ret != 0) { |
| 34 | trs_chan_stars_v2_ops_uninit(inst); | 34 | trs_chan_stars_v2_ops_uninit(inst); |
| 35 | } | 35 | } |
| @@ -43,15 +43,33 @@ void trs_soc_cloud_v4_chan_stars_uninit(struct trs_id_inst *inst) | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | -int trs_soc_cloud_v4_chan_stars_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v2_ops_init(inst); } | 46 | +int trs_soc_cloud_v4_chan_stars_ops_init(struct trs_id_inst *inst) |
| 47 | +{ | ||
| 48 | + return trs_chan_stars_v2_ops_init(inst); | ||
| 49 | +} | ||
| 47 | 50 | ||
| 48 | -void trs_soc_cloud_v4_chan_stars_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v2_ops_uninit(inst); } | 51 | +void trs_soc_cloud_v4_chan_stars_ops_uninit(struct trs_id_inst *inst) |
| 52 | +{ | ||
| 53 | + trs_chan_stars_v2_ops_uninit(inst); | ||
| 54 | +} | ||
| 49 | 55 | ||
| 50 | -struct trs_chan_adapt_ops *trs_chan_cloud_v4_get_stars_adapt_ops(void) { return trs_chan_get_stars_v2_adapt_ops(); } | 56 | +struct trs_chan_adapt_ops *trs_chan_cloud_v4_get_stars_adapt_ops(void) |
| 57 | +{ | ||
| 58 | + return trs_chan_get_stars_v2_adapt_ops(); | ||
| 59 | +} | ||
| 51 | 60 | ||
| 52 | 61 | ||
| 53 | -struct trs_core_adapt_ops *trs_core_cloud_v4_get_stars_adapt_ops(void) { return trs_core_get_stars_v2_adapt_ops(); } | 62 | +struct trs_core_adapt_ops *trs_core_cloud_v4_get_stars_adapt_ops(void) |
| 63 | +{ | ||
| 64 | + return trs_core_get_stars_v2_adapt_ops(); | ||
| 65 | +} | ||
| 54 | 66 | ||
| 55 | -int trs_soc_cloud_v4_sq_send_trigger_db_init(struct trs_id_inst *inst) { return 0; } | 67 | +int trs_soc_cloud_v4_sq_send_trigger_db_init(struct trs_id_inst *inst) |
| 68 | +{ | ||
| 69 | + return 0; | ||
| 70 | +} | ||
| 56 | 71 | ||
| 57 | -void trs_soc_cloud_v4_sq_send_trigger_db_uninit(struct trs_id_inst *inst) { return; } | 72 | +void trs_soc_cloud_v4_sq_send_trigger_db_uninit(struct trs_id_inst *inst) |
| 73 | +{ | ||
| 74 | + return; | ||
| 75 | +} | ||
| @@ -47,7 +47,10 @@ static inline u32 trs_soc_get_cloud_v4_notify_offset(u32 id) | |||
| 47 | (id / TRS_CLOUD_V4_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V4_NOTIFY_SLICE_SIZE; | 47 | (id / TRS_CLOUD_V4_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V4_NOTIFY_SLICE_SIZE; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -static inline size_t trs_soc_get_cloud_v4_notify_size(void) { return (size_t)TRS_CLOUD_V4_NOTIFY_SIZE; } | 50 | +static inline size_t trs_soc_get_cloud_v4_notify_size(void) |
| 51 | +{ | ||
| 52 | + return (size_t)TRS_CLOUD_V4_NOTIFY_SIZE; | ||
| 53 | +} | ||
| 51 | 54 | ||
| 52 | /* Cnt notify */ | 55 | /* Cnt notify */ |
| 53 | 56 | ||
| @@ -66,10 +69,16 @@ static inline u32 trs_soc_get_cloud_v4_cnt_notify_offset(u32 id) | |||
| 66 | (id / TRS_CLOUD_V4_CNT_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V4_CNT_NOTIFY_SLICE_SIZE; | 69 | (id / TRS_CLOUD_V4_CNT_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V4_CNT_NOTIFY_SLICE_SIZE; |
| 67 | } | 70 | } |
| 68 | 71 | ||
| 69 | -static inline size_t trs_soc_get_cloud_v4_cnt_notify_size(void) { return (size_t)TRS_CLOUD_V4_CNT_NOTIFY_SIZE; } | 72 | +static inline size_t trs_soc_get_cloud_v4_cnt_notify_size(void) |
| 73 | +{ | ||
| 74 | + return (size_t)TRS_CLOUD_V4_CNT_NOTIFY_SIZE; | ||
| 75 | +} | ||
| 70 | 76 | ||
| 71 | 77 | ||
| 72 | -static inline size_t trs_soc_get_cloud_v4_stars_sched_stride(void) { return (u32)TRS_CLOUD_V4_STARS_SCHED_STRIDE; } | 78 | +static inline size_t trs_soc_get_cloud_v4_stars_sched_stride(void) |
| 79 | +{ | ||
| 80 | + return (u32)TRS_CLOUD_V4_STARS_SCHED_STRIDE; | ||
| 81 | +} | ||
| 73 | 82 | ||
| 74 | static inline u32 trs_soc_get_cloud_v4_sq_mem_side(u32 devid, struct trs_chan_type *types) | 83 | static inline u32 trs_soc_get_cloud_v4_sq_mem_side(u32 devid, struct trs_chan_type *types) |
| 75 | { | 84 | { |
| @@ -93,17 +102,38 @@ static inline u32 trs_soc_get_cloud_v4_cq_mem_side(u32 devid) | |||
| 93 | } | 102 | } |
| 94 | } | 103 | } |
| 95 | 104 | ||
| 96 | -static inline int trs_soc_get_cloud_v4_sq_head_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_HEAD_OFFSET; } | 105 | +static inline int trs_soc_get_cloud_v4_sq_head_reg_offset(void) |
| 106 | +{ | ||
| 107 | + return TRS_STARS_V2_SCHED_SQ_HEAD_OFFSET; | ||
| 108 | +} | ||
| 97 | 109 | ||
| 98 | -static inline int trs_soc_get_cloud_v4_sq_tail_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_TAIL_OFFSET; } | 110 | +static inline int trs_soc_get_cloud_v4_sq_tail_reg_offset(void) |
| 111 | +{ | ||
| 112 | + return TRS_STARS_V2_SCHED_SQ_TAIL_OFFSET; | ||
| 113 | +} | ||
| 99 | 114 | ||
| 100 | -static inline int trs_soc_get_cloud_v4_sq_status_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_STATUS_OFFSET; } | 115 | +static inline int trs_soc_get_cloud_v4_sq_status_reg_offset(void) |
| 116 | +{ | ||
| 117 | + return TRS_STARS_V2_SCHED_SQ_STATUS_OFFSET; | ||
| 118 | +} | ||
| 101 | 119 | ||
| 102 | -static inline int trs_soc_get_cloud_v4_cq_head_reg_offset(void) { return TRS_STARS_V2_SCHED_CQ_HEAD_OFFSET; } | 120 | +static inline int trs_soc_get_cloud_v4_cq_head_reg_offset(void) |
| 121 | +{ | ||
| 122 | + return TRS_STARS_V2_SCHED_CQ_HEAD_OFFSET; | ||
| 123 | +} | ||
| 103 | 124 | ||
| 104 | -static inline int trs_soc_get_cloud_v4_cq_tail_reg_offset(void) { return TRS_STARS_V2_SCHED_CQ_TAIL_OFFSET; } | 125 | +static inline int trs_soc_get_cloud_v4_cq_tail_reg_offset(void) |
| 126 | +{ | ||
| 127 | + return TRS_STARS_V2_SCHED_CQ_TAIL_OFFSET; | ||
| 128 | +} | ||
| 105 | 129 | ||
| 106 | -static inline int trs_soc_get_cloud_v4_db_cfg(int db_type, u32 *start, u32 *end) { return -EOPNOTSUPP; } | 130 | +static inline int trs_soc_get_cloud_v4_db_cfg(int db_type, u32 *start, u32 *end) |
| 131 | +{ | ||
| 132 | + return -EOPNOTSUPP; | ||
| 133 | +} | ||
| 107 | 134 | ||
| 108 | -static inline bool trs_cloud_v4_is_support_soft_mbox(void) { return true; } | 135 | +static inline bool trs_cloud_v4_is_support_soft_mbox(void) |
| 136 | +{ | ||
| 137 | + return true; | ||
| 138 | +} | ||
| 109 | 139 | ||
| @@ -28,8 +28,8 @@ int trs_soc_cloud_v5_chan_stars_init(struct trs_id_inst *inst) | |||
| 28 | return ret; | 28 | return ret; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - ret = | 31 | + ret = trs_chan_ts_inst_register(inst, trs_soc_get_hw_type(inst->devid), UDA_NEAR, |
| 32 | - trs_chan_ts_inst_register(inst, trs_soc_get_hw_type(inst->devid), UDA_NEAR, trs_chan_get_stars_v2_adapt_ops()); | 32 | + trs_chan_get_stars_v2_adapt_ops()); |
| 33 | if (ret != 0) { | 33 | if (ret != 0) { |
| 34 | trs_chan_stars_v2_ops_uninit(inst); | 34 | trs_chan_stars_v2_ops_uninit(inst); |
| 35 | } | 35 | } |
| @@ -43,15 +43,33 @@ void trs_soc_cloud_v5_chan_stars_uninit(struct trs_id_inst *inst) | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | -int trs_soc_cloud_v5_chan_stars_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v2_ops_init(inst); } | 46 | +int trs_soc_cloud_v5_chan_stars_ops_init(struct trs_id_inst *inst) |
| 47 | +{ | ||
| 48 | + return trs_chan_stars_v2_ops_init(inst); | ||
| 49 | +} | ||
| 47 | 50 | ||
| 48 | -void trs_soc_cloud_v5_chan_stars_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v2_ops_uninit(inst); } | 51 | +void trs_soc_cloud_v5_chan_stars_ops_uninit(struct trs_id_inst *inst) |
| 52 | +{ | ||
| 53 | + trs_chan_stars_v2_ops_uninit(inst); | ||
| 54 | +} | ||
| 49 | 55 | ||
| 50 | -struct trs_chan_adapt_ops *trs_chan_cloud_v5_get_stars_adapt_ops(void) { return trs_chan_get_stars_v2_adapt_ops(); } | 56 | +struct trs_chan_adapt_ops *trs_chan_cloud_v5_get_stars_adapt_ops(void) |
| 57 | +{ | ||
| 58 | + return trs_chan_get_stars_v2_adapt_ops(); | ||
| 59 | +} | ||
| 51 | 60 | ||
| 52 | 61 | ||
| 53 | -struct trs_core_adapt_ops *trs_core_cloud_v5_get_stars_adapt_ops(void) { return trs_core_get_stars_v2_adapt_ops(); } | 62 | +struct trs_core_adapt_ops *trs_core_cloud_v5_get_stars_adapt_ops(void) |
| 63 | +{ | ||
| 64 | + return trs_core_get_stars_v2_adapt_ops(); | ||
| 65 | +} | ||
| 54 | 66 | ||
| 55 | -int trs_soc_cloud_v5_sq_send_trigger_db_init(struct trs_id_inst *inst) { return 0; } | 67 | +int trs_soc_cloud_v5_sq_send_trigger_db_init(struct trs_id_inst *inst) |
| 68 | +{ | ||
| 69 | + return 0; | ||
| 70 | +} | ||
| 56 | 71 | ||
| 57 | -void trs_soc_cloud_v5_sq_send_trigger_db_uninit(struct trs_id_inst *inst) { return; } | 72 | +void trs_soc_cloud_v5_sq_send_trigger_db_uninit(struct trs_id_inst *inst) |
| 73 | +{ | ||
| 74 | + return; | ||
| 75 | +} | ||
| @@ -46,7 +46,10 @@ static inline u32 trs_soc_get_cloud_v5_notify_offset(u32 id) | |||
| 46 | (id / TRS_CLOUD_V5_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V5_NOTIFY_SLICE_SIZE; | 46 | (id / TRS_CLOUD_V5_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V5_NOTIFY_SLICE_SIZE; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | -static inline size_t trs_soc_get_cloud_v5_notify_size(void) { return (size_t)TRS_CLOUD_V5_NOTIFY_SIZE; } | 49 | +static inline size_t trs_soc_get_cloud_v5_notify_size(void) |
| 50 | +{ | ||
| 51 | + return (size_t)TRS_CLOUD_V5_NOTIFY_SIZE; | ||
| 52 | +} | ||
| 50 | 53 | ||
| 51 | /* Cnt notify */ | 54 | /* Cnt notify */ |
| 52 | 55 | ||
| @@ -65,10 +68,16 @@ static inline u32 trs_soc_get_cloud_v5_cnt_notify_offset(u32 id) | |||
| 65 | (id / TRS_CLOUD_V5_CNT_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V5_CNT_NOTIFY_SLICE_SIZE; | 68 | (id / TRS_CLOUD_V5_CNT_NOTIFY_NUM_PER_SLICE) * TRS_CLOUD_V5_CNT_NOTIFY_SLICE_SIZE; |
| 66 | } | 69 | } |
| 67 | 70 | ||
| 68 | -static inline size_t trs_soc_get_cloud_v5_cnt_notify_size(void) { return (size_t)TRS_CLOUD_V5_CNT_NOTIFY_SIZE; } | 71 | +static inline size_t trs_soc_get_cloud_v5_cnt_notify_size(void) |
| 72 | +{ | ||
| 73 | + return (size_t)TRS_CLOUD_V5_CNT_NOTIFY_SIZE; | ||
| 74 | +} | ||
| 69 | 75 | ||
| 70 | 76 | ||
| 71 | -static inline size_t trs_soc_get_cloud_v5_stars_sched_stride(void) { return (u32)TRS_cloud_v5_STARS_SCHED_STRIDE; } | 77 | +static inline size_t trs_soc_get_cloud_v5_stars_sched_stride(void) |
| 78 | +{ | ||
| 79 | + return (u32)TRS_cloud_v5_STARS_SCHED_STRIDE; | ||
| 80 | +} | ||
| 72 | 81 | ||
| 73 | static inline u32 trs_soc_get_cloud_v5_sq_mem_side(u32 devid, struct trs_chan_type *types) | 82 | static inline u32 trs_soc_get_cloud_v5_sq_mem_side(u32 devid, struct trs_chan_type *types) |
| 74 | { | 83 | { |
| @@ -92,17 +101,38 @@ static inline u32 trs_soc_get_cloud_v5_cq_mem_side(u32 devid) | |||
| 92 | } | 101 | } |
| 93 | } | 102 | } |
| 94 | 103 | ||
| 95 | -static inline int trs_soc_get_cloud_v5_sq_head_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_HEAD_OFFSET; } | 104 | +static inline int trs_soc_get_cloud_v5_sq_head_reg_offset(void) |
| 105 | +{ | ||
| 106 | + return TRS_STARS_V2_SCHED_SQ_HEAD_OFFSET; | ||
| 107 | +} | ||
| 96 | 108 | ||
| 97 | -static inline int trs_soc_get_cloud_v5_sq_tail_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_TAIL_OFFSET; } | 109 | +static inline int trs_soc_get_cloud_v5_sq_tail_reg_offset(void) |
| 110 | +{ | ||
| 111 | + return TRS_STARS_V2_SCHED_SQ_TAIL_OFFSET; | ||
| 112 | +} | ||
| 98 | 113 | ||
| 99 | -static inline int trs_soc_get_cloud_v5_sq_status_reg_offset(void) { return TRS_STARS_V2_SCHED_SQ_STATUS_OFFSET; } | 114 | +static inline int trs_soc_get_cloud_v5_sq_status_reg_offset(void) |
| 115 | +{ | ||
| 116 | + return TRS_STARS_V2_SCHED_SQ_STATUS_OFFSET; | ||
| 117 | +} | ||
| 100 | 118 | ||
| 101 | -static inline int trs_soc_get_cloud_v5_cq_head_reg_offset(void) { return TRS_STARS_V2_SCHED_CQ_HEAD_OFFSET; } | 119 | +static inline int trs_soc_get_cloud_v5_cq_head_reg_offset(void) |
| 120 | +{ | ||
| 121 | + return TRS_STARS_V2_SCHED_CQ_HEAD_OFFSET; | ||
| 122 | +} | ||
| 102 | 123 | ||
| 103 | -static inline int trs_soc_get_cloud_v5_cq_tail_reg_offset(void) { return TRS_STARS_V2_SCHED_CQ_TAIL_OFFSET; } | 124 | +static inline int trs_soc_get_cloud_v5_cq_tail_reg_offset(void) |
| 125 | +{ | ||
| 126 | + return TRS_STARS_V2_SCHED_CQ_TAIL_OFFSET; | ||
| 127 | +} | ||
| 104 | 128 | ||
| 105 | -static inline int trs_soc_get_cloud_v5_db_cfg(int db_type, u32 *start, u32 *end) { return -EOPNOTSUPP; } | 129 | +static inline int trs_soc_get_cloud_v5_db_cfg(int db_type, u32 *start, u32 *end) |
| 130 | +{ | ||
| 131 | + return -EOPNOTSUPP; | ||
| 132 | +} | ||
| 106 | 133 | ||
| 107 | -static inline bool trs_cloud_v5_is_support_soft_mbox(void) { return true; } | 134 | +static inline bool trs_cloud_v5_is_support_soft_mbox(void) |
| 135 | +{ | ||
| 136 | + return true; | ||
| 137 | +} | ||
| 108 | 138 | ||
| @@ -32,14 +32,26 @@ | |||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | -u32 trs_soc_get_mini_v2_notify_offset(u32 notify_id) { return notify_id * TRS_MINI_V2_NOTIFY_SIZE; } | 35 | +u32 trs_soc_get_mini_v2_notify_offset(u32 notify_id) |
| 36 | +{ | ||
| 37 | + return notify_id * TRS_MINI_V2_NOTIFY_SIZE; | ||
| 38 | +} | ||
| 36 | 39 | ||
| 37 | -size_t trs_soc_get_mini_v2_notify_size(void) { return (size_t)TRS_MINI_V2_NOTIFY_SIZE; } | 40 | +size_t trs_soc_get_mini_v2_notify_size(void) |
| 41 | +{ | ||
| 42 | + return (size_t)TRS_MINI_V2_NOTIFY_SIZE; | ||
| 43 | +} | ||
| 38 | 44 | ||
| 39 | 45 | ||
| 40 | -u32 trs_soc_get_mini_v2_event_offset(u32 event_id) { return event_id * TRS_MINI_V2_EVENT_SIZE; } | 46 | +u32 trs_soc_get_mini_v2_event_offset(u32 event_id) |
| 47 | +{ | ||
| 48 | + return event_id * TRS_MINI_V2_EVENT_SIZE; | ||
| 49 | +} | ||
| 41 | 50 | ||
| 42 | -size_t trs_soc_get_mini_v2_db_stride(void) { return (size_t)TRS_SOC_MINI_V2_DB_STRIDE; } | 51 | +size_t trs_soc_get_mini_v2_db_stride(void) |
| 52 | +{ | ||
| 53 | + return (size_t)TRS_SOC_MINI_V2_DB_STRIDE; | ||
| 54 | +} | ||
| 43 | 55 | ||
| 44 | int trs_soc_get_mini_v2_db_cfg(int db_type, u32 *start, u32 *end) | 56 | int trs_soc_get_mini_v2_db_cfg(int db_type, u32 *start, u32 *end) |
| 45 | { | 57 | { |
| @@ -26,9 +26,18 @@ static inline u32 trs_soc_get_mini_v2_sq_mem_side(u32 devid, struct trs_chan_typ | |||
| 26 | return TRS_CHAN_DEV_RSV_MEM; | 26 | return TRS_CHAN_DEV_RSV_MEM; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | -static inline u32 trs_soc_get_mini_v2_cq_mem_side(u32 devid) { return TRS_CHAN_HOST_MEM; } | 29 | +static inline u32 trs_soc_get_mini_v2_cq_mem_side(u32 devid) |
| 30 | +{ | ||
| 31 | + return TRS_CHAN_HOST_MEM; | ||
| 32 | +} | ||
| 30 | 33 | ||
| 31 | -static inline int trs_soc_get_mini_v2_hwcq_rsv_mem_type(void) { return RSV_MEM_HW_SQCQ; } | 34 | +static inline int trs_soc_get_mini_v2_hwcq_rsv_mem_type(void) |
| 35 | +{ | ||
| 36 | + return RSV_MEM_HW_SQCQ; | ||
| 37 | +} | ||
| 32 | 38 | ||
| 33 | -static inline bool trs_mini_v2_is_support_soft_mbox(void) { return false; } | 39 | +static inline bool trs_mini_v2_is_support_soft_mbox(void) |
| 40 | +{ | ||
| 41 | + return false; | ||
| 42 | +} | ||
| 34 | 43 | ||
| @@ -37,9 +37,15 @@ | |||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | -u32 trs_soc_get_mini_v3_notify_offset(u32 notify_id) { return notify_id * TRS_MINI_V3_NOTIFY_SIZE; } | 40 | +u32 trs_soc_get_mini_v3_notify_offset(u32 notify_id) |
| 41 | +{ | ||
| 42 | + return notify_id * TRS_MINI_V3_NOTIFY_SIZE; | ||
| 43 | +} | ||
| 41 | 44 | ||
| 42 | -size_t trs_soc_get_mini_v3_notify_size(void) { return (size_t)TRS_MINI_V3_NOTIFY_SIZE; } | 45 | +size_t trs_soc_get_mini_v3_notify_size(void) |
| 46 | +{ | ||
| 47 | + return (size_t)TRS_MINI_V3_NOTIFY_SIZE; | ||
| 48 | +} | ||
| 43 | 49 | ||
| 44 | u32 trs_soc_get_mini_v3_event_offset(u32 event_id) | 50 | u32 trs_soc_get_mini_v3_event_offset(u32 event_id) |
| 45 | { | 51 | { |
| @@ -49,9 +55,15 @@ u32 trs_soc_get_mini_v3_event_offset(u32 event_id) | |||
| 49 | 55 | ||
| 50 | } | 56 | } |
| 51 | 57 | ||
| 52 | -size_t trs_soc_get_mini_v3_db_stride(void) { return (size_t)TRS_SOC_MINI_V3_DB_STRIDE; } | 58 | +size_t trs_soc_get_mini_v3_db_stride(void) |
| 59 | +{ | ||
| 60 | + return (size_t)TRS_SOC_MINI_V3_DB_STRIDE; | ||
| 61 | +} | ||
| 53 | 62 | ||
| 54 | -size_t trs_soc_get_mini_v3_stars_sched_stride(void) { return (u32)TRS_MINI_V3_STARS_SCHED_STRIDE; } | 63 | +size_t trs_soc_get_mini_v3_stars_sched_stride(void) |
| 64 | +{ | ||
| 65 | + return (u32)TRS_MINI_V3_STARS_SCHED_STRIDE; | ||
| 66 | +} | ||
| 55 | 67 | ||
| 56 | int trs_soc_get_mini_v3_db_cfg(int db_type, u32 *start, u32 *end) | 68 | int trs_soc_get_mini_v3_db_cfg(int db_type, u32 *start, u32 *end) |
| 57 | { | 69 | { |
| @@ -98,15 +110,33 @@ void trs_soc_mini_v3_chan_stars_uninit(struct trs_id_inst *inst) | |||
| 98 | } | 110 | } |
| 99 | 111 | ||
| 100 | 112 | ||
| 101 | -int trs_soc_mini_v3_chan_stars_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v1_ops_init(inst); } | 113 | +int trs_soc_mini_v3_chan_stars_ops_init(struct trs_id_inst *inst) |
| 114 | +{ | ||
| 115 | + return trs_chan_stars_v1_ops_init(inst); | ||
| 116 | +} | ||
| 102 | 117 | ||
| 103 | -void trs_soc_mini_v3_chan_stars_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v1_ops_uninit(inst); } | 118 | +void trs_soc_mini_v3_chan_stars_ops_uninit(struct trs_id_inst *inst) |
| 119 | +{ | ||
| 120 | + trs_chan_stars_v1_ops_uninit(inst); | ||
| 121 | +} | ||
| 104 | 122 | ||
| 105 | -struct trs_chan_adapt_ops *trs_chan_mini_v3_get_stars_adapt_ops(void) { return trs_chan_get_stars_v1_adapt_ops(); } | 123 | +struct trs_chan_adapt_ops *trs_chan_mini_v3_get_stars_adapt_ops(void) |
| 124 | +{ | ||
| 125 | + return trs_chan_get_stars_v1_adapt_ops(); | ||
| 126 | +} | ||
| 106 | 127 | ||
| 107 | 128 | ||
| 108 | -struct trs_core_adapt_ops *trs_core_mini_v3_get_stars_adapt_ops(void) { return trs_core_get_stars_v1_adapt_ops(); } | 129 | +struct trs_core_adapt_ops *trs_core_mini_v3_get_stars_adapt_ops(void) |
| 130 | +{ | ||
| 131 | + return trs_core_get_stars_v1_adapt_ops(); | ||
| 132 | +} | ||
| 109 | 133 | ||
| 110 | -int trs_soc_mini_v3_sq_send_trigger_db_init(struct trs_id_inst *inst) { return trs_sq_send_trigger_db_init(inst); } | 134 | +int trs_soc_mini_v3_sq_send_trigger_db_init(struct trs_id_inst *inst) |
| 135 | +{ | ||
| 136 | + return trs_sq_send_trigger_db_init(inst); | ||
| 137 | +} | ||
| 111 | 138 | ||
| 112 | -void trs_soc_mini_v3_sq_send_trigger_db_uninit(struct trs_id_inst *inst) { trs_sq_send_trigger_db_uninit(inst); } | 139 | +void trs_soc_mini_v3_sq_send_trigger_db_uninit(struct trs_id_inst *inst) |
| 140 | +{ | ||
| 141 | + trs_sq_send_trigger_db_uninit(inst); | ||
| 142 | +} | ||
| @@ -41,19 +41,43 @@ static inline u32 trs_soc_get_mini_v3_sq_mem_side(u32 devid, struct trs_chan_typ | |||
| 41 | return TRS_CHAN_DEV_RSV_MEM; | 41 | return TRS_CHAN_DEV_RSV_MEM; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | -static inline u32 trs_soc_get_mini_v3_cq_mem_side(u32 devid) { return TRS_CHAN_DEV_RSV_MEM; } | 44 | +static inline u32 trs_soc_get_mini_v3_cq_mem_side(u32 devid) |
| 45 | +{ | ||
| 46 | + return TRS_CHAN_DEV_RSV_MEM; | ||
| 47 | +} | ||
| 45 | 48 | ||
| 46 | -static inline int trs_soc_get_mini_v3_hwcq_rsv_mem_type(void) { return RSV_MEM_HW_SQCQ; } | 49 | +static inline int trs_soc_get_mini_v3_hwcq_rsv_mem_type(void) |
| 50 | +{ | ||
| 51 | + return RSV_MEM_HW_SQCQ; | ||
| 52 | +} | ||
| 47 | 53 | ||
| 48 | -static inline int trs_soc_get_mini_v3_sq_head_reg_offset(void) { return TRS_STARS_SCHED_SQ_HEAD_OFFSET; } | 54 | +static inline int trs_soc_get_mini_v3_sq_head_reg_offset(void) |
| 55 | +{ | ||
| 56 | + return TRS_STARS_SCHED_SQ_HEAD_OFFSET; | ||
| 57 | +} | ||
| 49 | 58 | ||
| 50 | -static inline int trs_soc_get_mini_v3_sq_tail_reg_offset(void) { return TRS_STARS_SCHED_SQ_TAIL_OFFSET; } | 59 | +static inline int trs_soc_get_mini_v3_sq_tail_reg_offset(void) |
| 60 | +{ | ||
| 61 | + return TRS_STARS_SCHED_SQ_TAIL_OFFSET; | ||
| 62 | +} | ||
| 51 | 63 | ||
| 52 | -static inline int trs_soc_get_mini_v3_sq_status_reg_offset(void) { return TRS_STARS_SCHED_SQ_STATUS_OFFSET; } | 64 | +static inline int trs_soc_get_mini_v3_sq_status_reg_offset(void) |
| 65 | +{ | ||
| 66 | + return TRS_STARS_SCHED_SQ_STATUS_OFFSET; | ||
| 67 | +} | ||
| 53 | 68 | ||
| 54 | -static inline int trs_soc_get_mini_v3_cq_head_reg_offset(void) { return TRS_STARS_SCHED_CQ_HEAD_OFFSET; } | 69 | +static inline int trs_soc_get_mini_v3_cq_head_reg_offset(void) |
| 70 | +{ | ||
| 71 | + return TRS_STARS_SCHED_CQ_HEAD_OFFSET; | ||
| 72 | +} | ||
| 55 | 73 | ||
| 56 | -static inline int trs_soc_get_mini_v3_cq_tail_reg_offset(void) { return TRS_STARS_SCHED_CQ_TAIL_OFFSET; } | 74 | +static inline int trs_soc_get_mini_v3_cq_tail_reg_offset(void) |
| 75 | +{ | ||
| 76 | + return TRS_STARS_SCHED_CQ_TAIL_OFFSET; | ||
| 77 | +} | ||
| 57 | 78 | ||
| 58 | -static inline bool trs_mini_v3_is_support_soft_mbox(void) { return false; } | 79 | +static inline bool trs_mini_v3_is_support_soft_mbox(void) |
| 80 | +{ | ||
| 81 | + return false; | ||
| 82 | +} | ||
| 59 | 83 | ||
| @@ -39,7 +39,10 @@ int trs_soc_get_chip_type(u32 phy_devid) | |||
| 39 | } | 39 | } |
| 40 | KA_EXPORT_SYMBOL_GPL(trs_soc_get_chip_type); | 40 | KA_EXPORT_SYMBOL_GPL(trs_soc_get_chip_type); |
| 41 | 41 | ||
| 42 | -int trs_soc_get_hw_type(u32 phy_devid) { return trs_get_hw_type_by_chip_type(trs_soc_get_chip_type(phy_devid)); } | 42 | +int trs_soc_get_hw_type(u32 phy_devid) |
| 43 | +{ | ||
| 44 | + return trs_get_hw_type_by_chip_type(trs_soc_get_chip_type(phy_devid)); | ||
| 45 | +} | ||
| 43 | 46 | ||
| 44 | static size_t (*const soc_get_db_stride[TRS_CHIP_TYPE_MAX])(void) = { | 47 | static size_t (*const soc_get_db_stride[TRS_CHIP_TYPE_MAX])(void) = { |
| 45 | [TRS_CHIP_TYPE_MINI_V3] = trs_soc_get_mini_v3_db_stride, | 48 | [TRS_CHIP_TYPE_MINI_V3] = trs_soc_get_mini_v3_db_stride, |
| @@ -211,9 +214,8 @@ u32 trs_soc_get_sq_mem_side(struct trs_id_inst *inst, struct trs_chan_type *type | |||
| 211 | if (soc_get_sq_mem_side[chip_type] != NULL) { | 214 | if (soc_get_sq_mem_side[chip_type] != NULL) { |
| 212 | sq_mem_side = soc_get_sq_mem_side[chip_type](inst->devid, types); | 215 | sq_mem_side = soc_get_sq_mem_side[chip_type](inst->devid, types); |
| 213 | } | 216 | } |
| 214 | - trs_debug( | 217 | + trs_debug("Get sq mem side. (devid=%d; sq mem side=%d; type=%u; sub_type=%u)\n", inst->devid, sq_mem_side, |
| 215 | - "Get sq mem side. (devid=%d; sq mem side=%d; type=%u; sub_type=%u)\n", inst->devid, sq_mem_side, types->type, | 218 | + types->type, types->sub_type); |
| 216 | - types->sub_type); | ||
| 217 | return sq_mem_side; | 219 | return sq_mem_side; |
| 218 | } | 220 | } |
| 219 | 221 | ||
| @@ -82,7 +82,10 @@ static void trs_get_core_info(u8 *base, enum accelerator_core_type type, u32 *co | |||
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | -static inline bool trs_util_status_is_valid(u8 *status) { return (*status == 0); } | 85 | +static inline bool trs_util_status_is_valid(u8 *status) |
| 86 | +{ | ||
| 87 | + return (*status == 0); | ||
| 88 | +} | ||
| 86 | 89 | ||
| 87 | static int trs_calculate_util(u8 *base, enum accelerator_core_type type, u32 *utilization) | 90 | static int trs_calculate_util(u8 *base, enum accelerator_core_type type, u32 *utilization) |
| 88 | { | 91 | { |
| @@ -112,8 +115,8 @@ static int trs_calculate_util(u8 *base, enum accelerator_core_type type, u32 *ut | |||
| 112 | 115 | ||
| 113 | *utilization = (unuse_num == core_num) ? 0 : (core_ans / (core_num - unuse_num)); | 116 | *utilization = (unuse_num == core_num) ? 0 : (core_ans / (core_num - unuse_num)); |
| 114 | 117 | ||
| 115 | - trs_debug( | 118 | + trs_debug("Core util info. (util=%u; core_num=%u; unuse_num=%u; type=%d)\n", *utilization, core_num, unuse_num, |
| 116 | - "Core util info. (util=%u; core_num=%u; unuse_num=%u; type=%d)\n", *utilization, core_num, unuse_num, type); | 119 | + type); |
| 117 | 120 | ||
| 118 | return 0; | 121 | return 0; |
| 119 | } | 122 | } |
| @@ -127,9 +130,15 @@ static void trs_util_result_fill(struct udis_dev_info *core_res, u32 utilization | |||
| 127 | core_res->last_update_time = ktime_get_raw_ns() / KA_NSEC_PER_MSEC; | 130 | core_res->last_update_time = ktime_get_raw_ns() / KA_NSEC_PER_MSEC; |
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | -static inline void trs_init_util_status(u8 *status) { *status = TRS_CORE_UTIL_INVALID_STATUS; } | 133 | +static inline void trs_init_util_status(u8 *status) |
| 134 | +{ | ||
| 135 | + *status = TRS_CORE_UTIL_INVALID_STATUS; | ||
| 136 | +} | ||
| 131 | 137 | ||
| 132 | -static inline bool trs_util_status_is_conflict(u8 *status) { return (*status == TRS_CORE_UTIL_IPC_CONFILCT_RET); } | 138 | +static inline bool trs_util_status_is_conflict(u8 *status) |
| 139 | +{ | ||
| 140 | + return (*status == TRS_CORE_UTIL_IPC_CONFILCT_RET); | ||
| 141 | +} | ||
| 133 | 142 | ||
| 134 | static int trs_notice_tsfw_get_util_start(struct trs_id_inst *inst, enum accelerator_core_type type, u8 *base) | 143 | static int trs_notice_tsfw_get_util_start(struct trs_id_inst *inst, enum accelerator_core_type type, u8 *base) |
| 135 | { | 144 | { |
| @@ -144,8 +153,8 @@ static int trs_notice_tsfw_get_util_start(struct trs_id_inst *inst, enum acceler | |||
| 144 | return ret; | 153 | return ret; |
| 145 | } | 154 | } |
| 146 | 155 | ||
| 147 | -static int _trs_get_accelerator_util( | 156 | +static int _trs_get_accelerator_util(u32 devid, enum accelerator_core_type type, u8 *base, |
| 148 | - u32 devid, enum accelerator_core_type type, u8 *base, struct udis_dev_info *udis_info) | 157 | + struct udis_dev_info *udis_info) |
| 149 | { | 158 | { |
| 150 | struct trs_id_inst inst = {.devid = devid, .tsid = 0}; | 159 | struct trs_id_inst inst = {.devid = devid, .tsid = 0}; |
| 151 | u32 utilization; | 160 | u32 utilization; |
| @@ -270,7 +279,9 @@ void trs_accelerator_util_uninit(void) | |||
| 270 | trs_info("Trs accelerator util uninit succeed.\n"); | 279 | trs_info("Trs accelerator util uninit succeed.\n"); |
| 271 | } | 280 | } |
| 272 | 281 | ||
| 273 | -void trs_accelerator_util_init(void) {} | 282 | +void trs_accelerator_util_init(void) |
| 283 | +{} | ||
| 274 | 284 | ||
| 275 | -void trs_accelerator_util_uninit(void) {} | 285 | +void trs_accelerator_util_uninit(void) |
| 286 | +{} | ||
| 276 | 287 | ||
| @@ -32,9 +32,8 @@ | |||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | -int trs_chan_ops_request_irq( | 35 | +int trs_chan_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 36 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 36 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)) |
| 37 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)) | ||
| 38 | { | 37 | { |
| 39 | struct trs_chan_irq_attr attr; | 38 | struct trs_chan_irq_attr attr; |
| 40 | u32 group_index = irq_index; | 39 | u32 group_index = irq_index; |
| @@ -202,8 +201,17 @@ static struct trs_chan_adapt_ops g_trs_chan_stars_v1_ops = { | |||
| 202 | .sqcq_speified_id_alloc = trs_chan_ops_sqcq_speified_id_alloc, | 201 | .sqcq_speified_id_alloc = trs_chan_ops_sqcq_speified_id_alloc, |
| 203 | .sqcq_speified_id_free = trs_chan_ops_sqcq_speified_id_free}; | 202 | .sqcq_speified_id_free = trs_chan_ops_sqcq_speified_id_free}; |
| 204 | 203 | ||
| 205 | -struct trs_chan_adapt_ops *trs_chan_get_stars_v1_adapt_ops(void) { return &g_trs_chan_stars_v1_ops; } | 204 | +struct trs_chan_adapt_ops *trs_chan_get_stars_v1_adapt_ops(void) |
| 205 | +{ | ||
| 206 | + return &g_trs_chan_stars_v1_ops; | ||
| 207 | +} | ||
| 206 | 208 | ||
| 207 | -int trs_chan_stars_v1_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v1_ops_stars_init(inst); } | 209 | +int trs_chan_stars_v1_ops_init(struct trs_id_inst *inst) |
| 210 | +{ | ||
| 211 | + return trs_chan_stars_v1_ops_stars_init(inst); | ||
| 212 | +} | ||
| 208 | 213 | ||
| 209 | -void trs_chan_stars_v1_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v1_ops_stars_uninit(inst); } | 214 | +void trs_chan_stars_v1_ops_uninit(struct trs_id_inst *inst) |
| 215 | +{ | ||
| 216 | + trs_chan_stars_v1_ops_stars_uninit(inst); | ||
| 217 | +} | ||
Msrc/sdk_driver/trsdrv/trs/lba/near/comm/adapt/trs_host_chan/stars_v1/trs_chan_stars_v1_ops_stars.c+10-13
| @@ -54,9 +54,8 @@ static int trs_chan_ops_stars_ops_get_valid_cq_list(struct trs_stars_cqint *cqin | |||
| 54 | continue; | 54 | continue; |
| 55 | } | 55 | } |
| 56 | cqid[cq_num] = cqint->group * per_grp_cq_num + mid_bit * TRS_STARS_CQINT_L2_STATUS_WIDTH + l2_bit; | 56 | cqid[cq_num] = cqint->group * per_grp_cq_num + mid_bit * TRS_STARS_CQINT_L2_STATUS_WIDTH + l2_bit; |
| 57 | - trs_debug( | 57 | + trs_debug("Clear irq group %u mid_status %u l2_status %u cqid %u\n", cqint->group, mid_status, l2_status, |
| 58 | - "Clear irq group %u mid_status %u l2_status %u cqid %u\n", cqint->group, mid_status, l2_status, | 58 | + cqid[cq_num]); |
| 59 | - cqid[cq_num]); | ||
| 60 | cq_num++; | 59 | cq_num++; |
| 61 | } | 60 | } |
| 62 | } | 61 | } |
| @@ -109,9 +108,8 @@ int trs_chan_get_cq_group(struct trs_id_inst *inst, u32 group_index, u32 *group) | |||
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | if (group_index >= cq_group->group_num) { | 110 | if (group_index >= cq_group->group_num) { |
| 112 | - trs_err( | 111 | + trs_err("Para error. (devid=%u; tsid=%u; group_index=%u; group_num=%u)\n", inst->devid, inst->tsid, group_index, |
| 113 | - "Para error. (devid=%u; tsid=%u; group_index=%u; group_num=%u)\n", inst->devid, inst->tsid, group_index, | 112 | + cq_group->group_num); |
| 114 | - cq_group->group_num); | ||
| 115 | 113 | ||
| 116 | return -EINVAL; | 114 | return -EINVAL; |
| 117 | 115 | ||
| @@ -148,8 +146,8 @@ int trs_chan_get_cq_group_index(struct trs_id_inst *inst, u32 group, u32 *group_ | |||
| 148 | return -EINVAL; | 146 | return -EINVAL; |
| 149 | } | 147 | } |
| 150 | 148 | ||
| 151 | -static int trs_chan_ops_stars_sched_attr_pack( | 149 | +static int trs_chan_ops_stars_sched_attr_pack(struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, |
| 152 | - struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, size_t size) | 150 | + size_t size) |
| 153 | { | 151 | { |
| 154 | size_t stride; | 152 | size_t stride; |
| 155 | int ret; | 153 | int ret; |
| @@ -167,8 +165,8 @@ static int trs_chan_ops_stars_sched_attr_pack( | |||
| 167 | return 0; | 165 | return 0; |
| 168 | } | 166 | } |
| 169 | 167 | ||
| 170 | -static int trs_chan_ops_stars_cqint_attr_pack( | 168 | +static int trs_chan_ops_stars_cqint_attr_pack(struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, |
| 171 | - struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, size_t size) | 169 | + size_t size) |
| 172 | { | 170 | { |
| 173 | struct trs_msg_id_cap hw_id_cap, sw_id_cap; | 171 | struct trs_msg_id_cap hw_id_cap, sw_id_cap; |
| 174 | int ret; | 172 | int ret; |
| @@ -216,9 +214,8 @@ int trs_chan_stars_v1_ops_stars_init(struct trs_id_inst *inst) | |||
| 216 | trs_stars_uninit(inst, TRS_STARS_SCHED); | 214 | trs_stars_uninit(inst, TRS_STARS_SCHED); |
| 217 | return ret; | 215 | return ret; |
| 218 | } | 216 | } |
| 219 | - trs_debug( | 217 | + trs_debug("Cq int. (devid=%u; tsid=%u; cq_grp_num=%u; cq_num=%u)\n", inst->devid, inst->tsid, |
| 220 | - "Cq int. (devid=%u; tsid=%u; cq_grp_num=%u; cq_num=%u)\n", inst->devid, inst->tsid, stars_attr.cq_grp_num, | 218 | + stars_attr.cq_grp_num, stars_attr.cq_num); |
| 221 | - stars_attr.cq_num); | ||
| 222 | 219 | ||
| 223 | ret = trs_stars_init(inst, TRS_STARS_CQINT, &stars_attr); | 220 | ret = trs_stars_init(inst, TRS_STARS_CQINT, &stars_attr); |
| 224 | if (ret != 0) { | 221 | if (ret != 0) { |
Msrc/sdk_driver/trsdrv/trs/lba/near/comm/adapt/trs_host_chan/stars_v2/trs_chan_stars_v2_maint_sqcq.c+6-8
| @@ -49,8 +49,8 @@ static int trs_stars_v2_maint_sq_cpy(struct trs_id_inst *inst, u32 sqid, u32 tai | |||
| 49 | return -EINVAL; | 49 | return -EINVAL; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | - ret = memcpy_s( | 52 | + ret = memcpy_s(sqe, TRS_MAINT_MAX_SQE_SIZE, sq_info.sq_vaddr + sq_info.sq_para.sqe_size * sq_pos, |
| 53 | - sqe, TRS_MAINT_MAX_SQE_SIZE, sq_info.sq_vaddr + sq_info.sq_para.sqe_size * sq_pos, sq_info.sq_para.sqe_size); | 53 | + sq_info.sq_para.sqe_size); |
| 54 | if (ret != 0) { | 54 | if (ret != 0) { |
| 55 | trs_err("Memcpy failed. (ret=%d; sqe_size=%u)\n", ret, sq_info.sq_para.sqe_size); | 55 | trs_err("Memcpy failed. (ret=%d; sqe_size=%u)\n", ret, sq_info.sq_para.sqe_size); |
| 56 | return -EFAULT; | 56 | return -EFAULT; |
| @@ -79,9 +79,8 @@ static int trs_stars_v2_maint_set_sq_tail(struct trs_id_inst *inst, u32 sqid, u3 | |||
| 79 | 79 | ||
| 80 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_sq_task_send_mailbox), TRS_MAINT_MBOX_TIMEOUT_MS); | 80 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_sq_task_send_mailbox), TRS_MAINT_MBOX_TIMEOUT_MS); |
| 81 | if ((ret != 0) || (mbox_data.header.result != 0)) { | 81 | if ((ret != 0) || (mbox_data.header.result != 0)) { |
| 82 | - trs_err( | 82 | + trs_err("Mbox send fail. (devid=%u; tsid=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, |
| 83 | - "Mbox send fail. (devid=%u; tsid=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, | 83 | + mbox_data.header.result, ret); |
| 84 | - mbox_data.header.result, ret); | ||
| 85 | ret = -EFAULT; | 84 | ret = -EFAULT; |
| 86 | } | 85 | } |
| 87 | trs_debug("Maint set sq tail. (devid=%u; sqid=%u; sq_type=%u; sq_tail=%u)\n", inst->devid, sqid, type, tail); | 86 | trs_debug("Maint set sq tail. (devid=%u; sqid=%u; sq_type=%u; sq_tail=%u)\n", inst->devid, sqid, type, tail); |
| @@ -100,9 +99,8 @@ static int trs_stars_v2_maint_cq_update_head(struct trs_id_inst *inst, u32 cqid, | |||
| 100 | 99 | ||
| 101 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_cq_report_recv_mailbox), TRS_MAINT_MBOX_TIMEOUT_MS); | 100 | ret = trs_mbox_send(inst, 0, &mbox_data, sizeof(struct trs_cq_report_recv_mailbox), TRS_MAINT_MBOX_TIMEOUT_MS); |
| 102 | if ((ret != 0) || (mbox_data.header.result != 0)) { | 101 | if ((ret != 0) || (mbox_data.header.result != 0)) { |
| 103 | - trs_err( | 102 | + trs_err("Mbox send fail. (devid=%u; tsid=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, |
| 104 | - "Mbox send fail. (devid=%u; tsid=%u; result=%u; ret=%d)\n", inst->devid, inst->tsid, | 103 | + mbox_data.header.result, ret); |
| 105 | - mbox_data.header.result, ret); | ||
| 106 | ret = -EFAULT; | 104 | ret = -EFAULT; |
| 107 | } | 105 | } |
| 108 | trs_debug("Maint cq update head. (devid=%u; cqid=%u; cq_type=%u; cq_head=%u)\n", inst->devid, cqid, type, head); | 106 | trs_debug("Maint cq update head. (devid=%u; cqid=%u; cq_type=%u; cq_head=%u)\n", inst->devid, cqid, type, head); |
| @@ -44,9 +44,8 @@ | |||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | -int trs_stars_v2_chan_ops_request_irq( | 47 | +int trs_stars_v2_chan_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 48 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 48 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)) |
| 49 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)) | ||
| 50 | { | 49 | { |
| 51 | struct trs_chan_irq_attr attr; | 50 | struct trs_chan_irq_attr attr; |
| 52 | u32 group_index = irq_index; | 51 | u32 group_index = irq_index; |
| @@ -104,8 +103,8 @@ int trs_stars_v2_chan_ops_free_irq(struct trs_id_inst *inst, int irq_type, int i | |||
| 104 | return ret; | 103 | return ret; |
| 105 | } | 104 | } |
| 106 | 105 | ||
| 107 | -static int trs_stars_v2_chan_ops_get_irq( | 106 | +static int trs_stars_v2_chan_ops_get_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, |
| 108 | - struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, u32 *valid_irq_num) | 107 | + u32 *valid_irq_num) |
| 109 | { | 108 | { |
| 110 | int ret; | 109 | int ret; |
| 111 | 110 | ||
| @@ -183,9 +182,8 @@ int trs_chan_stars_v2_ops_query_sqcq(struct trs_id_inst *inst, struct trs_chan_t | |||
| 183 | *value = 0; | 182 | *value = 0; |
| 184 | ret = 0; | 183 | ret = 0; |
| 185 | } | 184 | } |
| 186 | - } else if ( | 185 | + } else if ((cmd == QUERY_CMD_SQ_TAIL_PADDR) && |
| 187 | - (cmd == QUERY_CMD_SQ_TAIL_PADDR) && | 186 | + (trs_get_sq_send_mode(inst->devid) == TRS_MODE_TYPE_SQ_SEND_HIGH_PERFORMANCE)) { |
| 188 | - (trs_get_sq_send_mode(inst->devid) == TRS_MODE_TYPE_SQ_SEND_HIGH_PERFORMANCE)) { | ||
| 189 | *value = 0; | 187 | *value = 0; |
| 190 | ret = 0; | 188 | ret = 0; |
| 191 | } else { | 189 | } else { |
| @@ -281,8 +279,8 @@ static int trs_stars_v2_chan_ops_sqcq_free(struct trs_id_inst *inst, int type, u | |||
| 281 | } | 279 | } |
| 282 | } | 280 | } |
| 283 | 281 | ||
| 284 | -extern int trs_sqe_update_desc_create( | 282 | +extern int trs_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 285 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc, bool is_src_secure); | 283 | + struct trs_dma_desc *dma_desc, bool is_src_secure); |
| 286 | static int trs_chan_stars_v2_ops_sq_dma_desc_create(struct trs_id_inst *inst, struct trs_chan_dma_desc *para) | 284 | static int trs_chan_stars_v2_ops_sq_dma_desc_create(struct trs_id_inst *inst, struct trs_chan_dma_desc *para) |
| 287 | { | 285 | { |
| 288 | 286 | ||
| @@ -291,8 +289,8 @@ static int trs_chan_stars_v2_ops_sq_dma_desc_create(struct trs_id_inst *inst, st | |||
| 291 | int ret; | 289 | int ret; |
| 292 | 290 | ||
| 293 | 291 | ||
| 294 | - ret = hal_kernel_apm_query_slave_ssid_by_master( | 292 | + ret = hal_kernel_apm_query_slave_ssid_by_master(inst->devid, ka_task_get_current_tgid(), PROCESS_CP1, |
| 295 | - inst->devid, ka_task_get_current_tgid(), PROCESS_CP1, &addr_info.passid); | 293 | + &addr_info.passid); |
| 296 | if (ret != 0) { | 294 | if (ret != 0) { |
| 297 | trs_err("Get ssid failed. (devid=%u; ret=%d)\n", inst->devid, ret); | 295 | trs_err("Get ssid failed. (devid=%u; ret=%d)\n", inst->devid, ret); |
| 298 | return ret; | 296 | return ret; |
| @@ -305,9 +303,8 @@ static int trs_chan_stars_v2_ops_sq_dma_desc_create(struct trs_id_inst *inst, st | |||
| 305 | addr_info.src_va = (u64)(uintptr_t)para->src; | 303 | addr_info.src_va = (u64)(uintptr_t)para->src; |
| 306 | ret = trs_sqe_update_desc_create(inst->devid, inst->tsid, &addr_info, &dma_desc, false); | 304 | ret = trs_sqe_update_desc_create(inst->devid, inst->tsid, &addr_info, &dma_desc, false); |
| 307 | if (ret != 0) { | 305 | if (ret != 0) { |
| 308 | - trs_err( | 306 | + trs_err("Create sqe update dma desc failed. (devid=%u; tsid=%u; sqid=%u; sqeid=%u; ret=%d)\n", inst->devid, |
| 309 | - "Create sqe update dma desc failed. (devid=%u; tsid=%u; sqid=%u; sqeid=%u; ret=%d)\n", inst->devid, | 307 | + inst->tsid, para->sq_id, para->sqe_pos, ret); |
| 310 | - inst->tsid, para->sq_id, para->sqe_pos, ret); | ||
| 311 | return ret; | 308 | return ret; |
| 312 | } | 309 | } |
| 313 | 310 | ||
| @@ -356,8 +353,17 @@ static struct trs_chan_adapt_ops g_trs_chan_stars_v2_ops = { | |||
| 356 | .sq_dma_desc_destroy = trs_chan_stars_v2_ops_sq_dma_desc_destroy, | 353 | .sq_dma_desc_destroy = trs_chan_stars_v2_ops_sq_dma_desc_destroy, |
| 357 | }; | 354 | }; |
| 358 | 355 | ||
| 359 | -struct trs_chan_adapt_ops *trs_chan_get_stars_v2_adapt_ops(void) { return &g_trs_chan_stars_v2_ops; } | 356 | +struct trs_chan_adapt_ops *trs_chan_get_stars_v2_adapt_ops(void) |
| 357 | +{ | ||
| 358 | + return &g_trs_chan_stars_v2_ops; | ||
| 359 | +} | ||
| 360 | 360 | ||
| 361 | -int trs_chan_stars_v2_ops_init(struct trs_id_inst *inst) { return trs_chan_stars_v2_ops_stars_init(inst); } | 361 | +int trs_chan_stars_v2_ops_init(struct trs_id_inst *inst) |
| 362 | +{ | ||
| 363 | + return trs_chan_stars_v2_ops_stars_init(inst); | ||
| 364 | +} | ||
| 362 | 365 | ||
| 363 | -void trs_chan_stars_v2_ops_uninit(struct trs_id_inst *inst) { trs_chan_stars_v2_ops_stars_uninit(inst); } | 366 | +void trs_chan_stars_v2_ops_uninit(struct trs_id_inst *inst) |
| 367 | +{ | ||
| 368 | + trs_chan_stars_v2_ops_stars_uninit(inst); | ||
| 369 | +} | ||
| @@ -24,13 +24,12 @@ void trs_chan_stars_v2_ops_uninit(struct trs_id_inst *inst); | |||
| 24 | int trs_chan_ops_agent_init(struct trs_id_inst *inst); | 24 | int trs_chan_ops_agent_init(struct trs_id_inst *inst); |
| 25 | void trs_chan_ops_agent_uninit(struct trs_id_inst *inst); | 25 | void trs_chan_ops_agent_uninit(struct trs_id_inst *inst); |
| 26 | 26 | ||
| 27 | -int trs_stars_v2_chan_ops_request_irq( | 27 | +int trs_stars_v2_chan_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 28 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 28 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); |
| 29 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); | ||
| 30 | int trs_stars_v2_chan_ops_free_irq(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); | 29 | int trs_stars_v2_chan_ops_free_irq(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); |
| 31 | int trs_chan_stars_v2_ops_ctrl_sqcq(struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, u32 para); | 30 | int trs_chan_stars_v2_ops_ctrl_sqcq(struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, u32 para); |
| 32 | -int trs_chan_stars_v2_ops_query_sqcq( | 31 | +int trs_chan_stars_v2_ops_query_sqcq(struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, |
| 33 | - struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, u64 *value); | 32 | + u64 *value); |
| 34 | void trs_chan_stars_v2_update_ssid(struct trs_id_inst *inst, struct trs_chan_info *chan_info); | 33 | void trs_chan_stars_v2_update_ssid(struct trs_id_inst *inst, struct trs_chan_info *chan_info); |
| 35 | struct trs_chan_adapt_ops *trs_chan_get_stars_v2_adapt_ops(void); | 34 | struct trs_chan_adapt_ops *trs_chan_get_stars_v2_adapt_ops(void); |
| 36 | int trs_chan_stars_v2_ops_init(struct trs_id_inst *inst); | 35 | int trs_chan_stars_v2_ops_init(struct trs_id_inst *inst); |
Msrc/sdk_driver/trsdrv/trs/lba/near/comm/adapt/trs_host_chan/stars_v2/trs_chan_stars_v2_ops_stars.c+10-13
| @@ -55,9 +55,8 @@ static int trs_chan_ops_stars_ops_get_valid_cq_list(struct trs_stars_cqint *cqin | |||
| 55 | continue; | 55 | continue; |
| 56 | } | 56 | } |
| 57 | cqid[cq_num] = cqint->group * per_grp_cq_num + mid_bit * TRS_STARS_V2_CQINT_L2_STATUS_WIDTH + l2_bit; | 57 | cqid[cq_num] = cqint->group * per_grp_cq_num + mid_bit * TRS_STARS_V2_CQINT_L2_STATUS_WIDTH + l2_bit; |
| 58 | - trs_debug( | 58 | + trs_debug("Clear irq group %u mid_status %u l2_status %u cqid %u\n", cqint->group, mid_status, l2_status, |
| 59 | - "Clear irq group %u mid_status %u l2_status %u cqid %u\n", cqint->group, mid_status, l2_status, | 59 | + cqid[cq_num]); |
| 60 | - cqid[cq_num]); | ||
| 61 | cq_num++; | 60 | cq_num++; |
| 62 | } | 61 | } |
| 63 | } | 62 | } |
| @@ -115,9 +114,8 @@ int trs_chan_stars_v2_get_cq_group(struct trs_id_inst *inst, u32 group_index, u3 | |||
| 115 | } | 114 | } |
| 116 | 115 | ||
| 117 | if (group_index >= cq_group->group_num) { | 116 | if (group_index >= cq_group->group_num) { |
| 118 | - trs_err( | 117 | + trs_err("Para error. (devid=%u; tsid=%u; group_index=%u; group_num=%u)\n", inst->devid, inst->tsid, group_index, |
| 119 | - "Para error. (devid=%u; tsid=%u; group_index=%u; group_num=%u)\n", inst->devid, inst->tsid, group_index, | 118 | + cq_group->group_num); |
| 120 | - cq_group->group_num); | ||
| 121 | 119 | ||
| 122 | return -EINVAL; | 120 | return -EINVAL; |
| 123 | 121 | ||
| @@ -154,8 +152,8 @@ int trs_chan_stars_v2_get_cq_group_index(struct trs_id_inst *inst, u32 group, u3 | |||
| 154 | return -EINVAL; | 152 | return -EINVAL; |
| 155 | } | 153 | } |
| 156 | 154 | ||
| 157 | -static int trs_stars_v2_chan_ops_stars_sched_attr_pack( | 155 | +static int trs_stars_v2_chan_ops_stars_sched_attr_pack(struct trs_id_inst *inst, struct trs_stars_attr *attr, |
| 158 | - struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, size_t size) | 156 | + phys_addr_t paddr, size_t size) |
| 159 | { | 157 | { |
| 160 | size_t stride; | 158 | size_t stride; |
| 161 | int ret; | 159 | int ret; |
| @@ -173,8 +171,8 @@ static int trs_stars_v2_chan_ops_stars_sched_attr_pack( | |||
| 173 | return 0; | 171 | return 0; |
| 174 | } | 172 | } |
| 175 | 173 | ||
| 176 | -static int trs_chan_ops_stars_v2_cqint_attr_pack( | 174 | +static int trs_chan_ops_stars_v2_cqint_attr_pack(struct trs_id_inst *inst, struct trs_stars_attr *attr, |
| 177 | - struct trs_id_inst *inst, struct trs_stars_attr *attr, phys_addr_t paddr, size_t size) | 175 | + phys_addr_t paddr, size_t size) |
| 178 | { | 176 | { |
| 179 | struct trs_msg_id_cap hw_id_cap, sw_id_cap; | 177 | struct trs_msg_id_cap hw_id_cap, sw_id_cap; |
| 180 | int ret; | 178 | int ret; |
| @@ -224,9 +222,8 @@ int trs_chan_stars_v2_ops_stars_init(struct trs_id_inst *inst) | |||
| 224 | return ret; | 222 | return ret; |
| 225 | 223 | ||
| 226 | } | 224 | } |
| 227 | - trs_debug( | 225 | + trs_debug("Cq int. (devid=%u; tsid=%u; cq_grp_num=%u; cq_num=%u)\n", inst->devid, inst->tsid, |
| 228 | - "Cq int. (devid=%u; tsid=%u; cq_grp_num=%u; cq_num=%u)\n", inst->devid, inst->tsid, stars_attr.cq_grp_num, | 226 | + stars_attr.cq_grp_num, stars_attr.cq_num); |
| 229 | - stars_attr.cq_num); | ||
| 230 | 227 | ||
| 231 | ret = trs_stars_init(inst, TRS_STARS_CQINT, &stars_attr); | 228 | ret = trs_stars_init(inst, TRS_STARS_CQINT, &stars_attr); |
| 232 | if (ret != 0) { | 229 | if (ret != 0) { |
| @@ -83,8 +83,8 @@ int trs_stars_v2_chan_ops_sqcq_speicified_id_free(struct trs_id_inst *inst, int | |||
| 83 | return 0; | 83 | return 0; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | -int _trs_sqcq_event_update( | 86 | +int _trs_sqcq_event_update(u32 devid, struct sched_published_event_info *event_info, |
| 87 | - u32 devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 87 | + struct sched_published_event_func *event_func) |
| 88 | { | 88 | { |
| 89 | struct halSqCqOutputInfo *info = NULL; | 89 | struct halSqCqOutputInfo *info = NULL; |
| 90 | struct trs_id_inst inst; | 90 | struct trs_id_inst inst; |
| @@ -118,8 +118,8 @@ int _trs_sqcq_event_update( | |||
| 118 | return 0; | 118 | return 0; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | -int trs_sqcq_event_update( | 121 | +int trs_sqcq_event_update(u32 devid, struct sched_published_event_info *event_info, |
| 122 | - u32 devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 122 | + struct sched_published_event_func *event_func) |
| 123 | { | 123 | { |
| 124 | int ret = _trs_sqcq_event_update(devid, event_info, event_func); | 124 | int ret = _trs_sqcq_event_update(devid, event_info, event_func); |
| 125 | return trs_event_kerror_to_uerror(ret); | 125 | return trs_event_kerror_to_uerror(ret); |
| @@ -199,8 +199,8 @@ int trs_sqcq_event_init(void) | |||
| 199 | return -ENOMEM; | 199 | return -ENOMEM; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | - return hal_kernel_sched_register_event_pre_proc_handle( | 202 | + return hal_kernel_sched_register_event_pre_proc_handle(EVENT_DRV_MSG, SCHED_PRE_PROC_POS_REMOTE, |
| 203 | - EVENT_DRV_MSG, SCHED_PRE_PROC_POS_REMOTE, trs_sqcq_event_update); | 203 | + trs_sqcq_event_update); |
| 204 | } | 204 | } |
| 205 | DECLAER_FEATURE_AUTO_INIT(trs_sqcq_event_init, FEATURE_LOADER_STAGE_2); | 205 | DECLAER_FEATURE_AUTO_INIT(trs_sqcq_event_init, FEATURE_LOADER_STAGE_2); |
| 206 | 206 | ||
| @@ -220,7 +220,13 @@ void trs_sqcq_event_uninit(void) | |||
| 220 | } | 220 | } |
| 221 | DECLAER_FEATURE_AUTO_UNINIT(trs_sqcq_event_uninit, FEATURE_LOADER_STAGE_2); | 221 | DECLAER_FEATURE_AUTO_UNINIT(trs_sqcq_event_uninit, FEATURE_LOADER_STAGE_2); |
| 222 | 222 | ||
| 223 | -int trs_stars_v2_chan_ops_sqcq_speicified_id_alloc(struct trs_id_inst *inst, int type, u32 *id) { return 0; } | 223 | +int trs_stars_v2_chan_ops_sqcq_speicified_id_alloc(struct trs_id_inst *inst, int type, u32 *id) |
| 224 | +{ | ||
| 225 | + return 0; | ||
| 226 | +} | ||
| 224 | 227 | ||
| 225 | -int trs_stars_v2_chan_ops_sqcq_speicified_id_free(struct trs_id_inst *inst, int type, u32 id) { return 0; } | 228 | +int trs_stars_v2_chan_ops_sqcq_speicified_id_free(struct trs_id_inst *inst, int type, u32 id) |
| 229 | +{ | ||
| 230 | + return 0; | ||
| 231 | +} | ||
| 226 | 232 | ||
| @@ -18,10 +18,10 @@ | |||
| 18 | int trs_stars_v2_chan_ops_sqcq_speicified_id_alloc(struct trs_id_inst *inst, int type, u32 *id); | 18 | int trs_stars_v2_chan_ops_sqcq_speicified_id_alloc(struct trs_id_inst *inst, int type, u32 *id); |
| 19 | int trs_stars_v2_chan_ops_sqcq_speicified_id_free(struct trs_id_inst *inst, int type, u32 id); | 19 | int trs_stars_v2_chan_ops_sqcq_speicified_id_free(struct trs_id_inst *inst, int type, u32 id); |
| 20 | 20 | ||
| 21 | -int _trs_sqcq_event_update( | 21 | +int _trs_sqcq_event_update(u32 devid, struct sched_published_event_info *event_info, |
| 22 | - u32 devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func); | 22 | + struct sched_published_event_func *event_func); |
| 23 | -int trs_sqcq_event_update( | 23 | +int trs_sqcq_event_update(u32 devid, struct sched_published_event_info *event_info, |
| 24 | - u32 devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func); | 24 | + struct sched_published_event_func *event_func); |
| 25 | 25 | ||
| 26 | int trs_sqcq_event_dev_init(u32 ts_inst_id); | 26 | int trs_sqcq_event_dev_init(u32 ts_inst_id); |
| 27 | void trs_sqcq_event_dev_uninit(u32 ts_inst_id); | 27 | void trs_sqcq_event_dev_uninit(u32 ts_inst_id); |
| @@ -30,9 +30,8 @@ int trs_chan_maint_db_init(struct trs_id_inst *inst) | |||
| 30 | if (ret == -EOPNOTSUPP) { | 30 | if (ret == -EOPNOTSUPP) { |
| 31 | return 0; | 31 | return 0; |
| 32 | } | 32 | } |
| 33 | - trs_err( | 33 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 34 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 34 | + start, end); |
| 35 | - end); | ||
| 36 | return -ENODEV; | 35 | return -ENODEV; |
| 37 | } | 36 | } |
| 38 | ret = trs_ts_db_init(inst, TRS_DB_MAINT_SQ, start, end); | 37 | ret = trs_ts_db_init(inst, TRS_DB_MAINT_SQ, start, end); |
| @@ -48,9 +47,8 @@ int trs_chan_maint_db_init(struct trs_id_inst *inst) | |||
| 48 | return 0; | 47 | return 0; |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | - trs_err( | 50 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 52 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 51 | + start, end); |
| 53 | - end); | ||
| 54 | return -ENODEV; | 52 | return -ENODEV; |
| 55 | } | 53 | } |
| 56 | ret = trs_ts_db_init(inst, TRS_DB_MAINT_CQ, start, end); | 54 | ret = trs_ts_db_init(inst, TRS_DB_MAINT_CQ, start, end); |
| @@ -29,8 +29,8 @@ static int trs_chan_update_dev_mem_addr(struct trs_id_inst *inst, struct trs_cha | |||
| 29 | 29 | ||
| 30 | /* when set TSDRV_FLAG_ONLY_SQCQ_ID flag, no sq mem, but sq_mem_side is 0 */ | 30 | /* when set TSDRV_FLAG_ONLY_SQCQ_ID flag, no sq mem, but sq_mem_side is 0 */ |
| 31 | if ((chan_info->sq_info.sq_vaddr != NULL) && (trs_chan_mem_is_dev_mem(sq_mem_side))) { | 31 | if ((chan_info->sq_info.sq_vaddr != NULL) && (trs_chan_mem_is_dev_mem(sq_mem_side))) { |
| 32 | - ret = trs_chan_near_sqcq_mem_h2d( | 32 | + ret = trs_chan_near_sqcq_mem_h2d(inst, chan_info->sq_info.sq_phy_addr, &chan_info->sq_info.sq_phy_addr, |
| 33 | - inst, chan_info->sq_info.sq_phy_addr, &chan_info->sq_info.sq_phy_addr, sq_mem_side); | 33 | + sq_mem_side); |
| 34 | if (ret != 0) { | 34 | if (ret != 0) { |
| 35 | trs_err("Rsv mem h2d failed. (devid=%u; tsid=%u; ret=%d)\n", inst->devid, inst->tsid, ret); | 35 | trs_err("Rsv mem h2d failed. (devid=%u; tsid=%u; ret=%d)\n", inst->devid, inst->tsid, ret); |
| 36 | return ret; | 36 | return ret; |
| @@ -38,8 +38,8 @@ static int trs_chan_update_dev_mem_addr(struct trs_id_inst *inst, struct trs_cha | |||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | if (trs_chan_mem_is_dev_mem(cq_mem_side)) { | 40 | if (trs_chan_mem_is_dev_mem(cq_mem_side)) { |
| 41 | - ret = trs_chan_near_sqcq_mem_h2d( | 41 | + ret = trs_chan_near_sqcq_mem_h2d(inst, chan_info->cq_info.cq_phy_addr, &chan_info->cq_info.cq_phy_addr, |
| 42 | - inst, chan_info->cq_info.cq_phy_addr, &chan_info->cq_info.cq_phy_addr, cq_mem_side); | 42 | + cq_mem_side); |
| 43 | if (ret != 0) { | 43 | if (ret != 0) { |
| 44 | trs_err("Rsv mem h2d failed. (devid=%u; tsid=%u; ret=%d)\n", inst->devid, inst->tsid, ret); | 44 | trs_err("Rsv mem h2d failed. (devid=%u; tsid=%u; ret=%d)\n", inst->devid, inst->tsid, ret); |
| 45 | return ret; | 45 | return ret; |
| @@ -30,7 +30,10 @@ | |||
| 30 | /* stub for david ub scene start */ | 30 | /* stub for david ub scene start */ |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | -ka_device_t *hal_kernel_devdrv_get_pci_dev_by_devid(u32 udevid) { return NULL; } | 33 | +ka_device_t *hal_kernel_devdrv_get_pci_dev_by_devid(u32 udevid) |
| 34 | +{ | ||
| 35 | + return NULL; | ||
| 36 | +} | ||
| 34 | 37 | ||
| 35 | ka_dma_addr_t hal_kernel_devdrv_dma_map_single(ka_device_t *dev, void *ptr, size_t size, ka_dma_data_direction_t dir) | 38 | ka_dma_addr_t hal_kernel_devdrv_dma_map_single(ka_device_t *dev, void *ptr, size_t size, ka_dma_data_direction_t dir) |
| 36 | { | 39 | { |
| @@ -43,14 +46,14 @@ void hal_kernel_devdrv_dma_unmap_single(ka_device_t *dev, ka_dma_addr_t addr, si | |||
| 43 | 46 | ||
| 44 | /* stub for david ub scene end */ | 47 | /* stub for david ub scene end */ |
| 45 | 48 | ||
| 46 | -static void *trs_chan_mem_alloc_dma( | 49 | +static void *trs_chan_mem_alloc_dma(struct trs_id_inst *inst, ka_device_t *dev, size_t size, ka_dma_addr_t *dma_addr, |
| 47 | - struct trs_id_inst *inst, ka_device_t *dev, size_t size, ka_dma_addr_t *dma_addr, ka_dma_data_direction_t dir) | 50 | + ka_dma_data_direction_t dir) |
| 48 | { | 51 | { |
| 49 | void *vaddr = NULL; | 52 | void *vaddr = NULL; |
| 50 | 53 | ||
| 51 | if (dev != NULL) { | 54 | if (dev != NULL) { |
| 52 | - vaddr = | 55 | + vaddr = ka_alloc_pages_exact_ex(size, |
| 53 | - ka_alloc_pages_exact_ex(size, KA_GFP_KERNEL | __KA_GFP_ZERO | __KA_GFP_ACCOUNT | __KA_GFP_RETRY_MAYFAIL); | 56 | + KA_GFP_KERNEL | __KA_GFP_ZERO | __KA_GFP_ACCOUNT | __KA_GFP_RETRY_MAYFAIL); |
| 54 | if (vaddr == NULL) { | 57 | if (vaddr == NULL) { |
| 55 | return NULL; | 58 | return NULL; |
| 56 | } | 59 | } |
| @@ -67,12 +70,12 @@ static void *trs_chan_mem_alloc_dma( | |||
| 67 | 70 | ||
| 68 | static void *trs_chan_mem_alloc_ddr_dma(struct trs_id_inst *inst, size_t size, phys_addr_t *paddr) | 71 | static void *trs_chan_mem_alloc_ddr_dma(struct trs_id_inst *inst, size_t size, phys_addr_t *paddr) |
| 69 | { | 72 | { |
| 70 | - return trs_chan_mem_alloc_dma( | 73 | + return trs_chan_mem_alloc_dma(inst, hal_kernel_devdrv_get_pci_dev_by_devid(inst->devid), size, |
| 71 | - inst, hal_kernel_devdrv_get_pci_dev_by_devid(inst->devid), size, (ka_dma_addr_t *)paddr, KA_DMA_BIDIRECTIONAL); | 74 | + (ka_dma_addr_t *)paddr, KA_DMA_BIDIRECTIONAL); |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | -static void trs_chan_mem_free_dma( | 77 | +static void trs_chan_mem_free_dma(struct trs_id_inst *inst, ka_device_t *dev, void *vaddr, ka_dma_addr_t dma_addr, |
| 75 | - struct trs_id_inst *inst, ka_device_t *dev, void *vaddr, ka_dma_addr_t dma_addr, size_t size) | 78 | + size_t size) |
| 76 | { | 79 | { |
| 77 | if (dev != NULL) { | 80 | if (dev != NULL) { |
| 78 | hal_kernel_devdrv_dma_unmap_single(dev, dma_addr, size, KA_DMA_BIDIRECTIONAL); | 81 | hal_kernel_devdrv_dma_unmap_single(dev, dma_addr, size, KA_DMA_BIDIRECTIONAL); |
| @@ -118,14 +121,13 @@ static void *trs_chan_mem_get_ddr_dma(struct trs_id_inst *inst, size_t size, phy | |||
| 118 | static void trs_chan_mem_put_ddr_dma(struct trs_id_inst *inst, void *vaddr, size_t size, phys_addr_t phy_addr) | 121 | static void trs_chan_mem_put_ddr_dma(struct trs_id_inst *inst, void *vaddr, size_t size, phys_addr_t phy_addr) |
| 119 | { | 122 | { |
| 120 | int ret; | 123 | int ret; |
| 121 | - struct trs_chan_mem_node_attr attr = { | 124 | + struct trs_chan_mem_node_attr attr = {.inst = *inst, |
| 122 | - .inst = *inst, | 125 | + .vaddr = vaddr, |
| 123 | - .vaddr = vaddr, | 126 | + .phy_addr = phy_addr, |
| 124 | - .phy_addr = phy_addr, | 127 | + .size = size, |
| 125 | - .size = size, | 128 | + .is_dma_addr = true, |
| 126 | - .is_dma_addr = true, | 129 | + .ops.alloc_ddr = trs_chan_mem_alloc_ddr_dma, |
| 127 | - .ops.alloc_ddr = trs_chan_mem_alloc_ddr_dma, | 130 | + .ops.free_ddr = trs_chan_mem_free_ddr_dma}; |
| 128 | - .ops.free_ddr = trs_chan_mem_free_ddr_dma}; | ||
| 129 | 131 | ||
| 130 | ret = trs_chan_mem_put_to_mem_list(&attr); | 132 | ret = trs_chan_mem_put_to_mem_list(&attr); |
| 131 | if (ret != 0) { | 133 | if (ret != 0) { |
| @@ -147,14 +149,13 @@ static void *trs_chan_mem_get_ddr_phy(struct trs_id_inst *inst, size_t size, phy | |||
| 147 | static void trs_chan_mem_put_ddr_phy(struct trs_id_inst *inst, void *vaddr, size_t size, phys_addr_t phy_addr) | 149 | static void trs_chan_mem_put_ddr_phy(struct trs_id_inst *inst, void *vaddr, size_t size, phys_addr_t phy_addr) |
| 148 | { | 150 | { |
| 149 | int ret; | 151 | int ret; |
| 150 | - struct trs_chan_mem_node_attr attr = { | 152 | + struct trs_chan_mem_node_attr attr = {.inst = *inst, |
| 151 | - .inst = *inst, | 153 | + .vaddr = vaddr, |
| 152 | - .vaddr = vaddr, | 154 | + .phy_addr = phy_addr, |
| 153 | - .phy_addr = phy_addr, | 155 | + .size = size, |
| 154 | - .size = size, | 156 | + .is_dma_addr = false, |
| 155 | - .is_dma_addr = false, | 157 | + .ops.alloc_ddr = trs_chan_mem_alloc_ddr_phy, |
| 156 | - .ops.alloc_ddr = trs_chan_mem_alloc_ddr_phy, | 158 | + .ops.free_ddr = trs_chan_mem_free_ddr_phy}; |
| 157 | - .ops.free_ddr = trs_chan_mem_free_ddr_phy}; | ||
| 158 | 159 | ||
| 159 | ret = trs_chan_mem_put_to_mem_list(&attr); | 160 | ret = trs_chan_mem_put_to_mem_list(&attr); |
| 160 | if (ret != 0) { | 161 | if (ret != 0) { |
| @@ -162,8 +163,8 @@ static void trs_chan_mem_put_ddr_phy(struct trs_id_inst *inst, void *vaddr, size | |||
| 162 | } | 163 | } |
| 163 | } | 164 | } |
| 164 | 165 | ||
| 165 | -static void *trs_chan_mem_alloc_pm_inst_rsv( | 166 | +static void *trs_chan_mem_alloc_pm_inst_rsv(struct trs_id_inst *inst, int type, size_t size, phys_addr_t *paddr, |
| 166 | - struct trs_id_inst *inst, int type, size_t size, phys_addr_t *paddr, u32 flag) | 167 | + u32 flag) |
| 167 | { | 168 | { |
| 168 | struct uda_mia_dev_para dev_para; | 169 | struct uda_mia_dev_para dev_para; |
| 169 | struct trs_id_inst pm_inst; | 170 | struct trs_id_inst pm_inst; |
| @@ -247,8 +248,8 @@ static int trs_chan_devmem_addr_d2h(u32 devid, u64 host_addr, u64 *dev_addr) | |||
| 247 | } | 248 | } |
| 248 | 249 | ||
| 249 | 250 | ||
| 250 | -static void *trs_chan_mem_get_svm_mem( | 251 | +static void *trs_chan_mem_get_svm_mem(struct trs_id_inst *inst, size_t size, void *specified_uva, |
| 251 | - struct trs_id_inst *inst, size_t size, void *specified_uva, struct trs_chan_mem_attr *mem_attr) | 252 | + struct trs_chan_mem_attr *mem_attr) |
| 252 | { | 253 | { |
| 253 | 254 | ||
| 254 | svm_pa_seg_wraper_t pa_seg; | 255 | svm_pa_seg_wraper_t pa_seg; |
| @@ -331,21 +332,18 @@ static int trs_chan_check_sqcq_mem_size(struct trs_id_inst *inst, u32 mem_side, | |||
| 331 | } | 332 | } |
| 332 | /* In HCCS connection, virtual machine and using host mem, sqcq size should be less or equal 4K */ | 333 | /* In HCCS connection, virtual machine and using host mem, sqcq size should be less or equal 4K */ |
| 333 | if ((host_flag == 0) && is_host_mem(mem_side) && is_size_out_of_range(size)) { | 334 | if ((host_flag == 0) && is_host_mem(mem_side) && is_size_out_of_range(size)) { |
| 334 | - trs_err( | 335 | + trs_err("Check sqcq mem size failed. (devid=%u; host_flag=0x%x; mem_side=%u; size=0x%lx)\n", inst->devid, |
| 335 | - "Check sqcq mem size failed. (devid=%u; host_flag=0x%x; mem_side=%u; size=0x%lx)\n", inst->devid, | 336 | + host_flag, mem_side, size); |
| 336 | - host_flag, mem_side, size); | ||
| 337 | return -EINVAL; | 337 | return -EINVAL; |
| 338 | } | 338 | } |
| 339 | - trs_debug( | 339 | + trs_debug("Check sqcq mem size. (devid=%u; host_flag=0x%x; mem_side=%u; size=0x%lx)\n", inst->devid, host_flag, |
| 340 | - "Check sqcq mem size. (devid=%u; host_flag=0x%x; mem_side=%u; size=0x%lx)\n", inst->devid, host_flag, | 340 | + mem_side, size); |
| 341 | - mem_side, size); | ||
| 342 | } | 341 | } |
| 343 | return 0; | 342 | return 0; |
| 344 | } | 343 | } |
| 345 | 344 | ||
| 346 | -void *trs_chan_ops_sq_mem_alloc( | 345 | +void *trs_chan_ops_sq_mem_alloc(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, |
| 347 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, | 346 | + struct trs_chan_mem_attr *mem_attr) |
| 348 | - struct trs_chan_mem_attr *mem_attr) | ||
| 349 | { | 347 | { |
| 350 | size_t size = sq_para->sqe_size * sq_para->sq_depth; | 348 | size_t size = sq_para->sqe_size * sq_para->sq_depth; |
| 351 | void *vaddr = NULL; | 349 | void *vaddr = NULL; |
| @@ -385,8 +383,8 @@ void *trs_chan_ops_sq_mem_alloc( | |||
| 385 | return vaddr; | 383 | return vaddr; |
| 386 | } | 384 | } |
| 387 | 385 | ||
| 388 | -void trs_chan_ops_sq_mem_free( | 386 | +void trs_chan_ops_sq_mem_free(struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, |
| 389 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, struct trs_chan_mem_attr *mem_attr) | 387 | + struct trs_chan_mem_attr *mem_attr) |
| 390 | { | 388 | { |
| 391 | u32 mem_side; | 389 | u32 mem_side; |
| 392 | 390 | ||
| @@ -422,9 +420,8 @@ void trs_chan_sq_mem_free(struct trs_id_inst *inst, void *sq_addr, struct trs_ch | |||
| 422 | } | 420 | } |
| 423 | KA_EXPORT_SYMBOL_GPL(trs_chan_sq_mem_free); | 421 | KA_EXPORT_SYMBOL_GPL(trs_chan_sq_mem_free); |
| 424 | 422 | ||
| 425 | -void *trs_chan_ops_cq_mem_alloc( | 423 | +void *trs_chan_ops_cq_mem_alloc(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, |
| 426 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, | 424 | + struct trs_chan_mem_attr *mem_attr) |
| 427 | - struct trs_chan_mem_attr *mem_attr) | ||
| 428 | { | 425 | { |
| 429 | size_t size = cq_para->cqe_size * cq_para->cq_depth; | 426 | size_t size = cq_para->cqe_size * cq_para->cq_depth; |
| 430 | void *vaddr = NULL; | 427 | void *vaddr = NULL; |
| @@ -450,8 +447,8 @@ void *trs_chan_ops_cq_mem_alloc( | |||
| 450 | return vaddr; | 447 | return vaddr; |
| 451 | } | 448 | } |
| 452 | 449 | ||
| 453 | -void trs_chan_ops_cq_mem_free( | 450 | +void trs_chan_ops_cq_mem_free(struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, |
| 454 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, struct trs_chan_mem_attr *mem_attr) | 451 | + struct trs_chan_mem_attr *mem_attr) |
| 455 | { | 452 | { |
| 456 | u32 mem_side; | 453 | u32 mem_side; |
| 457 | 454 | ||
| @@ -547,8 +544,8 @@ int trs_chan_near_sqcq_mem_h2d(struct trs_id_inst *inst, u64 host_addr, u64 *dev | |||
| 547 | } | 544 | } |
| 548 | KA_EXPORT_SYMBOL_GPL(trs_chan_near_sqcq_mem_h2d); | 545 | KA_EXPORT_SYMBOL_GPL(trs_chan_near_sqcq_mem_h2d); |
| 549 | 546 | ||
| 550 | -static int _trs_chan_sq_rsvmem_map( | 547 | +static int _trs_chan_sq_rsvmem_map(struct trs_id_inst *inst, u64 host_paddr, u32 host_pid, |
| 551 | - struct trs_id_inst *inst, u64 host_paddr, u32 host_pid, struct trs_chan_sq_para *sq_param, u64 *dev_vaddr) | 548 | + struct trs_chan_sq_para *sq_param, u64 *dev_vaddr) |
| 552 | { | 549 | { |
| 553 | 550 | ||
| 554 | struct trs_msg_map_sq_mem *msg_map_sq_mem = NULL; | 551 | struct trs_msg_map_sq_mem *msg_map_sq_mem = NULL; |
| @@ -582,14 +579,12 @@ static int _trs_chan_sq_rsvmem_map( | |||
| 582 | msg_map_sq_mem->phy_devid = mia_para.phy_devid; | 579 | msg_map_sq_mem->phy_devid = mia_para.phy_devid; |
| 583 | msg_map_sq_mem->vfid = mia_para.sub_devid; | 580 | msg_map_sq_mem->vfid = mia_para.sub_devid; |
| 584 | } | 581 | } |
| 585 | - trs_debug( | 582 | + trs_debug("devid info. (devid=%u; phy_devid=%u; vfid=%u)\n", inst->devid, msg_map_sq_mem->phy_devid, |
| 586 | - "devid info. (devid=%u; phy_devid=%u; vfid=%u)\n", inst->devid, msg_map_sq_mem->phy_devid, | 583 | + msg_map_sq_mem->vfid); |
| 587 | - msg_map_sq_mem->vfid); | ||
| 588 | ret = trs_host_msg_send(msg_map_sq_mem->phy_devid, &msg, sizeof(struct trs_msg_data)); | 584 | ret = trs_host_msg_send(msg_map_sq_mem->phy_devid, &msg, sizeof(struct trs_msg_data)); |
| 589 | if ((ret != 0) && (ret != -ESRCH)) { | 585 | if ((ret != 0) && (ret != -ESRCH)) { |
| 590 | - trs_err( | 586 | + trs_err("Msg send fail. (devid=%u; phy_devid=%u; vfid=%d, ret=%d; header_result=%d)\n", inst->devid, |
| 591 | - "Msg send fail. (devid=%u; phy_devid=%u; vfid=%d, ret=%d; header_result=%d)\n", inst->devid, | 587 | + msg_map_sq_mem->phy_devid, msg_map_sq_mem->vfid, ret, msg.header.result); |
| 592 | - msg_map_sq_mem->phy_devid, msg_map_sq_mem->vfid, ret, msg.header.result); | ||
| 593 | return ret; | 588 | return ret; |
| 594 | } | 589 | } |
| 595 | 590 | ||
| @@ -632,8 +627,8 @@ int trs_chan_sq_rsvmem_map(struct trs_id_inst *inst, struct trs_sq_mem_map_para | |||
| 632 | } | 627 | } |
| 633 | KA_EXPORT_SYMBOL_GPL(trs_chan_sq_rsvmem_map); | 628 | KA_EXPORT_SYMBOL_GPL(trs_chan_sq_rsvmem_map); |
| 634 | 629 | ||
| 635 | -static int _trs_chan_sq_rsvmem_unmap( | 630 | +static int _trs_chan_sq_rsvmem_unmap(struct trs_id_inst *inst, struct trs_chan_sq_para *sq_para, u32 pid, |
| 636 | - struct trs_id_inst *inst, struct trs_chan_sq_para *sq_para, u32 pid, void *dev_vaddr) | 631 | + void *dev_vaddr) |
| 637 | { | 632 | { |
| 638 | 633 | ||
| 639 | struct trs_msg_map_sq_mem *msg_map_sq_mem = NULL; | 634 | struct trs_msg_map_sq_mem *msg_map_sq_mem = NULL; |
| @@ -662,9 +657,8 @@ static int _trs_chan_sq_rsvmem_unmap( | |||
| 662 | } | 657 | } |
| 663 | ret = trs_host_msg_send(msg_map_sq_mem->phy_devid, &msg, sizeof(struct trs_msg_data)); | 658 | ret = trs_host_msg_send(msg_map_sq_mem->phy_devid, &msg, sizeof(struct trs_msg_data)); |
| 664 | if (ret != 0) { | 659 | if (ret != 0) { |
| 665 | - trs_err( | 660 | + trs_err("Msg send fail. (devid=%u; phy_devid=%d; ret=%d; header_result=%d)\n", inst->devid, |
| 666 | - "Msg send fail. (devid=%u; phy_devid=%d; ret=%d; header_result=%d)\n", inst->devid, | 661 | + msg_map_sq_mem->phy_devid, ret, msg.header.result); |
| 667 | - msg_map_sq_mem->phy_devid, ret, msg.header.result); | ||
| 668 | return ret; | 662 | return ret; |
| 669 | } | 663 | } |
| 670 | return 0; | 664 | return 0; |
| @@ -25,5 +25,8 @@ int trs_chan_near_sqcq_mem_h2d(struct trs_id_inst *inst, u64 host_addr, u64 *dev | |||
| 25 | int trs_chan_sq_rsvmem_map(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void **sq_dev_vaddr); | 25 | int trs_chan_sq_rsvmem_map(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void **sq_dev_vaddr); |
| 26 | void trs_chan_sq_rsvmem_unmap(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void *sq_dev_vaddr); | 26 | void trs_chan_sq_rsvmem_unmap(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void *sq_dev_vaddr); |
| 27 | 27 | ||
| 28 | -static inline u32 trs_chan_get_sqcq_mem_side(u32 mem_type) { return mem_type & TRS_CHAN_MEM_TYPE_SIDE_MASK; } | 28 | +static inline u32 trs_chan_get_sqcq_mem_side(u32 mem_type) |
| 29 | +{ | ||
| 30 | + return mem_type & TRS_CHAN_MEM_TYPE_SIDE_MASK; | ||
| 31 | +} | ||
| 29 | 32 | ||
| @@ -26,7 +26,10 @@ | |||
| 26 | /* stub for david ub scene start */ | 26 | /* stub for david ub scene start */ |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | -int devdrv_devmem_addr_d2h(u32 devid, phys_addr_t device_phy_addr, phys_addr_t *host_bar_addr) { return -1; } | 29 | +int devdrv_devmem_addr_d2h(u32 devid, phys_addr_t device_phy_addr, phys_addr_t *host_bar_addr) |
| 30 | +{ | ||
| 31 | + return -1; | ||
| 32 | +} | ||
| 30 | 33 | ||
| 31 | 34 | ||
| 32 | /* stub for david ub scene end */ | 35 | /* stub for david ub scene end */ |
| @@ -97,7 +100,10 @@ static int _trs_chan_ops_rsv_mem_init(struct trs_id_inst *inst, int type) | |||
| 97 | return ret; | 100 | return ret; |
| 98 | } | 101 | } |
| 99 | 102 | ||
| 100 | -static void _trs_chan_ops_rsv_mem_uninit(struct trs_id_inst *inst, int type) { trs_rsv_mem_uninit(inst, type); } | 103 | +static void _trs_chan_ops_rsv_mem_uninit(struct trs_id_inst *inst, int type) |
| 104 | +{ | ||
| 105 | + trs_rsv_mem_uninit(inst, type); | ||
| 106 | +} | ||
| 101 | 107 | ||
| 102 | int trs_chan_near_sqcq_rsv_mem_h2d(struct trs_id_inst *inst, u64 host_addr, u64 *dev_addr) | 108 | int trs_chan_near_sqcq_rsv_mem_h2d(struct trs_id_inst *inst, u64 host_addr, u64 *dev_addr) |
| 103 | { | 109 | { |
| @@ -174,8 +180,8 @@ static int trs_chan_ops_dev_sqcq_rsv_mem_addr_init(struct trs_id_inst *inst) | |||
| 174 | 180 | ||
| 175 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 181 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 176 | if (ret != 0) { | 182 | if (ret != 0) { |
| 177 | - trs_err( | 183 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 178 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 184 | + msg.header.result); |
| 179 | return -ENODEV; | 185 | return -ENODEV; |
| 180 | } | 186 | } |
| 181 | ret = trs_chan_ops_update_sqcq_rsv_mem(inst, (phys_addr_t)info->addr, (size_t)info->size); | 187 | ret = trs_chan_ops_update_sqcq_rsv_mem(inst, (phys_addr_t)info->addr, (size_t)info->size); |
| @@ -198,4 +204,7 @@ int trs_chan_near_ops_rsv_mem_init(struct trs_id_inst *inst) | |||
| 198 | return ret; | 204 | return ret; |
| 199 | } | 205 | } |
| 200 | 206 | ||
| 201 | -void trs_chan_near_ops_rsv_mem_uninit(struct trs_id_inst *inst) { _trs_chan_ops_rsv_mem_uninit(inst, RSV_MEM_HW_SQCQ); } | 207 | +void trs_chan_near_ops_rsv_mem_uninit(struct trs_id_inst *inst) |
| 208 | +{ | ||
| 209 | + _trs_chan_ops_rsv_mem_uninit(inst, RSV_MEM_HW_SQCQ); | ||
| 210 | +} | ||
| @@ -22,9 +22,9 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | -static int trs_tscpu_chan_ops_request_irq( | 25 | +static int trs_tscpu_chan_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 26 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 26 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], |
| 27 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)) | 27 | + u32 cq_num)) |
| 28 | { | 28 | { |
| 29 | struct trs_chan_irq_attr attr; | 29 | struct trs_chan_irq_attr attr; |
| 30 | 30 | ||
| @@ -124,8 +124,17 @@ static struct trs_chan_adapt_ops g_trs_tscpu_chan_ops = { | |||
| 124 | .free_irq = trs_chan_free_irq, | 124 | .free_irq = trs_chan_free_irq, |
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | -struct trs_chan_adapt_ops *trs_chan_get_tscpu_adapt_ops(void) { return &g_trs_tscpu_chan_ops; } | 127 | +struct trs_chan_adapt_ops *trs_chan_get_tscpu_adapt_ops(void) |
| 128 | +{ | ||
| 129 | + return &g_trs_tscpu_chan_ops; | ||
| 130 | +} | ||
| 128 | 131 | ||
| 129 | -int trs_tscpu_chan_ops_init(struct trs_id_inst *inst) { return trs_tscpu_chan_near_ops_db_init(inst); } | 132 | +int trs_tscpu_chan_ops_init(struct trs_id_inst *inst) |
| 133 | +{ | ||
| 134 | + return trs_tscpu_chan_near_ops_db_init(inst); | ||
| 135 | +} | ||
| 130 | 136 | ||
| 131 | -void trs_tscpu_chan_ops_uninit(struct trs_id_inst *inst) { trs_tscpu_chan_near_ops_db_uninit(inst); } | 137 | +void trs_tscpu_chan_ops_uninit(struct trs_id_inst *inst) |
| 138 | +{ | ||
| 139 | + trs_tscpu_chan_near_ops_db_uninit(inst); | ||
| 140 | +} | ||
| @@ -23,9 +23,8 @@ int trs_tscpu_chan_near_ops_db_init(struct trs_id_inst *inst) | |||
| 23 | 23 | ||
| 24 | ret = trs_soc_get_db_cfg(inst, TRS_DB_TASK_SQ, &start, &end); | 24 | ret = trs_soc_get_db_cfg(inst, TRS_DB_TASK_SQ, &start, &end); |
| 25 | if ((ret != 0) || (start >= end)) { | 25 | if ((ret != 0) || (start >= end)) { |
| 26 | - trs_err( | 26 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 27 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 27 | + start, end); |
| 28 | - end); | ||
| 29 | return -ENODEV; | 28 | return -ENODEV; |
| 30 | } | 29 | } |
| 31 | 30 | ||
| @@ -35,9 +34,8 @@ int trs_tscpu_chan_near_ops_db_init(struct trs_id_inst *inst) | |||
| 35 | ret |= trs_soc_get_db_cfg(inst, TRS_DB_TASK_CQ, &start, &end); | 34 | ret |= trs_soc_get_db_cfg(inst, TRS_DB_TASK_CQ, &start, &end); |
| 36 | if ((ret != 0) || (start >= end)) { | 35 | if ((ret != 0) || (start >= end)) { |
| 37 | trs_tscpu_chan_near_ops_db_uninit(inst); | 36 | trs_tscpu_chan_near_ops_db_uninit(inst); |
| 38 | - trs_err( | 37 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 39 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 38 | + start, end); |
| 40 | - end); | ||
| 41 | return -ENODEV; | 39 | return -ENODEV; |
| 42 | } | 40 | } |
| 43 | 41 | ||
| @@ -101,8 +101,8 @@ int trs_host_get_ssid(struct trs_id_inst *inst, int *user_visible_flag, int *ssi | |||
| 101 | 101 | ||
| 102 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 102 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 103 | if ((ret != 0) || (msg.header.result != 0)) { | 103 | if ((ret != 0) || (msg.header.result != 0)) { |
| 104 | - trs_err( | 104 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 105 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 105 | + msg.header.result); |
| 106 | return -ENODEV; | 106 | return -ENODEV; |
| 107 | } | 107 | } |
| 108 | *user_visible_flag = 0; | 108 | *user_visible_flag = 0; |
| @@ -161,15 +161,13 @@ int trs_host_res_is_check_msg_proc(u32 devid, struct trs_msg_data *data) | |||
| 161 | 161 | ||
| 162 | trs_id_inst_pack(&inst, devid, data->header.tsid); | 162 | trs_id_inst_pack(&inst, devid, data->header.tsid); |
| 163 | if (trs_res_is_belong_to_proc(&inst, id_msg->hpid, id_msg->id_type, id_msg->res_id)) { | 163 | if (trs_res_is_belong_to_proc(&inst, id_msg->hpid, id_msg->id_type, id_msg->res_id)) { |
| 164 | - trs_debug( | 164 | + trs_debug("Res id belong to master process. (master_tgid=%u; type=%s; id=%d)\n", id_msg->hpid, |
| 165 | - "Res id belong to master process. (master_tgid=%u; type=%s; id=%d)\n", id_msg->hpid, | 165 | + trs_id_type_to_name(id_msg->id_type), id_msg->res_id); |
| 166 | - trs_id_type_to_name(id_msg->id_type), id_msg->res_id); | ||
| 167 | return 0; | 166 | return 0; |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | - trs_err( | 169 | + trs_err("Res id not belong to master process. (master_tgid=%u; type=%s; id=%d)\n", id_msg->hpid, |
| 171 | - "Res id not belong to master process. (master_tgid=%u; type=%s; id=%d)\n", id_msg->hpid, | 170 | + trs_id_type_to_name(id_msg->id_type), id_msg->res_id); |
| 172 | - trs_id_type_to_name(id_msg->id_type), id_msg->res_id); | ||
| 173 | return -1; | 171 | return -1; |
| 174 | 172 | ||
| 175 | } | 173 | } |
| @@ -193,8 +191,8 @@ int trs_host_res_id_check(struct trs_id_inst *inst, int id_type, u32 res_id) | |||
| 193 | 191 | ||
| 194 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 192 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 195 | if ((ret != 0) || (msg.header.result != 0)) { | 193 | if ((ret != 0) || (msg.header.result != 0)) { |
| 196 | - trs_err( | 194 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 197 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 195 | + msg.header.result); |
| 198 | return -ENODEV; | 196 | return -ENODEV; |
| 199 | } | 197 | } |
| 200 | 198 | ||
| @@ -213,8 +211,8 @@ int trs_host_ras_report(struct trs_id_inst *inst) | |||
| 213 | 211 | ||
| 214 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 212 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 215 | if ((ret != 0) || (msg.header.result != 0)) { | 213 | if ((ret != 0) || (msg.header.result != 0)) { |
| 216 | - trs_err( | 214 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 217 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 215 | + msg.header.result); |
| 218 | return ret; | 216 | return ret; |
| 219 | } | 217 | } |
| 220 | return 0; | 218 | return 0; |
| @@ -236,9 +234,8 @@ int trs_host_res_num_query(struct trs_id_inst *inst, struct trs_res_query_para * | |||
| 236 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 234 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 237 | if (ret != 0) { | 235 | if (ret != 0) { |
| 238 | if (ret != -EOPNOTSUPP) { | 236 | if (ret != -EOPNOTSUPP) { |
| 239 | - trs_err( | 237 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 240 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, | 238 | + msg.header.result); |
| 241 | - msg.header.result); | ||
| 242 | } | 239 | } |
| 243 | return ret; | 240 | return ret; |
| 244 | } | 241 | } |
| @@ -302,9 +299,8 @@ int trs_get_host_mach_flag(struct trs_id_inst *inst, u32 *host_flag) | |||
| 302 | return 0; | 299 | return 0; |
| 303 | } | 300 | } |
| 304 | 301 | ||
| 305 | -int trs_host_request_irq( | 302 | +int trs_host_request_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para, const char *name, |
| 306 | - struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para, const char *name, | 303 | + ka_irqreturn_t (*handler)(int irq, void *para)) |
| 307 | - ka_irqreturn_t (*handler)(int irq, void *para)) | ||
| 308 | { | 304 | { |
| 309 | int ret; | 305 | int ret; |
| 310 | struct res_inst_info res_inst; | 306 | struct res_inst_info res_inst; |
| @@ -312,8 +308,8 @@ int trs_host_request_irq( | |||
| 312 | soc_resmng_inst_pack(&res_inst, inst->devid, TS_SUBSYS, inst->tsid); | 308 | soc_resmng_inst_pack(&res_inst, inst->devid, TS_SUBSYS, inst->tsid); |
| 313 | ret = soc_resmng_get_hwirq(&res_inst, attr->irq_type, attr->irq, &hwirq); | 309 | ret = soc_resmng_get_hwirq(&res_inst, attr->irq_type, attr->irq, &hwirq); |
| 314 | if (ret != 0) { | 310 | if (ret != 0) { |
| 315 | - trs_err( | 311 | + trs_err("Get hw irq failed. (devid=%u; irqtype=%u; irq=%u; ret=%d)\n", inst->devid, attr->irq_type, attr->irq, |
| 316 | - "Get hw irq failed. (devid=%u; irqtype=%u; irq=%u; ret=%d)\n", inst->devid, attr->irq_type, attr->irq, ret); | 312 | + ret); |
| 317 | return ret; | 313 | return ret; |
| 318 | } | 314 | } |
| 319 | 315 | ||
| @@ -323,9 +319,8 @@ int trs_host_request_irq( | |||
| 323 | ret = ka_system_request_irq(attr->irq, handler, 0, name, para); | 319 | ret = ka_system_request_irq(attr->irq, handler, 0, name, para); |
| 324 | 320 | ||
| 325 | if (ret != 0) { | 321 | if (ret != 0) { |
| 326 | - trs_err( | 322 | + trs_err("Request irq failed. (devid=%u; irq_type=%u; irq=%u; hwirq=%u; name=%s; ret=%d)\n", inst->devid, |
| 327 | - "Request irq failed. (devid=%u; irq_type=%u; irq=%u; hwirq=%u; name=%s; ret=%d)\n", inst->devid, | 323 | + attr->irq_type, attr->irq, hwirq, name, ret); |
| 328 | - attr->irq_type, attr->irq, hwirq, name, ret); | ||
| 329 | } | 324 | } |
| 330 | return ret; | 325 | return ret; |
| 331 | } | 326 | } |
| @@ -338,8 +333,8 @@ void trs_host_free_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr | |||
| 338 | soc_resmng_inst_pack(&res_inst, inst->devid, TS_SUBSYS, inst->tsid); | 333 | soc_resmng_inst_pack(&res_inst, inst->devid, TS_SUBSYS, inst->tsid); |
| 339 | ret = soc_resmng_get_hwirq(&res_inst, attr->irq_type, attr->irq, &hwirq); | 334 | ret = soc_resmng_get_hwirq(&res_inst, attr->irq_type, attr->irq, &hwirq); |
| 340 | if (ret != 0) { | 335 | if (ret != 0) { |
| 341 | - trs_warn( | 336 | + trs_warn("Get hw irq warn. (devid=%u; irqtype=%u; irq=%u; ret=%d)\n", inst->devid, attr->irq_type, attr->irq, |
| 342 | - "Get hw irq warn. (devid=%u; irqtype=%u; irq=%u; ret=%d)\n", inst->devid, attr->irq_type, attr->irq, ret); | 337 | + ret); |
| 343 | return; | 338 | return; |
| 344 | } | 339 | } |
| 345 | 340 | ||
| @@ -348,15 +343,14 @@ void trs_host_free_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr | |||
| 348 | ret = ka_system_free_irq(attr->irq, para); | 343 | ret = ka_system_free_irq(attr->irq, para); |
| 349 | 344 | ||
| 350 | if (ret != 0) { | 345 | if (ret != 0) { |
| 351 | - trs_warn( | 346 | + trs_warn("Free irq warn. (devid=%u; irqtype=%u; irq=%u; hwirq=%u; ret=%d)\n", inst->devid, attr->irq_type, |
| 352 | - "Free irq warn. (devid=%u; irqtype=%u; irq=%u; hwirq=%u; ret=%d)\n", inst->devid, attr->irq_type, attr->irq, | 347 | + attr->irq, hwirq, ret); |
| 353 | - hwirq, ret); | ||
| 354 | return; | 348 | return; |
| 355 | } | 349 | } |
| 356 | } | 350 | } |
| 357 | 351 | ||
| 358 | -int trs_adapt_ops_request_irq( | 352 | +int trs_adapt_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, |
| 359 | - struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, ka_irqreturn_t (*handler)(int irq, void *para)) | 353 | + ka_irqreturn_t (*handler)(int irq, void *para)) |
| 360 | { | 354 | { |
| 361 | struct trs_adapt_irq_attr attr; | 355 | struct trs_adapt_irq_attr attr; |
| 362 | const char *name = NULL; | 356 | const char *name = NULL; |
| @@ -29,12 +29,11 @@ int trs_host_flush_id(u32 devid, struct trs_msg_data *data); | |||
| 29 | int trs_host_res_is_check_msg_proc(u32 devid, struct trs_msg_data *data); | 29 | int trs_host_res_is_check_msg_proc(u32 devid, struct trs_msg_data *data); |
| 30 | int trs_host_res_id_check(struct trs_id_inst *inst, int id_type, u32 res_id); | 30 | int trs_host_res_id_check(struct trs_id_inst *inst, int id_type, u32 res_id); |
| 31 | int trs_host_res_num_query(struct trs_id_inst *inst, struct trs_res_query_para *para); | 31 | int trs_host_res_num_query(struct trs_id_inst *inst, struct trs_res_query_para *para); |
| 32 | -int trs_host_request_irq( | 32 | +int trs_host_request_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para, const char *name, |
| 33 | - struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para, const char *name, | 33 | + ka_irqreturn_t (*handler)(int irq, void *para)); |
| 34 | - ka_irqreturn_t (*handler)(int irq, void *para)); | ||
| 35 | void trs_host_free_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para); | 34 | void trs_host_free_irq(struct trs_id_inst *inst, struct trs_adapt_irq_attr *attr, void *para); |
| 36 | -int trs_adapt_ops_request_irq( | 35 | +int trs_adapt_ops_request_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, |
| 37 | - struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para, ka_irqreturn_t (*handler)(int irq, void *para)); | 36 | + ka_irqreturn_t (*handler)(int irq, void *para)); |
| 38 | void trs_adapt_ops_free_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); | 37 | void trs_adapt_ops_free_irq(struct trs_id_inst *inst, u32 irq_type, u32 irq, void *para); |
| 39 | int trs_host_ts_cq_process(u32 devid, struct trs_msg_data *data); | 38 | int trs_host_ts_cq_process(u32 devid, struct trs_msg_data *data); |
| 40 | int trs_host_get_connect_protocol(struct trs_id_inst *inst); | 39 | int trs_host_get_connect_protocol(struct trs_id_inst *inst); |
| @@ -152,7 +152,10 @@ static struct trs_core_adapt_ops trs_core_stars_v1_ops = { | |||
| 152 | .res_num_query = trs_host_res_num_query, | 152 | .res_num_query = trs_host_res_num_query, |
| 153 | }; | 153 | }; |
| 154 | 154 | ||
| 155 | -struct trs_core_adapt_ops *trs_core_get_stars_v1_adapt_ops(void) { return &trs_core_stars_v1_ops; } | 155 | +struct trs_core_adapt_ops *trs_core_get_stars_v1_adapt_ops(void) |
| 156 | +{ | ||
| 157 | + return &trs_core_stars_v1_ops; | ||
| 158 | +} | ||
| 156 | 159 | ||
| 157 | static int trs_sq_trigger_msg_send(struct trs_id_inst *inst, u32 db, u32 hwirq) | 160 | static int trs_sq_trigger_msg_send(struct trs_id_inst *inst, u32 db, u32 hwirq) |
| 158 | { | 161 | { |
| @@ -181,9 +184,8 @@ int trs_sq_send_trigger_db_init(struct trs_id_inst *inst) | |||
| 181 | 184 | ||
| 182 | ret = trs_soc_get_db_cfg(inst, TRS_DB_TRIGGER_SQ, &start, &end); | 185 | ret = trs_soc_get_db_cfg(inst, TRS_DB_TRIGGER_SQ, &start, &end); |
| 183 | if ((ret != 0) || (start >= end)) { | 186 | if ((ret != 0) || (start >= end)) { |
| 184 | - trs_err( | 187 | + trs_err("Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, |
| 185 | - "Trs get db cfg fail. (devid=%u; tsid=%u; ret=%d; start=%u; end=%u)\n", inst->devid, inst->tsid, ret, start, | 188 | + start, end); |
| 186 | - end); | ||
| 187 | return -ENODEV; | 189 | return -ENODEV; |
| 188 | } | 190 | } |
| 189 | 191 | ||
| @@ -211,4 +213,7 @@ int trs_sq_send_trigger_db_init(struct trs_id_inst *inst) | |||
| 211 | return 0; | 213 | return 0; |
| 212 | } | 214 | } |
| 213 | 215 | ||
| 214 | -void trs_sq_send_trigger_db_uninit(struct trs_id_inst *inst) { trs_ts_db_uninit(inst, TRS_DB_TRIGGER_SQ); } | 216 | +void trs_sq_send_trigger_db_uninit(struct trs_id_inst *inst) |
| 217 | +{ | ||
| 218 | + trs_ts_db_uninit(inst, TRS_DB_TRIGGER_SQ); | ||
| 219 | +} | ||
| @@ -137,4 +137,7 @@ static struct trs_core_adapt_ops trs_core_stars_v2_ops = { | |||
| 137 | .res_num_query = trs_host_res_num_query, | 137 | .res_num_query = trs_host_res_num_query, |
| 138 | }; | 138 | }; |
| 139 | 139 | ||
| 140 | -struct trs_core_adapt_ops *trs_core_get_stars_v2_adapt_ops(void) { return &trs_core_stars_v2_ops; } | 140 | +struct trs_core_adapt_ops *trs_core_get_stars_v2_adapt_ops(void) |
| 141 | +{ | ||
| 142 | + return &trs_core_stars_v2_ops; | ||
| 143 | +} | ||
| @@ -40,7 +40,7 @@ void trs_ub_info_set(u32 devid, struct trs_ub_info *ub_info) | |||
| 40 | g_trs_ub_info[ts_inst_id].die_id = ub_info->die_id; | 40 | g_trs_ub_info[ts_inst_id].die_id = ub_info->die_id; |
| 41 | g_trs_ub_info[ts_inst_id].func_id = ub_info->func_id; | 41 | g_trs_ub_info[ts_inst_id].func_id = ub_info->func_id; |
| 42 | 42 | ||
| 43 | - trs_info( | 43 | + trs_info("devid=%u, dieid=%u, funcid=%u\n", devid, g_trs_ub_info[ts_inst_id].die_id, |
| 44 | - "devid=%u, dieid=%u, funcid=%u\n", devid, g_trs_ub_info[ts_inst_id].die_id, g_trs_ub_info[ts_inst_id].func_id); | 44 | + g_trs_ub_info[ts_inst_id].func_id); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| @@ -32,8 +32,8 @@ int trs_core_ops_get_proc_num(struct trs_id_inst *inst, u32 *proc_num) | |||
| 32 | 32 | ||
| 33 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 33 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 34 | if ((ret != 0) || (msg.header.result != 0)) { | 34 | if ((ret != 0) || (msg.header.result != 0)) { |
| 35 | - trs_err( | 35 | + trs_err("Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 36 | - "Msg send fail. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 36 | + msg.header.result); |
| 37 | return -ENODEV; | 37 | return -ENODEV; |
| 38 | } | 38 | } |
| 39 | proc_num_msg = (struct trs_msg_proc_num *)msg.payload; | 39 | proc_num_msg = (struct trs_msg_proc_num *)msg.payload; |
| @@ -81,12 +81,14 @@ int trs_core_ops_get_res_reg_total_size(struct trs_id_inst *inst, int type, u32 | |||
| 81 | return -ENODEV; | 81 | return -ENODEV; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | -int trs_core_ops_get_ts_inst_status(struct trs_id_inst *inst, u32 *status) { return trs_get_ts_status(inst, status); } | 84 | +int trs_core_ops_get_ts_inst_status(struct trs_id_inst *inst, u32 *status) |
| 85 | +{ | ||
| 86 | + return trs_get_ts_status(inst, status); | ||
| 87 | +} | ||
| 85 | 88 | ||
| 86 | -static int res_addr_type_to_id_type[RES_ADDR_TYPE_MAX] = { | 89 | +static int res_addr_type_to_id_type[RES_ADDR_TYPE_MAX] = {[RES_ADDR_TYPE_STARS_NOTIFY_RECORD] = TRS_NOTIFY, |
| 87 | - [RES_ADDR_TYPE_STARS_NOTIFY_RECORD] = TRS_NOTIFY, | 90 | + [RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD] = TRS_CNT_NOTIFY, |
| 88 | - [RES_ADDR_TYPE_STARS_CNT_NOTIFY_RECORD] = TRS_CNT_NOTIFY, | 91 | + [RES_ADDR_TYPE_STARS_RTSQ] = TRS_HW_SQ}; |
| 89 | - [RES_ADDR_TYPE_STARS_RTSQ] = TRS_HW_SQ}; | ||
| 90 | 92 | ||
| 91 | bool trs_host_res_is_belong_to_proc(int master_tgid, int slave_tgid, u32 udevid, struct res_map_info_in *res_info) | 93 | bool trs_host_res_is_belong_to_proc(int master_tgid, int slave_tgid, u32 udevid, struct res_map_info_in *res_info) |
| 92 | { | 94 | { |
| @@ -95,9 +97,8 @@ bool trs_host_res_is_belong_to_proc(int master_tgid, int slave_tgid, u32 udevid, | |||
| 95 | 97 | ||
| 96 | trs_id_inst_pack(&inst, udevid, res_info->id); | 98 | trs_id_inst_pack(&inst, udevid, res_info->id); |
| 97 | if (trs_res_is_belong_to_proc(&inst, master_tgid, res_addr_type_to_id_type[res_info->res_type], res_id)) { | 99 | if (trs_res_is_belong_to_proc(&inst, master_tgid, res_addr_type_to_id_type[res_info->res_type], res_id)) { |
| 98 | - trs_debug( | 100 | + trs_debug("Res id belong to master process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, |
| 99 | - "Res id belong to master process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, | 101 | + slave_tgid, res_info->res_type, res_id); |
| 100 | - slave_tgid, res_info->res_type, res_id); | ||
| 101 | return true; | 102 | return true; |
| 102 | } | 103 | } |
| 103 | 104 | ||
| @@ -111,11 +112,10 @@ bool trs_host_res_is_belong_to_proc(int master_tgid, int slave_tgid, u32 udevid, | |||
| 111 | 112 | ||
| 112 | trs_id_inst_pack(&remote_inst, priv->remote_devid, res_info->id); | 113 | trs_id_inst_pack(&remote_inst, priv->remote_devid, res_info->id); |
| 113 | if ((priv->flag & TSDRV_FLAG_REMOTE_ID) != 0) { | 114 | if ((priv->flag & TSDRV_FLAG_REMOTE_ID) != 0) { |
| 114 | - if (trs_res_is_belong_to_proc( | 115 | + if (trs_res_is_belong_to_proc(&remote_inst, master_tgid, res_addr_type_to_id_type[res_info->res_type], |
| 115 | - &remote_inst, master_tgid, res_addr_type_to_id_type[res_info->res_type], res_id)) { | 116 | + res_id)) { |
| 116 | - trs_debug( | 117 | + trs_debug("Res id belong to remote process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", |
| 117 | - "Res id belong to remote process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, | 118 | + master_tgid, slave_tgid, res_info->res_type, res_id); |
| 118 | - slave_tgid, res_info->res_type, res_id); | ||
| 119 | return true; | 119 | return true; |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| @@ -123,21 +123,25 @@ bool trs_host_res_is_belong_to_proc(int master_tgid, int slave_tgid, u32 udevid, | |||
| 123 | 123 | ||
| 124 | /* res id belongs to cp1 in MC2 */ | 124 | /* res id belongs to cp1 in MC2 */ |
| 125 | if (trs_host_res_id_check(&inst, res_addr_type_to_id_type[res_info->res_type], res_id) == 0) { | 125 | if (trs_host_res_id_check(&inst, res_addr_type_to_id_type[res_info->res_type], res_id) == 0) { |
| 126 | - trs_debug( | 126 | + trs_debug("Res id belong to cp1 process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, |
| 127 | - "Res id belong to cp1 process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, slave_tgid, | 127 | + slave_tgid, res_info->res_type, res_id); |
| 128 | - res_info->res_type, res_id); | ||
| 129 | return true; | 128 | return true; |
| 130 | } | 129 | } |
| 131 | - trs_err( | 130 | + trs_err("Res id not belong to master process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, |
| 132 | - "Res id not belong to master process. (master_tgid=%d; slave_tgid=%d; type=%d; id=%d)\n", master_tgid, | 131 | + slave_tgid, res_info->res_type, res_id); |
| 133 | - slave_tgid, res_info->res_type, res_id); | ||
| 134 | return false; | 132 | return false; |
| 135 | 133 | ||
| 136 | } | 134 | } |
| 137 | 135 | ||
| 138 | -void *trs_core_ops_cq_mem_alloc(struct trs_id_inst *inst, size_t size) { return trs_vzalloc(size); } | 136 | +void *trs_core_ops_cq_mem_alloc(struct trs_id_inst *inst, size_t size) |
| 137 | +{ | ||
| 138 | + return trs_vzalloc(size); | ||
| 139 | +} | ||
| 139 | 140 | ||
| 140 | -void trs_core_ops_cq_mem_free(struct trs_id_inst *inst, void *vaddr, size_t size) { trs_vfree(vaddr); } | 141 | +void trs_core_ops_cq_mem_free(struct trs_id_inst *inst, void *vaddr, size_t size) |
| 142 | +{ | ||
| 143 | + trs_vfree(vaddr); | ||
| 144 | +} | ||
| 141 | 145 | ||
| 142 | int trs_core_ops_mem_update(struct trs_id_inst *inst, u64 in_addr, u64 *out_addr, int flag) | 146 | int trs_core_ops_mem_update(struct trs_id_inst *inst, u64 in_addr, u64 *out_addr, int flag) |
| 143 | { | 147 | { |
| @@ -48,4 +48,7 @@ static struct trs_core_adapt_ops trs_tscpu_core_ops = { | |||
| 48 | .get_connect_protocol = trs_host_get_connect_protocol, | 48 | .get_connect_protocol = trs_host_get_connect_protocol, |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | -struct trs_core_adapt_ops *trs_core_get_tscpu_adapt_ops(void) { return &trs_tscpu_core_ops; } | 51 | +struct trs_core_adapt_ops *trs_core_get_tscpu_adapt_ops(void) |
| 52 | +{ | ||
| 53 | + return &trs_tscpu_core_ops; | ||
| 54 | +} | ||
| @@ -50,7 +50,10 @@ int trs_ts_db_config(struct trs_id_inst *inst) | |||
| 50 | } | 50 | } |
| 51 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_config); | 51 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_config); |
| 52 | 52 | ||
| 53 | -void trs_ts_db_deconfig(struct trs_id_inst *inst) { trs_ts_db_decfg(inst); } | 53 | +void trs_ts_db_deconfig(struct trs_id_inst *inst) |
| 54 | +{ | ||
| 55 | + trs_ts_db_decfg(inst); | ||
| 56 | +} | ||
| 54 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_deconfig); | 57 | KA_EXPORT_SYMBOL_GPL(trs_ts_db_deconfig); |
| 55 | 58 | ||
| 56 | int trs_ts_doorbell_init(u32 ts_inst_id) | 59 | int trs_ts_doorbell_init(u32 ts_inst_id) |
| @@ -90,9 +90,8 @@ int trs_sqcq_change_flag_init(struct trs_id_inst *inst, u32 grp_id, u32 vfid) | |||
| 90 | trs_err("Failed to get mia group info. (udevid=%u; grp_id=%u)\n", inst->devid, grp_id); | 90 | trs_err("Failed to get mia group info. (udevid=%u; grp_id=%u)\n", inst->devid, grp_id); |
| 91 | return ret; | 91 | return ret; |
| 92 | } | 92 | } |
| 93 | - trs_info( | 93 | + trs_info("Set change flag. (devid=%u; vfid=%u; vnpu_vfid=%u; bitmap=0x%llx)\n", inst->devid, vfid, vnpu_vfid, |
| 94 | - "Set change flag. (devid=%u; vfid=%u; vnpu_vfid=%u; bitmap=0x%llx)\n", inst->devid, vfid, vnpu_vfid, | 94 | + grp_info.rtsq_info.bitmap); |
| 95 | - grp_info.rtsq_info.bitmap); | ||
| 96 | for (bit = 0; bit < TRS_MAX_ID_BIT_NUM; bit++) { | 95 | for (bit = 0; bit < TRS_MAX_ID_BIT_NUM; bit++) { |
| 97 | if (trs_bitmap_bit_is_vaild(grp_info.rtsq_info.bitmap, bit)) { | 96 | if (trs_bitmap_bit_is_vaild(grp_info.rtsq_info.bitmap, bit)) { |
| 98 | g_trs_sqcq_change_flag[inst->devid][bit] = true; | 97 | g_trs_sqcq_change_flag[inst->devid][bit] = true; |
| @@ -229,8 +228,8 @@ int trs_add_group(struct trs_id_inst *inst, u32 grp_id) | |||
| 229 | } | 228 | } |
| 230 | ret = trs_sqcq_change_flag_init(inst, grp_id, vfid); | 229 | ret = trs_sqcq_change_flag_init(inst, grp_id, vfid); |
| 231 | if (ret != 0) { | 230 | if (ret != 0) { |
| 232 | - trs_err( | 231 | + trs_err("Init change flag failed. (ret=%d; udevid=%u; grp_id=%u; vfid=%u)\n", ret, inst->devid, grp_id, |
| 233 | - "Init change flag failed. (ret=%d; udevid=%u; grp_id=%u; vfid=%u)\n", ret, inst->devid, grp_id, vfid); | 232 | + vfid); |
| 234 | } | 233 | } |
| 235 | } | 234 | } |
| 236 | return ret; | 235 | return ret; |
| @@ -91,8 +91,8 @@ int trs_host_get_id_cap(struct trs_id_inst *inst, int type, struct trs_msg_id_ca | |||
| 91 | if (ret == 0) { | 91 | if (ret == 0) { |
| 92 | *id_cap = *_id_cap; | 92 | *id_cap = *_id_cap; |
| 93 | } else { | 93 | } else { |
| 94 | - trs_debug( | 94 | + trs_debug("Get id. (devid=%u; tsid=%u; type=%s; ret=%d)\n", inst->devid, inst->tsid, trs_id_type_to_name(type), |
| 95 | - "Get id. (devid=%u; tsid=%u; type=%s; ret=%d)\n", inst->devid, inst->tsid, trs_id_type_to_name(type), ret); | 95 | + ret); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | return ret; | 98 | return ret; |
| @@ -114,8 +114,8 @@ static int trs_host_res_avail_query(struct trs_id_inst *inst, int type, u32 *num | |||
| 114 | res_num_msg->type = type; | 114 | res_num_msg->type = type; |
| 115 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); | 115 | ret = trs_host_msg_send(inst->devid, &msg, sizeof(struct trs_msg_data)); |
| 116 | if ((ret != 0) || (msg.header.result != 0)) { | 116 | if ((ret != 0) || (msg.header.result != 0)) { |
| 117 | - trs_warn( | 117 | + trs_warn("Not support. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, |
| 118 | - "Not support. (devid=%u; tsid=%u; ret=%d; result=%d)\n", inst->devid, inst->tsid, ret, msg.header.result); | 118 | + msg.header.result); |
| 119 | return -ENODEV; | 119 | return -ENODEV; |
| 120 | } | 120 | } |
| 121 | *num = res_num_msg->avail_num; | 121 | *num = res_num_msg->avail_num; |
| @@ -124,19 +124,17 @@ static int trs_host_res_avail_query(struct trs_id_inst *inst, int type, u32 *num | |||
| 124 | 124 | ||
| 125 | static bool trs_host_id_is_non_cache_type(int type) | 125 | static bool trs_host_id_is_non_cache_type(int type) |
| 126 | { | 126 | { |
| 127 | - return ( | 127 | + return ((type == TRS_RSV_HW_SQ_ID) || (type == TRS_RSV_HW_CQ_ID) || (type == TRS_TASK_SCHED_CQ_ID) || |
| 128 | - (type == TRS_RSV_HW_SQ_ID) || (type == TRS_RSV_HW_CQ_ID) || (type == TRS_TASK_SCHED_CQ_ID) || | 128 | + (type == TRS_CDQM_ID)); |
| 129 | - (type == TRS_CDQM_ID)); | ||
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | static int trs_host_id_init(struct trs_id_inst *inst, int type) | 131 | static int trs_host_id_init(struct trs_id_inst *inst, int type) |
| 133 | { | 132 | { |
| 134 | - struct trs_id_ops ops = { | 133 | + struct trs_id_ops ops = {.owner = KA_THIS_MODULE, |
| 135 | - .owner = KA_THIS_MODULE, | 134 | + .alloc_batch = trs_host_alloc_id_batch, |
| 136 | - .alloc_batch = trs_host_alloc_id_batch, | 135 | + .free_batch = trs_host_free_id_batch, |
| 137 | - .free_batch = trs_host_free_id_batch, | 136 | + .avail_query = trs_host_res_avail_query, |
| 138 | - .avail_query = trs_host_res_avail_query, | 137 | + .is_non_cache_type = trs_host_id_is_non_cache_type}; |
| 139 | - .is_non_cache_type = trs_host_id_is_non_cache_type}; | ||
| 140 | struct trs_msg_id_cap id_cap; | 138 | struct trs_msg_id_cap id_cap; |
| 141 | struct trs_id_attr attr; | 139 | struct trs_id_attr attr; |
| 142 | int ret; | 140 | int ret; |
| @@ -147,9 +145,8 @@ static int trs_host_id_init(struct trs_id_inst *inst, int type) | |||
| 147 | } | 145 | } |
| 148 | 146 | ||
| 149 | if ((id_cap.isolate_num <= 0) || ((id_cap.total_num > 0) && (id_cap.isolate_num > id_cap.total_num))) { | 147 | if ((id_cap.isolate_num <= 0) || ((id_cap.total_num > 0) && (id_cap.isolate_num > id_cap.total_num))) { |
| 150 | - trs_err( | 148 | + trs_err("Invalid isolate_num. (devid=%u; tsid=%u; type=%s; isolate_num=%u; total_num=%u)\n", inst->devid, |
| 151 | - "Invalid isolate_num. (devid=%u; tsid=%u; type=%s; isolate_num=%u; total_num=%u)\n", inst->devid, | 149 | + inst->tsid, trs_id_type_to_name(type), id_cap.isolate_num, id_cap.total_num); |
| 152 | - inst->tsid, trs_id_type_to_name(type), id_cap.isolate_num, id_cap.total_num); | ||
| 153 | return -EINVAL; | 150 | return -EINVAL; |
| 154 | } | 151 | } |
| 155 | 152 | ||
| @@ -167,15 +164,17 @@ static int trs_host_id_init(struct trs_id_inst *inst, int type) | |||
| 167 | } | 164 | } |
| 168 | 165 | ||
| 169 | if (ret == 0) { | 166 | if (ret == 0) { |
| 170 | - trs_debug( | 167 | + trs_debug("Id init. (devid=%u; tsid=%u; type=%s; start=%u; end=%u; total_num=%u; split=%u; batch_num=%u)\n", |
| 171 | - "Id init. (devid=%u; tsid=%u; type=%s; start=%u; end=%u; total_num=%u; split=%u; batch_num=%u)\n", | 168 | + inst->devid, inst->tsid, trs_id_type_to_name(type), attr.id_start, attr.id_end, attr.id_num, |
| 172 | - inst->devid, inst->tsid, trs_id_type_to_name(type), attr.id_start, attr.id_end, attr.id_num, attr.split, | 169 | + attr.split, attr.batch_num); |
| 173 | - attr.batch_num); | ||
| 174 | } | 170 | } |
| 175 | return ret; | 171 | return ret; |
| 176 | } | 172 | } |
| 177 | 173 | ||
| 178 | -static void trs_host_id_uninit(struct trs_id_inst *inst, int type) { trs_id_unregister(inst, type); } | 174 | +static void trs_host_id_uninit(struct trs_id_inst *inst, int type) |
| 175 | +{ | ||
| 176 | + trs_id_unregister(inst, type); | ||
| 177 | +} | ||
| 179 | 178 | ||
| 180 | int trs_id_config(struct trs_id_inst *inst) | 179 | int trs_id_config(struct trs_id_inst *inst) |
| 181 | { | 180 | { |
| @@ -184,8 +183,8 @@ int trs_id_config(struct trs_id_inst *inst) | |||
| 184 | for (type = TRS_STREAM_ID; type < TRS_ID_TYPE_MAX; type++) { | 183 | for (type = TRS_STREAM_ID; type < TRS_ID_TYPE_MAX; type++) { |
| 185 | ret = trs_host_id_init(inst, type); | 184 | ret = trs_host_id_init(inst, type); |
| 186 | if (ret == 0) { | 185 | if (ret == 0) { |
| 187 | - trs_debug( | 186 | + trs_debug("Init id succeed. (devid=%u; tsid=%u; type=%s)\n", inst->devid, inst->tsid, |
| 188 | - "Init id succeed. (devid=%u; tsid=%u; type=%s)\n", inst->devid, inst->tsid, trs_id_type_to_name(type)); | 187 | + trs_id_type_to_name(type)); |
| 189 | } else if ((ret == -ENODEV) || (ret == -ENOSYS)) { | 188 | } else if ((ret == -ENODEV) || (ret == -ENOSYS)) { |
| 190 | trs_id_deconfig(inst); | 189 | trs_id_deconfig(inst); |
| 191 | return ret; | 190 | return ret; |
| @@ -98,9 +98,8 @@ static int trs_sq_send_mode_config_by_urd(struct trsModeInfo *info) | |||
| 98 | int ret = 0; | 98 | int ret = 0; |
| 99 | 99 | ||
| 100 | if ((info->mode < 0) || (info->mode >= TRS_MODE_TYPE_SQ_SEND_MAX) || (info->devId >= TRS_HOST_PHY_DEV_MAX)) { | 100 | if ((info->mode < 0) || (info->mode >= TRS_MODE_TYPE_SQ_SEND_MAX) || (info->devId >= TRS_HOST_PHY_DEV_MAX)) { |
| 101 | - trs_err( | 101 | + trs_err("The sq send mode or devid is invalid. (mode=%d; max=%d; devid=%u; max=%u)\n", info->mode, |
| 102 | - "The sq send mode or devid is invalid. (mode=%d; max=%d; devid=%u; max=%u)\n", info->mode, | 102 | + TRS_MODE_TYPE_SQ_SEND_MAX, info->devId, TRS_HOST_PHY_DEV_MAX); |
| 103 | - TRS_MODE_TYPE_SQ_SEND_MAX, info->devId, TRS_HOST_PHY_DEV_MAX); | ||
| 104 | return -EINVAL; | 103 | return -EINVAL; |
| 105 | } | 104 | } |
| 106 | 105 | ||
| @@ -190,9 +189,8 @@ int trs_mode_query_by_urd(void *feature, char *in, u32 in_len, char *out, u32 ou | |||
| 190 | 189 | ||
| 191 | if ((feature == NULL) || (in == NULL) || (in_len != sizeof(struct trsModeInfo)) || (out == NULL) || | 190 | if ((feature == NULL) || (in == NULL) || (in_len != sizeof(struct trsModeInfo)) || (out == NULL) || |
| 192 | (out_len != sizeof(int))) { | 191 | (out_len != sizeof(int))) { |
| 193 | - trs_err( | 192 | + trs_err("Param invalid. (feature=%d; in=%d; in_len=%u; out=%d; out_len=%u)\n", feature != NULL, in != NULL, |
| 194 | - "Param invalid. (feature=%d; in=%d; in_len=%u; out=%d; out_len=%u)\n", feature != NULL, in != NULL, in_len, | 193 | + in_len, out != NULL, out_len); |
| 195 | - out != NULL, out_len); | ||
| 196 | return -EINVAL; | 194 | return -EINVAL; |
| 197 | } | 195 | } |
| 198 | 196 | ||
| @@ -212,12 +210,12 @@ int trs_mode_query_by_urd(void *feature, char *in, u32 in_len, char *out, u32 ou | |||
| 212 | BEGIN_DMS_MODULE_DECLARATION(TRS_URD_CMD_NAME) | 210 | BEGIN_DMS_MODULE_DECLARATION(TRS_URD_CMD_NAME) |
| 213 | BEGIN_FEATURE_COMMAND() | 211 | BEGIN_FEATURE_COMMAND() |
| 214 | 212 | ||
| 215 | -ADD_FEATURE_COMMAND( | 213 | +ADD_FEATURE_COMMAND(TRS_URD_CMD_NAME, URD_TRS_MODE_CONFIG_CMD, ZERO_CMD, NULL, NULL, |
| 216 | - TRS_URD_CMD_NAME, URD_TRS_MODE_CONFIG_CMD, ZERO_CMD, NULL, NULL, | 214 | + DMS_ACC_ROOT | DMS_ENV_PHYSICAL | DMS_ENV_ADMIN_DOCKER | DMS_VDEV_NOTSUPPORT, |
| 217 | - DMS_ACC_ROOT | DMS_ENV_PHYSICAL | DMS_ENV_ADMIN_DOCKER | DMS_VDEV_NOTSUPPORT, trs_mode_config_by_urd) | 215 | + trs_mode_config_by_urd) |
| 218 | 216 | ||
| 219 | -ADD_FEATURE_COMMAND( | 217 | +ADD_FEATURE_COMMAND(TRS_URD_CMD_NAME, URD_TRS_MODE_QUERY_CMD, ZERO_CMD, NULL, NULL, DMS_SUPPORT_ALL, |
| 220 | - TRS_URD_CMD_NAME, URD_TRS_MODE_QUERY_CMD, ZERO_CMD, NULL, NULL, DMS_SUPPORT_ALL, trs_mode_query_by_urd) | 218 | + trs_mode_query_by_urd) |
| 221 | 219 | ||
| 222 | END_FEATURE_COMMAND() | 220 | END_FEATURE_COMMAND() |
| 223 | END_MODULE_DECLARATION() | 221 | END_MODULE_DECLARATION() |
| @@ -275,5 +273,8 @@ int trs_host_mode_config_init(void) | |||
| 275 | } | 273 | } |
| 276 | DECLAER_FEATURE_AUTO_INIT(trs_host_mode_config_init, FEATURE_LOADER_STAGE_2); | 274 | DECLAER_FEATURE_AUTO_INIT(trs_host_mode_config_init, FEATURE_LOADER_STAGE_2); |
| 277 | 275 | ||
| 278 | -void trs_host_mode_config_uninit(void) { CALL_EXIT_MODULE(TRS_URD_CMD_NAME); } | 276 | +void trs_host_mode_config_uninit(void) |
| 277 | +{ | ||
| 278 | + CALL_EXIT_MODULE(TRS_URD_CMD_NAME); | ||
| 279 | +} | ||
| 279 | DECLAER_FEATURE_AUTO_UNINIT(trs_host_mode_config_uninit, FEATURE_LOADER_STAGE_2); | 280 | DECLAER_FEATURE_AUTO_UNINIT(trs_host_mode_config_uninit, FEATURE_LOADER_STAGE_2); |
| @@ -128,10 +128,13 @@ static struct trs_host_msg *trs_host_msg_get(u32 devid) | |||
| 128 | return host_msg; | 128 | return host_msg; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | -static void trs_host_msg_put(struct trs_host_msg *host_msg) { kref_safe_put(&host_msg->ref, trs_host_msg_release); } | 131 | +static void trs_host_msg_put(struct trs_host_msg *host_msg) |
| 132 | +{ | ||
| 133 | + kref_safe_put(&host_msg->ref, trs_host_msg_release); | ||
| 134 | +} | ||
| 132 | 135 | ||
| 133 | -int trs_host_msg_chan_recv_check( | 136 | +int trs_host_msg_chan_recv_check(u32 devid, struct trs_msg_data *data, u32 in_data_len, u32 out_data_len, |
| 134 | - u32 devid, struct trs_msg_data *data, u32 in_data_len, u32 out_data_len, u32 *real_out_len) | 137 | + u32 *real_out_len) |
| 135 | { | 138 | { |
| 136 | if (devid >= TRS_DEV_MAX_NUM) { | 139 | if (devid >= TRS_DEV_MAX_NUM) { |
| 137 | trs_err("Invalid devid. (devid=%u)\n", devid); | 140 | trs_err("Invalid devid. (devid=%u)\n", devid); |
| @@ -179,8 +182,8 @@ int trs_host_msg_send(u32 devid, void *msg, size_t size) | |||
| 179 | if (host_msg == NULL) { | 182 | if (host_msg == NULL) { |
| 180 | return -ENODEV; | 183 | return -ENODEV; |
| 181 | } | 184 | } |
| 182 | - ret = devdrv_sync_msg_send( | 185 | + ret = devdrv_sync_msg_send(host_msg->chan, tmp_msg, sizeof(struct trs_msg_data), sizeof(struct trs_msg_data), |
| 183 | - host_msg->chan, tmp_msg, sizeof(struct trs_msg_data), sizeof(struct trs_msg_data), &out_len); | 186 | + &out_len); |
| 184 | trs_host_msg_put(host_msg); | 187 | trs_host_msg_put(host_msg); |
| 185 | 188 | ||
| 186 | return (ret == 0) ? (int)tmp_msg->header.result : ret; | 189 | return (ret == 0) ? (int)tmp_msg->header.result : ret; |
| @@ -20,8 +20,8 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void); | 22 | struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void); |
| 23 | -int trs_host_msg_chan_recv_check( | 23 | +int trs_host_msg_chan_recv_check(u32 devid, struct trs_msg_data *data, u32 in_data_len, u32 out_data_len, |
| 24 | - u32 devid, struct trs_msg_data *data, u32 in_data_len, u32 out_data_len, u32 *real_out_len); | 24 | + u32 *real_out_len); |
| 25 | int trs_host_msg_send(u32 devid, void *msg, size_t size); | 25 | int trs_host_msg_send(u32 devid, void *msg, size_t size); |
| 26 | int trs_host_msg_init(u32 ts_inst_id); | 26 | int trs_host_msg_init(u32 ts_inst_id); |
| 27 | void trs_host_msg_uninit(u32 ts_inst_id); | 27 | void trs_host_msg_uninit(u32 ts_inst_id); |
| @@ -48,9 +48,8 @@ static int trs_host_update_res_info(u32 udevid, struct res_map_info_in *res_info | |||
| 48 | trs_err("Fail to get remote add id. (ret=%d; remote_udevid=%u)\n", ret, priv->remote_devid); | 48 | trs_err("Fail to get remote add id. (ret=%d; remote_udevid=%u)\n", ret, priv->remote_devid); |
| 49 | return ret; | 49 | return ret; |
| 50 | } | 50 | } |
| 51 | - trs_debug( | 51 | + trs_debug("Update priv. (udevid=%u; local_add_id=%u; remote_udevid=%u; remote_add_id=%u)\n", udevid, |
| 52 | - "Update priv. (udevid=%u; local_add_id=%u; remote_udevid=%u; remote_add_id=%u)\n", udevid, local_add_id, | 52 | + local_add_id, priv->remote_devid, remote_add_id); |
| 53 | - priv->remote_devid, remote_add_id); | ||
| 54 | priv->local_devid = local_add_id; | 53 | priv->local_devid = local_add_id; |
| 55 | priv->remote_devid = remote_add_id; | 54 | priv->remote_devid = remote_add_id; |
| 56 | res_info->res_id = (remote_add_id << 20) | res_info->res_id; /* first 20 bits for res id */ | 55 | res_info->res_id = (remote_add_id << 20) | res_info->res_id; /* first 20 bits for res id */ |
| @@ -118,12 +118,10 @@ int trs_urd_rpc_msg_get(void *feature, char *in, u32 in_len, char *out, u32 out_ | |||
| 118 | 118 | ||
| 119 | BEGIN_DMS_MODULE_DECLARATION(DMS_MODULE_TRS_RPC_CTRL) | 119 | BEGIN_DMS_MODULE_DECLARATION(DMS_MODULE_TRS_RPC_CTRL) |
| 120 | BEGIN_FEATURE_COMMAND() | 120 | BEGIN_FEATURE_COMMAND() |
| 121 | -ADD_FEATURE_COMMAND( | 121 | +ADD_FEATURE_COMMAND(DMS_MODULE_TRS_RPC_CTRL, DMS_GET_SET_DEVICE_INFO_CMD, ZERO_CMD, "main_cmd=0xb,sub_cmd=0xb", NULL, |
| 122 | - DMS_MODULE_TRS_RPC_CTRL, DMS_GET_SET_DEVICE_INFO_CMD, ZERO_CMD, "main_cmd=0xb,sub_cmd=0xb", NULL, | 122 | + DMS_ACC_ROOT_ONLY | DMS_ENV_NOT_NORMAL_DOCKER | DMS_VDEV_NOTSUPPORT, trs_urd_rpc_msg_set) |
| 123 | - DMS_ACC_ROOT_ONLY | DMS_ENV_NOT_NORMAL_DOCKER | DMS_VDEV_NOTSUPPORT, trs_urd_rpc_msg_set) | 123 | +ADD_FEATURE_COMMAND(DMS_MODULE_TRS_RPC_CTRL, DMS_GET_GET_DEVICE_INFO_CMD, ZERO_CMD, "main_cmd=0xb,sub_cmd=0xb", NULL, |
| 124 | -ADD_FEATURE_COMMAND( | 124 | + DMS_ACC_ALL | DMS_ENV_ALL | DMS_VDEV_NOTSUPPORT, trs_urd_rpc_msg_get) |
| 125 | - DMS_MODULE_TRS_RPC_CTRL, DMS_GET_GET_DEVICE_INFO_CMD, ZERO_CMD, "main_cmd=0xb,sub_cmd=0xb", NULL, | ||
| 126 | - DMS_ACC_ALL | DMS_ENV_ALL | DMS_VDEV_NOTSUPPORT, trs_urd_rpc_msg_get) | ||
| 127 | END_FEATURE_COMMAND() | 125 | END_FEATURE_COMMAND() |
| 128 | END_MODULE_DECLARATION() | 126 | END_MODULE_DECLARATION() |
| 129 | 127 | ||
| @@ -86,16 +86,15 @@ int trs_ts_cq_cpy(struct trs_id_inst *inst, u32 cqid, u32 cq_type, u8 *cqe) | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | - ret = memcpy_s( | 89 | + ret = memcpy_s(cq_info.cq_vaddr + cq_info.cq_para.cqe_size * cq_head, cq_info.cq_para.cqe_size, cqe, |
| 90 | - cq_info.cq_vaddr + cq_info.cq_para.cqe_size * cq_head, cq_info.cq_para.cqe_size, cqe, TRS_MAINT_MAX_CQE_SIZE); | 90 | + TRS_MAINT_MAX_CQE_SIZE); |
| 91 | if (ret != 0) { | 91 | if (ret != 0) { |
| 92 | trs_err("Memcpy failed. (ret=%d; cqe_size=%u)\n", ret, cq_info.cq_para.cqe_size); | 92 | trs_err("Memcpy failed. (ret=%d; cqe_size=%u)\n", ret, cq_info.cq_para.cqe_size); |
| 93 | return -EFAULT; | 93 | return -EFAULT; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | - trs_debug( | 97 | + trs_debug("Cq copy success. (devid=%u; tsid=%u; cqid=%u; chan_id=%u; cq_head=%u)\n", inst->devid, inst->tsid, cqid, |
| 98 | - "Cq copy success. (devid=%u; tsid=%u; cqid=%u; chan_id=%u; cq_head=%u)\n", inst->devid, inst->tsid, cqid, | 98 | + chan_id, cq_head); |
| 99 | - chan_id, cq_head); | ||
| 100 | return 0; | 99 | return 0; |
| 101 | } | 100 | } |
| @@ -46,9 +46,8 @@ static int trs_ub_get_eid_info(struct trs_ub_dev *ub_dev, struct ubcore_eid_info | |||
| 46 | ka_task_spin_lock(&dev->eid_table.lock); | 46 | ka_task_spin_lock(&dev->eid_table.lock); |
| 47 | if ((dev->eid_table.eid_entries == NULL) || (dev_info.eid_index[0] >= dev->eid_table.eid_cnt)) { | 47 | if ((dev->eid_table.eid_entries == NULL) || (dev_info.eid_index[0] >= dev->eid_table.eid_cnt)) { |
| 48 | ka_task_spin_unlock(&dev->eid_table.lock); | 48 | ka_task_spin_unlock(&dev->eid_table.lock); |
| 49 | - trs_err( | 49 | + trs_err("Invalid eid_table or eid_index. (devid=%u; eid_cnt=%u; eid_index=%u)\n", ub_dev->devid, |
| 50 | - "Invalid eid_table or eid_index. (devid=%u; eid_cnt=%u; eid_index=%u)\n", ub_dev->devid, | 50 | + dev->eid_table.eid_cnt, dev_info.eid_index[0]); |
| 51 | - dev->eid_table.eid_cnt, dev_info.eid_index[0]); | ||
| 52 | return -EINVAL; | 51 | return -EINVAL; |
| 53 | } | 52 | } |
| 54 | 53 | ||
| @@ -136,7 +135,10 @@ static struct trs_ub_dev *trs_ub_create_dev(u32 devid, u32 vfid) | |||
| 136 | return ub_dev; | 135 | return ub_dev; |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | -static void trs_ub_destroy_dev(struct trs_ub_dev *ub_dev) { ka_mm_vfree(ub_dev); } | 138 | +static void trs_ub_destroy_dev(struct trs_ub_dev *ub_dev) |
| 139 | +{ | ||
| 140 | + ka_mm_vfree(ub_dev); | ||
| 141 | +} | ||
| 140 | 142 | ||
| 141 | static void trs_ub_dev_release(struct kref_safe *ref) | 143 | static void trs_ub_dev_release(struct kref_safe *ref) |
| 142 | { | 144 | { |
| @@ -144,7 +146,10 @@ static void trs_ub_dev_release(struct kref_safe *ref) | |||
| 144 | trs_ub_destroy_dev(ub_dev); | 146 | trs_ub_destroy_dev(ub_dev); |
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | -void trs_put_ub_dev(struct trs_ub_dev *ub_dev) { kref_safe_put(&ub_dev->ref, trs_ub_dev_release); } | 149 | +void trs_put_ub_dev(struct trs_ub_dev *ub_dev) |
| 150 | +{ | ||
| 151 | + kref_safe_put(&ub_dev->ref, trs_ub_dev_release); | ||
| 152 | +} | ||
| 148 | 153 | ||
| 149 | struct trs_ub_dev *trs_get_ub_dev(u32 devid) | 154 | struct trs_ub_dev *trs_get_ub_dev(u32 devid) |
| 150 | { | 155 | { |
| @@ -267,5 +272,6 @@ void trs_ub_dev_uninit(u32 ts_inst_id) | |||
| 267 | } | 272 | } |
| 268 | DECLAER_FEATURE_AUTO_UNINIT_DEV(trs_ub_dev_uninit, FEATURE_LOADER_STAGE_3); | 273 | DECLAER_FEATURE_AUTO_UNINIT_DEV(trs_ub_dev_uninit, FEATURE_LOADER_STAGE_3); |
| 269 | 274 | ||
| 270 | -void trs_ub_comm_stub(void) {} | 275 | +void trs_ub_comm_stub(void) |
| 276 | +{} | ||
| 271 | 277 | ||
| @@ -29,21 +29,25 @@ | |||
| 29 | /* stub for david ub scene start */ | 29 | /* stub for david ub scene start */ |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | -struct devdrv_dma_prepare *devdrv_dma_link_prepare( | 32 | +struct devdrv_dma_prepare *devdrv_dma_link_prepare(u32 devid, enum devdrv_dma_data_type type, |
| 33 | - u32 devid, enum devdrv_dma_data_type type, struct devdrv_dma_node *dma_node, u32 node_cnt, u32 fill_status) | 33 | + struct devdrv_dma_node *dma_node, u32 node_cnt, u32 fill_status) |
| 34 | { | 34 | { |
| 35 | return NULL; | 35 | return NULL; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | -int devdrv_dma_link_free(struct devdrv_dma_prepare *dma_prepare) { return -1; } | 38 | +int devdrv_dma_link_free(struct devdrv_dma_prepare *dma_prepare) |
| 39 | +{ | ||
| 40 | + return -1; | ||
| 41 | +} | ||
| 39 | 42 | ||
| 40 | -ka_dma_addr_t hal_kernel_devdrv_dma_map_page( | 43 | +ka_dma_addr_t hal_kernel_devdrv_dma_map_page(ka_device_t *dev, ka_page_t *page, size_t offset, size_t size, |
| 41 | - ka_device_t *dev, ka_page_t *page, size_t offset, size_t size, ka_dma_data_direction_t dir) | 44 | + ka_dma_data_direction_t dir) |
| 42 | { | 45 | { |
| 43 | return (ka_dma_addr_t)NULL; | 46 | return (ka_dma_addr_t)NULL; |
| 44 | } | 47 | } |
| 45 | 48 | ||
| 46 | -void hal_kernel_devdrv_dma_unmap_page(ka_device_t *dev, ka_dma_addr_t addr, size_t size, ka_dma_data_direction_t dir) {} | 49 | +void hal_kernel_devdrv_dma_unmap_page(ka_device_t *dev, ka_dma_addr_t addr, size_t size, ka_dma_data_direction_t dir) |
| 50 | +{} | ||
| 47 | 51 | ||
| 48 | 52 | ||
| 49 | /* stub for david ub scene end */ | 53 | /* stub for david ub scene end */ |
| @@ -84,7 +88,10 @@ struct trs_dma_desc_node { | |||
| 84 | static struct trs_dma_desc_node *trs_dma_desc_node_del_one_from_root(struct trs_rb_info *rb_info, u32 root_index); | 88 | static struct trs_dma_desc_node *trs_dma_desc_node_del_one_from_root(struct trs_rb_info *rb_info, u32 root_index); |
| 85 | static void trs_sqe_update_desc_destroy_all(struct trs_rb_info *rb_info); | 89 | static void trs_sqe_update_desc_destroy_all(struct trs_rb_info *rb_info); |
| 86 | 90 | ||
| 87 | -static inline void trs_rb_get_root_index(u32 sqid, u32 *root_index) { *root_index = sqid % TRS_DMA_NODE_RB_ROOT_NUM; } | 91 | +static inline void trs_rb_get_root_index(u32 sqid, u32 *root_index) |
| 92 | +{ | ||
| 93 | + *root_index = sqid % TRS_DMA_NODE_RB_ROOT_NUM; | ||
| 94 | +} | ||
| 88 | 95 | ||
| 89 | static struct trs_rb_info *trs_rb_info_get(u32 devid) | 96 | static struct trs_rb_info *trs_rb_info_get(u32 devid) |
| 90 | { | 97 | { |
| @@ -111,9 +118,15 @@ static void trs_rb_info_release(struct kref_safe *kref) | |||
| 111 | trs_vfree(rb_info); | 118 | trs_vfree(rb_info); |
| 112 | } | 119 | } |
| 113 | 120 | ||
| 114 | -static void trs_rb_info_put(struct trs_rb_info *rb_info) { kref_safe_put(&rb_info->ref, trs_rb_info_release); } | 121 | +static void trs_rb_info_put(struct trs_rb_info *rb_info) |
| 122 | +{ | ||
| 123 | + kref_safe_put(&rb_info->ref, trs_rb_info_release); | ||
| 124 | +} | ||
| 115 | 125 | ||
| 116 | -static bool trs_rb_root_is_empty(ka_rb_root_t *root) { return KA_BASE_RB_EMPTY_ROOT(root); } | 126 | +static bool trs_rb_root_is_empty(ka_rb_root_t *root) |
| 127 | +{ | ||
| 128 | + return KA_BASE_RB_EMPTY_ROOT(root); | ||
| 129 | +} | ||
| 117 | 130 | ||
| 118 | typedef u64 (*rb_handle_func)(ka_rb_node_t *node); | 131 | typedef u64 (*rb_handle_func)(ka_rb_node_t *node); |
| 119 | static int trs_rb_insert(ka_rb_root_t *root, ka_rb_node_t *node, rb_handle_func get_handle) | 132 | static int trs_rb_insert(ka_rb_root_t *root, ka_rb_node_t *node, rb_handle_func get_handle) |
| @@ -209,9 +222,9 @@ static int trs_dma_desc_node_find(u32 devid, u32 sqid, u64 rb_handle, struct trs | |||
| 209 | return ret; | 222 | return ret; |
| 210 | } | 223 | } |
| 211 | 224 | ||
| 212 | -static int trs_dma_desc_node_create( | 225 | +static int trs_dma_desc_node_create(u32 devid, struct trs_dma_desc_addr_info *addr_info, |
| 213 | - u32 devid, struct trs_dma_desc_addr_info *addr_info, struct devdrv_dma_prepare *dma_prepare, | 226 | + struct devdrv_dma_prepare *dma_prepare, struct trs_dma_desc *dma_desc, |
| 214 | - struct trs_dma_desc *dma_desc, struct trs_security_src_info *src_info) | 227 | + struct trs_security_src_info *src_info) |
| 215 | { | 228 | { |
| 216 | struct trs_rb_info *rb_info = NULL; | 229 | struct trs_rb_info *rb_info = NULL; |
| 217 | struct trs_dma_desc_node *node = NULL; | 230 | struct trs_dma_desc_node *node = NULL; |
| @@ -266,14 +279,13 @@ static int trs_dma_desc_node_create( | |||
| 266 | return ret; | 279 | return ret; |
| 267 | } | 280 | } |
| 268 | 281 | ||
| 269 | -static void trs_dma_node_pack( | 282 | +static void trs_dma_node_pack(struct trs_dma_desc_addr_info *addr_info, struct trs_security_src_info *src_info, |
| 270 | - struct trs_dma_desc_addr_info *addr_info, struct trs_security_src_info *src_info, struct trs_chan_sq_info *sq_info, | 283 | + struct trs_chan_sq_info *sq_info, u32 sq_mem_side, struct devdrv_dma_node *dma_node) |
| 271 | - u32 sq_mem_side, struct devdrv_dma_node *dma_node) | ||
| 272 | { | 284 | { |
| 273 | if (sq_mem_side == TRS_CHAN_DEV_SVM_MEM) { | 285 | if (sq_mem_side == TRS_CHAN_DEV_SVM_MEM) { |
| 274 | dma_node->src_addr = (u64)src_info->dma_addr; | 286 | dma_node->src_addr = (u64)src_info->dma_addr; |
| 275 | - dma_node->dst_addr = | 287 | + dma_node->dst_addr = (uintptr_t)sq_info->sq_para.sq_que_uva + addr_info->sqeid * sq_info->sq_para.sqe_size + |
| 276 | - (uintptr_t)sq_info->sq_para.sq_que_uva + addr_info->sqeid * sq_info->sq_para.sqe_size + addr_info->offset; | 288 | + addr_info->offset; |
| 277 | dma_node->direction = DEVDRV_DMA_HOST_TO_DEVICE; | 289 | dma_node->direction = DEVDRV_DMA_HOST_TO_DEVICE; |
| 278 | } else { | 290 | } else { |
| 279 | dma_node->src_addr = addr_info->src_va; | 291 | dma_node->src_addr = addr_info->src_va; |
| @@ -309,9 +321,9 @@ static bool trs_is_rb_node_limited(u32 devid) | |||
| 309 | return false; | 321 | return false; |
| 310 | } | 322 | } |
| 311 | 323 | ||
| 312 | -static int trs_check_alloc_src_security_dma_addr( | 324 | +static int trs_check_alloc_src_security_dma_addr(u32 devid, struct trs_dma_desc_addr_info *addr_info, |
| 313 | - u32 devid, struct trs_dma_desc_addr_info *addr_info, struct trs_chan_sq_info *sq_info, bool is_src_secure, | 325 | + struct trs_chan_sq_info *sq_info, bool is_src_secure, |
| 314 | - struct trs_security_src_info *src_info) | 326 | + struct trs_security_src_info *src_info) |
| 315 | { | 327 | { |
| 316 | struct trs_id_inst inst = {0}; | 328 | struct trs_id_inst inst = {0}; |
| 317 | ka_device_t *dev = NULL; | 329 | ka_device_t *dev = NULL; |
| @@ -390,8 +402,8 @@ static void trs_check_free_src_security_dma_addr(u32 devid, struct trs_security_ | |||
| 390 | } | 402 | } |
| 391 | 403 | ||
| 392 | /* sqid sqeid --key */ | 404 | /* sqid sqeid --key */ |
| 393 | -int trs_sqe_update_desc_create( | 405 | +int trs_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 394 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc, bool is_src_secure) | 406 | + struct trs_dma_desc *dma_desc, bool is_src_secure) |
| 395 | { | 407 | { |
| 396 | struct devdrv_dma_prepare *dma_prepare = NULL; | 408 | struct devdrv_dma_prepare *dma_prepare = NULL; |
| 397 | struct devdrv_dma_node dma_node; | 409 | struct devdrv_dma_node dma_node; |
| @@ -414,9 +426,8 @@ int trs_sqe_update_desc_create( | |||
| 414 | } | 426 | } |
| 415 | 427 | ||
| 416 | if (addr_info->sqeid >= sq_info.sq_para.sq_depth) { | 428 | if (addr_info->sqeid >= sq_info.sq_para.sq_depth) { |
| 417 | - trs_err( | 429 | + trs_err("Addr info invalid. (devid=%u; tsid=%u; sqeid=%u; depth=%u)\n", devid, tsid, addr_info->sqeid, |
| 418 | - "Addr info invalid. (devid=%u; tsid=%u; sqeid=%u; depth=%u)\n", devid, tsid, addr_info->sqeid, | 430 | + sq_info.sq_para.sq_depth); |
| 419 | - sq_info.sq_para.sq_depth); | ||
| 420 | return -EINVAL; | 431 | return -EINVAL; |
| 421 | } | 432 | } |
| 422 | 433 | ||
| @@ -441,8 +452,8 @@ int trs_sqe_update_desc_create( | |||
| 441 | } | 452 | } |
| 442 | 453 | ||
| 443 | trs_dma_node_pack(addr_info, &src_info, &sq_info, sq_mem_side, &dma_node); | 454 | trs_dma_node_pack(addr_info, &src_info, &sq_info, sq_mem_side, &dma_node); |
| 444 | - dma_prepare = devdrv_dma_link_prepare( | 455 | + dma_prepare = devdrv_dma_link_prepare(devid, DEVDRV_DMA_DATA_TRAFFIC, &dma_node, dma_node_num, |
| 445 | - devid, DEVDRV_DMA_DATA_TRAFFIC, &dma_node, dma_node_num, DEVDRV_DMA_DESC_FILL_FINISH); | 456 | + DEVDRV_DMA_DESC_FILL_FINISH); |
| 446 | if (dma_prepare == NULL) { | 457 | if (dma_prepare == NULL) { |
| 447 | trs_check_free_src_security_dma_addr(devid, &src_info); | 458 | trs_check_free_src_security_dma_addr(devid, &src_info); |
| 448 | trs_err("Dma_link_prepare alloc failed. (devid=%u)\n", devid); | 459 | trs_err("Dma_link_prepare alloc failed. (devid=%u)\n", devid); |
| @@ -459,15 +470,14 @@ int trs_sqe_update_desc_create( | |||
| 459 | return ret; | 470 | return ret; |
| 460 | } | 471 | } |
| 461 | } | 472 | } |
| 462 | - trs_debug( | 473 | + trs_debug("Dma desc create. (devid=%u; sqid=%u; sqeid=%u; ssid=%u; offset=%u; size=%u; sq_mem_side=%u)\n", devid, |
| 463 | - "Dma desc create. (devid=%u; sqid=%u; sqeid=%u; ssid=%u; offset=%u; size=%u; sq_mem_side=%u)\n", devid, | 474 | + addr_info->sqid, addr_info->sqeid, addr_info->passid, addr_info->offset, addr_info->size, sq_mem_side); |
| 464 | - addr_info->sqid, addr_info->sqeid, addr_info->passid, addr_info->offset, addr_info->size, sq_mem_side); | ||
| 465 | return ret; | 475 | return ret; |
| 466 | } | 476 | } |
| 467 | 477 | ||
| 468 | /* for chips before cloudv4 */ | 478 | /* for chips before cloudv4 */ |
| 469 | -int hal_kernel_sqe_update_desc_create( | 479 | +int hal_kernel_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 470 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc) | 480 | + struct trs_dma_desc *dma_desc) |
| 471 | { | 481 | { |
| 472 | u64 rb_handle = 0; | 482 | u64 rb_handle = 0; |
| 473 | int ret = 0; | 483 | int ret = 0; |
| @@ -13,7 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | -int trs_sqe_update_desc_create( | 16 | +int trs_sqe_update_desc_create(u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, |
| 17 | - u32 devid, u32 tsid, struct trs_dma_desc_addr_info *addr_info, struct trs_dma_desc *dma_desc, bool is_src_secure); | 17 | + struct trs_dma_desc *dma_desc, bool is_src_secure); |
| 18 | 18 | ||
| 19 | 19 | ||
| @@ -49,9 +49,8 @@ int trs_core_ops_stars_soc_res_ctrl(struct trs_id_inst *inst, u32 id_type, u32 i | |||
| 49 | return ret; | 49 | return ret; |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | - trs_debug( | 52 | + trs_debug("devid=%u; phy_devid=%u; tsid=%u; id=%u; id_type=%u; cmd=%u\n", inst->devid, dev_para.phy_devid, |
| 53 | - "devid=%u; phy_devid=%u; tsid=%u; id=%u; id_type=%u; cmd=%u\n", inst->devid, dev_para.phy_devid, inst->tsid, id, | 53 | + inst->tsid, id, id_type, cmd); |
| 54 | - id_type, cmd); | ||
| 55 | trs_id_inst_pack(&pm_inst, dev_para.phy_devid, inst->tsid); | 54 | trs_id_inst_pack(&pm_inst, dev_para.phy_devid, inst->tsid); |
| 56 | return trs_stars_soc_res_ctrl(&pm_inst, id_type, id, trs_res_cmd_trans[cmd]); | 55 | return trs_stars_soc_res_ctrl(&pm_inst, id_type, id, trs_res_cmd_trans[cmd]); |
| 57 | } | 56 | } |
| @@ -106,7 +106,10 @@ static struct devdrv_non_trans_msg_chan_info trs_host_msg_chan_info = { | |||
| 106 | .rx_msg_process = trs_host_msg_chan_recv, | 106 | .rx_msg_process = trs_host_msg_chan_recv, |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | -struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void) { return &trs_host_msg_chan_info; } | 109 | +struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void) |
| 110 | +{ | ||
| 111 | + return &trs_host_msg_chan_info; | ||
| 112 | +} | ||
| 110 | 113 | ||
| 111 | /* | 114 | /* |
| 112 | module_feature_auto_init_dev adds features as follows: | 115 | module_feature_auto_init_dev adds features as follows: |
| @@ -113,8 +113,8 @@ int trs_ub_get_sq_head_paddr(struct trs_id_inst *inst, u32 sq_id, u64 *paddr) | |||
| 113 | return -ENODEV; | 113 | return -ENODEV; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | - *paddr = | 116 | + *paddr = (u64)ka_mm_page_to_phys(ub_dev->sq_seg.seg_pages) + sq_id * TRS_UB_SQ_BUFFER_SIZE + |
| 117 | - (u64)ka_mm_page_to_phys(ub_dev->sq_seg.seg_pages) + sq_id * TRS_UB_SQ_BUFFER_SIZE + TRS_UB_SQ_TAIL_BUFFER_SIZE; | 117 | + TRS_UB_SQ_TAIL_BUFFER_SIZE; |
| 118 | trs_put_ub_dev(ub_dev); | 118 | trs_put_ub_dev(ub_dev); |
| 119 | 119 | ||
| 120 | return 0; | 120 | return 0; |
| @@ -479,8 +479,8 @@ static void trs_ub_cq_dispatch_task(unsigned long data) | |||
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | jetty_info->cq_num = 0; | 481 | jetty_info->cq_num = 0; |
| 482 | - (void)memset_s( | 482 | + (void)memset_s((void *)jetty_info->cq_id_bucket, sizeof(jetty_info->cq_id_bucket), 0, |
| 483 | - (void *)jetty_info->cq_id_bucket, sizeof(jetty_info->cq_id_bucket), 0, sizeof(jetty_info->cq_id_bucket)); | 483 | + sizeof(jetty_info->cq_id_bucket)); |
| 484 | for (i = 0; i < cr_num; i++) { | 484 | for (i = 0; i < cr_num; i++) { |
| 485 | u32 cq_id = (u32)(jetty_info->cr[i].imm_data); | 485 | u32 cq_id = (u32)(jetty_info->cr[i].imm_data); |
| 486 | u32 buff_index = jetty_info->cr[i].user_ctx; | 486 | u32 buff_index = jetty_info->cr[i].user_ctx; |
| @@ -507,13 +507,12 @@ static void trs_ub_cq_dispatch_task(unsigned long data) | |||
| 507 | jetty_info->cq_num++; | 507 | jetty_info->cq_num++; |
| 508 | jetty_info->cq_id_bucket[cq_id] = 1; | 508 | jetty_info->cq_id_bucket[cq_id] = 1; |
| 509 | } | 509 | } |
| 510 | - trs_debug( | 510 | + trs_debug("Cq info. (devid=%u; cq_id=%u; cq_num=%u; buff_index=%u; jfc_id=%u)\n", inst.devid, cq_id, |
| 511 | - "Cq info. (devid=%u; cq_id=%u; cq_num=%u; buff_index=%u; jfc_id=%u)\n", inst.devid, cq_id, | 511 | + jetty_info->cq_num, buff_index, jetty_info->cq_jfc->id); |
| 512 | - jetty_info->cq_num, buff_index, jetty_info->cq_jfc->id); | ||
| 513 | 512 | ||
| 514 | import_jfr_seg: | 513 | import_jfr_seg: |
| 515 | - ret = trs_ub_import_jfr_segment( | 514 | + ret = trs_ub_import_jfr_segment(jetty_info->cq_jfr, jetty_info->cq_seg.target_seg, buff_index, |
| 516 | - jetty_info->cq_jfr, jetty_info->cq_seg.target_seg, buff_index, TRS_UB_CQ_RECV_BUFFER_SIZE); | 515 | + TRS_UB_CQ_RECV_BUFFER_SIZE); |
| 517 | if (ret != 0) { | 516 | if (ret != 0) { |
| 518 | trs_err("Reimport jfr segment failed. (index=%d; len=%u)\n", buff_index, TRS_UB_CQ_RECV_BUFFER_SIZE); | 517 | trs_err("Reimport jfr segment failed. (index=%d; len=%u)\n", buff_index, TRS_UB_CQ_RECV_BUFFER_SIZE); |
| 519 | } | 518 | } |
| @@ -546,8 +545,8 @@ int trs_ub_request_cq_update_irq(struct trs_id_inst *inst, int irq_type, int irq | |||
| 546 | ub_dev->cq_irq_para = attr->para; | 545 | ub_dev->cq_irq_para = attr->para; |
| 547 | 546 | ||
| 548 | for (i = 0; i < TRS_VF_MAX_NUM; i++) { | 547 | for (i = 0; i < TRS_VF_MAX_NUM; i++) { |
| 549 | - ka_system_tasklet_init( | 548 | + ka_system_tasklet_init(&ub_dev->jetty_info[i].cq_dispatch_task, trs_ub_cq_dispatch_task, |
| 550 | - &ub_dev->jetty_info[i].cq_dispatch_task, trs_ub_cq_dispatch_task, (uintptr_t)(&ub_dev->jetty_info[i])); | 549 | + (uintptr_t)(&ub_dev->jetty_info[i])); |
| 551 | } | 550 | } |
| 552 | trs_put_ub_dev(ub_dev); | 551 | trs_put_ub_dev(ub_dev); |
| 553 | return 0; | 552 | return 0; |
| @@ -665,8 +664,8 @@ int trs_ub_cq_jetty_init(struct trs_ub_dev *ub_dev, u32 vfid) | |||
| 665 | goto destroy_jfc; | 664 | goto destroy_jfc; |
| 666 | } | 665 | } |
| 667 | 666 | ||
| 668 | - ret = trs_ub_import_jfr_all_segment( | 667 | + ret = trs_ub_import_jfr_all_segment(jfr, ub_dev->jetty_info[vfid].cq_seg.target_seg, TRS_UB_CQ_RECV_BUFFER_NUM, |
| 669 | - jfr, ub_dev->jetty_info[vfid].cq_seg.target_seg, TRS_UB_CQ_RECV_BUFFER_NUM, TRS_UB_CQ_RECV_BUFFER_SIZE); | 668 | + TRS_UB_CQ_RECV_BUFFER_SIZE); |
| 670 | if (ret != 0) { | 669 | if (ret != 0) { |
| 671 | trs_err("Import cq jfr segment failed. (devid=%u)\n", ub_dev->devid); | 670 | trs_err("Import cq jfr segment failed. (devid=%u)\n", ub_dev->devid); |
| 672 | goto destroy_jfr; | 671 | goto destroy_jfr; |
| @@ -742,8 +741,8 @@ static void trs_ub_unimport_reg_segment(struct trs_ub_dev *ub_dev) | |||
| 742 | ub_dev->cnt_notify_tseg = NULL; | 741 | ub_dev->cnt_notify_tseg = NULL; |
| 743 | } | 742 | } |
| 744 | 743 | ||
| 745 | -static int trs_ub_stars_reg_op(struct trs_id_inst *inst, enum trs_id_type id_type, | 744 | +static int trs_ub_stars_reg_op(struct trs_id_inst *inst, enum trs_id_type id_type, struct trs_ub_reg_cfg_para *para, |
| 746 | - struct trs_ub_reg_cfg_para *para, enum devdrv_urma_copy_dir dir) | 745 | + enum devdrv_urma_copy_dir dir) |
| 747 | { | 746 | { |
| 748 | struct trs_ub_dev *ub_dev = NULL; | 747 | struct trs_ub_dev *ub_dev = NULL; |
| 749 | struct devdrv_urma_copy local, peer; | 748 | struct devdrv_urma_copy local, peer; |
| @@ -782,9 +781,9 @@ static int trs_ub_stars_reg_op(struct trs_id_inst *inst, enum trs_id_type id_typ | |||
| 782 | 781 | ||
| 783 | ret = devdrv_urma_copy(inst->devid, URMA_CHAN_TSDRV, dir, &local, &peer); | 782 | ret = devdrv_urma_copy(inst->devid, URMA_CHAN_TSDRV, dir, &local, &peer); |
| 784 | if (ret != 0) { | 783 | if (ret != 0) { |
| 785 | - trs_err( | 784 | + trs_err("Failed to copy with urma. (ret=%d; devid=%u; dir=%d; type=%d; len=%lu; src_offset=0x%llx; " |
| 786 | - "Failed to copy with urma. (ret=%d; devid=%u; dir=%d; type=%d; len=%lu; src_offset=0x%llx; dst_offset=0x%llx)\n", | 785 | + "dst_offset=0x%llx)\n", |
| 787 | - ret, inst->devid, dir, id_type, para->size, para->src_offset, para->dst_offset); | 786 | + ret, inst->devid, dir, id_type, para->size, para->src_offset, para->dst_offset); |
| 788 | trs_put_ub_dev(ub_dev); | 787 | trs_put_ub_dev(ub_dev); |
| 789 | return ret; | 788 | return ret; |
| 790 | } | 789 | } |
| @@ -793,9 +792,8 @@ static int trs_ub_stars_reg_op(struct trs_id_inst *inst, enum trs_id_type id_typ | |||
| 793 | (void)memcpy_s(para->src, para->size, vaddr, para->size); | 792 | (void)memcpy_s(para->src, para->size, vaddr, para->size); |
| 794 | } | 793 | } |
| 795 | 794 | ||
| 796 | - trs_debug( | 795 | + trs_debug("Reg op success. (devid=%u; dir=%d; id_type=%d; len=%lu; src_offset=0x%llx; dst_offset=0x%llx)\n", |
| 797 | - "Reg op success. (devid=%u; dir=%d; id_type=%d; len=%lu; src_offset=0x%llx; dst_offset=0x%llx)\n", | 796 | + inst->devid, dir, id_type, para->size, para->src_offset, para->dst_offset); |
| 798 | - inst->devid, dir, id_type, para->size, para->src_offset, para->dst_offset); | ||
| 799 | trs_put_ub_dev(ub_dev); | 797 | trs_put_ub_dev(ub_dev); |
| 800 | return 0; | 798 | return 0; |
| 801 | } | 799 | } |
| @@ -832,22 +830,19 @@ int trs_ub_stars_soc_res_ctrl(struct trs_id_inst *inst, u32 type, u32 id, u32 cm | |||
| 832 | para.dst_offset = reg_offset; | 830 | para.dst_offset = reg_offset; |
| 833 | ret = trs_ub_stars_reg_op(inst, type, ¶, LOCAL_TO_PEER); | 831 | ret = trs_ub_stars_reg_op(inst, type, ¶, LOCAL_TO_PEER); |
| 834 | if (ret != 0) { | 832 | if (ret != 0) { |
| 835 | - trs_err( | 833 | + trs_err("Failed to cfg reg by urma. (ret=%d; devid=%u; type=%u; id=%u; len=%lu; dst_offset=0x%llx)\n", ret, |
| 836 | - "Failed to cfg reg by urma. (ret=%d; devid=%u; type=%u; id=%u; len=%lu; dst_offset=0x%llx)\n", ret, | 834 | + inst->devid, type, id, para.size, para.dst_offset); |
| 837 | - inst->devid, type, id, para.size, para.dst_offset); | ||
| 838 | return ret; | 835 | return ret; |
| 839 | } | 836 | } |
| 840 | 837 | ||
| 841 | - trs_debug( | 838 | + trs_debug("Reg cfg success. (devid=%u; type=%u; cmd=%u; id=%u; len=%lu; dst_offset=0x%llx)\n", inst->devid, type, |
| 842 | - "Reg cfg success. (devid=%u; type=%u; cmd=%u; id=%u; len=%lu; dst_offset=0x%llx)\n", inst->devid, type, cmd, id, | 839 | + cmd, id, para.size, para.dst_offset); |
| 843 | - para.size, para.dst_offset); | ||
| 844 | return 0; | 840 | return 0; |
| 845 | } | 841 | } |
| 846 | 842 | ||
| 847 | 843 | ||
| 848 | /* op: 0 for head, 1 for tail; dir: LOCAL_TO_PEER for set, PEER_TO_LOCAL for get */ | 844 | /* op: 0 for head, 1 for tail; dir: LOCAL_TO_PEER for set, PEER_TO_LOCAL for get */ |
| 849 | -int trs_ub_sq_head_tail_op(struct trs_id_inst *inst, u32 sq_id, u32 *value, int op, | 845 | +int trs_ub_sq_head_tail_op(struct trs_id_inst *inst, u32 sq_id, u32 *value, int op, enum devdrv_urma_copy_dir dir) |
| 850 | - enum devdrv_urma_copy_dir dir) | ||
| 851 | { | 846 | { |
| 852 | struct trs_ub_reg_cfg_para para = {0}; | 847 | struct trs_ub_reg_cfg_para para = {0}; |
| 853 | u64 sq_reg_src_offset = 0; | 848 | u64 sq_reg_src_offset = 0; |
| @@ -936,17 +931,16 @@ int trs_ub_bind_jetty(struct trs_ub_dev *ub_dev, u32 vfid) | |||
| 936 | jetty_info->sq_jfr_id = ub_dev->jetty_info[vfid].sq_jfr->jfr_id.id; | 931 | jetty_info->sq_jfr_id = ub_dev->jetty_info[vfid].sq_jfr->jfr_id.id; |
| 937 | jetty_info->eid_info = ub_dev->eid_info; | 932 | jetty_info->eid_info = ub_dev->eid_info; |
| 938 | jetty_info->token_value = ub_dev->token_val; | 933 | jetty_info->token_value = ub_dev->token_val; |
| 939 | - (void)memcpy_s( | 934 | + (void)memcpy_s(&(jetty_info->sq_seg), sizeof(struct ubcore_seg), &(ub_dev->sq_seg.target_seg->seg), |
| 940 | - &(jetty_info->sq_seg), sizeof(struct ubcore_seg), &(ub_dev->sq_seg.target_seg->seg), sizeof(struct ubcore_seg)); | 935 | + sizeof(struct ubcore_seg)); |
| 941 | - (void)memcpy_s( | 936 | + (void)memcpy_s(&(jetty_info->cq_seg), sizeof(struct ubcore_seg), &(ub_dev->jetty_info[vfid].cq_seg.target_seg->seg), |
| 942 | - &(jetty_info->cq_seg), sizeof(struct ubcore_seg), &(ub_dev->jetty_info[vfid].cq_seg.target_seg->seg), | 937 | + sizeof(struct ubcore_seg)); |
| 943 | - sizeof(struct ubcore_seg)); | ||
| 944 | jetty_info->vfid = vfid; | 938 | jetty_info->vfid = vfid; |
| 945 | 939 | ||
| 946 | ret = trs_host_msg_send(devid, &msg, sizeof(struct trs_msg_data)); | 940 | ret = trs_host_msg_send(devid, &msg, sizeof(struct trs_msg_data)); |
| 947 | if (ret != 0) { | 941 | if (ret != 0) { |
| 948 | - trs_err( | 942 | + trs_err("Fail send jetty bind msg. (devid=%u; vfid=%u; ret=%d; result=%d)\n", devid, vfid, ret, |
| 949 | - "Fail send jetty bind msg. (devid=%u; vfid=%u; ret=%d; result=%d)\n", devid, vfid, ret, msg.header.result); | 943 | + msg.header.result); |
| 950 | return ret; | 944 | return ret; |
| 951 | } | 945 | } |
| 952 | 946 | ||
| @@ -1102,5 +1096,6 @@ void trs_ub_dev_uninit_with_group(u32 devid, u32 vfid) | |||
| 1102 | } | 1096 | } |
| 1103 | } | 1097 | } |
| 1104 | 1098 | ||
| 1105 | -void trs_ub_host_stub(void) {} | 1099 | +void trs_ub_host_stub(void) |
| 1100 | +{} | ||
| 1106 | 1101 | ||
| @@ -29,20 +29,19 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | -static const ka_pci_device_id_t sec_eh_adapt_tbl[] = { | 32 | +static const ka_pci_device_id_t sec_eh_adapt_tbl[] = {{KA_PCI_VDEVICE(HUAWEI, 0xd802), 0}, |
| 33 | - {KA_PCI_VDEVICE(HUAWEI, 0xd802), 0}, | 33 | + {KA_PCI_VDEVICE(HUAWEI, 0xd803), 0}, |
| 34 | - {KA_PCI_VDEVICE(HUAWEI, 0xd803), 0}, | 34 | + {KA_PCI_VDEVICE(HUAWEI, 0xd804), 0}, |
| 35 | - {KA_PCI_VDEVICE(HUAWEI, 0xd804), 0}, | 35 | + {KA_PCI_VDEVICE(HUAWEI, 0xd806), 0}, |
| 36 | - {KA_PCI_VDEVICE(HUAWEI, 0xd806), 0}, | 36 | + {KA_PCI_VDEVICE(HUAWEI, 0xd807), 0}, |
| 37 | - {KA_PCI_VDEVICE(HUAWEI, 0xd807), 0}, | 37 | + {KA_PCI_VDEVICE(HUAWEI, 0xd808), 0}, |
| 38 | - {KA_PCI_VDEVICE(HUAWEI, 0xd808), 0}, | 38 | + {0x20C6, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 39 | - {0x20C6, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 39 | + {0x203F, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 40 | - {0x203F, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 40 | + {0x20E9, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 41 | - {0x20E9, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 41 | + {0x20C6, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 42 | - {0x20C6, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 42 | + {0x203F, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 43 | - {0x203F, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 43 | + {0x20E9, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 44 | - {0x20E9, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 44 | + {}}; |
| 45 | - {}}; | ||
| 46 | KA_MODULE_DEVICE_TABLE(pci, sec_eh_adapt_tbl); | 45 | KA_MODULE_DEVICE_TABLE(pci, sec_eh_adapt_tbl); |
| 47 | 46 | ||
| 48 | static const trs_msg_rdv_func_t rcv_ops[TRS_MSG_MAX] = { | 47 | static const trs_msg_rdv_func_t rcv_ops[TRS_MSG_MAX] = { |
| @@ -83,7 +82,10 @@ static struct devdrv_non_trans_msg_chan_info trs_sec_eh_msg_chan_info = { | |||
| 83 | .rx_msg_process = trs_sec_eh_msg_chan_recv, | 82 | .rx_msg_process = trs_sec_eh_msg_chan_recv, |
| 84 | }; | 83 | }; |
| 85 | 84 | ||
| 86 | -struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void) { return &trs_sec_eh_msg_chan_info; } | 85 | +struct devdrv_non_trans_msg_chan_info *trs_get_msg_chan_info(void) |
| 86 | +{ | ||
| 87 | + return &trs_sec_eh_msg_chan_info; | ||
| 88 | +} | ||
| 87 | 89 | ||
| 88 | /* | 90 | /* |
| 89 | * module_feature_auto_init_dev adds features as follows: | 91 | * module_feature_auto_init_dev adds features as follows: |
| @@ -50,8 +50,8 @@ int trs_sec_eh_chan_sqe_update(struct trs_id_inst *inst, struct trs_sqe_update_i | |||
| 50 | trs_err("Sqe copy fail. (ret=%d; max_size=0x%ld; sqe_size=0x%d)\n", ret, data_size, TRS_HW_SQE_SIZE); | 50 | trs_err("Sqe copy fail. (ret=%d; max_size=0x%ld; sqe_size=0x%d)\n", ret, data_size, TRS_HW_SQE_SIZE); |
| 51 | return ret; | 51 | return ret; |
| 52 | } | 52 | } |
| 53 | - ret = trs_sec_eh_vpc_msg_send( | 53 | + ret = trs_sec_eh_vpc_msg_send(inst->devid, (void *)&sqe_update, |
| 54 | - inst->devid, (void *)&sqe_update, sizeof(struct trs_sec_eh_sq_update_info) - (data_size - TRS_HW_SQE_SIZE)); | 54 | + sizeof(struct trs_sec_eh_sq_update_info) - (data_size - TRS_HW_SQE_SIZE)); |
| 55 | if ((ret != 0) || (sqe_update.head.result != 0)) { | 55 | if ((ret != 0) || (sqe_update.head.result != 0)) { |
| 56 | trs_err("Vpc send fail. (devid=%u; ret=%d; result=%d)\n", inst->devid, ret, sqe_update.head.result); | 56 | trs_err("Vpc send fail. (devid=%u; ret=%d; result=%d)\n", inst->devid, ret, sqe_update.head.result); |
| 57 | return -EFAULT; | 57 | return -EFAULT; |
| @@ -59,8 +59,8 @@ int trs_sec_eh_chan_sqe_update(struct trs_id_inst *inst, struct trs_sqe_update_i | |||
| 59 | return 0; | 59 | return 0; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | -int trs_sec_eh_chan_stars_ops_query_sqcq( | 62 | +int trs_sec_eh_chan_stars_ops_query_sqcq(struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, |
| 63 | - struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, u64 *value) | 63 | + u64 *value) |
| 64 | { | 64 | { |
| 65 | return trs_chan_ops_query_sqcq(inst, types, id, cmd, value); | 65 | return trs_chan_ops_query_sqcq(inst, types, id, cmd, value); |
| 66 | } | 66 | } |
| @@ -21,6 +21,6 @@ int trs_chan_init(u32 ts_inst_id); | |||
| 21 | void trs_chan_uninit(u32 ts_inst_id); | 21 | void trs_chan_uninit(u32 ts_inst_id); |
| 22 | 22 | ||
| 23 | int trs_sec_eh_chan_sqe_update(struct trs_id_inst *inst, struct trs_sqe_update_info *update_info); | 23 | int trs_sec_eh_chan_sqe_update(struct trs_id_inst *inst, struct trs_sqe_update_info *update_info); |
| 24 | -int trs_sec_eh_chan_stars_ops_query_sqcq( | 24 | +int trs_sec_eh_chan_stars_ops_query_sqcq(struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, |
| 25 | - struct trs_id_inst *inst, struct trs_chan_type *types, u32 id, u32 cmd, u64 *value); | 25 | + u64 *value); |
| 26 | 26 | ||
| @@ -20,7 +20,10 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | -static int trs_vpc_msg_recv(u32 devid, u32 fid, struct vmng_rx_msg_proc_info *proc_info) { return -EPERM; } | 23 | +static int trs_vpc_msg_recv(u32 devid, u32 fid, struct vmng_rx_msg_proc_info *proc_info) |
| 24 | +{ | ||
| 25 | + return -EPERM; | ||
| 26 | +} | ||
| 24 | 27 | ||
| 25 | static struct vmng_vpc_client trs_vpc_client = { | 28 | static struct vmng_vpc_client trs_vpc_client = { |
| 26 | .vpc_type = VMNG_VPC_TYPE_TSDRV, | 29 | .vpc_type = VMNG_VPC_TYPE_TSDRV, |
| @@ -29,17 +29,16 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | -static const ka_pci_device_id_t sec_eh_agent_tbl[] = { | 32 | +static const ka_pci_device_id_t sec_eh_agent_tbl[] = {{KA_PCI_VDEVICE(HUAWEI, 0xd802), 0}, |
| 33 | - {KA_PCI_VDEVICE(HUAWEI, 0xd802), 0}, | 33 | + {KA_PCI_VDEVICE(HUAWEI, 0xd803), 0}, |
| 34 | - {KA_PCI_VDEVICE(HUAWEI, 0xd803), 0}, | 34 | + {KA_PCI_VDEVICE(HUAWEI, 0xd804), 0}, |
| 35 | - {KA_PCI_VDEVICE(HUAWEI, 0xd804), 0}, | 35 | + {0x20C6, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 36 | - {0x20C6, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 36 | + {0x203F, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 37 | - {0x203F, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 37 | + {0x20E9, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 38 | - {0x20E9, 0xd500, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 38 | + {0x20C6, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 39 | - {0x20C6, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 39 | + {0x203F, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 40 | - {0x203F, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 40 | + {0x20E9, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, |
| 41 | - {0x20E9, 0xd802, KA_PCI_ANY_ID, KA_PCI_ANY_ID, 0, 0, 0}, | 41 | + {}}; |
| 42 | - {}}; | ||
| 43 | KA_MODULE_DEVICE_TABLE(pci, sec_eh_agent_tbl); | 42 | KA_MODULE_DEVICE_TABLE(pci, sec_eh_agent_tbl); |
| 44 | 43 | ||
| 45 | static ka_mutex_t sec_eh_cfg_mutex; | 44 | static ka_mutex_t sec_eh_cfg_mutex; |
| @@ -52,9 +51,8 @@ static int trx_sec_eh_msg_para_check(u32 dev_id, u32 fid, struct vmng_rx_msg_pro | |||
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | if (proc_info->in_data_len < sizeof(struct trs_sec_eh_msg_head)) { | 53 | if (proc_info->in_data_len < sizeof(struct trs_sec_eh_msg_head)) { |
| 55 | - trs_err( | 54 | + trs_err("Check failed. (in_data_len=%u; expected_len=%u\n", proc_info->in_data_len, |
| 56 | - "Check failed. (in_data_len=%u; expected_len=%u\n", proc_info->in_data_len, | 55 | + (u32)sizeof(struct trs_sec_eh_msg_head)); |
| 57 | - (u32)sizeof(struct trs_sec_eh_msg_head)); | ||
| 58 | return -EINVAL; | 56 | return -EINVAL; |
| 59 | } | 57 | } |
| 60 | 58 | ||
| @@ -124,13 +122,13 @@ static void trs_sec_eh_irq_unrequest(u32 devid) | |||
| 124 | } | 122 | } |
| 125 | 123 | ||
| 126 | for (i = 0; i < inject->sq_trigger_irq_cnt; i++) { | 124 | for (i = 0; i < inject->sq_trigger_irq_cnt; i++) { |
| 127 | - (void)devdrv_unregister_irq_by_vector_index( | 125 | + (void)devdrv_unregister_irq_by_vector_index(devid, inject->sq_trigger[i].vector_id, |
| 128 | - devid, inject->sq_trigger[i].vector_id, (void *)&inject->sq_trigger[i]); | 126 | + (void *)&inject->sq_trigger[i]); |
| 129 | } | 127 | } |
| 130 | 128 | ||
| 131 | for (i = 0; i < inject->cq_update_irq_cnt; i++) { | 129 | for (i = 0; i < inject->cq_update_irq_cnt; i++) { |
| 132 | - (void)devdrv_unregister_irq_by_vector_index( | 130 | + (void)devdrv_unregister_irq_by_vector_index(devid, inject->cq_update[i].vector_id, |
| 133 | - devid, inject->cq_update[i].vector_id, (void *)&inject->cq_update[i]); | 131 | + (void *)&inject->cq_update[i]); |
| 134 | } | 132 | } |
| 135 | 133 | ||
| 136 | trs_inject_irq[devid] = NULL; | 134 | trs_inject_irq[devid] = NULL; |
| @@ -157,8 +155,8 @@ static int trs_sec_eh_trigger_irq_request(u32 devid, struct trs_inject_irq_info | |||
| 157 | inject->sq_trigger[0].devid = devid; | 155 | inject->sq_trigger[0].devid = devid; |
| 158 | inject->sq_trigger[0].vector_id = irq; // hw irq | 156 | inject->sq_trigger[0].vector_id = irq; // hw irq |
| 159 | inject->sq_trigger[0].irq = irq_request; | 157 | inject->sq_trigger[0].irq = irq_request; |
| 160 | - ret = devdrv_register_irq_by_vector_index( | 158 | + ret = devdrv_register_irq_by_vector_index(devid, irq, trs_sec_eh_irq_inject_proc, (void *)&inject->sq_trigger[0], |
| 161 | - devid, irq, trs_sec_eh_irq_inject_proc, (void *)&inject->sq_trigger[0], "sq_trigger_inject"); | 159 | + "sq_trigger_inject"); |
| 162 | if (ret != 0) { | 160 | if (ret != 0) { |
| 163 | trs_err("Request irq failed. (irq=%u; ret=%d)\n", irq, ret); | 161 | trs_err("Request irq failed. (irq=%u; ret=%d)\n", irq, ret); |
| 164 | return ret; | 162 | return ret; |
| @@ -218,8 +216,8 @@ static int trs_sec_eh_irq_request(u32 devid) | |||
| 218 | inject->cq_update[i].devid = devid; | 216 | inject->cq_update[i].devid = devid; |
| 219 | inject->cq_update[i].vector_id = irq; // hw irq | 217 | inject->cq_update[i].vector_id = irq; // hw irq |
| 220 | inject->cq_update[i].irq = irq_request; | 218 | inject->cq_update[i].irq = irq_request; |
| 221 | - ret = devdrv_register_irq_by_vector_index( | 219 | + ret = devdrv_register_irq_by_vector_index(devid, irq, trs_sec_eh_irq_inject_proc, (void *)&inject->cq_update[i], |
| 222 | - devid, irq, trs_sec_eh_irq_inject_proc, (void *)&inject->cq_update[i], "cqe_done_inject"); | 220 | + "cqe_done_inject"); |
| 223 | if (ret != 0) { | 221 | if (ret != 0) { |
| 224 | trs_err("Request irq failed. (irq=%u)\n", irq); | 222 | trs_err("Request irq failed. (irq=%u)\n", irq); |
| 225 | goto free_irq; | 223 | goto free_irq; |
| @@ -56,8 +56,8 @@ static int trs_sec_eh_mb_send(u32 devid, struct vmng_rx_msg_proc_info *proc_info | |||
| 56 | 56 | ||
| 57 | trs_id_inst_pack(&inst, devid, mb->head.tsid); | 57 | trs_id_inst_pack(&inst, devid, mb->head.tsid); |
| 58 | if ((mb_head->cmd_type == TRS_MBOX_RPC_CALL) || (mb_head->cmd_type == TRS_MBOX_DSMI_RPC_CALL)) { | 58 | if ((mb_head->cmd_type == TRS_MBOX_RPC_CALL) || (mb_head->cmd_type == TRS_MBOX_DSMI_RPC_CALL)) { |
| 59 | - return trs_mbox_send_rpc_call_msg( | 59 | + return trs_mbox_send_rpc_call_msg(&inst, 0, (void *)mb->data, sizeof(struct trs_normal_cqsq_mailbox), |
| 60 | - &inst, 0, (void *)mb->data, sizeof(struct trs_normal_cqsq_mailbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 60 | + TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | if (trs_sec_eh_mb_not_support(mb_head->cmd_type)) { | 63 | if (trs_sec_eh_mb_not_support(mb_head->cmd_type)) { |
| @@ -70,8 +70,8 @@ static int trs_sec_eh_mb_send(u32 devid, struct vmng_rx_msg_proc_info *proc_info | |||
| 70 | return ret; | 70 | return ret; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | - ret = trs_mbox_send( | 73 | + ret = trs_mbox_send(&inst, 0, (void *)mb->data, sizeof(struct trs_normal_cqsq_mailbox), |
| 74 | - &inst, 0, (void *)mb->data, sizeof(struct trs_normal_cqsq_mailbox), TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); | 74 | + TRS_DEVICE_CHAN_MBOX_TIMEOUT_MS); |
| 75 | if (ret != 0) { | 75 | if (ret != 0) { |
| 76 | trs_err("Mbox send fail. (devid=%u; tsid=%u; cmd=%u; ret=%d)\n", inst.devid, inst.tsid, mb_head->cmd_type, ret); | 76 | trs_err("Mbox send fail. (devid=%u; tsid=%u; cmd=%u; ret=%d)\n", inst.devid, inst.tsid, mb_head->cmd_type, ret); |
| 77 | } | 77 | } |
| @@ -94,9 +94,8 @@ static int trs_sec_eh_sqe_update(u32 devid, struct vmng_rx_msg_proc_info *proc_i | |||
| 94 | *(proc_info->real_out_len) = data_len; | 94 | *(proc_info->real_out_len) = data_len; |
| 95 | 95 | ||
| 96 | if ((proc_info->in_data_len != data_len) || (proc_info->out_data_len != data_len)) { | 96 | if ((proc_info->in_data_len != data_len) || (proc_info->out_data_len != data_len)) { |
| 97 | - trs_err( | 97 | + trs_err("Check failed. (in_len=%u; out_len=%u; data_len=%u)\n", proc_info->in_data_len, proc_info->out_data_len, |
| 98 | - "Check failed. (in_len=%u; out_len=%u; data_len=%u)\n", proc_info->in_data_len, proc_info->out_data_len, | 98 | + data_len); |
| 99 | - data_len); | ||
| 100 | return -EINVAL; | 99 | return -EINVAL; |
| 101 | } | 100 | } |
| 102 | 101 | ||
| @@ -125,8 +124,8 @@ static int trs_sec_eh_res_ctrl(u32 devid, struct vmng_rx_msg_proc_info *proc_inf | |||
| 125 | trs_id_inst_pack(&inst, devid, info->head.tsid); | 124 | trs_id_inst_pack(&inst, devid, info->head.tsid); |
| 126 | ret = _trs_sec_eh_res_ctrl(&inst, info->id_type, info->id, info->cmd); | 125 | ret = _trs_sec_eh_res_ctrl(&inst, info->id_type, info->id, info->cmd); |
| 127 | if (ret != 0) { | 126 | if (ret != 0) { |
| 128 | - trs_err( | 127 | + trs_err("Failed to res ctrl. (devid=%u; id_type=%u; id=%u; cmd=%u)\n", devid, info->id_type, info->id, |
| 129 | - "Failed to res ctrl. (devid=%u; id_type=%u; id=%u; cmd=%u)\n", devid, info->id_type, info->id, info->cmd); | 128 | + info->cmd); |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | return ret; | 131 | return ret; |
| @@ -139,4 +138,7 @@ static const sec_eh_vpc_func sec_eh_vpc_handlers[TRS_SEC_EH_MAX] = { | |||
| 139 | [TRS_SEC_EH_RES_CTRL] = trs_sec_eh_res_ctrl, | 138 | [TRS_SEC_EH_RES_CTRL] = trs_sec_eh_res_ctrl, |
| 140 | }; | 139 | }; |
| 141 | 140 | ||
| 142 | -sec_eh_vpc_func trs_sec_eh_get_vpc_func(u32 cmd) { return sec_eh_vpc_handlers[cmd]; } | 141 | +sec_eh_vpc_func trs_sec_eh_get_vpc_func(u32 cmd) |
| 142 | +{ | ||
| 143 | + return sec_eh_vpc_handlers[cmd]; | ||
| 144 | +} | ||
| @@ -69,9 +69,8 @@ static int trs_sec_eh_cfg_init(struct trs_sec_eh_ts_inst *sec_eh_cfg) | |||
| 69 | for (type = 0; type < TRS_CORE_MAX_ID_TYPE; type++) { | 69 | for (type = 0; type < TRS_CORE_MAX_ID_TYPE; type++) { |
| 70 | ret = trs_host_get_id_cap(&sec_eh_cfg->pm_inst, type, &id_cap); | 70 | ret = trs_host_get_id_cap(&sec_eh_cfg->pm_inst, type, &id_cap); |
| 71 | if (ret != 0) { | 71 | if (ret != 0) { |
| 72 | - trs_warn( | 72 | + trs_warn("Id not support. (devid=%u; tsid=%u; type=%d)\n", sec_eh_cfg->pm_inst.devid, |
| 73 | - "Id not support. (devid=%u; tsid=%u; type=%d)\n", sec_eh_cfg->pm_inst.devid, sec_eh_cfg->pm_inst.tsid, | 73 | + sec_eh_cfg->pm_inst.tsid, type); |
| 74 | - type); | ||
| 75 | continue; | 74 | continue; |
| 76 | } | 75 | } |
| 77 | 76 | ||
| @@ -92,14 +91,13 @@ static int trs_sec_eh_cfg_init(struct trs_sec_eh_ts_inst *sec_eh_cfg) | |||
| 92 | id_info->num_per_bit = (id_cap.id_end - id_cap.id_start) / id_info->bitnum; | 91 | id_info->num_per_bit = (id_cap.id_end - id_cap.id_start) / id_info->bitnum; |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | - trs_info( | 94 | + trs_info("Id cap. (devid=%u; tsid=%u; type=%d; maxid=%u; bitmap=%u; num_per_bit=%u; start=%u; end=%u)\n", |
| 96 | - "Id cap. (devid=%u; tsid=%u; type=%d; maxid=%u; bitmap=%u; num_per_bit=%u; start=%u; end=%u)\n", | 95 | + sec_eh_cfg->pm_inst.devid, sec_eh_cfg->pm_inst.tsid, type, id_cap.id_end, id_info->bitmap, |
| 97 | - sec_eh_cfg->pm_inst.devid, sec_eh_cfg->pm_inst.tsid, type, id_cap.id_end, id_info->bitmap, | 96 | + id_info->num_per_bit, id_cap.id_start, id_cap.id_end); |
| 98 | - id_info->num_per_bit, id_cap.id_start, id_cap.id_end); | ||
| 99 | 97 | ||
| 100 | if (type == TRS_HW_SQ) { | 98 | if (type == TRS_HW_SQ) { |
| 101 | - sec_eh_cfg->sq_ctx = | 99 | + sec_eh_cfg->sq_ctx = (struct trs_sec_eh_sq_ctx *)trs_vzalloc(sizeof(struct trs_sec_eh_sq_ctx) * |
| 102 | - (struct trs_sec_eh_sq_ctx *)trs_vzalloc(sizeof(struct trs_sec_eh_sq_ctx) * id_cap.id_end); | 100 | + id_cap.id_end); |
| 103 | if (sec_eh_cfg->sq_ctx == NULL) { | 101 | if (sec_eh_cfg->sq_ctx == NULL) { |
| 104 | goto free_mem; | 102 | goto free_mem; |
| 105 | } | 103 | } |
| @@ -155,9 +153,8 @@ static int trs_sec_eh_init_mia_res(struct trs_id_inst *inst, struct trs_sec_eh_t | |||
| 155 | } | 153 | } |
| 156 | sec_eh_cfg->notify_bitmap = (u32)bitmap; | 154 | sec_eh_cfg->notify_bitmap = (u32)bitmap; |
| 157 | 155 | ||
| 158 | - trs_info( | 156 | + trs_info("Res. (devid=%u; rtsq_bitmap=%x; event_bitmap=%x; notify_bitmap=%x)\n", inst->devid, |
| 159 | - "Res. (devid=%u; rtsq_bitmap=%x; event_bitmap=%x; notify_bitmap=%x)\n", inst->devid, sec_eh_cfg->rtsq_bitmap, | 157 | + sec_eh_cfg->rtsq_bitmap, sec_eh_cfg->event_bitmap, sec_eh_cfg->notify_bitmap); |
| 160 | - sec_eh_cfg->event_bitmap, sec_eh_cfg->notify_bitmap); | ||
| 161 | 158 | ||
| 162 | return 0; | 159 | return 0; |
| 163 | } | 160 | } |
| @@ -24,9 +24,8 @@ static void trs_sec_eh_get_id_range_by_bit(struct trs_sec_eh_id_info *id_info, u | |||
| 24 | *start = id_info->start + bit * id_info->num_per_bit; | 24 | *start = id_info->start + bit * id_info->num_per_bit; |
| 25 | *end = *start + id_info->num_per_bit; | 25 | *end = *start + id_info->num_per_bit; |
| 26 | } | 26 | } |
| 27 | - trs_debug( | 27 | + trs_debug("Get id rang. (bit=%u; type=%d; start=%u; end=%u; num_per_bit=%u)\n", bit, type, *start, *end, |
| 28 | - "Get id rang. (bit=%u; type=%d; start=%u; end=%u; num_per_bit=%u)\n", bit, type, *start, *end, | 28 | + id_info->num_per_bit); |
| 29 | - id_info->num_per_bit); | ||
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | bool trs_sec_eh_id_is_belong_to_vf(struct trs_sec_eh_id_info *id_info, u32 id) | 31 | bool trs_sec_eh_id_is_belong_to_vf(struct trs_sec_eh_id_info *id_info, u32 id) |
| @@ -110,7 +109,10 @@ void trs_sec_eh_id_config(struct trs_id_inst *inst) | |||
| 110 | trs_res_ops_register(inst->devid, &ops); | 109 | trs_res_ops_register(inst->devid, &ops); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | -void trs_sec_eh_id_deconfig(struct trs_id_inst *inst) { trs_res_ops_unregister(inst->devid); } | 112 | +void trs_sec_eh_id_deconfig(struct trs_id_inst *inst) |
| 113 | +{ | ||
| 114 | + trs_res_ops_unregister(inst->devid); | ||
| 115 | +} | ||
| 114 | 116 | ||
| 115 | int _trs_sec_eh_res_ctrl(struct trs_id_inst *inst, u32 id_type, u32 res_id, u32 cmd) | 117 | int _trs_sec_eh_res_ctrl(struct trs_id_inst *inst, u32 id_type, u32 res_id, u32 cmd) |
| 116 | { | 118 | { |
| @@ -22,8 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | typedef int (*mb_update_func)(struct trs_sec_eh_ts_inst *sec_eh_cfg, void *mb_data); | 23 | typedef int (*mb_update_func)(struct trs_sec_eh_ts_inst *sec_eh_cfg, void *mb_data); |
| 24 | 24 | ||
| 25 | -static int trs_sec_eh_update_rsv_mem_info( | 25 | +static int trs_sec_eh_update_rsv_mem_info(struct trs_id_inst *inst, u32 sq_mem_type, |
| 26 | - struct trs_id_inst *inst, u32 sq_mem_type, struct trs_normal_cqsq_mailbox *mb_data) | 26 | + struct trs_normal_cqsq_mailbox *mb_data) |
| 27 | { | 27 | { |
| 28 | mb_data->sq_cq_side &= 0xfe; // 0xfe: clear sq side bit | 28 | mb_data->sq_cq_side &= 0xfe; // 0xfe: clear sq side bit |
| 29 | mb_data->sq_cq_side |= ((trs_chan_mem_is_dev_mem(sq_mem_type) ? 0 : 1) << TRS_CHAN_SQ_MEM_OFFSET); | 29 | mb_data->sq_cq_side |= ((trs_chan_mem_is_dev_mem(sq_mem_type) ? 0 : 1) << TRS_CHAN_SQ_MEM_OFFSET); |
| @@ -92,10 +92,9 @@ static int trs_sec_eh_create_sqcq_mb_update(struct trs_sec_eh_ts_inst *sec_eh_cf | |||
| 92 | return ret; | 92 | return ret; |
| 93 | 93 | ||
| 94 | } | 94 | } |
| 95 | - trs_debug( | 95 | + trs_debug("Id info. (devid=%u; tsid=%u; sq=%u; cq=%u; pid=%d; sqcq_side=%u; sq_mem_type=0x%x)\n", |
| 96 | - "Id info. (devid=%u; tsid=%u; sq=%u; cq=%u; pid=%d; sqcq_side=%u; sq_mem_type=0x%x)\n", sec_eh_cfg->inst.devid, | 96 | + sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, mb_data->sq_index, mb_data->cq0_index, mb_data->pid, |
| 97 | - sec_eh_cfg->inst.tsid, mb_data->sq_index, mb_data->cq0_index, mb_data->pid, mb_data->sq_cq_side, | 97 | + mb_data->sq_cq_side, sq_ctx.mem_type); |
| 98 | - sq_ctx.mem_type); | ||
| 99 | 98 | ||
| 100 | return ret; | 99 | return ret; |
| 101 | } | 100 | } |
| @@ -112,9 +111,8 @@ static int trs_sec_eh_free_sqcq_mb_update(struct trs_sec_eh_ts_inst *sec_eh_cfg, | |||
| 112 | 111 | ||
| 113 | trs_sec_eh_free_sq_mem(sec_eh_cfg, mb_data->sq_index); | 112 | trs_sec_eh_free_sq_mem(sec_eh_cfg, mb_data->sq_index); |
| 114 | trs_sec_eh_sq_ctx_uninit(sec_eh_cfg, mb_data->sq_index); | 113 | trs_sec_eh_sq_ctx_uninit(sec_eh_cfg, mb_data->sq_index); |
| 115 | - trs_debug( | 114 | + trs_debug("Id info. (devid=%u; tsid=%u; sq=%u; cq=%u; pid=%d)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, |
| 116 | - "Id info. (devid=%u; tsid=%u; sq=%u; cq=%u; pid=%d)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, | 115 | + mb_data->sq_index, mb_data->cq0_index, mb_data->pid); |
| 117 | - mb_data->sq_index, mb_data->cq0_index, mb_data->pid); | ||
| 118 | 116 | ||
| 119 | return 0; | 117 | return 0; |
| 120 | } | 118 | } |
| @@ -129,9 +127,8 @@ static int trs_sec_eh_free_all_sqcq_mb_update(struct trs_sec_eh_ts_inst *sec_eh_ | |||
| 129 | if (sq_ctx[sqid].pid == mb_data->proc_info.pid[0]) { | 127 | if (sq_ctx[sqid].pid == mb_data->proc_info.pid[0]) { |
| 130 | trs_sec_eh_free_sq_mem(sec_eh_cfg, sqid); | 128 | trs_sec_eh_free_sq_mem(sec_eh_cfg, sqid); |
| 131 | trs_sec_eh_sq_ctx_uninit(sec_eh_cfg, sqid); | 129 | trs_sec_eh_sq_ctx_uninit(sec_eh_cfg, sqid); |
| 132 | - trs_debug( | 130 | + trs_debug("Id info. (devid=%u; tsid=%u; pid=%d; sqid=%u)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, |
| 133 | - "Id info. (devid=%u; tsid=%u; pid=%d; sqid=%u)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, | 131 | + mb_data->proc_info.pid[0], sqid); |
| 134 | - mb_data->proc_info.pid[0], sqid); | ||
| 135 | } | 132 | } |
| 136 | } | 133 | } |
| 137 | 134 | ||
| @@ -76,9 +76,8 @@ u64 trs_sec_eh_alloc_sq_mem(struct trs_sec_eh_ts_inst *sec_eh_cfg, struct trs_se | |||
| 76 | int ret; | 76 | int ret; |
| 77 | struct trs_sq_mem_map_para sec_sq_map_param; | 77 | struct trs_sq_mem_map_para sec_sq_map_param; |
| 78 | if ((size == 0) || (ctx->sqesize > TRS_SEC_EH_MAX_SQE_SIZE) || (ctx->sqdepth > TRS_SEC_EH_MAX_SQDEPTH_SIZE)) { | 78 | if ((size == 0) || (ctx->sqesize > TRS_SEC_EH_MAX_SQE_SIZE) || (ctx->sqdepth > TRS_SEC_EH_MAX_SQDEPTH_SIZE)) { |
| 79 | - trs_err( | 79 | + trs_err("Invalid. (devid=%u; tsid=%u; sqid=%u; offset=0x%pK)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, |
| 80 | - "Invalid. (devid=%u; tsid=%u; sqid=%u; offset=0x%pK)\n", sec_eh_cfg->inst.devid, sec_eh_cfg->inst.tsid, | 80 | + ctx->sqid, (void *)ctx->addr_offset); |
| 81 | - ctx->sqid, (void *)ctx->addr_offset); | ||
| 82 | return -EINVAL; | 81 | return -EINVAL; |
| 83 | } | 82 | } |
| 84 | 83 | ||
| @@ -123,8 +122,8 @@ void trs_sec_eh_free_sq_mem(struct trs_sec_eh_ts_inst *sec_eh_cfg, u32 sqid) | |||
| 123 | { | 122 | { |
| 124 | struct trs_sec_eh_sq_ctx *sq_ctx = sec_eh_cfg->sq_ctx; | 123 | struct trs_sec_eh_sq_ctx *sq_ctx = sec_eh_cfg->sq_ctx; |
| 125 | struct trs_sq_mem_map_para sec_sq_map_param; | 124 | struct trs_sq_mem_map_para sec_sq_map_param; |
| 126 | - struct trs_chan_mem_attr mem_attr = { | 125 | + struct trs_chan_mem_attr mem_attr = {sq_ctx[sqid].sq_paddr, sq_ctx[sqid].sq_depth * sq_ctx[sqid].sqe_size, |
| 127 | - sq_ctx[sqid].sq_paddr, sq_ctx[sqid].sq_depth * sq_ctx[sqid].sqe_size, sq_ctx[sqid].mem_type}; | 126 | + sq_ctx[sqid].mem_type}; |
| 128 | 127 | ||
| 129 | ka_task_mutex_lock(&sec_eh_cfg->mutex); | 128 | ka_task_mutex_lock(&sec_eh_cfg->mutex); |
| 130 | if (sq_ctx[sqid].d_addr != NULL) { | 129 | if (sq_ctx[sqid].d_addr != NULL) { |
| @@ -151,9 +150,8 @@ void trs_sec_eh_free_sq_mem_all(struct trs_id_inst *inst) | |||
| 151 | num++; | 150 | num++; |
| 152 | } | 151 | } |
| 153 | 152 | ||
| 154 | - trs_info( | 153 | + trs_info("Kernel free sq success. (devid=%u; pm_devid=%u; num=%u)\n", sec_eh_cfg->inst.devid, |
| 155 | - "Kernel free sq success. (devid=%u; pm_devid=%u; num=%u)\n", sec_eh_cfg->inst.devid, | 154 | + sec_eh_cfg->pm_inst.devid, num); |
| 156 | - sec_eh_cfg->pm_inst.devid, num); | ||
| 157 | trs_sec_eh_ts_inst_put(sec_eh_cfg); | 155 | trs_sec_eh_ts_inst_put(sec_eh_cfg); |
| 158 | } | 156 | } |
| 159 | } | 157 | } |
| @@ -231,9 +229,8 @@ int trs_sec_eh_check_and_update_cq_ctx_info(struct trs_sec_eh_ts_inst *sec_eh_cf | |||
| 231 | 229 | ||
| 232 | if (((ctx->cqesize % TRS_SEC_EH_CQE_ALIGN_SIZE) != 0) || ((ctx->cqesize * ctx->cqdepth) != KA_MM_PAGE_SIZE) || | 230 | if (((ctx->cqesize % TRS_SEC_EH_CQE_ALIGN_SIZE) != 0) || ((ctx->cqesize * ctx->cqdepth) != KA_MM_PAGE_SIZE) || |
| 233 | (ctx->cq_paddr == 0) || ((ctx->cq_paddr & (KA_MM_PAGE_SIZE - 1)) != 0)) { | 231 | (ctx->cq_paddr == 0) || ((ctx->cq_paddr & (KA_MM_PAGE_SIZE - 1)) != 0)) { |
| 234 | - trs_err( | 232 | + trs_err("Invalid cq size or addr. (devid=%u; cqesize=%u; cqdepth=%u; pagesize=0x%lx)\n", inst.devid, |
| 235 | - "Invalid cq size or addr. (devid=%u; cqesize=%u; cqdepth=%u; pagesize=0x%lx)\n", inst.devid, ctx->cqesize, | 233 | + ctx->cqesize, ctx->cqdepth, KA_MM_PAGE_SIZE); |
| 236 | - ctx->cqdepth, KA_MM_PAGE_SIZE); | ||
| 237 | return -EINVAL; | 234 | return -EINVAL; |
| 238 | } | 235 | } |
| 239 | 236 | ||
| @@ -245,9 +242,8 @@ int trs_sec_eh_check_and_update_cq_ctx_info(struct trs_sec_eh_ts_inst *sec_eh_cf | |||
| 245 | 242 | ||
| 246 | pf_id = mia_para.phy_devid; | 243 | pf_id = mia_para.phy_devid; |
| 247 | vf_id = mia_para.sub_devid + 1; | 244 | vf_id = mia_para.sub_devid + 1; |
| 248 | - trs_debug( | 245 | + trs_debug("Get vdavinci. (devid=%u; pf_id=%u; vf_id=%u; pm_devid=%u)\n", inst.devid, pf_id, vf_id, |
| 249 | - "Get vdavinci. (devid=%u; pf_id=%u; vf_id=%u; pm_devid=%u)\n", inst.devid, pf_id, vf_id, | 246 | + sec_eh_cfg->pm_inst.devid); |
| 250 | - sec_eh_cfg->pm_inst.devid); | ||
| 251 | 247 | ||
| 252 | vdavinci = vmngh_get_vdavinci_by_id(pf_id, vf_id); | 248 | vdavinci = vmngh_get_vdavinci_by_id(pf_id, vf_id); |
| 253 | if (vdavinci == NULL) { | 249 | if (vdavinci == NULL) { |
| @@ -281,13 +281,15 @@ struct shr_id_proc_ctx *shr_id_proc_ctx_find(ka_pid_t pid) | |||
| 281 | return proc_ctx; | 281 | return proc_ctx; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | -static void shr_id_proc_put(struct shr_id_proc_ctx *proc_ctx) { kref_safe_put(&proc_ctx->ref, shr_id_proc_release); } | 284 | +static void shr_id_proc_put(struct shr_id_proc_ctx *proc_ctx) |
| 285 | +{ | ||
| 286 | + kref_safe_put(&proc_ctx->ref, shr_id_proc_release); | ||
| 287 | +} | ||
| 285 | 288 | ||
| 286 | static int shr_id_name_generate(struct trs_id_inst *inst, int pid, int id_type, u32 shr_id, char *name) | 289 | static int shr_id_name_generate(struct trs_id_inst *inst, int pid, int id_type, u32 shr_id, char *name) |
| 287 | { | 290 | { |
| 288 | - int offset = snprintf_s( | 291 | + int offset = snprintf_s(name, SHR_ID_NSM_NAME_SIZE, SHR_ID_NSM_NAME_SIZE - 1, "%08x%08x%08x%08x%08x", pid, |
| 289 | - name, SHR_ID_NSM_NAME_SIZE, SHR_ID_NSM_NAME_SIZE - 1, "%08x%08x%08x%08x%08x", pid, inst->devid, inst->tsid, | 292 | + inst->devid, inst->tsid, id_type, shr_id); |
| 290 | - id_type, shr_id); | ||
| 291 | if (offset < 0) { | 293 | if (offset < 0) { |
| 292 | trs_err("Snprintf failed. (offset=%d)\n", offset); | 294 | trs_err("Snprintf failed. (offset=%d)\n", offset); |
| 293 | return -EINVAL; | 295 | return -EINVAL; |
| @@ -321,8 +323,8 @@ static struct shr_id_proc_node *shr_id_find_proc_node(struct shr_id_proc_ctx *pr | |||
| 321 | return NULL; | 323 | return NULL; |
| 322 | } | 324 | } |
| 323 | 325 | ||
| 324 | -static int shr_id_add_to_proc( | 326 | +static int shr_id_add_to_proc(struct shr_id_proc_ctx *proc_ctx, struct shr_id_ioctl_info *ioctl_info, |
| 325 | - struct shr_id_proc_ctx *proc_ctx, struct shr_id_ioctl_info *ioctl_info, struct shr_id_node_op_attr *attr, int op) | 327 | + struct shr_id_node_op_attr *attr, int op) |
| 326 | { | 328 | { |
| 327 | struct shr_id_proc_node *proc_node = NULL; | 329 | struct shr_id_proc_node *proc_node = NULL; |
| 328 | 330 | ||
| @@ -358,9 +360,8 @@ static int shr_id_add_to_proc( | |||
| 358 | ioctl_info->flag |= TSDRV_FLAG_SHR_ID_SHADOW; | 360 | ioctl_info->flag |= TSDRV_FLAG_SHR_ID_SHADOW; |
| 359 | } | 361 | } |
| 360 | 362 | ||
| 361 | - trs_debug( | 363 | + trs_debug("Add info. (devid=%u; tsid=%u; type=%d; id=%u; flag=%u; node_flag=0x%x; op=%d)\n", attr->inst.devid, |
| 362 | - "Add info. (devid=%u; tsid=%u; type=%d; id=%u; flag=%u; node_flag=0x%x; op=%d)\n", attr->inst.devid, | 364 | + attr->inst.tsid, attr->res_type, attr->id, ioctl_info->flag, proc_node->flag, op); |
| 363 | - attr->inst.tsid, attr->res_type, attr->id, ioctl_info->flag, proc_node->flag, op); | ||
| 364 | 365 | ||
| 365 | ka_task_write_lock(&proc_ctx->lock); | 366 | ka_task_write_lock(&proc_ctx->lock); |
| 366 | ka_list_add_tail(&proc_node->list, shr_id_get_list_head(proc_ctx, op)); | 367 | ka_list_add_tail(&proc_node->list, shr_id_get_list_head(proc_ctx, op)); |
| @@ -382,9 +383,8 @@ static void shr_id_del_from_proc(struct shr_id_proc_ctx *proc_ctx, struct shr_id | |||
| 382 | return; | 383 | return; |
| 383 | } | 384 | } |
| 384 | 385 | ||
| 385 | - trs_debug( | 386 | + trs_debug("Del info. (devid=%u; tsid=%u; type=%d; id=%u; flag=%u; node_flag=%u; op=%d)\n", proc_node->inst.devid, |
| 386 | - "Del info. (devid=%u; tsid=%u; type=%d; id=%u; flag=%u; node_flag=%u; op=%d)\n", proc_node->inst.devid, | 387 | + proc_node->inst.devid, proc_node->type, proc_node->id, ioctl_info->flag, proc_node->flag, op); |
| 387 | - proc_node->inst.devid, proc_node->type, proc_node->id, ioctl_info->flag, proc_node->flag, op); | ||
| 388 | 388 | ||
| 389 | shr_id_proc_num_dec(proc_ctx, op, 1); | 389 | shr_id_proc_num_dec(proc_ctx, op, 1); |
| 390 | proc_node->ref--; | 390 | proc_node->ref--; |
| @@ -452,7 +452,10 @@ int shr_id_proc_add(struct shr_id_proc_ctx *proc_ctx) | |||
| 452 | return 0; | 452 | return 0; |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | -void shr_id_proc_del(struct shr_id_proc_ctx *proc_ctx) { shr_id_proc_put(proc_ctx); } | 455 | +void shr_id_proc_del(struct shr_id_proc_ctx *proc_ctx) |
| 456 | +{ | ||
| 457 | + shr_id_proc_put(proc_ctx); | ||
| 458 | +} | ||
| 456 | 459 | ||
| 457 | bool shr_id_is_belong_to_proc(struct trs_id_inst *inst, int pid, int res_type, u32 res_id) | 460 | bool shr_id_is_belong_to_proc(struct trs_id_inst *inst, int pid, int res_type, u32 res_id) |
| 458 | { | 461 | { |
| @@ -490,9 +493,8 @@ bool shr_id_is_belong_to_proc(struct trs_id_inst *inst, int pid, int res_type, u | |||
| 490 | ka_task_read_unlock(&proc_ctx->lock); | 493 | ka_task_read_unlock(&proc_ctx->lock); |
| 491 | shr_id_proc_put(proc_ctx); | 494 | shr_id_proc_put(proc_ctx); |
| 492 | 495 | ||
| 493 | - trs_debug( | 496 | + trs_debug("Id info. (devid=%u; tsid=%u; pid=%d; type=%d; shrid=%u; is=%u)\n", inst->devid, inst->tsid, |
| 494 | - "Id info. (devid=%u; tsid=%u; pid=%d; type=%d; shrid=%u; is=%u)\n", inst->devid, inst->tsid, | 497 | + ka_task_get_current_tgid(), res_type, res_id, is_belong); |
| 495 | - ka_task_get_current_tgid(), res_type, res_id, is_belong); | ||
| 496 | 498 | ||
| 497 | return is_belong; | 499 | return is_belong; |
| 498 | } | 500 | } |
| @@ -525,8 +527,8 @@ static int shr_id_set_stars_die_id(u32 devid, u32 tsid, struct shr_id_node_op_at | |||
| 525 | return 0; | 527 | return 0; |
| 526 | } | 528 | } |
| 527 | 529 | ||
| 528 | -static int shr_id_node_attr_pack( | 530 | +static int shr_id_node_attr_pack(struct shr_id_node_op_attr *attr, ka_pid_t pid, u64 start_time, |
| 529 | - struct shr_id_node_op_attr *attr, ka_pid_t pid, u64 start_time, struct shr_id_ioctl_info *ioctl_info) | 531 | + struct shr_id_ioctl_info *ioctl_info) |
| 530 | { | 532 | { |
| 531 | u32 type = ioctl_info->id_type; | 533 | u32 type = ioctl_info->id_type; |
| 532 | int ret, i; | 534 | int ret, i; |
| @@ -584,8 +586,8 @@ int shr_id_create(struct shr_id_proc_ctx *proc_ctx, unsigned long arg) | |||
| 584 | } | 586 | } |
| 585 | 587 | ||
| 586 | if (ioctl_info.id_type >= SHR_ID_TYPE_MAX) { | 588 | if (ioctl_info.id_type >= SHR_ID_TYPE_MAX) { |
| 587 | - trs_err( | 589 | + trs_err("Para invalid. (devid=%u; tsid=%u; idtype=%u)\n", ioctl_info.devid, ioctl_info.tsid, |
| 588 | - "Para invalid. (devid=%u; tsid=%u; idtype=%u)\n", ioctl_info.devid, ioctl_info.tsid, ioctl_info.id_type); | 590 | + ioctl_info.id_type); |
| 589 | return -EINVAL; | 591 | return -EINVAL; |
| 590 | } | 592 | } |
| 591 | 593 | ||
| @@ -63,9 +63,8 @@ static int shr_id_get_notify_base_addr(u32 devid, u32 remote_phy_id, u64 *base_a | |||
| 63 | trs_err("Get chipid failed. (remote_phy_id=%u)\n", remote_phy_id); | 63 | trs_err("Get chipid failed. (remote_phy_id=%u)\n", remote_phy_id); |
| 64 | return -EINVAL; | 64 | return -EINVAL; |
| 65 | } | 65 | } |
| 66 | - trs_debug( | 66 | + trs_debug("Notify info. (devid=%u; remote_devid=%u; chip=%u; die=%u; type=%d; addrmode=%u)\n", devid, |
| 67 | - "Notify info. (devid=%u; remote_devid=%u; chip=%u; die=%u; type=%d; addrmode=%u)\n", devid, remote_phy_id, | 67 | + remote_phy_id, info->chip_id, info->die_id, topology_type, info->addr_mode); |
| 68 | - info->chip_id, info->die_id, topology_type, info->addr_mode); | ||
| 69 | 68 | ||
| 70 | if (info->addr_mode == ADDR_MODE_UNIFIED) { | 69 | if (info->addr_mode == ADDR_MODE_UNIFIED) { |
| 71 | phy_base_addr = SHRID_CHIP_BASE_ADDR; | 70 | phy_base_addr = SHRID_CHIP_BASE_ADDR; |
| @@ -73,9 +72,8 @@ static int shr_id_get_notify_base_addr(u32 devid, u32 remote_phy_id, u64 *base_a | |||
| 73 | } | 72 | } |
| 74 | *base_addr = SHRID_STARS_BASE_ADDR + SHRID_STARS_NOTIFY_BASE_ADDR + chip_offset * info->chip_id + | 73 | *base_addr = SHRID_STARS_BASE_ADDR + SHRID_STARS_NOTIFY_BASE_ADDR + chip_offset * info->chip_id + |
| 75 | SHRID_ASCEND910_93_DIE_ADDR_OFFSET * info->die_id + phy_base_addr; | 74 | SHRID_ASCEND910_93_DIE_ADDR_OFFSET * info->die_id + phy_base_addr; |
| 76 | - } else if ( | 75 | + } else if ((topology_type == TOPOLOGY_PIX) || (topology_type == TOPOLOGY_PIB) || (topology_type == TOPOLOGY_PHB) || |
| 77 | - (topology_type == TOPOLOGY_PIX) || (topology_type == TOPOLOGY_PIB) || (topology_type == TOPOLOGY_PHB) || | 76 | + (topology_type == TOPOLOGY_SYS)) { |
| 78 | - (topology_type == TOPOLOGY_SYS)) { | ||
| 79 | *base_addr = SHRID_STARS_PCIE_BASE_ADDR + SHRID_STARS_NOTIFY_BASE_ADDR + | 77 | *base_addr = SHRID_STARS_PCIE_BASE_ADDR + SHRID_STARS_NOTIFY_BASE_ADDR + |
| 80 | ((u64)remote_phy_id << SHRID_PCIE_REMOTE_DEV_OFFSET) + | 78 | ((u64)remote_phy_id << SHRID_PCIE_REMOTE_DEV_OFFSET) + |
| 81 | ((u64)local_phy_id << SHRID_PCIE_LOCAL_DEV_OFFSET); | 79 | ((u64)local_phy_id << SHRID_PCIE_LOCAL_DEV_OFFSET); |
| @@ -88,8 +86,8 @@ static int shr_id_get_notify_base_addr(u32 devid, u32 remote_phy_id, u64 *base_a | |||
| 88 | return 0; | 86 | return 0; |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | -STATIC int _shr_id_event_update( | 89 | +STATIC int _shr_id_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 92 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 90 | + struct sched_published_event_func *event_func) |
| 93 | { | 91 | { |
| 94 | struct drvShrIdInfo *info = NULL; | 92 | struct drvShrIdInfo *info = NULL; |
| 95 | u64 base_addr, notify_addr; | 93 | u64 base_addr, notify_addr; |
| @@ -129,9 +127,8 @@ STATIC int _shr_id_event_update( | |||
| 129 | 127 | ||
| 130 | if (event_info->subevent_id == DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG) { /* only shrIdOpen need check shrid. */ | 128 | if (event_info->subevent_id == DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG) { /* only shrIdOpen need check shrid. */ |
| 131 | if (!shr_id_is_belong_to_proc(&inst, ka_task_get_current_tgid(), res_type, info->shrid)) { | 129 | if (!shr_id_is_belong_to_proc(&inst, ka_task_get_current_tgid(), res_type, info->shrid)) { |
| 132 | - trs_err( | 130 | + trs_err("Id invalid. (devid=%u; rudevid=%u; tsid=%u; pid=%d; type=%u; shrid=%u)\n", devid, info->devid, |
| 133 | - "Id invalid. (devid=%u; rudevid=%u; tsid=%u; pid=%d; type=%u; shrid=%u)\n", devid, info->devid, | 131 | + info->tsid, ka_task_get_current_tgid(), info->id_type, info->shrid); |
| 134 | - info->tsid, ka_task_get_current_tgid(), info->id_type, info->shrid); | ||
| 135 | return -EACCES; | 132 | return -EACCES; |
| 136 | } | 133 | } |
| 137 | } | 134 | } |
| @@ -145,15 +142,14 @@ STATIC int _shr_id_event_update( | |||
| 145 | info->rsv[0] = (u32)(notify_addr & 0xffffffffULL); /* 0xffffffffULL is low 32 bit */ | 142 | info->rsv[0] = (u32)(notify_addr & 0xffffffffULL); /* 0xffffffffULL is low 32 bit */ |
| 146 | info->rsv[1] = (u32)(notify_addr >> 32); /* 32 is high bit */ | 143 | info->rsv[1] = (u32)(notify_addr >> 32); /* 32 is high bit */ |
| 147 | 144 | ||
| 148 | - trs_debug( | 145 | + trs_debug("Notify info. (devid=%u; remote_devid=%u; type=%u; shrid=%u; sub_id=%u)\n", devid, info->devid, |
| 149 | - "Notify info. (devid=%u; remote_devid=%u; type=%u; shrid=%u; sub_id=%u)\n", devid, info->devid, info->id_type, | 146 | + info->id_type, info->shrid, event_info->subevent_id); |
| 150 | - info->shrid, event_info->subevent_id); | ||
| 151 | 147 | ||
| 152 | return 0; | 148 | return 0; |
| 153 | } | 149 | } |
| 154 | 150 | ||
| 155 | -int shr_id_event_update( | 151 | +int shr_id_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 156 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 152 | + struct sched_published_event_func *event_func) |
| 157 | { | 153 | { |
| 158 | int ret = _shr_id_event_update(devid, event_info, event_func); | 154 | int ret = _shr_id_event_update(devid, event_info, event_func); |
| 159 | return trs_event_kerror_to_uerror(ret); | 155 | return trs_event_kerror_to_uerror(ret); |
| @@ -161,8 +157,8 @@ int shr_id_event_update( | |||
| 161 | 157 | ||
| 162 | STATIC int shr_id_event_init(void) | 158 | STATIC int shr_id_event_init(void) |
| 163 | { | 159 | { |
| 164 | - return hal_kernel_sched_register_event_pre_proc_handle( | 160 | + return hal_kernel_sched_register_event_pre_proc_handle(EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, |
| 165 | - EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, shr_id_event_update); | 161 | + shr_id_event_update); |
| 166 | } | 162 | } |
| 167 | DECLAER_FEATURE_AUTO_INIT(shr_id_event_init, FEATURE_LOADER_STAGE_5); | 163 | DECLAER_FEATURE_AUTO_INIT(shr_id_event_init, FEATURE_LOADER_STAGE_5); |
| 168 | 164 | ||
| @@ -42,6 +42,6 @@ static inline int shr_id_type_trans_res_type(u32 shr_id_type) | |||
| 42 | return shr_id_type_trans[shr_id_type]; | 42 | return shr_id_type_trans[shr_id_type]; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | -int shr_id_event_update( | 45 | +int shr_id_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 46 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func); | 46 | + struct sched_published_event_func *event_func); |
| 47 | 47 | ||
| @@ -49,9 +49,15 @@ static u32 get_elfhash_key(const char *name) | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | struct shr_id_node_ops g_shrid_node_ops; | 51 | struct shr_id_node_ops g_shrid_node_ops; |
| 52 | -void shr_id_register_node_ops(struct shr_id_node_ops *ops) { g_shrid_node_ops = *ops; } | 52 | +void shr_id_register_node_ops(struct shr_id_node_ops *ops) |
| 53 | +{ | ||
| 54 | + g_shrid_node_ops = *ops; | ||
| 55 | +} | ||
| 53 | 56 | ||
| 54 | -static struct shr_id_node_ops *shr_id_get_node_ops(void) { return &g_shrid_node_ops; } | 57 | +static struct shr_id_node_ops *shr_id_get_node_ops(void) |
| 58 | +{ | ||
| 59 | + return &g_shrid_node_ops; | ||
| 60 | +} | ||
| 55 | struct shr_id_node_wlist { | 61 | struct shr_id_node_wlist { |
| 56 | ka_pid_t pid; | 62 | ka_pid_t pid; |
| 57 | u64 set_time; | 63 | u64 set_time; |
| @@ -114,9 +120,8 @@ static struct shr_id_node *_shr_id_node_create(struct shr_id_node_op_attr *attr) | |||
| 114 | 120 | ||
| 115 | static void _shr_id_node_destroy(struct shr_id_node *node) | 121 | static void _shr_id_node_destroy(struct shr_id_node *node) |
| 116 | { | 122 | { |
| 117 | - trs_debug( | 123 | + trs_debug("Destroy. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; flag=%d)\n", node->attr.inst.devid, |
| 118 | - "Destroy. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; flag=%d)\n", node->attr.inst.devid, node->attr.inst.tsid, | 124 | + node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id, node->attr.flag); |
| 119 | - node->attr.name, node->attr.type, node->attr.id, node->attr.flag); | ||
| 120 | 125 | ||
| 121 | if (node->attr.res_put != NULL) { | 126 | if (node->attr.res_put != NULL) { |
| 122 | node->attr.res_put(&node->attr.inst, node->attr.res_type, node->attr.id); | 127 | node->attr.res_put(&node->attr.inst, node->attr.res_type, node->attr.id); |
| @@ -168,10 +173,9 @@ static int shr_id_node_add(struct shr_id_node *node) | |||
| 168 | int wlist_num = 1; | 173 | int wlist_num = 1; |
| 169 | shr_id_get_opened_wlist_info(tmp_node, &tmp_wlist, &wlist_num); | 174 | shr_id_get_opened_wlist_info(tmp_node, &tmp_wlist, &wlist_num); |
| 170 | ka_task_write_unlock(&htable[node->attr.type].lock); | 175 | ka_task_write_unlock(&htable[node->attr.type].lock); |
| 171 | - trs_err( | 176 | + trs_err("Add shr id node fail. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; procs_num=%d; opened_pid=%d)\n", |
| 172 | - "Add shr id node fail. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; procs_num=%d; opened_pid=%d)\n", | 177 | + node->attr.inst.devid, node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id, wlist_num, |
| 173 | - node->attr.inst.devid, node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id, wlist_num, | 178 | + tmp_wlist.pid); |
| 174 | - tmp_wlist.pid); | ||
| 175 | return -EACCES; | 179 | return -EACCES; |
| 176 | } | 180 | } |
| 177 | _shr_id_node_add(node); | 181 | _shr_id_node_add(node); |
| @@ -180,7 +184,10 @@ static int shr_id_node_add(struct shr_id_node *node) | |||
| 180 | return 0; | 184 | return 0; |
| 181 | } | 185 | } |
| 182 | 186 | ||
| 183 | -static void _shr_id_node_del(struct shr_id_node *node) { ka_hash_del(&node->link); } | 187 | +static void _shr_id_node_del(struct shr_id_node *node) |
| 188 | +{ | ||
| 189 | + ka_hash_del(&node->link); | ||
| 190 | +} | ||
| 184 | 191 | ||
| 185 | static void shr_id_node_del(struct shr_id_node *node) | 192 | static void shr_id_node_del(struct shr_id_node *node) |
| 186 | { | 193 | { |
| @@ -228,9 +235,8 @@ int shr_id_node_create(struct shr_id_node_op_attr *attr) | |||
| 228 | if (ret != 0) { | 235 | if (ret != 0) { |
| 229 | _shr_id_node_destroy(node); | 236 | _shr_id_node_destroy(node); |
| 230 | } else { | 237 | } else { |
| 231 | - trs_debug( | 238 | + trs_debug("Create succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; size=%ld; flag=%u)\n", attr->inst.devid, |
| 232 | - "Create succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; size=%ld; flag=%u)\n", attr->inst.devid, | 239 | + attr->inst.tsid, node->attr.name, attr->type, attr->id, sizeof(*node), attr->flag); |
| 233 | - attr->inst.tsid, node->attr.name, attr->type, attr->id, sizeof(*node), attr->flag); | ||
| 234 | } | 240 | } |
| 235 | return ret; | 241 | return ret; |
| 236 | } | 242 | } |
| @@ -239,9 +245,8 @@ static void shr_id_node_release(struct kref_safe *kref) | |||
| 239 | { | 245 | { |
| 240 | struct shr_id_node *node = ka_container_of(kref, struct shr_id_node, ref); | 246 | struct shr_id_node *node = ka_container_of(kref, struct shr_id_node, ref); |
| 241 | 247 | ||
| 242 | - trs_debug( | 248 | + trs_debug("Release succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", node->attr.inst.devid, |
| 243 | - "Release succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", node->attr.inst.devid, node->attr.inst.tsid, | 249 | + node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id); |
| 244 | - node->attr.name, node->attr.type, node->attr.id); | ||
| 245 | shr_id_node_del(node); | 250 | shr_id_node_del(node); |
| 246 | _shr_id_node_destroy(node); | 251 | _shr_id_node_destroy(node); |
| 247 | } | 252 | } |
| @@ -275,7 +280,10 @@ static struct shr_id_node *_shr_id_node_get(const char *name, int type) | |||
| 275 | return node; | 280 | return node; |
| 276 | } | 281 | } |
| 277 | 282 | ||
| 278 | -static void _shr_id_node_put(struct shr_id_node *node) { kref_safe_put(&node->ref, shr_id_node_release); } | 283 | +static void _shr_id_node_put(struct shr_id_node *node) |
| 284 | +{ | ||
| 285 | + kref_safe_put(&node->ref, shr_id_node_release); | ||
| 286 | +} | ||
| 279 | 287 | ||
| 280 | int shr_id_node_get_attr(const char *name, struct shr_id_node_op_attr *attr) | 288 | int shr_id_node_get_attr(const char *name, struct shr_id_node_op_attr *attr) |
| 281 | { | 289 | { |
| @@ -339,7 +347,10 @@ bool shr_id_node_need_wlist(void *node) | |||
| 339 | return tmp_node->need_wlist; | 347 | return tmp_node->need_wlist; |
| 340 | } | 348 | } |
| 341 | 349 | ||
| 342 | -void *shr_id_node_get(const char *name, int type) { return (void *)_shr_id_node_get(name, type); } | 350 | +void *shr_id_node_get(const char *name, int type) |
| 351 | +{ | ||
| 352 | + return (void *)_shr_id_node_get(name, type); | ||
| 353 | +} | ||
| 343 | 354 | ||
| 344 | void shr_id_node_put(void *node) | 355 | void shr_id_node_put(void *node) |
| 345 | { | 356 | { |
| @@ -439,9 +450,8 @@ int shr_id_node_set_pids(const char *name, int type, ka_pid_t create_pid, ka_pid | |||
| 439 | ka_task_spin_unlock(&node->lock); | 450 | ka_task_spin_unlock(&node->lock); |
| 440 | 451 | ||
| 441 | if (ret != 0) { | 452 | if (ret != 0) { |
| 442 | - trs_err( | 453 | + trs_err("Shr node can't set pid.(need_wlist=%d; create_pid=%d; current_pid=%d; ret=%d)\n", node->need_wlist, |
| 443 | - "Shr node can't set pid.(need_wlist=%d; create_pid=%d; current_pid=%d; ret=%d)\n", node->need_wlist, | 454 | + node->attr.pid, create_pid, ret); |
| 444 | - node->attr.pid, create_pid, ret); | ||
| 445 | } | 455 | } |
| 446 | _shr_id_node_put(node); | 456 | _shr_id_node_put(node); |
| 447 | 457 | ||
| @@ -506,9 +516,8 @@ static int shr_id_destroy_node_handle(struct shr_id_node *node, u32 mode) | |||
| 506 | return shr_id_get_node_ops()->destory_node(node, mode); | 516 | return shr_id_get_node_ops()->destory_node(node, mode); |
| 507 | } | 517 | } |
| 508 | 518 | ||
| 509 | - trs_debug( | 519 | + trs_debug("Not support destroy handle. (devid=%u; tsid=%u; name=%s; type=%d)\n", node->attr.inst.devid, |
| 510 | - "Not support destroy handle. (devid=%u; tsid=%u; name=%s; type=%d)\n", node->attr.inst.devid, | 520 | + node->attr.inst.tsid, node->attr.name, node->attr.type); |
| 511 | - node->attr.inst.tsid, node->attr.name, node->attr.type); | ||
| 512 | return 0; | 521 | return 0; |
| 513 | } | 522 | } |
| 514 | 523 | ||
| @@ -528,9 +537,8 @@ int shr_id_node_set_attr(const char *name, int type, ka_pid_t pid) | |||
| 528 | if (ret == 0) { | 537 | if (ret == 0) { |
| 529 | trs_info("Set attribute success.(name=%s)\n", name); | 538 | trs_info("Set attribute success.(name=%s)\n", name); |
| 530 | } else { | 539 | } else { |
| 531 | - trs_err( | 540 | + trs_err("Shr node can't set attr.(need_wlist=%d; create_pid=%d; current_pid=%d; ret=%d)\n", node->need_wlist, |
| 532 | - "Shr node can't set attr.(need_wlist=%d; create_pid=%d; current_pid=%d; ret=%d)\n", node->need_wlist, | 541 | + node->attr.pid, pid, ret); |
| 533 | - node->attr.pid, pid, ret); | ||
| 534 | } | 542 | } |
| 535 | _shr_id_node_put(node); | 543 | _shr_id_node_put(node); |
| 536 | return ret; | 544 | return ret; |
| @@ -586,9 +594,9 @@ int shr_id_node_destroy(const char *name, int type, ka_pid_t pid, u32 mode) | |||
| 586 | if (ret == 0) { | 594 | if (ret == 0) { |
| 587 | /* Decrease ref when shr_id_node created. */ | 595 | /* Decrease ref when shr_id_node created. */ |
| 588 | _shr_id_node_put(node); | 596 | _shr_id_node_put(node); |
| 589 | - trs_debug( | 597 | + trs_debug("Destroy succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; ref=%u)\n", node->attr.inst.devid, |
| 590 | - "Destroy succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u; ref=%u)\n", node->attr.inst.devid, | 598 | + node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id, |
| 591 | - node->attr.inst.tsid, node->attr.name, node->attr.type, node->attr.id, kref_safe_read(&node->ref)); | 599 | + kref_safe_read(&node->ref)); |
| 592 | } else { | 600 | } else { |
| 593 | 601 | ||
| 594 | ka_task_spin_lock(&node->lock); | 602 | ka_task_spin_lock(&node->lock); |
| @@ -601,8 +609,8 @@ int shr_id_node_destroy(const char *name, int type, ka_pid_t pid, u32 mode) | |||
| 601 | return ret; | 609 | return ret; |
| 602 | } | 610 | } |
| 603 | 611 | ||
| 604 | -static int _shr_id_node_open( | 612 | +static int _shr_id_node_open(struct shr_id_node *node, ka_pid_t pid, unsigned long start_time, |
| 605 | - struct shr_id_node *node, ka_pid_t pid, unsigned long start_time, struct shr_id_node_op_attr *attr) | 613 | + struct shr_id_node_op_attr *attr) |
| 606 | { | 614 | { |
| 607 | int idx; | 615 | int idx; |
| 608 | 616 | ||
| @@ -653,13 +661,12 @@ int shr_id_node_open(const char *name, ka_pid_t pid, unsigned long start_time, s | |||
| 653 | ret = _shr_id_node_open(node, pid, start_time, attr); | 661 | ret = _shr_id_node_open(node, pid, start_time, attr); |
| 654 | ka_task_spin_unlock(&node->lock); | 662 | ka_task_spin_unlock(&node->lock); |
| 655 | if (ret != 0) { | 663 | if (ret != 0) { |
| 656 | - trs_err( | 664 | + trs_err("Open fail. (name=%s; type=%d; pid=%d; ret=%d; attr=%d)\n", name, attr->type, pid, ret, |
| 657 | - "Open fail. (name=%s; type=%d; pid=%d; ret=%d; attr=%d)\n", name, attr->type, pid, ret, node->need_wlist); | 665 | + node->need_wlist); |
| 658 | _shr_id_node_put(node); | 666 | _shr_id_node_put(node); |
| 659 | } else { | 667 | } else { |
| 660 | - trs_debug( | 668 | + trs_debug("Open succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", attr->inst.devid, attr->inst.tsid, |
| 661 | - "Open succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", attr->inst.devid, attr->inst.tsid, name, | 669 | + name, attr->type, attr->id); |
| 662 | - attr->type, attr->id); | ||
| 663 | } | 670 | } |
| 664 | 671 | ||
| 665 | return ret; | 672 | return ret; |
| @@ -696,9 +703,8 @@ int shr_id_node_close(const char *name, int type, ka_pid_t pid) | |||
| 696 | if (ret == 0) { | 703 | if (ret == 0) { |
| 697 | /* Decrease ref when shr_id_node opened. */ | 704 | /* Decrease ref when shr_id_node opened. */ |
| 698 | _shr_id_node_put(node); | 705 | _shr_id_node_put(node); |
| 699 | - trs_debug( | 706 | + trs_debug("Close succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", node->attr.inst.devid, |
| 700 | - "Close succeed. (devid=%u; tsid=%u; name=%s; type=%d; id=%u)\n", node->attr.inst.devid, | 707 | + node->attr.inst.tsid, name, type, node->attr.id); |
| 701 | - node->attr.inst.tsid, name, type, node->attr.id); | ||
| 702 | } | 708 | } |
| 703 | _shr_id_node_put(node); | 709 | _shr_id_node_put(node); |
| 704 | } | 710 | } |
| @@ -115,8 +115,8 @@ typedef int (*devdrv_register_p2p_msg_proc_ops)(enum devdrv_msg_client_type msg_ | |||
| 115 | 115 | ||
| 116 | typedef int (*devdrv_unregister_p2p_msg_proc_ops)(enum devdrv_msg_client_type msg_type); | 116 | typedef int (*devdrv_unregister_p2p_msg_proc_ops)(enum devdrv_msg_client_type msg_type); |
| 117 | 117 | ||
| 118 | -typedef int (*devdrv_p2p_msg_send_ops)( | 118 | +typedef int (*devdrv_p2p_msg_send_ops)(u32 local_devid, u32 sdid, enum devdrv_msg_client_type msg_type, |
| 119 | - u32 local_devid, u32 sdid, enum devdrv_msg_client_type msg_type, struct data_input_info *data_info); | 119 | + struct data_input_info *data_info); |
| 120 | 120 | ||
| 121 | static devdrv_p2p_msg_send_ops devdrv_p2p_msg_send_func = NULL; | 121 | static devdrv_p2p_msg_send_ops devdrv_p2p_msg_send_func = NULL; |
| 122 | 122 | ||
| @@ -216,8 +216,8 @@ STATIC int shr_id_create_shadow_node_msg_send(struct shr_id_node_op_attr *attr, | |||
| 216 | 216 | ||
| 217 | ret = trs_pod_msg_send(attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data)); | 217 | ret = trs_pod_msg_send(attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data)); |
| 218 | if (ret != 0) { | 218 | if (ret != 0) { |
| 219 | - trs_err( | 219 | + trs_err("Send fail. (devid=%u; sdid=0x%x; ret=%d; result=%d)\n", attr->inst.devid, sdid, ret, |
| 220 | - "Send fail. (devid=%u; sdid=0x%x; ret=%d; result=%d)\n", attr->inst.devid, sdid, ret, msg.header.result); | 220 | + msg.header.result); |
| 221 | return ret; | 221 | return ret; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| @@ -248,8 +248,8 @@ STATIC int shr_id_pod_set_pid_msg_send(struct shr_id_node_op_attr *attr, u32 sdi | |||
| 248 | return 0; | 248 | return 0; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | -STATIC int shr_id_destory_shadow_node_msg_send( | 251 | +STATIC int shr_id_destory_shadow_node_msg_send(struct shr_id_node_op_attr *attr, u32 sdid, int pid, int *cmd_result, |
| 252 | - struct shr_id_node_op_attr *attr, u32 sdid, int pid, int *cmd_result, u32 mode) | 252 | + u32 mode) |
| 253 | { | 253 | { |
| 254 | struct shr_id_pod_destroy_msg *destory_msg = NULL; | 254 | struct shr_id_pod_destroy_msg *destory_msg = NULL; |
| 255 | struct trs_pod_msg_data msg; | 255 | struct trs_pod_msg_data msg; |
| @@ -275,17 +275,16 @@ STATIC int shr_id_destory_shadow_node_msg_send( | |||
| 275 | 275 | ||
| 276 | ret = _trs_pod_msg_send(attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data), cmd_result, mode); | 276 | ret = _trs_pod_msg_send(attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data), cmd_result, mode); |
| 277 | if ((ret != 0) || ((*cmd_result) != 0)) { | 277 | if ((ret != 0) || ((*cmd_result) != 0)) { |
| 278 | - trs_debug( | 278 | + trs_debug("Should send again. (devid=%u; sdid=%u; ret=%d; cmd_result=%d)\n", attr->inst.devid, sdid, ret, |
| 279 | - "Should send again. (devid=%u; sdid=%u; ret=%d; cmd_result=%d)\n", attr->inst.devid, sdid, ret, | 279 | + *cmd_result); |
| 280 | - *cmd_result); | ||
| 281 | return ret; | 280 | return ret; |
| 282 | } | 281 | } |
| 283 | return 0; | 282 | return 0; |
| 284 | } | 283 | } |
| 285 | 284 | ||
| 286 | 285 | ||
| 287 | -STATIC int devdrv_s2s_async_msg_recv_stub( | 286 | +STATIC int devdrv_s2s_async_msg_recv_stub(u32 devid, u32 sdid, enum devdrv_s2s_msg_type msg_type, |
| 288 | - u32 devid, u32 sdid, enum devdrv_s2s_msg_type msg_type, struct data_recv_info *data_info) | 287 | + struct data_recv_info *data_info) |
| 289 | { | 288 | { |
| 290 | (void)devid; | 289 | (void)devid; |
| 291 | (void)sdid; | 290 | (void)sdid; |
| @@ -330,16 +329,15 @@ int trs_pod_msg_recv_async(u32 devid, u32 sdid, void *msg, size_t size, int *cmd | |||
| 330 | 329 | ||
| 331 | *cmd_result = (int)tmp_msg->header.result; | 330 | *cmd_result = (int)tmp_msg->header.result; |
| 332 | if (mode == DEVDRV_S2S_END_RECV) { | 331 | if (mode == DEVDRV_S2S_END_RECV) { |
| 333 | - trs_warn( | 332 | + trs_warn("Current node loop timeout, release s2s channel." |
| 334 | - "Current node loop timeout, release s2s channel." | 333 | + "(mode=%u; devid=%u; sdid=%u; ret=%d)\n", |
| 335 | - "(mode=%u; devid=%u; sdid=%u; ret=%d)\n", | 334 | + mode, devid, sdid, ret); |
| 336 | - mode, devid, sdid, ret); | ||
| 337 | } | 335 | } |
| 338 | return ret; | 336 | return ret; |
| 339 | } | 337 | } |
| 340 | 338 | ||
| 341 | -STATIC int shr_id_destory_shadow_node_msg_recv( | 339 | +STATIC int shr_id_destory_shadow_node_msg_recv(struct shr_id_node_op_attr *attr, u32 sdid, int pid, int *cmd_result, |
| 342 | - struct shr_id_node_op_attr *attr, u32 sdid, int pid, int *cmd_result, u32 mode) | 340 | + u32 mode) |
| 343 | { | 341 | { |
| 344 | struct shr_id_pod_destroy_msg *destory_msg = NULL; | 342 | struct shr_id_pod_destroy_msg *destory_msg = NULL; |
| 345 | struct trs_pod_msg_data msg; | 343 | struct trs_pod_msg_data msg; |
| @@ -374,12 +372,11 @@ STATIC int shr_id_query_shadow_node_msg_send(struct shr_id_node_op_attr *attr, u | |||
| 374 | query_msg->name[i] = attr->name[i]; | 372 | query_msg->name[i] = attr->name[i]; |
| 375 | } | 373 | } |
| 376 | 374 | ||
| 377 | - ret = _trs_pod_msg_send( | 375 | + ret = _trs_pod_msg_send(attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data), cmd_result, |
| 378 | - attr->inst.devid, sdid, &msg, sizeof(struct trs_pod_msg_data), cmd_result, DEVDRV_S2S_SYNC_MODE); | 376 | + DEVDRV_S2S_SYNC_MODE); |
| 379 | if ((ret != 0) || ((*cmd_result) != 0)) { | 377 | if ((ret != 0) || ((*cmd_result) != 0)) { |
| 380 | - trs_debug( | 378 | + trs_debug("Should send again. (devid=%u; sdid=%u; ret=%d; cmd_result=%d)\n", attr->inst.devid, sdid, ret, |
| 381 | - "Should send again. (devid=%u; sdid=%u; ret=%d; cmd_result=%d)\n", attr->inst.devid, sdid, ret, | 379 | + *cmd_result); |
| 382 | - *cmd_result); | ||
| 383 | return ret; | 380 | return ret; |
| 384 | } | 381 | } |
| 385 | return 0; | 382 | return 0; |
| @@ -388,8 +385,8 @@ STATIC int shr_id_query_shadow_node_msg_send(struct shr_id_node_op_attr *attr, u | |||
| 388 | void shr_id_recycle_work(ka_work_struct_t *p_work); | 385 | void shr_id_recycle_work(ka_work_struct_t *p_work); |
| 389 | STATIC struct shr_id_spod_info *shr_id_spod_info_create(void *node, struct shr_id_node_op_attr *attr) | 386 | STATIC struct shr_id_spod_info *shr_id_spod_info_create(void *node, struct shr_id_node_op_attr *attr) |
| 390 | { | 387 | { |
| 391 | - struct shr_id_spod_info *spod_info = | 388 | + struct shr_id_spod_info *spod_info = trs_kvzalloc(sizeof(struct shr_id_spod_info), |
| 392 | - trs_kvzalloc(sizeof(struct shr_id_spod_info), KA_GFP_ATOMIC | __KA_GFP_ACCOUNT); | 389 | + KA_GFP_ATOMIC | __KA_GFP_ACCOUNT); |
| 393 | if (spod_info == NULL) { | 390 | if (spod_info == NULL) { |
| 394 | return spod_info; | 391 | return spod_info; |
| 395 | } | 392 | } |
| @@ -460,9 +457,9 @@ void shr_id_recycle_work(ka_work_struct_t *p_work) | |||
| 460 | continue; | 457 | continue; |
| 461 | } | 458 | } |
| 462 | ret = shr_id_query_shadow_node_msg_send(&attr, spod_info->create_info[i].sdid, &cmd_result); | 459 | ret = shr_id_query_shadow_node_msg_send(&attr, spod_info->create_info[i].sdid, &cmd_result); |
| 463 | - trs_debug( | 460 | + trs_debug("Query shadow. (devid=%u; serverid=%u; sdid=%u; name=%s; type=%d; id=%u; ret=%d; result=%d)\n", |
| 464 | - "Query shadow. (devid=%u; serverid=%u; sdid=%u; name=%s; type=%d; id=%u; ret=%d; result=%d)\n", | 461 | + attr.inst.devid, i, spod_info->create_info[i].sdid, attr.name, attr.type, attr.id, ret, |
| 465 | - attr.inst.devid, i, spod_info->create_info[i].sdid, attr.name, attr.type, attr.id, ret, cmd_result); | 462 | + cmd_result); |
| 466 | 463 | ||
| 467 | spod_info->create_info[i].server_abnormal = ret; | 464 | spod_info->create_info[i].server_abnormal = ret; |
| 468 | if ((ret == 0) && (cmd_result == 0)) { | 465 | if ((ret == 0) && (cmd_result == 0)) { |
| @@ -480,8 +477,8 @@ void shr_id_recycle_work(ka_work_struct_t *p_work) | |||
| 480 | 477 | ||
| 481 | ret = shr_id_get_recycle_strategy(&attr, spod_server_abnormal, shadow_node_exist); | 478 | ret = shr_id_get_recycle_strategy(&attr, spod_server_abnormal, shadow_node_exist); |
| 482 | if (ret == TRS_SHADOW_NODE_RETRY) { | 479 | if (ret == TRS_SHADOW_NODE_RETRY) { |
| 483 | - (void)ka_task_schedule_delayed_work( | 480 | + (void)ka_task_schedule_delayed_work(&spod_info->shrid_recycle_work, |
| 484 | - &spod_info->shrid_recycle_work, ka_system_msecs_to_jiffies(300)); /* 300 ms */ | 481 | + ka_system_msecs_to_jiffies(300)); /* 300 ms */ |
| 485 | } else if (ret == TRS_SHADOW_NODE_DESTORY) { | 482 | } else if (ret == TRS_SHADOW_NODE_DESTORY) { |
| 486 | shr_id_node_priv_mutex_lock(shrid_node); | 483 | shr_id_node_priv_mutex_lock(shrid_node); |
| 487 | ka_base_atomic_set(&spod_info->in_recycling, 0); | 484 | ka_base_atomic_set(&spod_info->in_recycling, 0); |
| @@ -489,11 +486,10 @@ void shr_id_recycle_work(ka_work_struct_t *p_work) | |||
| 489 | shr_id_node_priv_mutex_unlock(shrid_node); | 486 | shr_id_node_priv_mutex_unlock(shrid_node); |
| 490 | } else { | 487 | } else { |
| 491 | ka_base_atomic_set(&spod_info->in_recycling, 0); | 488 | ka_base_atomic_set(&spod_info->in_recycling, 0); |
| 492 | - trs_debug( | 489 | + trs_debug("NOT destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; server_abnormal=%u;" |
| 493 | - "NOT destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; server_abnormal=%u;" | 490 | + " shadow_exist=%u; ret=%d)\n", |
| 494 | - " shadow_exist=%u; ret=%d)\n", | 491 | + attr.inst.devid, spod_info->wlist[0].sdid, attr.name, attr.type, attr.id, spod_server_abnormal, |
| 495 | - attr.inst.devid, spod_info->wlist[0].sdid, attr.name, attr.type, attr.id, spod_server_abnormal, | 492 | + shadow_node_exist, ret); |
| 496 | - shadow_node_exist, ret); | ||
| 497 | } | 493 | } |
| 498 | shr_id_node_put(shrid_node); | 494 | shr_id_node_put(shrid_node); |
| 499 | } | 495 | } |
| @@ -549,9 +545,8 @@ static void shr_id_spod_server_abnormal(struct shr_id_spod_info *spod_info, int | |||
| 549 | spod_info->shadow_node_num--; | 545 | spod_info->shadow_node_num--; |
| 550 | } | 546 | } |
| 551 | 547 | ||
| 552 | -static void shr_id_spod_async_msg_send( | 548 | +static void shr_id_spod_async_msg_send(struct shr_id_proc_ctx *proc_ctx, struct shr_id_spod_info *spod_info, |
| 553 | - struct shr_id_proc_ctx *proc_ctx, struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, | 549 | + bool *spod_server_abnormal, bool *shadow_node_exist, bool is_timeout) |
| 554 | - bool *shadow_node_exist, bool is_timeout) | ||
| 555 | { | 550 | { |
| 556 | int i, ret, cmd_result; | 551 | int i, ret, cmd_result; |
| 557 | 552 | ||
| @@ -568,56 +563,50 @@ static void shr_id_spod_async_msg_send( | |||
| 568 | continue; | 563 | continue; |
| 569 | 564 | ||
| 570 | } | 565 | } |
| 571 | - ret = shr_id_destory_shadow_node_msg_send( | 566 | + ret = shr_id_destory_shadow_node_msg_send(&spod_info->attr, spod_info->create_info[i].sdid, |
| 572 | - &spod_info->attr, spod_info->create_info[i].sdid, spod_info->create_info[i].pid, &cmd_result, | 567 | + spod_info->create_info[i].pid, &cmd_result, |
| 573 | - DEVDRV_S2S_ASYNC_MODE); | 568 | + DEVDRV_S2S_ASYNC_MODE); |
| 574 | if (ret == 0) { | 569 | if (ret == 0) { |
| 575 | 570 | ||
| 576 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_SEND; | 571 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_SEND; |
| 577 | - trs_debug( | 572 | + trs_debug("Async send success. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", |
| 578 | - "Async send success. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", | 573 | + spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, |
| 579 | - spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, | 574 | + spod_info->attr.id, spod_info->create_info[i].status, ret); |
| 580 | - spod_info->attr.id, spod_info->create_info[i].status, ret); | ||
| 581 | 575 | ||
| 582 | } else if (ret == -EBUSY) { | 576 | } else if (ret == -EBUSY) { |
| 583 | - trs_debug( | 577 | + trs_debug("Async send busy. Need send again.(devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", |
| 584 | - "Async send busy. Need send again.(devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", | 578 | + spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, |
| 585 | - spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, | 579 | + spod_info->attr.id, spod_info->create_info[i].status, ret); |
| 586 | - spod_info->attr.id, spod_info->create_info[i].status, ret); | ||
| 587 | } else { | 580 | } else { |
| 588 | 581 | ||
| 589 | shr_id_hash_add(proc_ctx, spod_info->create_info[i].sdid); | 582 | shr_id_hash_add(proc_ctx, spod_info->create_info[i].sdid); |
| 590 | shr_id_spod_server_abnormal(spod_info, i, spod_server_abnormal); | 583 | shr_id_spod_server_abnormal(spod_info, i, spod_server_abnormal); |
| 591 | - trs_warn( | 584 | + trs_warn("Send spod server is abnormal. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", |
| 592 | - "Send spod server is abnormal. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", | 585 | + spod_info->attr.inst.devid, spod_info->wlist[0].sdid, spod_info->attr.name, spod_info->attr.id, |
| 593 | - spod_info->attr.inst.devid, spod_info->wlist[0].sdid, spod_info->attr.name, spod_info->attr.id, | 586 | + spod_info->create_info[i].status, ret); |
| 594 | - spod_info->create_info[i].status, ret); | ||
| 595 | 587 | ||
| 596 | } | 588 | } |
| 597 | } | 589 | } |
| 598 | } | 590 | } |
| 599 | } | 591 | } |
| 600 | 592 | ||
| 601 | -static void shr_id_spod_async_msg_recv( | 593 | +static void shr_id_spod_async_msg_recv(struct shr_id_proc_ctx *proc_ctx, struct shr_id_spod_info *spod_info, |
| 602 | - struct shr_id_proc_ctx *proc_ctx, struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, | 594 | + bool *spod_server_abnormal, bool *shadow_node_exist, u32 recv_mode) |
| 603 | - bool *shadow_node_exist, u32 recv_mode) | ||
| 604 | { | 595 | { |
| 605 | int i, ret, cmd_result; | 596 | int i, ret, cmd_result; |
| 606 | 597 | ||
| 607 | for (i = 0; i < SHR_ID_PID_SERVER_ID_MAX_NUM; i++) { | 598 | for (i = 0; i < SHR_ID_PID_SERVER_ID_MAX_NUM; i++) { |
| 608 | if (spod_info->create_info[i].pid != 0 && spod_info->create_info[i].status == TRS_S2S_MSG_STATUS_SEND) { | 599 | if (spod_info->create_info[i].pid != 0 && spod_info->create_info[i].status == TRS_S2S_MSG_STATUS_SEND) { |
| 609 | - ret = shr_id_destory_shadow_node_msg_recv( | 600 | + ret = shr_id_destory_shadow_node_msg_recv(&spod_info->attr, spod_info->create_info[i].sdid, |
| 610 | - &spod_info->attr, spod_info->create_info[i].sdid, spod_info->create_info[i].pid, &cmd_result, | 601 | + spod_info->create_info[i].pid, &cmd_result, recv_mode); |
| 611 | - recv_mode); | ||
| 612 | spod_info->create_info[i].server_abnormal = ret; | 602 | spod_info->create_info[i].server_abnormal = ret; |
| 613 | if ((ret == 0) && (cmd_result == 0)) { | 603 | if ((ret == 0) && (cmd_result == 0)) { |
| 614 | spod_info->shadow_node_num--; | 604 | spod_info->shadow_node_num--; |
| 615 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_RECV; | 605 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_RECV; |
| 616 | shr_id_spod_set_sdid_pid_zero(spod_info, i); | 606 | shr_id_spod_set_sdid_pid_zero(spod_info, i); |
| 617 | - trs_debug( | 607 | + trs_debug("Async recv success. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d; result=%d)\n", |
| 618 | - "Async recv success. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d; result=%d)\n", | 608 | + spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, |
| 619 | - spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, | 609 | + spod_info->attr.id, spod_info->create_info[i].status, ret, cmd_result); |
| 620 | - spod_info->attr.id, spod_info->create_info[i].status, ret, cmd_result); | ||
| 621 | } else if ((ret == 0) && (cmd_result == -EEXIST)) { | 610 | } else if ((ret == 0) && (cmd_result == -EEXIST)) { |
| 622 | spod_info->shadow_node_num--; | 611 | spod_info->shadow_node_num--; |
| 623 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_RECV; | 612 | spod_info->create_info[i].status = TRS_S2S_MSG_STATUS_RECV; |
| @@ -630,26 +619,24 @@ static void shr_id_spod_async_msg_recv( | |||
| 630 | 619 | ||
| 631 | } else if (ret == -EAGAIN) { | 620 | } else if (ret == -EAGAIN) { |
| 632 | 621 | ||
| 633 | - trs_debug( | 622 | + trs_debug("Async recv busy. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", |
| 634 | - "Async recv busy. (devid=%u; sdid=%u; name=%s; id=%u; status=%d; ret=%d;)\n", | 623 | + spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, |
| 635 | - spod_info->attr.inst.devid, spod_info->create_info[i].sdid, spod_info->attr.name, | 624 | + spod_info->attr.id, spod_info->create_info[i].status, ret); |
| 636 | - spod_info->attr.id, spod_info->create_info[i].status, ret); | ||
| 637 | 625 | ||
| 638 | } else { | 626 | } else { |
| 639 | shr_id_hash_add(proc_ctx, spod_info->create_info[i].sdid); | 627 | shr_id_hash_add(proc_ctx, spod_info->create_info[i].sdid); |
| 640 | shr_id_spod_server_abnormal(spod_info, i, spod_server_abnormal); | 628 | shr_id_spod_server_abnormal(spod_info, i, spod_server_abnormal); |
| 641 | - trs_warn( | 629 | + trs_warn("Recv spod server is abnormal. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; ret=%d; " |
| 642 | - "Recv spod server is abnormal. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; ret=%d; " | 630 | + "in_recycle=%d)\n", |
| 643 | - "in_recycle=%d)\n", | 631 | + spod_info->attr.inst.devid, spod_info->wlist[0].sdid, spod_info->attr.name, |
| 644 | - spod_info->attr.inst.devid, spod_info->wlist[0].sdid, spod_info->attr.name, spod_info->attr.type, | 632 | + spod_info->attr.type, spod_info->attr.id, ret, ka_base_atomic_read(&spod_info->in_recycling)); |
| 645 | - spod_info->attr.id, ret, ka_base_atomic_read(&spod_info->in_recycling)); | ||
| 646 | } | 633 | } |
| 647 | } | 634 | } |
| 648 | } | 635 | } |
| 649 | } | 636 | } |
| 650 | 637 | ||
| 651 | -static int shr_id_async_send_and_recv( | 638 | +static int shr_id_async_send_and_recv(struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, |
| 652 | - struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, bool *shadow_node_exist, bool is_timeout) | 639 | + bool *shadow_node_exist, bool is_timeout) |
| 653 | { | 640 | { |
| 654 | struct shr_id_proc_ctx *proc_ctx; | 641 | struct shr_id_proc_ctx *proc_ctx; |
| 655 | u32 recv_mode; | 642 | u32 recv_mode; |
| @@ -667,8 +654,8 @@ static int shr_id_async_send_and_recv( | |||
| 667 | return (spod_info->shadow_node_num == 0) ? 0 : -1; | 654 | return (spod_info->shadow_node_num == 0) ? 0 : -1; |
| 668 | } | 655 | } |
| 669 | 656 | ||
| 670 | -static void shadow_node_loop_for_async_send_recv( | 657 | +static void shadow_node_loop_for_async_send_recv(struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, |
| 671 | - struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, bool *shadow_node_exist) | 658 | + bool *shadow_node_exist) |
| 672 | { | 659 | { |
| 673 | u64 start_time, current_time, time_cost; | 660 | u64 start_time, current_time, time_cost; |
| 674 | bool is_timeout = false; | 661 | bool is_timeout = false; |
| @@ -684,9 +671,8 @@ static void shadow_node_loop_for_async_send_recv( | |||
| 684 | current_time = ka_system_ktime_get_ns(); | 671 | current_time = ka_system_ktime_get_ns(); |
| 685 | time_cost = current_time - start_time; | 672 | time_cost = current_time - start_time; |
| 686 | if (time_cost >= MAX_LOOP_TIME) { | 673 | if (time_cost >= MAX_LOOP_TIME) { |
| 687 | - trs_debug( | 674 | + trs_debug("The async collection loop has timed out.(devid=%u, pid=%u, name=%s, time_cost=%llu)\n", |
| 688 | - "The async collection loop has timed out.(devid=%u, pid=%u, name=%s, time_cost=%llu)\n", | 675 | + spod_info->attr.inst.devid, spod_info->attr.pid, spod_info->attr.name, time_cost); |
| 689 | - spod_info->attr.inst.devid, spod_info->attr.pid, spod_info->attr.name, time_cost); | ||
| 690 | is_timeout = true; | 676 | is_timeout = true; |
| 691 | } | 677 | } |
| 692 | } | 678 | } |
| @@ -695,16 +681,15 @@ static void shadow_node_loop_for_async_send_recv( | |||
| 695 | } | 681 | } |
| 696 | } | 682 | } |
| 697 | 683 | ||
| 698 | -static void shadow_node_loop_for_sync_send( | 684 | +static void shadow_node_loop_for_sync_send(struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, |
| 699 | - struct shr_id_spod_info *spod_info, bool *spod_server_abnormal, bool *shadow_node_exist) | 685 | + bool *shadow_node_exist) |
| 700 | { | 686 | { |
| 701 | int i, ret, cmd_result; | 687 | int i, ret, cmd_result; |
| 702 | 688 | ||
| 703 | for (i = 0; i < SHR_ID_PID_SERVER_ID_MAX_NUM; i++) { | 689 | for (i = 0; i < SHR_ID_PID_SERVER_ID_MAX_NUM; i++) { |
| 704 | if (spod_info->create_info[i].pid != 0) { | 690 | if (spod_info->create_info[i].pid != 0) { |
| 705 | - ret = shr_id_destory_shadow_node_msg_send( | 691 | + ret = shr_id_destory_shadow_node_msg_send(&spod_info->attr, spod_info->create_info[i].sdid, |
| 706 | - &spod_info->attr, spod_info->create_info[i].sdid, spod_info->create_info[i].pid, &cmd_result, | 692 | + spod_info->create_info[i].pid, &cmd_result, DEVDRV_S2S_SYNC_MODE); |
| 707 | - DEVDRV_S2S_SYNC_MODE); | ||
| 708 | if ((ret == 0) && (cmd_result == 0)) { | 693 | if ((ret == 0) && (cmd_result == 0)) { |
| 709 | spod_info->create_info[i].sdid = 0; | 694 | spod_info->create_info[i].sdid = 0; |
| 710 | spod_info->create_info[i].pid = 0; | 695 | spod_info->create_info[i].pid = 0; |
| @@ -757,17 +742,15 @@ STATIC int shr_id_destroy_shadow_node_async(void *node, u32 mode) | |||
| 757 | (void)ka_task_schedule_delayed_work(&spod_info->shrid_recycle_work, 0); | 742 | (void)ka_task_schedule_delayed_work(&spod_info->shrid_recycle_work, 0); |
| 758 | ret = 0; | 743 | ret = 0; |
| 759 | } else if ((ret == TRS_SHADOW_NODE_DESTORY) && (ka_base_atomic_read(&spod_info->in_recycling) == 0)) { | 744 | } else if ((ret == TRS_SHADOW_NODE_DESTORY) && (ka_base_atomic_read(&spod_info->in_recycling) == 0)) { |
| 760 | - trs_debug( | 745 | + trs_debug("Destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u;)\n", attr.inst.devid, |
| 761 | - "Destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u;)\n", attr.inst.devid, | 746 | + spod_info->wlist[0].sdid, attr.name, attr.type, attr.id); |
| 762 | - spod_info->wlist[0].sdid, attr.name, attr.type, attr.id); | ||
| 763 | shr_id_spod_info_destroy(spod_info); | 747 | shr_id_spod_info_destroy(spod_info); |
| 764 | ret = 0; | 748 | ret = 0; |
| 765 | } else { | 749 | } else { |
| 766 | - trs_warn( | 750 | + trs_warn("NOT destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; server_abnormal=%u;" |
| 767 | - "NOT destroy shadow. (devid=%u; sdid=%u; name=%s; type=%d; id=%u; server_abnormal=%u;" | 751 | + " shadow_exist=%u; ret=%d; in_recycle=%d)\n", |
| 768 | - " shadow_exist=%u; ret=%d; in_recycle=%d)\n", | 752 | + attr.inst.devid, spod_info->wlist[0].sdid, attr.name, attr.type, attr.id, spod_server_abnormal, |
| 769 | - attr.inst.devid, spod_info->wlist[0].sdid, attr.name, attr.type, attr.id, spod_server_abnormal, | 753 | + shadow_node_exist, ret, ka_base_atomic_read(&spod_info->in_recycling)); |
| 770 | - shadow_node_exist, ret, ka_base_atomic_read(&spod_info->in_recycling)); | ||
| 771 | ret = -EPIPE; | 754 | ret = -EPIPE; |
| 772 | } | 755 | } |
| 773 | 756 | ||
| @@ -872,9 +855,8 @@ STATIC int shr_id_pod_set_pid(struct shr_id_node_op_attr *attr, u32 serverid, u3 | |||
| 872 | return ret; | 855 | return ret; |
| 873 | } | 856 | } |
| 874 | 857 | ||
| 875 | - trs_debug( | 858 | + trs_debug("Set pod pid. (devid=%u; serverid=%u; sdid=%u; name=%s; type=%d; id=%u; pid=%d)\n", attr->inst.devid, |
| 876 | - "Set pod pid. (devid=%u; serverid=%u; sdid=%u; name=%s; type=%d; id=%u; pid=%d)\n", attr->inst.devid, serverid, | 859 | + serverid, sdid, attr->name, attr->type, attr->id, pid); |
| 877 | - sdid, attr->name, attr->type, attr->id, pid); | ||
| 878 | 860 | ||
| 879 | if (spod_info->create_info[serverid].pid == 0) { | 861 | if (spod_info->create_info[serverid].pid == 0) { |
| 880 | ret = shr_id_create_shadow_node_msg_send(attr, sdid, pid); | 862 | ret = shr_id_create_shadow_node_msg_send(attr, sdid, pid); |
| @@ -987,9 +969,8 @@ STATIC int shr_id_set_pod_pid(struct shr_id_proc_ctx *proc_ctx, unsigned long ar | |||
| 987 | ret = dbl_parse_sdid(ioctl_info.sdid, &parse); | 969 | ret = dbl_parse_sdid(ioctl_info.sdid, &parse); |
| 988 | 970 | ||
| 989 | if ((ret != 0) || (parse.server_id >= SHR_ID_PID_SERVER_ID_MAX_NUM)) { | 971 | if ((ret != 0) || (parse.server_id >= SHR_ID_PID_SERVER_ID_MAX_NUM)) { |
| 990 | - trs_err( | 972 | + trs_err("Parse fail. (ret=%d; server_id=%u; server id range is [0, %u].)\n", ret, parse.server_id, |
| 991 | - "Parse fail. (ret=%d; server_id=%u; server id range is [0, %u].)\n", ret, parse.server_id, | 973 | + (SHR_ID_PID_SERVER_ID_MAX_NUM - 1)); |
| 992 | - (SHR_ID_PID_SERVER_ID_MAX_NUM - 1)); | ||
| 993 | return -EINVAL; | 974 | return -EINVAL; |
| 994 | } | 975 | } |
| 995 | 976 | ||
| @@ -1030,8 +1011,8 @@ STATIC int shr_id_pod_name_update(u32 devid, char *name) | |||
| 1030 | return 0; | 1011 | return 0; |
| 1031 | } | 1012 | } |
| 1032 | 1013 | ||
| 1033 | -bool hal_kernel_trs_is_belong_to_pod_proc( | 1014 | +bool hal_kernel_trs_is_belong_to_pod_proc(unsigned int sdid, unsigned int tsid, int pid, int res_type, |
| 1034 | - unsigned int sdid, unsigned int tsid, int pid, int res_type, unsigned int res_id) | 1015 | + unsigned int res_id) |
| 1035 | { | 1016 | { |
| 1036 | struct trs_id_inst inst = {.devid = sdid, .tsid = tsid}; | 1017 | struct trs_id_inst inst = {.devid = sdid, .tsid = tsid}; |
| 1037 | return shr_id_is_belong_to_proc(&inst, pid, res_type, res_id); | 1018 | return shr_id_is_belong_to_proc(&inst, pid, res_type, res_id); |
| @@ -1053,8 +1034,8 @@ STATIC int shr_id_spod_init(void) | |||
| 1053 | trs_warn("Lookup symbol: %s not found.\n", DEVDRV_P2P_MSG_SEND_OPS); | 1034 | trs_warn("Lookup symbol: %s not found.\n", DEVDRV_P2P_MSG_SEND_OPS); |
| 1054 | return DRV_ERROR_NONE; | 1035 | return DRV_ERROR_NONE; |
| 1055 | } | 1036 | } |
| 1056 | - devdrv_register_p2p_msg_proc_ops_func = | 1037 | + devdrv_register_p2p_msg_proc_ops_func = (devdrv_register_p2p_msg_proc_ops)(uintptr_t)__ka_system_symbol_get( |
| 1057 | - (devdrv_register_p2p_msg_proc_ops)(uintptr_t)__ka_system_symbol_get(DEVDRV_REGISTER_P2P_MSG_PROC_OPS); | 1038 | + DEVDRV_REGISTER_P2P_MSG_PROC_OPS); |
| 1058 | if (devdrv_register_p2p_msg_proc_ops_func == NULL) { | 1039 | if (devdrv_register_p2p_msg_proc_ops_func == NULL) { |
| 1059 | trs_warn("Lookup symbol: %s not found.\n", DEVDRV_REGISTER_P2P_MSG_PROC_OPS); | 1040 | trs_warn("Lookup symbol: %s not found.\n", DEVDRV_REGISTER_P2P_MSG_PROC_OPS); |
| 1060 | return DRV_ERROR_NONE; | 1041 | return DRV_ERROR_NONE; |
| @@ -1082,8 +1063,8 @@ STATIC void shr_id_spod_uninit(void) | |||
| 1082 | 1063 | ||
| 1083 | devdrv_unregister_p2p_msg_proc_ops devdrv_unregister_p2p_msg_proc_ops_func = NULL; | 1064 | devdrv_unregister_p2p_msg_proc_ops devdrv_unregister_p2p_msg_proc_ops_func = NULL; |
| 1084 | 1065 | ||
| 1085 | - devdrv_unregister_p2p_msg_proc_ops_func = | 1066 | + devdrv_unregister_p2p_msg_proc_ops_func = (devdrv_unregister_p2p_msg_proc_ops)(uintptr_t)__ka_system_symbol_get( |
| 1086 | - (devdrv_unregister_p2p_msg_proc_ops)(uintptr_t)__ka_system_symbol_get(DEVDRV_UNREGISTER_P2P_MSG_PROC_OPS); | 1067 | + DEVDRV_UNREGISTER_P2P_MSG_PROC_OPS); |
| 1087 | if (devdrv_unregister_p2p_msg_proc_ops_func != NULL) { | 1068 | if (devdrv_unregister_p2p_msg_proc_ops_func != NULL) { |
| 1088 | (void)devdrv_unregister_p2p_msg_proc_ops_func(devdrv_msg_client_tsdrv); | 1069 | (void)devdrv_unregister_p2p_msg_proc_ops_func(devdrv_msg_client_tsdrv); |
| 1089 | __ka_system_symbol_put(DEVDRV_UNREGISTER_P2P_MSG_PROC_OPS); | 1070 | __ka_system_symbol_put(DEVDRV_UNREGISTER_P2P_MSG_PROC_OPS); |
| @@ -47,14 +47,13 @@ static int shr_id_get_notify_base_addr(u32 devid, u32 sdid, u64 *base_addr) | |||
| 47 | parse_info.chip_id * SHRID_ASCEND910_93_CHIP_ADDR_OFFSET + | 47 | parse_info.chip_id * SHRID_ASCEND910_93_CHIP_ADDR_OFFSET + |
| 48 | parse_info.die_id * SHRID_ASCEND910_93_DIE_ADDR_OFFSET + SHRID_ASCEND910_93_NOTIFY_ADDR_OFFSET_PER_DIE; | 48 | parse_info.die_id * SHRID_ASCEND910_93_DIE_ADDR_OFFSET + SHRID_ASCEND910_93_NOTIFY_ADDR_OFFSET_PER_DIE; |
| 49 | 49 | ||
| 50 | - trs_debug( | 50 | + trs_debug("Sdid info. (devid=%u; sdid=0x%x; server_id=%u; chip_id=%u; die_id=%u)\n", devid, sdid, |
| 51 | - "Sdid info. (devid=%u; sdid=0x%x; server_id=%u; chip_id=%u; die_id=%u)\n", devid, sdid, parse_info.server_id, | 51 | + parse_info.server_id, parse_info.chip_id, parse_info.die_id); |
| 52 | - parse_info.chip_id, parse_info.die_id); | ||
| 53 | return 0; | 52 | return 0; |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | -STATIC int _shr_id_spod_event_update( | 55 | +STATIC int _shr_id_spod_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 57 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 56 | + struct sched_published_event_func *event_func) |
| 58 | { | 57 | { |
| 59 | struct drvShrIdInfo *info = NULL; | 58 | struct drvShrIdInfo *info = NULL; |
| 60 | u64 base_addr, notify_addr; | 59 | u64 base_addr, notify_addr; |
| @@ -89,9 +88,8 @@ STATIC int _shr_id_spod_event_update( | |||
| 89 | 88 | ||
| 90 | if (event_info->subevent_id == DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG) { /* only shrIdOpen need check shrid. */ | 89 | if (event_info->subevent_id == DRV_SUBEVENT_TRS_SHR_ID_CONFIG_MSG) { /* only shrIdOpen need check shrid. */ |
| 91 | if (!hal_kernel_trs_is_belong_to_pod_proc(sdid, tsid, ka_task_get_current_tgid(), res_type, info->shrid)) { | 90 | if (!hal_kernel_trs_is_belong_to_pod_proc(sdid, tsid, ka_task_get_current_tgid(), res_type, info->shrid)) { |
| 92 | - trs_err( | 91 | + trs_err("Id invalid. (devid=%u; sdid=%u; tsid=%u; pid=%d; type=%u; shrid=%u)\n", devid, sdid, tsid, |
| 93 | - "Id invalid. (devid=%u; sdid=%u; tsid=%u; pid=%d; type=%u; shrid=%u)\n", devid, sdid, tsid, | 92 | + ka_task_get_current_tgid(), info->id_type, info->shrid); |
| 94 | - ka_task_get_current_tgid(), info->id_type, info->shrid); | ||
| 95 | return -EACCES; | 93 | return -EACCES; |
| 96 | } | 94 | } |
| 97 | } | 95 | } |
| @@ -105,15 +103,14 @@ STATIC int _shr_id_spod_event_update( | |||
| 105 | info->rsv[0] = (u32)(notify_addr & 0xffffffffULL); /* 0xffffffffULL is low 32 bit */ | 103 | info->rsv[0] = (u32)(notify_addr & 0xffffffffULL); /* 0xffffffffULL is low 32 bit */ |
| 106 | info->rsv[1] = (u32)(notify_addr >> 32); /* 32 is high bit */ | 104 | info->rsv[1] = (u32)(notify_addr >> 32); /* 32 is high bit */ |
| 107 | 105 | ||
| 108 | - trs_debug( | 106 | + trs_debug("Notify info. (devid=%u; remote_devid=%u; type=%u; shrid=%u; sub_id=%u; flag=0x%x)\n", devid, info->devid, |
| 109 | - "Notify info. (devid=%u; remote_devid=%u; type=%u; shrid=%u; sub_id=%u; flag=0x%x)\n", devid, info->devid, | 107 | + info->id_type, info->shrid, event_info->subevent_id, info->flag); |
| 110 | - info->id_type, info->shrid, event_info->subevent_id, info->flag); | ||
| 111 | 108 | ||
| 112 | return 0; | 109 | return 0; |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | -int shr_id_spod_event_update( | 112 | +int shr_id_spod_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 116 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func) | 113 | + struct sched_published_event_func *event_func) |
| 117 | { | 114 | { |
| 118 | int ret = _shr_id_spod_event_update(devid, event_info, event_func); | 115 | int ret = _shr_id_spod_event_update(devid, event_info, event_func); |
| 119 | return trs_event_kerror_to_uerror(ret); | 116 | return trs_event_kerror_to_uerror(ret); |
| @@ -121,16 +118,16 @@ int shr_id_spod_event_update( | |||
| 121 | 118 | ||
| 122 | STATIC int shr_id_spod_event_init(void) | 119 | STATIC int shr_id_spod_event_init(void) |
| 123 | { | 120 | { |
| 124 | - return hal_kernel_sched_register_event_pre_proc_handle( | 121 | + return hal_kernel_sched_register_event_pre_proc_handle(EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, |
| 125 | - EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, shr_id_spod_event_update); | 122 | + shr_id_spod_event_update); |
| 126 | } | 123 | } |
| 127 | DECLAER_FEATURE_AUTO_INIT(shr_id_spod_event_init, FEATURE_LOADER_STAGE_5); | 124 | DECLAER_FEATURE_AUTO_INIT(shr_id_spod_event_init, FEATURE_LOADER_STAGE_5); |
| 128 | 125 | ||
| 129 | STATIC void shr_id_spod_event_uninit(void) | 126 | STATIC void shr_id_spod_event_uninit(void) |
| 130 | { | 127 | { |
| 131 | 128 | ||
| 132 | - hal_kernel_sched_unregister_event_pre_proc_handle( | 129 | + hal_kernel_sched_unregister_event_pre_proc_handle(EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, |
| 133 | - EVENT_DRV_MSG, SCHED_PRE_PROC_POS_LOCAL, shr_id_spod_event_update); | 130 | + shr_id_spod_event_update); |
| 134 | 131 | ||
| 135 | } | 132 | } |
| 136 | DECLAER_FEATURE_AUTO_UNINIT(shr_id_spod_event_uninit, FEATURE_LOADER_STAGE_5); | 133 | DECLAER_FEATURE_AUTO_UNINIT(shr_id_spod_event_uninit, FEATURE_LOADER_STAGE_5); |
| @@ -13,6 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | -int shr_id_spod_event_update( | 16 | +int shr_id_spod_event_update(unsigned int devid, struct sched_published_event_info *event_info, |
| 17 | - unsigned int devid, struct sched_published_event_info *event_info, struct sched_published_event_func *event_func); | 17 | + struct sched_published_event_func *event_func); |
| 18 | 18 | ||
| @@ -31,9 +31,8 @@ static int shr_id_create_shadow_node(u32 devid, struct trs_pod_msg_data *pod_msg | |||
| 31 | create_msg->attr.res_put = NULL; | 31 | create_msg->attr.res_put = NULL; |
| 32 | create_msg->attr.pid = create_msg->pid; | 32 | create_msg->attr.pid = create_msg->pid; |
| 33 | create_msg->attr.flag |= TSDRV_FLAG_SHR_ID_SHADOW; | 33 | create_msg->attr.flag |= TSDRV_FLAG_SHR_ID_SHADOW; |
| 34 | - trs_debug( | 34 | + trs_debug("Create info. (name=%s; sdid=0x%x; type=%d; pid=%d; flag=0x%x)\n", create_msg->attr.name, |
| 35 | - "Create info. (name=%s; sdid=0x%x; type=%d; pid=%d; flag=0x%x)\n", create_msg->attr.name, | 35 | + create_msg->attr.inst.devid, create_msg->attr.type, create_msg->pid, create_msg->attr.flag); |
| 36 | - create_msg->attr.inst.devid, create_msg->attr.type, create_msg->pid, create_msg->attr.flag); | ||
| 37 | 36 | ||
| 38 | return shr_id_node_create(&create_msg->attr); | 37 | return shr_id_node_create(&create_msg->attr); |
| 39 | } | 38 | } |
| @@ -50,9 +49,8 @@ static int shr_id_set_pid_shadow_node(u32 devid, struct trs_pod_msg_data *pod_ms | |||
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | ret = shr_id_node_set_pids(attr.name, attr.type, attr.pid, &msg->pid, 1); | 51 | ret = shr_id_node_set_pids(attr.name, attr.type, attr.pid, &msg->pid, 1); |
| 53 | - trs_debug( | 52 | + trs_debug("Set pod pid. (devid=%u; name=%s; type=%d; id=%u; pid=%d; ret=%d)\n", attr.inst.devid, attr.name, |
| 54 | - "Set pod pid. (devid=%u; name=%s; type=%d; id=%u; pid=%d; ret=%d)\n", attr.inst.devid, attr.name, attr.type, | 53 | + attr.type, attr.id, msg->pid, ret); |
| 55 | - attr.id, msg->pid, ret); | ||
| 56 | 54 | ||
| 57 | return ret; | 55 | return ret; |
| 58 | } | 56 | } |
| @@ -114,9 +112,8 @@ static int trs_s2s_msg_recv_check(u32 devid, struct data_input_info *data) | |||
| 114 | } | 112 | } |
| 115 | 113 | ||
| 116 | if ((data == NULL) || (data->data == NULL) || (data->in_len != (u32)sizeof(struct trs_pod_msg_data))) { | 114 | if ((data == NULL) || (data->data == NULL) || (data->in_len != (u32)sizeof(struct trs_pod_msg_data))) { |
| 117 | - trs_err( | 115 | + trs_err("Invalid. (devid=%u; para=%d; len=%ld)\n", devid, (data == NULL) ? 1 : data->in_len, |
| 118 | - "Invalid. (devid=%u; para=%d; len=%ld)\n", devid, (data == NULL) ? 1 : data->in_len, | 116 | + sizeof(struct trs_pod_msg_data)); |
| 119 | - sizeof(struct trs_pod_msg_data)); | ||
| 120 | return -EINVAL; | 117 | return -EINVAL; |
| 121 | } | 118 | } |
| 122 | 119 | ||
| @@ -78,5 +78,8 @@ struct trs_cb_stars_event { | |||
| 78 | unsigned int fn_data_high; | 78 | unsigned int fn_data_high; |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | -static inline void trs_get_cb_group_num(unsigned int *group_num) { *group_num = TRS_CB_GROUP_NUM; } | 81 | +static inline void trs_get_cb_group_num(unsigned int *group_num) |
| 82 | +{ | ||
| 83 | + *group_num = TRS_CB_GROUP_NUM; | ||
| 84 | +} | ||
| 82 | 85 | ||
| @@ -78,9 +78,8 @@ static void trs_cb_cq_recv_proc(struct trs_core_ts_inst *ts_inst, u32 cqid, void | |||
| 78 | struct sched_published_event event; | 78 | struct sched_published_event event; |
| 79 | 79 | ||
| 80 | if (cb_ctx->phy_sqcq.cqid != cqid) { | 80 | if (cb_ctx->phy_sqcq.cqid != cqid) { |
| 81 | - trs_err( | 81 | + trs_err("Not cb phy cqid. (devid=%u; tsid=%u; cqid=%u; cb_cqid=%u)\n", inst->devid, inst->tsid, cqid, |
| 82 | - "Not cb phy cqid. (devid=%u; tsid=%u; cqid=%u; cb_cqid=%u)\n", inst->devid, inst->tsid, cqid, | 82 | + cb_ctx->phy_sqcq.cqid); |
| 83 | - cb_ctx->phy_sqcq.cqid); | ||
| 84 | return; | 83 | return; |
| 85 | } | 84 | } |
| 86 | 85 | ||
| @@ -166,8 +165,8 @@ static void trs_cb_free_phy_sqcq(struct trs_core_ts_inst *ts_inst) | |||
| 166 | hal_kernel_trs_chan_destroy(&ts_inst->inst, ts_inst->cb_ctx.phy_sqcq.chan_id); | 165 | hal_kernel_trs_chan_destroy(&ts_inst->inst, ts_inst->cb_ctx.phy_sqcq.chan_id); |
| 167 | } | 166 | } |
| 168 | 167 | ||
| 169 | -static int _trs_cb_sqcq_init( | 168 | +static int _trs_cb_sqcq_init(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 170 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 169 | + struct halSqCqInputInfo *para) |
| 171 | { | 170 | { |
| 172 | struct trs_cb_cq *cq = NULL; | 171 | struct trs_cb_cq *cq = NULL; |
| 173 | int ret; | 172 | int ret; |
| @@ -230,9 +229,8 @@ static int trs_cb_sqcq_alloc_para_check(struct trs_core_ts_inst *ts_inst, struct | |||
| 230 | if ((para->cqeDepth > TRS_CB_MAX_CQ_DEPTH) || (para->cqeDepth < TRS_CB_MIN_CQ_DEPTH) || | 229 | if ((para->cqeDepth > TRS_CB_MAX_CQ_DEPTH) || (para->cqeDepth < TRS_CB_MIN_CQ_DEPTH) || |
| 231 | (para->cqeSize > TRS_CB_MAX_CQE_SIZE) || (para->cqeSize < TRS_CB_MIN_CQE_SIZE) || | 230 | (para->cqeSize > TRS_CB_MAX_CQE_SIZE) || (para->cqeSize < TRS_CB_MIN_CQE_SIZE) || |
| 232 | (para->sqeSize != TRS_CB_PHY_SQE_SIZE) || (para->grpId >= TRS_CB_GROUP_NUM)) { | 231 | (para->sqeSize != TRS_CB_PHY_SQE_SIZE) || (para->grpId >= TRS_CB_GROUP_NUM)) { |
| 233 | - trs_err( | 232 | + trs_err("Invalid para. (devid=%u; tsid=%u; cqeDepth=%u; cqeSize=%u; sqeSize=%u; grpId=%u)\n", inst->devid, |
| 234 | - "Invalid para. (devid=%u; tsid=%u; cqeDepth=%u; cqeSize=%u; sqeSize=%u; grpId=%u)\n", inst->devid, | 233 | + inst->tsid, para->cqeDepth, para->cqeSize, para->sqeSize, para->grpId); |
| 235 | - inst->tsid, para->cqeDepth, para->cqeSize, para->sqeSize, para->grpId); | ||
| 236 | return -EINVAL; | 234 | return -EINVAL; |
| 237 | } | 235 | } |
| 238 | 236 | ||
| @@ -305,8 +303,8 @@ int trs_cb_sqcq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 305 | } | 303 | } |
| 306 | } | 304 | } |
| 307 | 305 | ||
| 308 | - trs_debug( | 306 | + trs_debug("Alloc success. (devid=%u; tsid=%u; sqId=%u; cqId=%u;)\n", inst->devid, inst->tsid, para->sqId, |
| 309 | - "Alloc success. (devid=%u; tsid=%u; sqId=%u; cqId=%u;)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 307 | + para->cqId); |
| 310 | 308 | ||
| 311 | return 0; | 309 | return 0; |
| 312 | } | 310 | } |
| @@ -394,9 +392,8 @@ int trs_cb_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 394 | if (max_id > 0) { | 392 | if (max_id > 0) { |
| 395 | cb_ctx->cq = (struct trs_cb_cq *)trs_vzalloc(sizeof(struct trs_cb_cq) * max_id); | 393 | cb_ctx->cq = (struct trs_cb_cq *)trs_vzalloc(sizeof(struct trs_cb_cq) * max_id); |
| 396 | if (cb_ctx->cq == NULL) { | 394 | if (cb_ctx->cq == NULL) { |
| 397 | - trs_err( | 395 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 398 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 396 | + sizeof(struct trs_cb_cq) * max_id); |
| 399 | - sizeof(struct trs_cb_cq) * max_id); | ||
| 400 | return -ENOMEM; | 397 | return -ENOMEM; |
| 401 | } | 398 | } |
| 402 | } | 399 | } |
| @@ -34,8 +34,8 @@ struct trs_logic_cqe_v1_st { | |||
| 34 | u32 reserved1; | 34 | u32 reserved1; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | -static inline void trs_logic_cqe_trace_fill( | 37 | +static inline void trs_logic_cqe_trace_fill(struct trs_logic_cq *logic_cq, void *logic_cqe, |
| 38 | - struct trs_logic_cq *logic_cq, void *logic_cqe, struct trs_logic_cqe_trace *trace) | 38 | + struct trs_logic_cqe_trace *trace) |
| 39 | { | 39 | { |
| 40 | if (logic_cq->cqe_verion == LOGIC_CQE_VERSION_V1) { | 40 | if (logic_cq->cqe_verion == LOGIC_CQE_VERSION_V1) { |
| 41 | struct trs_logic_cqe_v1_st *logic_cqe_ = (struct trs_logic_cqe_v1_st *)logic_cqe; | 41 | struct trs_logic_cqe_v1_st *logic_cqe_ = (struct trs_logic_cqe_v1_st *)logic_cqe; |
| @@ -63,8 +63,8 @@ static inline void trs_logic_cqe_trace_fill( | |||
| 63 | trace->tail = logic_cq->tail; | 63 | trace->tail = logic_cq->tail; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | -void trs_logic_cq_copy_trace( | 66 | +void trs_logic_cq_copy_trace(const char *str, struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 67 | - const char *str, struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 start, u32 num) | 67 | + u32 start, u32 num) |
| 68 | { | 68 | { |
| 69 | if (trs_core_trace_is_enabled(ts_inst)) { | 69 | if (trs_core_trace_is_enabled(ts_inst)) { |
| 70 | u32 i; | 70 | u32 i; |
| @@ -86,8 +86,8 @@ void trs_logic_cq_recv_trace(const char *str, struct trs_core_ts_inst *ts_inst, | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | -void trs_logic_cq_enque_trace( | 89 | +void trs_logic_cq_enque_trace(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 stream_id, |
| 90 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 stream_id, u32 task_id, void *cqe) | 90 | + u32 task_id, void *cqe) |
| 91 | { | 91 | { |
| 92 | if (trs_core_trace_is_enabled(ts_inst)) { | 92 | if (trs_core_trace_is_enabled(ts_inst)) { |
| 93 | struct trs_logic_cqe_trace trace = {0}; | 93 | struct trs_logic_cqe_trace trace = {0}; |
| @@ -41,20 +41,20 @@ struct trs_logic_cq_recv_trace_t { | |||
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | -void trs_logic_cq_copy_trace( | 44 | +void trs_logic_cq_copy_trace(const char *str, struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 45 | - const char *str, struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 start, u32 num); | 45 | + u32 start, u32 num); |
| 46 | void trs_logic_cq_recv_trace(const char *str, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para); | 46 | void trs_logic_cq_recv_trace(const char *str, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para); |
| 47 | -void trs_logic_cq_enque_trace( | 47 | +void trs_logic_cq_enque_trace(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 stream_id, |
| 48 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 stream_id, u32 task_id, void *cqe); | 48 | + u32 task_id, void *cqe); |
| 49 | 49 | ||
| 50 | -static inline void trs_logic_cq_copy_trace( | 50 | +static inline void trs_logic_cq_copy_trace(const char *str, struct trs_core_ts_inst *ts_inst, |
| 51 | - const char *str, struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 start, u32 num) | 51 | + struct trs_logic_cq *logic_cq, u32 start, u32 num) |
| 52 | {} | 52 | {} |
| 53 | -static inline void trs_logic_cq_recv_trace( | 53 | +static inline void trs_logic_cq_recv_trace(const char *str, struct trs_core_ts_inst *ts_inst, |
| 54 | - const char *str, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para) | 54 | + struct halReportRecvInfo *para) |
| 55 | {} | 55 | {} |
| 56 | -static inline void trs_logic_cq_enque_trace( | 56 | +static inline void trs_logic_cq_enque_trace(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 57 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, u32 stream_id, u32 task_id, void *cqe) | 57 | + u32 stream_id, u32 task_id, void *cqe) |
| 58 | {} | 58 | {} |
| 59 | 59 | ||
| 60 | 60 | ||
| @@ -34,51 +34,51 @@ KA_DFX_TRACE_EVENT( | |||
| 34 | __ka_dfx_assign_str(str, "nop"); | 34 | __ka_dfx_assign_str(str, "nop"); |
| 35 | } __ka_entry->inst = *inst; | 35 | } __ka_entry->inst = *inst; |
| 36 | __ka_entry->cq_trace = *cq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), | 36 | __ka_entry->cq_trace = *cq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), |
| 37 | - KA_DFX_TP_printk( | 37 | + KA_DFX_TP_printk("%s:\t" |
| 38 | - "%s:\t" | 38 | + "devid=%u;" |
| 39 | - "devid=%u;" | 39 | + "tsid=%u;" |
| 40 | - "tsid=%u;" | 40 | + "logic_cqid=%u;" |
| 41 | - "logic_cqid=%u;" | 41 | + "head=%u;" |
| 42 | - "head=%u;" | 42 | + "tail=%u;" |
| 43 | - "tail=%u;" | 43 | + "task_id=%u;" |
| 44 | - "task_id=%u;" | 44 | + "stream_id=%u;" |
| 45 | - "stream_id=%u;" | 45 | + "sqid=%u;" |
| 46 | - "sqid=%u;" | 46 | + "sq_head=%u;" |
| 47 | - "sq_head=%u;" | 47 | + "sqe_type=%u;" |
| 48 | - "sqe_type=%u;" | 48 | + "match_flag=%u;" |
| 49 | - "match_flag=%u;" | 49 | + "%lld.%06ld", |
| 50 | - "%lld.%06ld", | 50 | + __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, |
| 51 | - __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, __ka_entry->cq_trace.logic_cqid, | 51 | + __ka_entry->cq_trace.logic_cqid, __ka_entry->cq_trace.head, __ka_entry->cq_trace.tail, |
| 52 | - __ka_entry->cq_trace.head, __ka_entry->cq_trace.tail, __ka_entry->cq_trace.task_id, | 52 | + __ka_entry->cq_trace.task_id, __ka_entry->cq_trace.stream_id, __ka_entry->cq_trace.sqid, |
| 53 | - __ka_entry->cq_trace.stream_id, __ka_entry->cq_trace.sqid, __ka_entry->cq_trace.sq_head, | 53 | + __ka_entry->cq_trace.sq_head, __ka_entry->cq_trace.sqe_type, __ka_entry->cq_trace.match_flag, |
| 54 | - __ka_entry->cq_trace.sqe_type, __ka_entry->cq_trace.match_flag, | 54 | + /* tv_sec type is depends on linux version */ |
| 55 | - /* tv_sec type is depends on linux version */ | 55 | + (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); |
| 56 | - (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); | ||
| 57 | 56 | ||
| 58 | -KA_DFX_TRACE_EVENT( | 57 | +KA_DFX_TRACE_EVENT(logic_cq_recv, |
| 59 | - logic_cq_recv, | 58 | + KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, |
| 60 | - KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_logic_cq_recv_trace_t *recv_trace), | 59 | + struct trs_logic_cq_recv_trace_t *recv_trace), |
| 61 | - KA_DFX_TP_ARGS(str, inst, recv_trace), | 60 | + KA_DFX_TP_ARGS(str, inst, recv_trace), |
| 62 | - KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) | 61 | + KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) |
| 63 | - __ka_dfx_field_struct(struct trs_logic_cq_recv_trace_t, recv_trace) | 62 | + __ka_dfx_field_struct(struct trs_logic_cq_recv_trace_t, recv_trace) |
| 64 | - __ka_dfx_field_struct(ka_timespec64_t, timestamp)), | 63 | + __ka_dfx_field_struct(ka_timespec64_t, timestamp)), |
| 65 | - KA_DFX_TP_fast_assign( | 64 | + KA_DFX_TP_fast_assign( |
| 66 | - if (str != NULL) { __ka_dfx_assign_str(str, str); } else { | 65 | + if (str != NULL) { __ka_dfx_assign_str(str, str); } else { |
| 67 | - __ka_dfx_assign_str(str, "nop"); | 66 | + __ka_dfx_assign_str(str, "nop"); |
| 68 | - } __ka_entry->inst = *inst; | 67 | + } __ka_entry->inst = *inst; |
| 69 | - __ka_entry->recv_trace = *recv_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), | 68 | + __ka_entry->recv_trace = *recv_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), |
| 70 | - KA_DFX_TP_printk( | 69 | + KA_DFX_TP_printk("%s:\t" |
| 71 | - "%s:\t" | 70 | + "devid=%u;" |
| 72 | - "devid=%u;" | 71 | + "tsid=%u;" |
| 73 | - "tsid=%u;" | 72 | + "logic_cqid=%u;" |
| 74 | - "logic_cqid=%u;" | 73 | + "report_cqe_num=%u;" |
| 75 | - "report_cqe_num=%u;" | 74 | + "timeout=%d;" |
| 76 | - "timeout=%d;" | 75 | + "%lld.%06ld", |
| 77 | - "%lld.%06ld", | 76 | + __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, |
| 78 | - __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, __ka_entry->recv_trace.logic_cqid, | 77 | + __ka_entry->recv_trace.logic_cqid, __ka_entry->recv_trace.report_cqe_num, |
| 79 | - __ka_entry->recv_trace.report_cqe_num, __ka_entry->recv_trace.timeout, | 78 | + __ka_entry->recv_trace.timeout, |
| 80 | - /* tv_sec type is depends on linux version */ | 79 | + /* tv_sec type is depends on linux version */ |
| 81 | - (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); | 80 | + (long long)__ka_entry->timestamp.tv_sec, |
| 81 | + __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); | ||
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | /* This part must be outside protection */ | 84 | /* This part must be outside protection */ |
| @@ -40,8 +40,8 @@ | |||
| 40 | 40 | ||
| 41 | TRS_INIT_REBOOT_NOTIFY; | 41 | TRS_INIT_REBOOT_NOTIFY; |
| 42 | 42 | ||
| 43 | -static int (*const trs_res_id_handles[TRS_MAX_CMD])( | 43 | +static int (*const trs_res_id_handles[TRS_MAX_CMD])(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 44 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) = { | 44 | + struct trs_res_id_para *para) = { |
| 45 | [_KA_IOC_NR(TRS_RES_ID_ALLOC)] = trs_res_id_alloc, | 45 | [_KA_IOC_NR(TRS_RES_ID_ALLOC)] = trs_res_id_alloc, |
| 46 | [_KA_IOC_NR(TRS_RES_ID_FREE)] = trs_res_id_free, | 46 | [_KA_IOC_NR(TRS_RES_ID_FREE)] = trs_res_id_free, |
| 47 | [_KA_IOC_NR(TRS_RES_ID_ENABLE)] = trs_res_id_enable, | 47 | [_KA_IOC_NR(TRS_RES_ID_ENABLE)] = trs_res_id_enable, |
| @@ -56,10 +56,9 @@ static int (*const trs_res_id_handles[TRS_MAX_CMD])( | |||
| 56 | 56 | ||
| 57 | static bool trs_is_id_query_cmd(unsigned int cmd) | 57 | static bool trs_is_id_query_cmd(unsigned int cmd) |
| 58 | { | 58 | { |
| 59 | - return ( | 59 | + return ((cmd == TRS_RES_ID_NUM_QUERY) || (cmd == TRS_RES_ID_MAX_QUERY) || (cmd == TRS_RES_ID_USED_NUM_QUERY) || |
| 60 | - (cmd == TRS_RES_ID_NUM_QUERY) || (cmd == TRS_RES_ID_MAX_QUERY) || (cmd == TRS_RES_ID_USED_NUM_QUERY) || | 60 | + (cmd == TRS_RES_ID_REG_OFFSET_QUERY) || (cmd == TRS_RES_ID_REG_SIZE_QUERY) || |
| 61 | - (cmd == TRS_RES_ID_REG_OFFSET_QUERY) || (cmd == TRS_RES_ID_REG_SIZE_QUERY) || | 61 | + (cmd == TRS_RES_ID_AVAIL_NUM_QUERY)); |
| 62 | - (cmd == TRS_RES_ID_AVAIL_NUM_QUERY)); | ||
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | static int ioctl_trs_res_id_comm(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg) | 64 | static int ioctl_trs_res_id_comm(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg) |
| @@ -121,9 +120,8 @@ static int ioctl_trs_res_id_comm(struct trs_proc_ctx *proc_ctx, unsigned int cmd | |||
| 121 | 120 | ||
| 122 | Exit: | 121 | Exit: |
| 123 | if ((ret != 0) && (ret != -EOPNOTSUPP) && (cmd != TRS_RES_ID_ALLOC)) { | 122 | if ((ret != 0) && (ret != -EOPNOTSUPP) && (cmd != TRS_RES_ID_ALLOC)) { |
| 124 | - trs_err( | 123 | + trs_err("Fail. (devid=%u; tsid=%u; cmd=%d; res_type=%d; id=%u; ret=%d)\n", proc_ctx->devid, para.tsid, |
| 125 | - "Fail. (devid=%u; tsid=%u; cmd=%d; res_type=%d; id=%u; ret=%d)\n", proc_ctx->devid, para.tsid, | 124 | + _KA_IOC_NR(cmd), para.res_type, para.id, ret); |
| 126 | - _KA_IOC_NR(cmd), para.res_type, para.id, ret); | ||
| 127 | } | 125 | } |
| 128 | 126 | ||
| 129 | return ret; | 127 | return ret; |
| @@ -207,8 +205,9 @@ static int ioctl_trs_hw_info_query(struct trs_proc_ctx *proc_ctx, unsigned int c | |||
| 207 | return ret; | 205 | return ret; |
| 208 | } | 206 | } |
| 209 | 207 | ||
| 210 | -static int (*const trs_sqcq_alloc_handles[DRV_INVALID_TYPE])( | 208 | +static int (*const trs_sqcq_alloc_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 211 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) = { | 209 | + struct trs_core_ts_inst *ts_inst, |
| 210 | + struct halSqCqInputInfo *para) = { | ||
| 212 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_alloc, [DRV_CALLBACK_TYPE] = trs_cb_sqcq_alloc, | 211 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_alloc, [DRV_CALLBACK_TYPE] = trs_cb_sqcq_alloc, |
| 213 | [DRV_LOGIC_TYPE] = trs_logic_cq_alloc, [DRV_SHM_TYPE] = trs_shm_sqcq_alloc, | 212 | [DRV_LOGIC_TYPE] = trs_logic_cq_alloc, [DRV_SHM_TYPE] = trs_shm_sqcq_alloc, |
| 214 | [DRV_CTRL_TYPE] = trs_sw_sqcq_alloc, [DRV_GDB_TYPE] = trs_gdb_sqcq_alloc}; | 213 | [DRV_CTRL_TYPE] = trs_sw_sqcq_alloc, [DRV_GDB_TYPE] = trs_gdb_sqcq_alloc}; |
| @@ -271,8 +270,9 @@ static int ioctl_trs_sqcq_alloc(struct trs_proc_ctx *proc_ctx, unsigned int cmd, | |||
| 271 | return ret; | 270 | return ret; |
| 272 | } | 271 | } |
| 273 | 272 | ||
| 274 | -static int (*const trs_sqcq_free_handles[DRV_INVALID_TYPE])( | 273 | +static int (*const trs_sqcq_free_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 275 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) = { | 274 | + struct trs_core_ts_inst *ts_inst, |
| 275 | + struct halSqCqFreeInfo *para) = { | ||
| 276 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_free, [DRV_CALLBACK_TYPE] = trs_cb_sqcq_free, [DRV_LOGIC_TYPE] = trs_logic_cq_free, | 276 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_free, [DRV_CALLBACK_TYPE] = trs_cb_sqcq_free, [DRV_LOGIC_TYPE] = trs_logic_cq_free, |
| 277 | [DRV_SHM_TYPE] = trs_shm_sqcq_free, [DRV_CTRL_TYPE] = trs_sw_sqcq_free, [DRV_GDB_TYPE] = trs_gdb_sqcq_free}; | 277 | [DRV_SHM_TYPE] = trs_shm_sqcq_free, [DRV_CTRL_TYPE] = trs_sw_sqcq_free, [DRV_GDB_TYPE] = trs_gdb_sqcq_free}; |
| 278 | 278 | ||
| @@ -309,8 +309,9 @@ static int ioctl_trs_sqcq_free(struct trs_proc_ctx *proc_ctx, unsigned int cmd, | |||
| 309 | return ret; | 309 | return ret; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | -static int (*const trs_sqcq_config_handles[DRV_INVALID_TYPE])( | 312 | +static int (*const trs_sqcq_config_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 313 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqConfigInfo *para) = { | 313 | + struct trs_core_ts_inst *ts_inst, |
| 314 | + struct halSqCqConfigInfo *para) = { | ||
| 314 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_config, | 315 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_config, |
| 315 | [DRV_LOGIC_TYPE] = trs_logic_cq_config, | 316 | [DRV_LOGIC_TYPE] = trs_logic_cq_config, |
| 316 | }; | 317 | }; |
| @@ -385,8 +386,9 @@ static int ioctl_trs_sqcq_query(struct trs_proc_ctx *proc_ctx, unsigned int cmd, | |||
| 385 | return ret; | 386 | return ret; |
| 386 | } | 387 | } |
| 387 | 388 | ||
| 388 | -static int (*const trs_sqcq_send_handles[DRV_INVALID_TYPE])( | 389 | +static int (*const trs_sqcq_send_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 389 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halTaskSendInfo *para) = { | 390 | + struct trs_core_ts_inst *ts_inst, |
| 391 | + struct halTaskSendInfo *para) = { | ||
| 390 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_send, | 392 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_send, |
| 391 | [DRV_CALLBACK_TYPE] = trs_cb_sqcq_send, | 393 | [DRV_CALLBACK_TYPE] = trs_cb_sqcq_send, |
| 392 | [DRV_GDB_TYPE] = trs_gdb_sqcq_send, | 394 | [DRV_GDB_TYPE] = trs_gdb_sqcq_send, |
| @@ -433,8 +435,9 @@ static int ioctl_trs_sqcq_send(struct trs_proc_ctx *proc_ctx, unsigned int cmd, | |||
| 433 | return ret; | 435 | return ret; |
| 434 | } | 436 | } |
| 435 | 437 | ||
| 436 | -static int (*const trs_sqcq_recv_handles[DRV_INVALID_TYPE])( | 438 | +static int (*const trs_sqcq_recv_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 437 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para) = { | 439 | + struct trs_core_ts_inst *ts_inst, |
| 440 | + struct halReportRecvInfo *para) = { | ||
| 438 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_recv, | 441 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_recv, |
| 439 | [DRV_LOGIC_TYPE] = trs_logic_cq_recv, | 442 | [DRV_LOGIC_TYPE] = trs_logic_cq_recv, |
| 440 | [DRV_GDB_TYPE] = trs_gdb_sqcq_recv, | 443 | [DRV_GDB_TYPE] = trs_gdb_sqcq_recv, |
| @@ -682,9 +685,8 @@ int trs_rpc_msg_ctrl(struct trs_id_inst *inst, int pid, void *msg, u32 msg_len, | |||
| 682 | if ((ret != 0) || (rpc_call_msg->header.result != 0)) { | 685 | if ((ret != 0) || (rpc_call_msg->header.result != 0)) { |
| 683 | trs_core_inst_put(ts_inst); | 686 | trs_core_inst_put(ts_inst); |
| 684 | if (ret != -EOPNOTSUPP) { | 687 | if (ret != -EOPNOTSUPP) { |
| 685 | - trs_err( | 688 | + trs_err("Notice ts and write back failed. (devid=%u; result=%u; ret=%d)\n", inst->devid, |
| 686 | - "Notice ts and write back failed. (devid=%u; result=%u; ret=%d)\n", inst->devid, | 689 | + rpc_call_msg->header.result, ret); |
| 687 | - rpc_call_msg->header.result, ret); | ||
| 688 | } | 690 | } |
| 689 | return (ret != 0) ? ret : -EINVAL; | 691 | return (ret != 0) ? ret : -EINVAL; |
| 690 | } | 692 | } |
| @@ -723,8 +725,8 @@ int ioctl_trs_msg_ctrl(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned | |||
| 723 | } | 725 | } |
| 724 | 726 | ||
| 725 | ret = ka_base_put_user(rpc_call_msg.rpc_call_header.len, &usr_para->msg_len); | 727 | ret = ka_base_put_user(rpc_call_msg.rpc_call_header.len, &usr_para->msg_len); |
| 726 | - ret |= ka_base_copy_to_user( | 728 | + ret |= ka_base_copy_to_user((void __ka_user *)usr_para->msg, (void *)rpc_call_msg.data, |
| 727 | - (void __ka_user *)usr_para->msg, (void *)rpc_call_msg.data, rpc_call_msg.rpc_call_header.len); | 729 | + rpc_call_msg.rpc_call_header.len); |
| 728 | if (ret != 0) { | 730 | if (ret != 0) { |
| 729 | trs_err("Copy to user err. (len=%u; ret=%d)\n", rpc_call_msg.rpc_call_header.len, ret); | 731 | trs_err("Copy to user err. (len=%u; ret=%d)\n", rpc_call_msg.rpc_call_header.len, ret); |
| 730 | } | 732 | } |
| @@ -826,8 +828,9 @@ static int ioctl_trs_id_res_map(struct trs_proc_ctx *proc_ctx, unsigned int cmd, | |||
| 826 | return 0; | 828 | return 0; |
| 827 | } | 829 | } |
| 828 | 830 | ||
| 829 | -static int (*const trs_sqcq_get_handles[DRV_INVALID_TYPE])( | 831 | +static int (*const trs_sqcq_get_handles[DRV_INVALID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 830 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) = { | 832 | + struct trs_core_ts_inst *ts_inst, |
| 833 | + struct halSqCqInputInfo *para) = { | ||
| 831 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_get, [DRV_LOGIC_TYPE] = trs_logic_cq_get}; | 834 | [DRV_NORMAL_TYPE] = trs_hw_sqcq_get, [DRV_LOGIC_TYPE] = trs_logic_cq_get}; |
| 832 | 835 | ||
| 833 | int ioctl_trs_sqcq_get(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg) | 836 | int ioctl_trs_sqcq_get(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg) |
| @@ -1418,9 +1421,8 @@ static int trs_open(ka_inode_t *inode, ka_file_t *file) | |||
| 1418 | ka_fs_set_file_private_data(file, task_info); | 1421 | ka_fs_set_file_private_data(file, task_info); |
| 1419 | ka_task_up_write(&ts_inst->ctrl_sem); | 1422 | ka_task_up_write(&ts_inst->ctrl_sem); |
| 1420 | 1423 | ||
| 1421 | - trs_debug( | 1424 | + trs_debug("Proc open success. (devid=%u; task_info_unique_id=%lld; proc_ctx_taskid=%lld; cp2_taskid=%lld)\n", devid, |
| 1422 | - "Proc open success. (devid=%u; task_info_unique_id=%lld; proc_ctx_taskid=%lld; cp2_taskid=%lld)\n", devid, | 1425 | + task_info->unique_id, proc_ctx->task_id, proc_ctx->cp2_task_id); |
| 1423 | - task_info->unique_id, proc_ctx->task_id, proc_ctx->cp2_task_id); | ||
| 1424 | return 0; | 1426 | return 0; |
| 1425 | 1427 | ||
| 1426 | ctx_destroy: | 1428 | ctx_destroy: |
| @@ -1471,18 +1473,23 @@ static void trs_core_dev_inst_put(struct trs_proc_ctx *proc_ctx) | |||
| 1471 | } | 1473 | } |
| 1472 | } | 1474 | } |
| 1473 | 1475 | ||
| 1474 | -static int trs_mmap_not_support(ka_file_t *file, ka_vm_area_struct_t *vma) { return -ENOTSUPP; } | 1476 | +static int trs_mmap_not_support(ka_file_t *file, ka_vm_area_struct_t *vma) |
| 1477 | +{ | ||
| 1478 | + return -ENOTSUPP; | ||
| 1479 | +} | ||
| 1475 | 1480 | ||
| 1476 | -static int trs_mremap(ka_vm_area_struct_t *area) { return -ENOTSUPP; } | 1481 | +static int trs_mremap(ka_vm_area_struct_t *area) |
| 1482 | +{ | ||
| 1483 | + return -ENOTSUPP; | ||
| 1484 | +} | ||
| 1477 | 1485 | ||
| 1478 | static ka_vm_operations_struct_t trs_vm_ops = {ka_vm_ops_init_mremap(trs_mremap)}; | 1486 | static ka_vm_operations_struct_t trs_vm_ops = {ka_vm_ops_init_mremap(trs_mremap)}; |
| 1479 | 1487 | ||
| 1480 | static int trs_mmap(ka_file_t *file, ka_vm_area_struct_t *vma) | 1488 | static int trs_mmap(ka_file_t *file, ka_vm_area_struct_t *vma) |
| 1481 | { | 1489 | { |
| 1482 | ka_mm_set_vm_ops(vma, &trs_vm_ops); | 1490 | ka_mm_set_vm_ops(vma, &trs_vm_ops); |
| 1483 | - ka_mm_set_vm_flags( | 1491 | + ka_mm_set_vm_flags(vma, ka_mm_get_vm_flags(vma) | KA_VM_LOCKED | KA_VM_DONTEXPAND | KA_VM_DONTDUMP | |
| 1484 | - vma, ka_mm_get_vm_flags(vma) | KA_VM_LOCKED | KA_VM_DONTEXPAND | KA_VM_DONTDUMP | KA_VM_DONTCOPY | KA_VM_IO | | 1492 | + KA_VM_DONTCOPY | KA_VM_IO | KA_VM_PFNMAP); |
| 1485 | - KA_VM_PFNMAP); | ||
| 1486 | if (!(ka_mm_get_vm_flags(vma) & KA_VM_WRITE)) { | 1493 | if (!(ka_mm_get_vm_flags(vma) & KA_VM_WRITE)) { |
| 1487 | ka_mm_vm_flags_clear(vma, KA_VM_MAYWRITE); | 1494 | ka_mm_vm_flags_clear(vma, KA_VM_MAYWRITE); |
| 1488 | } | 1495 | } |
| @@ -1491,7 +1498,10 @@ static int trs_mmap(ka_file_t *file, ka_vm_area_struct_t *vma) | |||
| 1491 | return 0; | 1498 | return 0; |
| 1492 | } | 1499 | } |
| 1493 | 1500 | ||
| 1494 | -static int trs_release(ka_inode_t *inode, ka_file_t *file) { return 0; } | 1501 | +static int trs_release(ka_inode_t *inode, ka_file_t *file) |
| 1502 | +{ | ||
| 1503 | + return 0; | ||
| 1504 | +} | ||
| 1495 | 1505 | ||
| 1496 | static ka_file_operations_t trs_fops = { | 1506 | static ka_file_operations_t trs_fops = { |
| 1497 | .owner = KA_THIS_MODULE, | 1507 | .owner = KA_THIS_MODULE, |
| @@ -1566,8 +1576,8 @@ static ka_file_operations_t trs_mmap_fops = { | |||
| 1566 | .mmap = trs_mmap, | 1576 | .mmap = trs_mmap, |
| 1567 | }; | 1577 | }; |
| 1568 | 1578 | ||
| 1569 | -void trs_handle_proc_release_result( | 1579 | +void trs_handle_proc_release_result(struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, int exit_stage, |
| 1570 | - struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, int exit_stage, bool is_success) | 1580 | + bool is_success) |
| 1571 | { | 1581 | { |
| 1572 | if (is_success) { | 1582 | if (is_success) { |
| 1573 | if (exit_stage == APM_STAGE_RECYCLE_RES) { | 1583 | if (exit_stage == APM_STAGE_RECYCLE_RES) { |
| @@ -1579,14 +1589,13 @@ void trs_handle_proc_release_result( | |||
| 1579 | } | 1589 | } |
| 1580 | ka_task_up_write(&ts_inst->sem); | 1590 | ka_task_up_write(&ts_inst->sem); |
| 1581 | trs_core_dev_inst_put(proc_ctx); | 1591 | trs_core_dev_inst_put(proc_ctx); |
| 1582 | - trs_debug( | 1592 | + trs_debug("Proc destroy. (devid=%u; pid=%d; task_id=%lld)\n", proc_ctx->devid, proc_ctx->pid, |
| 1583 | - "Proc destroy. (devid=%u; pid=%d; task_id=%lld)\n", proc_ctx->devid, proc_ctx->pid, proc_ctx->task_id); | 1593 | + proc_ctx->task_id); |
| 1584 | trs_proc_ctx_put(proc_ctx); | 1594 | trs_proc_ctx_put(proc_ctx); |
| 1585 | } | 1595 | } |
| 1586 | } else { | 1596 | } else { |
| 1587 | - trs_warn( | 1597 | + trs_warn("Release warn, add to exit_list. (devid=%u; pid=%d; task_id=%lld; stage=%u)\n", proc_ctx->devid, |
| 1588 | - "Release warn, add to exit_list. (devid=%u; pid=%d; task_id=%lld; stage=%u)\n", proc_ctx->devid, | 1598 | + proc_ctx->pid, proc_ctx->task_id, exit_stage); |
| 1589 | - proc_ctx->pid, proc_ctx->task_id, exit_stage); | ||
| 1590 | ka_task_down_write(&ts_inst->sem); | 1599 | ka_task_down_write(&ts_inst->sem); |
| 1591 | ka_list_move(&proc_ctx->node, &ts_inst->exit_proc_list_head); | 1600 | ka_list_move(&proc_ctx->node, &ts_inst->exit_proc_list_head); |
| 1592 | ka_base_atomic_dec(&ts_inst->ctx_num); | 1601 | ka_base_atomic_dec(&ts_inst->ctx_num); |
| @@ -1626,16 +1635,15 @@ static int _trs_release_by_exit_stage(struct trs_proc_ctx *proc_ctx, int stage) | |||
| 1626 | 1635 | ||
| 1627 | ret = trs_proc_release_check_ts(proc_ctx, ts_inst->inst.tsid); | 1636 | ret = trs_proc_release_check_ts(proc_ctx, ts_inst->inst.tsid); |
| 1628 | if (ret != 0) { | 1637 | if (ret != 0) { |
| 1629 | - trs_warn( | 1638 | + trs_warn("Recycle warn. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; ret=%d)\n", |
| 1630 | - "Recycle warn. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; ret=%d)\n", ts_inst->inst.devid, | 1639 | + ts_inst->inst.devid, ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, |
| 1631 | - ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, ret); | 1640 | + ret); |
| 1632 | trs_proc_leak_res_show(proc_ctx, ts_inst); | 1641 | trs_proc_leak_res_show(proc_ctx, ts_inst); |
| 1633 | trs_proc_release_ras_report(proc_ctx, ts_inst); | 1642 | trs_proc_release_ras_report(proc_ctx, ts_inst); |
| 1634 | ret = -EBUSY; | 1643 | ret = -EBUSY; |
| 1635 | } | 1644 | } |
| 1636 | - } else if ( | 1645 | + } else if (((stage == APM_STAGE_PRE_RECYCLE_RES) && (ts_inst->location != UDA_LOCAL)) || |
| 1637 | - ((stage == APM_STAGE_PRE_RECYCLE_RES) && (ts_inst->location != UDA_LOCAL)) || | 1646 | + ((stage == APM_STAGE_RECYCLE_RES) && (ts_inst->location == UDA_LOCAL))) { |
| 1638 | - ((stage == APM_STAGE_RECYCLE_RES) && (ts_inst->location == UDA_LOCAL))) { | ||
| 1639 | if ((ts_inst->location == UDA_NEAR) && (proc_ctx->release_type == TRS_PROC_RELEASE_LOCAL)) { | 1647 | if ((ts_inst->location == UDA_NEAR) && (proc_ctx->release_type == TRS_PROC_RELEASE_LOCAL)) { |
| 1640 | return 0; | 1648 | return 0; |
| 1641 | } | 1649 | } |
| @@ -1673,8 +1681,8 @@ static bool trs_notify_apm_release_task(struct trs_proc_ctx *proc_ctx) | |||
| 1673 | } | 1681 | } |
| 1674 | 1682 | ||
| 1675 | /* mutex tsdrv fd release and apm release */ | 1683 | /* mutex tsdrv fd release and apm release */ |
| 1676 | - release_flag = | 1684 | + release_flag = ka_base_atomic_cmpxchg(&proc_ctx->release_flag, TRS_PROC_RELEASE_FLAG_NONE, |
| 1677 | - ka_base_atomic_cmpxchg(&proc_ctx->release_flag, TRS_PROC_RELEASE_FLAG_NONE, TRS_PROC_RELEASE_BY_TSDRV_FD); | 1685 | + TRS_PROC_RELEASE_BY_TSDRV_FD); |
| 1678 | if ((release_flag == TRS_PROC_RELEASE_BY_APM_MASTER) || (release_flag == TRS_PROC_RELEASE_BY_APM_SLAVE)) { | 1686 | if ((release_flag == TRS_PROC_RELEASE_BY_APM_MASTER) || (release_flag == TRS_PROC_RELEASE_BY_APM_SLAVE)) { |
| 1679 | return true; | 1687 | return true; |
| 1680 | } | 1688 | } |
| @@ -1682,8 +1690,8 @@ static bool trs_notify_apm_release_task(struct trs_proc_ctx *proc_ctx) | |||
| 1682 | return false; | 1690 | return false; |
| 1683 | } | 1691 | } |
| 1684 | 1692 | ||
| 1685 | -static int trs_release_by_exit_stage( | 1693 | +static int trs_release_by_exit_stage(ka_notifier_block_t *self, unsigned long val, void *data, |
| 1686 | - ka_notifier_block_t *self, unsigned long val, void *data, TRS_PROC_RELEASE_FLAG flag) | 1694 | + TRS_PROC_RELEASE_FLAG flag) |
| 1687 | { | 1695 | { |
| 1688 | int tgid = apm_get_exit_tgid(val); | 1696 | int tgid = apm_get_exit_tgid(val); |
| 1689 | int stage = apm_get_exit_stage(val); | 1697 | int stage = apm_get_exit_stage(val); |
| @@ -1707,8 +1715,8 @@ static int trs_release_by_exit_stage( | |||
| 1707 | } | 1715 | } |
| 1708 | 1716 | ||
| 1709 | if (task_is_exit(proc_ctx->pid, &proc_ctx->start_time) == false) { | 1717 | if (task_is_exit(proc_ctx->pid, &proc_ctx->start_time) == false) { |
| 1710 | - (void)ka_base_atomic_cmpxchg( | 1718 | + (void)ka_base_atomic_cmpxchg(&proc_ctx->release_flag, TRS_PROC_RELEASE_FLAG_NONE, |
| 1711 | - &proc_ctx->release_flag, TRS_PROC_RELEASE_FLAG_NONE, TRS_PROC_RELEASE_BY_TSDRV_FD); | 1719 | + TRS_PROC_RELEASE_BY_TSDRV_FD); |
| 1712 | goto release_next; | 1720 | goto release_next; |
| 1713 | } | 1721 | } |
| 1714 | 1722 | ||
| @@ -1810,9 +1818,8 @@ static int trs_release_prepare(ka_file_t *file, unsigned long mode) | |||
| 1810 | return 0; | 1818 | return 0; |
| 1811 | } | 1819 | } |
| 1812 | 1820 | ||
| 1813 | - trs_debug( | 1821 | + trs_debug("Task info. (devid=%u; task_info_unique_id=%lld; proc_ctx_taskid=%lld; cp2_taskid=%lld)\n", |
| 1814 | - "Task info. (devid=%u; task_info_unique_id=%lld; proc_ctx_taskid=%lld; cp2_taskid=%lld)\n", proc_ctx->devid, | 1822 | + proc_ctx->devid, task_info->unique_id, proc_ctx->task_id, proc_ctx->cp2_task_id); |
| 1815 | - task_info->unique_id, proc_ctx->task_id, proc_ctx->cp2_task_id); | ||
| 1816 | if (trs_shr_proc_check(task_info) == true) { | 1823 | if (trs_shr_proc_check(task_info) == true) { |
| 1817 | trs_debug("Shr proc exit. (cur_pid=%u; proc_ctx_pid=%u)\n", ka_task_get_current_tgid(), proc_ctx->pid); | 1824 | trs_debug("Shr proc exit. (cur_pid=%u; proc_ctx_pid=%u)\n", ka_task_get_current_tgid(), proc_ctx->pid); |
| 1818 | trs_shr_proc_close(task_info); | 1825 | trs_shr_proc_close(task_info); |
| @@ -1833,9 +1840,8 @@ static int trs_release_prepare(ka_file_t *file, unsigned long mode) | |||
| 1833 | } | 1840 | } |
| 1834 | 1841 | ||
| 1835 | 1842 | ||
| 1836 | - trs_debug( | 1843 | + trs_debug("Proc release. (devid=%u; pid=%d; task_id=%lld; close_type=%d)\n", proc_ctx->devid, proc_ctx->pid, |
| 1837 | - "Proc release. (devid=%u; pid=%d; task_id=%lld; close_type=%d)\n", proc_ctx->devid, proc_ctx->pid, | 1844 | + proc_ctx->task_id, proc_ctx->release_type); |
| 1838 | - proc_ctx->task_id, proc_ctx->release_type); | ||
| 1839 | return trs_ts_inst_release(proc_ctx); | 1845 | return trs_ts_inst_release(proc_ctx); |
| 1840 | } | 1846 | } |
| 1841 | 1847 | ||
| @@ -26,6 +26,6 @@ int ioctl_trs_ub_info_query(struct trs_proc_ctx *proc_ctx, unsigned int cmd, uns | |||
| 26 | int ioctl_trs_msg_ctrl(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); | 26 | int ioctl_trs_msg_ctrl(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); |
| 27 | int ioctl_trs_sqcq_get(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); | 27 | int ioctl_trs_sqcq_get(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); |
| 28 | int ioctl_trs_sqcq_restore(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); | 28 | int ioctl_trs_sqcq_restore(struct trs_proc_ctx *proc_ctx, unsigned int cmd, unsigned long arg); |
| 29 | -void trs_handle_proc_release_result( | 29 | +void trs_handle_proc_release_result(struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, int exit_stage, |
| 30 | - struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, int exit_stage, bool is_success); | 30 | + bool is_success); |
| 31 | 31 | ||
| @@ -107,8 +107,8 @@ int trs_gdb_sqcq_recv(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 107 | return 0; | 107 | return 0; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | -static int trs_gdb_alloc_chan( | 110 | +static int trs_gdb_alloc_chan(struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, |
| 111 | - struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, int *chan_id) | 111 | + int *chan_id) |
| 112 | { | 112 | { |
| 113 | struct trs_chan_para chan_para = {0}; | 113 | struct trs_chan_para chan_para = {0}; |
| 114 | int ret; | 114 | int ret; |
| @@ -180,8 +180,8 @@ int trs_gdb_sqcq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 180 | 180 | ||
| 181 | trs_set_sq_status(&ts_inst->maint_sq_ctx[sq_info.sqid], 1); | 181 | trs_set_sq_status(&ts_inst->maint_sq_ctx[sq_info.sqid], 1); |
| 182 | 182 | ||
| 183 | - trs_debug( | 183 | + trs_debug("Alloc maint sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, |
| 184 | - "Alloc maint sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 184 | + para->cqId); |
| 185 | 185 | ||
| 186 | return 0; | 186 | return 0; |
| 187 | 187 | ||
| @@ -195,8 +195,8 @@ destroy_chan: | |||
| 195 | return ret; | 195 | return ret; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | -static int trs_gdb_sqcq_free_check( | 198 | +static int trs_gdb_sqcq_free_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 199 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 199 | + struct halSqCqFreeInfo *para) |
| 200 | { | 200 | { |
| 201 | struct trs_id_inst *inst = &ts_inst->inst; | 201 | struct trs_id_inst *inst = &ts_inst->inst; |
| 202 | 202 | ||
| @@ -211,8 +211,8 @@ static int trs_gdb_sqcq_free_check( | |||
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | if (ts_inst->maint_sq_ctx[para->sqId].chan_id != ts_inst->maint_cq_ctx[para->cqId].chan_id) { | 213 | if (ts_inst->maint_sq_ctx[para->sqId].chan_id != ts_inst->maint_cq_ctx[para->cqId].chan_id) { |
| 214 | - trs_err( | 214 | + trs_err("Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, |
| 215 | - "Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 215 | + para->cqId); |
| 216 | return -EINVAL; | 216 | return -EINVAL; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| @@ -270,17 +270,15 @@ int trs_maint_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 270 | u32 cq_id_num = trs_res_get_id_num(ts_inst, TRS_MAINT_CQ); | 270 | u32 cq_id_num = trs_res_get_id_num(ts_inst, TRS_MAINT_CQ); |
| 271 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_MAINT_CQ); | 271 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_MAINT_CQ); |
| 272 | 272 | ||
| 273 | - trs_debug( | 273 | + trs_debug("Init maint sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", |
| 274 | - "Init maint sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", inst->devid, | 274 | + inst->devid, inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); |
| 275 | - inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); | ||
| 276 | 275 | ||
| 277 | if (sq_max_id > 0) { | 276 | if (sq_max_id > 0) { |
| 278 | ts_inst->maint_sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); | 277 | ts_inst->maint_sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); |
| 279 | if (ts_inst->maint_sq_ctx == NULL) { | 278 | if (ts_inst->maint_sq_ctx == NULL) { |
| 280 | 279 | ||
| 281 | - trs_err( | 280 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=0x%lx)\n", inst->devid, inst->tsid, |
| 282 | - "Mem alloc failed. (devid=%u; tsid=%u; size=0x%lx)\n", inst->devid, inst->tsid, | 281 | + sizeof(struct trs_sq_ctx) * sq_max_id); |
| 283 | - sizeof(struct trs_sq_ctx) * sq_max_id); | ||
| 284 | return -ENOMEM; | 282 | return -ENOMEM; |
| 285 | 283 | ||
| 286 | } | 284 | } |
| @@ -297,9 +295,8 @@ int trs_maint_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 297 | trs_vfree(ts_inst->maint_sq_ctx); | 295 | trs_vfree(ts_inst->maint_sq_ctx); |
| 298 | ts_inst->maint_sq_ctx = NULL; | 296 | ts_inst->maint_sq_ctx = NULL; |
| 299 | } | 297 | } |
| 300 | - trs_err( | 298 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 301 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 299 | + sizeof(struct trs_cq_ctx) * cq_max_id); |
| 302 | - sizeof(struct trs_cq_ctx) * cq_max_id); | ||
| 303 | return -ENOMEM; | 300 | return -ENOMEM; |
| 304 | 301 | ||
| 305 | } | 302 | } |
| @@ -31,9 +31,15 @@ | |||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | -static bool trs_is_sqcq_pair_mode(struct trs_core_ts_inst *ts_inst) { return trs_is_stars_inst(ts_inst); } | 34 | +static bool trs_is_sqcq_pair_mode(struct trs_core_ts_inst *ts_inst) |
| 35 | +{ | ||
| 36 | + return trs_is_stars_inst(ts_inst); | ||
| 37 | +} | ||
| 35 | 38 | ||
| 36 | -static inline u32 trs_hw_get_sq_head(struct trs_sq_ctx *sq_ctx) { return *(u32 *)sq_ctx->head.kva; } | 39 | +static inline u32 trs_hw_get_sq_head(struct trs_sq_ctx *sq_ctx) |
| 40 | +{ | ||
| 41 | + return *(u32 *)sq_ctx->head.kva; | ||
| 42 | +} | ||
| 37 | 43 | ||
| 38 | static inline void trs_hw_set_sq_head(struct trs_sq_ctx *sq_ctx, u32 head) | 44 | static inline void trs_hw_set_sq_head(struct trs_sq_ctx *sq_ctx, u32 head) |
| 39 | { | 45 | { |
| @@ -42,7 +48,10 @@ static inline void trs_hw_set_sq_head(struct trs_sq_ctx *sq_ctx, u32 head) | |||
| 42 | *(u32 *)sq_ctx->head.kva = head; | 48 | *(u32 *)sq_ctx->head.kva = head; |
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | -static inline u32 trs_hw_get_sq_tail(struct trs_sq_ctx *sq_ctx) { return *(u32 *)sq_ctx->tail.kva; } | 51 | +static inline u32 trs_hw_get_sq_tail(struct trs_sq_ctx *sq_ctx) |
| 52 | +{ | ||
| 53 | + return *(u32 *)sq_ctx->tail.kva; | ||
| 54 | +} | ||
| 46 | 55 | ||
| 47 | static void trs_trace_hw_cqe_fill(struct trs_id_inst *inst, struct trs_chan_cq_trace *cq_trace, void *cqe) | 56 | static void trs_trace_hw_cqe_fill(struct trs_id_inst *inst, struct trs_chan_cq_trace *cq_trace, void *cqe) |
| 48 | { | 57 | { |
| @@ -90,9 +99,8 @@ int trs_hw_sq_send_task(struct trs_sq_ctx *sq_ctx, enum trs_sq_send_sched_type s | |||
| 90 | int ret; | 99 | int ret; |
| 91 | 100 | ||
| 92 | if ((head >= sq_ctx->sq_depth) || (tail >= sq_ctx->sq_depth)) { | 101 | if ((head >= sq_ctx->sq_depth) || (tail >= sq_ctx->sq_depth)) { |
| 93 | - trs_err( | 102 | + trs_err("Invalid head tail. (devid=%u; tsid=%u; sqId=%u; sq_depth=%u; head=%u; tail=%u)\n", inst->devid, |
| 94 | - "Invalid head tail. (devid=%u; tsid=%u; sqId=%u; sq_depth=%u; head=%u; tail=%u)\n", inst->devid, | 103 | + inst->tsid, sq_ctx->sqid, sq_ctx->sq_depth, head, tail); |
| 95 | - inst->tsid, sq_ctx->sqid, sq_ctx->sq_depth, head, tail); | ||
| 96 | break; | 104 | break; |
| 97 | } | 105 | } |
| 98 | 106 | ||
| @@ -101,9 +109,8 @@ int trs_hw_sq_send_task(struct trs_sq_ctx *sq_ctx, enum trs_sq_send_sched_type s | |||
| 101 | ret = hal_kernel_trs_chan_send(inst, sq_ctx->chan_id, ¶); | 109 | ret = hal_kernel_trs_chan_send(inst, sq_ctx->chan_id, ¶); |
| 102 | if (ret != 0) { | 110 | if (ret != 0) { |
| 103 | sq_ctx->send_fail++; | 111 | sq_ctx->send_fail++; |
| 104 | - trs_debug( | 112 | + trs_debug("Send failed. (devid=%u; tsid=%u; sqId=%u; sq_depth=%u; head=%u; tail=%u; ret=%d)\n", inst->devid, |
| 105 | - "Send failed. (devid=%u; tsid=%u; sqId=%u; sq_depth=%u; head=%u; tail=%u; ret=%d)\n", inst->devid, | 113 | + inst->tsid, sq_ctx->sqid, sq_ctx->sq_depth, head, tail, ret); |
| 106 | - inst->tsid, sq_ctx->sqid, sq_ctx->sq_depth, head, tail, ret); | ||
| 107 | break; | 114 | break; |
| 108 | } | 115 | } |
| 109 | 116 | ||
| @@ -118,9 +125,8 @@ int trs_hw_sq_send_task(struct trs_sq_ctx *sq_ctx, enum trs_sq_send_sched_type s | |||
| 118 | ka_task_mutex_unlock(&sq_ctx->mutex); | 125 | ka_task_mutex_unlock(&sq_ctx->mutex); |
| 119 | 126 | ||
| 120 | if (num > 1) { | 127 | if (num > 1) { |
| 121 | - trs_debug( | 128 | + trs_debug("Tx burst. (devid=%u; tsid=%u; sqId=%u; num=%u; tail=%u)\n", inst->devid, inst->tsid, sq_ctx->sqid, |
| 122 | - "Tx burst. (devid=%u; tsid=%u; sqId=%u; num=%u; tail=%u)\n", inst->devid, inst->tsid, sq_ctx->sqid, num, | 129 | + num, tail); |
| 123 | - tail); | ||
| 124 | } | 130 | } |
| 125 | return num; | 131 | return num; |
| 126 | } | 132 | } |
| @@ -382,16 +388,15 @@ static int trs_chan_cq_full_proc(struct trs_id_inst *inst, int chan_id) | |||
| 382 | 388 | ||
| 383 | ret = trs_chan_ctrl(inst, chan_id, CHAN_CTRL_CMD_SQ_STATUS_SET, 0); | 389 | ret = trs_chan_ctrl(inst, chan_id, CHAN_CTRL_CMD_SQ_STATUS_SET, 0); |
| 384 | if (ret != 0) { | 390 | if (ret != 0) { |
| 385 | - trs_err( | 391 | + trs_err("Set sq status failed. (devid=%u; tsid=%u; chan_id=%d; ret=%d)\n", inst->devid, inst->tsid, chan_id, |
| 386 | - "Set sq status failed. (devid=%u; tsid=%u; chan_id=%d; ret=%d)\n", inst->devid, inst->tsid, chan_id, ret); | 392 | + ret); |
| 387 | return ret; | 393 | return ret; |
| 388 | } | 394 | } |
| 389 | 395 | ||
| 390 | ret = hal_kernel_trs_chan_recv(inst, chan_id, &recv_para); | 396 | ret = hal_kernel_trs_chan_recv(inst, chan_id, &recv_para); |
| 391 | if (ret != 0) { | 397 | if (ret != 0) { |
| 392 | - trs_err( | 398 | + trs_err("Fetch cq and update cq head failed. (devid=%u; tsid=%u; chan_id=%d; ret=%d)\n", inst->devid, |
| 393 | - "Fetch cq and update cq head failed. (devid=%u; tsid=%u; chan_id=%d; ret=%d)\n", inst->devid, inst->tsid, | 399 | + inst->tsid, chan_id, ret); |
| 394 | - chan_id, ret); | ||
| 395 | return ret; | 400 | return ret; |
| 396 | } | 401 | } |
| 397 | 402 | ||
| @@ -415,17 +420,16 @@ static int trs_hw_sqcq_abnormal_proc(struct trs_id_inst *inst, int chan_id, u8 e | |||
| 415 | return 0; | 420 | return 0; |
| 416 | } | 421 | } |
| 417 | 422 | ||
| 418 | -static int trs_hw_alloc_chan( | 423 | +static int trs_hw_alloc_chan(struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, |
| 419 | - struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, int *chan_id) | 424 | + int *chan_id) |
| 420 | { | 425 | { |
| 421 | struct trs_chan_para chan_para = {0}; | 426 | struct trs_chan_para chan_para = {0}; |
| 422 | int ret; | 427 | int ret; |
| 423 | 428 | ||
| 424 | - trs_debug( | 429 | + trs_debug("Alloc chan. (devid=%u; tsid=%u; flag=0x%x; sqeSize=%u; sqeDepth=%u; cqeSize=%u; cqeDepth=%u; " |
| 425 | - "Alloc chan. (devid=%u; tsid=%u; flag=0x%x; sqeSize=%u; sqeDepth=%u; cqeSize=%u; cqeDepth=%u; " | 430 | + "info[0]=%u)\n", |
| 426 | - "info[0]=%u)\n", | 431 | + inst->devid, inst->tsid, para->flag, para->sqeSize, para->sqeDepth, para->cqeSize, para->cqeDepth, |
| 427 | - inst->devid, inst->tsid, para->flag, para->sqeSize, para->sqeDepth, para->cqeSize, para->cqeDepth, | 432 | + para->info[0]); |
| 428 | - para->info[0]); | ||
| 429 | chan_para.types.type = CHAN_TYPE_HW; | 433 | chan_para.types.type = CHAN_TYPE_HW; |
| 430 | if ((para->flag & TSDRV_FLAG_ONLY_SQCQ_ID) != 0) { | 434 | if ((para->flag & TSDRV_FLAG_ONLY_SQCQ_ID) != 0) { |
| 431 | chan_para.types.sub_type = CHAN_SUB_TYPE_HW_TS; | 435 | chan_para.types.sub_type = CHAN_SUB_TYPE_HW_TS; |
| @@ -547,8 +551,8 @@ static int trs_pair_mode_alloc_para_check(struct trs_id_inst *inst, struct halSq | |||
| 547 | return 0; | 551 | return 0; |
| 548 | } | 552 | } |
| 549 | 553 | ||
| 550 | -static int trs_hw_sqcq_alloc_pair( | 554 | +static int trs_hw_sqcq_alloc_pair(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 551 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 555 | + struct halSqCqInputInfo *para) |
| 552 | { | 556 | { |
| 553 | struct trs_id_inst *inst = &ts_inst->inst; | 557 | struct trs_id_inst *inst = &ts_inst->inst; |
| 554 | struct trs_sqcq_reg_map_para reg_map_para; | 558 | struct trs_sqcq_reg_map_para reg_map_para; |
| @@ -569,10 +573,9 @@ static int trs_hw_sqcq_alloc_pair( | |||
| 569 | ret = trs_hw_alloc_chan(proc_ctx, &ts_inst->inst, para, &chan_id); | 573 | ret = trs_hw_alloc_chan(proc_ctx, &ts_inst->inst, para, &chan_id); |
| 570 | if (ret != 0) { | 574 | if (ret != 0) { |
| 571 | if (trs_get_proc_id_dfx_times(proc_ctx, inst->tsid, TRS_HW_SQ) <= TRS_PROC_DFX_TIMES_MAX) { | 575 | if (trs_get_proc_id_dfx_times(proc_ctx, inst->tsid, TRS_HW_SQ) <= TRS_PROC_DFX_TIMES_MAX) { |
| 572 | - trs_warn( | 576 | + trs_warn("Alloc chan failed. (devid=%u; tsid=%u; type=%d; cur_sq_num=%u; cur_cq_num=%u; ret=%d)\n", |
| 573 | - "Alloc chan failed. (devid=%u; tsid=%u; type=%d; cur_sq_num=%u; cur_cq_num=%u; ret=%d)\n", inst->devid, | 577 | + inst->devid, inst->tsid, para->type, trs_get_proc_res_num(proc_ctx, inst->tsid, TRS_HW_SQ), |
| 574 | - inst->tsid, para->type, trs_get_proc_res_num(proc_ctx, inst->tsid, TRS_HW_SQ), | 578 | + trs_get_proc_res_num(proc_ctx, inst->tsid, TRS_HW_CQ), ret); |
| 575 | - trs_get_proc_res_num(proc_ctx, inst->tsid, TRS_HW_CQ), ret); | ||
| 576 | } | 579 | } |
| 577 | return ret; | 580 | return ret; |
| 578 | } | 581 | } |
| @@ -605,9 +608,8 @@ static int trs_hw_sqcq_alloc_pair( | |||
| 605 | (void)trs_sq_remap(proc_ctx, ts_inst, para, &ts_inst->sq_ctx[sq_info.sqid], &sq_info); | 608 | (void)trs_sq_remap(proc_ctx, ts_inst, para, &ts_inst->sq_ctx[sq_info.sqid], &sq_info); |
| 606 | trs_set_sq_status(&ts_inst->sq_ctx[sq_info.sqid], 1); | 609 | trs_set_sq_status(&ts_inst->sq_ctx[sq_info.sqid], 1); |
| 607 | 610 | ||
| 608 | - trs_debug( | 611 | + trs_debug("Alloc pair sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, |
| 609 | - "Alloc pair sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->flag, | 612 | + para->flag, para->sqId, para->cqId); |
| 610 | - para->sqId, para->cqId); | ||
| 611 | return 0; | 613 | return 0; |
| 612 | 614 | ||
| 613 | del_sq_res: | 615 | del_sq_res: |
| @@ -635,8 +637,8 @@ int trs_get_stream_with_sq(struct trs_id_inst *inst, u32 sqid, u32 *stream_id) | |||
| 635 | } | 637 | } |
| 636 | KA_EXPORT_SYMBOL_GPL(trs_get_stream_with_sq); | 638 | KA_EXPORT_SYMBOL_GPL(trs_get_stream_with_sq); |
| 637 | 639 | ||
| 638 | -static int pair_mode_free_para_check( | 640 | +static int pair_mode_free_para_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 639 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 641 | + struct halSqCqFreeInfo *para) |
| 640 | { | 642 | { |
| 641 | struct trs_id_inst *inst = &ts_inst->inst; | 643 | struct trs_id_inst *inst = &ts_inst->inst; |
| 642 | u32 stream_id; | 644 | u32 stream_id; |
| @@ -657,8 +659,8 @@ static int pair_mode_free_para_check( | |||
| 657 | } | 659 | } |
| 658 | 660 | ||
| 659 | if (ts_inst->sq_ctx[para->sqId].chan_id != ts_inst->cq_ctx[para->cqId].chan_id) { | 661 | if (ts_inst->sq_ctx[para->sqId].chan_id != ts_inst->cq_ctx[para->cqId].chan_id) { |
| 660 | - trs_err( | 662 | + trs_err("Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, |
| 661 | - "Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 663 | + para->cqId); |
| 662 | return -EINVAL; | 664 | return -EINVAL; |
| 663 | } | 665 | } |
| 664 | 666 | ||
| @@ -671,15 +673,14 @@ static int pair_mode_free_para_check( | |||
| 671 | return 0; | 673 | return 0; |
| 672 | } | 674 | } |
| 673 | 675 | ||
| 674 | -static void _trs_hw_sqcq_free_pair( | 676 | +static void _trs_hw_sqcq_free_pair(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 flag, u32 sqId, |
| 675 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 flag, u32 sqId, u32 cqId) | 677 | + u32 cqId) |
| 676 | { | 678 | { |
| 677 | struct trs_id_inst *inst = &ts_inst->inst; | 679 | struct trs_id_inst *inst = &ts_inst->inst; |
| 678 | int chan_id; | 680 | int chan_id; |
| 679 | 681 | ||
| 680 | - trs_debug( | 682 | + trs_debug("Free pair sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, flag, sqId, |
| 681 | - "Free pair sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, flag, sqId, | 683 | + cqId); |
| 682 | - cqId); | ||
| 683 | 684 | ||
| 684 | chan_id = ts_inst->sq_ctx[sqId].chan_id; | 685 | chan_id = ts_inst->sq_ctx[sqId].chan_id; |
| 685 | 686 | ||
| @@ -693,9 +694,8 @@ static void _trs_hw_sqcq_free_pair( | |||
| 693 | hal_kernel_trs_chan_destroy_ex(inst, flag, chan_id); | 694 | hal_kernel_trs_chan_destroy_ex(inst, flag, chan_id); |
| 694 | } | 695 | } |
| 695 | 696 | ||
| 696 | -static void trs_fill_notice_ts_msg( | 697 | +static void trs_fill_notice_ts_msg(struct trs_proc_ctx *proc_ctx, u16 cmd_type, struct trs_chan_sq_info *sq_info, |
| 697 | - struct trs_proc_ctx *proc_ctx, u16 cmd_type, struct trs_chan_sq_info *sq_info, struct trs_chan_cq_info *cq_info, | 698 | + struct trs_chan_cq_info *cq_info, struct trs_normal_cqsq_mailbox *msg) |
| 698 | - struct trs_normal_cqsq_mailbox *msg) | ||
| 699 | { | 699 | { |
| 700 | trs_mbox_init_header(&msg->header, cmd_type); | 700 | trs_mbox_init_header(&msg->header, cmd_type); |
| 701 | 701 | ||
| @@ -716,8 +716,8 @@ static void trs_fill_notice_ts_msg( | |||
| 716 | /* adapt fill: app_type, fid, sq_cq_side */ | 716 | /* adapt fill: app_type, fid, sq_cq_side */ |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | -static int trs_hw_sqcq_status_query_notice_ts( | 719 | +static int trs_hw_sqcq_status_query_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 720 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 720 | + struct halSqCqFreeInfo *para) |
| 721 | { | 721 | { |
| 722 | struct trs_normal_cqsq_mailbox msg = {0}; | 722 | struct trs_normal_cqsq_mailbox msg = {0}; |
| 723 | struct trs_chan_sq_info sq_info; | 723 | struct trs_chan_sq_info sq_info; |
| @@ -741,8 +741,8 @@ static int trs_hw_sqcq_status_query_notice_ts( | |||
| 741 | return msg.header.result; | 741 | return msg.header.result; |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | -static int trs_hw_sqcq_free_pair( | 744 | +static int trs_hw_sqcq_free_pair(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 745 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 745 | + struct halSqCqFreeInfo *para) |
| 746 | { | 746 | { |
| 747 | struct trs_sqcq_reg_map_para reg_map_para; | 747 | struct trs_sqcq_reg_map_para reg_map_para; |
| 748 | struct trs_sq_ctx *sq_ctx = NULL; | 748 | struct trs_sq_ctx *sq_ctx = NULL; |
| @@ -782,8 +782,8 @@ static int trs_hw_sqcq_free_pair( | |||
| 782 | return 0; | 782 | return 0; |
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | -static int non_pair_mode_alloc_para_check( | 785 | +static int non_pair_mode_alloc_para_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 786 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 786 | + struct halSqCqInputInfo *para) |
| 787 | { | 787 | { |
| 788 | struct trs_id_inst *inst = &ts_inst->inst; | 788 | struct trs_id_inst *inst = &ts_inst->inst; |
| 789 | 789 | ||
| @@ -809,9 +809,8 @@ static int non_pair_mode_alloc_para_check( | |||
| 809 | return 0; | 809 | return 0; |
| 810 | } | 810 | } |
| 811 | 811 | ||
| 812 | -static int trs_hw_sqcq_alloc_sq_chan( | 812 | +static int trs_hw_sqcq_alloc_sq_chan(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 813 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 813 | + struct halSqCqInputInfo *para, struct trs_chan_sq_info *sq_info, int *chan_id) |
| 814 | - struct trs_chan_sq_info *sq_info, int *chan_id) | ||
| 815 | { | 814 | { |
| 816 | struct trs_id_inst *inst = &ts_inst->inst; | 815 | struct trs_id_inst *inst = &ts_inst->inst; |
| 817 | int ret; | 816 | int ret; |
| @@ -845,9 +844,8 @@ static void trs_hw_sqcq_free_sq_chan(struct trs_proc_ctx *proc_ctx, struct trs_c | |||
| 845 | trs_sq_ctx_uninit(&ts_inst->sq_ctx[sqid]); | 844 | trs_sq_ctx_uninit(&ts_inst->sq_ctx[sqid]); |
| 846 | } | 845 | } |
| 847 | 846 | ||
| 848 | -static int trs_hw_sqcq_alloc_cq_chan( | 847 | +static int trs_hw_sqcq_alloc_cq_chan(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 849 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 848 | + struct halSqCqInputInfo *para, struct trs_chan_cq_info *cq_info, int *chan_id) |
| 850 | - struct trs_chan_cq_info *cq_info, int *chan_id) | ||
| 851 | { | 849 | { |
| 852 | struct trs_id_inst *inst = &ts_inst->inst; | 850 | struct trs_id_inst *inst = &ts_inst->inst; |
| 853 | int ret; | 851 | int ret; |
| @@ -877,9 +875,9 @@ static void trs_hw_sqcq_free_cq_chan(struct trs_proc_ctx *proc_ctx, struct trs_c | |||
| 877 | trs_cq_ctx_uninit(&ts_inst->cq_ctx[cqid]); | 875 | trs_cq_ctx_uninit(&ts_inst->cq_ctx[cqid]); |
| 878 | } | 876 | } |
| 879 | 877 | ||
| 880 | -static int trs_hw_sqcq_alloc_notice_ts( | 878 | +static int trs_hw_sqcq_alloc_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 881 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 879 | + struct halSqCqInputInfo *para, struct trs_chan_sq_info *sq_info, |
| 882 | - struct trs_chan_sq_info *sq_info, struct trs_chan_cq_info *cq_info) | 880 | + struct trs_chan_cq_info *cq_info) |
| 883 | { | 881 | { |
| 884 | struct trs_normal_cqsq_mailbox msg; | 882 | struct trs_normal_cqsq_mailbox msg; |
| 885 | int ret; | 883 | int ret; |
| @@ -895,8 +893,8 @@ static int trs_hw_sqcq_alloc_notice_ts( | |||
| 895 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); | 893 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); |
| 896 | } | 894 | } |
| 897 | 895 | ||
| 898 | -static int trs_hw_sqcq_alloc_non_pair( | 896 | +static int trs_hw_sqcq_alloc_non_pair(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 899 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 897 | + struct halSqCqInputInfo *para) |
| 900 | { | 898 | { |
| 901 | struct trs_id_inst *inst = &ts_inst->inst; | 899 | struct trs_id_inst *inst = &ts_inst->inst; |
| 902 | struct trs_sqcq_reg_map_para reg_map_para; | 900 | struct trs_sqcq_reg_map_para reg_map_para; |
| @@ -972,15 +970,14 @@ static int trs_hw_sqcq_alloc_non_pair( | |||
| 972 | trs_set_sq_status(&ts_inst->sq_ctx[sq_info.sqid], 1); | 970 | trs_set_sq_status(&ts_inst->sq_ctx[sq_info.sqid], 1); |
| 973 | } | 971 | } |
| 974 | 972 | ||
| 975 | - trs_info( | 973 | + trs_info("Alloc non pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, |
| 976 | - "Alloc non pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, para->sqId, | 974 | + para->sqId, para->cqId, para->flag); |
| 977 | - para->cqId, para->flag); | ||
| 978 | 975 | ||
| 979 | return 0; | 976 | return 0; |
| 980 | } | 977 | } |
| 981 | 978 | ||
| 982 | -static int non_pair_mode_free_para_check( | 979 | +static int non_pair_mode_free_para_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 983 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 980 | + struct halSqCqFreeInfo *para) |
| 984 | { | 981 | { |
| 985 | struct trs_id_inst *inst = &ts_inst->inst; | 982 | struct trs_id_inst *inst = &ts_inst->inst; |
| 986 | 983 | ||
| @@ -999,8 +996,8 @@ static int non_pair_mode_free_para_check( | |||
| 999 | return 0; | 996 | return 0; |
| 1000 | } | 997 | } |
| 1001 | 998 | ||
| 1002 | -static int trs_hw_sqcq_free_notice_ts( | 999 | +static int trs_hw_sqcq_free_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 1003 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 1000 | + struct halSqCqFreeInfo *para) |
| 1004 | { | 1001 | { |
| 1005 | struct trs_normal_cqsq_mailbox msg; | 1002 | struct trs_normal_cqsq_mailbox msg; |
| 1006 | struct trs_chan_sq_info sq_info; | 1003 | struct trs_chan_sq_info sq_info; |
| @@ -1022,8 +1019,8 @@ static int trs_hw_sqcq_free_notice_ts( | |||
| 1022 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); | 1019 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); |
| 1023 | } | 1020 | } |
| 1024 | 1021 | ||
| 1025 | -static int trs_hw_sqcq_free_non_pair( | 1022 | +static int trs_hw_sqcq_free_non_pair(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 1026 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 1023 | + struct halSqCqFreeInfo *para) |
| 1027 | { | 1024 | { |
| 1028 | struct trs_id_inst *inst = &ts_inst->inst; | 1025 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1029 | int ret; | 1026 | int ret; |
| @@ -1035,15 +1032,13 @@ static int trs_hw_sqcq_free_non_pair( | |||
| 1035 | 1032 | ||
| 1036 | ret = trs_hw_sqcq_free_notice_ts(proc_ctx, ts_inst, para); | 1033 | ret = trs_hw_sqcq_free_notice_ts(proc_ctx, ts_inst, para); |
| 1037 | if (ret != 0) { | 1034 | if (ret != 0) { |
| 1038 | - trs_info( | 1035 | + trs_info("Notice ts warn. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, |
| 1039 | - "Notice ts warn. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, para->sqId, | 1036 | + para->sqId, para->cqId, para->flag); |
| 1040 | - para->cqId, para->flag); | ||
| 1041 | return ret; | 1037 | return ret; |
| 1042 | } | 1038 | } |
| 1043 | 1039 | ||
| 1044 | - trs_info( | 1040 | + trs_info("Free non pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, |
| 1045 | - "Free non pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u; flag=%x)\n", inst->devid, inst->tsid, para->sqId, | 1041 | + para->sqId, para->cqId, para->flag); |
| 1046 | - para->cqId, para->flag); | ||
| 1047 | 1042 | ||
| 1048 | trs_set_sq_status(&ts_inst->sq_ctx[para->sqId], 0); | 1043 | trs_set_sq_status(&ts_inst->sq_ctx[para->sqId], 0); |
| 1049 | trs_sq_unmap(proc_ctx, ts_inst, &ts_inst->sq_ctx[para->sqId]); | 1044 | trs_sq_unmap(proc_ctx, ts_inst, &ts_inst->sq_ctx[para->sqId]); |
| @@ -1091,9 +1086,8 @@ int trs_hw_sqcq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 1091 | } | 1086 | } |
| 1092 | 1087 | ||
| 1093 | if (ret != 0) { | 1088 | if (ret != 0) { |
| 1094 | - trs_err( | 1089 | + trs_err("No stream. (ret=%d; devid=%u; tsid=%u; stream_id=%u)\n", ret, ts_inst->inst.devid, |
| 1095 | - "No stream. (ret=%d; devid=%u; tsid=%u; stream_id=%u)\n", ret, ts_inst->inst.devid, | 1090 | + ts_inst->inst.tsid, stream_id); |
| 1096 | - ts_inst->inst.tsid, stream_id); | ||
| 1097 | return ret; | 1091 | return ret; |
| 1098 | } | 1092 | } |
| 1099 | } | 1093 | } |
| @@ -1147,8 +1141,8 @@ static bool trs_stream_mem_is_need_update(struct trs_core_ts_inst *ts_inst, u64 | |||
| 1147 | return false; | 1141 | return false; |
| 1148 | } | 1142 | } |
| 1149 | 1143 | ||
| 1150 | -static int trs_sq_switch_stream_notice_ts( | 1144 | +static int trs_sq_switch_stream_notice_ts(struct trs_core_ts_inst *ts_inst, u32 sqid, u32 stream_id, u64 stream_pa_addr, |
| 1151 | - struct trs_core_ts_inst *ts_inst, u32 sqid, u32 stream_id, u64 stream_pa_addr, u32 sq_depth) | 1145 | + u32 sq_depth) |
| 1152 | { | 1146 | { |
| 1153 | struct trs_sq_switch_stream_info msg; | 1147 | struct trs_sq_switch_stream_info msg; |
| 1154 | u64 stream_device_pa = stream_pa_addr; | 1148 | u64 stream_device_pa = stream_pa_addr; |
| @@ -1175,16 +1169,15 @@ static int trs_sq_switch_stream_notice_ts( | |||
| 1175 | 1169 | ||
| 1176 | ret = ts_inst->ops.notice_ts(&ts_inst->inst, (u8 *)&msg, sizeof(struct trs_sq_switch_stream_info)); | 1170 | ret = ts_inst->ops.notice_ts(&ts_inst->inst, (u8 *)&msg, sizeof(struct trs_sq_switch_stream_info)); |
| 1177 | if ((ret != 0) || (msg.header.result != 0)) { | 1171 | if ((ret != 0) || (msg.header.result != 0)) { |
| 1178 | - trs_err( | 1172 | + trs_err("Notice ts failed. (ret=%d; result=%u; devid=%u; stream_id=%u; sqid=%u)\n", ret, msg.header.result, |
| 1179 | - "Notice ts failed. (ret=%d; result=%u; devid=%u; stream_id=%u; sqid=%u)\n", ret, msg.header.result, | 1173 | + ts_inst->inst.devid, stream_id, sqid); |
| 1180 | - ts_inst->inst.devid, stream_id, sqid); | ||
| 1181 | return (ret != 0) ? ret : -EINVAL; | 1174 | return (ret != 0) ? ret : -EINVAL; |
| 1182 | } | 1175 | } |
| 1183 | return 0; | 1176 | return 0; |
| 1184 | } | 1177 | } |
| 1185 | 1178 | ||
| 1186 | -int trs_sq_switch_stream( | 1179 | +int trs_sq_switch_stream(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 1187 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct sq_switch_stream_info *info) | 1180 | + struct sq_switch_stream_info *info) |
| 1188 | { | 1181 | { |
| 1189 | struct trs_id_inst *inst = &ts_inst->inst; | 1182 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1190 | struct trs_stream_ctx *new_stream_ctx = NULL; | 1183 | struct trs_stream_ctx *new_stream_ctx = NULL; |
| @@ -1236,9 +1229,8 @@ int trs_sq_switch_stream( | |||
| 1236 | 1229 | ||
| 1237 | ret = trs_sq_switch_stream_notice_ts(ts_inst, info->sq_id, info->stream_id, stream_pa_addr, info->sq_depth); | 1230 | ret = trs_sq_switch_stream_notice_ts(ts_inst, info->sq_id, info->stream_id, stream_pa_addr, info->sq_depth); |
| 1238 | if (ret != 0) { | 1231 | if (ret != 0) { |
| 1239 | - trs_err( | 1232 | + trs_err("Notice ts failed. (ret=%d; devid=%u; tsid=%u; stream_id=%u; sqid=%u)\n", ret, inst->devid, inst->tsid, |
| 1240 | - "Notice ts failed. (ret=%d; devid=%u; tsid=%u; stream_id=%u; sqid=%u)\n", ret, inst->devid, inst->tsid, | 1233 | + info->stream_id, info->sq_id); |
| 1241 | - info->stream_id, info->sq_id); | ||
| 1242 | goto put_mem; | 1234 | goto put_mem; |
| 1243 | } | 1235 | } |
| 1244 | 1236 | ||
| @@ -1250,13 +1242,12 @@ int trs_sq_switch_stream( | |||
| 1250 | 1242 | ||
| 1251 | if (info->stream_id != KA_U32_MAX) { | 1243 | if (info->stream_id != KA_U32_MAX) { |
| 1252 | ts_inst->stream_ctx[info->stream_id].sq = info->sq_id; | 1244 | ts_inst->stream_ctx[info->stream_id].sq = info->sq_id; |
| 1253 | - trs_stream_set_bind_sqcq( | 1245 | + trs_stream_set_bind_sqcq(ts_inst, info->stream_id, info->sq_id, ts_inst->sq_ctx[info->sq_id].cqid, |
| 1254 | - ts_inst, info->stream_id, info->sq_id, ts_inst->sq_ctx[info->sq_id].cqid, proc_ctx->pid); | 1246 | + proc_ctx->pid); |
| 1255 | } | 1247 | } |
| 1256 | 1248 | ||
| 1257 | - trs_debug( | 1249 | + trs_debug("Sq switches stream success. (devid=%u; tsid=%u; stream_id=%u; sqid=%u)\n", inst->devid, inst->tsid, |
| 1258 | - "Sq switches stream success. (devid=%u; tsid=%u; stream_id=%u; sqid=%u)\n", inst->devid, inst->tsid, | 1250 | + info->stream_id, info->sq_id); |
| 1259 | - info->stream_id, info->sq_id); | ||
| 1260 | 1251 | ||
| 1261 | return 0; | 1252 | return 0; |
| 1262 | 1253 | ||
| @@ -1353,17 +1344,16 @@ int trs_hw_sqcq_get(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_i | |||
| 1353 | para->cqeSize = 32; /* 32 is cqe size for ut */ | 1344 | para->cqeSize = 32; /* 32 is cqe size for ut */ |
| 1354 | 1345 | ||
| 1355 | 1346 | ||
| 1356 | - trs_debug( | 1347 | + trs_debug("Share sqcq info. (devid=%u; streamid=%u; sqid=%u; sq_depth=%u; sqe_size=%u; cqid=%u; " |
| 1357 | - "Share sqcq info. (devid=%u; streamid=%u; sqid=%u; sq_depth=%u; sqe_size=%u; cqid=%u; " | 1348 | + "cq_depth=%u; cqe_size=%u; logic_cqid=%d)\n", |
| 1358 | - "cq_depth=%u; cqe_size=%u; logic_cqid=%d)\n", | 1349 | + proc_ctx->devid, stream_id, para->sqId, para->sqeDepth, para->sqeSize, para->cqId, para->cqeDepth, |
| 1359 | - proc_ctx->devid, stream_id, para->sqId, para->sqeDepth, para->sqeSize, para->cqId, para->cqeDepth, | 1350 | + para->cqeSize, para->info[1]); |
| 1360 | - para->cqeSize, para->info[1]); | ||
| 1361 | 1351 | ||
| 1362 | return 0; | 1352 | return 0; |
| 1363 | } | 1353 | } |
| 1364 | 1354 | ||
| 1365 | -static int trs_sqcq_restore_para_check( | 1355 | +static int trs_sqcq_restore_para_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 1366 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 1356 | + struct halSqCqInputInfo *para) |
| 1367 | { | 1357 | { |
| 1368 | struct trs_id_inst *inst = &ts_inst->inst; | 1358 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1369 | 1359 | ||
| @@ -1384,8 +1374,8 @@ static int trs_sqcq_restore_para_check( | |||
| 1384 | 1374 | ||
| 1385 | if (ts_inst->sq_ctx[para->sqId].chan_id != ts_inst->cq_ctx[para->cqId].chan_id) { | 1375 | if (ts_inst->sq_ctx[para->sqId].chan_id != ts_inst->cq_ctx[para->cqId].chan_id) { |
| 1386 | 1376 | ||
| 1387 | - trs_err( | 1377 | + trs_err("Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, |
| 1388 | - "Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 1378 | + para->cqId); |
| 1389 | return -EINVAL; | 1379 | return -EINVAL; |
| 1390 | 1380 | ||
| 1391 | } | 1381 | } |
| @@ -1413,33 +1403,32 @@ int trs_hw_sqcq_restore(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst * | |||
| 1413 | return ret; | 1403 | return ret; |
| 1414 | } | 1404 | } |
| 1415 | 1405 | ||
| 1416 | - trs_debug( | 1406 | + trs_debug("Restore sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->flag, |
| 1417 | - "Restore sqcq. (devid=%u; tsid=%u; flag=0x%x; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->flag, | 1407 | + para->sqId, para->cqId); |
| 1418 | - para->sqId, para->cqId); | ||
| 1419 | 1408 | ||
| 1420 | return 0; | 1409 | return 0; |
| 1421 | } | 1410 | } |
| 1422 | 1411 | ||
| 1423 | -void trs_proc_diable_sq_status( | 1412 | +void trs_proc_diable_sq_status(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, |
| 1424 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id) | 1413 | + u32 res_id) |
| 1425 | { | 1414 | { |
| 1426 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[res_id]; | 1415 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[res_id]; |
| 1427 | struct trs_id_inst *inst = &ts_inst->inst; | 1416 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1428 | 1417 | ||
| 1429 | trs_set_sq_status(sq_ctx, 0); | 1418 | trs_set_sq_status(sq_ctx, 0); |
| 1430 | - trs_debug( | 1419 | + trs_debug("Disable sq success. (devid=%u; tsid=%u; pid=%u; sqid=%u)\n", inst->devid, inst->tsid, proc_ctx->pid, |
| 1431 | - "Disable sq success. (devid=%u; tsid=%u; pid=%u; sqid=%u)\n", inst->devid, inst->tsid, proc_ctx->pid, res_id); | 1420 | + res_id); |
| 1432 | } | 1421 | } |
| 1433 | 1422 | ||
| 1434 | -static void trs_proc_enable_sq_status( | 1423 | +static void trs_proc_enable_sq_status(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, |
| 1435 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id) | 1424 | + u32 res_id) |
| 1436 | { | 1425 | { |
| 1437 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[res_id]; | 1426 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[res_id]; |
| 1438 | struct trs_id_inst *inst = &ts_inst->inst; | 1427 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1439 | 1428 | ||
| 1440 | trs_set_sq_status(sq_ctx, 1); | 1429 | trs_set_sq_status(sq_ctx, 1); |
| 1441 | - trs_debug( | 1430 | + trs_debug("Enable sq success. (devid=%u; tsid=%u; pid=%u; sqid=%u)\n", inst->devid, inst->tsid, proc_ctx->pid, |
| 1442 | - "Enable sq success. (devid=%u; tsid=%u; pid=%u; sqid=%u)\n", inst->devid, inst->tsid, proc_ctx->pid, res_id); | 1431 | + res_id); |
| 1443 | } | 1432 | } |
| 1444 | 1433 | ||
| 1445 | static int trs_sq_task_stop(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 sqid) | 1434 | static int trs_sq_task_stop(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 sqid) |
| @@ -1454,8 +1443,8 @@ static int trs_sq_task_resume(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_ | |||
| 1454 | return 0; | 1443 | return 0; |
| 1455 | } | 1444 | } |
| 1456 | 1445 | ||
| 1457 | -static int trs_hw_sqcq_config_of_proc( | 1446 | +static int trs_hw_sqcq_config_of_proc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, uint32_t type, |
| 1458 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, uint32_t type, int prop) | 1447 | + int prop) |
| 1459 | { | 1448 | { |
| 1460 | u32 i; | 1449 | u32 i; |
| 1461 | int ret = 0; | 1450 | int ret = 0; |
| @@ -1488,8 +1477,8 @@ static int trs_config_sq_tail_check(struct trs_core_ts_inst *ts_inst, struct hal | |||
| 1488 | { | 1477 | { |
| 1489 | u32 stream_id = ts_inst->sq_ctx[para->sqId].stream_id; | 1478 | u32 stream_id = ts_inst->sq_ctx[para->sqId].stream_id; |
| 1490 | if (stream_id >= trs_res_get_max_id(ts_inst, TRS_STREAM)) { | 1479 | if (stream_id >= trs_res_get_max_id(ts_inst, TRS_STREAM)) { |
| 1491 | - trs_err( | 1480 | + trs_err("Stream id is invalid. (devid=%u; sqid=%u; stream_id=%u)\n", ts_inst->inst.devid, para->sqId, |
| 1492 | - "Stream id is invalid. (devid=%u; sqid=%u; stream_id=%u)\n", ts_inst->inst.devid, para->sqId, stream_id); | 1481 | + stream_id); |
| 1493 | return -EINVAL; | 1482 | return -EINVAL; |
| 1494 | } | 1483 | } |
| 1495 | 1484 | ||
| @@ -1502,9 +1491,8 @@ static int trs_config_sq_tail_check(struct trs_core_ts_inst *ts_inst, struct hal | |||
| 1502 | } | 1491 | } |
| 1503 | } | 1492 | } |
| 1504 | 1493 | ||
| 1505 | - trs_debug( | 1494 | + trs_debug("Config tail success. (devid=%u; sqid=%u; tail=%u; value=%u)\n", ts_inst->inst.devid, para->sqId, |
| 1506 | - "Config tail success. (devid=%u; sqid=%u; tail=%u; value=%u)\n", ts_inst->inst.devid, para->sqId, | 1495 | + ts_inst->stream_ctx[stream_id].tail, para->value[0]); |
| 1507 | - ts_inst->stream_ctx[stream_id].tail, para->value[0]); | ||
| 1508 | return 0; | 1496 | return 0; |
| 1509 | } | 1497 | } |
| 1510 | 1498 | ||
| @@ -1520,9 +1508,8 @@ int trs_hw_sqcq_config(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 1520 | ret = trs_hw_sqcq_config_of_proc(proc_ctx, ts_inst, TRS_HW_SQ, para->prop); | 1508 | ret = trs_hw_sqcq_config_of_proc(proc_ctx, ts_inst, TRS_HW_SQ, para->prop); |
| 1521 | ret |= trs_hw_sqcq_config_of_proc(proc_ctx, ts_inst, TRS_HW_CQ, para->prop); /* cq need to pause in UB scene */ | 1509 | ret |= trs_hw_sqcq_config_of_proc(proc_ctx, ts_inst, TRS_HW_CQ, para->prop); /* cq need to pause in UB scene */ |
| 1522 | if (ret != 0) { | 1510 | if (ret != 0) { |
| 1523 | - trs_err( | 1511 | + trs_err("Proc sqcq config failed. (devid=%u; pid=%u; prop=%d; ret=%d)\n", inst->devid, proc_ctx->pid, |
| 1524 | - "Proc sqcq config failed. (devid=%u; pid=%u; prop=%d; ret=%d)\n", inst->devid, proc_ctx->pid, | 1512 | + para->prop, ret); |
| 1525 | - para->prop, ret); | ||
| 1526 | return ret; | 1513 | return ret; |
| 1527 | } | 1514 | } |
| 1528 | trs_debug("Proc sqcq config success. (devid=%u; pid=%u; prop=%d)\n", inst->devid, proc_ctx->pid, para->prop); | 1515 | trs_debug("Proc sqcq config success. (devid=%u; pid=%u; prop=%d)\n", inst->devid, proc_ctx->pid, para->prop); |
| @@ -1569,9 +1556,8 @@ int trs_hw_sqcq_config(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 1569 | } | 1556 | } |
| 1570 | 1557 | ||
| 1571 | if (ret != 0) { | 1558 | if (ret != 0) { |
| 1572 | - trs_err( | 1559 | + trs_err("Cfg failed. (devid=%u; tsid=%u; sqId=%u; cqId=%u; prop=%d)\n", inst->devid, inst->tsid, sqid, cqid, |
| 1573 | - "Cfg failed. (devid=%u; tsid=%u; sqId=%u; cqId=%u; prop=%d)\n", inst->devid, inst->tsid, sqid, cqid, | 1560 | + para->prop); |
| 1574 | - para->prop); | ||
| 1575 | } | 1561 | } |
| 1576 | 1562 | ||
| 1577 | return ret; | 1563 | return ret; |
| @@ -1688,9 +1674,8 @@ int trs_sqcq_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_in | |||
| 1688 | } | 1674 | } |
| 1689 | 1675 | ||
| 1690 | if (ret != 0) { | 1676 | if (ret != 0) { |
| 1691 | - trs_err( | 1677 | + trs_err("Query failed. (devid=%u; tsid=%u; sqId=%u; prop=%d; ret=%d)\n", inst->devid, inst->tsid, sqid, |
| 1692 | - "Query failed. (devid=%u; tsid=%u; sqId=%u; prop=%d; ret=%d)\n", inst->devid, inst->tsid, sqid, para->prop, | 1678 | + para->prop, ret); |
| 1693 | - ret); | ||
| 1694 | } | 1679 | } |
| 1695 | 1680 | ||
| 1696 | return ret; | 1681 | return ret; |
| @@ -1774,8 +1759,8 @@ void trs_hw_sqcq_recycle(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 1774 | } | 1759 | } |
| 1775 | } | 1760 | } |
| 1776 | 1761 | ||
| 1777 | -int trs_hw_sqcq_dma_desc_create( | 1762 | +int trs_hw_sqcq_dma_desc_create(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 1778 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_cmd_dma_desc *para) | 1763 | + struct trs_cmd_dma_desc *para) |
| 1779 | { | 1764 | { |
| 1780 | struct trs_id_inst *inst = &ts_inst->inst; | 1765 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1781 | u32 sqid = para->sq_id; | 1766 | u32 sqid = para->sq_id; |
| @@ -1789,9 +1774,8 @@ int trs_hw_sqcq_dma_desc_create( | |||
| 1789 | chan_id = ts_inst->sq_ctx[sqid].chan_id; | 1774 | chan_id = ts_inst->sq_ctx[sqid].chan_id; |
| 1790 | ret = trs_chan_dma_desc_create(inst, chan_id, (struct trs_chan_dma_desc *)para); | 1775 | ret = trs_chan_dma_desc_create(inst, chan_id, (struct trs_chan_dma_desc *)para); |
| 1791 | if (ret != 0) { | 1776 | if (ret != 0) { |
| 1792 | - trs_err( | 1777 | + trs_err("Sqcq dma desc create failed. (devid=%u; tsid=%u; sqid=%u; ret=%d)\n", proc_ctx->devid, para->tsid, |
| 1793 | - "Sqcq dma desc create failed. (devid=%u; tsid=%u; sqid=%u; ret=%d)\n", proc_ctx->devid, para->tsid, | 1778 | + para->sq_id, ret); |
| 1794 | - para->sq_id, ret); | ||
| 1795 | return -EINVAL; | 1779 | return -EINVAL; |
| 1796 | } | 1780 | } |
| 1797 | 1781 | ||
| @@ -1836,9 +1820,15 @@ static u32 trs_hw_sq_get_wq_flag(u32 ts_inst_flag) | |||
| 1836 | return flag; | 1820 | return flag; |
| 1837 | } | 1821 | } |
| 1838 | 1822 | ||
| 1839 | -static u32 trs_hw_sq_get_trigger_wq_flag(u32 ts_inst_flag) { return trs_hw_sq_get_wq_flag(ts_inst_flag) | WQ_HIGHPRI; } | 1823 | +static u32 trs_hw_sq_get_trigger_wq_flag(u32 ts_inst_flag) |
| 1824 | +{ | ||
| 1825 | + return trs_hw_sq_get_wq_flag(ts_inst_flag) | WQ_HIGHPRI; | ||
| 1826 | +} | ||
| 1840 | 1827 | ||
| 1841 | -static u32 trs_hw_sq_get_fair_wq_flag(u32 ts_inst_flag) { return trs_hw_sq_get_wq_flag(ts_inst_flag); } | 1828 | +static u32 trs_hw_sq_get_fair_wq_flag(u32 ts_inst_flag) |
| 1829 | +{ | ||
| 1830 | + return trs_hw_sq_get_wq_flag(ts_inst_flag); | ||
| 1831 | +} | ||
| 1842 | 1832 | ||
| 1843 | static int trs_hw_sq_trigger_init(struct trs_core_ts_inst *ts_inst) | 1833 | static int trs_hw_sq_trigger_init(struct trs_core_ts_inst *ts_inst) |
| 1844 | { | 1834 | { |
| @@ -1855,8 +1845,8 @@ static int trs_hw_sq_trigger_init(struct trs_core_ts_inst *ts_inst) | |||
| 1855 | return ret; | 1845 | return ret; |
| 1856 | } | 1846 | } |
| 1857 | 1847 | ||
| 1858 | - ts_inst->work_queue = ka_task_alloc_workqueue( | 1848 | + ts_inst->work_queue = ka_task_alloc_workqueue("dev%u_sq_send_wq", |
| 1859 | - "dev%u_sq_send_wq", trs_hw_sq_get_trigger_wq_flag(ts_inst->ts_inst_flag), 1, inst->devid); | 1849 | + trs_hw_sq_get_trigger_wq_flag(ts_inst->ts_inst_flag), 1, inst->devid); |
| 1860 | if (ts_inst->work_queue == NULL) { | 1850 | if (ts_inst->work_queue == NULL) { |
| 1861 | trs_err("Createn wq failed. (devid=%u; tsid=%u)\n", inst->devid, inst->tsid); | 1851 | trs_err("Createn wq failed. (devid=%u; tsid=%u)\n", inst->devid, inst->tsid); |
| 1862 | 1852 | ||
| @@ -1864,8 +1854,8 @@ static int trs_hw_sq_trigger_init(struct trs_core_ts_inst *ts_inst) | |||
| 1864 | 1854 | ||
| 1865 | } | 1855 | } |
| 1866 | 1856 | ||
| 1867 | - ts_inst->fair_work_queue = | 1857 | + ts_inst->fair_work_queue = ka_task_alloc_workqueue( |
| 1868 | - ka_task_alloc_workqueue("dev%u_sq_fair_wq", trs_hw_sq_get_fair_wq_flag(ts_inst->ts_inst_flag), 1, inst->devid); | 1858 | + "dev%u_sq_fair_wq", trs_hw_sq_get_fair_wq_flag(ts_inst->ts_inst_flag), 1, inst->devid); |
| 1869 | if (ts_inst->fair_work_queue == NULL) { | 1859 | if (ts_inst->fair_work_queue == NULL) { |
| 1870 | ka_task_destroy_workqueue(ts_inst->work_queue); | 1860 | ka_task_destroy_workqueue(ts_inst->work_queue); |
| 1871 | trs_err("Create fair wq failed. (devid=%u; tsid=%u)\n", inst->devid, inst->tsid); | 1861 | trs_err("Create fair wq failed. (devid=%u; tsid=%u)\n", inst->devid, inst->tsid); |
| @@ -1886,8 +1876,8 @@ static int trs_hw_sq_trigger_init(struct trs_core_ts_inst *ts_inst) | |||
| 1886 | return ret; | 1876 | return ret; |
| 1887 | } | 1877 | } |
| 1888 | 1878 | ||
| 1889 | - ret = ts_inst->ops.request_irq( | 1879 | + ret = ts_inst->ops.request_irq(inst, ts_inst->irq_type, ts_inst->sq_trigger_irq, (void *)ts_inst, |
| 1890 | - inst, ts_inst->irq_type, ts_inst->sq_trigger_irq, (void *)ts_inst, trs_sq_trigger_irq_proc); | 1880 | + trs_sq_trigger_irq_proc); |
| 1891 | if (ret != 0) { | 1881 | if (ret != 0) { |
| 1892 | 1882 | ||
| 1893 | trs_hw_sq_send_thread_destroy(ts_inst); | 1883 | trs_hw_sq_send_thread_destroy(ts_inst); |
| @@ -1935,15 +1925,13 @@ int trs_hw_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 1935 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_HW_CQ); | 1925 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_HW_CQ); |
| 1936 | int ret; | 1926 | int ret; |
| 1937 | 1927 | ||
| 1938 | - trs_debug( | 1928 | + trs_debug("Init hw sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", |
| 1939 | - "Init hw sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", inst->devid, | 1929 | + inst->devid, inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); |
| 1940 | - inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); | ||
| 1941 | 1930 | ||
| 1942 | ts_inst->sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); | 1931 | ts_inst->sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); |
| 1943 | if (ts_inst->sq_ctx == NULL) { | 1932 | if (ts_inst->sq_ctx == NULL) { |
| 1944 | - trs_err( | 1933 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 1945 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 1934 | + sizeof(struct trs_sq_ctx) * sq_max_id); |
| 1946 | - sizeof(struct trs_sq_ctx) * sq_max_id); | ||
| 1947 | return -ENOMEM; | 1935 | return -ENOMEM; |
| 1948 | } | 1936 | } |
| 1949 | ts_inst->sq_ctx->sq_num = sq_max_id; | 1937 | ts_inst->sq_ctx->sq_num = sq_max_id; |
| @@ -1954,9 +1942,8 @@ int trs_hw_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 1954 | trs_sq_ctxs_uninit(ts_inst->sq_ctx); | 1942 | trs_sq_ctxs_uninit(ts_inst->sq_ctx); |
| 1955 | trs_vfree(ts_inst->sq_ctx); | 1943 | trs_vfree(ts_inst->sq_ctx); |
| 1956 | ts_inst->sq_ctx = NULL; | 1944 | ts_inst->sq_ctx = NULL; |
| 1957 | - trs_err( | 1945 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 1958 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 1946 | + sizeof(struct trs_cq_ctx) * cq_max_id); |
| 1959 | - sizeof(struct trs_cq_ctx) * cq_max_id); | ||
| 1960 | return -ENOMEM; | 1947 | return -ENOMEM; |
| 1961 | } | 1948 | } |
| 1962 | 1949 | ||
| @@ -22,7 +22,10 @@ | |||
| 22 | 22 | ||
| 23 | struct trs_core_ts_inst; | 23 | struct trs_core_ts_inst; |
| 24 | 24 | ||
| 25 | -enum trs_sq_send_sched_type { SQ_SEND_NON_FAIR_MODE, SQ_SEND_FAIR_MODE }; | 25 | +enum trs_sq_send_sched_type { |
| 26 | + SQ_SEND_NON_FAIR_MODE, | ||
| 27 | + SQ_SEND_FAIR_MODE | ||
| 28 | +}; | ||
| 26 | 29 | ||
| 27 | int trs_hw_sqcq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para); | 30 | int trs_hw_sqcq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para); |
| 28 | int trs_hw_sqcq_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para); | 31 | int trs_hw_sqcq_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para); |
| @@ -34,8 +37,8 @@ int trs_sqcq_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_in | |||
| 34 | 37 | ||
| 35 | int trs_hw_sqcq_send(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halTaskSendInfo *para); | 38 | int trs_hw_sqcq_send(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halTaskSendInfo *para); |
| 36 | int trs_hw_sqcq_recv(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para); | 39 | int trs_hw_sqcq_recv(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para); |
| 37 | -void trs_proc_diable_sq_status( | 40 | +void trs_proc_diable_sq_status(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, |
| 38 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 41 | + u32 res_id); |
| 39 | void trs_hw_sqcq_recycle(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 42 | void trs_hw_sqcq_recycle(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| 40 | 43 | ||
| 41 | void trs_hw_sq_trigger_irq_hw_res_uninit(struct trs_core_ts_inst *ts_inst); | 44 | void trs_hw_sq_trigger_irq_hw_res_uninit(struct trs_core_ts_inst *ts_inst); |
| @@ -44,10 +47,10 @@ int trs_hw_sqcq_init(struct trs_core_ts_inst *ts_inst); | |||
| 44 | void trs_hw_sqcq_uninit(struct trs_core_ts_inst *ts_inst); | 47 | void trs_hw_sqcq_uninit(struct trs_core_ts_inst *ts_inst); |
| 45 | int trs_hw_sq_send_thread_create(struct trs_core_ts_inst *ts_inst); | 48 | int trs_hw_sq_send_thread_create(struct trs_core_ts_inst *ts_inst); |
| 46 | void trs_hw_sq_send_thread_destroy(struct trs_core_ts_inst *ts_inst); | 49 | void trs_hw_sq_send_thread_destroy(struct trs_core_ts_inst *ts_inst); |
| 47 | -int trs_hw_sqcq_dma_desc_create( | 50 | +int trs_hw_sqcq_dma_desc_create(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 48 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_cmd_dma_desc *para); | 51 | + struct trs_cmd_dma_desc *para); |
| 49 | -int trs_sq_switch_stream( | 52 | +int trs_sq_switch_stream(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 50 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct sq_switch_stream_info *info); | 53 | + struct sq_switch_stream_info *info); |
| 51 | 54 | ||
| 52 | int trs_hw_sq_send_task(struct trs_sq_ctx *sq_ctx, enum trs_sq_send_sched_type sched_mode); | 55 | int trs_hw_sq_send_task(struct trs_sq_ctx *sq_ctx, enum trs_sq_send_sched_type sched_mode); |
| 53 | 56 | ||
| @@ -147,8 +147,8 @@ static int trs_thread_bind_irq_init(struct trs_core_ts_inst *ts_inst) | |||
| 147 | irq_ctx[i].irq = irq[i]; | 147 | irq_ctx[i].irq = irq[i]; |
| 148 | irq_ctx[i].irq_type = irq_type; | 148 | irq_ctx[i].irq_type = irq_type; |
| 149 | 149 | ||
| 150 | - ret = ts_inst->ops.request_irq( | 150 | + ret = ts_inst->ops.request_irq(inst, irq_ctx[i].irq_type, irq_ctx[i].irq, (void *)&irq_ctx[i], |
| 151 | - inst, irq_ctx[i].irq_type, irq_ctx[i].irq, (void *)&irq_ctx[i], trs_thread_bind_irq_proc); | 151 | + trs_thread_bind_irq_proc); |
| 152 | if (ret != 0) { | 152 | if (ret != 0) { |
| 153 | trs_thread_bind_irq_uninit(ts_inst, i); | 153 | trs_thread_bind_irq_uninit(ts_inst, i); |
| 154 | trs_err("Request irq failed. (devid=%u; tsid=%u; id=%u; ret=%d)\n", inst->devid, inst->tsid, i, ret); | 154 | trs_err("Request irq failed. (devid=%u; tsid=%u; id=%u; ret=%d)\n", inst->devid, inst->tsid, i, ret); |
| @@ -159,8 +159,8 @@ static int trs_thread_bind_irq_init(struct trs_core_ts_inst *ts_inst) | |||
| 159 | return 0; | 159 | return 0; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | -static int trs_thread_bind_irq_alloc( | 162 | +static int trs_thread_bind_irq_alloc(struct trs_core_ts_inst *ts_inst, ka_atomic_t *wait_flag, |
| 163 | - struct trs_core_ts_inst *ts_inst, ka_atomic_t *wait_flag, ka_wait_queue_head_t *wait_queue) | 163 | + ka_wait_queue_head_t *wait_queue) |
| 164 | { | 164 | { |
| 165 | struct trs_thread_bind_intr_mng *intr_mng = &ts_inst->logic_cq_ctx.intr_mng; | 165 | struct trs_thread_bind_intr_mng *intr_mng = &ts_inst->logic_cq_ctx.intr_mng; |
| 166 | struct trs_thread_bind_intr_ctx *irq_ctx = intr_mng->irq_ctx; | 166 | struct trs_thread_bind_intr_ctx *irq_ctx = intr_mng->irq_ctx; |
| @@ -206,8 +206,8 @@ static int trs_thread_bind_irq_wait(struct trs_logic_cq *logic_cq, int timeout) | |||
| 206 | 206 | ||
| 207 | tm = (timeout == -1) ? KA_TASK_MAX_SCHEDULE_TIMEOUT : ka_system_msecs_to_jiffies((u32)timeout); | 207 | tm = (timeout == -1) ? KA_TASK_MAX_SCHEDULE_TIMEOUT : ka_system_msecs_to_jiffies((u32)timeout); |
| 208 | 208 | ||
| 209 | - ret = ka_task_wait_event_interruptible_timeout( | 209 | + ret = ka_task_wait_event_interruptible_timeout(logic_cq->wait_queue, |
| 210 | - logic_cq->wait_queue, (ka_base_atomic_read(&logic_cq->wakeup_num) > 0), tm); | 210 | + (ka_base_atomic_read(&logic_cq->wakeup_num) > 0), tm); |
| 211 | if (ret == 0) { | 211 | if (ret == 0) { |
| 212 | return -ETIMEDOUT; | 212 | return -ETIMEDOUT; |
| 213 | } else if (ret < 0) { | 213 | } else if (ret < 0) { |
| @@ -219,7 +219,10 @@ static int trs_thread_bind_irq_wait(struct trs_logic_cq *logic_cq, int timeout) | |||
| 219 | return 0; | 219 | return 0; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | -static bool trs_logic_cq_is_empty(struct trs_logic_cq *logic_cq) { return (logic_cq->tail == logic_cq->head); } | 222 | +static bool trs_logic_cq_is_empty(struct trs_logic_cq *logic_cq) |
| 223 | +{ | ||
| 224 | + return (logic_cq->tail == logic_cq->head); | ||
| 225 | +} | ||
| 223 | 226 | ||
| 224 | static bool trs_logic_cq_is_full(struct trs_logic_cq *logic_cq) | 227 | static bool trs_logic_cq_is_full(struct trs_logic_cq *logic_cq) |
| 225 | { | 228 | { |
| @@ -254,8 +257,8 @@ static bool trs_logic_is_cqe_match(struct trs_logic_cq *logic_cq, void *cqe, u32 | |||
| 254 | } | 257 | } |
| 255 | } | 258 | } |
| 256 | 259 | ||
| 257 | -static int trs_logic_cq_recv_para_check( | 260 | +static int trs_logic_cq_recv_para_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 258 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halReportRecvInfo *para) | 261 | + struct halReportRecvInfo *para) |
| 259 | { | 262 | { |
| 260 | struct trs_id_inst *inst = &ts_inst->inst; | 263 | struct trs_id_inst *inst = &ts_inst->inst; |
| 261 | 264 | ||
| @@ -265,9 +268,8 @@ static int trs_logic_cq_recv_para_check( | |||
| 265 | } | 268 | } |
| 266 | 269 | ||
| 267 | if (((para->timeout < 0) && (para->timeout != -1)) || (para->cqe_num == 0) || (para->cqe_addr == NULL)) { | 270 | if (((para->timeout < 0) && (para->timeout != -1)) || (para->cqe_num == 0) || (para->cqe_addr == NULL)) { |
| 268 | - trs_err( | 271 | + trs_err("Invalid para. (devid=%u; tsid=%u; logic_cqid=%u; timeout=%d; cqe_num=%u)\n", inst->devid, inst->tsid, |
| 269 | - "Invalid para. (devid=%u; tsid=%u; logic_cqid=%u; timeout=%d; cqe_num=%u)\n", inst->devid, inst->tsid, | 272 | + para->cqId, para->timeout, para->cqe_num); |
| 270 | - para->cqId, para->timeout, para->cqe_num); | ||
| 271 | return -EINVAL; | 273 | return -EINVAL; |
| 272 | } | 274 | } |
| 273 | 275 | ||
| @@ -286,8 +288,8 @@ static void trs_logic_cq_check_report_cqe(u32 cqid, struct trs_logic_cqe *cqe, u | |||
| 286 | } | 288 | } |
| 287 | } | 289 | } |
| 288 | 290 | ||
| 289 | -static u32 trs_logic_cq_get_match_copy_range( | 291 | +static u32 trs_logic_cq_get_match_copy_range(struct trs_logic_cq *logic_cq, struct halReportRecvInfo *para, |
| 290 | - struct trs_logic_cq *logic_cq, struct halReportRecvInfo *para, u32 cqe_start, u32 cqe_end, u32 *num) | 292 | + u32 cqe_start, u32 cqe_end, u32 *num) |
| 291 | { | 293 | { |
| 292 | u32 cqe_cnt, report_cnt, i, pos, search_start, search_num; | 294 | u32 cqe_cnt, report_cnt, i, pos, search_start, search_num; |
| 293 | void *cqe = NULL; | 295 | void *cqe = NULL; |
| @@ -346,9 +348,8 @@ static u32 trs_logic_cq_get_match_copy_range( | |||
| 346 | } | 348 | } |
| 347 | } | 349 | } |
| 348 | 350 | ||
| 349 | - trs_debug( | 351 | + trs_debug("Cmp. (cqid=%u; tid=%d; report_cnt=%u; cqe_num=%u; cqe_cnt=%u, search_start=%u; search_num=%u)\n", |
| 350 | - "Cmp. (cqid=%u; tid=%d; report_cnt=%u; cqe_num=%u; cqe_cnt=%u, search_start=%u; search_num=%u)\n", | 352 | + logic_cq->cqid, ka_task_get_current_pid(), report_cnt, para->cqe_num, cqe_cnt, search_start, search_num); |
| 351 | - logic_cq->cqid, ka_task_get_current_pid(), report_cnt, para->cqe_num, cqe_cnt, search_start, search_num); | ||
| 352 | 353 | ||
| 353 | *num = search_num; | 354 | *num = search_num; |
| 354 | return search_start; | 355 | return search_start; |
| @@ -394,9 +395,8 @@ static void trs_logic_cq_eliminate_holes(struct trs_logic_cq *logic_cq, u32 star | |||
| 394 | { | 395 | { |
| 395 | u32 num, src_pos, dst_pos; | 396 | u32 num, src_pos, dst_pos; |
| 396 | 397 | ||
| 397 | - trs_debug( | 398 | + trs_debug("Eliminate holes. (cqid=%u; start=%u; report_cnt=%u; rollback=%u; head=%u; tail=%u)\n", logic_cq->cqid, |
| 398 | - "Eliminate holes. (cqid=%u; start=%u; report_cnt=%u; rollback=%u; head=%u; tail=%u)\n", logic_cq->cqid, start, | 399 | + start, report_cnt, rollback, logic_cq->head, logic_cq->tail); |
| 399 | - report_cnt, rollback, logic_cq->head, logic_cq->tail); | ||
| 400 | 400 | ||
| 401 | if (rollback == 0) { | 401 | if (rollback == 0) { |
| 402 | num = start - logic_cq->head; | 402 | num = start - logic_cq->head; |
| @@ -434,8 +434,8 @@ static void trs_logic_cq_eliminate_holes(struct trs_logic_cq *logic_cq, u32 star | |||
| 434 | trs_logic_cq_move_cqes(logic_cq, src_pos, dst_pos, num); | 434 | trs_logic_cq_move_cqes(logic_cq, src_pos, dst_pos, num); |
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | -static int trs_logic_cq_match_copy( | 437 | +static int trs_logic_cq_match_copy(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 438 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, struct halReportRecvInfo *para) | 438 | + struct halReportRecvInfo *para) |
| 439 | { | 439 | { |
| 440 | u32 start, report_cnt, tail; | 440 | u32 start, report_cnt, tail; |
| 441 | u32 rollback = 0; | 441 | u32 rollback = 0; |
| @@ -457,9 +457,9 @@ static int trs_logic_cq_match_copy( | |||
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | trs_logic_cq_copy_trace("Logic Cq Recv Match", ts_inst, logic_cq, start, report_cnt); | 459 | trs_logic_cq_copy_trace("Logic Cq Recv Match", ts_inst, logic_cq, start, report_cnt); |
| 460 | - ret = ka_base_copy_to_user( | 460 | + ret = ka_base_copy_to_user((void __ka_user *)para->cqe_addr, |
| 461 | - (void __ka_user *)para->cqe_addr, logic_cq->addr + ((unsigned long)start * logic_cq->cqe_size), | 461 | + logic_cq->addr + ((unsigned long)start * logic_cq->cqe_size), |
| 462 | - (unsigned long)report_cnt * logic_cq->cqe_size); | 462 | + (unsigned long)report_cnt * logic_cq->cqe_size); |
| 463 | if (ret != 0) { | 463 | if (ret != 0) { |
| 464 | trs_err("copy to user fail, cqid=%u report_cnt=%u\n", logic_cq->cqid, report_cnt); | 464 | trs_err("copy to user fail, cqid=%u report_cnt=%u\n", logic_cq->cqid, report_cnt); |
| 465 | return -EFAULT; | 465 | return -EFAULT; |
| @@ -474,8 +474,8 @@ static int trs_logic_cq_match_copy( | |||
| 474 | return 0; | 474 | return 0; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | -static int trs_logic_cq_non_match_copy( | 477 | +static int trs_logic_cq_non_match_copy(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 478 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, struct halReportRecvInfo *para) | 478 | + struct halReportRecvInfo *para) |
| 479 | { | 479 | { |
| 480 | u32 start, report_cnt, tail; | 480 | u32 start, report_cnt, tail; |
| 481 | int ret; | 481 | int ret; |
| @@ -485,9 +485,9 @@ static int trs_logic_cq_non_match_copy( | |||
| 485 | report_cnt = (tail > start) ? tail - start : logic_cq->cq_depth - start; | 485 | report_cnt = (tail > start) ? tail - start : logic_cq->cq_depth - start; |
| 486 | 486 | ||
| 487 | trs_logic_cq_copy_trace("Logic Cq Recv NoMatch", ts_inst, logic_cq, start, report_cnt); | 487 | trs_logic_cq_copy_trace("Logic Cq Recv NoMatch", ts_inst, logic_cq, start, report_cnt); |
| 488 | - ret = ka_base_copy_to_user( | 488 | + ret = ka_base_copy_to_user((void __ka_user *)para->cqe_addr, |
| 489 | - (void __ka_user *)para->cqe_addr, logic_cq->addr + ((unsigned long)start * logic_cq->cqe_size), | 489 | + logic_cq->addr + ((unsigned long)start * logic_cq->cqe_size), |
| 490 | - (unsigned long)report_cnt * logic_cq->cqe_size); | 490 | + (unsigned long)report_cnt * logic_cq->cqe_size); |
| 491 | if (ret != 0) { | 491 | if (ret != 0) { |
| 492 | trs_err("copy to user fail, cqid=%u report_cnt=%u\n", logic_cq->cqid, report_cnt); | 492 | trs_err("copy to user fail, cqid=%u report_cnt=%u\n", logic_cq->cqid, report_cnt); |
| 493 | return -EFAULT; | 493 | return -EFAULT; |
| @@ -498,8 +498,8 @@ static int trs_logic_cq_non_match_copy( | |||
| 498 | return 0; | 498 | return 0; |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | -static int trs_logic_cq_copy_report( | 501 | +static int trs_logic_cq_copy_report(struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, |
| 502 | - struct trs_core_ts_inst *ts_inst, struct trs_logic_cq *logic_cq, struct halReportRecvInfo *para) | 502 | + struct halReportRecvInfo *para) |
| 503 | { | 503 | { |
| 504 | u32 version = para->res[0]; | 504 | u32 version = para->res[0]; |
| 505 | int full_flag = 0; | 505 | int full_flag = 0; |
| @@ -533,9 +533,8 @@ static int trs_logic_cq_copy_report( | |||
| 533 | 533 | ||
| 534 | logic_cq->head = (logic_cq->head + para->report_cqe_num) % logic_cq->cq_depth; | 534 | logic_cq->head = (logic_cq->head + para->report_cqe_num) % logic_cq->cq_depth; |
| 535 | 535 | ||
| 536 | - trs_debug( | 536 | + trs_debug("Recv success. (cqid=%u; tail=%u; head=%u; report_cqe_num=%u; logic_cq_depth=%u)\n", logic_cq->cqid, |
| 537 | - "Recv success. (cqid=%u; tail=%u; head=%u; report_cqe_num=%u; logic_cq_depth=%u)\n", logic_cq->cqid, | 537 | + logic_cq->tail, logic_cq->head, para->report_cqe_num, logic_cq->cq_depth); |
| 538 | - logic_cq->tail, logic_cq->head, para->report_cqe_num, logic_cq->cq_depth); | ||
| 539 | 538 | ||
| 540 | if ((full_flag != 0) && (ts_inst->logic_cq_ctx.phy_cq.chan_id >= 0)) { | 539 | if ((full_flag != 0) && (ts_inst->logic_cq_ctx.phy_cq.chan_id >= 0)) { |
| 541 | (void)trs_chan_ctrl(&ts_inst->inst, ts_inst->logic_cq_ctx.phy_cq.chan_id, CHAN_CTRL_CMD_CQ_SCHED, 0); | 540 | (void)trs_chan_ctrl(&ts_inst->inst, ts_inst->logic_cq_ctx.phy_cq.chan_id, CHAN_CTRL_CMD_CQ_SCHED, 0); |
| @@ -550,9 +549,8 @@ static int trs_logic_cq_wait_event(struct trs_logic_cq *logic_cq, int timeout) | |||
| 550 | long ret, tm; | 549 | long ret, tm; |
| 551 | 550 | ||
| 552 | ka_base_atomic_inc(&logic_cq->wait_thread_num); | 551 | ka_base_atomic_inc(&logic_cq->wait_thread_num); |
| 553 | - trs_debug( | 552 | + trs_debug("Wake wait start. (logic_cqid=%u; timeout=%d; wait_thread_num=%d)\n", logic_cq->cqid, timeout, |
| 554 | - "Wake wait start. (logic_cqid=%u; timeout=%d; wait_thread_num=%d)\n", logic_cq->cqid, timeout, | 553 | + ka_base_atomic_read(&logic_cq->wait_thread_num)); |
| 555 | - ka_base_atomic_read(&logic_cq->wait_thread_num)); | ||
| 556 | 554 | ||
| 557 | tm = (timeout == -1) ? KA_TASK_MAX_SCHEDULE_TIMEOUT : ka_system_msecs_to_jiffies((u32)timeout); | 555 | tm = (timeout == -1) ? KA_TASK_MAX_SCHEDULE_TIMEOUT : ka_system_msecs_to_jiffies((u32)timeout); |
| 558 | (void)ka_task_prepare_to_wait_exclusive(&logic_cq->wait_queue, &wq_entry, KA_TASK_INTERRUPTIBLE); | 556 | (void)ka_task_prepare_to_wait_exclusive(&logic_cq->wait_queue, &wq_entry, KA_TASK_INTERRUPTIBLE); |
| @@ -568,9 +566,8 @@ static int trs_logic_cq_wait_event(struct trs_logic_cq *logic_cq, int timeout) | |||
| 568 | ka_task_finish_wait(&logic_cq->wait_queue, &wq_entry); | 566 | ka_task_finish_wait(&logic_cq->wait_queue, &wq_entry); |
| 569 | 567 | ||
| 570 | ka_base_atomic_dec(&logic_cq->wait_thread_num); | 568 | ka_base_atomic_dec(&logic_cq->wait_thread_num); |
| 571 | - trs_debug( | 569 | + trs_debug("Wake wait finish. (logic_cqid=%u; timeout=%d; wait_thread_num=%d; ret=%ld)\n", logic_cq->cqid, timeout, |
| 572 | - "Wake wait finish. (logic_cqid=%u; timeout=%d; wait_thread_num=%d; ret=%ld)\n", logic_cq->cqid, timeout, | 570 | + ka_base_atomic_read(&logic_cq->wait_thread_num), ret); |
| 573 | - ka_base_atomic_read(&logic_cq->wait_thread_num), ret); | ||
| 574 | 571 | ||
| 575 | if (ret == 0) { | 572 | if (ret == 0) { |
| 576 | /* wait event timeout */ | 573 | /* wait event timeout */ |
| @@ -685,18 +682,16 @@ int trs_logic_cq_enque(struct trs_core_ts_inst *ts_inst, u32 logic_cq_id, u32 st | |||
| 685 | ka_task_spin_lock_bh(&logic_cq->lock); | 682 | ka_task_spin_lock_bh(&logic_cq->lock); |
| 686 | if (logic_cq->valid == 0) { | 683 | if (logic_cq->valid == 0) { |
| 687 | ka_task_spin_unlock_bh(&logic_cq->lock); | 684 | ka_task_spin_unlock_bh(&logic_cq->lock); |
| 688 | - trs_debug( | 685 | + trs_debug("Invalid logic cq drop. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u)\n", inst->devid, |
| 689 | - "Invalid logic cq drop. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u)\n", inst->devid, | 686 | + inst->tsid, logic_cq_id, stream_id, task_id); |
| 690 | - inst->tsid, logic_cq_id, stream_id, task_id); | ||
| 691 | return -EINVAL; | 687 | return -EINVAL; |
| 692 | } | 688 | } |
| 693 | 689 | ||
| 694 | if (trs_logic_cq_is_full(logic_cq)) { | 690 | if (trs_logic_cq_is_full(logic_cq)) { |
| 695 | ka_task_spin_unlock_bh(&logic_cq->lock); | 691 | ka_task_spin_unlock_bh(&logic_cq->lock); |
| 696 | logic_cq->stat.full_drop++; | 692 | logic_cq->stat.full_drop++; |
| 697 | - trs_debug( | 693 | + trs_debug("Full drop. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u)\n", inst->devid, inst->tsid, |
| 698 | - "Full drop. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u)\n", inst->devid, inst->tsid, | 694 | + logic_cq_id, stream_id, task_id); |
| 699 | - logic_cq_id, stream_id, task_id); | ||
| 700 | return -EAGAIN; /* block recv */ | 695 | return -EAGAIN; /* block recv */ |
| 701 | } | 696 | } |
| 702 | 697 | ||
| @@ -706,9 +701,8 @@ int trs_logic_cq_enque(struct trs_core_ts_inst *ts_inst, u32 logic_cq_id, u32 st | |||
| 706 | logic_cq->tail = (logic_cq->tail + 1) % logic_cq->cq_depth; | 701 | logic_cq->tail = (logic_cq->tail + 1) % logic_cq->cq_depth; |
| 707 | ka_task_spin_unlock_bh(&logic_cq->lock); | 702 | ka_task_spin_unlock_bh(&logic_cq->lock); |
| 708 | 703 | ||
| 709 | - trs_debug( | 704 | + trs_debug("Enque. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u; tail=%u)\n", inst->devid, inst->tsid, |
| 710 | - "Enque. (devid=%u; tsid=%u; logic_cqid=%u; stream_id=%u; task_id=%u; tail=%u)\n", inst->devid, inst->tsid, | 705 | + logic_cq_id, stream_id, task_id, logic_cq->tail); |
| 711 | - logic_cq_id, stream_id, task_id, logic_cq->tail); | ||
| 712 | 706 | ||
| 713 | ka_smp_wmb(); | 707 | ka_smp_wmb(); |
| 714 | trs_logic_cq_enque_trace(ts_inst, logic_cq, stream_id, task_id, cqe); | 708 | trs_logic_cq_enque_trace(ts_inst, logic_cq, stream_id, task_id, cqe); |
| @@ -725,9 +719,8 @@ static int trs_logic_phy_cq_recv_proc(struct trs_core_ts_inst *ts_inst, u32 cqid | |||
| 725 | int ret; | 719 | int ret; |
| 726 | 720 | ||
| 727 | if (logic_cq_ctx->phy_cq.cqid != cqid) { | 721 | if (logic_cq_ctx->phy_cq.cqid != cqid) { |
| 728 | - trs_err( | 722 | + trs_err("Not logic phy cqid. (devid=%u; tsid=%u; cqid=%u; logic_cqid=%u)\n", inst->devid, inst->tsid, cqid, |
| 729 | - "Not logic phy cqid. (devid=%u; tsid=%u; cqid=%u; logic_cqid=%u)\n", inst->devid, inst->tsid, cqid, | 723 | + logic_cq_ctx->phy_cq.cqid); |
| 730 | - logic_cq_ctx->phy_cq.cqid); | ||
| 731 | return CQ_RECV_FINISH; | 724 | return CQ_RECV_FINISH; |
| 732 | } | 725 | } |
| 733 | 726 | ||
| @@ -799,9 +792,8 @@ static int trs_logic_alloc_phy_cq(struct trs_core_ts_inst *ts_inst) | |||
| 799 | phy_cq->cq_irq = cq_info.irq; | 792 | phy_cq->cq_irq = cq_info.irq; |
| 800 | phy_cq->cq_phy_addr = cq_info.cq_phy_addr; | 793 | phy_cq->cq_phy_addr = cq_info.cq_phy_addr; |
| 801 | 794 | ||
| 802 | - trs_info( | 795 | + trs_info("Alloc phy cq success. (devid=%u; tsid=%u; chan_id=%d; cqid=%u)\n", inst->devid, inst->tsid, |
| 803 | - "Alloc phy cq success. (devid=%u; tsid=%u; chan_id=%d; cqid=%u)\n", inst->devid, inst->tsid, phy_cq->chan_id, | 796 | + phy_cq->chan_id, phy_cq->cqid); |
| 804 | - phy_cq->cqid); | ||
| 805 | 797 | ||
| 806 | return 0; | 798 | return 0; |
| 807 | } | 799 | } |
| @@ -811,15 +803,14 @@ static void trs_logic_free_phy_cq(struct trs_core_ts_inst *ts_inst) | |||
| 811 | struct trs_logic_phy_cq *phy_cq = &ts_inst->logic_cq_ctx.phy_cq; | 803 | struct trs_logic_phy_cq *phy_cq = &ts_inst->logic_cq_ctx.phy_cq; |
| 812 | struct trs_id_inst *inst = &ts_inst->inst; | 804 | struct trs_id_inst *inst = &ts_inst->inst; |
| 813 | 805 | ||
| 814 | - trs_info( | 806 | + trs_info("Free phy cq success. (devid=%u; tsid=%u; chan_id=%d; cqid=%u)\n", inst->devid, inst->tsid, |
| 815 | - "Free phy cq success. (devid=%u; tsid=%u; chan_id=%d; cqid=%u)\n", inst->devid, inst->tsid, phy_cq->chan_id, | 807 | + phy_cq->chan_id, phy_cq->cqid); |
| 816 | - phy_cq->cqid); | ||
| 817 | hal_kernel_trs_chan_destroy(&ts_inst->inst, phy_cq->chan_id); | 808 | hal_kernel_trs_chan_destroy(&ts_inst->inst, phy_cq->chan_id); |
| 818 | phy_cq->chan_id = -1; | 809 | phy_cq->chan_id = -1; |
| 819 | } | 810 | } |
| 820 | 811 | ||
| 821 | -static int trs_logic_cq_id_init( | 812 | +static int trs_logic_cq_id_init(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 822 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 813 | + struct halSqCqInputInfo *para) |
| 823 | { | 814 | { |
| 824 | struct trs_id_inst *inst = &ts_inst->inst; | 815 | struct trs_id_inst *inst = &ts_inst->inst; |
| 825 | struct trs_logic_cq *logic_cq = NULL; | 816 | struct trs_logic_cq *logic_cq = NULL; |
| @@ -845,17 +836,16 @@ static int trs_logic_cq_id_init( | |||
| 845 | if ((para->flag & TSDRV_FLAG_THREAD_BIND_IRQ) != 0) { | 836 | if ((para->flag & TSDRV_FLAG_THREAD_BIND_IRQ) != 0) { |
| 846 | /* thread bind irq num in proc needn't be precise, so not use lock */ | 837 | /* thread bind irq num in proc needn't be precise, so not use lock */ |
| 847 | if (ka_base_atomic_read(&proc_ctx->ts_ctx[inst->tsid].thread_bind_irq_num) < TRS_PROC_MAX_THREAD_BIND_IRQ_NUM) { | 838 | if (ka_base_atomic_read(&proc_ctx->ts_ctx[inst->tsid].thread_bind_irq_num) < TRS_PROC_MAX_THREAD_BIND_IRQ_NUM) { |
| 848 | - logic_cq->thread_bind_irq = | 839 | + logic_cq->thread_bind_irq = trs_thread_bind_irq_alloc(ts_inst, &logic_cq->wakeup_num, |
| 849 | - trs_thread_bind_irq_alloc(ts_inst, &logic_cq->wakeup_num, &logic_cq->wait_queue); | 840 | + &logic_cq->wait_queue); |
| 850 | } | 841 | } |
| 851 | 842 | ||
| 852 | if (logic_cq->thread_bind_irq < 0) { | 843 | if (logic_cq->thread_bind_irq < 0) { |
| 853 | para->flag &= ~TSDRV_FLAG_THREAD_BIND_IRQ; | 844 | para->flag &= ~TSDRV_FLAG_THREAD_BIND_IRQ; |
| 854 | } else { | 845 | } else { |
| 855 | ka_base_atomic_inc(&proc_ctx->ts_ctx[inst->tsid].thread_bind_irq_num); | 846 | ka_base_atomic_inc(&proc_ctx->ts_ctx[inst->tsid].thread_bind_irq_num); |
| 856 | - trs_info( | 847 | + trs_info("Alloc thread bind irq. (devid=%u; tsid=%u; cqId=%u; thread_bind_irq=%u)\n", inst->devid, |
| 857 | - "Alloc thread bind irq. (devid=%u; tsid=%u; cqId=%u; thread_bind_irq=%u)\n", inst->devid, inst->tsid, | 848 | + inst->tsid, para->cqId, logic_cq->thread_bind_irq); |
| 858 | - para->cqId, logic_cq->thread_bind_irq); | ||
| 859 | } | 849 | } |
| 860 | } | 850 | } |
| 861 | 851 | ||
| @@ -892,9 +882,8 @@ static void trs_logic_cq_id_uninit(struct trs_proc_ctx *proc_ctx, struct trs_cor | |||
| 892 | if (logic_cq->thread_bind_irq >= 0) { | 882 | if (logic_cq->thread_bind_irq >= 0) { |
| 893 | ka_base_atomic_dec(&proc_ctx->ts_ctx[ts_inst->inst.tsid].thread_bind_irq_num); | 883 | ka_base_atomic_dec(&proc_ctx->ts_ctx[ts_inst->inst.tsid].thread_bind_irq_num); |
| 894 | trs_thread_bind_irq_free(ts_inst, logic_cq->thread_bind_irq); | 884 | trs_thread_bind_irq_free(ts_inst, logic_cq->thread_bind_irq); |
| 895 | - trs_info( | 885 | + trs_info("Free thread bind irq. (devid=%u; tsid=%u; cqId=%u; thread_bind_irq=%u)\n", inst->devid, inst->tsid, |
| 896 | - "Free thread bind irq. (devid=%u; tsid=%u; cqId=%u; thread_bind_irq=%u)\n", inst->devid, inst->tsid, cqid, | 886 | + cqid, logic_cq->thread_bind_irq); |
| 897 | - logic_cq->thread_bind_irq); | ||
| 898 | } | 887 | } |
| 899 | ts_inst->ops.cq_mem_free(inst, logic_cq->addr, logic_cq->cq_depth * logic_cq->cqe_size); | 888 | ts_inst->ops.cq_mem_free(inst, logic_cq->addr, logic_cq->cq_depth * logic_cq->cqe_size); |
| 900 | logic_cq->addr = NULL; | 889 | logic_cq->addr = NULL; |
| @@ -902,8 +891,8 @@ static void trs_logic_cq_id_uninit(struct trs_proc_ctx *proc_ctx, struct trs_cor | |||
| 902 | ka_task_mutex_unlock(&logic_cq->mutex); | 891 | ka_task_mutex_unlock(&logic_cq->mutex); |
| 903 | } | 892 | } |
| 904 | 893 | ||
| 905 | -static int trs_logic_cq_alloc_notice_ts( | 894 | +static int trs_logic_cq_alloc_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 906 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 895 | + struct halSqCqInputInfo *para) |
| 907 | { | 896 | { |
| 908 | struct trs_logic_phy_cq *phy_cq = &ts_inst->logic_cq_ctx.phy_cq; | 897 | struct trs_logic_phy_cq *phy_cq = &ts_inst->logic_cq_ctx.phy_cq; |
| 909 | struct trs_logic_cq *logic_cq = &ts_inst->logic_cq_ctx.cq[para->cqId]; | 898 | struct trs_logic_cq *logic_cq = &ts_inst->logic_cq_ctx.cq[para->cqId]; |
| @@ -962,9 +951,8 @@ int trs_logic_cq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 962 | 951 | ||
| 963 | ret = trs_logic_cq_alloc_para_check(ts_inst, para); | 952 | ret = trs_logic_cq_alloc_para_check(ts_inst, para); |
| 964 | if (ret != 0) { | 953 | if (ret != 0) { |
| 965 | - trs_err( | 954 | + trs_err("Invalid para. (devid=%u; tsid=%u; cqeDepth=%u; cqeSize=%u)\n", inst->devid, inst->tsid, para->cqeDepth, |
| 966 | - "Invalid para. (devid=%u; tsid=%u; cqeDepth=%u; cqeSize=%u)\n", inst->devid, inst->tsid, para->cqeDepth, | 955 | + para->cqeSize); |
| 967 | - para->cqeSize); | ||
| 968 | return ret; | 956 | return ret; |
| 969 | } | 957 | } |
| 970 | 958 | ||
| @@ -1003,9 +991,8 @@ int trs_logic_cq_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 1003 | } | 991 | } |
| 1004 | } | 992 | } |
| 1005 | 993 | ||
| 1006 | - trs_debug( | 994 | + trs_debug("Logic cq alloc. (devid=%u; tsid=%u; flag=0x%x; logic_cqid=%u)\n", inst->devid, inst->tsid, para->flag, |
| 1007 | - "Logic cq alloc. (devid=%u; tsid=%u; flag=0x%x; logic_cqid=%u)\n", inst->devid, inst->tsid, para->flag, | 995 | + para->cqId); |
| 1008 | - para->cqId); | ||
| 1009 | 996 | ||
| 1010 | return 0; | 997 | return 0; |
| 1011 | } | 998 | } |
| @@ -1087,9 +1074,8 @@ int trs_logic_cq_get(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 1087 | 1074 | ||
| 1088 | logic_cqid = stm_ctx.logic_cq; | 1075 | logic_cqid = stm_ctx.logic_cq; |
| 1089 | if ((logic_cqid < 0) || ((u32)logic_cqid > trs_res_get_max_id(ts_inst, TRS_LOGIC_CQ))) { | 1076 | if ((logic_cqid < 0) || ((u32)logic_cqid > trs_res_get_max_id(ts_inst, TRS_LOGIC_CQ))) { |
| 1090 | - trs_err( | 1077 | + trs_err("Stream no logic cq. (devid=%u; tsid=%u; stream_id=%u; logic_cqid=%d)\n", inst->devid, inst->tsid, |
| 1091 | - "Stream no logic cq. (devid=%u; tsid=%u; stream_id=%u; logic_cqid=%d)\n", inst->devid, inst->tsid, | 1078 | + stream_id, logic_cqid); |
| 1092 | - stream_id, logic_cqid); | ||
| 1093 | return -EINVAL; | 1079 | return -EINVAL; |
| 1094 | } | 1080 | } |
| 1095 | 1081 | ||
| @@ -1097,9 +1083,8 @@ int trs_logic_cq_get(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 1097 | para->cqeDepth = ts_inst->logic_cq_ctx.cq[stm_ctx.logic_cq].cq_depth; | 1083 | para->cqeDepth = ts_inst->logic_cq_ctx.cq[stm_ctx.logic_cq].cq_depth; |
| 1098 | para->cqeSize = ts_inst->logic_cq_ctx.cq[stm_ctx.logic_cq].cqe_size; | 1084 | para->cqeSize = ts_inst->logic_cq_ctx.cq[stm_ctx.logic_cq].cqe_size; |
| 1099 | 1085 | ||
| 1100 | - trs_debug( | 1086 | + trs_debug("Share logic cq info. (devid=%u; streamid=%u; logic_cqid=%u; cq_depth=%u; cqe_size=%u)\n", |
| 1101 | - "Share logic cq info. (devid=%u; streamid=%u; logic_cqid=%u; cq_depth=%u; cqe_size=%u)\n", proc_ctx->devid, | 1087 | + proc_ctx->devid, stream_id, para->cqId, para->cqeDepth, para->cqeSize); |
| 1102 | - stream_id, para->cqId, para->cqeDepth, para->cqeSize); | ||
| 1103 | 1088 | ||
| 1104 | return 0; | 1089 | return 0; |
| 1105 | } | 1090 | } |
| @@ -1117,9 +1102,8 @@ int trs_logic_cq_init(struct trs_core_ts_inst *ts_inst) | |||
| 1117 | 1102 | ||
| 1118 | cq_ctx->cq = (struct trs_logic_cq *)trs_vzalloc(sizeof(struct trs_logic_cq) * max_id); | 1103 | cq_ctx->cq = (struct trs_logic_cq *)trs_vzalloc(sizeof(struct trs_logic_cq) * max_id); |
| 1119 | if (cq_ctx->cq == NULL) { | 1104 | if (cq_ctx->cq == NULL) { |
| 1120 | - trs_err( | 1105 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 1121 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 1106 | + sizeof(struct trs_logic_cq) * max_id); |
| 1122 | - sizeof(struct trs_logic_cq) * max_id); | ||
| 1123 | return -ENOMEM; | 1107 | return -ENOMEM; |
| 1124 | } | 1108 | } |
| 1125 | 1109 | ||
| @@ -98,7 +98,7 @@ int trs_logic_cq_get(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 98 | 98 | ||
| 99 | int trs_logic_cq_init(struct trs_core_ts_inst *ts_inst); | 99 | int trs_logic_cq_init(struct trs_core_ts_inst *ts_inst); |
| 100 | void trs_logic_cq_uninit(struct trs_core_ts_inst *ts_inst); | 100 | void trs_logic_cq_uninit(struct trs_core_ts_inst *ts_inst); |
| 101 | -int trs_logic_cq_config( | 101 | +int trs_logic_cq_config(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 102 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqConfigInfo *para); | 102 | + struct halSqCqConfigInfo *para); |
| 103 | 103 | ||
| 104 | 104 | ||
| @@ -40,9 +40,8 @@ static bool trs_is_res_pid_match(struct trs_core_ts_inst *ts_inst, int pid, s64 | |||
| 40 | bool ret = false; | 40 | bool ret = false; |
| 41 | 41 | ||
| 42 | if (res_id >= res_mng->max_id) { | 42 | if (res_id >= res_mng->max_id) { |
| 43 | - trs_err( | 43 | + trs_err("Invalid id. (devid=%u; tsid=%u; res_type=%d; id=%u; max_num=%u)\n", ts_inst->inst.devid, |
| 44 | - "Invalid id. (devid=%u; tsid=%u; res_type=%d; id=%u; max_num=%u)\n", ts_inst->inst.devid, | 44 | + ts_inst->inst.tsid, res_type, res_id, res_mng->max_id); |
| 45 | - ts_inst->inst.tsid, res_type, res_id, res_mng->max_id); | ||
| 46 | return false; | 45 | return false; |
| 47 | } | 46 | } |
| 48 | 47 | ||
| @@ -52,11 +51,10 @@ static bool trs_is_res_pid_match(struct trs_core_ts_inst *ts_inst, int pid, s64 | |||
| 52 | * Do not change log level. | 51 | * Do not change log level. |
| 53 | * Shr id will check ipc notify is opened by this proc. | 52 | * Shr id will check ipc notify is opened by this proc. |
| 54 | */ | 53 | */ |
| 55 | - trs_debug( | 54 | + trs_debug("Match failed. (devid=%u; tsid=%u; res_type=%d; res_id=%u; id_pid=%d; pid=%u; " |
| 56 | - "Match failed. (devid=%u; tsid=%u; res_type=%d; res_id=%u; id_pid=%d; pid=%u; " | 55 | + "id_task_id=%lld; task_id=%lld; id_status=%u)\n", |
| 57 | - "id_task_id=%lld; task_id=%lld; id_status=%u)\n", | 56 | + ts_inst->inst.devid, ts_inst->inst.tsid, res_type, res_id, res_mng->ids[res_id].pid, pid, |
| 58 | - ts_inst->inst.devid, ts_inst->inst.tsid, res_type, res_id, res_mng->ids[res_id].pid, pid, | 57 | + res_mng->ids[res_id].task_id, task_id, res_mng->ids[res_id].status); |
| 59 | - res_mng->ids[res_id].task_id, task_id, res_mng->ids[res_id].status); | ||
| 60 | } | 58 | } |
| 61 | return ret; | 59 | return ret; |
| 62 | } | 60 | } |
| @@ -170,9 +168,8 @@ int trs_res_put(struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id) | |||
| 170 | 168 | ||
| 171 | ka_task_mutex_lock(&res_mng->mutex); | 169 | ka_task_mutex_lock(&res_mng->mutex); |
| 172 | if (res_mng->ids[res_id].ref == 0) { | 170 | if (res_mng->ids[res_id].ref == 0) { |
| 173 | - trs_err( | 171 | + trs_err("Res not valid. (devid=%u; tsid=%u; res_type=%d; id=%u)\n", ts_inst->inst.devid, ts_inst->inst.tsid, |
| 174 | - "Res not valid. (devid=%u; tsid=%u; res_type=%d; id=%u)\n", ts_inst->inst.devid, ts_inst->inst.tsid, | 172 | + res_type, res_id); |
| 175 | - res_type, res_id); | ||
| 176 | ka_task_mutex_unlock(&res_mng->mutex); | 173 | ka_task_mutex_unlock(&res_mng->mutex); |
| 177 | return -EINVAL; | 174 | return -EINVAL; |
| 178 | } | 175 | } |
| @@ -188,25 +185,23 @@ int trs_res_put(struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id) | |||
| 188 | return ref; | 185 | return ref; |
| 189 | } | 186 | } |
| 190 | 187 | ||
| 191 | -static int _trs_proc_add_res( | 188 | +static int _trs_proc_add_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, |
| 192 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, bool is_agent_res) | 189 | + bool is_agent_res) |
| 193 | { | 190 | { |
| 194 | struct trs_res_mng *res_mng = &ts_inst->res_mng[res_type]; | 191 | struct trs_res_mng *res_mng = &ts_inst->res_mng[res_type]; |
| 195 | struct trs_id_inst *inst = &ts_inst->inst; | 192 | struct trs_id_inst *inst = &ts_inst->inst; |
| 196 | 193 | ||
| 197 | if (res_id >= res_mng->max_id) { | 194 | if (res_id >= res_mng->max_id) { |
| 198 | - trs_err( | 195 | + trs_err("Invalid id. (devid=%u; tsid=%u; res_type=%d; id=%u; max_num=%u)\n", inst->devid, inst->tsid, res_type, |
| 199 | - "Invalid id. (devid=%u; tsid=%u; res_type=%d; id=%u; max_num=%u)\n", inst->devid, inst->tsid, res_type, | 196 | + res_id, res_mng->max_id); |
| 200 | - res_id, res_mng->max_id); | ||
| 201 | return -EINVAL; | 197 | return -EINVAL; |
| 202 | } | 198 | } |
| 203 | 199 | ||
| 204 | ka_task_mutex_lock(&res_mng->mutex); | 200 | ka_task_mutex_lock(&res_mng->mutex); |
| 205 | if (res_mng->ids[res_id].pid != 0) { | 201 | if (res_mng->ids[res_id].pid != 0) { |
| 206 | 202 | ||
| 207 | - trs_err( | 203 | + trs_err("Repeat add res. (devid=%u; tsid=%u; res_type=%d; id=%u; owner_pid=%u)\n", inst->devid, inst->tsid, |
| 208 | - "Repeat add res. (devid=%u; tsid=%u; res_type=%d; id=%u; owner_pid=%u)\n", inst->devid, inst->tsid, | 204 | + res_type, res_id, res_mng->ids[res_id].pid); |
| 209 | - res_type, res_id, res_mng->ids[res_id].pid); | ||
| 210 | ka_task_mutex_unlock(&res_mng->mutex); | 205 | ka_task_mutex_unlock(&res_mng->mutex); |
| 211 | return -EINVAL; | 206 | return -EINVAL; |
| 212 | 207 | ||
| @@ -220,9 +215,8 @@ static int _trs_proc_add_res( | |||
| 220 | res_mng->use_num++; | 215 | res_mng->use_num++; |
| 221 | ka_task_mutex_unlock(&res_mng->mutex); | 216 | ka_task_mutex_unlock(&res_mng->mutex); |
| 222 | 217 | ||
| 223 | - trs_debug( | 218 | + trs_debug("Add res. (devid=%u; tsid=%u; res_type=%d; id=%u; owner_pid=%u)\n", inst->devid, inst->tsid, res_type, |
| 224 | - "Add res. (devid=%u; tsid=%u; res_type=%d; id=%u; owner_pid=%u)\n", inst->devid, inst->tsid, res_type, res_id, | 219 | + res_id, res_mng->ids[res_id].pid); |
| 225 | - res_mng->ids[res_id].pid); | ||
| 226 | 220 | ||
| 227 | ka_base_atomic_inc(&proc_ctx->ts_ctx[inst->tsid].current_id_num[res_type]); | 221 | ka_base_atomic_inc(&proc_ctx->ts_ctx[inst->tsid].current_id_num[res_type]); |
| 228 | if (is_agent_res) { | 222 | if (is_agent_res) { |
| @@ -237,8 +231,8 @@ int trs_proc_add_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 237 | return _trs_proc_add_res(proc_ctx, ts_inst, res_type, res_id, false); | 231 | return _trs_proc_add_res(proc_ctx, ts_inst, res_type, res_id, false); |
| 238 | } | 232 | } |
| 239 | 233 | ||
| 240 | -int trs_proc_add_res_ex( | 234 | +int trs_proc_add_res_ex(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, |
| 241 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, bool is_agent_res) | 235 | + bool is_agent_res) |
| 242 | { | 236 | { |
| 243 | return _trs_proc_add_res(proc_ctx, ts_inst, res_type, res_id, is_agent_res); | 237 | return _trs_proc_add_res(proc_ctx, ts_inst, res_type, res_id, is_agent_res); |
| 244 | } | 238 | } |
| @@ -252,9 +246,8 @@ bool trs_is_proc_res_limited(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_i | |||
| 252 | ka_task_mutex_lock(&res_mng->mutex); | 246 | ka_task_mutex_lock(&res_mng->mutex); |
| 253 | if ((res_mng->id_num - res_mng->use_num) < ts_inst->support_proc_num) { | 247 | if ((res_mng->id_num - res_mng->use_num) < ts_inst->support_proc_num) { |
| 254 | if (trs_get_proc_res_num(proc_ctx, inst->tsid, res_type) > 0) { | 248 | if (trs_get_proc_res_num(proc_ctx, inst->tsid, res_type) > 0) { |
| 255 | - trs_warn( | 249 | + trs_warn("Proc res limited. (devid=%u; tsid=%u; res_type=%d; id_num=%u; use_num=%u; support_proc_num=%u)\n", |
| 256 | - "Proc res limited. (devid=%u; tsid=%u; res_type=%d; id_num=%u; use_num=%u; support_proc_num=%u)\n", | 250 | + inst->devid, inst->tsid, res_type, res_mng->id_num, res_mng->use_num, ts_inst->support_proc_num); |
| 257 | - inst->devid, inst->tsid, res_type, res_mng->id_num, res_mng->use_num, ts_inst->support_proc_num); | ||
| 258 | flag = true; | 251 | flag = true; |
| 259 | } | 252 | } |
| 260 | } | 253 | } |
| @@ -280,9 +273,8 @@ int trs_proc_del_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 280 | ret = trs_res_id_pre_del(proc_ctx, ts_inst, res_type, res_id); | 273 | ret = trs_res_id_pre_del(proc_ctx, ts_inst, res_type, res_id); |
| 281 | if (ret != 0) { | 274 | if (ret != 0) { |
| 282 | ka_task_mutex_unlock(&res_mng->mutex); | 275 | ka_task_mutex_unlock(&res_mng->mutex); |
| 283 | - trs_err( | 276 | + trs_err("Failed to check. (ret=%d; devid=%u; tsid=%u; res_type=%d; id=%d)\n", ret, inst->devid, inst->tsid, |
| 284 | - "Failed to check. (ret=%d; devid=%u; tsid=%u; res_type=%d; id=%d)\n", ret, inst->devid, inst->tsid, | 277 | + res_type, res_id); |
| 285 | - res_type, res_id); | ||
| 286 | return ret; | 278 | return ret; |
| 287 | } | 279 | } |
| 288 | 280 | ||
| @@ -358,7 +350,10 @@ static struct trs_proc_ctx *trs_proc_ctx_get(struct trs_core_ts_inst *ts_inst, i | |||
| 358 | } | 350 | } |
| 359 | 351 | ||
| 360 | void trs_proc_ctx_destroy(struct kref_safe *kref); | 352 | void trs_proc_ctx_destroy(struct kref_safe *kref); |
| 361 | -void trs_proc_ctx_put(struct trs_proc_ctx *proc_ctx) { kref_safe_put(&proc_ctx->ref, trs_proc_ctx_destroy); } | 353 | +void trs_proc_ctx_put(struct trs_proc_ctx *proc_ctx) |
| 354 | +{ | ||
| 355 | + kref_safe_put(&proc_ctx->ref, trs_proc_ctx_destroy); | ||
| 356 | +} | ||
| 362 | 357 | ||
| 363 | struct trs_proc_ctx *trs_get_share_ctx(struct trs_core_ts_inst *ts_inst, u32 share_pid) | 358 | struct trs_proc_ctx *trs_get_share_ctx(struct trs_core_ts_inst *ts_inst, u32 share_pid) |
| 364 | { | 359 | { |
| @@ -403,9 +398,8 @@ struct trs_proc_ctx *trs_proc_ctx_create(struct trs_core_ts_inst *all_ts_inst[], | |||
| 403 | proc_ctx->task_id = ka_base_atomic64_inc_return(&ts_inst->cur_task_id); | 398 | proc_ctx->task_id = ka_base_atomic64_inc_return(&ts_inst->cur_task_id); |
| 404 | proc_ctx->pid = ka_task_get_current_tgid(); | 399 | proc_ctx->pid = ka_task_get_current_tgid(); |
| 405 | proc_ctx->release_type = TRS_PROC_RELEASE_LOCAL_REMOTE; | 400 | proc_ctx->release_type = TRS_PROC_RELEASE_LOCAL_REMOTE; |
| 406 | - if (strncpy_s( | 401 | + if (strncpy_s(proc_ctx->name, TASK_COMM_LEN, ka_task_get_current_comm(), |
| 407 | - proc_ctx->name, TASK_COMM_LEN, ka_task_get_current_comm(), ka_base_strlen(ka_task_get_current_comm())) != | 402 | + ka_base_strlen(ka_task_get_current_comm())) != 0) { |
| 408 | - 0) { | ||
| 409 | 403 | ||
| 410 | trs_warn("Strcpy warn. (pid=%d)\n", proc_ctx->pid); | 404 | trs_warn("Strcpy warn. (pid=%d)\n", proc_ctx->pid); |
| 411 | 405 | ||
| @@ -460,10 +454,9 @@ static int trs_check_va_range(ka_vm_area_struct_t *vma, unsigned long addr, unsi | |||
| 460 | if (((addr & (KA_MM_PAGE_SIZE - 1)) != 0) || (addr < ka_mm_get_vm_start(vma)) || (addr > ka_mm_get_vm_end(vma)) || | 454 | if (((addr & (KA_MM_PAGE_SIZE - 1)) != 0) || (addr < ka_mm_get_vm_start(vma)) || (addr > ka_mm_get_vm_end(vma)) || |
| 461 | (end > ka_mm_get_vm_end(vma)) || (addr >= end)) { | 455 | (end > ka_mm_get_vm_end(vma)) || (addr >= end)) { |
| 462 | 456 | ||
| 463 | - trs_err( | 457 | + trs_err("Invalid para. (addr=%pK; size=0x%lx; end=%pK; vm_start=%pK; vm_end=%pK)\n", (void *)(uintptr_t)addr, |
| 464 | - "Invalid para. (addr=%pK; size=0x%lx; end=%pK; vm_start=%pK; vm_end=%pK)\n", (void *)(uintptr_t)addr, size, | 458 | + size, (void *)(uintptr_t)end, (void *)(uintptr_t)ka_mm_get_vm_start(vma), |
| 465 | - (void *)(uintptr_t)end, (void *)(uintptr_t)ka_mm_get_vm_start(vma), | 459 | + (void *)(uintptr_t)ka_mm_get_vm_end(vma)); |
| 466 | - (void *)(uintptr_t)ka_mm_get_vm_end(vma)); | ||
| 467 | 460 | ||
| 468 | return -EINVAL; | 461 | return -EINVAL; |
| 469 | } | 462 | } |
| @@ -478,9 +471,8 @@ static int trs_check_va_map(ka_vm_area_struct_t *vma, unsigned long addr, unsign | |||
| 478 | 471 | ||
| 479 | for (va_check = addr; va_check < end; va_check += KA_MM_PAGE_SIZE) { | 472 | for (va_check = addr; va_check < end; va_check += KA_MM_PAGE_SIZE) { |
| 480 | if (ka_mm_follow_pfn(vma, va_check, &pfn) == 0) { | 473 | if (ka_mm_follow_pfn(vma, va_check, &pfn) == 0) { |
| 481 | - trs_err( | 474 | + trs_err("Check va is map. (addr=0x%pK; size=0x%lx; va_check=0x%pK)\n", (void *)(uintptr_t)addr, size, |
| 482 | - "Check va is map. (addr=0x%pK; size=0x%lx; va_check=0x%pK)\n", (void *)(uintptr_t)addr, size, | 475 | + (void *)(uintptr_t)va_check); |
| 483 | - (void *)(uintptr_t)va_check); | ||
| 484 | return -EINVAL; | 476 | return -EINVAL; |
| 485 | } | 477 | } |
| 486 | } | 478 | } |
| @@ -495,9 +487,8 @@ static int trs_check_va_unmap(ka_vm_area_struct_t *vma, unsigned long addr, unsi | |||
| 495 | 487 | ||
| 496 | for (va_check = addr; va_check < end; va_check += KA_MM_PAGE_SIZE) { | 488 | for (va_check = addr; va_check < end; va_check += KA_MM_PAGE_SIZE) { |
| 497 | if (ka_mm_follow_pfn(vma, va_check, &pfn) != 0) { | 489 | if (ka_mm_follow_pfn(vma, va_check, &pfn) != 0) { |
| 498 | - trs_err( | 490 | + trs_err("Check va is unmap. (addr=0x%pK; size=0x%lx; va_check=0x%pK)\n", (void *)(uintptr_t)addr, size, |
| 499 | - "Check va is unmap. (addr=0x%pK; size=0x%lx; va_check=0x%pK)\n", (void *)(uintptr_t)addr, size, | 491 | + (void *)(uintptr_t)va_check); |
| 500 | - (void *)(uintptr_t)va_check); | ||
| 501 | return -EINVAL; | 492 | return -EINVAL; |
| 502 | } | 493 | } |
| 503 | } | 494 | } |
| @@ -527,10 +518,9 @@ static void trs_zap_vma_ptes(ka_vm_area_struct_t *vma, unsigned long addr, size_ | |||
| 527 | int ret = ka_mm_zap_vma_ptes(vma, addr, KA_MM_PAGE_ALIGN(len)); | 518 | int ret = ka_mm_zap_vma_ptes(vma, addr, KA_MM_PAGE_ALIGN(len)); |
| 528 | if (ret != 0) { | 519 | if (ret != 0) { |
| 529 | 520 | ||
| 530 | - trs_err( | 521 | + trs_err("Unmap va failed. (vma_start=%pK; end=%pK; addr=%pK; len=0x%lx)\n", |
| 531 | - "Unmap va failed. (vma_start=%pK; end=%pK; addr=%pK; len=0x%lx)\n", | 522 | + (void *)(uintptr_t)ka_mm_get_vm_start(vma), (void *)(uintptr_t)ka_mm_get_vm_end(vma), |
| 532 | - (void *)(uintptr_t)ka_mm_get_vm_start(vma), (void *)(uintptr_t)ka_mm_get_vm_end(vma), | 523 | + (void *)(uintptr_t)addr, len); |
| 533 | - (void *)(uintptr_t)addr, len); | ||
| 534 | 524 | ||
| 535 | } | 525 | } |
| 536 | } | 526 | } |
| @@ -548,10 +538,9 @@ static int trs_remap_pfn(struct trs_proc_ctx *proc_ctx, struct trs_mem_map_para | |||
| 548 | ret = ka_mm_remap_pfn_range(vma, para->va, __ka_mm_phys_to_pfn(para->pa), para->len, prot); | 538 | ret = ka_mm_remap_pfn_range(vma, para->va, __ka_mm_phys_to_pfn(para->pa), para->len, prot); |
| 549 | if (ret != 0) { | 539 | if (ret != 0) { |
| 550 | 540 | ||
| 551 | - trs_err( | 541 | + trs_err("Remap va failed. (vma_start=%pK; end=%pK; addr=%pK; len=0x%lx)\n", |
| 552 | - "Remap va failed. (vma_start=%pK; end=%pK; addr=%pK; len=0x%lx)\n", | 542 | + (void *)(uintptr_t)ka_mm_get_vm_start(vma), (void *)(uintptr_t)ka_mm_get_vm_end(vma), |
| 553 | - (void *)(uintptr_t)ka_mm_get_vm_start(vma), (void *)(uintptr_t)ka_mm_get_vm_end(vma), | 543 | + (void *)(uintptr_t)para->va, para->len); |
| 554 | - (void *)(uintptr_t)para->va, para->len); | ||
| 555 | 544 | ||
| 556 | } | 545 | } |
| 557 | 546 | ||
| @@ -677,9 +666,8 @@ int trs_proc_release_check_ts(struct trs_proc_ctx *proc_ctx, u32 tsid) | |||
| 677 | return 0; | 666 | return 0; |
| 678 | } | 667 | } |
| 679 | 668 | ||
| 680 | - trs_debug( | 669 | + trs_debug("Send check. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld)\n", ts_inst->inst.devid, tsid, |
| 681 | - "Send check. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld)\n", ts_inst->inst.devid, tsid, | 670 | + proc_ctx->name, proc_ctx->pid, proc_ctx->task_id); |
| 682 | - proc_ctx->name, proc_ctx->pid, proc_ctx->task_id); | ||
| 683 | ret = trs_proc_release_msg_send(ts_inst, proc_ctx->pid, TRS_MBOX_RECYCLE_CHECK); | 671 | ret = trs_proc_release_msg_send(ts_inst, proc_ctx->pid, TRS_MBOX_RECYCLE_CHECK); |
| 684 | if (ret == 0) { | 672 | if (ret == 0) { |
| 685 | trs_core_inst_put(ts_inst); | 673 | trs_core_inst_put(ts_inst); |
| @@ -708,9 +696,8 @@ void trs_proc_release_ras_report(struct trs_proc_ctx *proc_ctx, struct trs_core_ | |||
| 708 | ts_inst->ops.ras_report(&ts_inst->inst); | 696 | ts_inst->ops.ras_report(&ts_inst->inst); |
| 709 | return; | 697 | return; |
| 710 | } | 698 | } |
| 711 | - trs_debug( | 699 | + trs_debug("No need to send ras. (devid=%u; tsid=%u; pid=%d; task_id=%lld)\n", ts_inst->inst.devid, |
| 712 | - "No need to send ras. (devid=%u; tsid=%u; pid=%d; task_id=%lld)\n", ts_inst->inst.devid, ts_inst->inst.tsid, | 700 | + ts_inst->inst.tsid, proc_ctx->pid, proc_ctx->task_id); |
| 713 | - proc_ctx->pid, proc_ctx->task_id); | ||
| 714 | return; | 701 | return; |
| 715 | } | 702 | } |
| 716 | 703 | ||
| @@ -756,9 +743,8 @@ retry: | |||
| 756 | queue_full_retry_cnt++; | 743 | queue_full_retry_cnt++; |
| 757 | ret = trs_proc_release_msg_send(ts_inst, proc_ctx->pid, TRS_MBOX_RECYCLE_PID); | 744 | ret = trs_proc_release_msg_send(ts_inst, proc_ctx->pid, TRS_MBOX_RECYCLE_PID); |
| 758 | if (ret != 0) { | 745 | if (ret != 0) { |
| 759 | - trs_warn( | 746 | + trs_warn("Notice ts warn. (devid=%u; tsid=%u; pid=%d; retry_cnt=%d; ret=%d)\n", inst->devid, inst->tsid, |
| 760 | - "Notice ts warn. (devid=%u; tsid=%u; pid=%d; retry_cnt=%d; ret=%d)\n", inst->devid, inst->tsid, | 747 | + proc_ctx->pid, queue_full_retry_cnt, ret); |
| 761 | - proc_ctx->pid, queue_full_retry_cnt, ret); | ||
| 762 | } | 748 | } |
| 763 | 749 | ||
| 764 | if ((ret == -EBUSY) && (queue_full_retry_cnt < TSFW_QUEUE_FULL_RETRY_TIMES)) { | 750 | if ((ret == -EBUSY) && (queue_full_retry_cnt < TSFW_QUEUE_FULL_RETRY_TIMES)) { |
| @@ -776,9 +762,9 @@ retry: | |||
| 776 | } | 762 | } |
| 777 | } | 763 | } |
| 778 | 764 | ||
| 779 | -static void trs_for_each_proc_res_id( | 765 | +static void trs_for_each_proc_res_id(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, |
| 780 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, | 766 | + void (*recycle_func)(struct trs_proc_ctx *proc_ctx, |
| 781 | - void (*recycle_func)(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id)) | 767 | + struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id)) |
| 782 | { | 768 | { |
| 783 | struct trs_res_mng *res_mng = &ts_inst->res_mng[res_type]; | 769 | struct trs_res_mng *res_mng = &ts_inst->res_mng[res_type]; |
| 784 | struct trs_id_inst *inst = &ts_inst->inst; | 770 | struct trs_id_inst *inst = &ts_inst->inst; |
| @@ -799,9 +785,8 @@ static void trs_for_each_proc_res_id( | |||
| 799 | } | 785 | } |
| 800 | } | 786 | } |
| 801 | 787 | ||
| 802 | - trs_debug( | 788 | + trs_debug("Recycle res. (devid=%u; tsid=%u; res_type=%d; recycle_num=%u; proc_res_num=%u)\n", inst->devid, |
| 803 | - "Recycle res. (devid=%u; tsid=%u; res_type=%d; recycle_num=%u; proc_res_num=%u)\n", inst->devid, inst->tsid, | 789 | + inst->tsid, res_type, recycle_num, trs_get_proc_res_num(proc_ctx, inst->tsid, res_type)); |
| 804 | - res_type, recycle_num, trs_get_proc_res_num(proc_ctx, inst->tsid, res_type)); | ||
| 805 | } | 790 | } |
| 806 | 791 | ||
| 807 | void trs_proc_leak_res_show(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst) | 792 | void trs_proc_leak_res_show(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst) |
| @@ -819,9 +804,8 @@ void trs_proc_leak_res_show(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_in | |||
| 819 | } | 804 | } |
| 820 | if (trs_is_id_pid_match(&res_mng->ids[i], proc_ctx->pid, proc_ctx->task_id)) { | 805 | if (trs_is_id_pid_match(&res_mng->ids[i], proc_ctx->pid, proc_ctx->task_id)) { |
| 821 | num++; | 806 | num++; |
| 822 | - trs_warn( | 807 | + trs_warn("Leak res. (devid=%u; tsid=%u; res_type=%d; res_id=%d; proc_res_num=%d)\n", inst->devid, |
| 823 | - "Leak res. (devid=%u; tsid=%u; res_type=%d; res_id=%d; proc_res_num=%d)\n", inst->devid, inst->tsid, | 808 | + inst->tsid, i, j, trs_get_proc_res_num(proc_ctx, inst->tsid, i)); |
| 824 | - i, j, trs_get_proc_res_num(proc_ctx, inst->tsid, i)); | ||
| 825 | } | 809 | } |
| 826 | } | 810 | } |
| 827 | } | 811 | } |
| @@ -843,9 +827,9 @@ static int trs_proc_release_agent_master_check_ts(struct trs_proc_ctx *proc_ctx, | |||
| 843 | 827 | ||
| 844 | ret = trs_proc_release_msg_send(ts_inst, master_pid, TRS_MBOX_RECYCLE_CHECK); | 828 | ret = trs_proc_release_msg_send(ts_inst, master_pid, TRS_MBOX_RECYCLE_CHECK); |
| 845 | if (ret != 0) { | 829 | if (ret != 0) { |
| 846 | - trs_warn( | 830 | + trs_warn("App exit not finish. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; master_pid=%d; ret=%d)\n", |
| 847 | - "App exit not finish. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; master_pid=%d; ret=%d)\n", | 831 | + ts_inst->inst.devid, ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, master_pid, |
| 848 | - ts_inst->inst.devid, ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, master_pid, ret); | 832 | + ret); |
| 849 | goto exit; | 833 | goto exit; |
| 850 | } | 834 | } |
| 851 | 835 | ||
| @@ -853,10 +837,9 @@ static int trs_proc_release_agent_master_check_ts(struct trs_proc_ctx *proc_ctx, | |||
| 853 | if (ts_inst->ops.notice_proc_release != NULL) { | 837 | if (ts_inst->ops.notice_proc_release != NULL) { |
| 854 | ret = ts_inst->ops.notice_proc_release(&ts_inst->inst, master_pid); | 838 | ret = ts_inst->ops.notice_proc_release(&ts_inst->inst, master_pid); |
| 855 | if (ret != 0) { | 839 | if (ret != 0) { |
| 856 | - trs_warn( | 840 | + trs_warn("App exit warn. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; master_pid=%d; ret=%d)\n", |
| 857 | - "App exit warn. (devid=%u; tsid=%u; name=%s; pid=%d; task_id=%lld; master_pid=%d; ret=%d)\n", | 841 | + ts_inst->inst.devid, ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, |
| 858 | - ts_inst->inst.devid, ts_inst->inst.tsid, proc_ctx->name, proc_ctx->pid, proc_ctx->task_id, master_pid, | 842 | + master_pid, ret); |
| 859 | - ret); | ||
| 860 | goto exit; | 843 | goto exit; |
| 861 | } | 844 | } |
| 862 | } | 845 | } |
| @@ -121,8 +121,8 @@ static inline int trs_get_proc_id_dfx_times(struct trs_proc_ctx *proc_ctx, u32 t | |||
| 121 | bool trs_proc_has_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 121 | bool trs_proc_has_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| 122 | bool trs_proc_has_res_with_pid(struct trs_core_ts_inst *ts_inst, int pid, int res_type, u32 res_id); | 122 | bool trs_proc_has_res_with_pid(struct trs_core_ts_inst *ts_inst, int pid, int res_type, u32 res_id); |
| 123 | int trs_proc_add_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 123 | int trs_proc_add_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| 124 | -int trs_proc_add_res_ex( | 124 | +int trs_proc_add_res_ex(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, |
| 125 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id, bool is_agent_res); | 125 | + bool is_agent_res); |
| 126 | int trs_proc_del_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 126 | int trs_proc_del_res(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| 127 | int trs_res_get(struct trs_core_ts_inst *ts_inst, int pid, int res_type, u32 res_id); | 127 | int trs_res_get(struct trs_core_ts_inst *ts_inst, int pid, int res_type, u32 res_id); |
| 128 | int trs_res_put(struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 128 | int trs_res_put(struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| @@ -163,8 +163,8 @@ struct trs_mem_unmap_para { | |||
| 163 | unsigned long len; | 163 | unsigned long len; |
| 164 | }; | 164 | }; |
| 165 | 165 | ||
| 166 | -static inline void trs_remap_fill_para( | 166 | +static inline void trs_remap_fill_para(struct trs_mem_map_para *para, int type, unsigned long va, unsigned long pa, |
| 167 | - struct trs_mem_map_para *para, int type, unsigned long va, unsigned long pa, unsigned long len) | 167 | + unsigned long len) |
| 168 | { | 168 | { |
| 169 | para->type = type; | 169 | para->type = type; |
| 170 | para->va = va; | 170 | para->va = va; |
| @@ -92,9 +92,8 @@ static const ka_procfs_ops_t proc_trace_ops = { | |||
| 92 | 92 | ||
| 93 | static void trs_proc_show(struct trs_proc_ctx *proc_ctx, ka_seq_file_t *seq) | 93 | static void trs_proc_show(struct trs_proc_ctx *proc_ctx, ka_seq_file_t *seq) |
| 94 | { | 94 | { |
| 95 | - ka_fs_seq_printf( | 95 | + ka_fs_seq_printf(seq, "pid %d(%s) task_id %lld devid %d status %d(0:normal, 1:exit) ssid %u\n", proc_ctx->pid, |
| 96 | - seq, "pid %d(%s) task_id %lld devid %d status %d(0:normal, 1:exit) ssid %u\n", proc_ctx->pid, proc_ctx->name, | 96 | + proc_ctx->name, proc_ctx->task_id, proc_ctx->devid, proc_ctx->status, proc_ctx->cp_ssid); |
| 97 | - proc_ctx->task_id, proc_ctx->devid, proc_ctx->status, proc_ctx->cp_ssid); | ||
| 98 | } | 97 | } |
| 99 | 98 | ||
| 100 | static void ts_inst_proc_show(struct trs_core_ts_inst *ts_inst, ka_seq_file_t *seq) | 99 | static void ts_inst_proc_show(struct trs_core_ts_inst *ts_inst, ka_seq_file_t *seq) |
| @@ -103,10 +102,16 @@ static void ts_inst_proc_show(struct trs_core_ts_inst *ts_inst, ka_seq_file_t *s | |||
| 103 | 102 | ||
| 104 | ka_task_down_read(&ts_inst->sem); | 103 | ka_task_down_read(&ts_inst->sem); |
| 105 | ka_fs_seq_printf(seq, "\nproc list:\n"); | 104 | ka_fs_seq_printf(seq, "\nproc list:\n"); |
| 106 | - ka_list_for_each_entry(proc_ctx, &ts_inst->proc_list_head, node) { trs_proc_show(proc_ctx, seq); } | 105 | + ka_list_for_each_entry(proc_ctx, &ts_inst->proc_list_head, node) |
| 106 | + { | ||
| 107 | + trs_proc_show(proc_ctx, seq); | ||
| 108 | + } | ||
| 107 | 109 | ||
| 108 | ka_fs_seq_printf(seq, "\nexit proc list:\n"); | 110 | ka_fs_seq_printf(seq, "\nexit proc list:\n"); |
| 109 | - ka_list_for_each_entry(proc_ctx, &ts_inst->exit_proc_list_head, node) { trs_proc_show(proc_ctx, seq); } | 111 | + ka_list_for_each_entry(proc_ctx, &ts_inst->exit_proc_list_head, node) |
| 112 | + { | ||
| 113 | + trs_proc_show(proc_ctx, seq); | ||
| 114 | + } | ||
| 110 | ka_task_up_read(&ts_inst->sem); | 115 | ka_task_up_read(&ts_inst->sem); |
| 111 | } | 116 | } |
| 112 | 117 | ||
| @@ -118,9 +123,8 @@ static void ts_inst_res_show(struct trs_core_ts_inst *ts_inst, ka_seq_file_t *se | |||
| 118 | 123 | ||
| 119 | for (i = 0; i < TRS_CORE_MAX_ID_TYPE; i++) { | 124 | for (i = 0; i < TRS_CORE_MAX_ID_TYPE; i++) { |
| 120 | struct trs_res_mng *res_mng = &ts_inst->res_mng[i]; | 125 | struct trs_res_mng *res_mng = &ts_inst->res_mng[i]; |
| 121 | - ka_fs_seq_printf( | 126 | + ka_fs_seq_printf(seq, "idx %d res %s id_num %u max_id %u use_num %u\n", i, res_name[i], res_mng->id_num, |
| 122 | - seq, "idx %d res %s id_num %u max_id %u use_num %u\n", i, res_name[i], res_mng->id_num, res_mng->max_id, | 127 | + res_mng->max_id, res_mng->use_num); |
| 123 | - res_mng->use_num); | ||
| 124 | } | 128 | } |
| 125 | 129 | ||
| 126 | ka_fs_seq_printf(seq, "\nid_allocator res list:\n"); | 130 | ka_fs_seq_printf(seq, "\nid_allocator res list:\n"); |
| @@ -130,9 +134,8 @@ static void ts_inst_res_show(struct trs_core_ts_inst *ts_inst, ka_seq_file_t *se | |||
| 130 | 134 | ||
| 131 | ret = trs_id_get_stat(&ts_inst->inst, i, &stat); | 135 | ret = trs_id_get_stat(&ts_inst->inst, i, &stat); |
| 132 | if (ret == 0) { | 136 | if (ret == 0) { |
| 133 | - ka_fs_seq_printf( | 137 | + ka_fs_seq_printf(seq, "idx %d res %s use_num %u allocatable %u rsv_num %u\n", i, trs_id_type_to_name(i), |
| 134 | - seq, "idx %d res %s use_num %u allocatable %u rsv_num %u\n", i, trs_id_type_to_name(i), stat.alloc, | 138 | + stat.alloc, stat.allocatable, stat.rsv_num); |
| 135 | - stat.allocatable, stat.rsv_num); | ||
| 136 | } | 139 | } |
| 137 | } | 140 | } |
| 138 | 141 | ||
| @@ -152,10 +155,9 @@ static int ts_inst_info_show(ka_seq_file_t *seq, void *offset) | |||
| 152 | { | 155 | { |
| 153 | struct trs_core_ts_inst *ts_inst = (struct trs_core_ts_inst *)ka_fs_get_seq_file_private(seq); | 156 | struct trs_core_ts_inst *ts_inst = (struct trs_core_ts_inst *)ka_fs_get_seq_file_private(seq); |
| 154 | 157 | ||
| 155 | - ka_fs_seq_printf( | 158 | + ka_fs_seq_printf(seq, "devid %d tsid %d hw_type %d(0:tscpu, 1:stars) support_proc_num %u(0:no_limit) ref %u\n", |
| 156 | - seq, "devid %d tsid %d hw_type %d(0:tscpu, 1:stars) support_proc_num %u(0:no_limit) ref %u\n", | 159 | + ts_inst->inst.devid, ts_inst->inst.tsid, ts_inst->hw_type, ts_inst->support_proc_num, |
| 157 | - ts_inst->inst.devid, ts_inst->inst.tsid, ts_inst->hw_type, ts_inst->support_proc_num, | 160 | + kref_safe_read(&ts_inst->ref)); |
| 158 | - kref_safe_read(&ts_inst->ref)); | ||
| 159 | if (ts_inst->inst.tsid == 0) { | 161 | if (ts_inst->inst.tsid == 0) { |
| 160 | ts_inst_proc_show(ts_inst, seq); | 162 | ts_inst_proc_show(ts_inst, seq); |
| 161 | } | 163 | } |
| @@ -189,9 +191,8 @@ static void ts_inst_cb_phy_sqcq_show(struct trs_core_ts_inst *ts_inst, ka_seq_fi | |||
| 189 | { | 191 | { |
| 190 | struct trs_cb_ctx *cb_ctx = &ts_inst->cb_ctx; | 192 | struct trs_cb_ctx *cb_ctx = &ts_inst->cb_ctx; |
| 191 | if (cb_ctx->phy_sqcq.chan_id >= 0) { | 193 | if (cb_ctx->phy_sqcq.chan_id >= 0) { |
| 192 | - ka_fs_seq_printf( | 194 | + ka_fs_seq_printf(seq, "cb cq_num %u phy sqid %u cqid %u chan %d\n", cb_ctx->cq_num, cb_ctx->phy_sqcq.sqid, |
| 193 | - seq, "cb cq_num %u phy sqid %u cqid %u chan %d\n", cb_ctx->cq_num, cb_ctx->phy_sqcq.sqid, | 195 | + cb_ctx->phy_sqcq.cqid, cb_ctx->phy_sqcq.chan_id); |
| 194 | - cb_ctx->phy_sqcq.cqid, cb_ctx->phy_sqcq.chan_id); | ||
| 195 | trs_id_show(ts_inst, seq, TRS_SW_SQ_ID, cb_ctx->phy_sqcq.sqid); | 196 | trs_id_show(ts_inst, seq, TRS_SW_SQ_ID, cb_ctx->phy_sqcq.sqid); |
| 196 | trs_id_show(ts_inst, seq, TRS_SW_CQ_ID, cb_ctx->phy_sqcq.cqid); | 197 | trs_id_show(ts_inst, seq, TRS_SW_CQ_ID, cb_ctx->phy_sqcq.cqid); |
| 197 | trs_chan_show(ts_inst, seq, cb_ctx->phy_sqcq.chan_id); | 198 | trs_chan_show(ts_inst, seq, cb_ctx->phy_sqcq.chan_id); |
| @@ -202,9 +203,8 @@ static void ts_inst_logic_phy_sqcq_show(struct trs_core_ts_inst *ts_inst, ka_seq | |||
| 202 | { | 203 | { |
| 203 | struct trs_logic_cq_ctx *logic_cq_ctx = &ts_inst->logic_cq_ctx; | 204 | struct trs_logic_cq_ctx *logic_cq_ctx = &ts_inst->logic_cq_ctx; |
| 204 | if (logic_cq_ctx->phy_cq.chan_id >= 0) { | 205 | if (logic_cq_ctx->phy_cq.chan_id >= 0) { |
| 205 | - ka_fs_seq_printf( | 206 | + ka_fs_seq_printf(seq, "logic cq_num %u phy cqid %u chan %d\n", logic_cq_ctx->cq_num, logic_cq_ctx->phy_cq.cqid, |
| 206 | - seq, "logic cq_num %u phy cqid %u chan %d\n", logic_cq_ctx->cq_num, logic_cq_ctx->phy_cq.cqid, | 207 | + logic_cq_ctx->phy_cq.chan_id); |
| 207 | - logic_cq_ctx->phy_cq.chan_id); | ||
| 208 | trs_id_show(ts_inst, seq, TRS_SW_CQ_ID, logic_cq_ctx->phy_cq.cqid); | 208 | trs_id_show(ts_inst, seq, TRS_SW_CQ_ID, logic_cq_ctx->phy_cq.cqid); |
| 209 | trs_chan_show(ts_inst, seq, logic_cq_ctx->phy_cq.chan_id); | 209 | trs_chan_show(ts_inst, seq, logic_cq_ctx->phy_cq.chan_id); |
| 210 | } | 210 | } |
| @@ -213,28 +213,26 @@ static void ts_inst_logic_phy_sqcq_show(struct trs_core_ts_inst *ts_inst, ka_seq | |||
| 213 | static void res_stream_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, ka_seq_file_t *seq) | 213 | static void res_stream_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, ka_seq_file_t *seq) |
| 214 | { | 214 | { |
| 215 | struct trs_stream_ctx *stream_ctx = &ts_inst->stream_ctx[id]; | 215 | struct trs_stream_ctx *stream_ctx = &ts_inst->stream_ctx[id]; |
| 216 | - ka_fs_seq_printf( | 216 | + ka_fs_seq_printf(seq, " host_pid %d sq %d cq %d logic_cq %d\n", stream_ctx->host_pid, stream_ctx->sq, |
| 217 | - seq, " host_pid %d sq %d cq %d logic_cq %d\n", stream_ctx->host_pid, stream_ctx->sq, stream_ctx->cq, | 217 | + stream_ctx->cq, stream_ctx->logic_cq); |
| 218 | - stream_ctx->logic_cq); | ||
| 219 | } | 218 | } |
| 220 | 219 | ||
| 221 | static int trs_hw_sq_to_string(struct trs_core_ts_inst *ts_inst, u32 id, char *buff, u32 buff_len) | 220 | static int trs_hw_sq_to_string(struct trs_core_ts_inst *ts_inst, u32 id, char *buff, u32 buff_len) |
| 222 | { | 221 | { |
| 223 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[id]; | 222 | struct trs_sq_ctx *sq_ctx = &ts_inst->sq_ctx[id]; |
| 224 | int ret, len = 0; | 223 | int ret, len = 0; |
| 225 | - ret = sprintf_s( | 224 | + ret = sprintf_s(buff, buff_len, " mode %s type %u flag %u cqid %u stream_id %u chan %d cp_proc %s\n", |
| 226 | - buff, buff_len, " mode %s type %u flag %u cqid %u stream_id %u chan %d cp_proc %s\n", | 225 | + (sq_ctx->mode == 0) ? "kio" : ((sq_ctx->mode == 1) ? "uio_t" : "uio_d"), sq_ctx->type, sq_ctx->flag, |
| 227 | - (sq_ctx->mode == 0) ? "kio" : ((sq_ctx->mode == 1) ? "uio_t" : "uio_d"), sq_ctx->type, sq_ctx->flag, | 226 | + sq_ctx->cqid, sq_ctx->stream_id, sq_ctx->chan_id, |
| 228 | - sq_ctx->cqid, sq_ctx->stream_id, sq_ctx->chan_id, (sq_ctx->reg_mem.cp_proc_state == 0) ? "exist" : "not exist"); | 227 | + (sq_ctx->reg_mem.cp_proc_state == 0) ? "exist" : "not exist"); |
| 229 | 228 | ||
| 230 | ka_task_spin_lock_bh(&sq_ctx->shr_info_lock); | 229 | ka_task_spin_lock_bh(&sq_ctx->shr_info_lock); |
| 231 | if ((ret > 0) && ((sq_ctx->mode == (u32)SEND_MODE_UIO_T) || (sq_ctx->mode == (u32)SEND_MODE_UIO_D)) && | 230 | if ((ret > 0) && ((sq_ctx->mode == (u32)SEND_MODE_UIO_T) || (sq_ctx->mode == (u32)SEND_MODE_UIO_D)) && |
| 232 | (sq_ctx->shr_info.kva != NULL)) { | 231 | (sq_ctx->shr_info.kva != NULL)) { |
| 233 | struct trs_sq_shr_info *shr_info = (struct trs_sq_shr_info *)sq_ctx->shr_info.kva; | 232 | struct trs_sq_shr_info *shr_info = (struct trs_sq_shr_info *)sq_ctx->shr_info.kva; |
| 234 | len += ret; | 233 | len += ret; |
| 235 | - ret = sprintf_s( | 234 | + ret = sprintf_s(buff + len, buff_len - len, " uio send ok %llu send full %llu send invalid in kernel %llu\n", |
| 236 | - buff + len, buff_len - len, " uio send ok %llu send full %llu send invalid in kernel %llu\n", | 235 | + shr_info->send_ok, shr_info->send_full, sq_ctx->send_fail); |
| 237 | - shr_info->send_ok, shr_info->send_full, sq_ctx->send_fail); | ||
| 238 | } | 236 | } |
| 239 | ka_task_spin_unlock_bh(&sq_ctx->shr_info_lock); | 237 | ka_task_spin_unlock_bh(&sq_ctx->shr_info_lock); |
| 240 | 238 | ||
| @@ -267,9 +265,8 @@ static int trs_hw_cq_stat_to_string(struct trs_cq_ctx *cq_ctx, char *buff, u32 b | |||
| 267 | int len = 0; | 265 | int len = 0; |
| 268 | 266 | ||
| 269 | len = sprintf_s(buff, buff_len, " chan %d, logic_cqid %d\n", cq_ctx->chan_id, cq_ctx->logic_cqid); | 267 | len = sprintf_s(buff, buff_len, " chan %d, logic_cqid %d\n", cq_ctx->chan_id, cq_ctx->logic_cqid); |
| 270 | - len += sprintf_s( | 268 | + len += sprintf_s(buff + len, buff_len - len, " stat: rx %llu rx_enque %llu drop %llu logic_enque_invalid %llu\n", |
| 271 | - buff + len, buff_len - len, " stat: rx %llu rx_enque %llu drop %llu logic_enque_invalid %llu\n", | 269 | + cq_ctx->stat.rx, cq_ctx->stat.rx_enque, cq_ctx->stat.rx_drop, cq_ctx->stat.rx_enque_fail); |
| 272 | - cq_ctx->stat.rx, cq_ctx->stat.rx_enque, cq_ctx->stat.rx_drop, cq_ctx->stat.rx_enque_fail); | ||
| 273 | return len; | 270 | return len; |
| 274 | } | 271 | } |
| 275 | 272 | ||
| @@ -318,9 +315,8 @@ static void res_sw_cq_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, ka_s | |||
| 318 | static void res_cb_cq_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, ka_seq_file_t *seq) | 315 | static void res_cb_cq_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, ka_seq_file_t *seq) |
| 319 | { | 316 | { |
| 320 | struct trs_cb_cq *cb_cq = &ts_inst->cb_ctx.cq[id]; | 317 | struct trs_cb_cq *cb_cq = &ts_inst->cb_ctx.cq[id]; |
| 321 | - ka_fs_seq_printf( | 318 | + ka_fs_seq_printf(seq, " valid %u pid %d cq_depth %u cqe_size %u grpid %u\n", cb_cq->valid, cb_cq->pid, |
| 322 | - seq, " valid %u pid %d cq_depth %u cqe_size %u grpid %u\n", cb_cq->valid, cb_cq->pid, cb_cq->cq_depth, | 319 | + cb_cq->cq_depth, cb_cq->cqe_size, cb_cq->grpid); |
| 323 | - cb_cq->cqe_size, cb_cq->grpid); | ||
| 324 | } | 320 | } |
| 325 | 321 | ||
| 326 | static int trs_logic_cq_to_string(struct trs_logic_cq *cq, char *buff, u32 buff_len) | 322 | static int trs_logic_cq_to_string(struct trs_logic_cq *cq, char *buff, u32 buff_len) |
| @@ -361,9 +357,8 @@ void trs_logic_cq_show(struct trs_core_ts_inst *ts_inst, u32 cqid) | |||
| 361 | char buff[BUFF_LEN]; | 357 | char buff[BUFF_LEN]; |
| 362 | 358 | ||
| 363 | if (trs_logic_cq_to_string(cq, buff, BUFF_LEN) > 0) { | 359 | if (trs_logic_cq_to_string(cq, buff, BUFF_LEN) > 0) { |
| 364 | - trs_info_ratelimited( | 360 | + trs_info_ratelimited("Logic cq stat show. (devid=%u; tsid=%u; id=%u; flag=%u)\n%s", inst->devid, inst->tsid, |
| 365 | - "Logic cq stat show. (devid=%u; tsid=%u; id=%u; flag=%u)\n%s", inst->devid, inst->tsid, cqid, cq->flag, | 361 | + cqid, cq->flag, buff); |
| 366 | - buff); | ||
| 367 | } | 362 | } |
| 368 | } | 363 | } |
| 369 | 364 | ||
| @@ -376,8 +371,8 @@ static void res_logic_cq_detail_show(struct trs_core_ts_inst *ts_inst, u32 id, k | |||
| 376 | } | 371 | } |
| 377 | } | 372 | } |
| 378 | 373 | ||
| 379 | -static void (*const res_detail_handles[TRS_CORE_MAX_ID_TYPE])( | 374 | +static void (*const res_detail_handles[TRS_CORE_MAX_ID_TYPE])(struct trs_core_ts_inst *ts_inst, u32 id, |
| 380 | - struct trs_core_ts_inst *ts_inst, u32 id, ka_seq_file_t *seq) = { | 375 | + ka_seq_file_t *seq) = { |
| 381 | [TRS_STREAM] = res_stream_detail_show, [TRS_HW_SQ] = res_hw_sq_detail_show, [TRS_HW_CQ] = res_hw_cq_detail_show, | 376 | [TRS_STREAM] = res_stream_detail_show, [TRS_HW_SQ] = res_hw_sq_detail_show, [TRS_HW_CQ] = res_hw_cq_detail_show, |
| 382 | [TRS_SW_SQ] = res_sw_sq_detail_show, [TRS_SW_CQ] = res_sw_cq_detail_show, [TRS_CB_CQ] = res_cb_cq_detail_show, | 377 | [TRS_SW_SQ] = res_sw_sq_detail_show, [TRS_SW_CQ] = res_sw_cq_detail_show, [TRS_CB_CQ] = res_cb_cq_detail_show, |
| 383 | [TRS_LOGIC_CQ] = res_logic_cq_detail_show}; | 378 | [TRS_LOGIC_CQ] = res_logic_cq_detail_show}; |
| @@ -539,7 +534,10 @@ void proc_fs_add_ts_inst(struct trs_core_ts_inst *ts_inst) | |||
| 539 | } | 534 | } |
| 540 | } | 535 | } |
| 541 | 536 | ||
| 542 | -void proc_fs_del_ts_inst(struct trs_core_ts_inst *ts_inst) { proc_fs_rm_ts_inst_dir(ts_inst, ts_inst_entry); } | 537 | +void proc_fs_del_ts_inst(struct trs_core_ts_inst *ts_inst) |
| 538 | +{ | ||
| 539 | + proc_fs_rm_ts_inst_dir(ts_inst, ts_inst_entry); | ||
| 540 | +} | ||
| 543 | 541 | ||
| 544 | static void proc_fs_format_pid_dir_name(struct trs_proc_ctx *proc_ctx, char *name, int len) | 542 | static void proc_fs_format_pid_dir_name(struct trs_proc_ctx *proc_ctx, char *name, int len) |
| 545 | { | 543 | { |
| @@ -579,7 +577,10 @@ void proc_fs_add_pid(struct trs_proc_ctx *proc_ctx) | |||
| 579 | (void)ka_fs_proc_create_data("summary", PROC_FS_MODE, proc_ctx->entry, &proc_sum_ops, proc_ctx); | 577 | (void)ka_fs_proc_create_data("summary", PROC_FS_MODE, proc_ctx->entry, &proc_sum_ops, proc_ctx); |
| 580 | } | 578 | } |
| 581 | 579 | ||
| 582 | -void proc_fs_del_pid(struct trs_proc_ctx *proc_ctx) { proc_fs_rm_pid_dir(proc_ctx, proc_entry); } | 580 | +void proc_fs_del_pid(struct trs_proc_ctx *proc_ctx) |
| 581 | +{ | ||
| 582 | + proc_fs_rm_pid_dir(proc_ctx, proc_entry); | ||
| 583 | +} | ||
| 583 | 584 | ||
| 584 | void trs_proc_fs_init(void) | 585 | void trs_proc_fs_init(void) |
| 585 | { | 586 | { |
| @@ -604,4 +605,7 @@ void trs_proc_fs_init(void) | |||
| 604 | return; | 605 | return; |
| 605 | } | 606 | } |
| 606 | 607 | ||
| 607 | -void trs_proc_fs_uninit(void) { (void)ka_fs_remove_proc_subtree("trs_core", NULL); } | 608 | +void trs_proc_fs_uninit(void) |
| 609 | +{ | ||
| 610 | + (void)ka_fs_remove_proc_subtree("trs_core", NULL); | ||
| 611 | +} | ||
| @@ -94,9 +94,15 @@ static bool trs_is_host_pid_match(int cur_pid, int host_pid) | |||
| 94 | return (pid == host_pid); | 94 | return (pid == host_pid); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | -u32 trs_res_get_id_num(struct trs_core_ts_inst *ts_inst, int res_type) { return ts_inst->res_mng[res_type].id_num; } | 97 | +u32 trs_res_get_id_num(struct trs_core_ts_inst *ts_inst, int res_type) |
| 98 | +{ | ||
| 99 | + return ts_inst->res_mng[res_type].id_num; | ||
| 100 | +} | ||
| 98 | 101 | ||
| 99 | -u32 trs_res_get_max_id(struct trs_core_ts_inst *ts_inst, int res_type) { return ts_inst->res_mng[res_type].max_id; } | 102 | +u32 trs_res_get_max_id(struct trs_core_ts_inst *ts_inst, int res_type) |
| 103 | +{ | ||
| 104 | + return ts_inst->res_mng[res_type].max_id; | ||
| 105 | +} | ||
| 100 | 106 | ||
| 101 | u32 trs_res_get_id_used_num(struct trs_core_ts_inst *ts_inst, int res_type) | 107 | u32 trs_res_get_id_used_num(struct trs_core_ts_inst *ts_inst, int res_type) |
| 102 | { | 108 | { |
| @@ -136,8 +142,8 @@ static int trs_event_notice_ts(struct trs_core_ts_inst *ts_inst, int op, u32 eve | |||
| 136 | return trs_event_res_map_notice_ts(ts_inst, op, event_id); | 142 | return trs_event_res_map_notice_ts(ts_inst, op, event_id); |
| 137 | } | 143 | } |
| 138 | 144 | ||
| 139 | -static int trs_notify_notice_ts( | 145 | +static int trs_notify_notice_ts(struct trs_core_ts_inst *ts_inst, int op, u32 notify_id, u32 notify_type, |
| 140 | - struct trs_core_ts_inst *ts_inst, int op, u32 notify_id, u32 notify_type, u32 config_type) | 146 | + u32 config_type) |
| 141 | { | 147 | { |
| 142 | struct trs_notify_msg msg; | 148 | struct trs_notify_msg msg; |
| 143 | u32 cmd_type = (config_type == TRS_RES_OP_RESET) ? TRS_MBOX_RESET_NOTIFY : TRS_MBOX_RECORD_NOTIFY; | 149 | u32 cmd_type = (config_type == TRS_RES_OP_RESET) ? TRS_MBOX_RESET_NOTIFY : TRS_MBOX_RECORD_NOTIFY; |
| @@ -165,9 +171,8 @@ int trs_notify_config_with_ts(struct trs_id_inst *inst, u32 notify_id, u32 notif | |||
| 165 | } | 171 | } |
| 166 | ret = trs_notify_notice_ts(ts_inst, 0, notify_id, notify_type, config_type); | 172 | ret = trs_notify_notice_ts(ts_inst, 0, notify_id, notify_type, config_type); |
| 167 | if (ret != 0) { | 173 | if (ret != 0) { |
| 168 | - trs_err( | 174 | + trs_err("Notice ts failed. (devid=%u; notify_id=%u; notify_type=%u; ret=%d)\n", inst->devid, notify_id, |
| 169 | - "Notice ts failed. (devid=%u; notify_id=%u; notify_type=%u; ret=%d)\n", inst->devid, notify_id, notify_type, | 175 | + notify_type, ret); |
| 170 | - ret); | ||
| 171 | } | 176 | } |
| 172 | trs_core_inst_put(ts_inst); | 177 | trs_core_inst_put(ts_inst); |
| 173 | return ret; | 178 | return ret; |
| @@ -233,9 +238,8 @@ static void trs_res_mng_id_free(struct trs_core_ts_inst *ts_inst, int res_type, | |||
| 233 | 238 | ||
| 234 | if (ret != 0) { | 239 | if (ret != 0) { |
| 235 | 240 | ||
| 236 | - trs_warn( | 241 | + trs_warn("Free warn. (devid=%u; tsid=%u; res_type=%d; res_id=%u; flag=%u; ret=%d)\n", inst->devid, inst->tsid, |
| 237 | - "Free warn. (devid=%u; tsid=%u; res_type=%d; res_id=%u; flag=%u; ret=%d)\n", inst->devid, inst->tsid, | 242 | + res_type, res_id, flag, ret); |
| 238 | - res_type, res_id, flag, ret); | ||
| 239 | 243 | ||
| 240 | } | 244 | } |
| 241 | } | 245 | } |
| @@ -272,9 +276,8 @@ int trs_res_id_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 272 | if ((ret != -EOPNOTSUPP) && | 276 | if ((ret != -EOPNOTSUPP) && |
| 273 | (trs_get_proc_id_dfx_times(proc_ctx, inst->tsid, para->res_type) <= TRS_PROC_DFX_TIMES_MAX)) { | 277 | (trs_get_proc_id_dfx_times(proc_ctx, inst->tsid, para->res_type) <= TRS_PROC_DFX_TIMES_MAX)) { |
| 274 | if (para->res_type != TRS_NOTIFY) { | 278 | if (para->res_type != TRS_NOTIFY) { |
| 275 | - trs_err( | 279 | + trs_err("Alloc res id failed. (devid=%u; tsid=%u; id_type=%u; cur_id_num=%u; ret=%d)\n", inst->devid, |
| 276 | - "Alloc res id failed. (devid=%u; tsid=%u; id_type=%u; cur_id_num=%u; ret=%d)\n", inst->devid, | 280 | + inst->tsid, para->res_type, trs_get_proc_res_num(proc_ctx, inst->tsid, para->res_type), ret); |
| 277 | - inst->tsid, para->res_type, trs_get_proc_res_num(proc_ctx, inst->tsid, para->res_type), ret); | ||
| 278 | } | 281 | } |
| 279 | } | 282 | } |
| 280 | return ret; | 283 | return ret; |
| @@ -285,9 +288,8 @@ int trs_res_id_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 285 | ret = trs_res_notice_ts(ts_inst, 0, para->res_type, para->id); | 288 | ret = trs_res_notice_ts(ts_inst, 0, para->res_type, para->id); |
| 286 | if (ret != 0) { | 289 | if (ret != 0) { |
| 287 | trs_res_mng_id_free(ts_inst, para->res_type, para->flag, para->id); | 290 | trs_res_mng_id_free(ts_inst, para->res_type, para->flag, para->id); |
| 288 | - trs_err( | 291 | + trs_err("Notice ts failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, para->res_type, |
| 289 | - "Notice ts failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, para->res_type, | 292 | + ret); |
| 290 | - ret); | ||
| 291 | return ret; | 293 | return ret; |
| 292 | } | 294 | } |
| 293 | 295 | ||
| @@ -314,8 +316,8 @@ int trs_res_id_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_ | |||
| 314 | } | 316 | } |
| 315 | 317 | ||
| 316 | 318 | ||
| 317 | -static inline void trs_pack_stream_mem_attr( | 319 | +static inline void trs_pack_stream_mem_attr(struct trs_core_ts_inst *ts_inst, u64 addr, u64 size, |
| 318 | - struct trs_core_ts_inst *ts_inst, u64 addr, u64 size, struct ka_mem_attr *stream_mem_attr) | 320 | + struct ka_mem_attr *stream_mem_attr) |
| 319 | { | 321 | { |
| 320 | stream_mem_attr->addr = addr; | 322 | stream_mem_attr->addr = addr; |
| 321 | stream_mem_attr->size = size; | 323 | stream_mem_attr->size = size; |
| @@ -335,8 +337,8 @@ static inline void trs_pack_stream_mem_attr( | |||
| 335 | } | 337 | } |
| 336 | } | 338 | } |
| 337 | 339 | ||
| 338 | -void trs_stream_put_mem_pa_list( | 340 | +void trs_stream_put_mem_pa_list(struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, |
| 339 | - struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, struct trs_stream_ctx *stream_ctx) | 341 | + struct trs_stream_ctx *stream_ctx) |
| 340 | { | 342 | { |
| 341 | struct ka_pa_wraper pa_wraper = {.pa = stream_ctx->pa_list[0], .size = stream_ctx->size}; | 343 | struct ka_pa_wraper pa_wraper = {.pa = stream_ctx->pa_list[0], .size = stream_ctx->size}; |
| 342 | struct ka_mem_attr stream_mem_attr = {0}; | 344 | struct ka_mem_attr stream_mem_attr = {0}; |
| @@ -392,8 +394,8 @@ int trs_res_id_pre_del(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *t | |||
| 392 | return 0; | 394 | return 0; |
| 393 | } | 395 | } |
| 394 | 396 | ||
| 395 | -static int _trs_res_id_free( | 397 | +static int _trs_res_id_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u64 flag, |
| 396 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u64 flag, u32 res_id) | 398 | + u32 res_id) |
| 397 | { | 399 | { |
| 398 | int ret; | 400 | int ret; |
| 399 | 401 | ||
| @@ -422,9 +424,8 @@ int trs_res_id_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_i | |||
| 422 | 424 | ||
| 423 | 425 | ||
| 424 | 426 | ||
| 425 | -int trs_stream_get_mem_pa_list( | 427 | +int trs_stream_get_mem_pa_list(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 426 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_stream_ctx *stream_ctx, | 428 | + struct trs_stream_ctx *stream_ctx, void *stream_mem, u32 depth) |
| 427 | - void *stream_mem, u32 depth) | ||
| 428 | { | 429 | { |
| 429 | struct ka_pa_wraper pa_wraper = {0}; | 430 | struct ka_pa_wraper pa_wraper = {0}; |
| 430 | struct ka_mem_attr stream_mem_attr = {0}; | 431 | struct ka_mem_attr stream_mem_attr = {0}; |
| @@ -458,9 +459,8 @@ int trs_stream_get_mem_pa_list( | |||
| 458 | trs_pack_stream_mem_attr(ts_inst, base_va, align_len, &stream_mem_attr); | 459 | trs_pack_stream_mem_attr(ts_inst, base_va, align_len, &stream_mem_attr); |
| 459 | ret = hal_kernel_get_mem_pa_list(proc_ctx->devid, proc_ctx->pid, &stream_mem_attr, &pa_num, &pa_wraper); | 460 | ret = hal_kernel_get_mem_pa_list(proc_ctx->devid, proc_ctx->pid, &stream_mem_attr, &pa_num, &pa_wraper); |
| 460 | if (ret != 0) { | 461 | if (ret != 0) { |
| 461 | - trs_err( | 462 | + trs_err("Failed to get pa list. (ret=%d; devid=%u; pid=%d; align_len=%u;)\n", ret, proc_ctx->devid, |
| 462 | - "Failed to get pa list. (ret=%d; devid=%u; pid=%d; align_len=%u;)\n", ret, proc_ctx->devid, proc_ctx->pid, | 463 | + proc_ctx->pid, align_len); |
| 463 | - align_len); | ||
| 464 | goto free_mem; | 464 | goto free_mem; |
| 465 | } | 465 | } |
| 466 | 466 | ||
| @@ -497,24 +497,22 @@ free_mem: | |||
| 497 | return ret; | 497 | return ret; |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | -static int trs_stream_task_fill_proc_mem_check( | 500 | +static int trs_stream_task_fill_proc_mem_check(struct trs_core_ts_inst *ts_inst, struct trs_stream_task_para *para, |
| 501 | - struct trs_core_ts_inst *ts_inst, struct trs_stream_task_para *para, struct trs_stream_ctx *stream_ctx) | 501 | + struct trs_stream_ctx *stream_ctx) |
| 502 | { | 502 | { |
| 503 | if ((uda_get_chip_type(ts_inst->inst.devid) == HISI_CLOUD_V2)) { | 503 | if ((uda_get_chip_type(ts_inst->inst.devid) == HISI_CLOUD_V2)) { |
| 504 | if (((para->stream_mem != NULL) && (stream_ctx->stream_base_addr != (u64)(uintptr_t)para->stream_mem)) || | 504 | if (((para->stream_mem != NULL) && (stream_ctx->stream_base_addr != (u64)(uintptr_t)para->stream_mem)) || |
| 505 | (stream_ctx->stream_kva == 0)) { | 505 | (stream_ctx->stream_kva == 0)) { |
| 506 | - trs_err( | 506 | + trs_err("Stream mem invalid or kva not inited. (base=0x%llx; mem=0x%llx)\n", stream_ctx->stream_base_addr, |
| 507 | - "Stream mem invalid or kva not inited. (base=0x%llx; mem=0x%llx)\n", stream_ctx->stream_base_addr, | 507 | + (u64)(uintptr_t)para->stream_mem); |
| 508 | - (u64)(uintptr_t)para->stream_mem); | ||
| 509 | return -EINVAL; | 508 | return -EINVAL; |
| 510 | } | 509 | } |
| 511 | } else { | 510 | } else { |
| 512 | if ((stream_ctx->stream_base_addr > (u64)(uintptr_t)para->stream_mem) || | 511 | if ((stream_ctx->stream_base_addr > (u64)(uintptr_t)para->stream_mem) || |
| 513 | ((u64)(uintptr_t)para->stream_mem > (stream_ctx->stream_base_addr + stream_ctx->tail * TRS_HW_SQE_SIZE)) || | 512 | ((u64)(uintptr_t)para->stream_mem > (stream_ctx->stream_base_addr + stream_ctx->tail * TRS_HW_SQE_SIZE)) || |
| 514 | (stream_ctx->stream_kva == 0)) { | 513 | (stream_ctx->stream_kva == 0)) { |
| 515 | - trs_err( | 514 | + trs_err("Stream mem invalid or kva not inited. (base=0x%llx; mem=0x%llx; tail=%u)\n", |
| 516 | - "Stream mem invalid or kva not inited. (base=0x%llx; mem=0x%llx; tail=%u)\n", | 515 | + stream_ctx->stream_base_addr, (u64)(uintptr_t)para->stream_mem, stream_ctx->tail); |
| 517 | - stream_ctx->stream_base_addr, (u64)(uintptr_t)para->stream_mem, stream_ctx->tail); | ||
| 518 | return -EINVAL; | 516 | return -EINVAL; |
| 519 | } | 517 | } |
| 520 | } | 518 | } |
| @@ -522,8 +520,8 @@ static int trs_stream_task_fill_proc_mem_check( | |||
| 522 | return 0; | 520 | return 0; |
| 523 | } | 521 | } |
| 524 | 522 | ||
| 525 | -int trs_stream_task_fill_proc( | 523 | +int trs_stream_task_fill_proc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 526 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_stream_task_para *para) | 524 | + struct trs_stream_task_para *para) |
| 527 | { | 525 | { |
| 528 | struct trs_stream_ctx *stream_ctx = NULL; | 526 | struct trs_stream_ctx *stream_ctx = NULL; |
| 529 | unsigned long cur_jiffies; | 527 | unsigned long cur_jiffies; |
| @@ -558,26 +556,24 @@ int trs_stream_task_fill_proc( | |||
| 558 | tail_tmp = stream_ctx->tail + para->task_cnt; | 556 | tail_tmp = stream_ctx->tail + para->task_cnt; |
| 559 | } else { | 557 | } else { |
| 560 | task_addr = stream_ctx->stream_kva + (u64)(uintptr_t)para->stream_mem - stream_ctx->stream_uva; | 558 | task_addr = stream_ctx->stream_kva + (u64)(uintptr_t)para->stream_mem - stream_ctx->stream_uva; |
| 561 | - tail_tmp = | 559 | + tail_tmp = ka_base_max((task_addr - stream_ctx->stream_kva) / TRS_HW_SQE_SIZE + para->task_cnt, |
| 562 | - ka_base_max((task_addr - stream_ctx->stream_kva) / TRS_HW_SQE_SIZE + para->task_cnt, (u64)stream_ctx->tail); | 560 | + (u64)stream_ctx->tail); |
| 563 | } | 561 | } |
| 564 | 562 | ||
| 565 | if ((task_addr + para->task_cnt * TRS_HW_SQE_SIZE) > (stream_ctx->stream_kva + stream_ctx->size)) { | 563 | if ((task_addr + para->task_cnt * TRS_HW_SQE_SIZE) > (stream_ctx->stream_kva + stream_ctx->size)) { |
| 566 | - trs_err( | 564 | + trs_err("Failed to get pa list. (devid=%u; stream=%u; tail=%u; task_cnt=%u)\n", proc_ctx->devid, |
| 567 | - "Failed to get pa list. (devid=%u; stream=%u; tail=%u; task_cnt=%u)\n", proc_ctx->devid, para->stream_id, | 565 | + para->stream_id, stream_ctx->tail, para->task_cnt); |
| 568 | - stream_ctx->tail, para->task_cnt); | ||
| 569 | ret = -ENOSPC; | 566 | ret = -ENOSPC; |
| 570 | goto put_mem; | 567 | goto put_mem; |
| 571 | } | 568 | } |
| 572 | 569 | ||
| 573 | cur_jiffies = ka_jiffies; | 570 | cur_jiffies = ka_jiffies; |
| 574 | for (i = 0; i < para->task_cnt; i++) { | 571 | for (i = 0; i < para->task_cnt; i++) { |
| 575 | - ret = trs_chan_stream_task_update( | 572 | + ret = trs_chan_stream_task_update(&ts_inst->inst, proc_ctx->pid, (para->task_info + i * TRS_HW_SQE_SIZE), |
| 576 | - &ts_inst->inst, proc_ctx->pid, (para->task_info + i * TRS_HW_SQE_SIZE), &stream_ctx->long_task_cnt); | 573 | + &stream_ctx->long_task_cnt); |
| 577 | if (ret != 0) { | 574 | if (ret != 0) { |
| 578 | - trs_err( | 575 | + trs_err("Update stream task fail. (devid=%u; i=%u; task_cnt=%u; ret=%d)\n", proc_ctx->devid, i, |
| 579 | - "Update stream task fail. (devid=%u; i=%u; task_cnt=%u; ret=%d)\n", proc_ctx->devid, i, para->task_cnt, | 576 | + para->task_cnt, ret); |
| 580 | - ret); | ||
| 581 | goto put_mem; | 577 | goto put_mem; |
| 582 | } | 578 | } |
| 583 | trs_try_resched(&cur_jiffies, 50); /* timeout is 50 ms */ | 579 | trs_try_resched(&cur_jiffies, 50); /* timeout is 50 ms */ |
| @@ -586,9 +582,8 @@ int trs_stream_task_fill_proc( | |||
| 586 | ka_mm_memcpy_toio((void *)(uintptr_t)task_addr, para->task_info, para->task_cnt * TRS_HW_SQE_SIZE); | 582 | ka_mm_memcpy_toio((void *)(uintptr_t)task_addr, para->task_info, para->task_cnt * TRS_HW_SQE_SIZE); |
| 587 | 583 | ||
| 588 | stream_ctx->tail = tail_tmp; | 584 | stream_ctx->tail = tail_tmp; |
| 589 | - trs_debug( | 585 | + trs_debug("Fill stream task success. (devid=%u; stream_id=%u; task_cnt=%u; tail=%u)\n", proc_ctx->devid, |
| 590 | - "Fill stream task success. (devid=%u; stream_id=%u; task_cnt=%u; tail=%u)\n", proc_ctx->devid, para->stream_id, | 586 | + para->stream_id, para->task_cnt, stream_ctx->tail); |
| 591 | - para->task_cnt, stream_ctx->tail); | ||
| 592 | return 0; | 587 | return 0; |
| 593 | 588 | ||
| 594 | put_mem: | 589 | put_mem: |
| @@ -601,7 +596,10 @@ put_mem: | |||
| 601 | 596 | ||
| 602 | static trs_res_share_by_proc_ops_t shr_proc_ops[TRS_MAX_ID_TYPE]; | 597 | static trs_res_share_by_proc_ops_t shr_proc_ops[TRS_MAX_ID_TYPE]; |
| 603 | 598 | ||
| 604 | -void trs_res_share_proc_ops_register(int res_type, trs_res_share_by_proc_ops_t func) { shr_proc_ops[res_type] = func; } | 599 | +void trs_res_share_proc_ops_register(int res_type, trs_res_share_by_proc_ops_t func) |
| 600 | +{ | ||
| 601 | + shr_proc_ops[res_type] = func; | ||
| 602 | +} | ||
| 605 | KA_EXPORT_SYMBOL_GPL(trs_res_share_proc_ops_register); | 603 | KA_EXPORT_SYMBOL_GPL(trs_res_share_proc_ops_register); |
| 606 | 604 | ||
| 607 | bool trs_res_is_belong_to_proc(struct trs_id_inst *inst, int pid, int res_type, u32 res_id) | 605 | bool trs_res_is_belong_to_proc(struct trs_id_inst *inst, int pid, int res_type, u32 res_id) |
| @@ -754,14 +752,12 @@ int trs_res_id_used_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 754 | if (ret == 0) { | 752 | if (ret == 0) { |
| 755 | para->para += query_para.alloc_num; | 753 | para->para += query_para.alloc_num; |
| 756 | } else if (ret != -EOPNOTSUPP) { | 754 | } else if (ret != -EOPNOTSUPP) { |
| 757 | - trs_err( | 755 | + trs_err("Failed to query resource number. (ret=%d; devid=%u; type=%d)\n", ret, ts_inst->inst.devid, |
| 758 | - "Failed to query resource number. (ret=%d; devid=%u; type=%d)\n", ret, ts_inst->inst.devid, | 756 | + para->res_type); |
| 759 | - para->res_type); | ||
| 760 | return ret; | 757 | return ret; |
| 761 | } | 758 | } |
| 762 | - trs_debug( | 759 | + trs_debug("Query from remote. (devid=%u; type=%d; device_alloc_num=%u; alloc_num=%u)\n", ts_inst->inst.devid, |
| 763 | - "Query from remote. (devid=%u; type=%d; device_alloc_num=%u; alloc_num=%u)\n", ts_inst->inst.devid, | 760 | + para->res_type, query_para.alloc_num, para->para); |
| 764 | - para->res_type, query_para.alloc_num, para->para); | ||
| 765 | } | 761 | } |
| 766 | 762 | ||
| 767 | if (!trs_is_stars_inst(ts_inst)) { | 763 | if (!trs_is_stars_inst(ts_inst)) { |
| @@ -784,8 +780,8 @@ int trs_res_id_used_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 784 | return 0; | 780 | return 0; |
| 785 | } | 781 | } |
| 786 | 782 | ||
| 787 | -int trs_res_id_avail_query( | 783 | +int trs_res_id_avail_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 788 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) | 784 | + struct trs_res_id_para *para) |
| 789 | { | 785 | { |
| 790 | int type = trs_res_get_id_type(&ts_inst->inst, para->res_type); | 786 | int type = trs_res_get_id_type(&ts_inst->inst, para->res_type); |
| 791 | int ret; | 787 | int ret; |
| @@ -799,8 +795,8 @@ int trs_res_id_avail_query( | |||
| 799 | return 0; | 795 | return 0; |
| 800 | } | 796 | } |
| 801 | 797 | ||
| 802 | -int trs_res_id_reg_offset_query( | 798 | +int trs_res_id_reg_offset_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 803 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) | 799 | + struct trs_res_id_para *para) |
| 804 | { | 800 | { |
| 805 | (void)proc_ctx; | 801 | (void)proc_ctx; |
| 806 | 802 | ||
| @@ -813,12 +809,12 @@ int trs_res_id_reg_offset_query( | |||
| 813 | if (ts_inst->ops.get_res_reg_offset == NULL) { | 809 | if (ts_inst->ops.get_res_reg_offset == NULL) { |
| 814 | return -EOPNOTSUPP; | 810 | return -EOPNOTSUPP; |
| 815 | } | 811 | } |
| 816 | - return ts_inst->ops.get_res_reg_offset( | 812 | + return ts_inst->ops.get_res_reg_offset(&ts_inst->inst, trs_res_get_id_type(&ts_inst->inst, para->res_type), |
| 817 | - &ts_inst->inst, trs_res_get_id_type(&ts_inst->inst, para->res_type), para->id, ¶->para); | 813 | + para->id, ¶->para); |
| 818 | } | 814 | } |
| 819 | 815 | ||
| 820 | -int trs_res_id_reg_size_query( | 816 | +int trs_res_id_reg_size_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 821 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) | 817 | + struct trs_res_id_para *para) |
| 822 | { | 818 | { |
| 823 | (void)proc_ctx; | 819 | (void)proc_ctx; |
| 824 | 820 | ||
| @@ -830,8 +826,8 @@ int trs_res_id_reg_size_query( | |||
| 830 | if (ts_inst->ops.get_res_reg_total_size == NULL) { | 826 | if (ts_inst->ops.get_res_reg_total_size == NULL) { |
| 831 | return -EOPNOTSUPP; | 827 | return -EOPNOTSUPP; |
| 832 | } | 828 | } |
| 833 | - return ts_inst->ops.get_res_reg_total_size( | 829 | + return ts_inst->ops.get_res_reg_total_size(&ts_inst->inst, trs_res_get_id_type(&ts_inst->inst, para->res_type), |
| 834 | - &ts_inst->inst, trs_res_get_id_type(&ts_inst->inst, para->res_type), ¶->para); | 830 | + ¶->para); |
| 835 | } | 831 | } |
| 836 | 832 | ||
| 837 | int trs_get_stream_logic_cq(struct trs_core_ts_inst *ts_inst, u32 stream_id) | 833 | int trs_get_stream_logic_cq(struct trs_core_ts_inst *ts_inst, u32 stream_id) |
| @@ -845,23 +841,21 @@ int trs_get_stream_logic_cq(struct trs_core_ts_inst *ts_inst, u32 stream_id) | |||
| 845 | return ts_inst->stream_ctx[stream_id].logic_cq; | 841 | return ts_inst->stream_ctx[stream_id].logic_cq; |
| 846 | } | 842 | } |
| 847 | 843 | ||
| 848 | -static int trs_stream_bind_logic_cq( | 844 | +static int trs_stream_bind_logic_cq(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, |
| 849 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, u32 logic_cq) | 845 | + u32 logic_cq) |
| 850 | { | 846 | { |
| 851 | struct trs_stream_ctx *stream_ctx = &ts_inst->stream_ctx[stream_id]; | 847 | struct trs_stream_ctx *stream_ctx = &ts_inst->stream_ctx[stream_id]; |
| 852 | struct trs_id_inst *inst = &ts_inst->inst; | 848 | struct trs_id_inst *inst = &ts_inst->inst; |
| 853 | 849 | ||
| 854 | if (!trs_proc_has_res(proc_ctx, ts_inst, TRS_LOGIC_CQ, logic_cq)) { | 850 | if (!trs_proc_has_res(proc_ctx, ts_inst, TRS_LOGIC_CQ, logic_cq)) { |
| 855 | - trs_err( | 851 | + trs_err("Logic cq not belong to proc. (devid=%u; tsid=%u; stream_id=%u; logic_cq=%u)\n", inst->devid, |
| 856 | - "Logic cq not belong to proc. (devid=%u; tsid=%u; stream_id=%u; logic_cq=%u)\n", inst->devid, inst->tsid, | 852 | + inst->tsid, stream_id, logic_cq); |
| 857 | - stream_id, logic_cq); | ||
| 858 | return -EINVAL; | 853 | return -EINVAL; |
| 859 | } | 854 | } |
| 860 | 855 | ||
| 861 | if ((stream_ctx->logic_cq >= 0) && (stream_ctx->logic_cq != logic_cq)) { | 856 | if ((stream_ctx->logic_cq >= 0) && (stream_ctx->logic_cq != logic_cq)) { |
| 862 | - trs_info( | 857 | + trs_info("Stream Bind new logic cq. (devid=%u; tsid=%u; stream_id=%u; logic_cq=%u; new_logic_cq=%u)\n", |
| 863 | - "Stream Bind new logic cq. (devid=%u; tsid=%u; stream_id=%u; logic_cq=%u; new_logic_cq=%u)\n", inst->devid, | 858 | + inst->devid, inst->tsid, stream_id, stream_ctx->logic_cq, logic_cq); |
| 864 | - inst->tsid, stream_id, stream_ctx->logic_cq, logic_cq); | ||
| 865 | } | 859 | } |
| 866 | 860 | ||
| 867 | stream_ctx->logic_cq = (int)logic_cq; | 861 | stream_ctx->logic_cq = (int)logic_cq; |
| @@ -899,8 +893,8 @@ static int trs_stream_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 899 | return ret; | 893 | return ret; |
| 900 | } | 894 | } |
| 901 | 895 | ||
| 902 | -static int trs_set_res_id_ctrl( | 896 | +static int trs_set_res_id_ctrl(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 type, u32 id, |
| 903 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 type, u32 id, u32 cmd) | 897 | + u32 cmd) |
| 904 | { | 898 | { |
| 905 | struct trs_id_inst *inst = &ts_inst->inst; | 899 | struct trs_id_inst *inst = &ts_inst->inst; |
| 906 | int ret; | 900 | int ret; |
| @@ -912,9 +906,8 @@ static int trs_set_res_id_ctrl( | |||
| 912 | 906 | ||
| 913 | ret = ts_inst->ops.res_id_ctrl(inst, type, id, cmd); | 907 | ret = ts_inst->ops.res_id_ctrl(inst, type, id, cmd); |
| 914 | if ((ret != 0) && (ret != -EOPNOTSUPP)) { | 908 | if ((ret != 0) && (ret != -EOPNOTSUPP)) { |
| 915 | - trs_err( | 909 | + trs_err("Set id ctrl failed. (devid=%u; tsid=%u; type=%u; id=%u; cmd=%u; ret=%d)\n", inst->devid, inst->tsid, |
| 916 | - "Set id ctrl failed. (devid=%u; tsid=%u; type=%u; id=%u; cmd=%u; ret=%d)\n", inst->devid, inst->tsid, type, | 910 | + type, id, cmd, ret); |
| 917 | - id, cmd, ret); | ||
| 918 | } | 911 | } |
| 919 | 912 | ||
| 920 | return ret; | 913 | return ret; |
| @@ -937,8 +930,8 @@ static int trs_set_res_id_ctrl_of_proc(struct trs_proc_ctx *proc_ctx, struct trs | |||
| 937 | return ret; | 930 | return ret; |
| 938 | } | 931 | } |
| 939 | 932 | ||
| 940 | -static int trs_res_id_ctrl_comm( | 933 | +static int trs_res_id_ctrl_comm(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 941 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) | 934 | + struct trs_res_id_para *para) |
| 942 | { | 935 | { |
| 943 | struct trs_id_inst *inst = &ts_inst->inst; | 936 | struct trs_id_inst *inst = &ts_inst->inst; |
| 944 | enum trs_id_type res_type = (enum trs_id_type)para->res_type; | 937 | enum trs_id_type res_type = (enum trs_id_type)para->res_type; |
| @@ -951,9 +944,8 @@ static int trs_res_id_ctrl_comm( | |||
| 951 | 944 | ||
| 952 | ret = trs_res_id_get(inst, res_type, res_id); | 945 | ret = trs_res_id_get(inst, res_type, res_id); |
| 953 | if (ret != 0) { | 946 | if (ret != 0) { |
| 954 | - trs_err( | 947 | + trs_err("Id not belong to proc. (devid=%u; tsid=%u; res_type=%d; res_id=%u)\n", inst->devid, inst->tsid, |
| 955 | - "Id not belong to proc. (devid=%u; tsid=%u; res_type=%d; res_id=%u)\n", inst->devid, inst->tsid, res_type, | 948 | + res_type, res_id); |
| 956 | - res_id); | ||
| 957 | return -EINVAL; | 949 | return -EINVAL; |
| 958 | } | 950 | } |
| 959 | 951 | ||
| @@ -975,8 +967,8 @@ static int trs_notify_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 975 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); | 967 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); |
| 976 | } | 968 | } |
| 977 | 969 | ||
| 978 | -static int trs_cnt_notify_cfg( | 970 | +static int trs_cnt_notify_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 979 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) | 971 | + struct trs_res_id_para *para) |
| 980 | { | 972 | { |
| 981 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); | 973 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); |
| 982 | } | 974 | } |
| @@ -986,8 +978,9 @@ static int trs_event_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst | |||
| 986 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); | 978 | return trs_res_id_ctrl_comm(proc_ctx, ts_inst, para); |
| 987 | } | 979 | } |
| 988 | 980 | ||
| 989 | -static int (*const trs_res_id_cfg_handles[TRS_MAX_ID_TYPE])( | 981 | +static int (*const trs_res_id_cfg_handles[TRS_MAX_ID_TYPE])(struct trs_proc_ctx *proc_ctx, |
| 990 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para) = { | 982 | + struct trs_core_ts_inst *ts_inst, |
| 983 | + struct trs_res_id_para *para) = { | ||
| 991 | [TRS_STREAM] = trs_stream_cfg, | 984 | [TRS_STREAM] = trs_stream_cfg, |
| 992 | [TRS_EVENT] = trs_event_cfg, | 985 | [TRS_EVENT] = trs_event_cfg, |
| 993 | [TRS_NOTIFY] = trs_notify_cfg, | 986 | [TRS_NOTIFY] = trs_notify_cfg, |
| @@ -1025,9 +1018,8 @@ static int trs_stream_id_ctrl(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_ | |||
| 1025 | 1018 | ||
| 1026 | if (!trs_proc_has_res(proc_ctx, ts_inst, TRS_STREAM, stream_id)) { | 1019 | if (!trs_proc_has_res(proc_ctx, ts_inst, TRS_STREAM, stream_id)) { |
| 1027 | if (!trs_is_host_pid_match(proc_ctx->pid, stream_ctx->host_pid)) { | 1020 | if (!trs_is_host_pid_match(proc_ctx->pid, stream_ctx->host_pid)) { |
| 1028 | - trs_err( | 1021 | + trs_err("Stream not belong to proc. (devid=%u; tsid=%u; stream_id=%u; pid=%d)\n", inst->devid, inst->tsid, |
| 1029 | - "Stream not belong to proc. (devid=%u; tsid=%u; stream_id=%u; pid=%d)\n", inst->devid, inst->tsid, | 1022 | + stream_id, stream_ctx->host_pid); |
| 1030 | - stream_id, stream_ctx->host_pid); | ||
| 1031 | return -EINVAL; | 1023 | return -EINVAL; |
| 1032 | } | 1024 | } |
| 1033 | } | 1025 | } |
| @@ -1083,8 +1075,8 @@ void trs_sqcq_reg_map(struct trs_core_ts_inst *ts_inst, struct trs_sqcq_reg_map_ | |||
| 1083 | { | 1075 | { |
| 1084 | struct trs_res_mng *res_mng = &ts_inst->res_mng[TRS_STREAM]; | 1076 | struct trs_res_mng *res_mng = &ts_inst->res_mng[TRS_STREAM]; |
| 1085 | if (ts_inst->ops.sqcq_reg_map != NULL) { | 1077 | if (ts_inst->ops.sqcq_reg_map != NULL) { |
| 1086 | - ts_inst->sq_ctx[para->sqid].reg_mem.cp_proc_state = | 1078 | + ts_inst->sq_ctx[para->sqid].reg_mem.cp_proc_state = (ts_inst->ops.sqcq_reg_map(&ts_inst->inst, para) == 0) ? 0 : |
| 1087 | - (ts_inst->ops.sqcq_reg_map(&ts_inst->inst, para) == 0) ? 0 : 1; | 1079 | + 1; |
| 1088 | } | 1080 | } |
| 1089 | if (para->stream_id < res_mng->max_id) { | 1081 | if (para->stream_id < res_mng->max_id) { |
| 1090 | trs_stream_set_bind_sqcq(ts_inst, para->stream_id, para->sqid, para->cqid, para->host_pid); | 1082 | trs_stream_set_bind_sqcq(ts_inst, para->stream_id, para->sqid, para->cqid, para->host_pid); |
| @@ -1123,9 +1115,8 @@ int trs_stream_bind_remote_sqcq(struct trs_id_inst *inst, u32 stream_id, u32 sqi | |||
| 1123 | 1115 | ||
| 1124 | if (stream_id >= trs_res_get_max_id(ts_inst, TRS_STREAM)) { | 1116 | if (stream_id >= trs_res_get_max_id(ts_inst, TRS_STREAM)) { |
| 1125 | trs_core_ts_inst_put(ts_inst); | 1117 | trs_core_ts_inst_put(ts_inst); |
| 1126 | - trs_err( | 1118 | + trs_err("Invalid para. (devid=%u; tsid=%u; stream_id=%u; sqid=%u; cqid=%u; host_pid=%d)\n", inst->devid, |
| 1127 | - "Invalid para. (devid=%u; tsid=%u; stream_id=%u; sqid=%u; cqid=%u; host_pid=%d)\n", inst->devid, inst->tsid, | 1119 | + inst->tsid, stream_id, sqid, cqid, host_pid); |
| 1128 | - stream_id, sqid, cqid, host_pid); | ||
| 1129 | return -EINVAL; | 1120 | return -EINVAL; |
| 1130 | } | 1121 | } |
| 1131 | 1122 | ||
| @@ -1135,15 +1126,15 @@ int trs_stream_bind_remote_sqcq(struct trs_id_inst *inst, u32 stream_id, u32 sqi | |||
| 1135 | } | 1126 | } |
| 1136 | KA_EXPORT_SYMBOL_GPL(trs_stream_bind_remote_sqcq); | 1127 | KA_EXPORT_SYMBOL_GPL(trs_stream_bind_remote_sqcq); |
| 1137 | 1128 | ||
| 1138 | -int trs_get_stream_ctx( | 1129 | +int trs_get_stream_ctx(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, |
| 1139 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, struct trs_stream_ctx *stm_ctx) | 1130 | + struct trs_stream_ctx *stm_ctx) |
| 1140 | { | 1131 | { |
| 1141 | struct trs_id_inst *inst = &ts_inst->inst; | 1132 | struct trs_id_inst *inst = &ts_inst->inst; |
| 1142 | struct trs_stream_ctx *stream_ctx = NULL; | 1133 | struct trs_stream_ctx *stream_ctx = NULL; |
| 1143 | 1134 | ||
| 1144 | if (trs_proc_has_res(proc_ctx, ts_inst, TRS_STREAM, stream_id) == false) { | 1135 | if (trs_proc_has_res(proc_ctx, ts_inst, TRS_STREAM, stream_id) == false) { |
| 1145 | - trs_err( | 1136 | + trs_err("Stream is not belong to proc. (devid=%u; tsid=%u; stream_id=%u)\n", inst->devid, inst->tsid, |
| 1146 | - "Stream is not belong to proc. (devid=%u; tsid=%u; stream_id=%u)\n", inst->devid, inst->tsid, stream_id); | 1137 | + stream_id); |
| 1147 | return -EINVAL; | 1138 | return -EINVAL; |
| 1148 | } | 1139 | } |
| 1149 | 1140 | ||
| @@ -1169,9 +1160,8 @@ static int trs_res_stream_init(struct trs_core_ts_inst *ts_inst) | |||
| 1169 | 1160 | ||
| 1170 | stream_ctx = (struct trs_stream_ctx *)trs_vzalloc(sizeof(struct trs_stream_ctx) * stream_num); | 1161 | stream_ctx = (struct trs_stream_ctx *)trs_vzalloc(sizeof(struct trs_stream_ctx) * stream_num); |
| 1171 | if (stream_ctx == NULL) { | 1162 | if (stream_ctx == NULL) { |
| 1172 | - trs_err( | 1163 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 1173 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 1164 | + sizeof(struct trs_stream_ctx) * stream_num); |
| 1174 | - sizeof(struct trs_stream_ctx) * stream_num); | ||
| 1175 | return -ENOMEM; | 1165 | return -ENOMEM; |
| 1176 | } | 1166 | } |
| 1177 | 1167 | ||
| @@ -1207,17 +1197,15 @@ static int trs_res_id_init(struct trs_core_ts_inst *ts_inst, struct trs_res_mng | |||
| 1207 | if (res_mng->id_num > 0) { | 1197 | if (res_mng->id_num > 0) { |
| 1208 | ret = trs_id_get_max_id(inst, id_type, &res_mng->max_id); | 1198 | ret = trs_id_get_max_id(inst, id_type, &res_mng->max_id); |
| 1209 | if (ret != 0) { | 1199 | if (ret != 0) { |
| 1210 | - trs_err( | 1200 | + trs_err("Get max id failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, res_type, |
| 1211 | - "Get max id failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, res_type, | 1201 | + ret); |
| 1212 | - ret); | ||
| 1213 | return ret; | 1202 | return ret; |
| 1214 | } | 1203 | } |
| 1215 | 1204 | ||
| 1216 | res_mng->ids = (struct trs_res_ids *)trs_vzalloc(sizeof(struct trs_res_ids) * res_mng->max_id); | 1205 | res_mng->ids = (struct trs_res_ids *)trs_vzalloc(sizeof(struct trs_res_ids) * res_mng->max_id); |
| 1217 | if (res_mng->ids == NULL) { | 1206 | if (res_mng->ids == NULL) { |
| 1218 | - trs_err( | 1207 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; res_type=%d; size=%lx)\n", inst->devid, inst->tsid, res_type, |
| 1219 | - "Mem alloc failed. (devid=%u; tsid=%u; res_type=%d; size=%lx)\n", inst->devid, inst->tsid, res_type, | 1208 | + sizeof(struct trs_res_ids) * res_mng->max_id); |
| 1220 | - sizeof(struct trs_res_ids) * res_mng->max_id); | ||
| 1221 | return -ENOMEM; | 1209 | return -ENOMEM; |
| 1222 | } | 1210 | } |
| 1223 | } | 1211 | } |
| @@ -63,24 +63,23 @@ u32 trs_res_get_id_used_num(struct trs_core_ts_inst *ts_inst, int res_type); | |||
| 63 | void trs_sqcq_reg_map(struct trs_core_ts_inst *ts_inst, struct trs_sqcq_reg_map_para *para); | 63 | void trs_sqcq_reg_map(struct trs_core_ts_inst *ts_inst, struct trs_sqcq_reg_map_para *para); |
| 64 | void trs_sqcq_reg_unmap(struct trs_core_ts_inst *ts_inst, struct trs_sqcq_reg_map_para *para); | 64 | void trs_sqcq_reg_unmap(struct trs_core_ts_inst *ts_inst, struct trs_sqcq_reg_map_para *para); |
| 65 | void trs_stream_set_bind_sqcq(struct trs_core_ts_inst *ts_inst, u32 stream_id, u32 sqid, u32 cqid, int host_pid); | 65 | void trs_stream_set_bind_sqcq(struct trs_core_ts_inst *ts_inst, u32 stream_id, u32 sqid, u32 cqid, int host_pid); |
| 66 | -int trs_stream_task_fill_proc( | 66 | +int trs_stream_task_fill_proc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 67 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_stream_task_para *para); | 67 | + struct trs_stream_task_para *para); |
| 68 | -int trs_stream_get_mem_pa_list( | 68 | +int trs_stream_get_mem_pa_list(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 69 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_stream_ctx *stream_ctx, | 69 | + struct trs_stream_ctx *stream_ctx, void *stream_mem, u32 depth); |
| 70 | - void *stream_mem, u32 depth); | 70 | +void trs_stream_put_mem_pa_list(struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, |
| 71 | -void trs_stream_put_mem_pa_list( | 71 | + struct trs_stream_ctx *stream_ctx); |
| 72 | - struct trs_core_ts_inst *ts_inst, struct trs_proc_ctx *proc_ctx, struct trs_stream_ctx *stream_ctx); | ||
| 73 | int trs_res_id_pre_del(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); | 72 | int trs_res_id_pre_del(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, int res_type, u32 res_id); |
| 74 | int trs_res_id_num_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 73 | int trs_res_id_num_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); |
| 75 | int trs_res_id_max_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 74 | int trs_res_id_max_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); |
| 76 | -int trs_res_id_used_query( | 75 | +int trs_res_id_used_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 77 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 76 | + struct trs_res_id_para *para); |
| 78 | -int trs_res_id_avail_query( | 77 | +int trs_res_id_avail_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 79 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 78 | + struct trs_res_id_para *para); |
| 80 | -int trs_res_id_reg_offset_query( | 79 | +int trs_res_id_reg_offset_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 81 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 80 | + struct trs_res_id_para *para); |
| 82 | -int trs_res_id_reg_size_query( | 81 | +int trs_res_id_reg_size_query(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 83 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 82 | + struct trs_res_id_para *para); |
| 84 | int trs_res_id_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 83 | int trs_res_id_cfg(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); |
| 85 | int trs_res_id_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 84 | int trs_res_id_alloc(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); |
| 86 | int trs_res_id_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); | 85 | int trs_res_id_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_res_id_para *para); |
| @@ -92,8 +91,8 @@ int trs_get_stream_logic_cq(struct trs_core_ts_inst *ts_inst, u32 stream_id); | |||
| 92 | 91 | ||
| 93 | int trs_res_get_id_type(struct trs_id_inst *id_inst, int res_type); | 92 | int trs_res_get_id_type(struct trs_id_inst *id_inst, int res_type); |
| 94 | int trs_res_replace_res_type(struct trs_core_ts_inst *ts_inst, int res_type); | 93 | int trs_res_replace_res_type(struct trs_core_ts_inst *ts_inst, int res_type); |
| 95 | -int trs_get_stream_ctx( | 94 | +int trs_get_stream_ctx(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, |
| 96 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, u32 stream_id, struct trs_stream_ctx *stm_ctx); | 95 | + struct trs_stream_ctx *stm_ctx); |
| 97 | 96 | ||
| 98 | int trs_res_mng_init(struct trs_core_ts_inst *ts_inst); | 97 | int trs_res_mng_init(struct trs_core_ts_inst *ts_inst); |
| 99 | void trs_res_mng_uninit(struct trs_core_ts_inst *ts_inst); | 98 | void trs_res_mng_uninit(struct trs_core_ts_inst *ts_inst); |
| @@ -184,18 +184,17 @@ static int trs_shm_sqcq_alloc_para_check(struct trs_id_inst *inst, struct halSqC | |||
| 184 | if ((para->sqeSize != TRS_SHM_SQE_SIZE) || (para->sqeDepth != TRS_SHM_SQ_DEPTH) || | 184 | if ((para->sqeSize != TRS_SHM_SQE_SIZE) || (para->sqeDepth != TRS_SHM_SQ_DEPTH) || |
| 185 | (para->cqeSize != TRS_SHM_CQE_SIZE) || (para->cqeDepth != TRS_SHM_CQ_DEPTH) || | 185 | (para->cqeSize != TRS_SHM_CQE_SIZE) || (para->cqeDepth != TRS_SHM_CQ_DEPTH) || |
| 186 | (alloc_para->uio_info->sq_que_addr == 0)) { | 186 | (alloc_para->uio_info->sq_que_addr == 0)) { |
| 187 | - trs_err( | 187 | + trs_err("Invalid para. (devid=%u; tsid=%u; sqeDepth=%u; sqeSize=%u; cqeDepth=%u; cqeSize=%u; sq_addr=0x%pK)\n", |
| 188 | - "Invalid para. (devid=%u; tsid=%u; sqeDepth=%u; sqeSize=%u; cqeDepth=%u; cqeSize=%u; sq_addr=0x%pK)\n", | 188 | + inst->devid, inst->tsid, para->sqeDepth, para->sqeSize, para->cqeDepth, para->cqeSize, |
| 189 | - inst->devid, inst->tsid, para->sqeDepth, para->sqeSize, para->cqeDepth, para->cqeSize, | 189 | + (void *)(uintptr_t)alloc_para->uio_info->sq_que_addr); |
| 190 | - (void *)(uintptr_t)alloc_para->uio_info->sq_que_addr); | ||
| 191 | return -EINVAL; | 190 | return -EINVAL; |
| 192 | } | 191 | } |
| 193 | 192 | ||
| 194 | return 0; | 193 | return 0; |
| 195 | } | 194 | } |
| 196 | 195 | ||
| 197 | -static int trs_shm_sq_remap( | 196 | +static int trs_shm_sq_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 198 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 197 | + struct halSqCqInputInfo *para) |
| 199 | { | 198 | { |
| 200 | struct trs_id_inst *inst = &ts_inst->inst; | 199 | struct trs_id_inst *inst = &ts_inst->inst; |
| 201 | struct trs_proc_ts_ctx *ts_ctx = &proc_ctx->ts_ctx[inst->tsid]; | 200 | struct trs_proc_ts_ctx *ts_ctx = &proc_ctx->ts_ctx[inst->tsid]; |
| @@ -204,14 +203,12 @@ static int trs_shm_sq_remap( | |||
| 204 | struct trs_mem_map_para map_para; | 203 | struct trs_mem_map_para map_para; |
| 205 | int ret; | 204 | int ret; |
| 206 | 205 | ||
| 207 | - trs_remap_fill_para( | 206 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_RO_DEV_MEM, alloc_para->uio_info->sq_que_addr, shm_ctx->sq_pa, |
| 208 | - &map_para, TRS_MAP_TYPE_RO_DEV_MEM, alloc_para->uio_info->sq_que_addr, shm_ctx->sq_pa, | 207 | + KA_MM_PAGE_ALIGN(para->sqeDepth * para->sqeSize)); |
| 209 | - KA_MM_PAGE_ALIGN(para->sqeDepth * para->sqeSize)); | ||
| 210 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); | 208 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); |
| 211 | if (ret != 0) { | 209 | if (ret != 0) { |
| 212 | - trs_err( | 210 | + trs_err("Remap sq failed. (devid=%u; tsid=%u; sqid=%u; va=%lx)\n", inst->devid, inst->tsid, para->sqId, |
| 213 | - "Remap sq failed. (devid=%u; tsid=%u; sqid=%u; va=%lx)\n", inst->devid, inst->tsid, para->sqId, | 211 | + alloc_para->uio_info->sq_que_addr); |
| 214 | - alloc_para->uio_info->sq_que_addr); | ||
| 215 | return ret; | 212 | return ret; |
| 216 | } | 213 | } |
| 217 | 214 | ||
| @@ -230,8 +227,8 @@ static void trs_shm_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_i | |||
| 230 | (void)trs_unmap_sq(proc_ctx, ts_inst, &unmap_para); | 227 | (void)trs_unmap_sq(proc_ctx, ts_inst, &unmap_para); |
| 231 | } | 228 | } |
| 232 | 229 | ||
| 233 | -static int trs_shm_sqcq_alloc_notice_ts( | 230 | +static int trs_shm_sqcq_alloc_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 234 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para) | 231 | + struct halSqCqInputInfo *para) |
| 235 | { | 232 | { |
| 236 | struct trs_shm_ctx *shm_ctx = &ts_inst->shm_ctx; | 233 | struct trs_shm_ctx *shm_ctx = &ts_inst->shm_ctx; |
| 237 | struct trs_proc_shm_ctx *proc_shm_ctx = &proc_ctx->ts_ctx[ts_inst->inst.tsid].shm_ctx; | 234 | struct trs_proc_shm_ctx *proc_shm_ctx = &proc_ctx->ts_ctx[ts_inst->inst.tsid].shm_ctx; |
| @@ -266,8 +263,8 @@ static int trs_shm_sqcq_alloc_notice_ts( | |||
| 266 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); | 263 | return trs_core_notice_ts(ts_inst, (u8 *)&msg, sizeof(msg)); |
| 267 | } | 264 | } |
| 268 | 265 | ||
| 269 | -static int trs_shm_sqcq_free_notice_ts( | 266 | +static int trs_shm_sqcq_free_notice_ts(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 270 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 267 | + struct halSqCqFreeInfo *para) |
| 271 | { | 268 | { |
| 272 | struct trs_shm_sqcq_mbox msg; | 269 | struct trs_shm_sqcq_mbox msg; |
| 273 | 270 | ||
| @@ -345,9 +342,8 @@ int trs_shm_sqcq_free(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 345 | int ret; | 342 | int ret; |
| 346 | 343 | ||
| 347 | if ((shm_ctx->chan_id < 0) || (shm_ctx->sqid != para->sqId) || (proc_shm_ctx->cqid != para->cqId)) { | 344 | if ((shm_ctx->chan_id < 0) || (shm_ctx->sqid != para->sqId) || (proc_shm_ctx->cqid != para->cqId)) { |
| 348 | - trs_err( | 345 | + trs_err("Invalid para. (devid=%u; tsid=%u; sqid=%u; cqid=%u; chan_id=%u; shm_sqid=%u; shm_cqid=%u)\n", |
| 349 | - "Invalid para. (devid=%u; tsid=%u; sqid=%u; cqid=%u; chan_id=%u; shm_sqid=%u; shm_cqid=%u)\n", inst->devid, | 346 | + inst->devid, inst->tsid, para->sqId, para->cqId, shm_ctx->chan_id, shm_ctx->sqid, proc_shm_ctx->cqid); |
| 350 | - inst->tsid, para->sqId, para->cqId, shm_ctx->chan_id, shm_ctx->sqid, proc_shm_ctx->cqid); | ||
| 351 | return -EINVAL; | 347 | return -EINVAL; |
| 352 | } | 348 | } |
| 353 | 349 | ||
| @@ -72,7 +72,10 @@ void trs_shr_ctx_mng_release(struct kref_safe *kref) | |||
| 72 | 72 | ||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | -void trs_put_shr_ctx(struct trs_shr_ctx_mng *shr_ctx) { kref_safe_put(&shr_ctx->ref, trs_shr_ctx_mng_release); } | 75 | +void trs_put_shr_ctx(struct trs_shr_ctx_mng *shr_ctx) |
| 76 | +{ | ||
| 77 | + kref_safe_put(&shr_ctx->ref, trs_shr_ctx_mng_release); | ||
| 78 | +} | ||
| 76 | 79 | ||
| 77 | int trs_shr_ctx_mng_init(struct trs_id_inst *inst) | 80 | int trs_shr_ctx_mng_init(struct trs_id_inst *inst) |
| 78 | { | 81 | { |
| @@ -84,36 +87,32 @@ int trs_shr_ctx_mng_init(struct trs_id_inst *inst) | |||
| 84 | 87 | ||
| 85 | shr_ctx = trs_vzalloc(sizeof(struct trs_shr_ctx_mng)); | 88 | shr_ctx = trs_vzalloc(sizeof(struct trs_shr_ctx_mng)); |
| 86 | if (shr_ctx == NULL) { | 89 | if (shr_ctx == NULL) { |
| 87 | - trs_err( | 90 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 88 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 91 | + sizeof(struct trs_shr_ctx_mng)); |
| 89 | - sizeof(struct trs_shr_ctx_mng)); | ||
| 90 | return -ENOMEM; | 92 | return -ENOMEM; |
| 91 | } | 93 | } |
| 92 | 94 | ||
| 93 | ret = trs_id_get_max_id(inst, TRS_HW_SQ_ID, &sqid_max_num); | 95 | ret = trs_id_get_max_id(inst, TRS_HW_SQ_ID, &sqid_max_num); |
| 94 | if (ret != 0) { | 96 | if (ret != 0) { |
| 95 | trs_vfree(shr_ctx); | 97 | trs_vfree(shr_ctx); |
| 96 | - trs_err( | 98 | + trs_err("Get sq max id failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, |
| 97 | - "Get sq max id failed. (devid=%u; tsid=%u; res_type=%d; ret=%d)\n", inst->devid, inst->tsid, TRS_HW_SQ_ID, | 99 | + TRS_HW_SQ_ID, ret); |
| 98 | - ret); | ||
| 99 | return ret; | 100 | return ret; |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | shr_ctx->sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sqid_max_num); | 103 | shr_ctx->sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sqid_max_num); |
| 103 | if (shr_ctx->sq_ctx == NULL) { | 104 | if (shr_ctx->sq_ctx == NULL) { |
| 104 | trs_vfree(shr_ctx); | 105 | trs_vfree(shr_ctx); |
| 105 | - trs_err( | 106 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; res_type=%d; size=0x%lx)\n", inst->devid, inst->tsid, |
| 106 | - "Mem alloc failed. (devid=%u; tsid=%u; res_type=%d; size=0x%lx)\n", inst->devid, inst->tsid, TRS_HW_SQ_ID, | 107 | + TRS_HW_SQ_ID, sizeof(struct trs_sq_ctx) * sqid_max_num); |
| 107 | - sizeof(struct trs_sq_ctx) * sqid_max_num); | ||
| 108 | return -ENOMEM; | 108 | return -ENOMEM; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | kref_safe_init(&shr_ctx->ref); | 111 | kref_safe_init(&shr_ctx->ref); |
| 112 | shr_ctx_mng[ts_inst_id] = shr_ctx; | 112 | shr_ctx_mng[ts_inst_id] = shr_ctx; |
| 113 | 113 | ||
| 114 | - trs_info( | 114 | + trs_info("Shr init info. (devid=%u; tsid=%u; res_type=%d; size=%lx; num=%u)\n", inst->devid, inst->tsid, |
| 115 | - "Shr init info. (devid=%u; tsid=%u; res_type=%d; size=%lx; num=%u)\n", inst->devid, inst->tsid, TRS_HW_SQ_ID, | 115 | + TRS_HW_SQ_ID, sizeof(struct trs_sq_ctx) * sqid_max_num, sqid_max_num); |
| 116 | - sizeof(struct trs_sq_ctx) * sqid_max_num, sqid_max_num); | ||
| 117 | 116 | ||
| 118 | 117 | ||
| 119 | return 0; | 118 | return 0; |
| @@ -175,9 +174,15 @@ ka_task_struct_t *trs_shr_get_task_struct(ka_pid_t pid) | |||
| 175 | return NULL; | 174 | return NULL; |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | -void trs_shr_put_task_struct(ka_task_struct_t *tsk) { ka_task_put_task_struct(tsk); } | 177 | +void trs_shr_put_task_struct(ka_task_struct_t *tsk) |
| 178 | +{ | ||
| 179 | + ka_task_put_task_struct(tsk); | ||
| 180 | +} | ||
| 179 | 181 | ||
| 180 | -inline ka_rw_semaphore_t *trs_shr_get_mmap_sem(ka_mm_struct_t *mm) { return ka_mm_get_mmap_sem(mm); } | 182 | +inline ka_rw_semaphore_t *trs_shr_get_mmap_sem(ka_mm_struct_t *mm) |
| 183 | +{ | ||
| 184 | + return ka_mm_get_mmap_sem(mm); | ||
| 185 | +} | ||
| 181 | 186 | ||
| 182 | int trs_shr_unmap_sq(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_mem_unmap_para *para) | 187 | int trs_shr_unmap_sq(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_mem_unmap_para *para) |
| 183 | { | 188 | { |
| @@ -283,15 +288,15 @@ void trs_shr_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 283 | } | 288 | } |
| 284 | 289 | ||
| 285 | if (shr_sq_ctx->que_mem.uva != 0) { | 290 | if (shr_sq_ctx->que_mem.uva != 0) { |
| 286 | - trs_unmap_fill_para( | 291 | + trs_unmap_fill_para(&unmap_para, shr_sq_ctx->que_mem.mem_type, shr_sq_ctx->que_mem.uva, |
| 287 | - &unmap_para, shr_sq_ctx->que_mem.mem_type, shr_sq_ctx->que_mem.uva, shr_sq_ctx->que_mem.len); | 292 | + shr_sq_ctx->que_mem.len); |
| 288 | (void)trs_shr_unmap_sq(proc_ctx, ts_inst, &unmap_para); | 293 | (void)trs_shr_unmap_sq(proc_ctx, ts_inst, &unmap_para); |
| 289 | trs_clear_map_addr_info(&shr_sq_ctx->que_mem); | 294 | trs_clear_map_addr_info(&shr_sq_ctx->que_mem); |
| 290 | } | 295 | } |
| 291 | 296 | ||
| 292 | if (shr_sq_ctx->shr_info.uva != 0) { | 297 | if (shr_sq_ctx->shr_info.uva != 0) { |
| 293 | - trs_unmap_fill_para( | 298 | + trs_unmap_fill_para(&unmap_para, shr_sq_ctx->shr_info.mem_type, shr_sq_ctx->shr_info.uva, |
| 294 | - &unmap_para, shr_sq_ctx->shr_info.mem_type, shr_sq_ctx->shr_info.uva, shr_sq_ctx->shr_info.len); | 299 | + shr_sq_ctx->shr_info.len); |
| 295 | (void)trs_shr_unmap_sq(proc_ctx, ts_inst, &unmap_para); | 300 | (void)trs_shr_unmap_sq(proc_ctx, ts_inst, &unmap_para); |
| 296 | trs_clear_map_addr_info(&shr_sq_ctx->shr_info); | 301 | trs_clear_map_addr_info(&shr_sq_ctx->shr_info); |
| 297 | } | 302 | } |
| @@ -303,9 +308,8 @@ void trs_shr_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts | |||
| 303 | return; | 308 | return; |
| 304 | } | 309 | } |
| 305 | 310 | ||
| 306 | -int trs_shr_sq_remap( | 311 | +int trs_shr_sq_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, |
| 307 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 312 | + struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) |
| 308 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) | ||
| 309 | { | 313 | { |
| 310 | struct trs_alloc_para *alloc_para = get_alloc_para_addr(para); | 314 | struct trs_alloc_para *alloc_para = get_alloc_para_addr(para); |
| 311 | struct trs_uio_info *uio_info = alloc_para->uio_info; | 315 | struct trs_uio_info *uio_info = alloc_para->uio_info; |
| @@ -338,9 +342,8 @@ int trs_shr_sq_remap( | |||
| 338 | return 0; | 342 | return 0; |
| 339 | } | 343 | } |
| 340 | 344 | ||
| 341 | - trs_remap_fill_para( | 345 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_MEM, uio_info->sq_ctrl_addr[TRS_UIO_SHR_INFO], |
| 342 | - &map_para, TRS_MAP_TYPE_MEM, uio_info->sq_ctrl_addr[TRS_UIO_SHR_INFO], ka_mm_virt_to_phys(sq_ctx->shr_info.kva), | 346 | + ka_mm_virt_to_phys(sq_ctx->shr_info.kva), KA_MM_PAGE_SIZE); |
| 343 | - KA_MM_PAGE_SIZE); | ||
| 344 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); | 347 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); |
| 345 | if (ret != 0) { | 348 | if (ret != 0) { |
| 346 | goto out; | 349 | goto out; |
| @@ -355,9 +358,8 @@ int trs_shr_sq_remap( | |||
| 355 | } | 358 | } |
| 356 | trs_fill_map_addr_info(&shr_sq_ctx->que_mem, &map_para); | 359 | trs_fill_map_addr_info(&shr_sq_ctx->que_mem, &map_para); |
| 357 | 360 | ||
| 358 | - trs_remap_fill_para( | 361 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_HEAD], |
| 359 | - &map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_HEAD], | 362 | + KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 360 | - KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 361 | uio_info->sq_ctrl_addr[TRS_UIO_HEAD] += sq_info->head_addr % KA_MM_PAGE_SIZE; | 363 | uio_info->sq_ctrl_addr[TRS_UIO_HEAD] += sq_info->head_addr % KA_MM_PAGE_SIZE; |
| 362 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); | 364 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); |
| 363 | if (ret != 0) { | 365 | if (ret != 0) { |
| @@ -366,9 +368,8 @@ int trs_shr_sq_remap( | |||
| 366 | } | 368 | } |
| 367 | trs_fill_map_addr_info(&shr_sq_ctx->head, &map_para); | 369 | trs_fill_map_addr_info(&shr_sq_ctx->head, &map_para); |
| 368 | 370 | ||
| 369 | - trs_remap_fill_para( | 371 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_DB], |
| 370 | - &map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_DB], | 372 | + KA_DRIVER_ALIGN_DOWN(sq_info->db_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 371 | - KA_DRIVER_ALIGN_DOWN(sq_info->db_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 372 | uio_info->sq_ctrl_addr[TRS_UIO_DB] += sq_info->db_addr % KA_MM_PAGE_SIZE; | 373 | uio_info->sq_ctrl_addr[TRS_UIO_DB] += sq_info->db_addr % KA_MM_PAGE_SIZE; |
| 373 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); | 374 | ret = trs_shr_remap_sq(proc_ctx, ts_inst, &map_para); |
| 374 | if (ret != 0) { | 375 | if (ret != 0) { |
| @@ -390,9 +391,8 @@ int trs_shr_sq_remap( | |||
| 390 | out: | 391 | out: |
| 391 | trs_shr_sq_unmap(proc_ctx, ts_inst, sq_ctx); | 392 | trs_shr_sq_unmap(proc_ctx, ts_inst, sq_ctx); |
| 392 | trs_put_shr_ctx(shr_ctx); | 393 | trs_put_shr_ctx(shr_ctx); |
| 393 | - trs_debug( | 394 | + trs_debug("Share sq send use kernel mode. (devid=%u; tsid=%u; sqid=%u; type=%u; flag=%u, ret=%d)\n", inst->devid, |
| 394 | - "Share sq send use kernel mode. (devid=%u; tsid=%u; sqid=%u; type=%u; flag=%u, ret=%d)\n", inst->devid, | 395 | + inst->tsid, para->sqId, para->type, para->flag, ret); |
| 395 | - inst->tsid, para->sqId, para->type, para->flag, ret); | ||
| 396 | 396 | ||
| 397 | 397 | ||
| 398 | return ret; | 398 | return ret; |
| @@ -19,9 +19,8 @@ | |||
| 19 | int trs_shr_ctx_mng_init(struct trs_id_inst *inst); | 19 | int trs_shr_ctx_mng_init(struct trs_id_inst *inst); |
| 20 | void trs_shr_ctx_mng_uninit(struct trs_id_inst *inst); | 20 | void trs_shr_ctx_mng_uninit(struct trs_id_inst *inst); |
| 21 | 21 | ||
| 22 | -int trs_shr_sq_remap( | 22 | +int trs_shr_sq_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, |
| 23 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 23 | + struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info); |
| 24 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info); | ||
| 25 | void trs_shr_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx); | 24 | void trs_shr_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx); |
| 26 | 25 | ||
| 27 | struct trs_shr_ctx_mng *trs_get_shr_ctx(struct trs_id_inst *inst); | 26 | struct trs_shr_ctx_mng *trs_get_shr_ctx(struct trs_id_inst *inst); |
| @@ -81,8 +81,8 @@ static inline bool trs_cq_is_need_show(struct trs_cq_ctx *cq_ctx) | |||
| 81 | return (cq_ctx->stat.rx_drop > 0 || cq_ctx->stat.rx_enque_fail > 0); | 81 | return (cq_ctx->stat.rx_drop > 0 || cq_ctx->stat.rx_enque_fail > 0); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | -static inline void trs_sq_ctx_init( | 84 | +static inline void trs_sq_ctx_init(struct trs_id_inst *inst, struct trs_sq_ctx *sq_ctx, struct halSqCqInputInfo *para, |
| 85 | - struct trs_id_inst *inst, struct trs_sq_ctx *sq_ctx, struct halSqCqInputInfo *para, u32 stream_id, int chan_id) | 85 | + u32 stream_id, int chan_id) |
| 86 | { | 86 | { |
| 87 | sq_ctx->inst = *inst; | 87 | sq_ctx->inst = *inst; |
| 88 | sq_ctx->sqid = para->sqId; | 88 | sq_ctx->sqid = para->sqId; |
| @@ -119,7 +119,10 @@ static inline void trs_cq_ctx_init(struct trs_cq_ctx *cq_ctx, u32 logic_cqid, in | |||
| 119 | (void)memset_s(&cq_ctx->stat, sizeof(struct trs_cq_stat), 0, sizeof(struct trs_cq_stat)); | 119 | (void)memset_s(&cq_ctx->stat, sizeof(struct trs_cq_stat), 0, sizeof(struct trs_cq_stat)); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | -static inline void trs_cq_ctx_uninit(struct trs_cq_ctx *cq_ctx) { cq_ctx->chan_id = -1; } | 122 | +static inline void trs_cq_ctx_uninit(struct trs_cq_ctx *cq_ctx) |
| 123 | +{ | ||
| 124 | + cq_ctx->chan_id = -1; | ||
| 125 | +} | ||
| 123 | 126 | ||
| 124 | static inline void trs_sq_ctxs_init(struct trs_sq_ctx *sq_ctx, u32 sq_num) | 127 | static inline void trs_sq_ctxs_init(struct trs_sq_ctx *sq_ctx, u32 sq_num) |
| 125 | { | 128 | { |
| @@ -39,8 +39,8 @@ static void trs_sq_mem_free(struct trs_sq_ctx *sq_ctx) | |||
| 39 | 39 | ||
| 40 | static int trs_sq_mem_alloc(struct trs_sq_ctx *sq_ctx, unsigned long que_mem_len) | 40 | static int trs_sq_mem_alloc(struct trs_sq_ctx *sq_ctx, unsigned long que_mem_len) |
| 41 | { | 41 | { |
| 42 | - sq_ctx->que_mem.kva = | 42 | + sq_ctx->que_mem.kva = ka_alloc_pages_exact_ex( |
| 43 | - ka_alloc_pages_exact_ex(que_mem_len, KA_GFP_KERNEL | __KA_GFP_ZERO | __KA_GFP_ACCOUNT | __KA_GFP_RETRY_MAYFAIL); | 43 | + que_mem_len, KA_GFP_KERNEL | __KA_GFP_ZERO | __KA_GFP_ACCOUNT | __KA_GFP_RETRY_MAYFAIL); |
| 44 | if (sq_ctx->que_mem.kva == NULL) { | 44 | if (sq_ctx->que_mem.kva == NULL) { |
| 45 | return -ENOMEM; | 45 | return -ENOMEM; |
| 46 | } | 46 | } |
| @@ -65,9 +65,8 @@ static int trs_sq_mem_alloc(struct trs_sq_ctx *sq_ctx, unsigned long que_mem_len | |||
| 65 | return 0; | 65 | return 0; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | -static int trs_sq_que_remap( | 68 | +static int trs_sq_que_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, |
| 69 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, | 69 | + struct trs_mem_map_para *map_para) |
| 70 | - struct trs_mem_map_para *map_para) | ||
| 71 | { | 70 | { |
| 72 | int ret; | 71 | int ret; |
| 73 | 72 | ||
| @@ -92,9 +91,8 @@ static void trs_sq_que_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_i | |||
| 92 | } | 91 | } |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | -static int trs_sq_head_remap( | 94 | +static int trs_sq_head_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, |
| 96 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, | 95 | + struct trs_mem_map_para *map_para) |
| 97 | - struct trs_mem_map_para *map_para) | ||
| 98 | { | 96 | { |
| 99 | int ret; | 97 | int ret; |
| 100 | 98 | ||
| @@ -112,8 +110,8 @@ static int trs_sq_head_remap( | |||
| 112 | return ret; | 110 | return ret; |
| 113 | } | 111 | } |
| 114 | 112 | ||
| 115 | -static void trs_sq_head_unmap( | 113 | +static void trs_sq_head_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 116 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx) | 114 | + struct trs_sq_ctx *sq_ctx) |
| 117 | { | 115 | { |
| 118 | struct trs_mem_unmap_para unmap_para; | 116 | struct trs_mem_unmap_para unmap_para; |
| 119 | 117 | ||
| @@ -124,9 +122,8 @@ static void trs_sq_head_unmap( | |||
| 124 | } | 122 | } |
| 125 | } | 123 | } |
| 126 | 124 | ||
| 127 | -static int trs_sq_tail_remap( | 125 | +static int trs_sq_tail_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, |
| 128 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, | 126 | + struct trs_mem_map_para *map_para) |
| 129 | - struct trs_mem_map_para *map_para) | ||
| 130 | { | 127 | { |
| 131 | int ret; | 128 | int ret; |
| 132 | 129 | ||
| @@ -144,8 +141,8 @@ static int trs_sq_tail_remap( | |||
| 144 | return ret; | 141 | return ret; |
| 145 | } | 142 | } |
| 146 | 143 | ||
| 147 | -static void trs_sq_tail_unmap( | 144 | +static void trs_sq_tail_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 148 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx) | 145 | + struct trs_sq_ctx *sq_ctx) |
| 149 | { | 146 | { |
| 150 | struct trs_mem_unmap_para unmap_para; | 147 | struct trs_mem_unmap_para unmap_para; |
| 151 | 148 | ||
| @@ -156,9 +153,8 @@ static void trs_sq_tail_unmap( | |||
| 156 | } | 153 | } |
| 157 | } | 154 | } |
| 158 | 155 | ||
| 159 | -static int trs_sq_db_remap( | 156 | +static int trs_sq_db_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, |
| 160 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx, | 157 | + struct trs_mem_map_para *map_para) |
| 161 | - struct trs_mem_map_para *map_para) | ||
| 162 | { | 158 | { |
| 163 | int ret; | 159 | int ret; |
| 164 | 160 | ||
| @@ -200,9 +196,9 @@ static void trs_sq_shr_info_mem_free(struct trs_sq_ctx *sq_ctx) | |||
| 200 | } | 196 | } |
| 201 | } | 197 | } |
| 202 | 198 | ||
| 203 | -static int trs_sq_shr_info_remap( | 199 | +static int trs_sq_shr_info_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 204 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_uio_info *uio_info, | 200 | + struct trs_uio_info *uio_info, struct trs_sq_ctx *sq_ctx, |
| 205 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) | 201 | + struct trs_chan_sq_info *sq_info) |
| 206 | { | 202 | { |
| 207 | struct trs_mem_map_para map_para; | 203 | struct trs_mem_map_para map_para; |
| 208 | int ret; | 204 | int ret; |
| @@ -216,9 +212,8 @@ static int trs_sq_shr_info_remap( | |||
| 216 | } | 212 | } |
| 217 | sq_ctx->shr_info.len = KA_MM_PAGE_SIZE; | 213 | sq_ctx->shr_info.len = KA_MM_PAGE_SIZE; |
| 218 | 214 | ||
| 219 | - trs_remap_fill_para( | 215 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_MEM, uio_info->sq_ctrl_addr[TRS_UIO_SHR_INFO], |
| 220 | - &map_para, TRS_MAP_TYPE_MEM, uio_info->sq_ctrl_addr[TRS_UIO_SHR_INFO], ka_mm_virt_to_phys(sq_ctx->shr_info.kva), | 216 | + ka_mm_virt_to_phys(sq_ctx->shr_info.kva), KA_MM_PAGE_SIZE); |
| 221 | - KA_MM_PAGE_SIZE); | ||
| 222 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); | 217 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); |
| 223 | if (ret != 0) { | 218 | if (ret != 0) { |
| 224 | trs_sq_shr_info_mem_free(sq_ctx); | 219 | trs_sq_shr_info_mem_free(sq_ctx); |
| @@ -234,8 +229,8 @@ static int trs_sq_shr_info_remap( | |||
| 234 | return 0; | 229 | return 0; |
| 235 | } | 230 | } |
| 236 | 231 | ||
| 237 | -static void trs_sq_shr_info_unmap( | 232 | +static void trs_sq_shr_info_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 238 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx) | 233 | + struct trs_sq_ctx *sq_ctx) |
| 239 | { | 234 | { |
| 240 | if (sq_ctx->shr_info.uva != 0) { | 235 | if (sq_ctx->shr_info.uva != 0) { |
| 241 | struct trs_mem_unmap_para unmap_para; | 236 | struct trs_mem_unmap_para unmap_para; |
| @@ -247,17 +242,15 @@ static void trs_sq_shr_info_unmap( | |||
| 247 | trs_sq_shr_info_mem_free(sq_ctx); | 242 | trs_sq_shr_info_mem_free(sq_ctx); |
| 248 | } | 243 | } |
| 249 | 244 | ||
| 250 | -static void trs_sq_reg_remap( | 245 | +static void trs_sq_reg_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 251 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_uio_info *uio_info, | 246 | + struct trs_uio_info *uio_info, struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) |
| 252 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) | ||
| 253 | { | 247 | { |
| 254 | struct trs_mem_map_para map_para; | 248 | struct trs_mem_map_para map_para; |
| 255 | int ret; | 249 | int ret; |
| 256 | 250 | ||
| 257 | /* head reg addr not page align */ | 251 | /* head reg addr not page align */ |
| 258 | - trs_remap_fill_para( | 252 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_RO_REG, uio_info->sq_ctrl_addr[TRS_UIO_HEAD_REG], |
| 259 | - &map_para, TRS_MAP_TYPE_RO_REG, uio_info->sq_ctrl_addr[TRS_UIO_HEAD_REG], | 253 | + KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 260 | - KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 261 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); | 254 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); |
| 262 | if (ret == 0) { | 255 | if (ret == 0) { |
| 263 | sq_ctx->head_reg.uva = map_para.va; | 256 | sq_ctx->head_reg.uva = map_para.va; |
| @@ -269,9 +262,8 @@ static void trs_sq_reg_remap( | |||
| 269 | } | 262 | } |
| 270 | 263 | ||
| 271 | /* tail reg addr not page align */ | 264 | /* tail reg addr not page align */ |
| 272 | - trs_remap_fill_para( | 265 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_RO_REG, uio_info->sq_ctrl_addr[TRS_UIO_TAIL_REG], |
| 273 | - &map_para, TRS_MAP_TYPE_RO_REG, uio_info->sq_ctrl_addr[TRS_UIO_TAIL_REG], | 266 | + KA_DRIVER_ALIGN_DOWN(sq_info->tail_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 274 | - KA_DRIVER_ALIGN_DOWN(sq_info->tail_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 275 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); | 267 | ret = trs_remap_sq(proc_ctx, ts_inst, &map_para); |
| 276 | if (ret == 0) { | 268 | if (ret == 0) { |
| 277 | sq_ctx->tail_reg.uva = map_para.va; | 269 | sq_ctx->tail_reg.uva = map_para.va; |
| @@ -300,9 +292,8 @@ static void trs_sq_reg_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_i | |||
| 300 | } | 292 | } |
| 301 | } | 293 | } |
| 302 | 294 | ||
| 303 | -int trs_sq_remap( | 295 | +int trs_sq_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, |
| 304 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 296 | + struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) |
| 305 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info) | ||
| 306 | { | 297 | { |
| 307 | struct trs_id_inst *inst = &ts_inst->inst; | 298 | struct trs_id_inst *inst = &ts_inst->inst; |
| 308 | struct trs_alloc_para *alloc_para = get_alloc_para_addr(para); | 299 | struct trs_alloc_para *alloc_para = get_alloc_para_addr(para); |
| @@ -353,9 +344,8 @@ int trs_sq_remap( | |||
| 353 | } | 344 | } |
| 354 | 345 | ||
| 355 | /* head addr not page align */ | 346 | /* head addr not page align */ |
| 356 | - trs_remap_fill_para( | 347 | + trs_remap_fill_para(&map_para, sq_reg_type, uio_info->sq_ctrl_addr[TRS_UIO_HEAD], |
| 357 | - &map_para, sq_reg_type, uio_info->sq_ctrl_addr[TRS_UIO_HEAD], | 348 | + KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 358 | - KA_DRIVER_ALIGN_DOWN(sq_info->head_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 359 | uio_info->sq_ctrl_addr[TRS_UIO_HEAD] += sq_info->head_addr % KA_MM_PAGE_SIZE; | 349 | uio_info->sq_ctrl_addr[TRS_UIO_HEAD] += sq_info->head_addr % KA_MM_PAGE_SIZE; |
| 360 | ret = trs_sq_head_remap(proc_ctx, ts_inst, sq_ctx, &map_para); | 350 | ret = trs_sq_head_remap(proc_ctx, ts_inst, sq_ctx, &map_para); |
| 361 | if (ret != 0) { | 351 | if (ret != 0) { |
| @@ -363,9 +353,8 @@ int trs_sq_remap( | |||
| 363 | } | 353 | } |
| 364 | 354 | ||
| 365 | /* tail addr not page align */ | 355 | /* tail addr not page align */ |
| 366 | - trs_remap_fill_para( | 356 | + trs_remap_fill_para(&map_para, sq_reg_type, uio_info->sq_ctrl_addr[TRS_UIO_TAIL], |
| 367 | - &map_para, sq_reg_type, uio_info->sq_ctrl_addr[TRS_UIO_TAIL], | 357 | + KA_DRIVER_ALIGN_DOWN(sq_info->tail_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 368 | - KA_DRIVER_ALIGN_DOWN(sq_info->tail_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 369 | uio_info->sq_ctrl_addr[TRS_UIO_TAIL] += sq_info->tail_addr % KA_MM_PAGE_SIZE; | 358 | uio_info->sq_ctrl_addr[TRS_UIO_TAIL] += sq_info->tail_addr % KA_MM_PAGE_SIZE; |
| 370 | ret = trs_sq_tail_remap(proc_ctx, ts_inst, sq_ctx, &map_para); | 359 | ret = trs_sq_tail_remap(proc_ctx, ts_inst, sq_ctx, &map_para); |
| 371 | if (ret != 0) { | 360 | if (ret != 0) { |
| @@ -373,9 +362,8 @@ int trs_sq_remap( | |||
| 373 | } | 362 | } |
| 374 | 363 | ||
| 375 | /* db addr not page align */ | 364 | /* db addr not page align */ |
| 376 | - trs_remap_fill_para( | 365 | + trs_remap_fill_para(&map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_DB], |
| 377 | - &map_para, TRS_MAP_TYPE_REG, uio_info->sq_ctrl_addr[TRS_UIO_DB], | 366 | + KA_DRIVER_ALIGN_DOWN(sq_info->db_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); |
| 378 | - KA_DRIVER_ALIGN_DOWN(sq_info->db_addr, KA_MM_PAGE_SIZE), KA_MM_PAGE_SIZE); | ||
| 379 | uio_info->sq_ctrl_addr[TRS_UIO_DB] += sq_info->db_addr % KA_MM_PAGE_SIZE; | 367 | uio_info->sq_ctrl_addr[TRS_UIO_DB] += sq_info->db_addr % KA_MM_PAGE_SIZE; |
| 380 | ret = trs_sq_db_remap(proc_ctx, ts_inst, sq_ctx, &map_para); | 368 | ret = trs_sq_db_remap(proc_ctx, ts_inst, sq_ctx, &map_para); |
| 381 | if (ret != 0) { | 369 | if (ret != 0) { |
| @@ -399,9 +387,8 @@ out: | |||
| 399 | uio_info->uio_flag = 0; | 387 | uio_info->uio_flag = 0; |
| 400 | uio_info->soft_que_flag = 0; | 388 | uio_info->soft_que_flag = 0; |
| 401 | sq_ctx->mode = SEND_MODE_KIO; | 389 | sq_ctx->mode = SEND_MODE_KIO; |
| 402 | - trs_debug( | 390 | + trs_debug("Sq send use kernel mode. (devid=%u; tsid=%u; sqid=%u; type=%u; flag=%u, ret=%d)\n", inst->devid, |
| 403 | - "Sq send use kernel mode. (devid=%u; tsid=%u; sqid=%u; type=%u; flag=%u, ret=%d)\n", inst->devid, inst->tsid, | 391 | + inst->tsid, para->sqId, para->type, para->flag, ret); |
| 404 | - para->sqId, para->type, para->flag, ret); | ||
| 405 | 392 | ||
| 406 | return ret; | 393 | return ret; |
| 407 | } | 394 | } |
| @@ -22,9 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | struct trs_core_ts_inst; | 23 | struct trs_core_ts_inst; |
| 24 | 24 | ||
| 25 | -int trs_sq_remap( | 25 | +int trs_sq_remap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, |
| 26 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqInputInfo *para, | 26 | + struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info); |
| 27 | - struct trs_sq_ctx *sq_ctx, struct trs_chan_sq_info *sq_info); | ||
| 28 | void trs_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx); | 27 | void trs_sq_unmap(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct trs_sq_ctx *sq_ctx); |
| 29 | void trs_sq_clear_map_info(struct trs_sq_ctx *sq_ctx); | 28 | void trs_sq_clear_map_info(struct trs_sq_ctx *sq_ctx); |
| 30 | void trs_sq_ctx_mem_free(struct trs_sq_ctx *sq_ctx); | 29 | void trs_sq_ctx_mem_free(struct trs_sq_ctx *sq_ctx); |
| @@ -54,8 +54,8 @@ static void trs_sw_cq_recv_proc(struct trs_core_ts_inst *ts_inst, u32 cqid, void | |||
| 54 | 54 | ||
| 55 | trs_ctrl_cqe_to_logic_cqe(ctrl_cqe, &logic_cqe); | 55 | trs_ctrl_cqe_to_logic_cqe(ctrl_cqe, &logic_cqe); |
| 56 | 56 | ||
| 57 | - (void)trs_logic_cq_enque( | 57 | + (void)trs_logic_cq_enque(ts_inst, cq_ctx->logic_cqid, (u32)ctrl_cqe->stream_id, (u32)ctrl_cqe->task_id, |
| 58 | - ts_inst, cq_ctx->logic_cqid, (u32)ctrl_cqe->stream_id, (u32)ctrl_cqe->task_id, (void *)&logic_cqe); | 58 | + (void *)&logic_cqe); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | static int trs_sw_cq_recv(struct trs_id_inst *inst, u32 cqid, void *cqe) | 61 | static int trs_sw_cq_recv(struct trs_id_inst *inst, u32 cqid, void *cqe) |
| @@ -74,8 +74,8 @@ static int trs_sw_cq_recv(struct trs_id_inst *inst, u32 cqid, void *cqe) | |||
| 74 | return CQ_RECV_CONTINUE; | 74 | return CQ_RECV_CONTINUE; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | -static int trs_sw_alloc_chan( | 77 | +static int trs_sw_alloc_chan(struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, |
| 78 | - struct trs_proc_ctx *proc_ctx, struct trs_id_inst *inst, struct halSqCqInputInfo *para, int *chan_id) | 78 | + int *chan_id) |
| 79 | { | 79 | { |
| 80 | struct trs_chan_para chan_para = {0}; | 80 | struct trs_chan_para chan_para = {0}; |
| 81 | int ret; | 81 | int ret; |
| @@ -83,8 +83,8 @@ static int trs_sw_alloc_chan( | |||
| 83 | chan_para.types.type = CHAN_TYPE_SW; | 83 | chan_para.types.type = CHAN_TYPE_SW; |
| 84 | chan_para.types.sub_type = CHAN_SUB_TYPE_SW_CTRL; | 84 | chan_para.types.sub_type = CHAN_SUB_TYPE_SW_CTRL; |
| 85 | 85 | ||
| 86 | - chan_para.flag = | 86 | + chan_para.flag = (0x1 << CHAN_FLAG_ALLOC_SQ_BIT) | (0x1 << CHAN_FLAG_ALLOC_CQ_BIT) | |
| 87 | - (0x1 << CHAN_FLAG_ALLOC_SQ_BIT) | (0x1 << CHAN_FLAG_ALLOC_CQ_BIT) | (0x1 << CHAN_FLAG_NOTICE_TS_BIT); | 87 | + (0x1 << CHAN_FLAG_NOTICE_TS_BIT); |
| 88 | 88 | ||
| 89 | chan_para.ssid = proc_ctx->cp_ssid; | 89 | chan_para.ssid = proc_ctx->cp_ssid; |
| 90 | chan_para.sq_para.sqe_size = para->sqeSize; | 90 | chan_para.sq_para.sqe_size = para->sqeSize; |
| @@ -185,8 +185,8 @@ destroy_chan: | |||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | 187 | ||
| 188 | -static int trs_sw_sqcq_free_check( | 188 | +static int trs_sw_sqcq_free_check(struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, |
| 189 | - struct trs_proc_ctx *proc_ctx, struct trs_core_ts_inst *ts_inst, struct halSqCqFreeInfo *para) | 189 | + struct halSqCqFreeInfo *para) |
| 190 | { | 190 | { |
| 191 | struct trs_id_inst *inst = &ts_inst->inst; | 191 | struct trs_id_inst *inst = &ts_inst->inst; |
| 192 | 192 | ||
| @@ -201,8 +201,8 @@ static int trs_sw_sqcq_free_check( | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | if (ts_inst->sw_sq_ctx[para->sqId].chan_id != ts_inst->sw_cq_ctx[para->cqId].chan_id) { | 203 | if (ts_inst->sw_sq_ctx[para->sqId].chan_id != ts_inst->sw_cq_ctx[para->cqId].chan_id) { |
| 204 | - trs_err( | 204 | + trs_err("Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, |
| 205 | - "Not pair sqcq. (devid=%u; tsid=%u; sqId=%u; cqId=%u)\n", inst->devid, inst->tsid, para->sqId, para->cqId); | 205 | + para->cqId); |
| 206 | return -EINVAL; | 206 | return -EINVAL; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| @@ -263,16 +263,14 @@ int trs_sw_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 263 | u32 cq_id_num = trs_res_get_id_num(ts_inst, TRS_SW_CQ); | 263 | u32 cq_id_num = trs_res_get_id_num(ts_inst, TRS_SW_CQ); |
| 264 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_SW_CQ); | 264 | u32 cq_max_id = trs_res_get_max_id(ts_inst, TRS_SW_CQ); |
| 265 | 265 | ||
| 266 | - trs_debug( | 266 | + trs_debug("Init sw sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", |
| 267 | - "Init sw sqcq. (devid=%u; tsid=%u; sq_id_num=%u; sq_max_id=%u; cq_id_num=%u; cq_max_id=%u)\n", inst->devid, | 267 | + inst->devid, inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); |
| 268 | - inst->tsid, sq_id_num, sq_max_id, cq_id_num, cq_max_id); | ||
| 269 | 268 | ||
| 270 | if (sq_max_id > 0) { | 269 | if (sq_max_id > 0) { |
| 271 | ts_inst->sw_sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); | 270 | ts_inst->sw_sq_ctx = (struct trs_sq_ctx *)trs_vzalloc(sizeof(struct trs_sq_ctx) * sq_max_id); |
| 272 | if (ts_inst->sw_sq_ctx == NULL) { | 271 | if (ts_inst->sw_sq_ctx == NULL) { |
| 273 | - trs_err( | 272 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 274 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 273 | + sizeof(struct trs_sq_ctx) * sq_max_id); |
| 275 | - sizeof(struct trs_sq_ctx) * sq_max_id); | ||
| 276 | return -ENOMEM; | 274 | return -ENOMEM; |
| 277 | } | 275 | } |
| 278 | ts_inst->sw_sq_ctx->sq_num = sq_max_id; | 276 | ts_inst->sw_sq_ctx->sq_num = sq_max_id; |
| @@ -285,9 +283,8 @@ int trs_sw_sqcq_init(struct trs_core_ts_inst *ts_inst) | |||
| 285 | trs_sq_ctxs_uninit(ts_inst->sw_sq_ctx); | 283 | trs_sq_ctxs_uninit(ts_inst->sw_sq_ctx); |
| 286 | trs_vfree(ts_inst->sw_sq_ctx); | 284 | trs_vfree(ts_inst->sw_sq_ctx); |
| 287 | ts_inst->sw_sq_ctx = NULL; | 285 | ts_inst->sw_sq_ctx = NULL; |
| 288 | - trs_err( | 286 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 289 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 287 | + sizeof(struct trs_cq_ctx) * cq_max_id); |
| 290 | - sizeof(struct trs_cq_ctx) * cq_max_id); | ||
| 291 | return -ENOMEM; | 288 | return -ENOMEM; |
| 292 | } | 289 | } |
| 293 | } | 290 | } |
| @@ -123,8 +123,8 @@ static void trs_core_ts_inst_uninit(struct trs_core_ts_inst *ts_inst) | |||
| 123 | trs_res_mng_uninit(ts_inst); | 123 | trs_res_mng_uninit(ts_inst); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | -static int trs_core_ts_inst_create( | 126 | +static int trs_core_ts_inst_create(struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, |
| 127 | - struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, struct trs_core_adapt_ops *ops) | 127 | + struct trs_core_adapt_ops *ops) |
| 128 | { | 128 | { |
| 129 | u32 ts_inst_id = trs_id_inst_to_ts_inst(inst); | 129 | u32 ts_inst_id = trs_id_inst_to_ts_inst(inst); |
| 130 | struct trs_core_ts_inst *ts_inst = NULL; | 130 | struct trs_core_ts_inst *ts_inst = NULL; |
| @@ -137,9 +137,8 @@ static int trs_core_ts_inst_create( | |||
| 137 | 137 | ||
| 138 | ts_inst = trs_vzalloc(sizeof(struct trs_core_ts_inst)); | 138 | ts_inst = trs_vzalloc(sizeof(struct trs_core_ts_inst)); |
| 139 | if (ts_inst == NULL) { | 139 | if (ts_inst == NULL) { |
| 140 | - trs_err( | 140 | + trs_err("Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, |
| 141 | - "Mem alloc failed. (devid=%u; tsid=%u; size=%lx)\n", inst->devid, inst->tsid, | 141 | + sizeof(struct trs_core_ts_inst)); |
| 142 | - sizeof(struct trs_core_ts_inst)); | ||
| 143 | return -ENOMEM; | 142 | return -ENOMEM; |
| 144 | } | 143 | } |
| 145 | 144 | ||
| @@ -211,8 +210,8 @@ static int trs_core_check_ts_inst_ops(struct trs_core_adapt_ops *ops) | |||
| 211 | return 0; | 210 | return 0; |
| 212 | } | 211 | } |
| 213 | 212 | ||
| 214 | -int trs_core_ts_inst_register( | 213 | +int trs_core_ts_inst_register(struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, |
| 215 | - struct trs_id_inst *inst, int hw_type, int location, u32 ts_inst_flag, struct trs_core_adapt_ops *ops) | 214 | + struct trs_core_adapt_ops *ops) |
| 216 | { | 215 | { |
| 217 | int ret; | 216 | int ret; |
| 218 | 217 | ||
| @@ -267,7 +266,10 @@ struct trs_core_ts_inst *trs_core_ts_inst_get(struct trs_id_inst *inst) | |||
| 267 | return ts_inst; | 266 | return ts_inst; |
| 268 | } | 267 | } |
| 269 | 268 | ||
| 270 | -void trs_core_ts_inst_put(struct trs_core_ts_inst *ts_inst) { kref_safe_put(&ts_inst->ref, trs_core_ts_inst_release); } | 269 | +void trs_core_ts_inst_put(struct trs_core_ts_inst *ts_inst) |
| 270 | +{ | ||
| 271 | + kref_safe_put(&ts_inst->ref, trs_core_ts_inst_release); | ||
| 272 | +} | ||
| 271 | 273 | ||
| 272 | static void trs_core_destroy_all_proc(struct trs_core_ts_inst *ts_inst) | 274 | static void trs_core_destroy_all_proc(struct trs_core_ts_inst *ts_inst) |
| 273 | { | 275 | { |
| @@ -89,7 +89,10 @@ static inline struct trs_core_ts_inst *trs_core_inst_get(u32 devid, u32 tsid) | |||
| 89 | return trs_core_ts_inst_get(&inst); | 89 | return trs_core_ts_inst_get(&inst); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | -static inline void trs_core_inst_put(struct trs_core_ts_inst *ts_inst) { trs_core_ts_inst_put(ts_inst); } | 92 | +static inline void trs_core_inst_put(struct trs_core_ts_inst *ts_inst) |
| 93 | +{ | ||
| 94 | + trs_core_ts_inst_put(ts_inst); | ||
| 95 | +} | ||
| 93 | 96 | ||
| 94 | 97 | ||
| 95 | static inline int trs_core_notice_ts(struct trs_core_ts_inst *ts_inst, u8 *msg, u32 len) | 98 | static inline int trs_core_notice_ts(struct trs_core_ts_inst *ts_inst, u8 *msg, u32 len) |
| @@ -102,9 +105,8 @@ static inline int trs_core_notice_ts(struct trs_core_ts_inst *ts_inst, u8 *msg, | |||
| 102 | 105 | ||
| 103 | if (((ret != 0) || (header->result != 0)) && (header->cmd_type != TRS_MBOX_RECYCLE_CHECK) && | 106 | if (((ret != 0) || (header->result != 0)) && (header->cmd_type != TRS_MBOX_RECYCLE_CHECK) && |
| 104 | (header->cmd_type != TRS_MBOX_RECYCLE_PID)) { | 107 | (header->cmd_type != TRS_MBOX_RECYCLE_PID)) { |
| 105 | - trs_err( | 108 | + trs_err("Ts resp failed. (devid=%u; tsid=%u; cmd_type=%u; ret=%d; result=%u)\n", ts_inst->inst.devid, |
| 106 | - "Ts resp failed. (devid=%u; tsid=%u; cmd_type=%u; ret=%d; result=%u)\n", ts_inst->inst.devid, | 109 | + ts_inst->inst.tsid, header->cmd_type, ret, header->result); |
| 107 | - ts_inst->inst.tsid, header->cmd_type, ret, header->result); | ||
| 108 | } | 110 | } |
| 109 | 111 | ||
| 110 | if (((ret == 0) && (header->result == TSFW_ERR_QUEUE_FULL) && (header->cmd_type == TRS_MBOX_RECYCLE_PID)) || | 112 | if (((ret == 0) && (header->result == TSFW_ERR_QUEUE_FULL) && (header->cmd_type == TRS_MBOX_RECYCLE_PID)) || |
| @@ -115,7 +117,10 @@ static inline int trs_core_notice_ts(struct trs_core_ts_inst *ts_inst, u8 *msg, | |||
| 115 | return ((ret == 0) && (header->result == 0)) ? 0 : -EFAULT; | 117 | return ((ret == 0) && (header->result == 0)) ? 0 : -EFAULT; |
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | -static inline bool trs_core_trace_is_enabled(struct trs_core_ts_inst *ts_inst) { return ts_inst->trace_enable; } | 120 | +static inline bool trs_core_trace_is_enabled(struct trs_core_ts_inst *ts_inst) |
| 121 | +{ | ||
| 122 | + return ts_inst->trace_enable; | ||
| 123 | +} | ||
| 119 | 124 | ||
| 120 | bool trs_still_has_proc(struct trs_core_ts_inst *ts_inst, u32 check_level); | 125 | bool trs_still_has_proc(struct trs_core_ts_inst *ts_inst, u32 check_level); |
| 121 | 126 | ||
| @@ -66,8 +66,8 @@ void trs_uninit_cnt_notify_tbl_ns_base_addr(struct trs_id_inst *inst) | |||
| 66 | 66 | ||
| 67 | static stars_cnt_notify_table_slice *trs_get_cnt_notify_table(struct trs_id_inst *inst, u32 id) | 67 | static stars_cnt_notify_table_slice *trs_get_cnt_notify_table(struct trs_id_inst *inst, u32 id) |
| 68 | { | 68 | { |
| 69 | - stars_cnt_notify_tbl_regs_type *tbl_info = | 69 | + stars_cnt_notify_tbl_regs_type *tbl_info = (stars_cnt_notify_tbl_regs_type *) |
| 70 | - (stars_cnt_notify_tbl_regs_type *)stars_cnt_notify_table_ns_all_reg[inst->devid][inst->tsid]; | 70 | + stars_cnt_notify_table_ns_all_reg[inst->devid][inst->tsid]; |
| 71 | 71 | ||
| 72 | if (tbl_info != NULL) { | 72 | if (tbl_info != NULL) { |
| 73 | return trs_get_stars_cnt_notify_tab_slice(tbl_info, id); | 73 | return trs_get_stars_cnt_notify_tab_slice(tbl_info, id); |
| @@ -69,8 +69,8 @@ static StarsEventTable *trs_get_event_table(struct trs_id_inst *inst, u32 id) | |||
| 69 | u32 group_id = id / STARS_TABLE_EVENT_NUM; | 69 | u32 group_id = id / STARS_TABLE_EVENT_NUM; |
| 70 | u32 offset = id % STARS_TABLE_EVENT_NUM; | 70 | u32 offset = id % STARS_TABLE_EVENT_NUM; |
| 71 | StarsEventGroupTableInfo *group_info = NULL; | 71 | StarsEventGroupTableInfo *group_info = NULL; |
| 72 | - StarsEventTableNsRegsType *tbl_info = | 72 | + StarsEventTableNsRegsType *tbl_info = (StarsEventTableNsRegsType *) |
| 73 | - (StarsEventTableNsRegsType *)stars_event_table_ns_all_reg[inst->devid][inst->tsid]; | 73 | + stars_event_table_ns_all_reg[inst->devid][inst->tsid]; |
| 74 | if (tbl_info == NULL) { | 74 | if (tbl_info == NULL) { |
| 75 | return NULL; | 75 | return NULL; |
| 76 | } | 76 | } |
| @@ -18,11 +18,18 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -int trs_init_cnt_notify_tbl(struct trs_id_inst *inst) { return 0; } | 21 | +int trs_init_cnt_notify_tbl(struct trs_id_inst *inst) |
| 22 | +{ | ||
| 23 | + return 0; | ||
| 24 | +} | ||
| 22 | 25 | ||
| 23 | -void trs_uninit_cnt_notify_tbl(struct trs_id_inst *inst) {} | 26 | +void trs_uninit_cnt_notify_tbl(struct trs_id_inst *inst) |
| 27 | +{} | ||
| 24 | 28 | ||
| 25 | -int trs_stars_func_cnt_notify_id_ctrl(struct trs_id_inst *inst, u32 id, u32 cmd) { return -EOPNOTSUPP; } | 29 | +int trs_stars_func_cnt_notify_id_ctrl(struct trs_id_inst *inst, u32 id, u32 cmd) |
| 30 | +{ | ||
| 31 | + return -EOPNOTSUPP; | ||
| 32 | +} | ||
| 26 | 33 | ||
| 27 | int trs_stars_func_notify_id_reset(struct trs_id_inst *inst, u32 id) | 34 | int trs_stars_func_notify_id_reset(struct trs_id_inst *inst, u32 id) |
| 28 | { | 35 | { |
| @@ -18,9 +18,15 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -int trs_init_cnt_notify_tbl(struct trs_id_inst *inst) { return trs_init_cnt_notify_tbl_ns_base_addr(inst); } | 21 | +int trs_init_cnt_notify_tbl(struct trs_id_inst *inst) |
| 22 | +{ | ||
| 23 | + return trs_init_cnt_notify_tbl_ns_base_addr(inst); | ||
| 24 | +} | ||
| 22 | 25 | ||
| 23 | -void trs_uninit_cnt_notify_tbl(struct trs_id_inst *inst) { trs_uninit_cnt_notify_tbl_ns_base_addr(inst); } | 26 | +void trs_uninit_cnt_notify_tbl(struct trs_id_inst *inst) |
| 27 | +{ | ||
| 28 | + trs_uninit_cnt_notify_tbl_ns_base_addr(inst); | ||
| 29 | +} | ||
| 24 | 30 | ||
| 25 | int trs_stars_func_cnt_notify_id_ctrl(struct trs_id_inst *inst, u32 id, u32 cmd) | 31 | int trs_stars_func_cnt_notify_id_ctrl(struct trs_id_inst *inst, u32 id, u32 cmd) |
| 26 | { | 32 | { |
| @@ -77,7 +77,10 @@ static struct trs_stars_ops trs_stars_func_ops = { | |||
| 77 | .res_id_ctrl = trs_stars_ops_func_res_id_ctrl, | 77 | .res_id_ctrl = trs_stars_ops_func_res_id_ctrl, |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | -struct trs_stars_ops *trs_stars_func_op_get(void) { return &trs_stars_func_ops; } | 80 | +struct trs_stars_ops *trs_stars_func_op_get(void) |
| 81 | +{ | ||
| 82 | + return &trs_stars_func_ops; | ||
| 83 | +} | ||
| 81 | 84 | ||
| 82 | int trs_stars_func_init(struct trs_id_inst *inst) | 85 | int trs_stars_func_init(struct trs_id_inst *inst) |
| 83 | { | 86 | { |
| @@ -49,8 +49,8 @@ typedef struct { | |||
| 49 | stars_cnt_notify_table_slice_info stars_cnt_notify_group_table[STARS_TABLE_CNT_NOTIFY_GRP_NUM]; | 49 | stars_cnt_notify_table_slice_info stars_cnt_notify_group_table[STARS_TABLE_CNT_NOTIFY_GRP_NUM]; |
| 50 | } stars_cnt_notify_tbl_regs_type; | 50 | } stars_cnt_notify_tbl_regs_type; |
| 51 | 51 | ||
| 52 | -static inline stars_cnt_notify_table_slice *trs_get_stars_cnt_notify_tab_slice( | 52 | +static inline stars_cnt_notify_table_slice *trs_get_stars_cnt_notify_tab_slice(stars_cnt_notify_tbl_regs_type *tbl_info, |
| 53 | - stars_cnt_notify_tbl_regs_type *tbl_info, u32 id) | 53 | + u32 id) |
| 54 | { | 54 | { |
| 55 | u32 group_id = id / STARS_TABLE_CNT_NOTIFY_NUM; | 55 | u32 group_id = id / STARS_TABLE_CNT_NOTIFY_NUM; |
| 56 | u32 unit = (id % STARS_TABLE_CNT_NOTIFY_NUM) / STARS_TABLE_CNT_NOTIFY_NUM_PER_UNIT; | 56 | u32 unit = (id % STARS_TABLE_CNT_NOTIFY_NUM) / STARS_TABLE_CNT_NOTIFY_NUM_PER_UNIT; |
| @@ -48,8 +48,8 @@ typedef struct { | |||
| 48 | stars_cnt_notify_table_slice_info stars_cnt_notify_group_table[STARS_TABLE_CNT_NOTIFY_GRP_NUM]; | 48 | stars_cnt_notify_table_slice_info stars_cnt_notify_group_table[STARS_TABLE_CNT_NOTIFY_GRP_NUM]; |
| 49 | } stars_cnt_notify_tbl_regs_type; | 49 | } stars_cnt_notify_tbl_regs_type; |
| 50 | 50 | ||
| 51 | -static inline stars_cnt_notify_table_slice *trs_get_stars_cnt_notify_tab_slice( | 51 | +static inline stars_cnt_notify_table_slice *trs_get_stars_cnt_notify_tab_slice(stars_cnt_notify_tbl_regs_type *tbl_info, |
| 52 | - stars_cnt_notify_tbl_regs_type *tbl_info, u32 id) | 52 | + u32 id) |
| 53 | { | 53 | { |
| 54 | u32 group_id = id / STARS_TABLE_CNT_NOTIFY_NUM; | 54 | u32 group_id = id / STARS_TABLE_CNT_NOTIFY_NUM; |
| 55 | u32 unit = (id % STARS_TABLE_CNT_NOTIFY_NUM) / STARS_TABLE_CNT_NOTIFY_NUM_PER_UNIT; | 55 | u32 unit = (id % STARS_TABLE_CNT_NOTIFY_NUM) / STARS_TABLE_CNT_NOTIFY_NUM_PER_UNIT; |
| @@ -204,4 +204,7 @@ int init_trs_stars(void) | |||
| 204 | return 0; | 204 | return 0; |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | -void exit_trs_stars(void) { trs_stars_notifier_unregister(); } | 207 | +void exit_trs_stars(void) |
| 208 | +{ | ||
| 209 | + trs_stars_notifier_unregister(); | ||
| 210 | +} | ||
| @@ -55,9 +55,8 @@ static int trs_task_abnormal_proc(struct trs_id_inst *inst, int chan_id, u32 sqi | |||
| 55 | int ret = 0; | 55 | int ret = 0; |
| 56 | 56 | ||
| 57 | if (trs_chan_sq_abnormal_handle[task_type] != NULL) { | 57 | if (trs_chan_sq_abnormal_handle[task_type] != NULL) { |
| 58 | - trs_info( | 58 | + trs_info("Process chan abnormal task. (devid=%u; tsid=%u; chan_id=%d; sqid=%u; task_type=%u)\n", inst->devid, |
| 59 | - "Process chan abnormal task. (devid=%u; tsid=%u; chan_id=%d; sqid=%u; task_type=%u)\n", inst->devid, | 59 | + inst->tsid, chan_id, sqid, task_type); |
| 60 | - inst->tsid, chan_id, sqid, task_type); | ||
| 61 | ret = trs_chan_sq_abnormal_handle[task_type](inst, sqid, NULL, info); | 60 | ret = trs_chan_sq_abnormal_handle[task_type](inst, sqid, NULL, info); |
| 62 | if (ret != 0) { | 61 | if (ret != 0) { |
| 63 | trs_err("Failed to handle aicpu sq abnormal task. (chan_id=%d, task_type=%d)\n", chan_id, task_type); | 62 | trs_err("Failed to handle aicpu sq abnormal task. (chan_id=%d, task_type=%d)\n", chan_id, task_type); |
| @@ -74,9 +73,8 @@ static int _trs_chan_abnormal_proc(struct trs_id_inst *inst, struct trs_chan *ch | |||
| 74 | if (chan->ops.abnormal_proc != NULL) { | 73 | if (chan->ops.abnormal_proc != NULL) { |
| 75 | ret = chan->ops.abnormal_proc(inst, chan->id, err_type); | 74 | ret = chan->ops.abnormal_proc(inst, chan->id, err_type); |
| 76 | if (ret != 0) { | 75 | if (ret != 0) { |
| 77 | - trs_err( | 76 | + trs_err("Chan abnormal proc failed. (devid=%u; tsid=%u; chan_id=%d; sqid=%u; err_type=%u)\n", inst->devid, |
| 78 | - "Chan abnormal proc failed. (devid=%u; tsid=%u; chan_id=%d; sqid=%u; err_type=%u)\n", inst->devid, | 77 | + inst->tsid, chan->id, chan->sq.sqid, err_type); |
| 79 | - inst->tsid, chan->id, chan->sq.sqid, err_type); | ||
| 80 | } | 78 | } |
| 81 | } | 79 | } |
| 82 | 80 | ||
| @@ -103,9 +101,8 @@ int trs_chan_abnormal_proc(struct trs_id_inst *inst, struct stars_abnormal_info | |||
| 103 | } | 101 | } |
| 104 | 102 | ||
| 105 | chan_id = trs_chan_sq_to_chan_id(ts_inst, abnormal_info->sqid); | 103 | chan_id = trs_chan_sq_to_chan_id(ts_inst, abnormal_info->sqid); |
| 106 | - trs_info( | 104 | + trs_info("Abnormal info. (devid=%u; tsid=%u; chan_id=%d; task_type=%u; err_type=%u)\n", inst->devid, inst->tsid, |
| 107 | - "Abnormal info. (devid=%u; tsid=%u; chan_id=%d; task_type=%u; err_type=%u)\n", inst->devid, inst->tsid, chan_id, | 105 | + chan_id, task_type, err_type); |
| 108 | - task_type, err_type); | ||
| 109 | 106 | ||
| 110 | (void)trs_task_abnormal_proc(inst, chan_id, abnormal_info->sqid, task_type, (void *)abnormal_info->abnormal_data); | 107 | (void)trs_task_abnormal_proc(inst, chan_id, abnormal_info->sqid, task_type, (void *)abnormal_info->abnormal_data); |
| 111 | 108 | ||
| @@ -37,9 +37,15 @@ u32 trs_chan_get_max_sq_depth(struct trs_chan_type *type); | |||
| 37 | u32 trs_chan_get_max_cq_depth(struct trs_chan_type *type); | 37 | u32 trs_chan_get_max_cq_depth(struct trs_chan_type *type); |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | -u32 trs_chan_get_max_sq_depth(struct trs_chan_type *type) { return TRS_SQCQ_DEPTH_MAX; } | 40 | +u32 trs_chan_get_max_sq_depth(struct trs_chan_type *type) |
| 41 | +{ | ||
| 42 | + return TRS_SQCQ_DEPTH_MAX; | ||
| 43 | +} | ||
| 41 | 44 | ||
| 42 | -u32 trs_chan_get_max_cq_depth(struct trs_chan_type *type) { return TRS_SQCQ_DEPTH_MAX; } | 45 | +u32 trs_chan_get_max_cq_depth(struct trs_chan_type *type) |
| 46 | +{ | ||
| 47 | + return TRS_SQCQ_DEPTH_MAX; | ||
| 48 | +} | ||
| 43 | 49 | ||
| 44 | 50 | ||
| 45 | 51 | ||
| @@ -122,8 +128,8 @@ static void trs_chan_irq_init(struct trs_chan *chan) | |||
| 122 | } | 128 | } |
| 123 | if ((chan->types.type == CHAN_TYPE_HW) && (chan->ts_inst->ops.get_cq_affinity_irq != NULL)) { | 129 | if ((chan->types.type == CHAN_TYPE_HW) && (chan->ts_inst->ops.get_cq_affinity_irq != NULL)) { |
| 124 | if (chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index == KA_U32_MAX) { | 130 | if (chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index == KA_U32_MAX) { |
| 125 | - (void)chan->ts_inst->ops.get_cq_affinity_irq( | 131 | + (void)chan->ts_inst->ops.get_cq_affinity_irq(&chan->inst, chan->cq.cqid, |
| 126 | - &chan->inst, chan->cq.cqid, &chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index); | 132 | + &chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index); |
| 127 | } | 133 | } |
| 128 | irq_ctx += chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index % irq_num; | 134 | irq_ctx += chan->ts_inst->hw_cq_ctx[chan->cq.cqid].irq_index % irq_num; |
| 129 | } else { | 135 | } else { |
| @@ -194,8 +200,8 @@ static int trs_chan_get_cq_type(int hw_type, u32 flag, struct trs_chan_type *typ | |||
| 194 | } | 200 | } |
| 195 | } | 201 | } |
| 196 | 202 | ||
| 197 | -static void sq_map_param_pack( | 203 | +static void sq_map_param_pack(struct trs_sq_mem_map_para *sq_map_param, struct trs_chan *chan, |
| 198 | - struct trs_sq_mem_map_para *sq_map_param, struct trs_chan *chan, struct trs_chan_sq_ctx *sq) | 204 | + struct trs_chan_sq_ctx *sq) |
| 199 | { | 205 | { |
| 200 | sq_map_param->host_pid = chan->pid; | 206 | sq_map_param->host_pid = chan->pid; |
| 201 | sq_map_param->sq_para = sq->para; | 207 | sq_map_param->sq_para = sq->para; |
| @@ -213,9 +219,8 @@ static int trs_chan_sq_mem_init(struct trs_chan_ts_inst *ts_inst, struct trs_cha | |||
| 213 | if ((sq->para.sq_depth == 0) || (sq->para.sq_depth > trs_chan_get_max_sq_depth(&chan->types)) || | 219 | if ((sq->para.sq_depth == 0) || (sq->para.sq_depth > trs_chan_get_max_sq_depth(&chan->types)) || |
| 214 | (sq->para.sqe_size == 0) || (sq->para.sqe_size > TRS_SQCQ_SLOT_SIZE_MAX) || | 220 | (sq->para.sqe_size == 0) || (sq->para.sqe_size > TRS_SQCQ_SLOT_SIZE_MAX) || |
| 215 | ((sq->para.sqe_size % SQE_ALIGN_SIZE) != 0)) { | 221 | ((sq->para.sqe_size % SQE_ALIGN_SIZE) != 0)) { |
| 216 | - trs_err( | 222 | + trs_err("Invalid alloc para. (devid=%u; tsid=%u; sq_depth=%u; sqe_size=%u)\n", inst->devid, inst->tsid, |
| 217 | - "Invalid alloc para. (devid=%u; tsid=%u; sq_depth=%u; sqe_size=%u)\n", inst->devid, inst->tsid, | 223 | + sq->para.sq_depth, sq->para.sqe_size); |
| 218 | - sq->para.sq_depth, sq->para.sqe_size); | ||
| 219 | return -EINVAL; | 224 | return -EINVAL; |
| 220 | } | 225 | } |
| 221 | 226 | ||
| @@ -274,9 +279,8 @@ static int trs_chan_sq_init(struct trs_chan_ts_inst *ts_inst, struct trs_chan *c | |||
| 274 | ret = ts_inst->ops.sqcq_speified_id_alloc(inst, type, id_flag, &chan->sq.sqid, chan->ext_msg); | 279 | ret = ts_inst->ops.sqcq_speified_id_alloc(inst, type, id_flag, &chan->sq.sqid, chan->ext_msg); |
| 275 | if (ret != 0) { | 280 | if (ret != 0) { |
| 276 | 281 | ||
| 277 | - trs_debug( | 282 | + trs_debug("Alloc sq id failed. (devid=%u; tsid=%u; id_flag=0x%x; ret=%d)\n", inst->devid, inst->tsid, |
| 278 | - "Alloc sq id failed. (devid=%u; tsid=%u; id_flag=0x%x; ret=%d)\n", inst->devid, inst->tsid, id_flag, | 283 | + id_flag, ret); |
| 279 | - ret); | ||
| 280 | 284 | ||
| 281 | return ret; | 285 | return ret; |
| 282 | } | 286 | } |
| @@ -319,9 +323,8 @@ static int trs_chan_sq_init(struct trs_chan_ts_inst *ts_inst, struct trs_chan *c | |||
| 319 | ts_inst->maint_sq_ctx[chan->sq.sqid].chan_id = chan->id; | 323 | ts_inst->maint_sq_ctx[chan->sq.sqid].chan_id = chan->id; |
| 320 | } | 324 | } |
| 321 | 325 | ||
| 322 | - trs_debug( | 326 | + trs_debug("Alloc sq. (devid=%u; tsid=%u; flag=0x%x; id=%d; sqid=%u; mem_type=0x%x)\n", inst->devid, inst->tsid, |
| 323 | - "Alloc sq. (devid=%u; tsid=%u; flag=0x%x; id=%d; sqid=%u; mem_type=0x%x)\n", inst->devid, inst->tsid, | 327 | + chan->flag, chan->id, chan->sq.sqid, chan->sq.mem_attr.mem_type); |
| 324 | - chan->flag, chan->id, chan->sq.sqid, chan->sq.mem_attr.mem_type); | ||
| 325 | 328 | ||
| 326 | return 0; | 329 | return 0; |
| 327 | 330 | ||
| @@ -389,9 +392,8 @@ static int trs_chan_cq_mem_init(struct trs_chan_ts_inst *ts_inst, struct trs_cha | |||
| 389 | if ((chan->cq.para.cq_depth == 0) || (chan->cq.para.cq_depth > trs_chan_get_max_cq_depth(&chan->types)) || | 392 | if ((chan->cq.para.cq_depth == 0) || (chan->cq.para.cq_depth > trs_chan_get_max_cq_depth(&chan->types)) || |
| 390 | (chan->cq.para.cqe_size == 0) || (chan->cq.para.cqe_size > TRS_SQCQ_SLOT_SIZE_MAX) || | 393 | (chan->cq.para.cqe_size == 0) || (chan->cq.para.cqe_size > TRS_SQCQ_SLOT_SIZE_MAX) || |
| 391 | ((chan->cq.para.cqe_size % CQE_ALIGN_SIZE) != 0)) { | 394 | ((chan->cq.para.cqe_size % CQE_ALIGN_SIZE) != 0)) { |
| 392 | - trs_err( | 395 | + trs_err("Invalid alloc para. (devid=%u; tsid=%u; cq_depth=%u; cqe_size=%u)\n", inst->devid, inst->tsid, |
| 393 | - "Invalid alloc para. (devid=%u; tsid=%u; cq_depth=%u; cqe_size=%u)\n", inst->devid, inst->tsid, | 396 | + chan->cq.para.cq_depth, chan->cq.para.cqe_size); |
| 394 | - chan->cq.para.cq_depth, chan->cq.para.cqe_size); | ||
| 395 | return -EINVAL; | 397 | return -EINVAL; |
| 396 | } | 398 | } |
| 397 | 399 | ||
| @@ -424,9 +426,8 @@ static int trs_chan_cq_init(struct trs_chan_ts_inst *ts_inst, struct trs_chan *c | |||
| 424 | ret = ts_inst->ops.sqcq_speified_id_alloc(inst, type, id_flag, &chan->cq.cqid, chan->ext_msg); | 426 | ret = ts_inst->ops.sqcq_speified_id_alloc(inst, type, id_flag, &chan->cq.cqid, chan->ext_msg); |
| 425 | if (ret != 0) { | 427 | if (ret != 0) { |
| 426 | 428 | ||
| 427 | - trs_debug( | 429 | + trs_debug("Alloc cq id failed. (devid=%u; tsid=%u; id_flag=0x%x; ret=%d)\n", inst->devid, inst->tsid, |
| 428 | - "Alloc cq id failed. (devid=%u; tsid=%u; id_flag=0x%x; ret=%d)\n", inst->devid, inst->tsid, id_flag, | 430 | + id_flag, ret); |
| 429 | - ret); | ||
| 430 | 431 | ||
| 431 | return ret; | 432 | return ret; |
| 432 | } | 433 | } |
| @@ -442,9 +443,8 @@ static int trs_chan_cq_init(struct trs_chan_ts_inst *ts_inst, struct trs_chan *c | |||
| 442 | } else { | 443 | } else { |
| 443 | ret = trs_id_alloc(inst, type, &chan->cq.cqid); | 444 | ret = trs_id_alloc(inst, type, &chan->cq.cqid); |
| 444 | if ((ret != 0) || ((chan->types.type == CHAN_TYPE_HW) && (chan->cq.cqid >= ts_inst->cq_max_id))) { | 445 | if ((ret != 0) || ((chan->types.type == CHAN_TYPE_HW) && (chan->cq.cqid >= ts_inst->cq_max_id))) { |
| 445 | - trs_debug( | 446 | + trs_debug("Alloc cq id failed. (devid=%u; tsid=%u; type=%u; cqid=%u; ret=%d)\n", inst->devid, inst->tsid, |
| 446 | - "Alloc cq id failed. (devid=%u; tsid=%u; type=%u; cqid=%u; ret=%d)\n", inst->devid, inst->tsid, | 447 | + chan->types.type, chan->cq.cqid, ret); |
| 447 | - chan->types.type, chan->cq.cqid, ret); | ||
| 448 | return (ret != 0) ? ret : -EFAULT; | 448 | return (ret != 0) ? ret : -EFAULT; |
| 449 | } | 449 | } |
| 450 | } | 450 | } |
| @@ -474,9 +474,8 @@ static int trs_chan_cq_init(struct trs_chan_ts_inst *ts_inst, struct trs_chan *c | |||
| 474 | ts_inst->maint_cq_ctx[chan->cq.cqid].chan_id = chan->id; | 474 | ts_inst->maint_cq_ctx[chan->cq.cqid].chan_id = chan->id; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | - trs_debug( | 477 | + trs_debug("Alloc cq. (devid=%u; tsid=%u; flag=0x%x; id=%d, cqid=%u)\n", inst->devid, inst->tsid, chan->flag, |
| 478 | - "Alloc cq. (devid=%u; tsid=%u; flag=0x%x; id=%d, cqid=%u)\n", inst->devid, inst->tsid, chan->flag, chan->id, | 478 | + chan->id, chan->cq.cqid); |
| 479 | - chan->cq.cqid); | ||
| 480 | 479 | ||
| 481 | return 0; | 480 | return 0; |
| 482 | 481 | ||
| @@ -509,8 +508,8 @@ static void trs_chan_cq_uninit(struct trs_chan_ts_inst *ts_inst, struct trs_chan | |||
| 509 | if (ka_base_atomic_read(&chan->chan_status)) { | 508 | if (ka_base_atomic_read(&chan->chan_status)) { |
| 510 | ka_base_atomic_set(&chan->chan_status, 0); | 509 | ka_base_atomic_set(&chan->chan_status, 0); |
| 511 | (void)ka_task_cancel_work_sync(&chan->work); | 510 | (void)ka_task_cancel_work_sync(&chan->work); |
| 512 | - trs_debug( | 511 | + trs_debug("Cancel work success. (devid=%u; tsid=%u; chan_id=%d)\n", chan->inst.devid, chan->inst.tsid, |
| 513 | - "Cancel work success. (devid=%u; tsid=%u; chan_id=%d)\n", chan->inst.devid, chan->inst.tsid, chan->id); | 512 | + chan->id); |
| 514 | } | 513 | } |
| 515 | 514 | ||
| 516 | if (chan->cq.cq_addr != NULL) { | 515 | if (chan->cq.cq_addr != NULL) { |
| @@ -573,9 +572,8 @@ static int trs_chan_notice_ts(struct trs_chan *chan, u32 op) | |||
| 573 | info.no_cq_mem_flag = 1; | 572 | info.no_cq_mem_flag = 1; |
| 574 | } | 573 | } |
| 575 | 574 | ||
| 576 | - trs_debug( | 575 | + trs_debug("Info. (pid=%d; master_pid=%d; flag=0x%x)\n", ka_task_get_current_tgid(), info.msg[SQCQ_INFO_LENGTH - 1], |
| 577 | - "Info. (pid=%d; master_pid=%d; flag=0x%x)\n", ka_task_get_current_tgid(), info.msg[SQCQ_INFO_LENGTH - 1], | 576 | + chan->flag); |
| 578 | - chan->flag); | ||
| 579 | 577 | ||
| 580 | return chan->ts_inst->ops.notice_ts(inst, &info); | 578 | return chan->ts_inst->ops.notice_ts(inst, &info); |
| 581 | } | 579 | } |
| @@ -596,9 +594,8 @@ static void trs_chan_wait_hw_stop(struct trs_chan *chan) | |||
| 596 | return; | 594 | return; |
| 597 | } | 595 | } |
| 598 | 596 | ||
| 599 | - trs_warn( | 597 | + trs_warn("Abnormal free. (devid=%u; tsid=%u; chan_id=%u; sqId=%u; cqId=%u; sqHead=%u; sqTail=%u)\n", id_inst->devid, |
| 600 | - "Abnormal free. (devid=%u; tsid=%u; chan_id=%u; sqId=%u; cqId=%u; sqHead=%u; sqTail=%u)\n", id_inst->devid, | 598 | + id_inst->tsid, chan->id, chan->sq.sqid, chan->cq.cqid, (u32)sq_head, (u32)sq_tail); |
| 601 | - id_inst->tsid, chan->id, chan->sq.sqid, chan->cq.cqid, (u32)sq_head, (u32)sq_tail); | ||
| 602 | (void)ops->sqcq_ctrl(id_inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_STATUS_SET, 0); | 599 | (void)ops->sqcq_ctrl(id_inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_STATUS_SET, 0); |
| 603 | (void)ops->sqcq_query(id_inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_HEAD, &last_sq_head); | 600 | (void)ops->sqcq_query(id_inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_HEAD, &last_sq_head); |
| 604 | while ((timeout_cnt < 50) && (TRS_IS_REBOOT_ACTIVE == false)) { /* 50 timeout */ | 601 | while ((timeout_cnt < 50) && (TRS_IS_REBOOT_ACTIVE == false)) { /* 50 timeout */ |
| @@ -609,9 +606,8 @@ static void trs_chan_wait_hw_stop(struct trs_chan *chan) | |||
| 609 | timeout_cnt++; | 606 | timeout_cnt++; |
| 610 | 607 | ||
| 611 | ka_system_msleep(100); /* sleep 100 ms */ | 608 | ka_system_msleep(100); /* sleep 100 ms */ |
| 612 | - trs_warn( | 609 | + trs_warn("Wait task done. (devid=%u; tsid=%u; last_sq_head=%u; sq_head=%u; sq_tail=%u; timeout_cnt=%d)\n", |
| 613 | - "Wait task done. (devid=%u; tsid=%u; last_sq_head=%u; sq_head=%u; sq_tail=%u; timeout_cnt=%d)\n", | 610 | + id_inst->devid, id_inst->tsid, (u32)last_sq_head, (u32)sq_head, (u32)sq_tail, timeout_cnt); |
| 614 | - id_inst->devid, id_inst->tsid, (u32)last_sq_head, (u32)sq_head, (u32)sq_tail, timeout_cnt); | ||
| 615 | 611 | ||
| 616 | } | 612 | } |
| 617 | } | 613 | } |
| @@ -773,9 +769,8 @@ static int trs_chan_inst_create(struct trs_chan_ts_inst *ts_inst, struct trs_cha | |||
| 773 | *chan_id = chan->id; | 769 | *chan_id = chan->id; |
| 774 | chan_proc_fs_add_chan(chan); | 770 | chan_proc_fs_add_chan(chan); |
| 775 | 771 | ||
| 776 | - trs_debug( | 772 | + trs_debug("Create success. (devid=%u; tsid=%u; id=%d; type=%u; sub_type=%u; flag=%x)\n", inst->devid, inst->tsid, |
| 777 | - "Create success. (devid=%u; tsid=%u; id=%d; type=%u; sub_type=%u; flag=%x)\n", inst->devid, inst->tsid, | 773 | + chan->id, chan->types.type, chan->types.sub_type, chan->flag); |
| 778 | - chan->id, chan->types.type, chan->types.sub_type, chan->flag); | ||
| 779 | 774 | ||
| 780 | return 0; | 775 | return 0; |
| 781 | } | 776 | } |
| @@ -812,8 +807,8 @@ static void trs_chan_inst_destroy(struct trs_chan *chan) | |||
| 812 | 807 | ||
| 813 | trs_chan_inst_destroy_sync(chan); | 808 | trs_chan_inst_destroy_sync(chan); |
| 814 | 809 | ||
| 815 | - trs_debug( | 810 | + trs_debug("Destroy success. (devid=%u; tsid=%u; id=%d; flag=0x%x)\n", inst->devid, inst->tsid, chan->id, |
| 816 | - "Destroy success. (devid=%u; tsid=%u; id=%d; flag=0x%x)\n", inst->devid, inst->tsid, chan->id, chan->flag); | 811 | + chan->flag); |
| 817 | 812 | ||
| 818 | kref_safe_put(&chan->ref, trs_chan_inst_release); | 813 | kref_safe_put(&chan->ref, trs_chan_inst_release); |
| 819 | } | 814 | } |
| @@ -841,7 +836,10 @@ struct trs_chan *trs_chan_get(struct trs_id_inst *inst, u32 chan_id) | |||
| 841 | return chan; | 836 | return chan; |
| 842 | } | 837 | } |
| 843 | 838 | ||
| 844 | -void trs_chan_put(struct trs_chan *chan) { kref_safe_put(&chan->ref, trs_chan_inst_release); } | 839 | +void trs_chan_put(struct trs_chan *chan) |
| 840 | +{ | ||
| 841 | + kref_safe_put(&chan->ref, trs_chan_inst_release); | ||
| 842 | +} | ||
| 845 | 843 | ||
| 846 | int trs_sq_switch_stream_chan_update(struct trs_id_inst *inst, u32 chan_id, u32 sq_depth) | 844 | int trs_sq_switch_stream_chan_update(struct trs_id_inst *inst, u32 chan_id, u32 sq_depth) |
| 847 | { | 845 | { |
| @@ -878,8 +876,8 @@ void trs_all_chan_cq_work_cancel(struct trs_chan_ts_inst *ts_inst) | |||
| 878 | if (chan != NULL) { | 876 | if (chan != NULL) { |
| 879 | ka_base_atomic_set(&chan->chan_status, 0); | 877 | ka_base_atomic_set(&chan->chan_status, 0); |
| 880 | (void)ka_task_cancel_work_sync(&chan->work); | 878 | (void)ka_task_cancel_work_sync(&chan->work); |
| 881 | - trs_debug( | 879 | + trs_debug("Cancel work success. (devid=%u; tsid=%u; chan_id=%d)\n", chan->inst.devid, chan->inst.tsid, |
| 882 | - "Cancel work success. (devid=%u; tsid=%u; chan_id=%d)\n", chan->inst.devid, chan->inst.tsid, chan->id); | 880 | + chan->id); |
| 883 | trs_chan_put(chan); | 881 | trs_chan_put(chan); |
| 884 | } | 882 | } |
| 885 | } | 883 | } |
| @@ -922,7 +920,10 @@ int hal_kernel_trs_chan_create(struct trs_id_inst *inst, struct trs_chan_para *p | |||
| 922 | } | 920 | } |
| 923 | KA_EXPORT_SYMBOL_GPL(hal_kernel_trs_chan_create); | 921 | KA_EXPORT_SYMBOL_GPL(hal_kernel_trs_chan_create); |
| 924 | 922 | ||
| 925 | -static bool trs_chan_is_need_show(struct trs_chan *chan) { return (chan->stat.hw_err != 0); } | 923 | +static bool trs_chan_is_need_show(struct trs_chan *chan) |
| 924 | +{ | ||
| 925 | + return (chan->stat.hw_err != 0); | ||
| 926 | +} | ||
| 926 | 927 | ||
| 927 | static void trs_chan_detail_show(struct trs_id_inst *inst, struct trs_chan *chan) | 928 | static void trs_chan_detail_show(struct trs_id_inst *inst, struct trs_chan *chan) |
| 928 | { | 929 | { |
| @@ -93,9 +93,8 @@ static int chan_sum_show(ka_seq_file_t *seq, void *offset) | |||
| 93 | struct trs_chan *chan = (struct trs_chan *)ka_fs_get_seq_file_private(seq); | 93 | struct trs_chan *chan = (struct trs_chan *)ka_fs_get_seq_file_private(seq); |
| 94 | char buff[BUFF_LEN]; | 94 | char buff[BUFF_LEN]; |
| 95 | 95 | ||
| 96 | - ka_fs_seq_printf( | 96 | + ka_fs_seq_printf(seq, "id %d ref %u flag 0x%x irq %u type %u subtype %u\n", chan->id, kref_safe_read(&chan->ref), |
| 97 | - seq, "id %d ref %u flag 0x%x irq %u type %u subtype %u\n", chan->id, kref_safe_read(&chan->ref), chan->flag, | 97 | + chan->flag, chan->irq, chan->types.type, chan->types.sub_type); |
| 98 | - chan->irq, chan->types.type, chan->types.sub_type); | ||
| 99 | 98 | ||
| 100 | if (_trs_chan_to_string(chan, buff, BUFF_LEN) > 0) { | 99 | if (_trs_chan_to_string(chan, buff, BUFF_LEN) > 0) { |
| 101 | ka_fs_seq_printf(seq, "%s\n", buff); | 100 | ka_fs_seq_printf(seq, "%s\n", buff); |
| @@ -152,7 +151,10 @@ void chan_proc_fs_add_ts_inst(struct trs_chan_ts_inst *ts_inst) | |||
| 152 | 151 | ||
| 153 | } | 152 | } |
| 154 | 153 | ||
| 155 | -void chan_proc_fs_del_ts_inst(struct trs_chan_ts_inst *ts_inst) { proc_fs_rm_ts_inst_dir(ts_inst, chan_top_entry); } | 154 | +void chan_proc_fs_del_ts_inst(struct trs_chan_ts_inst *ts_inst) |
| 155 | +{ | ||
| 156 | + proc_fs_rm_ts_inst_dir(ts_inst, chan_top_entry); | ||
| 157 | +} | ||
| 156 | 158 | ||
| 157 | static void proc_fs_format_chan_file_name(struct trs_chan *chan, char *name, int len) | 159 | static void proc_fs_format_chan_file_name(struct trs_chan *chan, char *name, int len) |
| 158 | { | 160 | { |
| @@ -171,7 +173,10 @@ void chan_proc_fs_add_chan(struct trs_chan *chan) | |||
| 171 | chan->entry = ka_fs_proc_create_data(name, PROC_FS_MODE, chan->ts_inst->entry, &chan_sum_ops, chan); | 173 | chan->entry = ka_fs_proc_create_data(name, PROC_FS_MODE, chan->ts_inst->entry, &chan_sum_ops, chan); |
| 172 | } | 174 | } |
| 173 | 175 | ||
| 174 | -void chan_proc_fs_del_chan(struct trs_chan *chan) { ka_fs_proc_remove(chan->entry); } | 176 | +void chan_proc_fs_del_chan(struct trs_chan *chan) |
| 177 | +{ | ||
| 178 | + ka_fs_proc_remove(chan->entry); | ||
| 179 | +} | ||
| 175 | 180 | ||
| 176 | void chan_proc_fs_init(void) | 181 | void chan_proc_fs_init(void) |
| 177 | { | 182 | { |
| @@ -181,4 +186,7 @@ void chan_proc_fs_init(void) | |||
| 181 | } | 186 | } |
| 182 | } | 187 | } |
| 183 | 188 | ||
| 184 | -void chan_proc_fs_uninit(void) { (void)ka_fs_remove_proc_subtree("trs_chan", NULL); } | 189 | +void chan_proc_fs_uninit(void) |
| 190 | +{ | ||
| 191 | + (void)ka_fs_remove_proc_subtree("trs_chan", NULL); | ||
| 192 | +} | ||
| @@ -122,8 +122,8 @@ static int trs_chan_submit_wait(struct trs_chan *chan, u32 timeout) | |||
| 122 | struct trs_chan_sq_ctx *sq = &chan->sq; | 122 | struct trs_chan_sq_ctx *sq = &chan->sq; |
| 123 | long ret; | 123 | long ret; |
| 124 | 124 | ||
| 125 | - ret = ka_task_wait_event_interruptible_timeout( | 125 | + ret = ka_task_wait_event_interruptible_timeout(sq->wait_queue, !trs_chan_sq_is_full(sq), |
| 126 | - sq->wait_queue, !trs_chan_sq_is_full(sq), ka_system_msecs_to_jiffies((u32)timeout)); | 126 | + ka_system_msecs_to_jiffies((u32)timeout)); |
| 127 | if (ret == 0) { | 127 | if (ret == 0) { |
| 128 | return -ETIMEDOUT; | 128 | return -ETIMEDOUT; |
| 129 | } else if (ret < 0) { | 129 | } else if (ret < 0) { |
| @@ -297,7 +297,10 @@ static int trs_chan_sem_down(struct trs_chan *chan, int timeout) | |||
| 297 | return ret; | 297 | return ret; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | -static void trs_chan_sem_up(struct trs_chan *chan) { ka_task_up(&chan->sq.sem); } | 300 | +static void trs_chan_sem_up(struct trs_chan *chan) |
| 301 | +{ | ||
| 302 | + ka_task_up(&chan->sq.sem); | ||
| 303 | +} | ||
| 301 | 304 | ||
| 302 | static int trs_chan_send_ex(struct trs_id_inst *inst, int chan_id, struct trs_chan_send_para *para, int addr_domain) | 305 | static int trs_chan_send_ex(struct trs_id_inst *inst, int chan_id, struct trs_chan_send_para *para, int addr_domain) |
| 303 | { | 306 | { |
| @@ -332,9 +335,8 @@ static int trs_chan_send_ex(struct trs_id_inst *inst, int chan_id, struct trs_ch | |||
| 332 | } else { | 335 | } else { |
| 333 | ret = trs_chan_sem_down(chan, para->timeout); | 336 | ret = trs_chan_sem_down(chan, para->timeout); |
| 334 | if (ret != 0) { | 337 | if (ret != 0) { |
| 335 | - trs_warn( | 338 | + trs_warn("Down warn. (devid=%u; tsid=%u; sqid=%u; ret=%d)\n", chan->ts_inst->inst.devid, |
| 336 | - "Down warn. (devid=%u; tsid=%u; sqid=%u; ret=%d)\n", chan->ts_inst->inst.devid, | 339 | + chan->ts_inst->inst.tsid, chan->sq.sqid, ret); |
| 337 | - chan->ts_inst->inst.tsid, chan->sq.sqid, ret); | ||
| 338 | chan->stat.tx_timeout++; | 340 | chan->stat.tx_timeout++; |
| 339 | trs_chan_put(chan); | 341 | trs_chan_put(chan); |
| 340 | return ret; | 342 | return ret; |
| @@ -369,9 +371,8 @@ KA_EXPORT_SYMBOL_GPL(hal_kernel_trs_chan_send); | |||
| 369 | static int trs_chan_update_sq_head(struct trs_chan *chan, u32 sq_head) | 371 | static int trs_chan_update_sq_head(struct trs_chan *chan, u32 sq_head) |
| 370 | { | 372 | { |
| 371 | if (sq_head >= chan->sq.para.sq_depth) { | 373 | if (sq_head >= chan->sq.para.sq_depth) { |
| 372 | - trs_warn( | 374 | + trs_warn("Invalid head. (devid=%u; tsid=%u; sqid=%u; sq_head=%u; sq_depth=%u)\n", chan->ts_inst->inst.devid, |
| 373 | - "Invalid head. (devid=%u; tsid=%u; sqid=%u; sq_head=%u; sq_depth=%u)\n", chan->ts_inst->inst.devid, | 375 | + chan->ts_inst->inst.tsid, chan->sq.sqid, sq_head, chan->sq.para.sq_depth); |
| 374 | - chan->ts_inst->inst.tsid, chan->sq.sqid, sq_head, chan->sq.para.sq_depth); | ||
| 375 | return -EINVAL; | 376 | return -EINVAL; |
| 376 | } | 377 | } |
| 377 | 378 | ||
| @@ -387,8 +388,8 @@ static int trs_chan_set_sq_head(struct trs_chan *chan, u32 sq_head) | |||
| 387 | int ret; | 388 | int ret; |
| 388 | 389 | ||
| 389 | if (sq_head < chan->sq.para.sq_depth) { | 390 | if (sq_head < chan->sq.para.sq_depth) { |
| 390 | - ret = chan->ts_inst->ops.sqcq_ctrl( | 391 | + ret = chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_HEAD_UPDATE, |
| 391 | - &chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_HEAD_UPDATE, sq_head); | 392 | + sq_head); |
| 392 | if (ret != 0) { | 393 | if (ret != 0) { |
| 393 | return ret; | 394 | return ret; |
| 394 | } | 395 | } |
| @@ -400,9 +401,8 @@ static int trs_chan_set_sq_head(struct trs_chan *chan, u32 sq_head) | |||
| 400 | static int trs_chan_update_sq_tail(struct trs_chan *chan, u32 sq_tail) | 401 | static int trs_chan_update_sq_tail(struct trs_chan *chan, u32 sq_tail) |
| 401 | { | 402 | { |
| 402 | if (sq_tail >= chan->sq.para.sq_depth) { | 403 | if (sq_tail >= chan->sq.para.sq_depth) { |
| 403 | - trs_warn( | 404 | + trs_warn("Invalid tail. (devid=%u; tsid=%u; sqid=%u; sq_tail=%u; sq_depth=%u)\n", chan->ts_inst->inst.devid, |
| 404 | - "Invalid tail. (devid=%u; tsid=%u; sqid=%u; sq_tail=%u; sq_depth=%u)\n", chan->ts_inst->inst.devid, | 405 | + chan->ts_inst->inst.tsid, chan->sq.sqid, sq_tail, chan->sq.para.sq_depth); |
| 405 | - chan->ts_inst->inst.tsid, chan->sq.sqid, sq_tail, chan->sq.para.sq_depth); | ||
| 406 | return -EINVAL; | 406 | return -EINVAL; |
| 407 | } | 407 | } |
| 408 | 408 | ||
| @@ -415,8 +415,8 @@ static int trs_chan_set_sq_tail(struct trs_chan *chan, u32 sq_tail) | |||
| 415 | int ret; | 415 | int ret; |
| 416 | 416 | ||
| 417 | if (sq_tail < chan->sq.para.sq_depth) { | 417 | if (sq_tail < chan->sq.para.sq_depth) { |
| 418 | - ret = chan->ts_inst->ops.sqcq_ctrl( | 418 | + ret = chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_TAIL_UPDATE, |
| 419 | - &chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_TAIL_UPDATE, sq_tail); | 419 | + sq_tail); |
| 420 | if (ret != 0) { | 420 | if (ret != 0) { |
| 421 | return ret; | 421 | return ret; |
| 422 | } | 422 | } |
| @@ -427,8 +427,8 @@ static int trs_chan_set_sq_tail(struct trs_chan *chan, u32 sq_tail) | |||
| 427 | 427 | ||
| 428 | static int trs_chan_set_sq_status(struct trs_chan *chan, u32 status) | 428 | static int trs_chan_set_sq_status(struct trs_chan *chan, u32 status) |
| 429 | { | 429 | { |
| 430 | - int ret = | 430 | + int ret = chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_STATUS_SET, |
| 431 | - chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_STATUS_SET, status); | 431 | + status); |
| 432 | if (ret == 0) { | 432 | if (ret == 0) { |
| 433 | chan->sq.status = status; | 433 | chan->sq.status = status; |
| 434 | } | 434 | } |
| @@ -438,8 +438,8 @@ static int trs_chan_set_sq_status(struct trs_chan *chan, u32 status) | |||
| 438 | 438 | ||
| 439 | static int trs_chan_sq_disable_to_enable(struct trs_chan *chan, u32 timeout) | 439 | static int trs_chan_sq_disable_to_enable(struct trs_chan *chan, u32 timeout) |
| 440 | { | 440 | { |
| 441 | - int ret = chan->ts_inst->ops.sqcq_ctrl( | 441 | + int ret = chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->sq.sqid, |
| 442 | - &chan->ts_inst->inst, &chan->types, chan->sq.sqid, CTRL_CMD_SQ_DISABLE_TO_ENABLE, timeout); | 442 | + CTRL_CMD_SQ_DISABLE_TO_ENABLE, timeout); |
| 443 | if (ret == 0) { | 443 | if (ret == 0) { |
| 444 | chan->sq.status = 1; | 444 | chan->sq.status = 1; |
| 445 | } | 445 | } |
| @@ -488,9 +488,8 @@ static int trs_chan_fetch_wait(struct trs_chan *chan, u32 timeout) | |||
| 488 | 488 | ||
| 489 | ret = ka_task_wait_event_interruptible_timeout(cq->wait_queue, (cq->cqe_valid == 1), tm); | 489 | ret = ka_task_wait_event_interruptible_timeout(cq->wait_queue, (cq->cqe_valid == 1), tm); |
| 490 | if (ret == 0) { | 490 | if (ret == 0) { |
| 491 | - trs_warn( | 491 | + trs_warn("Wait timeout. (devid=%u; tsid=%u; type=%u; cqid=%u; timeout=%u)\n", inst->devid, inst->tsid, |
| 492 | - "Wait timeout. (devid=%u; tsid=%u; type=%u; cqid=%u; timeout=%u)\n", inst->devid, inst->tsid, | 492 | + chan->types.type, cq->cqid, timeout); |
| 493 | - chan->types.type, cq->cqid, timeout); | ||
| 494 | return -ETIMEDOUT; | 493 | return -ETIMEDOUT; |
| 495 | } else if (ret < 0) { | 494 | } else if (ret < 0) { |
| 496 | 495 | ||
| @@ -549,16 +548,15 @@ static int trs_chan_fetch(struct trs_chan *chan, u8 *cqe, int addr_domain, u32 t | |||
| 549 | if (((u64)cq_addr % sizeof(u8 *)) != 0) { | 548 | if (((u64)cq_addr % sizeof(u8 *)) != 0) { |
| 550 | /* copy_to_user need addr 8 byte align */ | 549 | /* copy_to_user need addr 8 byte align */ |
| 551 | ret = ka_base_put_user(*(u32 *)cq_addr, (u32 *)cqe); | 550 | ret = ka_base_put_user(*(u32 *)cq_addr, (u32 *)cqe); |
| 552 | - ret |= ka_base_copy_to_user( | 551 | + ret |= ka_base_copy_to_user(cqe + CQE_ALIGN_SIZE, (void *)(cq_addr + CQE_ALIGN_SIZE), |
| 553 | - cqe + CQE_ALIGN_SIZE, (void *)(cq_addr + CQE_ALIGN_SIZE), cq->para.cqe_size - CQE_ALIGN_SIZE); | 552 | + cq->para.cqe_size - CQE_ALIGN_SIZE); |
| 554 | } else { | 553 | } else { |
| 555 | ret = ka_base_copy_to_user(cqe, (void *)cq_addr, cq->para.cqe_size); | 554 | ret = ka_base_copy_to_user(cqe, (void *)cq_addr, cq->para.cqe_size); |
| 556 | } | 555 | } |
| 557 | if (ret != 0) { | 556 | if (ret != 0) { |
| 558 | ka_task_mutex_unlock(&cq->mutex); | 557 | ka_task_mutex_unlock(&cq->mutex); |
| 559 | - trs_err( | 558 | + trs_err("Copy fail. (devid=%u; tsid=%u; cqid=%u; ret=%d)\n", chan->ts_inst->inst.devid, |
| 560 | - "Copy fail. (devid=%u; tsid=%u; cqid=%u; ret=%d)\n", chan->ts_inst->inst.devid, | 559 | + chan->ts_inst->inst.tsid, cq->cqid, ret); |
| 561 | - chan->ts_inst->inst.tsid, cq->cqid, ret); | ||
| 562 | return ret; | 560 | return ret; |
| 563 | } | 561 | } |
| 564 | } | 562 | } |
| @@ -688,9 +686,8 @@ static int trs_chan_cq_dispatch(struct trs_chan *chan, u32 dispatch_num) | |||
| 688 | chan->stat.rx_in++; | 686 | chan->stat.rx_in++; |
| 689 | 687 | ||
| 690 | if (!trs_chan_has_cq_mem(chan)) { | 688 | if (!trs_chan_has_cq_mem(chan)) { |
| 691 | - trs_debug( | 689 | + trs_debug("Unauthorized operation. (devid=%u; tsid=%u; cq_id=%d)\n", chan->ts_inst->inst.devid, |
| 692 | - "Unauthorized operation. (devid=%u; tsid=%u; cq_id=%d)\n", chan->ts_inst->inst.devid, | 690 | + chan->ts_inst->inst.tsid, chan->cq.cqid); |
| 693 | - chan->ts_inst->inst.tsid, chan->cq.cqid); | ||
| 694 | return 0; | 691 | return 0; |
| 695 | } | 692 | } |
| 696 | 693 | ||
| @@ -759,8 +756,8 @@ static int trs_chan_cq_dispatch(struct trs_chan *chan, u32 dispatch_num) | |||
| 759 | ka_mb(); | 756 | ka_mb(); |
| 760 | 757 | ||
| 761 | if (recv_num > 0) { | 758 | if (recv_num > 0) { |
| 762 | - chan->ts_inst->ops.sqcq_ctrl( | 759 | + chan->ts_inst->ops.sqcq_ctrl(&chan->ts_inst->inst, &chan->types, chan->cq.cqid, CTRL_CMD_CQ_HEAD_UPDATE, |
| 763 | - &chan->ts_inst->inst, &chan->types, chan->cq.cqid, CTRL_CMD_CQ_HEAD_UPDATE, cq->cq_head); | 760 | + cq->cq_head); |
| 764 | } | 761 | } |
| 765 | return state; | 762 | return state; |
| 766 | } | 763 | } |
| @@ -810,9 +807,8 @@ static int trs_chan_irq_proc_cqs(struct trs_chan_ts_inst *ts_inst, u32 irq_type, | |||
| 810 | chan->tasklet_running = 0; | 807 | chan->tasklet_running = 0; |
| 811 | trs_chan_put(chan); | 808 | trs_chan_put(chan); |
| 812 | } else { | 809 | } else { |
| 813 | - trs_debug( | 810 | + trs_debug("Chan failed. (devid=%u; tsid=%u; cqid=%u; chan_id=%d)\n", ts_inst->inst.devid, |
| 814 | - "Chan failed. (devid=%u; tsid=%u; cqid=%u; chan_id=%d)\n", ts_inst->inst.devid, ts_inst->inst.tsid, | 811 | + ts_inst->inst.tsid, cqid[i], chan_id); |
| 815 | - cqid[i], chan_id); | ||
| 816 | } | 812 | } |
| 817 | } | 813 | } |
| 818 | return ret; | 814 | return ret; |
| @@ -888,9 +884,8 @@ void trs_chan_cq_guard_work_proc(struct trs_chan_ts_inst *ts_inst) | |||
| 888 | 884 | ||
| 889 | chan = trs_chan_get(&ts_inst->inst, ts_inst->hw_cq_ctx[cqid].chan_id); | 885 | chan = trs_chan_get(&ts_inst->inst, ts_inst->hw_cq_ctx[cqid].chan_id); |
| 890 | if (chan == NULL) { | 886 | if (chan == NULL) { |
| 891 | - trs_debug( | 887 | + trs_debug("Failed to get chan. (devid=%u; cqid=%u; chan_id=%u)\n", ts_inst->inst.devid, cqid, |
| 892 | - "Failed to get chan. (devid=%u; cqid=%u; chan_id=%u)\n", ts_inst->inst.devid, cqid, | 888 | + ts_inst->hw_cq_ctx[cqid].chan_id); |
| 893 | - ts_inst->hw_cq_ctx[cqid].chan_id); | ||
| 894 | continue; | 889 | continue; |
| 895 | } | 890 | } |
| 896 | 891 | ||
| @@ -908,18 +903,16 @@ void trs_chan_cq_guard_work_proc(struct trs_chan_ts_inst *ts_inst) | |||
| 908 | ret = ts_inst->ops.sqcq_query(&chan->inst, &chan->types, cqid, QUERY_CMD_CQ_HEAD, &cq_head); | 903 | ret = ts_inst->ops.sqcq_query(&chan->inst, &chan->types, cqid, QUERY_CMD_CQ_HEAD, &cq_head); |
| 909 | ret |= ts_inst->ops.sqcq_query(&chan->inst, &chan->types, cqid, QUERY_CMD_CQ_TAIL, &cq_tail); | 904 | ret |= ts_inst->ops.sqcq_query(&chan->inst, &chan->types, cqid, QUERY_CMD_CQ_TAIL, &cq_tail); |
| 910 | if (ret != 0) { | 905 | if (ret != 0) { |
| 911 | - trs_debug( | 906 | + trs_debug("Failed to query cq head tail. (ret=%d; devid=%u; cqid=%u; chan_id=%u)\n", ret, |
| 912 | - "Failed to query cq head tail. (ret=%d; devid=%u; cqid=%u; chan_id=%u)\n", ret, ts_inst->inst.devid, | 907 | + ts_inst->inst.devid, cqid, ts_inst->hw_cq_ctx[cqid].chan_id); |
| 913 | - cqid, ts_inst->hw_cq_ctx[cqid].chan_id); | ||
| 914 | trs_chan_put(chan); | 908 | trs_chan_put(chan); |
| 915 | continue; | 909 | continue; |
| 916 | } | 910 | } |
| 917 | time_cost = trs_get_us_timestamp() - chan->interrupt_time_us; | 911 | time_cost = trs_get_us_timestamp() - chan->interrupt_time_us; |
| 918 | if ((cq_head != cq_tail) && (time_cost > 1000000) && (chan->tasklet_running == 0)) { /* 1s = 1000000us */ | 912 | if ((cq_head != cq_tail) && (time_cost > 1000000) && (chan->tasklet_running == 0)) { /* 1s = 1000000us */ |
| 919 | - trs_debug( | 913 | + trs_debug("Guard work process cq. (devid=%u; chan_id=%u; cqid=%u; cq_head=%llu; cq_tail=%llu; " |
| 920 | - "Guard work process cq. (devid=%u; chan_id=%u; cqid=%u; cq_head=%llu; cq_tail=%llu; " | 914 | + "time_cost=%llu)\n", |
| 921 | - "time_cost=%llu)\n", | 915 | + ts_inst->inst.devid, ts_inst->hw_cq_ctx[cqid].chan_id, cqid, cq_head, cq_tail, time_cost); |
| 922 | - ts_inst->inst.devid, ts_inst->hw_cq_ctx[cqid].chan_id, cqid, cq_head, cq_tail, time_cost); | ||
| 923 | ka_task_schedule_work(&chan->work); | 916 | ka_task_schedule_work(&chan->work); |
| 924 | } | 917 | } |
| 925 | trs_chan_put(chan); | 918 | trs_chan_put(chan); |
| @@ -1158,9 +1151,8 @@ int trs_chan_dma_desc_create(struct trs_id_inst *inst, int chan_id, struct trs_c | |||
| 1158 | if ((para->sqe_pos >= chan->sq.para.sq_depth) || | 1151 | if ((para->sqe_pos >= chan->sq.para.sq_depth) || |
| 1159 | (((chan->sq.para.sq_depth - para->sqe_pos) * chan->sq.para.sqe_size) < para->len)) { | 1152 | (((chan->sq.para.sq_depth - para->sqe_pos) * chan->sq.para.sqe_size) < para->len)) { |
| 1160 | trs_chan_put(chan); | 1153 | trs_chan_put(chan); |
| 1161 | - trs_err( | 1154 | + trs_err("Sqe pos or len exceed. (devid=%u; tsid=%u, sqid=%d; sqe_pos=%u; depth=%u; sqe_size=%u)\n", inst->devid, |
| 1162 | - "Sqe pos or len exceed. (devid=%u; tsid=%u, sqid=%d; sqe_pos=%u; depth=%u; sqe_size=%u)\n", inst->devid, | 1155 | + inst->tsid, chan->sq.sqid, para->sqe_pos, chan->sq.para.sq_depth, chan->sq.para.sqe_size); |
| 1163 | - inst->tsid, chan->sq.sqid, para->sqe_pos, chan->sq.para.sq_depth, chan->sq.para.sqe_size); | ||
| 1164 | return -EINVAL; | 1156 | return -EINVAL; |
| 1165 | } | 1157 | } |
| 1166 | 1158 | ||
| @@ -1175,8 +1167,7 @@ int trs_chan_dma_desc_create(struct trs_id_inst *inst, int chan_id, struct trs_c | |||
| 1175 | } | 1167 | } |
| 1176 | KA_EXPORT_SYMBOL_GPL(trs_chan_dma_desc_create); | 1168 | KA_EXPORT_SYMBOL_GPL(trs_chan_dma_desc_create); |
| 1177 | 1169 | ||
| 1178 | -static int trs_chan_hw_info_to_string(struct trs_chan *chan, struct trs_chan_adapt_ops *ops, | 1170 | +static int trs_chan_hw_info_to_string(struct trs_chan *chan, struct trs_chan_adapt_ops *ops, char *buff, u32 buff_len) |
| 1179 | - char *buff, u32 buff_len) | ||
| 1180 | { | 1171 | { |
| 1181 | u64 sq_head, sq_tail, cq_head, cq_tail, sq_status; | 1172 | u64 sq_head, sq_tail, cq_head, cq_tail, sq_status; |
| 1182 | int ret, len = 0; | 1173 | int ret, len = 0; |
| @@ -1188,8 +1179,7 @@ static int trs_chan_hw_info_to_string(struct trs_chan *chan, struct trs_chan_ada | |||
| 1188 | ret = sprintf_s(buff + len, buff_len - len, "sq status %llu ", sq_status); | 1179 | ret = sprintf_s(buff + len, buff_len - len, "sq status %llu ", sq_status); |
| 1189 | } | 1180 | } |
| 1190 | 1181 | ||
| 1191 | - if ((ret > 0) && | 1182 | + if ((ret > 0) && (ops->sqcq_query(&chan->inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_HEAD, &sq_head) == 0)) { |
| 1192 | - (ops->sqcq_query(&chan->inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_HEAD, &sq_head) == 0)) { | ||
| 1193 | len += ret; | 1183 | len += ret; |
| 1194 | ret = sprintf_s(buff + len, buff_len - len, "sq head %llu ", sq_head); | 1184 | ret = sprintf_s(buff + len, buff_len - len, "sq head %llu ", sq_head); |
| 1195 | } | 1185 | } |
| @@ -1200,8 +1190,7 @@ static int trs_chan_hw_info_to_string(struct trs_chan *chan, struct trs_chan_ada | |||
| 1200 | ret = sprintf_s(buff + len, buff_len - len, "stars head %llu ", sq_head); | 1190 | ret = sprintf_s(buff + len, buff_len - len, "stars head %llu ", sq_head); |
| 1201 | } | 1191 | } |
| 1202 | 1192 | ||
| 1203 | - if ((ret > 0) && | 1193 | + if ((ret > 0) && (ops->sqcq_query(&chan->inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_TAIL, &sq_tail) == 0)) { |
| 1204 | - (ops->sqcq_query(&chan->inst, &chan->types, chan->sq.sqid, QUERY_CMD_SQ_TAIL, &sq_tail) == 0)) { | ||
| 1205 | len += ret; | 1194 | len += ret; |
| 1206 | ret = sprintf_s(buff + len, buff_len - len, "sq tail %llu ", sq_tail); | 1195 | ret = sprintf_s(buff + len, buff_len - len, "sq tail %llu ", sq_tail); |
| 1207 | } | 1196 | } |
| @@ -1212,14 +1201,12 @@ static int trs_chan_hw_info_to_string(struct trs_chan *chan, struct trs_chan_ada | |||
| 1212 | ret = sprintf_s(buff + len, buff_len - len, "stars tail %llu ", sq_tail); | 1201 | ret = sprintf_s(buff + len, buff_len - len, "stars tail %llu ", sq_tail); |
| 1213 | } | 1202 | } |
| 1214 | 1203 | ||
| 1215 | - if ((ret > 0) && | 1204 | + if ((ret > 0) && (ops->sqcq_query(&chan->inst, &chan->types, chan->cq.cqid, QUERY_CMD_CQ_HEAD, &cq_head) == 0)) { |
| 1216 | - (ops->sqcq_query(&chan->inst, &chan->types, chan->cq.cqid, QUERY_CMD_CQ_HEAD, &cq_head) == 0)) { | ||
| 1217 | len += ret; | 1205 | len += ret; |
| 1218 | ret = sprintf_s(buff + len, buff_len - len, "cq head %llu ", cq_head); | 1206 | ret = sprintf_s(buff + len, buff_len - len, "cq head %llu ", cq_head); |
| 1219 | } | 1207 | } |
| 1220 | 1208 | ||
| 1221 | - if ((ret > 0) && | 1209 | + if ((ret > 0) && (ops->sqcq_query(&chan->inst, &chan->types, chan->cq.cqid, QUERY_CMD_CQ_TAIL, &cq_tail) == 0)) { |
| 1222 | - (ops->sqcq_query(&chan->inst, &chan->types, chan->cq.cqid, QUERY_CMD_CQ_TAIL, &cq_tail) == 0)) { | ||
| 1223 | len += ret; | 1210 | len += ret; |
| 1224 | ret = sprintf_s(buff + len, buff_len - len, "cq tail %llu ", cq_tail); | 1211 | ret = sprintf_s(buff + len, buff_len - len, "cq tail %llu ", cq_tail); |
| 1225 | } | 1212 | } |
| @@ -1240,13 +1227,12 @@ int _trs_chan_to_string(struct trs_chan *chan, char *buff, u32 buff_len) | |||
| 1240 | ret = sprintf_s(buff, buff_len, " chan details:\n"); | 1227 | ret = sprintf_s(buff, buff_len, " chan details:\n"); |
| 1241 | if ((ret > 0) && trs_chan_has_sq(chan)) { | 1228 | if ((ret > 0) && trs_chan_has_sq(chan)) { |
| 1242 | len += ret; | 1229 | len += ret; |
| 1243 | - ret = sprintf_s( | 1230 | + ret = sprintf_s(buff + len, buff_len - len, |
| 1244 | - buff + len, buff_len - len, | 1231 | + " sq: id(%u),status(%u),head(%u),tail(%u),sqe_size(%u),sq_depth(%u),mem_type(0x%lx)\n" |
| 1245 | - " sq: id(%u),status(%u),head(%u),tail(%u),sqe_size(%u),sq_depth(%u),mem_type(0x%lx)\n" | 1232 | + " stat: tx(%llu),tx_full(%llu),tx_timeout(%llu)\n", |
| 1246 | - " stat: tx(%llu),tx_full(%llu),tx_timeout(%llu)\n", | 1233 | + chan->sq.sqid, chan->sq.status, chan->sq.sq_head, chan->sq.sq_tail, chan->sq.para.sqe_size, |
| 1247 | - chan->sq.sqid, chan->sq.status, chan->sq.sq_head, chan->sq.sq_tail, chan->sq.para.sqe_size, | 1234 | + chan->sq.para.sq_depth, chan->sq.mem_attr.mem_type, chan->stat.tx, chan->stat.tx_full, |
| 1248 | - chan->sq.para.sq_depth, chan->sq.mem_attr.mem_type, chan->stat.tx, chan->stat.tx_full, | 1235 | + chan->stat.tx_timeout); |
| 1249 | - chan->stat.tx_timeout); | ||
| 1250 | } | 1236 | } |
| 1251 | 1237 | ||
| 1252 | if ((ret > 0) && trs_chan_has_cq(chan)) { | 1238 | if ((ret > 0) && trs_chan_has_cq(chan)) { |
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | -static inline void trs_chan_sq_to_trace( | 20 | +static inline void trs_chan_sq_to_trace(struct trs_chan *chan, struct trs_chan_sq_ctx *sq, |
| 21 | - struct trs_chan *chan, struct trs_chan_sq_ctx *sq, struct trs_chan_sq_trace *sq_trace) | 21 | + struct trs_chan_sq_trace *sq_trace) |
| 22 | { | 22 | { |
| 23 | sq_trace->sqid = sq->sqid; | 23 | sq_trace->sqid = sq->sqid; |
| 24 | sq_trace->sq_head = sq->sq_head; | 24 | sq_trace->sq_head = sq->sq_head; |
| @@ -27,8 +27,8 @@ static inline void trs_chan_sq_to_trace( | |||
| 27 | sq_trace->types = chan->types; | 27 | sq_trace->types = chan->types; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | -static inline void tra_chan_cq_to_trace( | 30 | +static inline void tra_chan_cq_to_trace(struct trs_chan *chan, struct trs_chan_cq_ctx *cq, |
| 31 | - struct trs_chan *chan, struct trs_chan_cq_ctx *cq, struct trs_chan_cq_trace *cq_trace) | 31 | + struct trs_chan_cq_trace *cq_trace) |
| 32 | { | 32 | { |
| 33 | cq_trace->cqid = cq->cqid; | 33 | cq_trace->cqid = cq->cqid; |
| 34 | cq_trace->cq_head = cq->cq_head; | 34 | cq_trace->cq_head = cq->cq_head; |
| @@ -60,14 +60,13 @@ void trs_chan_trace_sqe(const char *str, struct trs_chan *chan, struct trs_chan_ | |||
| 60 | void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para) | 60 | void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para) |
| 61 | { | 61 | { |
| 62 | if (trs_chan_trace_is_enabled(chan->ts_inst) && (chan->ops.trace_cqe_fill != NULL)) { | 62 | if (trs_chan_trace_is_enabled(chan->ts_inst) && (chan->ops.trace_cqe_fill != NULL)) { |
| 63 | - struct trs_chan_recv_trace recv_trace = { | 63 | + struct trs_chan_recv_trace recv_trace = {.chan_id = chan->id, |
| 64 | - .chan_id = chan->id, | 64 | + .types = chan->types, |
| 65 | - .types = chan->types, | 65 | + .cqid = chan->cq.cqid, |
| 66 | - .cqid = chan->cq.cqid, | 66 | + .cq_head = chan->cq.cq_head, |
| 67 | - .cq_head = chan->cq.cq_head, | 67 | + .cqe_num = para->cqe_num, |
| 68 | - .cqe_num = para->cqe_num, | 68 | + .recv_cqe_num = para->recv_cqe_num, |
| 69 | - .recv_cqe_num = para->recv_cqe_num, | 69 | + .timeout = para->timeout}; |
| 70 | - .timeout = para->timeout}; | ||
| 71 | trace_recv(str, &chan->inst, &recv_trace); | 70 | trace_recv(str, &chan->inst, &recv_trace); |
| 72 | } | 71 | } |
| 73 | } | 72 | } |
| @@ -34,9 +34,12 @@ void trs_chan_trace_sqe(const char *str, struct trs_chan *chan, struct trs_chan_ | |||
| 34 | void trs_chan_trace_cqe(const char *str, struct trs_chan *chan, struct trs_chan_cq_ctx *cq, void *cqe); | 34 | void trs_chan_trace_cqe(const char *str, struct trs_chan *chan, struct trs_chan_cq_ctx *cq, void *cqe); |
| 35 | void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para); | 35 | void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para); |
| 36 | 36 | ||
| 37 | -static inline void trs_chan_trace_sqe(const char *str, struct trs_chan *chan, struct trs_chan_sq_ctx *sq, void *sqe) {} | 37 | +static inline void trs_chan_trace_sqe(const char *str, struct trs_chan *chan, struct trs_chan_sq_ctx *sq, void *sqe) |
| 38 | -static inline void trs_chan_trace_cqe(const char *str, struct trs_chan *chan, struct trs_chan_cq_ctx *cq, void *cqe) {} | 38 | +{} |
| 39 | -static inline void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para) {} | 39 | +static inline void trs_chan_trace_cqe(const char *str, struct trs_chan *chan, struct trs_chan_cq_ctx *cq, void *cqe) |
| 40 | +{} | ||
| 41 | +static inline void trace_chan_trace_recv(const char *str, struct trs_chan *chan, struct trs_chan_recv_para *para) | ||
| 42 | +{} | ||
| 40 | 43 | ||
| 41 | 44 | ||
| 42 | 45 | ||
| @@ -24,68 +24,68 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | -KA_DFX_TRACE_EVENT( | 27 | +KA_DFX_TRACE_EVENT(sqe, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_sq_trace *sq_trace), |
| 28 | - sqe, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_sq_trace *sq_trace), | 28 | + KA_DFX_TP_ARGS(str, inst, sq_trace), |
| 29 | - KA_DFX_TP_ARGS(str, inst, sq_trace), | 29 | + KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) |
| 30 | - KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) | 30 | + __ka_dfx_field_struct(struct trs_chan_sq_trace, sq_trace) |
| 31 | - __ka_dfx_field_struct(struct trs_chan_sq_trace, sq_trace) | 31 | + __ka_dfx_field_struct(ka_timespec64_t, timestamp)), |
| 32 | - __ka_dfx_field_struct(ka_timespec64_t, timestamp)), | 32 | + KA_DFX_TP_fast_assign( |
| 33 | - KA_DFX_TP_fast_assign( | 33 | + if (str != NULL) { __ka_dfx_assign_str(str, str); } else { |
| 34 | - if (str != NULL) { __ka_dfx_assign_str(str, str); } else { | 34 | + __ka_dfx_assign_str(str, "nop"); |
| 35 | - __ka_dfx_assign_str(str, "nop"); | 35 | + } __ka_entry->inst = *inst; |
| 36 | - } __ka_entry->inst = *inst; | 36 | + __ka_entry->sq_trace = *sq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), |
| 37 | - __ka_entry->sq_trace = *sq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), | 37 | + KA_DFX_TP_printk("%s:\t" |
| 38 | - KA_DFX_TP_printk( | 38 | + "devid=%u;" |
| 39 | - "%s:\t" | 39 | + "tsid=%u;" |
| 40 | - "devid=%u;" | 40 | + "chan_id=%u;" |
| 41 | - "tsid=%u;" | 41 | + "chan_name=%s;" |
| 42 | - "chan_id=%u;" | 42 | + "sqid=%u;" |
| 43 | - "chan_name=%s;" | 43 | + "sq_head=%u;" |
| 44 | - "sqid=%u;" | 44 | + "sq_tail=%u;" |
| 45 | - "sq_head=%u;" | 45 | + "sqe_type=%u;" |
| 46 | - "sq_tail=%u;" | 46 | + "task_id=%u;" |
| 47 | - "sqe_type=%u;" | 47 | + "stream_id=%u;" |
| 48 | - "task_id=%u;" | 48 | + "%lld.%06ld", |
| 49 | - "stream_id=%u;" | 49 | + __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, |
| 50 | - "%lld.%06ld", | 50 | + __ka_entry->sq_trace.chan_id, trs_chan_type_to_name(&__ka_entry->sq_trace.types), |
| 51 | - __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, __ka_entry->sq_trace.chan_id, | 51 | + __ka_entry->sq_trace.sqid, __ka_entry->sq_trace.sq_head, |
| 52 | - trs_chan_type_to_name(&__ka_entry->sq_trace.types), __ka_entry->sq_trace.sqid, __ka_entry->sq_trace.sq_head, | 52 | + __ka_entry->sq_trace.sq_tail, __ka_entry->sq_trace.type, |
| 53 | - __ka_entry->sq_trace.sq_tail, __ka_entry->sq_trace.type, __ka_entry->sq_trace.task_id, | 53 | + __ka_entry->sq_trace.task_id, __ka_entry->sq_trace.stream_id, |
| 54 | - __ka_entry->sq_trace.stream_id, | 54 | + /* tv_sec type is depends on linux version */ |
| 55 | - /* tv_sec type is depends on linux version */ | 55 | + (long long)__ka_entry->timestamp.tv_sec, |
| 56 | - (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); | 56 | + __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)); |
| 57 | 57 | ||
| 58 | -KA_DFX_TRACE_EVENT( | 58 | +KA_DFX_TRACE_EVENT(cqe, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_cq_trace *cq_trace), |
| 59 | - cqe, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_cq_trace *cq_trace), | 59 | + KA_DFX_TP_ARGS(str, inst, cq_trace), |
| 60 | - KA_DFX_TP_ARGS(str, inst, cq_trace), | 60 | + KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) |
| 61 | - KA_DFX_TP_STRUCT__entry(__ka_dfx_string(str, str) __ka_dfx_field_struct(struct trs_id_inst, inst) | 61 | + __ka_dfx_field_struct(struct trs_chan_cq_trace, cq_trace) |
| 62 | - __ka_dfx_field_struct(struct trs_chan_cq_trace, cq_trace) | 62 | + __ka_dfx_field_struct(ka_timespec64_t, timestamp)), |
| 63 | - __ka_dfx_field_struct(ka_timespec64_t, timestamp)), | 63 | + KA_DFX_TP_fast_assign( |
| 64 | - KA_DFX_TP_fast_assign( | 64 | + if (str != NULL) { __ka_dfx_assign_str(str, str); } else { |
| 65 | - if (str != NULL) { __ka_dfx_assign_str(str, str); } else { | 65 | + __ka_dfx_assign_str(str, "nop"); |
| 66 | - __ka_dfx_assign_str(str, "nop"); | 66 | + } __ka_entry->inst = *inst; |
| 67 | - } __ka_entry->inst = *inst; | 67 | + __ka_entry->cq_trace = *cq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), |
| 68 | - __ka_entry->cq_trace = *cq_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), | 68 | + KA_DFX_TP_printk("%s:\t" |
| 69 | - KA_DFX_TP_printk( | 69 | + "devid=%u;" |
| 70 | - "%s:\t" | 70 | + "tsid=%u;" |
| 71 | - "devid=%u;" | 71 | + "chan_id=%u;" |
| 72 | - "tsid=%u;" | 72 | + "chan_name=%s;" |
| 73 | - "chan_id=%u;" | 73 | + "cqid=%u;" |
| 74 | - "chan_name=%s;" | 74 | + "cq_head=%u;" |
| 75 | - "cqid=%u;" | 75 | + "round=%u;" |
| 76 | - "cq_head=%u;" | 76 | + "task_id=%u;" |
| 77 | - "round=%u;" | 77 | + "stream_id=%u;" |
| 78 | - "task_id=%u;" | 78 | + "sq_id=%u;" |
| 79 | - "stream_id=%u;" | 79 | + "sq_head=%u;" |
| 80 | - "sq_id=%u;" | 80 | + "%lld.%06ld", |
| 81 | - "sq_head=%u;" | 81 | + __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, |
| 82 | - "%lld.%06ld", | 82 | + __ka_entry->cq_trace.chan_id, trs_chan_type_to_name(&__ka_entry->cq_trace.types), |
| 83 | - __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, __ka_entry->cq_trace.chan_id, | 83 | + __ka_entry->cq_trace.cqid, __ka_entry->cq_trace.cq_head, __ka_entry->cq_trace.round, |
| 84 | - trs_chan_type_to_name(&__ka_entry->cq_trace.types), __ka_entry->cq_trace.cqid, __ka_entry->cq_trace.cq_head, | 84 | + __ka_entry->cq_trace.task_id, __ka_entry->cq_trace.stream_id, |
| 85 | - __ka_entry->cq_trace.round, __ka_entry->cq_trace.task_id, __ka_entry->cq_trace.stream_id, | 85 | + __ka_entry->cq_trace.sq_id, __ka_entry->cq_trace.sq_head, |
| 86 | - __ka_entry->cq_trace.sq_id, __ka_entry->cq_trace.sq_head, | 86 | + /* tv_sec type is depends on linux version */ |
| 87 | - /* tv_sec type is depends on linux version */ | 87 | + (long long)__ka_entry->timestamp.tv_sec, |
| 88 | - (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)) | 88 | + __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)) |
| 89 | 89 | ||
| 90 | KA_DFX_TRACE_EVENT( | 90 | KA_DFX_TRACE_EVENT( |
| 91 | recv, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_recv_trace *recv_trace), | 91 | recv, KA_DFX_TP_PROTO(const char *str, struct trs_id_inst *inst, struct trs_chan_recv_trace *recv_trace), |
| @@ -98,24 +98,23 @@ KA_DFX_TRACE_EVENT( | |||
| 98 | __ka_dfx_assign_str(str, "nop"); | 98 | __ka_dfx_assign_str(str, "nop"); |
| 99 | } __ka_entry->inst = *inst; | 99 | } __ka_entry->inst = *inst; |
| 100 | __ka_entry->recv_trace = *recv_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), | 100 | __ka_entry->recv_trace = *recv_trace; ka_system_ktime_get_ts64(&__ka_entry->timestamp);), |
| 101 | - KA_DFX_TP_printk( | 101 | + KA_DFX_TP_printk("%s:\t" |
| 102 | - "%s:\t" | 102 | + "devid=%u;" |
| 103 | - "devid=%u;" | 103 | + "tsid=%u;" |
| 104 | - "tsid=%u;" | 104 | + "chan_id=%u;" |
| 105 | - "chan_id=%u;" | 105 | + "chan_name=%s;" |
| 106 | - "chan_name=%s;" | 106 | + "cqid=%u;" |
| 107 | - "cqid=%u;" | 107 | + "cq_head=%u;" |
| 108 | - "cq_head=%u;" | 108 | + "cqe_num=%u;" |
| 109 | - "cqe_num=%u;" | 109 | + "recv_cqe_num=%u;" |
| 110 | - "recv_cqe_num=%u;" | 110 | + "timeout=%d;" |
| 111 | - "timeout=%d;" | 111 | + "%lld.%06ld", |
| 112 | - "%lld.%06ld", | 112 | + __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, |
| 113 | - __ka_dfx_get_str(str), __ka_entry->inst.devid, __ka_entry->inst.tsid, __ka_entry->recv_trace.chan_id, | 113 | + __ka_entry->recv_trace.chan_id, trs_chan_type_to_name(&__ka_entry->recv_trace.types), |
| 114 | - trs_chan_type_to_name(&__ka_entry->recv_trace.types), __ka_entry->recv_trace.cqid, | 114 | + __ka_entry->recv_trace.cqid, __ka_entry->recv_trace.cq_head, __ka_entry->recv_trace.cqe_num, |
| 115 | - __ka_entry->recv_trace.cq_head, __ka_entry->recv_trace.cqe_num, __ka_entry->recv_trace.recv_cqe_num, | 115 | + __ka_entry->recv_trace.recv_cqe_num, __ka_entry->recv_trace.timeout, |
| 116 | - __ka_entry->recv_trace.timeout, | 116 | + /* tv_sec type is depends on linux version */ |
| 117 | - /* tv_sec type is depends on linux version */ | 117 | + (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)) |
| 118 | - (long long)__ka_entry->timestamp.tv_sec, __ka_entry->timestamp.tv_nsec / KA_NSEC_PER_USEC)) | ||
| 119 | 118 | ||
| 120 | 119 | ||
| 121 | /* This part must be outside protection */ | 120 | /* This part must be outside protection */ |
| @@ -35,8 +35,8 @@ static struct trs_chan_ts_inst *chan_ts_inst[TRS_TS_INST_MAX_NUM] = { | |||
| 35 | NULL, | 35 | NULL, |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | -static void trs_chan_ts_inst_irq_hw_res_uninit( | 38 | +static void trs_chan_ts_inst_irq_hw_res_uninit(struct trs_chan_ts_inst *ts_inst, struct trs_chan_irq_ctx *irq_ctx, |
| 39 | - struct trs_chan_ts_inst *ts_inst, struct trs_chan_irq_ctx *irq_ctx, u32 irq_num) | 39 | + u32 irq_num) |
| 40 | { | 40 | { |
| 41 | struct trs_id_inst *inst = &ts_inst->inst; | 41 | struct trs_id_inst *inst = &ts_inst->inst; |
| 42 | int ret; | 42 | int ret; |
| @@ -66,8 +66,8 @@ static void trs_chan_ts_inst_irq_uninit(struct trs_chan_ts_inst *ts_inst, struct | |||
| 66 | trs_chan_ts_inst_irq_sw_res_uninit(irq_ctx); | 66 | trs_chan_ts_inst_irq_sw_res_uninit(irq_ctx); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | -static int trs_chan_ts_inst_irq_init( | 69 | +static int trs_chan_ts_inst_irq_init(struct trs_chan_ts_inst *ts_inst, u32 irq_type, struct trs_chan_irq_ctx **irq, |
| 70 | - struct trs_chan_ts_inst *ts_inst, u32 irq_type, struct trs_chan_irq_ctx **irq, u32 *num) | 70 | + u32 *num) |
| 71 | { | 71 | { |
| 72 | struct trs_id_inst *inst = &ts_inst->inst; | 72 | struct trs_id_inst *inst = &ts_inst->inst; |
| 73 | struct trs_chan_irq_ctx *irq_ctx = NULL; | 73 | struct trs_chan_irq_ctx *irq_ctx = NULL; |
| @@ -313,8 +313,8 @@ static void trs_chan_cq_guard_work_sched(ka_work_struct_t *p_work) | |||
| 313 | trs_debug("Sched cq guard work. (devid=%u; cq_max_id=%u)\n", ts_inst->inst.devid, ts_inst->cq_max_id); | 313 | trs_debug("Sched cq guard work. (devid=%u; cq_max_id=%u)\n", ts_inst->inst.devid, ts_inst->cq_max_id); |
| 314 | trs_chan_cq_guard_work_proc(ts_inst); | 314 | trs_chan_cq_guard_work_proc(ts_inst); |
| 315 | if (ts_inst->guard_work.work_magic == TRS_CHAN_GUARD_WORK_MAGIC) { | 315 | if (ts_inst->guard_work.work_magic == TRS_CHAN_GUARD_WORK_MAGIC) { |
| 316 | - ka_task_schedule_delayed_work( | 316 | + ka_task_schedule_delayed_work(&ts_inst->guard_work.cq_guard_work, |
| 317 | - &ts_inst->guard_work.cq_guard_work, ka_system_msecs_to_jiffies(TRS_CHAN_GUARD_WORK_DELAY_MS)); | 317 | + ka_system_msecs_to_jiffies(TRS_CHAN_GUARD_WORK_DELAY_MS)); |
| 318 | } | 318 | } |
| 319 | } | 319 | } |
| 320 | 320 | ||
| @@ -113,6 +113,9 @@ static inline int trs_chan_maint_cq_to_chan_id(struct trs_chan_ts_inst *ts_inst, | |||
| 113 | return (cqid < ts_inst->maint_cq_max_id) ? ts_inst->maint_cq_ctx[cqid].chan_id : -1; | 113 | return (cqid < ts_inst->maint_cq_max_id) ? ts_inst->maint_cq_ctx[cqid].chan_id : -1; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | -static inline bool trs_chan_trace_is_enabled(struct trs_chan_ts_inst *ts_inst) { return ts_inst->trace_enable; } | 116 | +static inline bool trs_chan_trace_is_enabled(struct trs_chan_ts_inst *ts_inst) |
| 117 | +{ | ||
| 118 | + return ts_inst->trace_enable; | ||
| 119 | +} | ||
| 117 | 120 | ||
| 118 | 121 | ||
| @@ -76,11 +76,20 @@ size_t trs_id_get_pool_size(void); | |||
| 76 | int init_trs_id(void); | 76 | int init_trs_id(void); |
| 77 | void exit_trs_id(void); | 77 | void exit_trs_id(void); |
| 78 | 78 | ||
| 79 | -static u32 trs_id_make_hash_key(u32 isolate_num, u32 id) { return (id / isolate_num * isolate_num); } | 79 | +static u32 trs_id_make_hash_key(u32 isolate_num, u32 id) |
| 80 | +{ | ||
| 81 | + return (id / isolate_num * isolate_num); | ||
| 82 | +} | ||
| 80 | 83 | ||
| 81 | -size_t trs_id_get_node_size(void) { return sizeof(struct trs_id_node); } | 84 | +size_t trs_id_get_node_size(void) |
| 85 | +{ | ||
| 86 | + return sizeof(struct trs_id_node); | ||
| 87 | +} | ||
| 82 | 88 | ||
| 83 | -size_t trs_id_get_pool_size(void) { return sizeof(struct trs_id_pool); } | 89 | +size_t trs_id_get_pool_size(void) |
| 90 | +{ | ||
| 91 | + return sizeof(struct trs_id_pool); | ||
| 92 | +} | ||
| 84 | 93 | ||
| 85 | static struct trs_id_node *trs_id_node_create(void) | 94 | static struct trs_id_node *trs_id_node_create(void) |
| 86 | { | 95 | { |
| @@ -166,9 +175,8 @@ static int trs_id_pool_add_rsv_node(struct trs_id_pool *id_pool, u32 id) | |||
| 166 | { | 175 | { |
| 167 | struct trs_id_rsv_node *node = trs_id_rsv_node_create(); | 176 | struct trs_id_rsv_node *node = trs_id_rsv_node_create(); |
| 168 | if (node == NULL) { | 177 | if (node == NULL) { |
| 169 | - trs_err( | 178 | + trs_err("Alloc id node fail. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, |
| 170 | - "Alloc id node fail. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, | 179 | + trs_id_type_to_name(id_pool->type), id); |
| 171 | - trs_id_type_to_name(id_pool->type), id); | ||
| 172 | return -ENOMEM; | 180 | return -ENOMEM; |
| 173 | } | 181 | } |
| 174 | 182 | ||
| @@ -177,9 +185,8 @@ static int trs_id_pool_add_rsv_node(struct trs_id_pool *id_pool, u32 id) | |||
| 177 | id_pool->rsv_num++; | 185 | id_pool->rsv_num++; |
| 178 | ka_list_add(&node->list, &id_pool->rsv_head); | 186 | ka_list_add(&node->list, &id_pool->rsv_head); |
| 179 | id_pool->allocatable_num++; | 187 | id_pool->allocatable_num++; |
| 180 | - trs_debug( | 188 | + trs_debug("Add rsv node. (devid=%u; type=%s; allocatable_num=%u; id=%u; pid=%d)\n", id_pool->inst.devid, |
| 181 | - "Add rsv node. (devid=%u; type=%s; allocatable_num=%u; id=%u; pid=%d)\n", id_pool->inst.devid, | 189 | + trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, id, node->pid); |
| 182 | - trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, id, node->pid); | ||
| 183 | return 0; | 190 | return 0; |
| 184 | } | 191 | } |
| 185 | 192 | ||
| @@ -187,9 +194,8 @@ static int trs_id_pool_add_new_node(struct trs_id_pool *id_pool, u32 flag, u32 i | |||
| 187 | { | 194 | { |
| 188 | struct trs_id_node *node = trs_id_node_create(); | 195 | struct trs_id_node *node = trs_id_node_create(); |
| 189 | if (node == NULL) { | 196 | if (node == NULL) { |
| 190 | - trs_err( | 197 | + trs_err("Alloc id node fail. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, |
| 191 | - "Alloc id node fail. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, | 198 | + trs_id_type_to_name(id_pool->type), id); |
| 192 | - trs_id_type_to_name(id_pool->type), id); | ||
| 193 | return -ENOMEM; | 199 | return -ENOMEM; |
| 194 | } | 200 | } |
| 195 | 201 | ||
| @@ -208,10 +214,9 @@ static int trs_id_pool_add_new_node(struct trs_id_pool *id_pool, u32 flag, u32 i | |||
| 208 | ka_list_add_tail(&node->list, &id_pool->idle_head); | 214 | ka_list_add_tail(&node->list, &id_pool->idle_head); |
| 209 | } | 215 | } |
| 210 | 216 | ||
| 211 | - trs_debug( | 217 | + trs_debug("Add node. (devid=%u; type=%s; node_start=%u; node_total_num=%u; allocatable_num=%u; id=%u)\n", |
| 212 | - "Add node. (devid=%u; type=%s; node_start=%u; node_total_num=%u; allocatable_num=%u; id=%u)\n", | 218 | + id_pool->inst.devid, trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num, |
| 213 | - id_pool->inst.devid, trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num, | 219 | + id_pool->allocatable_num, id); |
| 214 | - id_pool->allocatable_num, id); | ||
| 215 | return 0; | 220 | return 0; |
| 216 | } | 221 | } |
| 217 | 222 | ||
| @@ -244,16 +249,14 @@ static void trs_id_pool_move_node(struct trs_id_pool *id_pool, struct trs_id_nod | |||
| 244 | } | 249 | } |
| 245 | node->pid = 0; | 250 | node->pid = 0; |
| 246 | node->is_in_idle = 1; | 251 | node->is_in_idle = 1; |
| 247 | - trs_debug( | 252 | + trs_debug("Add to idle list. (devid=%u; type=%s; id_start=%u; id_total_num=%u)\n", id_pool->inst.devid, |
| 248 | - "Add to idle list. (devid=%u; type=%s; id_start=%u; id_total_num=%u)\n", id_pool->inst.devid, | 253 | + trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num); |
| 249 | - trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num); | ||
| 250 | } else { | 254 | } else { |
| 251 | ka_list_del(&node->list); | 255 | ka_list_del(&node->list); |
| 252 | ka_hash_add(id_pool->allocated_htable, &node->link, node->id_start); | 256 | ka_hash_add(id_pool->allocated_htable, &node->link, node->id_start); |
| 253 | node->is_in_idle = 0; | 257 | node->is_in_idle = 0; |
| 254 | - trs_debug( | 258 | + trs_debug("Add to allocated list. (devid=%u; type=%s; id_start=%u; id_total_num=%u)\n", id_pool->inst.devid, |
| 255 | - "Add to allocated list. (devid=%u; type=%s; id_start=%u; id_total_num=%u)\n", id_pool->inst.devid, | 259 | + trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num); |
| 256 | - trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num); | ||
| 257 | } | 260 | } |
| 258 | } | 261 | } |
| 259 | 262 | ||
| @@ -273,11 +276,16 @@ static void trs_id_pool_del_node_all(struct trs_id_pool *id_pool) | |||
| 273 | ka_hlist_node_t *tmp = NULL; | 276 | ka_hlist_node_t *tmp = NULL; |
| 274 | u32 bkt = 0; | 277 | u32 bkt = 0; |
| 275 | 278 | ||
| 276 | - ka_hash_for_each_safe(id_pool->allocated_htable, bkt, tmp, node, link) { trs_id_pool_del_node(node); } | 279 | + ka_hash_for_each_safe(id_pool->allocated_htable, bkt, tmp, node, link) |
| 277 | - ka_list_for_each_entry_safe(node, n, &id_pool->idle_head, list) { trs_id_pool_del_node(node); } | 280 | + { |
| 278 | - trs_debug( | 281 | + trs_id_pool_del_node(node); |
| 279 | - "Id pool del node all. (devid=%u; type=%s; alloc_num=%u; allocatable_num=%u)\n", id_pool->inst.devid, | 282 | + } |
| 280 | - trs_id_type_to_name(id_pool->type), id_pool->alloc_num, id_pool->allocatable_num); | 283 | + ka_list_for_each_entry_safe(node, n, &id_pool->idle_head, list) |
| 284 | + { | ||
| 285 | + trs_id_pool_del_node(node); | ||
| 286 | + } | ||
| 287 | + trs_debug("Id pool del node all. (devid=%u; type=%s; alloc_num=%u; allocatable_num=%u)\n", id_pool->inst.devid, | ||
| 288 | + trs_id_type_to_name(id_pool->type), id_pool->alloc_num, id_pool->allocatable_num); | ||
| 281 | } | 289 | } |
| 282 | 290 | ||
| 283 | static int trs_id_node_all(struct trs_id_pool *id_pool) | 291 | static int trs_id_node_all(struct trs_id_pool *id_pool) |
| @@ -295,8 +303,8 @@ static int trs_id_node_all(struct trs_id_pool *id_pool) | |||
| 295 | return 0; | 303 | return 0; |
| 296 | } | 304 | } |
| 297 | 305 | ||
| 298 | -static struct trs_id_pool *trs_id_pool_create( | 306 | +static struct trs_id_pool *trs_id_pool_create(struct trs_id_inst *inst, int type, struct trs_id_attr *attr, |
| 299 | - struct trs_id_inst *inst, int type, struct trs_id_attr *attr, struct trs_id_ops *ops) | 307 | + struct trs_id_ops *ops) |
| 300 | { | 308 | { |
| 301 | struct trs_id_pool *id_pool = trs_kzalloc(trs_id_get_pool_size(), KA_GFP_KERNEL | __KA_GFP_ACCOUNT); | 309 | struct trs_id_pool *id_pool = trs_kzalloc(trs_id_get_pool_size(), KA_GFP_KERNEL | __KA_GFP_ACCOUNT); |
| 302 | 310 | ||
| @@ -390,9 +398,8 @@ static int trs_id_pool_alloc_one_id_in_node(struct trs_id_pool *id_pool, struct | |||
| 390 | } | 398 | } |
| 391 | } | 399 | } |
| 392 | if (alloc_id == -1) { | 400 | if (alloc_id == -1) { |
| 393 | - trs_err( | 401 | + trs_err("Node has no resource. (alloc_id=%d; start=%u; total_num=%u; avail_num=%u)\n", alloc_id, node->id_start, |
| 394 | - "Node has no resource. (alloc_id=%d; start=%u; total_num=%u; avail_num=%u)\n", alloc_id, node->id_start, | 402 | + node->id_total_num, node->id_avail_num); |
| 395 | - node->id_total_num, node->id_avail_num); | ||
| 396 | return alloc_id; | 403 | return alloc_id; |
| 397 | } | 404 | } |
| 398 | if (node->pid == 0) { | 405 | if (node->pid == 0) { |
| @@ -402,11 +409,10 @@ static int trs_id_pool_alloc_one_id_in_node(struct trs_id_pool *id_pool, struct | |||
| 402 | node->id_avail_num--; | 409 | node->id_avail_num--; |
| 403 | id_pool->allocatable_num--; | 410 | id_pool->allocatable_num--; |
| 404 | *id = (u32)alloc_id; | 411 | *id = (u32)alloc_id; |
| 405 | - trs_debug( | 412 | + trs_debug("Alloc success. (type=%s; id=%d; start=%u; avail_num=%u; total_num=%u; isolate_num=%u; " |
| 406 | - "Alloc success. (type=%s; id=%d; start=%u; avail_num=%u; total_num=%u; isolate_num=%u; " | 413 | + "allocatable_num=%u)\n", |
| 407 | - "allocatable_num=%u)\n", | 414 | + trs_id_type_to_name(id_pool->type), alloc_id, node->id_start, node->id_avail_num, node->id_total_num, |
| 408 | - trs_id_type_to_name(id_pool->type), alloc_id, node->id_start, node->id_avail_num, node->id_total_num, | 415 | + id_pool->attr.isolate_num, id_pool->allocatable_num); |
| 409 | - id_pool->attr.isolate_num, id_pool->allocatable_num); | ||
| 410 | return 0; | 416 | return 0; |
| 411 | } | 417 | } |
| 412 | 418 | ||
| @@ -434,10 +440,9 @@ static int trs_id_pool_alloc_id_in_idle_node(struct trs_id_pool *id_pool, u32 ba | |||
| 434 | } | 440 | } |
| 435 | } | 441 | } |
| 436 | if (node->id_avail_num == 0) { | 442 | if (node->id_avail_num == 0) { |
| 437 | - trs_debug( | 443 | + trs_debug("Del node. (type=%s; start=%u; total_num=%u; avail_num=%u; allocatable_num=%u; alloc=%u)\n", |
| 438 | - "Del node. (type=%s; start=%u; total_num=%u; avail_num=%u; allocatable_num=%u; alloc=%u)\n", | 444 | + trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num, node->id_avail_num, |
| 439 | - trs_id_type_to_name(id_pool->type), node->id_start, node->id_total_num, node->id_avail_num, | 445 | + id_pool->allocatable_num, id_pool->alloc_num); |
| 440 | - id_pool->allocatable_num, id_pool->alloc_num); | ||
| 441 | trs_id_pool_del_node(node); | 446 | trs_id_pool_del_node(node); |
| 442 | } | 447 | } |
| 443 | return 0; | 448 | return 0; |
| @@ -450,9 +455,8 @@ static int trs_id_pool_try_free_batch(struct trs_id_pool *id_pool) | |||
| 450 | return 0; | 455 | return 0; |
| 451 | } | 456 | } |
| 452 | 457 | ||
| 453 | - trs_debug( | 458 | + trs_debug("Free info. (type=%s; batch_num=%u; allocatable_num=%u; rsv_num=%u)\n", |
| 454 | - "Free info. (type=%s; batch_num=%u; allocatable_num=%u; rsv_num=%u)\n", trs_id_type_to_name(id_pool->type), | 459 | + trs_id_type_to_name(id_pool->type), id_pool->attr.batch_num, id_pool->allocatable_num, id_pool->rsv_num); |
| 455 | - id_pool->attr.batch_num, id_pool->allocatable_num, id_pool->rsv_num); | ||
| 456 | 460 | ||
| 457 | while (id_pool->allocatable_num > 0) { | 461 | while (id_pool->allocatable_num > 0) { |
| 458 | /* allocatable_num - rsv_num = not rsv num*/ | 462 | /* allocatable_num - rsv_num = not rsv num*/ |
| @@ -470,17 +474,15 @@ static int trs_id_pool_try_free_batch(struct trs_id_pool *id_pool) | |||
| 470 | } | 474 | } |
| 471 | 475 | ||
| 472 | if (batch_num == 0) { | 476 | if (batch_num == 0) { |
| 473 | - trs_warn( | 477 | + trs_warn("Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", |
| 474 | - "Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", | 478 | + trs_id_type_to_name(id_pool->type), batch_num, id_pool->allocatable_num, ret); |
| 475 | - trs_id_type_to_name(id_pool->type), batch_num, id_pool->allocatable_num, ret); | ||
| 476 | break; | 479 | break; |
| 477 | } | 480 | } |
| 478 | 481 | ||
| 479 | ret = id_pool->ops.free_batch(&id_pool->inst, id_pool->type, id, batch_num); | 482 | ret = id_pool->ops.free_batch(&id_pool->inst, id_pool->type, id, batch_num); |
| 480 | if (ret != 0) { | 483 | if (ret != 0) { |
| 481 | - trs_warn( | 484 | + trs_warn("Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", |
| 482 | - "Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", | 485 | + trs_id_type_to_name(id_pool->type), batch_num, id_pool->allocatable_num, ret); |
| 483 | - trs_id_type_to_name(id_pool->type), batch_num, id_pool->allocatable_num, ret); | ||
| 484 | for (idx = 0; idx < batch_num; idx++) { | 486 | for (idx = 0; idx < batch_num; idx++) { |
| 485 | (void)trs_id_pool_add_node(id_pool, 0, id[idx]); | 487 | (void)trs_id_pool_add_node(id_pool, 0, id[idx]); |
| 486 | } | 488 | } |
| @@ -519,9 +521,8 @@ static int trs_id_pool_add(int type, struct trs_id_pool *id_pool) | |||
| 519 | ka_task_mutex_lock(&g_trs_id_mutex); | 521 | ka_task_mutex_lock(&g_trs_id_mutex); |
| 520 | if (g_trs_id_pool[ts_inst][type] != NULL) { | 522 | if (g_trs_id_pool[ts_inst][type] != NULL) { |
| 521 | ka_task_mutex_unlock(&g_trs_id_mutex); | 523 | ka_task_mutex_unlock(&g_trs_id_mutex); |
| 522 | - trs_err( | 524 | + trs_err("[%s] id pool exists. (devid=%u; tsid=%u)\n", trs_id_type_to_name(type), id_pool->inst.devid, |
| 523 | - "[%s] id pool exists. (devid=%u; tsid=%u)\n", trs_id_type_to_name(type), id_pool->inst.devid, | 525 | + id_pool->inst.tsid); |
| 524 | - id_pool->inst.tsid); | ||
| 525 | return -ENODEV; | 526 | return -ENODEV; |
| 526 | } | 527 | } |
| 527 | g_trs_id_pool[ts_inst][type] = id_pool; | 528 | g_trs_id_pool[ts_inst][type] = id_pool; |
| @@ -612,9 +613,8 @@ static void trs_id_pool_put(struct trs_id_pool *id_pool) | |||
| 612 | static int trs_id_pool_range_check(struct trs_id_pool *id_pool, u32 id) | 613 | static int trs_id_pool_range_check(struct trs_id_pool *id_pool, u32 id) |
| 613 | { | 614 | { |
| 614 | if ((id < id_pool->attr.id_start) || (id >= (id_pool->attr.id_end))) { | 615 | if ((id < id_pool->attr.id_start) || (id >= (id_pool->attr.id_end))) { |
| 615 | - trs_err( | 616 | + trs_err("Trs id range check fail. (id_start=%u; id_end=%u; type=%d; id=%u)\n", id_pool->attr.id_start, |
| 616 | - "Trs id range check fail. (id_start=%u; id_end=%u; type=%d; id=%u)\n", id_pool->attr.id_start, | 617 | + id_pool->attr.id_end, id_pool->type, id); |
| 617 | - id_pool->attr.id_end, id_pool->type, id); | ||
| 618 | return -EBADR; | 618 | return -EBADR; |
| 619 | } | 619 | } |
| 620 | return 0; | 620 | return 0; |
| @@ -682,10 +682,9 @@ static int trs_id_alloc_non_cache(struct trs_id_pool *id_pool, u32 flag, u32 *id | |||
| 682 | 682 | ||
| 683 | ret = id_pool->ops.alloc_batch(&id_pool->inst, id_pool->type, flag, id, &id_num); | 683 | ret = id_pool->ops.alloc_batch(&id_pool->inst, id_pool->type, flag, id, &id_num); |
| 684 | if ((ret != 0) || (id_num > id_pool->attr.batch_num) || (id_num == 0)) { | 684 | if ((ret != 0) || (id_num > id_pool->attr.batch_num) || (id_num == 0)) { |
| 685 | - trs_debug( | 685 | + trs_debug("Alloc batch fail. (devid=%u; tsid=%u; real_id_num=%u; batch_num=%u; type=%s; ret=%d)\n", |
| 686 | - "Alloc batch fail. (devid=%u; tsid=%u; real_id_num=%u; batch_num=%u; type=%s; ret=%d)\n", | 686 | + id_pool->inst.devid, id_pool->inst.tsid, id_num, id_pool->attr.batch_num, |
| 687 | - id_pool->inst.devid, id_pool->inst.tsid, id_num, id_pool->attr.batch_num, | 687 | + trs_id_type_to_name(id_pool->type), ret); |
| 688 | - trs_id_type_to_name(id_pool->type), ret); | ||
| 689 | return -ENOSPC; | 688 | return -ENOSPC; |
| 690 | } | 689 | } |
| 691 | 690 | ||
| @@ -693,8 +692,8 @@ static int trs_id_alloc_non_cache(struct trs_id_pool *id_pool, u32 flag, u32 *id | |||
| 693 | return ret; | 692 | return ret; |
| 694 | } | 693 | } |
| 695 | 694 | ||
| 696 | -static int trs_id_pool_alloc_specified_id_in_node( | 695 | +static int trs_id_pool_alloc_specified_id_in_node(struct trs_id_pool *id_pool, struct trs_id_node *node, u32 start, |
| 697 | - struct trs_id_pool *id_pool, struct trs_id_node *node, u32 start, u32 end, u32 *id) | 696 | + u32 end, u32 *id) |
| 698 | { | 697 | { |
| 699 | int tmp_id = -1; | 698 | int tmp_id = -1; |
| 700 | u32 offset, offset_start, offset_end; | 699 | u32 offset, offset_start, offset_end; |
| @@ -710,9 +709,8 @@ static int trs_id_pool_alloc_specified_id_in_node( | |||
| 710 | } | 709 | } |
| 711 | } | 710 | } |
| 712 | if (tmp_id == -1) { | 711 | if (tmp_id == -1) { |
| 713 | - trs_err( | 712 | + trs_err("Node has no resource. (alloc_id=%d; start=%u; total_num=%u; avail_num=%u)\n", tmp_id, node->id_start, |
| 714 | - "Node has no resource. (alloc_id=%d; start=%u; total_num=%u; avail_num=%u)\n", tmp_id, node->id_start, | 713 | + node->id_total_num, node->id_avail_num); |
| 715 | - node->id_total_num, node->id_avail_num); | ||
| 716 | return tmp_id; | 714 | return tmp_id; |
| 717 | } | 715 | } |
| 718 | 716 | ||
| @@ -723,9 +721,8 @@ static int trs_id_pool_alloc_specified_id_in_node( | |||
| 723 | node->id_avail_num--; | 721 | node->id_avail_num--; |
| 724 | id_pool->allocatable_num--; | 722 | id_pool->allocatable_num--; |
| 725 | *id = (u32)tmp_id; | 723 | *id = (u32)tmp_id; |
| 726 | - trs_debug( | 724 | + trs_debug("Alloc specified id. (devid=%u; type=%s; id=%u; id_start=%d; id_end=%d; node_pid=%d)\n", |
| 727 | - "Alloc specified id. (devid=%u; type=%s; id=%u; id_start=%d; id_end=%d; node_pid=%d)\n", id_pool->inst.devid, | 725 | + id_pool->inst.devid, trs_id_type_to_name(id_pool->type), *id, offset_start, offset_end, node->pid); |
| 728 | - trs_id_type_to_name(id_pool->type), *id, offset_start, offset_end, node->pid); | ||
| 729 | return 0; | 726 | return 0; |
| 730 | } | 727 | } |
| 731 | 728 | ||
| @@ -810,9 +807,8 @@ static void trs_id_print_isolated_res_detail(struct trs_id_pool *id_pool) | |||
| 810 | ka_hlist_node_t *tmp = NULL; | 807 | ka_hlist_node_t *tmp = NULL; |
| 811 | u32 bkt = 0; | 808 | u32 bkt = 0; |
| 812 | 809 | ||
| 813 | - trs_err( | 810 | + trs_err("No res. (devid=%u; tsid=%u; type=%s; allocatable_num=%u; alloc_num=%u)\n", id_pool->inst.devid, |
| 814 | - "No res. (devid=%u; tsid=%u; type=%s; allocatable_num=%u; alloc_num=%u)\n", id_pool->inst.devid, | 811 | + id_pool->inst.tsid, trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, id_pool->alloc_num); |
| 815 | - id_pool->inst.tsid, trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, id_pool->alloc_num); | ||
| 816 | 812 | ||
| 817 | ka_hash_for_each_safe(id_pool->allocated_htable, bkt, tmp, node, link) | 813 | ka_hash_for_each_safe(id_pool->allocated_htable, bkt, tmp, node, link) |
| 818 | { | 814 | { |
| @@ -845,26 +841,24 @@ static int trs_id_alloc_cache(struct trs_id_pool *id_pool, u32 flag, u32 *id, u3 | |||
| 845 | 841 | ||
| 846 | if (trs_id_is_specified(flag)) { | 842 | if (trs_id_is_specified(flag)) { |
| 847 | if (!trs_id_pool_find_specified_id(id_pool, *id, (*id) + num, id)) { | 843 | if (!trs_id_pool_find_specified_id(id_pool, *id, (*id) + num, id)) { |
| 848 | - trs_err( | 844 | + trs_err("Fail to alloc id in range. (devid=%u; type=%s; start=%u; end=%u)\n", id_pool->inst.devid, |
| 849 | - "Fail to alloc id in range. (devid=%u; type=%s; start=%u; end=%u)\n", id_pool->inst.devid, | 845 | + trs_id_type_to_name(id_pool->type), *id, (*id) + num); |
| 850 | - trs_id_type_to_name(id_pool->type), *id, (*id) + num); | ||
| 851 | return -ENOSPC; | 846 | return -ENOSPC; |
| 852 | } | 847 | } |
| 853 | } else { | 848 | } else { |
| 854 | int ret; | 849 | int ret; |
| 855 | ret = trs_id_pool_alloc_one_available_id(id_pool, id); | 850 | ret = trs_id_pool_alloc_one_available_id(id_pool, id); |
| 856 | if (ret != 0) { | 851 | if (ret != 0) { |
| 857 | - trs_err( | 852 | + trs_err("Alloc id failed. (ret=%d; devid=%u; type=%s; allocatable_num=%u; alloc_num=%u)\n", ret, |
| 858 | - "Alloc id failed. (ret=%d; devid=%u; type=%s; allocatable_num=%u; alloc_num=%u)\n", ret, | 853 | + id_pool->inst.devid, trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, |
| 859 | - id_pool->inst.devid, trs_id_type_to_name(id_pool->type), id_pool->allocatable_num, id_pool->alloc_num); | 854 | + id_pool->alloc_num); |
| 860 | return ret; | 855 | return ret; |
| 861 | } | 856 | } |
| 862 | } | 857 | } |
| 863 | 858 | ||
| 864 | id_pool->alloc_num++; | 859 | id_pool->alloc_num++; |
| 865 | - trs_debug( | 860 | + trs_debug("Alloc id. (devid=%u; type=%s; id=%u; allocatable_num=%u; alloc_num=%u)\n", id_pool->inst.devid, |
| 866 | - "Alloc id. (devid=%u; type=%s; id=%u; allocatable_num=%u; alloc_num=%u)\n", id_pool->inst.devid, | 861 | + trs_id_type_to_name(id_pool->type), *id, id_pool->allocatable_num, id_pool->alloc_num); |
| 867 | - trs_id_type_to_name(id_pool->type), *id, id_pool->allocatable_num, id_pool->alloc_num); | ||
| 868 | 862 | ||
| 869 | return 0; | 863 | return 0; |
| 870 | } | 864 | } |
| @@ -888,9 +882,8 @@ static int trs_id_free_non_cache(struct trs_id_pool *id_pool, u32 flag, u32 id) | |||
| 888 | 882 | ||
| 889 | ret = id_pool->ops.free_batch(&id_pool->inst, id_pool->type, &id, 1); | 883 | ret = id_pool->ops.free_batch(&id_pool->inst, id_pool->type, &id, 1); |
| 890 | if (ret != 0) { | 884 | if (ret != 0) { |
| 891 | - trs_warn( | 885 | + trs_warn("Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", |
| 892 | - "Free batch warn. (type=%s; batch_num=%u; allocatable_num=%u; ret=%d)\n", | 886 | + trs_id_type_to_name(id_pool->type), id_pool->attr.batch_num, id_pool->allocatable_num, ret); |
| 893 | - trs_id_type_to_name(id_pool->type), id_pool->attr.batch_num, id_pool->allocatable_num, ret); | ||
| 894 | return ret; | 887 | return ret; |
| 895 | } | 888 | } |
| 896 | 889 | ||
| @@ -905,9 +898,8 @@ static int trs_id_free_cache(struct trs_id_pool *id_pool, u32 flag, u32 id) | |||
| 905 | 898 | ||
| 906 | node = trs_id_pool_get_allocated_node_by_id(id_pool, id); | 899 | node = trs_id_pool_get_allocated_node_by_id(id_pool, id); |
| 907 | if (node == NULL) { | 900 | if (node == NULL) { |
| 908 | - trs_err( | 901 | + trs_err("Invalid id. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, |
| 909 | - "Invalid id. (devid=%u; tsid=%u; type=%s; id=%u)\n", id_pool->inst.devid, id_pool->inst.tsid, | 902 | + trs_id_type_to_name(id_pool->type), id); |
| 910 | - trs_id_type_to_name(id_pool->type), id); | ||
| 911 | return -EINVAL; | 903 | return -EINVAL; |
| 912 | } | 904 | } |
| 913 | 905 | ||
| @@ -922,11 +914,10 @@ static int trs_id_free_cache(struct trs_id_pool *id_pool, u32 flag, u32 id) | |||
| 922 | } | 914 | } |
| 923 | 915 | ||
| 924 | id_pool->alloc_num--; | 916 | id_pool->alloc_num--; |
| 925 | - trs_debug( | 917 | + trs_debug("Free id. (ret=%d; devid=%u; type=%s; id=%u; node_start=%u; avail_num=%u; total=%u; allocatable_num=%u; " |
| 926 | - "Free id. (ret=%d; devid=%u; type=%s; id=%u; node_start=%u; avail_num=%u; total=%u; allocatable_num=%u; " | 918 | + "alloc_num=%u)\n", |
| 927 | - "alloc_num=%u)\n", | 919 | + ret, id_pool->inst.devid, trs_id_type_to_name(id_pool->type), id, node->id_start, node->id_avail_num, |
| 928 | - ret, id_pool->inst.devid, trs_id_type_to_name(id_pool->type), id, node->id_start, node->id_avail_num, | 920 | + node->id_total_num, id_pool->allocatable_num, id_pool->alloc_num); |
| 929 | - node->id_total_num, id_pool->allocatable_num, id_pool->alloc_num); | ||
| 930 | return ret; | 921 | return ret; |
| 931 | } | 922 | } |
| 932 | 923 | ||
| @@ -988,10 +979,9 @@ int trs_id_register(struct trs_id_inst *inst, int type, struct trs_id_attr *attr | |||
| 988 | trs_id_pool_destroy(id_pool); | 979 | trs_id_pool_destroy(id_pool); |
| 989 | return ret; | 980 | return ret; |
| 990 | } | 981 | } |
| 991 | - trs_debug( | 982 | + trs_debug("Trs id init. (devid=%u; tsid=%u; type=%s; start=%u; end=%u; num=%u; split=%u; isolate_num=%u)\n", |
| 992 | - "Trs id init. (devid=%u; tsid=%u; type=%s; start=%u; end=%u; num=%u; split=%u; isolate_num=%u)\n", inst->devid, | 983 | + inst->devid, inst->tsid, trs_id_type_to_name(type), attr->id_start, attr->id_end, attr->id_num, |
| 993 | - inst->tsid, trs_id_type_to_name(type), attr->id_start, attr->id_end, attr->id_num, attr->split, | 984 | + attr->split, attr->isolate_num); |
| 994 | - attr->isolate_num); | ||
| 995 | return 0; | 985 | return 0; |
| 996 | } | 986 | } |
| 997 | KA_EXPORT_SYMBOL_GPL(trs_id_register); | 987 | KA_EXPORT_SYMBOL_GPL(trs_id_register); |
| @@ -1169,9 +1159,8 @@ int trs_id_alloc_ex(struct trs_id_inst *inst, int type, u32 flag, u32 *id, u32 p | |||
| 1169 | } | 1159 | } |
| 1170 | 1160 | ||
| 1171 | if ((ret == 0) && (id != NULL)) { | 1161 | if ((ret == 0) && (id != NULL)) { |
| 1172 | - trs_debug( | 1162 | + trs_debug("Alloc success. (devid=%u; type=%s; flag=0x%x; para=%u; id=%u)\n", inst->devid, |
| 1173 | - "Alloc success. (devid=%u; type=%s; flag=0x%x; para=%u; id=%u)\n", inst->devid, trs_id_type_to_name(type), | 1163 | + trs_id_type_to_name(type), flag, para, *id); |
| 1174 | - flag, para, *id); | ||
| 1175 | } | 1164 | } |
| 1176 | 1165 | ||
| 1177 | return ret; | 1166 | return ret; |
| @@ -1219,9 +1208,8 @@ int trs_id_flush_to_pool(struct trs_id_inst *inst) | |||
| 1219 | for (type = TRS_STREAM_ID; type < TRS_ID_TYPE_MAX; type++) { | 1208 | for (type = TRS_STREAM_ID; type < TRS_ID_TYPE_MAX; type++) { |
| 1220 | if (trs_id_free_batch_by_type(inst, type) != 0) { | 1209 | if (trs_id_free_batch_by_type(inst, type) != 0) { |
| 1221 | ret = -ENODEV; | 1210 | ret = -ENODEV; |
| 1222 | - trs_err( | 1211 | + trs_err("Id fush to pool fail. (devid=%u; tsid=%u; type=%s)\n", inst->devid, inst->tsid, |
| 1223 | - "Id fush to pool fail. (devid=%u; tsid=%u; type=%s)\n", inst->devid, inst->tsid, | 1212 | + trs_id_type_to_name(type)); |
| 1224 | - trs_id_type_to_name(type)); | ||
| 1225 | } | 1213 | } |
| 1226 | } | 1214 | } |
| 1227 | 1215 | ||
| @@ -1260,9 +1248,8 @@ static void _trs_id_clear_reserved_flag(struct trs_id_pool *id_pool, ka_pid_t pi | |||
| 1260 | 1248 | ||
| 1261 | hash_node = trs_id_pool_get_current_node_by_id(id_pool, id); | 1249 | hash_node = trs_id_pool_get_current_node_by_id(id_pool, id); |
| 1262 | if (hash_node == NULL) { | 1250 | if (hash_node == NULL) { |
| 1263 | - trs_warn( | 1251 | + trs_warn("Invalid id. (devid=%u; type=%s; id=%u)\n", id_pool->inst.devid, |
| 1264 | - "Invalid id. (devid=%u; type=%s; id=%u)\n", id_pool->inst.devid, trs_id_type_to_name(id_pool->type), | 1252 | + trs_id_type_to_name(id_pool->type), id); |
| 1265 | - id); | ||
| 1266 | continue; | 1253 | continue; |
| 1267 | } | 1254 | } |
| 1268 | 1255 | ||
| @@ -158,7 +158,10 @@ struct trs_chan_mem_attr { | |||
| 158 | void *specified_uva; | 158 | void *specified_uva; |
| 159 | }; | 159 | }; |
| 160 | 160 | ||
| 161 | -static inline bool trs_chan_mem_is_local_mem(u32 mem_type) { return ((mem_type & TRS_CHAN_MEM_TYPE_LOCAL_MASK) != 0); } | 161 | +static inline bool trs_chan_mem_is_local_mem(u32 mem_type) |
| 162 | +{ | ||
| 163 | + return ((mem_type & TRS_CHAN_MEM_TYPE_LOCAL_MASK) != 0); | ||
| 164 | +} | ||
| 162 | 165 | ||
| 163 | static inline bool trs_chan_mem_is_dev_mem(u32 mem_type) | 166 | static inline bool trs_chan_mem_is_dev_mem(u32 mem_type) |
| 164 | { | 167 | { |
| @@ -180,16 +183,14 @@ struct trs_chan_dma_desc { | |||
| 180 | 183 | ||
| 181 | struct trs_chan_adapt_ops { | 184 | struct trs_chan_adapt_ops { |
| 182 | ka_module_t *owner; | 185 | ka_module_t *owner; |
| 183 | - void *(*sq_mem_alloc)( | 186 | + void *(*sq_mem_alloc)(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, |
| 184 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_sq_para *sq_para, | 187 | + struct trs_chan_mem_attr *mem_attr); |
| 185 | - struct trs_chan_mem_attr *mem_attr); | 188 | + void (*sq_mem_free)(struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, |
| 186 | - void (*sq_mem_free)( | 189 | + struct trs_chan_mem_attr *mem_attr); |
| 187 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *sq_addr, struct trs_chan_mem_attr *mem_attr); | 190 | + void *(*cq_mem_alloc)(struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, |
| 188 | - void *(*cq_mem_alloc)( | 191 | + struct trs_chan_mem_attr *mem_attr); |
| 189 | - struct trs_id_inst *inst, struct trs_chan_type *types, struct trs_chan_cq_para *cq_para, | 192 | + void (*cq_mem_free)(struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, |
| 190 | - struct trs_chan_mem_attr *mem_attr); | 193 | + struct trs_chan_mem_attr *mem_attr); |
| 191 | - void (*cq_mem_free)( | ||
| 192 | - struct trs_id_inst *inst, struct trs_chan_type *types, void *cq_addr, struct trs_chan_mem_attr *mem_attr); | ||
| 193 | 194 | ||
| 194 | bool (*is_current_proc_sq)(struct trs_id_inst *inst, u32 sqid); /* not must */ | 195 | bool (*is_current_proc_sq)(struct trs_id_inst *inst, u32 sqid); /* not must */ |
| 195 | bool (*is_current_proc_cq)(struct trs_id_inst *inst, u32 cqid); /* not must */ | 196 | bool (*is_current_proc_cq)(struct trs_id_inst *inst, u32 cqid); /* not must */ |
| @@ -210,9 +211,8 @@ struct trs_chan_adapt_ops { | |||
| 210 | 211 | ||
| 211 | int (*get_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, u32 *valid_irq_num); | 212 | int (*get_irq)(struct trs_id_inst *inst, u32 irq_type, u32 irq[], u32 irq_num, u32 *valid_irq_num); |
| 212 | int (*get_cq_affinity_irq)(struct trs_id_inst *inst, u32 cq_id, u32 *irq_index); | 213 | int (*get_cq_affinity_irq)(struct trs_id_inst *inst, u32 cq_id, u32 *irq_index); |
| 213 | - int (*request_irq)( | 214 | + int (*request_irq)(struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, |
| 214 | - struct trs_id_inst *inst, u32 irq_type, int irq_index, void *para, | 215 | + int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); |
| 215 | - int (*handler)(int irq_type, int irq_index, void *para, u32 cqid[], u32 cq_num)); | ||
| 216 | int (*free_irq)(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); | 216 | int (*free_irq)(struct trs_id_inst *inst, int irq_type, int irq_index, void *para); |
| 217 | int (*sq_mem_map)(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void **sq_dev_vaddr); | 217 | int (*sq_mem_map)(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void **sq_dev_vaddr); |
| 218 | int (*sq_mem_unmap)(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void *sq_dev_vaddr); | 218 | int (*sq_mem_unmap)(struct trs_id_inst *inst, struct trs_sq_mem_map_para *para, void *sq_dev_vaddr); |
| @@ -91,19 +91,40 @@ struct trs_id_stat { | |||
| 91 | u32 rsv_num; | 91 | u32 rsv_num; |
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | -static inline bool trs_id_is_specified(u32 flag) { return ((flag & (0x1 << TRS_ID_SPECIFIED_BIT)) != 0); } | 94 | +static inline bool trs_id_is_specified(u32 flag) |
| 95 | +{ | ||
| 96 | + return ((flag & (0x1 << TRS_ID_SPECIFIED_BIT)) != 0); | ||
| 97 | +} | ||
| 95 | 98 | ||
| 96 | -static inline bool trs_id_is_reserved(u32 flag) { return ((flag & (0x1 << TRS_ID_RESERVED_BIT)) != 0); } | 99 | +static inline bool trs_id_is_reserved(u32 flag) |
| 100 | +{ | ||
| 101 | + return ((flag & (0x1 << TRS_ID_RESERVED_BIT)) != 0); | ||
| 102 | +} | ||
| 97 | 103 | ||
| 98 | -static inline bool trs_id_is_ranged(u32 flag) { return ((flag & (0x1 << TRS_ID_RANGE_BIT)) != 0); } | 104 | +static inline bool trs_id_is_ranged(u32 flag) |
| 105 | +{ | ||
| 106 | + return ((flag & (0x1 << TRS_ID_RANGE_BIT)) != 0); | ||
| 107 | +} | ||
| 99 | 108 | ||
| 100 | -static inline void trs_id_set_specified_flag(u32 *flag) { *flag |= (0x1 << TRS_ID_SPECIFIED_BIT); } | 109 | +static inline void trs_id_set_specified_flag(u32 *flag) |
| 110 | +{ | ||
| 111 | + *flag |= (0x1 << TRS_ID_SPECIFIED_BIT); | ||
| 112 | +} | ||
| 101 | 113 | ||
| 102 | -static inline void trs_id_set_reserved_flag(u32 *flag) { *flag |= (0x1 << TRS_ID_RESERVED_BIT); } | 114 | +static inline void trs_id_set_reserved_flag(u32 *flag) |
| 115 | +{ | ||
| 116 | + *flag |= (0x1 << TRS_ID_RESERVED_BIT); | ||
| 117 | +} | ||
| 103 | 118 | ||
| 104 | -static inline void trs_id_set_range_flag(u32 *flag) { *flag |= (0x1 << TRS_ID_RANGE_BIT); } | 119 | +static inline void trs_id_set_range_flag(u32 *flag) |
| 120 | +{ | ||
| 121 | + *flag |= (0x1 << TRS_ID_RANGE_BIT); | ||
| 122 | +} | ||
| 105 | 123 | ||
| 106 | -static inline bool trs_id_is_rts_rsv_flag(u32 flag) { return ((flag & (0x1U << TRS_ID_RTS_RSV_BIT)) != 0); } | 124 | +static inline bool trs_id_is_rts_rsv_flag(u32 flag) |
| 125 | +{ | ||
| 126 | + return ((flag & (0x1U << TRS_ID_RTS_RSV_BIT)) != 0); | ||
| 127 | +} | ||
| 107 | 128 | ||
| 108 | /* Stream Id, Event id, etc., initialized by adapt */ | 129 | /* Stream Id, Event id, etc., initialized by adapt */ |
| 109 | int trs_id_register(struct trs_id_inst *inst, int type, struct trs_id_attr *attr, struct trs_id_ops *ops); | 130 | int trs_id_register(struct trs_id_inst *inst, int type, struct trs_id_attr *attr, struct trs_id_ops *ops); |
| @@ -126,7 +147,10 @@ static inline int trs_id_alloc(struct trs_id_inst *inst, int type, u32 *id) | |||
| 126 | return trs_id_alloc_ex(inst, type, 0, id, 1); | 147 | return trs_id_alloc_ex(inst, type, 0, id, 1); |
| 127 | } | 148 | } |
| 128 | 149 | ||
| 129 | -static inline int trs_id_free(struct trs_id_inst *inst, int type, u32 id) { return trs_id_free_ex(inst, type, 0, id); } | 150 | +static inline int trs_id_free(struct trs_id_inst *inst, int type, u32 id) |
| 151 | +{ | ||
| 152 | + return trs_id_free_ex(inst, type, 0, id); | ||
| 153 | +} | ||
| 130 | 154 | ||
| 131 | int trs_id_free_batch_by_type(struct trs_id_inst *inst, int type); | 155 | int trs_id_free_batch_by_type(struct trs_id_inst *inst, int type); |
| 132 | int trs_id_flush_to_pool(struct trs_id_inst *inst); | 156 | int trs_id_flush_to_pool(struct trs_id_inst *inst); |