@@ -773,6 +773,10 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
773773 goto fail ;
774774 }
775775
776+ if (gpu -> identity .nn_core_count > 0 )
777+ dev_warn (gpu -> dev , "etnaviv has been instantiated on a NPU, "
778+ "for which the UAPI is still experimental\n" );
779+
776780 /* Exclude VG cores with FE2.0 */
777781 if (gpu -> identity .features & chipFeatures_PIPE_VG &&
778782 gpu -> identity .features & chipFeatures_FE20 ) {
@@ -957,6 +961,8 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
957961 gpu -> identity .vertex_cache_size );
958962 seq_printf (m , "\t shader_core_count: %d\n" ,
959963 gpu -> identity .shader_core_count );
964+ seq_printf (m , "\t nn_core_count: %d\n" ,
965+ gpu -> identity .nn_core_count );
960966 seq_printf (m , "\t pixel_pipes: %d\n" ,
961967 gpu -> identity .pixel_pipes );
962968 seq_printf (m , "\t vertex_output_buffer_size: %d\n" ,
@@ -1240,7 +1246,7 @@ int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
12401246 * pretends we didn't find a fence in that case.
12411247 */
12421248 rcu_read_lock ();
1243- fence = idr_find (& gpu -> fence_idr , id );
1249+ fence = xa_load (& gpu -> user_fences , id );
12441250 if (fence )
12451251 fence = dma_fence_get_rcu (fence );
12461252 rcu_read_unlock ();
@@ -1450,6 +1456,15 @@ static void sync_point_worker(struct work_struct *work)
14501456
14511457static void dump_mmu_fault (struct etnaviv_gpu * gpu )
14521458{
1459+ static const char * fault_reasons [] = {
1460+ "slave not present" ,
1461+ "page not present" ,
1462+ "write violation" ,
1463+ "out of bounds" ,
1464+ "read security violation" ,
1465+ "write security violation" ,
1466+ };
1467+
14531468 u32 status_reg , status ;
14541469 int i ;
14551470
@@ -1462,18 +1477,25 @@ static void dump_mmu_fault(struct etnaviv_gpu *gpu)
14621477 dev_err_ratelimited (gpu -> dev , "MMU fault status 0x%08x\n" , status );
14631478
14641479 for (i = 0 ; i < 4 ; i ++ ) {
1480+ const char * reason = "unknown" ;
14651481 u32 address_reg ;
1482+ u32 mmu_status ;
14661483
1467- if (!(status & (VIVS_MMUv2_STATUS_EXCEPTION0__MASK << (i * 4 ))))
1484+ mmu_status = (status >> (i * 4 )) & VIVS_MMUv2_STATUS_EXCEPTION0__MASK ;
1485+ if (!mmu_status )
14681486 continue ;
14691487
1488+ if ((mmu_status - 1 ) < ARRAY_SIZE (fault_reasons ))
1489+ reason = fault_reasons [mmu_status - 1 ];
1490+
14701491 if (gpu -> sec_mode == ETNA_SEC_NONE )
14711492 address_reg = VIVS_MMUv2_EXCEPTION_ADDR (i );
14721493 else
14731494 address_reg = VIVS_MMUv2_SEC_EXCEPTION_ADDR ;
14741495
1475- dev_err_ratelimited (gpu -> dev , "MMU %d fault addr 0x%08x\n" , i ,
1476- gpu_read (gpu , address_reg ));
1496+ dev_err_ratelimited (gpu -> dev ,
1497+ "MMU %d fault (%s) addr 0x%08x\n" ,
1498+ i , reason , gpu_read (gpu , address_reg ));
14771499 }
14781500}
14791501
@@ -1629,7 +1651,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
16291651 return etnaviv_gpu_clk_disable (gpu );
16301652}
16311653
1632- #ifdef CONFIG_PM
16331654static int etnaviv_gpu_hw_resume (struct etnaviv_gpu * gpu )
16341655{
16351656 int ret ;
@@ -1645,7 +1666,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
16451666
16461667 return 0 ;
16471668}
1648- #endif
16491669
16501670static int
16511671etnaviv_gpu_cooling_get_max_state (struct thermal_cooling_device * cdev ,
@@ -1713,18 +1733,17 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
17131733 if (ret )
17141734 goto out_workqueue ;
17151735
1716- #ifdef CONFIG_PM
1717- ret = pm_runtime_get_sync (gpu -> dev );
1718- #else
1719- ret = etnaviv_gpu_clk_enable (gpu );
1720- #endif
1736+ if (IS_ENABLED (CONFIG_PM ))
1737+ ret = pm_runtime_get_sync (gpu -> dev );
1738+ else
1739+ ret = etnaviv_gpu_clk_enable (gpu );
17211740 if (ret < 0 )
17221741 goto out_sched ;
17231742
17241743
17251744 gpu -> drm = drm ;
17261745 gpu -> fence_context = dma_fence_context_alloc (1 );
1727- idr_init (& gpu -> fence_idr );
1746+ xa_init_flags (& gpu -> user_fences , XA_FLAGS_ALLOC );
17281747 spin_lock_init (& gpu -> fence_spinlock );
17291748
17301749 INIT_WORK (& gpu -> sync_point_work , sync_point_worker );
@@ -1761,12 +1780,12 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
17611780
17621781 etnaviv_sched_fini (gpu );
17631782
1764- #ifdef CONFIG_PM
1765- pm_runtime_get_sync (gpu -> dev );
1766- pm_runtime_put_sync_suspend (gpu -> dev );
1767- # else
1768- etnaviv_gpu_hw_suspend (gpu );
1769- #endif
1783+ if ( IS_ENABLED ( CONFIG_PM )) {
1784+ pm_runtime_get_sync (gpu -> dev );
1785+ pm_runtime_put_sync_suspend (gpu -> dev );
1786+ } else {
1787+ etnaviv_gpu_hw_suspend (gpu );
1788+ }
17701789
17711790 if (gpu -> mmu_context )
17721791 etnaviv_iommu_context_put (gpu -> mmu_context );
@@ -1778,7 +1797,7 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
17781797 }
17791798
17801799 gpu -> drm = NULL ;
1781- idr_destroy (& gpu -> fence_idr );
1800+ xa_destroy (& gpu -> user_fences );
17821801
17831802 if (IS_ENABLED (CONFIG_DRM_ETNAVIV_THERMAL ))
17841803 thermal_cooling_device_unregister (gpu -> cooling );
@@ -1810,7 +1829,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
18101829
18111830 gpu -> dev = & pdev -> dev ;
18121831 mutex_init (& gpu -> lock );
1813- mutex_init (& gpu -> fence_lock );
1832+ mutex_init (& gpu -> sched_lock );
18141833
18151834 /* Map registers: */
18161835 gpu -> mmio = devm_platform_ioremap_resource (pdev , 0 );
@@ -1880,7 +1899,6 @@ static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
18801899 return 0 ;
18811900}
18821901
1883- #ifdef CONFIG_PM
18841902static int etnaviv_gpu_rpm_suspend (struct device * dev )
18851903{
18861904 struct etnaviv_gpu * gpu = dev_get_drvdata (dev );
@@ -1923,18 +1941,16 @@ static int etnaviv_gpu_rpm_resume(struct device *dev)
19231941
19241942 return 0 ;
19251943}
1926- #endif
19271944
19281945static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
1929- SET_RUNTIME_PM_OPS (etnaviv_gpu_rpm_suspend , etnaviv_gpu_rpm_resume ,
1930- NULL )
1946+ RUNTIME_PM_OPS (etnaviv_gpu_rpm_suspend , etnaviv_gpu_rpm_resume , NULL )
19311947};
19321948
19331949struct platform_driver etnaviv_gpu_driver = {
19341950 .driver = {
19351951 .name = "etnaviv-gpu" ,
19361952 .owner = THIS_MODULE ,
1937- .pm = & etnaviv_gpu_pm_ops ,
1953+ .pm = pm_ptr ( & etnaviv_gpu_pm_ops ) ,
19381954 .of_match_table = etnaviv_gpu_match ,
19391955 },
19401956 .probe = etnaviv_gpu_platform_probe ,
0 commit comments