hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/video/rockchip/mpp/mpp_vepu2.c
....@@ -22,6 +22,7 @@
2222 #include <linux/proc_fs.h>
2323 #include <linux/nospec.h>
2424 #include <soc/rockchip/pm_domains.h>
25
+#include <soc/rockchip/rockchip_iommu.h>
2526
2627 #include "mpp_debug.h"
2728 #include "mpp_common.h"
....@@ -36,6 +37,8 @@
3637 #define VEPU2_REG_HW_ID_INDEX -1 /* INVALID */
3738 #define VEPU2_REG_START_INDEX 0
3839 #define VEPU2_REG_END_INDEX 183
40
+#define VEPU2_REG_OUT_INDEX (77)
41
+#define VEPU2_REG_STRM_INDEX (53)
3942
4043 #define VEPU2_REG_ENC_EN 0x19c
4144 #define VEPU2_REG_ENC_EN_INDEX (103)
....@@ -97,6 +100,8 @@
97100 u32 width;
98101 u32 height;
99102 u32 pixels;
103
+ struct mpp_dma_buffer *bs_buf;
104
+ u32 offset_bs;
100105 };
101106
102107 struct vepu_session_priv {
....@@ -121,6 +126,18 @@
121126 #endif
122127 struct reset_control *rst_a;
123128 struct reset_control *rst_h;
129
+ /* for ccu(central control unit) */
130
+ struct vepu_ccu *ccu;
131
+ bool disable_work;
132
+};
133
+
134
+struct vepu_ccu {
135
+ u32 core_num;
136
+ /* lock for core attach */
137
+ spinlock_t lock;
138
+ struct mpp_dev *main_core;
139
+ struct mpp_dev *cores[MPP_MAX_CORE_NUM];
140
+ unsigned long core_idle;
124141 };
125142
126143 static struct mpp_hw_info vepu_v2_hw_info = {
....@@ -167,7 +184,13 @@
167184 struct mpp_task_msgs *msgs)
168185 {
169186 int ret;
187
+ int fd_bs;
170188 int fmt = VEPU2_GET_FORMAT(task->reg[VEPU2_REG_ENC_EN_INDEX]);
189
+
190
+ if (session->msg_flags & MPP_FLAGS_REG_NO_OFFSET)
191
+ fd_bs = task->reg[VEPU2_REG_OUT_INDEX];
192
+ else
193
+ fd_bs = task->reg[VEPU2_REG_OUT_INDEX] & 0x3ff;
171194
172195 ret = mpp_translate_reg_address(session, &task->mpp_task,
173196 fmt, task->reg, &task->off_inf);
....@@ -176,6 +199,15 @@
176199
177200 mpp_translate_reg_offset_info(&task->mpp_task,
178201 &task->off_inf, task->reg);
202
+
203
+ if (fmt == VEPU2_FMT_JPEGE) {
204
+ struct mpp_dma_buffer *bs_buf = mpp_dma_find_buffer_fd(session->dma, fd_bs);
205
+
206
+ task->offset_bs = mpp_query_reg_offset_info(&task->off_inf, VEPU2_REG_OUT_INDEX);
207
+ if (bs_buf && task->offset_bs > 0)
208
+ mpp_dma_buf_sync(bs_buf, 0, task->offset_bs, DMA_TO_DEVICE, false);
209
+ task->bs_buf = bs_buf;
210
+ }
179211
180212 return 0;
181213 }
....@@ -281,12 +313,54 @@
281313 return NULL;
282314 }
283315
316
+static void *vepu_prepare(struct mpp_dev *mpp, struct mpp_task *mpp_task)
317
+{
318
+ struct vepu_dev *enc = to_vepu_dev(mpp);
319
+ struct vepu_ccu *ccu = enc->ccu;
320
+ unsigned long core_idle;
321
+ unsigned long flags;
322
+ s32 core_id;
323
+ u32 i;
324
+
325
+ spin_lock_irqsave(&ccu->lock, flags);
326
+
327
+ core_idle = ccu->core_idle;
328
+
329
+ for (i = 0; i < ccu->core_num; i++) {
330
+ struct mpp_dev *mpp = ccu->cores[i];
331
+
332
+ if (mpp && mpp->disable)
333
+ clear_bit(mpp->core_id, &core_idle);
334
+ }
335
+
336
+ core_id = find_first_bit(&core_idle, ccu->core_num);
337
+ if (core_id >= ARRAY_SIZE(ccu->cores)) {
338
+ mpp_task = NULL;
339
+ mpp_dbg_core("core %d all busy %lx\n", core_id, ccu->core_idle);
340
+ goto done;
341
+ }
342
+
343
+ core_id = array_index_nospec(core_id, MPP_MAX_CORE_NUM);
344
+ clear_bit(core_id, &ccu->core_idle);
345
+ mpp_task->mpp = ccu->cores[core_id];
346
+ mpp_task->core_id = core_id;
347
+
348
+ mpp_dbg_core("core cnt %d core %d set idle %lx -> %lx\n",
349
+ ccu->core_num, core_id, core_idle, ccu->core_idle);
350
+
351
+done:
352
+ spin_unlock_irqrestore(&ccu->lock, flags);
353
+
354
+ return mpp_task;
355
+}
356
+
284357 static int vepu_run(struct mpp_dev *mpp,
285358 struct mpp_task *mpp_task)
286359 {
287360 u32 i;
288361 u32 reg_en;
289362 struct vepu_task *task = to_vepu_task(mpp_task);
363
+ u32 timing_en = mpp->srv->timing_en;
290364
291365 mpp_debug_enter();
292366
....@@ -305,16 +379,32 @@
305379
306380 mpp_write_req(mpp, task->reg, s, e, reg_en);
307381 }
382
+
383
+ /* flush tlb before starting hardware */
384
+ mpp_iommu_flush_tlb(mpp->iommu_info);
385
+
308386 /* init current task */
309387 mpp->cur_task = mpp_task;
388
+
389
+ mpp_task_run_begin(mpp_task, timing_en, MPP_WORK_TIMEOUT_DELAY);
390
+
310391 /* Last, flush the registers */
311392 wmb();
312393 mpp_write(mpp, VEPU2_REG_ENC_EN,
313394 task->reg[reg_en] | VEPU2_ENC_START);
314395
396
+ mpp_task_run_end(mpp_task, timing_en);
397
+
315398 mpp_debug_leave();
316399
317400 return 0;
401
+}
402
+
403
+static int vepu_px30_run(struct mpp_dev *mpp,
404
+ struct mpp_task *mpp_task)
405
+{
406
+ mpp_iommu_flush_tlb(mpp->iommu_info);
407
+ return vepu_run(mpp, mpp_task);
318408 }
319409
320410 static int vepu_irq(struct mpp_dev *mpp)
....@@ -333,6 +423,9 @@
333423 u32 err_mask;
334424 struct vepu_task *task = NULL;
335425 struct mpp_task *mpp_task = mpp->cur_task;
426
+ unsigned long core_idle;
427
+ struct vepu_dev *enc = to_vepu_dev(mpp);
428
+ struct vepu_ccu *ccu = enc->ccu;
336429
337430 /* FIXME use a spin lock here */
338431 if (!mpp_task) {
....@@ -354,6 +447,14 @@
354447 atomic_inc(&mpp->reset_request);
355448
356449 mpp_task_finish(mpp_task->session, mpp_task);
450
+ /* the whole vepu has no ccu that manage multi core */
451
+ if (ccu) {
452
+ core_idle = ccu->core_idle;
453
+ set_bit(mpp->core_id, &ccu->core_idle);
454
+
455
+ mpp_dbg_core("core %d isr idle %lx -> %lx\n", mpp->core_id, core_idle,
456
+ ccu->core_idle);
457
+ }
357458
358459 mpp_debug_leave();
359460
....@@ -380,6 +481,11 @@
380481 /* revert hack for irq status */
381482 task->reg[VEPU2_REG_INT_INDEX] = task->irq_status;
382483
484
+ if (task->bs_buf)
485
+ mpp_dma_buf_sync(task->bs_buf, 0,
486
+ task->reg[VEPU2_REG_STRM_INDEX] / 8 +
487
+ task->offset_bs,
488
+ DMA_FROM_DEVICE, true);
383489 mpp_debug_leave();
384490
385491 return 0;
....@@ -522,7 +628,7 @@
522628 }
523629 seq_puts(seq, "\n");
524630 /* item data*/
525
- seq_printf(seq, "|%8p|", session);
631
+ seq_printf(seq, "|%8d|", session->index);
526632 seq_printf(seq, "%8s|", mpp_device_name[session->device_type]);
527633 for (i = ENC_INFO_BASE; i < ENC_INFO_BUTT; i++) {
528634 u32 flag = priv->codec_info[i].flag;
....@@ -555,8 +661,9 @@
555661 mutex_lock(&mpp->srv->session_lock);
556662 list_for_each_entry_safe(session, n,
557663 &mpp->srv->session_list,
558
- session_link) {
559
- if (session->device_type != MPP_DEVICE_VEPU2)
664
+ service_link) {
665
+ if (session->device_type != MPP_DEVICE_VEPU2 &&
666
+ session->device_type != MPP_DEVICE_VEPU2_JPEG)
560667 continue;
561668 if (!session->priv)
562669 continue;
....@@ -571,13 +678,28 @@
571678 static int vepu_procfs_init(struct mpp_dev *mpp)
572679 {
573680 struct vepu_dev *enc = to_vepu_dev(mpp);
681
+ char name[32];
574682
575
- enc->procfs = proc_mkdir(mpp->dev->of_node->name, mpp->srv->procfs);
683
+ if (!mpp->dev || !mpp->dev->of_node || !mpp->dev->of_node->name ||
684
+ !mpp->srv || !mpp->srv->procfs)
685
+ return -EINVAL;
686
+ if (enc->ccu)
687
+ snprintf(name, sizeof(name) - 1, "%s%d",
688
+ mpp->dev->of_node->name, mpp->core_id);
689
+ else
690
+ snprintf(name, sizeof(name) - 1, "%s",
691
+ mpp->dev->of_node->name);
692
+
693
+ enc->procfs = proc_mkdir(name, mpp->srv->procfs);
576694 if (IS_ERR_OR_NULL(enc->procfs)) {
577695 mpp_err("failed on open procfs\n");
578696 enc->procfs = NULL;
579697 return -EIO;
580698 }
699
+
700
+ /* for common mpp_dev options */
701
+ mpp_procfs_create_common(enc->procfs, mpp);
702
+
581703 mpp_procfs_create_u32("aclk", 0644,
582704 enc->procfs, &enc->aclk_info.debug_rate_hz);
583705 mpp_procfs_create_u32("session_buffers", 0644,
....@@ -588,6 +710,17 @@
588710
589711 return 0;
590712 }
713
+
714
+static int vepu_procfs_ccu_init(struct mpp_dev *mpp)
715
+{
716
+ struct vepu_dev *enc = to_vepu_dev(mpp);
717
+
718
+ if (!enc->procfs)
719
+ goto done;
720
+
721
+done:
722
+ return 0;
723
+}
591724 #else
592725 static inline int vepu_procfs_remove(struct mpp_dev *mpp)
593726 {
....@@ -595,6 +728,11 @@
595728 }
596729
597730 static inline int vepu_procfs_init(struct mpp_dev *mpp)
731
+{
732
+ return 0;
733
+}
734
+
735
+static inline int vepu_procfs_ccu_init(struct mpp_dev *mpp)
598736 {
599737 return 0;
600738 }
....@@ -721,18 +859,68 @@
721859 static int vepu_reset(struct mpp_dev *mpp)
722860 {
723861 struct vepu_dev *enc = to_vepu_dev(mpp);
862
+ struct vepu_ccu *ccu = enc->ccu;
724863
864
+ mpp_write(mpp, VEPU2_REG_ENC_EN, 0);
865
+ udelay(5);
725866 if (enc->rst_a && enc->rst_h) {
726867 /* Don't skip this or iommu won't work after reset */
727
- rockchip_pmu_idle_request(mpp->dev, true);
868
+ mpp_pmu_idle_request(mpp, true);
728869 mpp_safe_reset(enc->rst_a);
729870 mpp_safe_reset(enc->rst_h);
730871 udelay(5);
731872 mpp_safe_unreset(enc->rst_a);
732873 mpp_safe_unreset(enc->rst_h);
733
- rockchip_pmu_idle_request(mpp->dev, false);
874
+ mpp_pmu_idle_request(mpp, false);
734875 }
735876 mpp_write(mpp, VEPU2_REG_INT, VEPU2_INT_CLEAR);
877
+
878
+ if (ccu) {
879
+ set_bit(mpp->core_id, &ccu->core_idle);
880
+ mpp_dbg_core("core %d reset idle %lx\n", mpp->core_id, ccu->core_idle);
881
+ }
882
+
883
+ return 0;
884
+}
885
+
886
+static int vepu2_iommu_fault_handle(struct iommu_domain *iommu, struct device *iommu_dev,
887
+ unsigned long iova, int status, void *arg)
888
+{
889
+ struct mpp_dev *mpp = (struct mpp_dev *)arg;
890
+ struct mpp_task *mpp_task;
891
+ struct vepu_dev *enc = to_vepu_dev(mpp);
892
+ struct vepu_ccu *ccu = enc->ccu;
893
+
894
+ dev_err(iommu_dev, "fault addr 0x%08lx status %x arg %p\n",
895
+ iova, status, arg);
896
+
897
+ if (ccu) {
898
+ int i;
899
+ struct mpp_dev *core;
900
+
901
+ for (i = 0; i < ccu->core_num; i++) {
902
+ core = ccu->cores[i];
903
+ if (core->iommu_info && (&core->iommu_info->pdev->dev == iommu_dev)) {
904
+ mpp = core;
905
+ break;
906
+ }
907
+ }
908
+ }
909
+
910
+ if (!mpp) {
911
+ dev_err(iommu_dev, "pagefault without device to handle\n");
912
+ return 0;
913
+ }
914
+ mpp_task = mpp->cur_task;
915
+ if (mpp_task)
916
+ mpp_task_dump_mem_region(mpp, mpp_task);
917
+
918
+ mpp_task_dump_hw_reg(mpp);
919
+ /*
920
+ * Mask iommu irq, in order for iommu not repeatedly trigger pagefault.
921
+ * Until the pagefault task finish by hw timeout.
922
+ */
923
+ rockchip_iommu_mask_irq(mpp->dev);
736924
737925 return 0;
738926 }
....@@ -771,6 +959,36 @@
771959 .dump_session = vepu_dump_session,
772960 };
773961
962
+static struct mpp_dev_ops vepu_px30_dev_ops = {
963
+ .alloc_task = vepu_alloc_task,
964
+ .run = vepu_px30_run,
965
+ .irq = vepu_irq,
966
+ .isr = vepu_isr,
967
+ .finish = vepu_finish,
968
+ .result = vepu_result,
969
+ .free_task = vepu_free_task,
970
+ .ioctl = vepu_control,
971
+ .init_session = vepu_init_session,
972
+ .free_session = vepu_free_session,
973
+ .dump_session = vepu_dump_session,
974
+};
975
+
976
+static struct mpp_dev_ops vepu_ccu_dev_ops = {
977
+ .alloc_task = vepu_alloc_task,
978
+ .prepare = vepu_prepare,
979
+ .run = vepu_run,
980
+ .irq = vepu_irq,
981
+ .isr = vepu_isr,
982
+ .finish = vepu_finish,
983
+ .result = vepu_result,
984
+ .free_task = vepu_free_task,
985
+ .ioctl = vepu_control,
986
+ .init_session = vepu_init_session,
987
+ .free_session = vepu_free_session,
988
+ .dump_session = vepu_dump_session,
989
+};
990
+
991
+
774992 static const struct mpp_dev_var vepu_v2_data = {
775993 .device_type = MPP_DEVICE_VEPU2,
776994 .hw_info = &vepu_v2_hw_info,
....@@ -784,7 +1002,15 @@
7841002 .hw_info = &vepu_v2_hw_info,
7851003 .trans_info = trans_rk_vepu2,
7861004 .hw_ops = &vepu_px30_hw_ops,
787
- .dev_ops = &vepu_v2_dev_ops,
1005
+ .dev_ops = &vepu_px30_dev_ops,
1006
+};
1007
+
1008
+static const struct mpp_dev_var vepu_ccu_data = {
1009
+ .device_type = MPP_DEVICE_VEPU2_JPEG,
1010
+ .hw_info = &vepu_v2_hw_info,
1011
+ .trans_info = trans_rk_vepu2,
1012
+ .hw_ops = &vepu_v2_hw_ops,
1013
+ .dev_ops = &vepu_ccu_dev_ops,
7881014 };
7891015
7901016 static const struct of_device_id mpp_vepu2_dt_match[] = {
....@@ -798,10 +1024,83 @@
7981024 .data = &vepu_px30_data,
7991025 },
8001026 #endif
1027
+#ifdef CONFIG_CPU_RK3588
1028
+ {
1029
+ .compatible = "rockchip,vpu-jpege-core",
1030
+ .data = &vepu_ccu_data,
1031
+ },
1032
+ {
1033
+ .compatible = "rockchip,vpu-jpege-ccu",
1034
+ },
1035
+#endif
8011036 {},
8021037 };
8031038
804
-static int vepu_probe(struct platform_device *pdev)
1039
+static int vepu_ccu_probe(struct platform_device *pdev)
1040
+{
1041
+ struct vepu_ccu *ccu;
1042
+ struct device *dev = &pdev->dev;
1043
+
1044
+ ccu = devm_kzalloc(dev, sizeof(*ccu), GFP_KERNEL);
1045
+ if (!ccu)
1046
+ return -ENOMEM;
1047
+
1048
+ platform_set_drvdata(pdev, ccu);
1049
+ spin_lock_init(&ccu->lock);
1050
+ return 0;
1051
+}
1052
+
1053
+static int vepu_attach_ccu(struct device *dev, struct vepu_dev *enc)
1054
+{
1055
+ struct device_node *np;
1056
+ struct platform_device *pdev;
1057
+ struct vepu_ccu *ccu;
1058
+ unsigned long flags;
1059
+
1060
+ np = of_parse_phandle(dev->of_node, "rockchip,ccu", 0);
1061
+ if (!np || !of_device_is_available(np))
1062
+ return -ENODEV;
1063
+
1064
+ pdev = of_find_device_by_node(np);
1065
+ of_node_put(np);
1066
+ if (!pdev)
1067
+ return -ENODEV;
1068
+
1069
+ ccu = platform_get_drvdata(pdev);
1070
+ if (!ccu)
1071
+ return -ENOMEM;
1072
+
1073
+ spin_lock_irqsave(&ccu->lock, flags);
1074
+ ccu->core_num++;
1075
+ ccu->cores[enc->mpp.core_id] = &enc->mpp;
1076
+ set_bit(enc->mpp.core_id, &ccu->core_idle);
1077
+ spin_unlock_irqrestore(&ccu->lock, flags);
1078
+
1079
+ /* attach the ccu-domain to current core */
1080
+ if (!ccu->main_core) {
1081
+ /**
1082
+ * set the first device for the main-core,
1083
+ * then the domain of the main-core named ccu-domain
1084
+ */
1085
+ ccu->main_core = &enc->mpp;
1086
+ } else {
1087
+ struct mpp_iommu_info *ccu_info, *cur_info;
1088
+
1089
+ /* set the ccu domain for current device */
1090
+ ccu_info = ccu->main_core->iommu_info;
1091
+ cur_info = enc->mpp.iommu_info;
1092
+
1093
+ if (cur_info)
1094
+ cur_info->domain = ccu_info->domain;
1095
+ mpp_iommu_attach(cur_info);
1096
+ }
1097
+ enc->ccu = ccu;
1098
+
1099
+ dev_info(dev, "attach ccu success\n");
1100
+ return 0;
1101
+}
1102
+
1103
+static int vepu_core_probe(struct platform_device *pdev)
8051104 {
8061105 struct device *dev = &pdev->dev;
8071106 struct vepu_dev *enc = NULL;
....@@ -809,18 +1108,73 @@
8091108 const struct of_device_id *match = NULL;
8101109 int ret = 0;
8111110
812
- dev_info(dev, "probe device\n");
8131111 enc = devm_kzalloc(dev, sizeof(struct vepu_dev), GFP_KERNEL);
8141112 if (!enc)
8151113 return -ENOMEM;
8161114
8171115 mpp = &enc->mpp;
818
- platform_set_drvdata(pdev, enc);
1116
+ platform_set_drvdata(pdev, mpp);
8191117
8201118 if (pdev->dev.of_node) {
8211119 match = of_match_node(mpp_vepu2_dt_match, pdev->dev.of_node);
8221120 if (match)
8231121 mpp->var = (struct mpp_dev_var *)match->data;
1122
+
1123
+ mpp->core_id = of_alias_get_id(pdev->dev.of_node, "jpege");
1124
+ }
1125
+
1126
+ ret = mpp_dev_probe(mpp, pdev);
1127
+ if (ret) {
1128
+ dev_err(dev, "probe sub driver failed\n");
1129
+ return -EINVAL;
1130
+ }
1131
+ /* current device attach to ccu */
1132
+ ret = vepu_attach_ccu(dev, enc);
1133
+ if (ret)
1134
+ return ret;
1135
+
1136
+ ret = devm_request_threaded_irq(dev, mpp->irq,
1137
+ mpp_dev_irq,
1138
+ mpp_dev_isr_sched,
1139
+ IRQF_SHARED,
1140
+ dev_name(dev), mpp);
1141
+ if (ret) {
1142
+ dev_err(dev, "register interrupter runtime failed\n");
1143
+ return -EINVAL;
1144
+ }
1145
+
1146
+ mpp->fault_handler = vepu2_iommu_fault_handle;
1147
+ mpp->session_max_buffers = VEPU2_SESSION_MAX_BUFFERS;
1148
+ vepu_procfs_init(mpp);
1149
+ vepu_procfs_ccu_init(mpp);
1150
+ /* if current is main-core, register current device to mpp service */
1151
+ if (mpp == enc->ccu->main_core)
1152
+ mpp_dev_register_srv(mpp, mpp->srv);
1153
+
1154
+ return 0;
1155
+}
1156
+
1157
+static int vepu_probe_default(struct platform_device *pdev)
1158
+{
1159
+ struct device *dev = &pdev->dev;
1160
+ struct vepu_dev *enc = NULL;
1161
+ struct mpp_dev *mpp = NULL;
1162
+ const struct of_device_id *match = NULL;
1163
+ int ret = 0;
1164
+
1165
+ enc = devm_kzalloc(dev, sizeof(struct vepu_dev), GFP_KERNEL);
1166
+ if (!enc)
1167
+ return -ENOMEM;
1168
+
1169
+ mpp = &enc->mpp;
1170
+ platform_set_drvdata(pdev, mpp);
1171
+
1172
+ if (pdev->dev.of_node) {
1173
+ match = of_match_node(mpp_vepu2_dt_match, pdev->dev.of_node);
1174
+ if (match)
1175
+ mpp->var = (struct mpp_dev_var *)match->data;
1176
+
1177
+ mpp->core_id = of_alias_get_id(pdev->dev.of_node, "vepu");
8241178 }
8251179
8261180 ret = mpp_dev_probe(mpp, pdev);
....@@ -839,43 +1193,77 @@
8391193 return -EINVAL;
8401194 }
8411195
1196
+ mpp->fault_handler = vepu2_iommu_fault_handle;
8421197 mpp->session_max_buffers = VEPU2_SESSION_MAX_BUFFERS;
8431198 vepu_procfs_init(mpp);
8441199 /* register current device to mpp service */
8451200 mpp_dev_register_srv(mpp, mpp->srv);
846
- dev_info(dev, "probing finish\n");
8471201
8481202 return 0;
1203
+}
1204
+
1205
+static int vepu_probe(struct platform_device *pdev)
1206
+{
1207
+ int ret;
1208
+ struct device *dev = &pdev->dev;
1209
+ struct device_node *np = dev->of_node;
1210
+
1211
+ dev_info(dev, "probing start\n");
1212
+
1213
+ if (strstr(np->name, "ccu"))
1214
+ ret = vepu_ccu_probe(pdev);
1215
+ else if (strstr(np->name, "core"))
1216
+ ret = vepu_core_probe(pdev);
1217
+ else
1218
+ ret = vepu_probe_default(pdev);
1219
+
1220
+ dev_info(dev, "probing finish\n");
1221
+
1222
+ return ret;
8491223 }
8501224
8511225 static int vepu_remove(struct platform_device *pdev)
8521226 {
8531227 struct device *dev = &pdev->dev;
854
- struct vepu_dev *enc = platform_get_drvdata(pdev);
1228
+ struct device_node *np = dev->of_node;
8551229
856
- dev_info(dev, "remove device\n");
857
- mpp_dev_remove(&enc->mpp);
858
- vepu_procfs_remove(&enc->mpp);
1230
+ if (strstr(np->name, "ccu")) {
1231
+ dev_info(dev, "remove ccu device\n");
1232
+ } else if (strstr(np->name, "core")) {
1233
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
1234
+ struct vepu_dev *enc = to_vepu_dev(mpp);
1235
+
1236
+ dev_info(dev, "remove core\n");
1237
+ if (enc->ccu) {
1238
+ s32 core_id = mpp->core_id;
1239
+ struct vepu_ccu *ccu = enc->ccu;
1240
+ unsigned long flags;
1241
+
1242
+ spin_lock_irqsave(&ccu->lock, flags);
1243
+ ccu->core_num--;
1244
+ ccu->cores[core_id] = NULL;
1245
+ clear_bit(core_id, &ccu->core_idle);
1246
+ spin_unlock_irqrestore(&ccu->lock, flags);
1247
+ }
1248
+ mpp_dev_remove(&enc->mpp);
1249
+ vepu_procfs_remove(&enc->mpp);
1250
+ } else {
1251
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
1252
+
1253
+ dev_info(dev, "remove device\n");
1254
+ mpp_dev_remove(mpp);
1255
+ vepu_procfs_remove(mpp);
1256
+ }
8591257
8601258 return 0;
8611259 }
8621260
8631261 static void vepu_shutdown(struct platform_device *pdev)
8641262 {
865
- int ret;
866
- int val;
8671263 struct device *dev = &pdev->dev;
868
- struct vepu_dev *enc = platform_get_drvdata(pdev);
869
- struct mpp_dev *mpp = &enc->mpp;
8701264
871
- dev_info(dev, "shutdown device\n");
872
-
873
- atomic_inc(&mpp->srv->shutdown_request);
874
- ret = readx_poll_timeout(atomic_read,
875
- &mpp->task_count,
876
- val, val == 0, 20000, 200000);
877
- if (ret == -ETIMEDOUT)
878
- dev_err(dev, "wait total running time out\n");
1265
+ if (!strstr(dev_name(dev), "ccu"))
1266
+ mpp_dev_shutdown(pdev);
8791267 }
8801268
8811269 struct platform_driver rockchip_vepu2_driver = {