2929 * DRM operations:
3030 */
3131
32+ static struct device_node * etnaviv_of_first_available_node (void )
33+ {
34+ struct device_node * np ;
35+
36+ for_each_compatible_node (np , NULL , "vivante,gc" ) {
37+ if (of_device_is_available (np ))
38+ return np ;
39+ }
40+
41+ return NULL ;
42+ }
3243
3344static void load_gpu (struct drm_device * dev )
3445{
@@ -79,7 +90,7 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file)
7990 drm_sched_entity_init (& ctx -> sched_entity [i ],
8091 DRM_SCHED_PRIORITY_NORMAL , & sched ,
8192 1 , NULL );
82- }
93+ }
8394 }
8495
8596 file -> driver_priv = ctx ;
@@ -233,11 +244,11 @@ static int show_each_gpu(struct seq_file *m, void *arg)
233244}
234245
235246static struct drm_info_list etnaviv_debugfs_list [] = {
236- {"gpu" , show_each_gpu , 0 , etnaviv_gpu_debugfs },
237- {"gem" , show_unlocked , 0 , etnaviv_gem_show },
238- { "mm" , show_unlocked , 0 , etnaviv_mm_show },
239- {"mmu" , show_each_gpu , 0 , etnaviv_mmu_show },
240- {"ring" , show_each_gpu , 0 , etnaviv_ring_show },
247+ {"gpu" , show_each_gpu , 0 , etnaviv_gpu_debugfs },
248+ {"gem" , show_unlocked , 0 , etnaviv_gem_show },
249+ { "mm" , show_unlocked , 0 , etnaviv_mm_show },
250+ {"mmu" , show_each_gpu , 0 , etnaviv_mmu_show },
251+ {"ring" , show_each_gpu , 0 , etnaviv_ring_show },
241252};
242253
243254static void etnaviv_debugfs_init (struct drm_minor * minor )
@@ -494,7 +505,7 @@ static const struct drm_driver etnaviv_drm_driver = {
494505 .desc = "etnaviv DRM" ,
495506 .date = "20151214" ,
496507 .major = 1 ,
497- .minor = 3 ,
508+ .minor = 4 ,
498509};
499510
500511/*
@@ -597,9 +608,6 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
597608 if (!of_device_is_available (core_node ))
598609 continue ;
599610
600- if (!first_node )
601- first_node = core_node ;
602-
603611 drm_of_component_match_add (& pdev -> dev , & match ,
604612 component_compare_of , core_node );
605613 }
@@ -634,8 +642,11 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
634642 * device as the GPU we found. This assumes that all Vivante
635643 * GPUs in the system share the same DMA constraints.
636644 */
637- if (first_node )
645+ first_node = etnaviv_of_first_available_node ();
646+ if (first_node ) {
638647 of_dma_configure (& pdev -> dev , first_node , true);
648+ of_node_put (first_node );
649+ }
639650
640651 return component_master_add_with_match (dev , & etnaviv_master_ops , match );
641652}
@@ -653,11 +664,43 @@ static struct platform_driver etnaviv_platform_driver = {
653664 },
654665};
655666
667+ static int etnaviv_create_platform_device (const char * name ,
668+ struct platform_device * * ppdev )
669+ {
670+ struct platform_device * pdev ;
671+ int ret ;
672+
673+ pdev = platform_device_alloc (name , PLATFORM_DEVID_NONE );
674+ if (!pdev )
675+ return - ENOMEM ;
676+
677+ ret = platform_device_add (pdev );
678+ if (ret ) {
679+ platform_device_put (pdev );
680+ return ret ;
681+ }
682+
683+ * ppdev = pdev ;
684+
685+ return 0 ;
686+ }
687+
688+ static void etnaviv_destroy_platform_device (struct platform_device * * ppdev )
689+ {
690+ struct platform_device * pdev = * ppdev ;
691+
692+ if (!pdev )
693+ return ;
694+
695+ platform_device_unregister (pdev );
696+
697+ * ppdev = NULL ;
698+ }
699+
656700static struct platform_device * etnaviv_drm ;
657701
658702static int __init etnaviv_init (void )
659703{
660- struct platform_device * pdev ;
661704 int ret ;
662705 struct device_node * np ;
663706
@@ -675,27 +718,13 @@ static int __init etnaviv_init(void)
675718 * If the DT contains at least one available GPU device, instantiate
676719 * the DRM platform device.
677720 */
678- for_each_compatible_node (np , NULL , "vivante,gc" ) {
679- if (!of_device_is_available (np ))
680- continue ;
681-
682- pdev = platform_device_alloc ("etnaviv" , PLATFORM_DEVID_NONE );
683- if (!pdev ) {
684- ret = - ENOMEM ;
685- of_node_put (np );
686- goto unregister_platform_driver ;
687- }
721+ np = etnaviv_of_first_available_node ();
722+ if (np ) {
723+ of_node_put (np );
688724
689- ret = platform_device_add (pdev );
690- if (ret ) {
691- platform_device_put (pdev );
692- of_node_put (np );
725+ ret = etnaviv_create_platform_device ("etnaviv" , & etnaviv_drm );
726+ if (ret )
693727 goto unregister_platform_driver ;
694- }
695-
696- etnaviv_drm = pdev ;
697- of_node_put (np );
698- break ;
699728 }
700729
701730 return 0 ;
@@ -710,7 +739,7 @@ module_init(etnaviv_init);
710739
711740static void __exit etnaviv_exit (void )
712741{
713- platform_device_unregister ( etnaviv_drm );
742+ etnaviv_destroy_platform_device ( & etnaviv_drm );
714743 platform_driver_unregister (& etnaviv_platform_driver );
715744 platform_driver_unregister (& etnaviv_gpu_driver );
716745}
0 commit comments