@@ -498,6 +498,108 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
498498 return ret ;
499499}
500500
501+ static int ipp_put_mem_node (struct drm_device * drm_dev ,
502+ struct drm_exynos_ipp_cmd_node * c_node ,
503+ struct drm_exynos_ipp_mem_node * m_node )
504+ {
505+ int i ;
506+
507+ DRM_DEBUG_KMS ("node[0x%x]\n" , (int )m_node );
508+
509+ if (!m_node ) {
510+ DRM_ERROR ("invalid dequeue node.\n" );
511+ return - EFAULT ;
512+ }
513+
514+ DRM_DEBUG_KMS ("ops_id[%d]\n" , m_node -> ops_id );
515+
516+ /* put gem buffer */
517+ for_each_ipp_planar (i ) {
518+ unsigned long handle = m_node -> buf_info .handles [i ];
519+ if (handle )
520+ exynos_drm_gem_put_dma_addr (drm_dev , handle ,
521+ c_node -> filp );
522+ }
523+
524+ list_del (& m_node -> list );
525+ kfree (m_node );
526+
527+ return 0 ;
528+ }
529+
530+ static struct drm_exynos_ipp_mem_node
531+ * ipp_get_mem_node (struct drm_device * drm_dev ,
532+ struct drm_file * file ,
533+ struct drm_exynos_ipp_cmd_node * c_node ,
534+ struct drm_exynos_ipp_queue_buf * qbuf )
535+ {
536+ struct drm_exynos_ipp_mem_node * m_node ;
537+ struct drm_exynos_ipp_buf_info * buf_info ;
538+ int i ;
539+
540+ m_node = kzalloc (sizeof (* m_node ), GFP_KERNEL );
541+ if (!m_node )
542+ return ERR_PTR (- ENOMEM );
543+
544+ buf_info = & m_node -> buf_info ;
545+
546+ /* operations, buffer id */
547+ m_node -> ops_id = qbuf -> ops_id ;
548+ m_node -> prop_id = qbuf -> prop_id ;
549+ m_node -> buf_id = qbuf -> buf_id ;
550+ INIT_LIST_HEAD (& m_node -> list );
551+
552+ DRM_DEBUG_KMS ("m_node[0x%x]ops_id[%d]\n" , (int )m_node , qbuf -> ops_id );
553+ DRM_DEBUG_KMS ("prop_id[%d]buf_id[%d]\n" , qbuf -> prop_id , m_node -> buf_id );
554+
555+ for_each_ipp_planar (i ) {
556+ DRM_DEBUG_KMS ("i[%d]handle[0x%x]\n" , i , qbuf -> handle [i ]);
557+
558+ /* get dma address by handle */
559+ if (qbuf -> handle [i ]) {
560+ dma_addr_t * addr ;
561+
562+ addr = exynos_drm_gem_get_dma_addr (drm_dev ,
563+ qbuf -> handle [i ], file );
564+ if (IS_ERR (addr )) {
565+ DRM_ERROR ("failed to get addr.\n" );
566+ ipp_put_mem_node (drm_dev , c_node , m_node );
567+ return ERR_PTR (- EFAULT );
568+ }
569+
570+ buf_info -> handles [i ] = qbuf -> handle [i ];
571+ buf_info -> base [i ] = * addr ;
572+ DRM_DEBUG_KMS ("i[%d]base[0x%x]hd[0x%lx]\n" , i ,
573+ buf_info -> base [i ], buf_info -> handles [i ]);
574+ }
575+ }
576+
577+ mutex_lock (& c_node -> mem_lock );
578+ list_add_tail (& m_node -> list , & c_node -> mem_list [qbuf -> ops_id ]);
579+ mutex_unlock (& c_node -> mem_lock );
580+
581+ return m_node ;
582+ }
583+
584+ static void ipp_clean_mem_nodes (struct drm_device * drm_dev ,
585+ struct drm_exynos_ipp_cmd_node * c_node , int ops )
586+ {
587+ struct drm_exynos_ipp_mem_node * m_node , * tm_node ;
588+ struct list_head * head = & c_node -> mem_list [ops ];
589+
590+ mutex_lock (& c_node -> mem_lock );
591+
592+ list_for_each_entry_safe (m_node , tm_node , head , list ) {
593+ int ret ;
594+
595+ ret = ipp_put_mem_node (drm_dev , c_node , m_node );
596+ if (ret )
597+ DRM_ERROR ("failed to put m_node.\n" );
598+ }
599+
600+ mutex_unlock (& c_node -> mem_lock );
601+ }
602+
501603static void ipp_clean_cmd_node (struct ipp_context * ctx ,
502604 struct drm_exynos_ipp_cmd_node * c_node )
503605{
@@ -599,89 +701,6 @@ static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
599701 return ret ;
600702}
601703
602- static int ipp_put_mem_node (struct drm_device * drm_dev ,
603- struct drm_exynos_ipp_cmd_node * c_node ,
604- struct drm_exynos_ipp_mem_node * m_node )
605- {
606- int i ;
607-
608- DRM_DEBUG_KMS ("node[0x%x]\n" , (int )m_node );
609-
610- if (!m_node ) {
611- DRM_ERROR ("invalid dequeue node.\n" );
612- return - EFAULT ;
613- }
614-
615- DRM_DEBUG_KMS ("ops_id[%d]\n" , m_node -> ops_id );
616-
617- /* put gem buffer */
618- for_each_ipp_planar (i ) {
619- unsigned long handle = m_node -> buf_info .handles [i ];
620- if (handle )
621- exynos_drm_gem_put_dma_addr (drm_dev , handle ,
622- c_node -> filp );
623- }
624-
625- list_del (& m_node -> list );
626- kfree (m_node );
627-
628- return 0 ;
629- }
630-
631- static struct drm_exynos_ipp_mem_node
632- * ipp_get_mem_node (struct drm_device * drm_dev ,
633- struct drm_file * file ,
634- struct drm_exynos_ipp_cmd_node * c_node ,
635- struct drm_exynos_ipp_queue_buf * qbuf )
636- {
637- struct drm_exynos_ipp_mem_node * m_node ;
638- struct drm_exynos_ipp_buf_info * buf_info ;
639- int i ;
640-
641- m_node = kzalloc (sizeof (* m_node ), GFP_KERNEL );
642- if (!m_node )
643- return ERR_PTR (- ENOMEM );
644-
645- buf_info = & m_node -> buf_info ;
646-
647- /* operations, buffer id */
648- m_node -> ops_id = qbuf -> ops_id ;
649- m_node -> prop_id = qbuf -> prop_id ;
650- m_node -> buf_id = qbuf -> buf_id ;
651- INIT_LIST_HEAD (& m_node -> list );
652-
653- DRM_DEBUG_KMS ("m_node[0x%x]ops_id[%d]\n" , (int )m_node , qbuf -> ops_id );
654- DRM_DEBUG_KMS ("prop_id[%d]buf_id[%d]\n" , qbuf -> prop_id , m_node -> buf_id );
655-
656- for_each_ipp_planar (i ) {
657- DRM_DEBUG_KMS ("i[%d]handle[0x%x]\n" , i , qbuf -> handle [i ]);
658-
659- /* get dma address by handle */
660- if (qbuf -> handle [i ]) {
661- dma_addr_t * addr ;
662-
663- addr = exynos_drm_gem_get_dma_addr (drm_dev ,
664- qbuf -> handle [i ], file );
665- if (IS_ERR (addr )) {
666- DRM_ERROR ("failed to get addr.\n" );
667- ipp_put_mem_node (drm_dev , c_node , m_node );
668- return ERR_PTR (- EFAULT );
669- }
670-
671- buf_info -> handles [i ] = qbuf -> handle [i ];
672- buf_info -> base [i ] = * addr ;
673- DRM_DEBUG_KMS ("i[%d]base[0x%x]hd[0x%lx]\n" , i ,
674- buf_info -> base [i ], buf_info -> handles [i ]);
675- }
676- }
677-
678- mutex_lock (& c_node -> mem_lock );
679- list_add_tail (& m_node -> list , & c_node -> mem_list [qbuf -> ops_id ]);
680- mutex_unlock (& c_node -> mem_lock );
681-
682- return m_node ;
683- }
684-
685704static void ipp_free_event (struct drm_pending_event * event )
686705{
687706 kfree (event );
@@ -1257,59 +1276,25 @@ static int ipp_stop_property(struct drm_device *drm_dev,
12571276 struct exynos_drm_ippdrv * ippdrv ,
12581277 struct drm_exynos_ipp_cmd_node * c_node )
12591278{
1260- struct drm_exynos_ipp_mem_node * m_node , * tm_node ;
12611279 struct drm_exynos_ipp_property * property = & c_node -> property ;
1262- struct list_head * head ;
12631280 int ret = 0 , i ;
12641281
12651282 DRM_DEBUG_KMS ("prop_id[%d]\n" , property -> prop_id );
12661283
12671284 /* put event */
12681285 ipp_put_event (c_node , NULL );
12691286
1270- mutex_lock (& c_node -> mem_lock );
1271-
12721287 /* check command */
12731288 switch (property -> cmd ) {
12741289 case IPP_CMD_M2M :
1275- for_each_ipp_ops (i ) {
1276- /* source/destination memory list */
1277- head = & c_node -> mem_list [i ];
1278-
1279- list_for_each_entry_safe (m_node , tm_node ,
1280- head , list ) {
1281- ret = ipp_put_mem_node (drm_dev , c_node ,
1282- m_node );
1283- if (ret ) {
1284- DRM_ERROR ("failed to put m_node.\n" );
1285- goto err_clear ;
1286- }
1287- }
1288- }
1290+ for_each_ipp_ops (i )
1291+ ipp_clean_mem_nodes (drm_dev , c_node , i );
12891292 break ;
12901293 case IPP_CMD_WB :
1291- /* destination memory list */
1292- head = & c_node -> mem_list [EXYNOS_DRM_OPS_DST ];
1293-
1294- list_for_each_entry_safe (m_node , tm_node , head , list ) {
1295- ret = ipp_put_mem_node (drm_dev , c_node , m_node );
1296- if (ret ) {
1297- DRM_ERROR ("failed to put m_node.\n" );
1298- goto err_clear ;
1299- }
1300- }
1294+ ipp_clean_mem_nodes (drm_dev , c_node , EXYNOS_DRM_OPS_DST );
13011295 break ;
13021296 case IPP_CMD_OUTPUT :
1303- /* source memory list */
1304- head = & c_node -> mem_list [EXYNOS_DRM_OPS_SRC ];
1305-
1306- list_for_each_entry_safe (m_node , tm_node , head , list ) {
1307- ret = ipp_put_mem_node (drm_dev , c_node , m_node );
1308- if (ret ) {
1309- DRM_ERROR ("failed to put m_node.\n" );
1310- goto err_clear ;
1311- }
1312- }
1297+ ipp_clean_mem_nodes (drm_dev , c_node , EXYNOS_DRM_OPS_SRC );
13131298 break ;
13141299 default :
13151300 DRM_ERROR ("invalid operations.\n" );
@@ -1318,8 +1303,6 @@ static int ipp_stop_property(struct drm_device *drm_dev,
13181303 }
13191304
13201305err_clear :
1321- mutex_unlock (& c_node -> mem_lock );
1322-
13231306 /* stop operations */
13241307 if (ippdrv -> stop )
13251308 ippdrv -> stop (ippdrv -> dev , property -> cmd );
0 commit comments