iginally from nv-tegra.nvidia.com/linux-nvgpu.git.
summaryrefslogblamecommitdiffstats
path: root/drivers/gpu/nvgpu/gv11b/gr_gv11b.c
blob: bb76178e424327b9813bc2d5521070270d752285 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
  
               
  
                                                                     
  





                                                                             
  









                                                                             

   
                         
                       
                      
                      
                        
                          
                       
                      
                                 
                      
                     
                        
                         
                        
                          
 
                           
                                
                               
                               
 
                           
 

                           
                           

                               
                        
                               




                                               

                                          
                                         
 
                                                  
 



                                                                                





                                                            
                                                            























                                
                                                                   


                     
                                                                















                             

                                            
                                                                      

                                              


                       
                                                                

            
                                                                          

                                                  


               
                                                                    















                               
                                               







                                                                             



























                                                                                      
                                                                                                 
                         
         
















                                                                                                                  
                                                       



                                                                                                     



                                                                                                    
                                                                                





                                                                                                       
                                                       



                                                                                                         



                                                                                                      
                                                                                  











                                                                                           
 



































                                                                                     
                                                                                           
                         
         
















                                                                                                            
                                                       



                                                                                                  



                                                                                                 
                                                                          





                                                                                                 
                                                       



                                                                                                    



                                                                                                   
                                                                          












                                                                                        
                                                    
 
                               
 





                                                         


















                                                                 

 












                                                                               
                                                















                                                                        

                                                         
                                                        


                                                           
                                                        


                                                                      



                                                      



























                                                                                     
                                                                                           
                         
         
















                                                                                                            
                                                       



                                                                                                  



                                                                                                 
                                                                             





                                                                                                 
                                                       



                                                                                                    



                                                                                                   
                                                                               












                                                                                        























                                                                                     
                                                                                                   
                         
         
















                                                                                                                    
                                                       



                                                                                                       



                                                                                                     
                                                                                 





                                                                                                         
                                                       



                                                                                                           



                                                                                                       
                                                                                   








































                                                                                            
                                                                                                 
                         
         
















                                                                                                                  
                                                       



                                                                                                              



                                                                                                    
                                                                                





                                                                                                       
                                                       



                                                                                                                



                                                                                                      
                                                                                  












                                                                                           
                                                         


                                                                 

                    
 

                                                                                            

                                       



                                                                                         
 





                                                                                             


                   
                                                                    





















                                                                           
                                                                                                   
                         
         





















                                                                                                            



                                                                                             
                                                                         










                                                                                                           



                                                                                               
                                                                           











                                                                                            
                                                                         


                                                                              

                                                                       
                                                                 

                                                     




                                                                             
                                                                              
                           
         





















                                                                                        
                                                          


                                                                       

                                                              


                                                                         
         




                                                                             
                                 
                                                                                                  

                                   
                                                                                                      
         
 
 
                                                                   
                                                                        
                                                                     



                                                                                   
                                                                                        
                                                                          

                                                                                          
                                                                            

                                                                                        
                                                                          

                                                                                          
                                                                            

                                                         
                                                                 
         




                                                                

                                                                            












                                                                              
                    



                                                                     
                                                                    
                           
         









                                                                             










                                                                                           
                                 
                                                          


                                                                          

                                                              


                                                                            
         
 


                                                                                
                                                               
                                                                        
                                                                 
                                                                          


                                                                               
                                                                                  
                                                                       
         
                        
                                                                           
                                                                         
         
                        
                                                                         
                                                                       
         
                        
                                                                           
                                                                         

                                                         
                                                             
         






                                                                          

                                                                        



                   
                                                                  

                                                                          
                                                                     

                                                                               
         


                 
                                                                 

                                                                          
                                                                    

                                                                               
         



                 
                                                    




                                                                

                                                                             

                  

                                                              
 
                                                           
                                                                     

                                                                         

 
                                                                    

                                 
                 

 
                                                                    
                                                              
 


                                             
                                                                

                               

                                    






                                                             
                                                                  


                                                             
              



























                                                               
                                  
                                               
                 



                     
                                                                  


                                                                         

                             
                                                          

                               










                                                                             



                 
                                                      
                                     
 
                                 
                
 

                                              
 


                                                  


                          

                                                  



                                                
 

                                                  


                                                
         
 

                                    
                 



                                                               

 
                                                                   






                                                              
 


                                                      
 
                                                              
                          
                                   
                 
         


                 
                                                   



                                                           
                                                         
























                                                                           
                                                            



                                                         
                                                                 


                
                             





                                                                                   
                                

 
                                                       



                  
                             


















                                                                              
                                                      






















                                                                                       
                                                              
 
                             
 







                                                                                

 
                                                                 





                                                             
                                                                  


                                                                                    
                


                                                                                     
         



                                                             
                                                        

                                                                         
                             
 
                                           

                                                  
                                                                
                              


                                                        


                                                                   




                                  
                                   
                                      
                                                  
                                                                
                              
                                                     

                                                                    
                                                           

                                                                          
                                                




                                                                   


                                                         


                                                        


                                                               


                                                               


                                                                   









                                  
                                                 










                                                                       
                                              


                                     
                                          

                                                                    
         

                                                             



                                                         

 
                                                                       





                                              
                             
 
                                                
                                                  
         


































                                                                                          
                                                                 




                                               
                             
 
                                                  
                                                    
         






















































                                                                                  
                                                           
                                              

                
                                            
 
                             
 
                                                        
                  
                           
         
 

                                        
                                     
                                                       
                                                    

                                               








                               
                                       


                   
                                                       
                                                            






                                                               
                                                                       
                                                                            
         

                                                         
                                                               
                                                                          
         

                                            
                                                                          
                               
         

                                                                             
                                                                                  
                               
         


                                                                   
                                                                     
                               
         

                                   
                                                                   
                               
         

















                                                                                    


                                                                                  







































































                                                                            
                                        

                                      

                                    
                                                     







                                                                                   
                             
 
                                   
                   
                       
         


                              

                                                                              
                                                                   






                                                                              
                                                                   






                                                                             
                                                                 










                                                                             
                                                

                                                                                
                                

                                                                          
                         

                 
                                                                      









                                                                                        
                                                                    
                                                                         






                                                                               
                                                                 
                                                                     
                 
 
                                                                              







                                                                                       
                                                   


                                                                               
                                                   




                                                                               
                                                   



                                                                         
                                                   




                                                                             




                                                             
                                                              


         
                                
 


























































                                                                                    




                                                                            




                                                                       
                                                                      













                                                                  
 
                                                 


                                                        


                                                      



















                                                                            
                                                                    



















                                                                                    
                                                             

                                                                                            
         











                                                                                    
                                                             

                                                                                            
         

















                                                                                          

                                                                   
                                                                     


















                                                                                    



                                                                            























                                                                                       


                                       




                                                   
                     

                                                        
                                                            
                                     
                 





                          
                                                                   


                                        



                                                       
                                     
 
                             
 

                                                                            




                                                                   











                                                                        
                                                
                                                


                                 
                                                     

                                                                  
                                                   
 
                    





                                                                                   
                                                      
                                                                         

                                                                  

                           
                                                  
                                                                  
                
                                                                          
         


                                                                                 
                                                                 
 
                                                                                         


                                                                                
                                                                         

                                                                         
                                                                         



                                                                          
                                                              
 

                     
                                             
                       
         







                                                                                

                                                 
                                                                             
 

                                                 
 
                                                                 

 
                                             































                                                                     
                                                                  
                                                                 





                                                 

                                                                   
                           

                                       
                   
                    
 
                                               
                       








                                                                             
         






                                                                                
                   
                                            
         







                                                               



                                                  
                   

 


                                                                              
                             







                                                                      
                                               
                                                                          
                                                   

































                                                                                 
                                       
                                                                  
                                                    





                                                                       
                       
 
 



                                                                               

                              
                                     











                                                                           



                                                    














                                                                     






















                                                                                  



                                                                                                             
                                                      
                                                                       



                                                                          
                                  
                                                            


                                                     
                                                                             
                              



                                 



                                                            
                                                                                 
                                                                               
                                                          
         
 








                                                                  
 

                                                  
                           
                                       
                 

                                                                   
                                                            
         
 
                                                  

                                                                                

                                                   
                                                                                       

                                                                                             
                 
 
                                                                                                    

                                                                                                          
                 
 

                                                                                                



                                                                       
                                                                  


                                                                         

                                                                             
                                                                          


                                                                               

                                                                    


                                                                                     
                                                                          


                                                                  

                                                                         


                                                                     

                                                                            

                                                                       
                                                                  


                                                                 
 
                                                                                                           
                                                                             
                                  
                                                                                                


                                           
                                                                                                    
                                                                                                         
                                                                          


                                                                                
                                                                        

                                                                                                             
                                                                                                            

                         
                                                                  

                                                                       
                                                                    

                                                
                                                                  

                                                                         






                                   


                                                                     

                                                     










                                                                           












                                                                                             
                                                                  

                                                                               

                                                                      


                                                                             
                 






                                                                               



                                                                          
                                                                    
                                                                        
                                                                      

                                                                          



                                                               
                                                                           
                                                                               
                 
                                
                                                                             

                                                                              
                 
                                
                                                                           
                                                                               
                 
                                
                                                                             

                                                                              

                                                                 
                                                                    
                 






                                                                            

                                                                             


         
                                               



                                                                       
                
 
                                                                       
 


                                                        

                                                            
                   

 
                                                                    

                

                                              


                                                                   
                                                  
 
                             
 
                             
                          
         



                                                                         











































                                                                                 
 


                                                                             

























                                                                             
                                                                    



                                                            

                                 
                                              

                                          
                                                                            



                                                            

                                                                            
         
                   

 
                                                 





                                                            
 
                                                          
                                                            





                                                                           

                                                                    



                                                                               
                                                          

                                                                           


                                                                             
                        
                                                                  
                 
 

                                                                      
                              
                 
         


                   




                                                                           
                             























                                                                              
                                             


                                                         
                                       
                                                      
                                      
                                                     
                                      
                                                     

 
                                                                    






                                                            
                                                            
                              
                 









                                                                  
                                                      





                                                                       
                                                                          
                       
 
                                                          
                                             
 
                                                                          
                                                                        





                                                                               
                                              



                                         
                                                                           

                                                                   
                                                                            
                         
                               
         
 










                                                                
                                                    
 
                                                      
                                      
                         













                                                                             
                                                        
                                                                 
         
                                  

                 
 
 
                                                             


                    
                                    
                
                               
 
                             
 
                                           
                  
                           
         
 
                                                    
                  
                           
         
 


                                                                       

                                                  
                                                                          
                                          


                                                                              
                                                                          






                                                     
                                                                              
 
                                           





                            
                             




                                                                       












                                                                               
                                                                               
                                                                         
                                                                           
                                                                   

                                                                                
                                                                           
                                                                              



                 
                                              
                                                                  





                                 
                            
                                                            
                            



                                                               
                                           
                                                                  





                                 
                            
                                                         
                            

                                                            
 
                                            
 












                                                                          
                                                             











                                                                              

 
                                                       



                                                          


                                                    















                                                                              
                                           

                 
                
                                                          
 
                             





                                                                                               


                                                                                  


                                                                    
                                                                             

                                                                   
                                                                            

                                                                  
                                                                    





                                                                       
                                                           





                                                                                           
 




                                                                            
                                                       

                                                         
                                                             

         
                                        
                  
                           
         










                                                                           
 
 
                                                               





                                                                               
                                                  

                                                                    
                                                                  
                                

                                                                  
                                      
         
                                                  


                                                                 
                                                






                                                                        
                                                                   





                                                                                
                                                    





                                                                              
                                                                            



















                                                                 

                                                                        
                                             
                                                                        



                                                  

                                                                            
                                              
                                                                            



                                                   

                                                                           
                                               
                                                                           









                                                                
                                                                     
                                                                              
                                                                     

                                                                              
                                                                       
                                                                                
                                                                       

                                                                                
                                                                      
                                                                               
                                                                      



                                                                               
                                               

                                                       
                                     



                                                             
                   
                               
         



                                                          
                                            
                                 
                 

                                                           






                                                                              
































                                                                                
                                                            
                  
                                                            
         



                            





















                                                                           
                                                                             
                                                               

                  

                                       

                                                                



                                                                       

                                                                  
 

                                                                          


                                                            


                                                  
 



                                             
 

                                                                 
 
            

                                                   
                     
 
 
                                                      





















                                                                                             

                                                                                





                                                                                             
                                                   









                                                                               
                                                    

                                                               
                                                                              
                            
         



                     
                                                

























                                                                                
                                                              







                                                       
                                              






























                                                                                

                                                                        










                                                                        
                                               


































































                                                                                 
                                             































































                                                                                 
                                               

                    
                    




                                                                              



                                                                          





                                    
                                                 










                                                                            
                                                   











                                                                               
                                                                     















                                                                                 



























                                                                                
                      




                                                               
                
                                                            



                                                               
         

 
                                                   










                                                                         
                                                     

                                                  
                                                    



















                                                                                 
                                                              





















                                                                               
                                                                    



                                                                               


                                                                










                                                                               












                                                                        
                                          






                                                                                
                                                    












                                                                                
                                                                     






                                                                                
                                                  




                                                                            
                                                  




                                                                          
                                                      






                                                                               
                                                                          
                         
         

















                                                                                


                                         
                                        
 
                                     
                       
         

































                                                                                 
                                        
 
                                             
                       
         






                                                                              
                                                   









                                                                            
                                                        









                                                                                    
                                                                        





                                                                   
                                                                    









































                                                                              








                                                                       
                                                         









                                                                       






































                                                                         
                                                         




                                                      
                                                          
                                    
                 













                                                                       
                                                                       
                                 
                 

























                                                                       
                                                          











                                                                             


                                                                    

                     
                     
























                                                                              
                                                             
                                                                           
                                                                             
                         









                                                                  


















                                                                              
                                                                  

                                                      
 
                                















                                                                              














                                                                                             
                                 
                                                                                


                                                                     
                                





                                                                             
                                                                              
                                                 
                                 

                                                                








                                                                               
                                                                    
                                         
                                                     
                                                                           


                                                                             
                                        
                                                             

                                                                  
                                                               



                                                                    
                                 
                         
                                                                        


                                                             








                                                                      
                                           



                             
                                           




                                                
                                     













                                                                
                                                     
                                                     
                                                   
                                                     
                                                   
 




                                                   
                 


                             
                                                                      
                                                                 
                
                                                                   
         


                                                 

                                                     






                                                          
                                                               




                                                                            
                                                                        

                                            
                

                                                 
         
 




                                                                      
                

                                   




                                              
 


                                                         
                                                                      
                                                                 
 

                                                                                          
                                                                       
                                              
                                 
 
                                                                      
                                                          
                                 






                                                                            










































































                                                                               


                                                                                 



                                                                                


                                                                                 
























































                                                                                    

















































































































                                                                                



                                                 
                                             
 
                                           
                                                         

                                               
                                                             

                                              
                                                            

                                           
                                                         

                                             
                                                            
         

 









                                                                









                                                            





                                                                    
                                        




                                                              
                                                                      














                                                                    
                        
                                                            
                 
























                                                                            
                                                         
                                                  
                                                            
                                                                     
                                                                   
                                                                     
                 
















































                                                                                
 






                                                                   

                                     
                                                                    













                                                                     
                                                                           
















                                                                               
                                       




                                              



                           
                                                                      



                                                                              
                                                                   
                  
                           
         








                                                                                
                                                                  
                                                                           
                        
                                                    
                 












                                                                              
                                                                        

                                                                            
                                                 



                                                                              
                                 
                         



                                                                             
                                          
                                                   
                                 






                                                                             
                                                                              
                                                 
                                 


































                                                                               
                                                                            





                                                                      
                                                                       
                                                                              

                                                                      
                                                            

                                                                             
                                                            

                                                                             


                                                                             

























                                                                           
                                                                

                                                                    
                                         



                                                                          
                         
                                                                       

                                                                            
                        
                                                    
                 




                           




















































                                                                                     
/*
 * GV11b GPU GR
 *
 * Copyright (c) 2016-2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <nvgpu/timers.h>
#include <nvgpu/gmmu.h>
#include <nvgpu/dma.h>
#include <nvgpu/log.h>
#include <nvgpu/debug.h>
#include <nvgpu/enabled.h>
#include <nvgpu/fuse.h>
#include <nvgpu/bug.h>
#include <nvgpu/error_notifier.h>
#include <nvgpu/soc.h>
#include <nvgpu/io.h>
#include <nvgpu/utils.h>
#include <nvgpu/bitops.h>
#include <nvgpu/gk20a.h>
#include <nvgpu/channel.h>

#include "gk20a/gr_gk20a.h"
#include "gk20a/dbg_gpu_gk20a.h"
#include "gk20a/regops_gk20a.h"
#include "gk20a/gr_pri_gk20a.h"

#include "gm20b/gr_gm20b.h"

#include "gp10b/gr_gp10b.h"

#include "gv11b/gr_gv11b.h"
#include "gv11b/mm_gv11b.h"
#include "gv11b/subctx_gv11b.h"
#include "gv11b/gv11b.h"
#include "gv11b/gr_pri_gv11b.h"

#include <nvgpu/hw/gv11b/hw_gr_gv11b.h>
#include <nvgpu/hw/gv11b/hw_fifo_gv11b.h>
#include <nvgpu/hw/gv11b/hw_proj_gv11b.h>
#include <nvgpu/hw/gv11b/hw_ctxsw_prog_gv11b.h>
#include <nvgpu/hw/gv11b/hw_ram_gv11b.h>
#include <nvgpu/hw/gv11b/hw_pbdma_gv11b.h>
#include <nvgpu/hw/gv11b/hw_perf_gv11b.h>

#define GFXP_WFI_TIMEOUT_COUNT_IN_USEC_DEFAULT 100

/* ecc scrubbing will done in 1 pri read cycle,but for safety used 10 retries */
#define ECC_SCRUBBING_TIMEOUT_MAX 1000
#define ECC_SCRUBBING_TIMEOUT_DEFAULT 10

/*
 * Each gpc can have maximum 32 tpcs, so each tpc index need
 * 5 bits. Each map register(32bits) can hold 6 tpcs info.
 */
#define GR_TPCS_INFO_FOR_MAPREGISTER 6

bool gr_gv11b_is_valid_class(struct gk20a *g, u32 class_num)
{
	bool valid = false;

	switch (class_num) {
	case VOLTA_COMPUTE_A:
	case VOLTA_A:
	case VOLTA_DMA_COPY_A:
		valid = true;
		break;

	case MAXWELL_COMPUTE_B:
	case MAXWELL_B:
	case FERMI_TWOD_A:
	case KEPLER_DMA_COPY_A:
	case MAXWELL_DMA_COPY_A:
	case PASCAL_COMPUTE_A:
	case PASCAL_A:
	case PASCAL_DMA_COPY_A:
		valid = true;
		break;

	default:
		break;
	}
	nvgpu_log_info(g, "class=0x%x valid=%d", class_num, valid);
	return valid;
}

bool gr_gv11b_is_valid_gfx_class(struct gk20a *g, u32 class_num)
{
	bool valid = false;

	switch (class_num) {
	case VOLTA_A:
	case PASCAL_A:
	case MAXWELL_B:
		valid = true;
		break;

	default:
		break;
	}
	return valid;
}

void gr_gv11b_powergate_tpc(struct gk20a *g)
{
	u32 tpc_pg_status = g->ops.fuse.fuse_status_opt_tpc_gpc(g, 0);

	if (tpc_pg_status == g->tpc_pg_mask) {
		return;
	}

	g->ops.fuse.fuse_ctrl_opt_tpc_gpc(g, 0, g->tpc_pg_mask);

	do {
		tpc_pg_status = g->ops.fuse.fuse_status_opt_tpc_gpc(g, 0);
	} while (tpc_pg_status != g->tpc_pg_mask);

	return;
}

bool gr_gv11b_is_valid_compute_class(struct gk20a *g, u32 class_num)
{
	bool valid = false;

	switch (class_num) {
	case VOLTA_COMPUTE_A:
	case PASCAL_COMPUTE_A:
	case MAXWELL_COMPUTE_B:
		valid = true;
		break;

	default:
		break;
	}
	return valid;
}

u32 gv11b_gr_sm_offset(struct gk20a *g, u32 sm)
{

	u32 sm_pri_stride = nvgpu_get_litter_value(g, GPU_LIT_SM_PRI_STRIDE);
	u32 sm_offset = sm_pri_stride * sm;

	return sm_offset;
}

static int gr_gv11b_handle_l1_tag_exception(struct gk20a *g, u32 gpc, u32 tpc,
			bool *post_event, struct channel_gk20a *fault_ch,
			u32 *hww_global_esr)
{
	u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
	u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
	u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
	u32 l1_tag_ecc_status, l1_tag_ecc_corrected_err_status = 0;
	u32 l1_tag_ecc_uncorrected_err_status = 0;
	u32 l1_tag_corrected_err_count_delta = 0;
	u32 l1_tag_uncorrected_err_count_delta = 0;
	bool is_l1_tag_ecc_corrected_total_err_overflow = 0;
	bool is_l1_tag_ecc_uncorrected_total_err_overflow = 0;

	/* Check for L1 tag ECC errors. */
	l1_tag_ecc_status = gk20a_readl(g,
		gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_r() + offset);
	l1_tag_ecc_corrected_err_status = l1_tag_ecc_status &
		(gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_corrected_err_el1_0_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_corrected_err_el1_1_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_corrected_err_pixrpf_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_corrected_err_miss_fifo_m());
	l1_tag_ecc_uncorrected_err_status = l1_tag_ecc_status &
		(gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_uncorrected_err_el1_0_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_uncorrected_err_el1_1_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_uncorrected_err_pixrpf_m() |
		 gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_uncorrected_err_miss_fifo_m());

	if ((l1_tag_ecc_corrected_err_status == 0) && (l1_tag_ecc_uncorrected_err_status == 0)) {
		return 0;
	}

	l1_tag_corrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_l1_tag_ecc_corrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_l1_tag_ecc_corrected_err_count_r() +
				offset));
	l1_tag_uncorrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_l1_tag_ecc_uncorrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_l1_tag_ecc_uncorrected_err_count_r() +
				offset));
	is_l1_tag_ecc_corrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_corrected_err_total_counter_overflow_v(l1_tag_ecc_status);
	is_l1_tag_ecc_uncorrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_uncorrected_err_total_counter_overflow_v(l1_tag_ecc_status);

	if ((l1_tag_corrected_err_count_delta > 0) || is_l1_tag_ecc_corrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"corrected error (SBE) detected in SM L1 tag! err_mask [%08x] is_overf [%d]",
			l1_tag_ecc_corrected_err_status, is_l1_tag_ecc_corrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_l1_tag_ecc_corrected_total_err_overflow) {
			l1_tag_corrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_l1_tag_ecc_corrected_err_count_total_s());
		}
		g->ecc.gr.sm_l1_tag_ecc_corrected_err_count[gpc][tpc].counter +=
							l1_tag_corrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_l1_tag_ecc_corrected_err_count_r() + offset,
			0);
	}
	if ((l1_tag_uncorrected_err_count_delta > 0) || is_l1_tag_ecc_uncorrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"Uncorrected error (DBE) detected in SM L1 tag! err_mask [%08x] is_overf [%d]",
			l1_tag_ecc_uncorrected_err_status, is_l1_tag_ecc_uncorrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_l1_tag_ecc_uncorrected_total_err_overflow) {
			l1_tag_uncorrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_l1_tag_ecc_uncorrected_err_count_total_s());
		}
		g->ecc.gr.sm_l1_tag_ecc_uncorrected_err_count[gpc][tpc].counter +=
							l1_tag_uncorrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_l1_tag_ecc_uncorrected_err_count_r() + offset,
			0);
	}

	gk20a_writel(g, gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_r() + offset,
			gr_pri_gpc0_tpc0_sm_l1_tag_ecc_status_reset_task_f());

	return 0;

}

static int gr_gv11b_handle_lrf_exception(struct gk20a *g, u32 gpc, u32 tpc,
			bool *post_event, struct channel_gk20a *fault_ch,
			u32 *hww_global_esr)
{
	u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
	u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
	u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
	u32 lrf_ecc_status, lrf_ecc_corrected_err_status = 0;
	u32 lrf_ecc_uncorrected_err_status = 0;
	u32 lrf_corrected_err_count_delta = 0;
	u32 lrf_uncorrected_err_count_delta = 0;
	bool is_lrf_ecc_corrected_total_err_overflow = 0;
	bool is_lrf_ecc_uncorrected_total_err_overflow = 0;

	/* Check for LRF ECC errors. */
	lrf_ecc_status = gk20a_readl(g,
		gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r() + offset);
	lrf_ecc_corrected_err_status = lrf_ecc_status &
		(gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp0_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp1_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp2_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp3_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp4_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp5_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp6_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_qrfdp7_m());
	lrf_ecc_uncorrected_err_status = lrf_ecc_status &
		(gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp0_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp1_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp2_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp3_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp4_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp5_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp6_m() |
		 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_qrfdp7_m());

	if ((lrf_ecc_corrected_err_status == 0) && (lrf_ecc_uncorrected_err_status == 0)) {
		return 0;
	}

	lrf_corrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_lrf_ecc_corrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_lrf_ecc_corrected_err_count_r() +
				offset));
	lrf_uncorrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_lrf_ecc_uncorrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_lrf_ecc_uncorrected_err_count_r() +
				offset));
	is_lrf_ecc_corrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_lrf_ecc_status_corrected_err_total_counter_overflow_v(lrf_ecc_status);
	is_lrf_ecc_uncorrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_lrf_ecc_status_uncorrected_err_total_counter_overflow_v(lrf_ecc_status);

	if ((lrf_corrected_err_count_delta > 0) || is_lrf_ecc_corrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"corrected error (SBE) detected in SM LRF! err_mask [%08x] is_overf [%d]",
			lrf_ecc_corrected_err_status, is_lrf_ecc_corrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_lrf_ecc_corrected_total_err_overflow) {
			lrf_corrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_lrf_ecc_corrected_err_count_total_s());
		}
		g->ecc.gr.sm_lrf_ecc_single_err_count[gpc][tpc].counter +=
							lrf_corrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_lrf_ecc_corrected_err_count_r() + offset,
			0);
	}
	if ((lrf_uncorrected_err_count_delta > 0) || is_lrf_ecc_uncorrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"Uncorrected error (DBE) detected in SM LRF! err_mask [%08x] is_overf [%d]",
			lrf_ecc_uncorrected_err_status, is_lrf_ecc_uncorrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_lrf_ecc_uncorrected_total_err_overflow) {
			lrf_uncorrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_lrf_ecc_uncorrected_err_count_total_s());
		}
		g->ecc.gr.sm_lrf_ecc_double_err_count[gpc][tpc].counter +=
							lrf_uncorrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_lrf_ecc_uncorrected_err_count_r() + offset,
			0);
	}

	gk20a_writel(g, gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r() + offset,
			gr_pri_gpc0_tpc0_sm_lrf_ecc_status_reset_task_f());

	return 0;

}

void gr_gv11b_enable_hww_exceptions(struct gk20a *g)
{
	/* enable exceptions */

	gk20a_writel(g, gr_fe_hww_esr_r(),
		     gr_fe_hww_esr_en_enable_f() |
		     gr_fe_hww_esr_reset_active_f());
	gk20a_writel(g, gr_memfmt_hww_esr_r(),
		     gr_memfmt_hww_esr_en_enable_f() |
		     gr_memfmt_hww_esr_reset_active_f());
	gk20a_writel(g, gr_pd_hww_esr_r(),
		     gr_pd_hww_esr_en_enable_f() |
		     gr_pd_hww_esr_reset_active_f());
	gk20a_writel(g, gr_scc_hww_esr_r(),
		     gr_scc_hww_esr_en_enable_f() |
		     gr_scc_hww_esr_reset_active_f());
	gk20a_writel(g, gr_ds_hww_esr_r(),
		     gr_ds_hww_esr_en_enabled_f() |
		     gr_ds_hww_esr_reset_task_f());
	gk20a_writel(g, gr_ssync_hww_esr_r(),
		     gr_ssync_hww_esr_en_enable_f() |
		     gr_ssync_hww_esr_reset_active_f());
	gk20a_writel(g, gr_mme_hww_esr_r(),
		     gr_mme_hww_esr_en_enable_f() |
		     gr_mme_hww_esr_reset_active_f());

	/* For now leave POR values */
	nvgpu_log(g, gpu_dbg_info, "gr_sked_hww_esr_en_r 0x%08x",
			gk20a_readl(g, gr_sked_hww_esr_en_r()));
}

void gr_gv11b_fecs_host_int_enable(struct gk20a *g)
{
	gk20a_writel(g, gr_fecs_host_int_enable_r(),
		     gr_fecs_host_int_enable_ctxsw_intr1_enable_f() |
		     gr_fecs_host_int_enable_fault_during_ctxsw_enable_f() |
		     gr_fecs_host_int_enable_umimp_firmware_method_enable_f() |
		     gr_fecs_host_int_enable_umimp_illegal_method_enable_f() |
		     gr_fecs_host_int_enable_watchdog_enable_f() |
		     gr_fecs_host_int_enable_flush_when_busy_enable_f() |
		     gr_fecs_host_int_enable_ecc_corrected_enable_f() |
		     gr_fecs_host_int_enable_ecc_uncorrected_enable_f());
}

void gr_gv11b_enable_exceptions(struct gk20a *g)
{
	struct gr_gk20a *gr = &g->gr;
	u32 reg_val;

	/*
	 * clear exceptions :
	 * other than SM : hww_esr are reset in *enable_hww_excetpions*
	 * SM            : cleared in *set_hww_esr_report_mask*
	 */

	/* enable exceptions */
	gk20a_writel(g, gr_exception2_en_r(), 0x0); /* BE not enabled */
	gk20a_writel(g, gr_exception1_en_r(), (1 << gr->gpc_count) - 1);

	reg_val = gr_exception_en_fe_enabled_f() |
			gr_exception_en_memfmt_enabled_f() |
			gr_exception_en_pd_enabled_f() |
			gr_exception_en_scc_enabled_f() |
			gr_exception_en_ds_enabled_f() |
			gr_exception_en_ssync_enabled_f() |
			gr_exception_en_mme_enabled_f() |
			gr_exception_en_sked_enabled_f() |
			gr_exception_en_gpc_enabled_f();

	nvgpu_log(g, gpu_dbg_info, "gr_exception_en 0x%08x", reg_val);

	gk20a_writel(g, gr_exception_en_r(), reg_val);

}

static int gr_gv11b_handle_cbu_exception(struct gk20a *g, u32 gpc, u32 tpc,
			bool *post_event, struct channel_gk20a *fault_ch,
			u32 *hww_global_esr)
{
	u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
	u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
	u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
	u32 cbu_ecc_status, cbu_ecc_corrected_err_status = 0;
	u32 cbu_ecc_uncorrected_err_status = 0;
	u32 cbu_corrected_err_count_delta = 0;
	u32 cbu_uncorrected_err_count_delta = 0;
	bool is_cbu_ecc_corrected_total_err_overflow = 0;
	bool is_cbu_ecc_uncorrected_total_err_overflow = 0;

	/* Check for CBU ECC errors. */
	cbu_ecc_status = gk20a_readl(g,
		gr_pri_gpc0_tpc0_sm_cbu_ecc_status_r() + offset);
	cbu_ecc_corrected_err_status = cbu_ecc_status &
		(gr_pri_gpc0_tpc0_sm_cbu_ecc_status_corrected_err_warp_sm0_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_corrected_err_warp_sm1_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_corrected_err_barrier_sm0_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_corrected_err_barrier_sm1_m());
	cbu_ecc_uncorrected_err_status = cbu_ecc_status &
		(gr_pri_gpc0_tpc0_sm_cbu_ecc_status_uncorrected_err_warp_sm0_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_uncorrected_err_warp_sm1_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_uncorrected_err_barrier_sm0_m() |
		 gr_pri_gpc0_tpc0_sm_cbu_ecc_status_uncorrected_err_barrier_sm1_m());

	if ((cbu_ecc_corrected_err_status == 0) && (cbu_ecc_uncorrected_err_status == 0)) {
		return 0;
	}

	cbu_corrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_cbu_ecc_corrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_cbu_ecc_corrected_err_count_r() +
				offset));
	cbu_uncorrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_cbu_ecc_uncorrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_cbu_ecc_uncorrected_err_count_r() +
				offset));
	is_cbu_ecc_corrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_cbu_ecc_status_corrected_err_total_counter_overflow_v(cbu_ecc_status);
	is_cbu_ecc_uncorrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_cbu_ecc_status_uncorrected_err_total_counter_overflow_v(cbu_ecc_status);

	if ((cbu_corrected_err_count_delta > 0) || is_cbu_ecc_corrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"corrected error (SBE) detected in SM CBU! err_mask [%08x] is_overf [%d]",
			cbu_ecc_corrected_err_status, is_cbu_ecc_corrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_cbu_ecc_corrected_total_err_overflow) {
			cbu_corrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_cbu_ecc_corrected_err_count_total_s());
		}
		g->ecc.gr.sm_cbu_ecc_corrected_err_count[gpc][tpc].counter +=
							cbu_corrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_cbu_ecc_corrected_err_count_r() + offset,
			0);
	}
	if ((cbu_uncorrected_err_count_delta > 0) || is_cbu_ecc_uncorrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"Uncorrected error (DBE) detected in SM CBU! err_mask [%08x] is_overf [%d]",
			cbu_ecc_uncorrected_err_status, is_cbu_ecc_uncorrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_cbu_ecc_uncorrected_total_err_overflow) {
			cbu_uncorrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_cbu_ecc_uncorrected_err_count_total_s());
		}
		g->ecc.gr.sm_cbu_ecc_uncorrected_err_count[gpc][tpc].counter +=
							cbu_uncorrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_cbu_ecc_uncorrected_err_count_r() + offset,
			0);
	}

	gk20a_writel(g, gr_pri_gpc0_tpc0_sm_cbu_ecc_status_r() + offset,
			gr_pri_gpc0_tpc0_sm_cbu_ecc_status_reset_task_f());

	return 0;

}

static int gr_gv11b_handle_l1_data_exception(struct gk20a *g, u32 gpc, u32 tpc,
			bool *post_event, struct channel_gk20a *fault_ch,
			u32 *hww_global_esr)
{
	u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
	u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
	u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
	u32 l1_data_ecc_status, l1_data_ecc_corrected_err_status = 0;
	u32 l1_data_ecc_uncorrected_err_status = 0;
	u32 l1_data_corrected_err_count_delta = 0;
	u32 l1_data_uncorrected_err_count_delta = 0;
	bool is_l1_data_ecc_corrected_total_err_overflow = 0;
	bool is_l1_data_ecc_uncorrected_total_err_overflow = 0;

	/* Check for L1 data ECC errors. */
	l1_data_ecc_status = gk20a_readl(g,
		gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_r() + offset);
	l1_data_ecc_corrected_err_status = l1_data_ecc_status &
		(gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_corrected_err_el1_0_m() |
		 gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_corrected_err_el1_1_m());
	l1_data_ecc_uncorrected_err_status = l1_data_ecc_status &
		(gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_uncorrected_err_el1_0_m() |
		 gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_uncorrected_err_el1_1_m());

	if ((l1_data_ecc_corrected_err_status == 0) && (l1_data_ecc_uncorrected_err_status == 0)) {
		return 0;
	}

	l1_data_corrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_l1_data_ecc_corrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_l1_data_ecc_corrected_err_count_r() +
				offset));
	l1_data_uncorrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_l1_data_ecc_uncorrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_l1_data_ecc_uncorrected_err_count_r() +
				offset));
	is_l1_data_ecc_corrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_corrected_err_total_counter_overflow_v(l1_data_ecc_status);
	is_l1_data_ecc_uncorrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_uncorrected_err_total_counter_overflow_v(l1_data_ecc_status);

	if ((l1_data_corrected_err_count_delta > 0) || is_l1_data_ecc_corrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"corrected error (SBE) detected in SM L1 data! err_mask [%08x] is_overf [%d]",
			l1_data_ecc_corrected_err_status, is_l1_data_ecc_corrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_l1_data_ecc_corrected_total_err_overflow) {
			l1_data_corrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_l1_data_ecc_corrected_err_count_total_s());
		}
		g->ecc.gr.sm_l1_data_ecc_corrected_err_count[gpc][tpc].counter +=
							l1_data_corrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_l1_data_ecc_corrected_err_count_r() + offset,
			0);
	}
	if ((l1_data_uncorrected_err_count_delta > 0) || is_l1_data_ecc_uncorrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"Uncorrected error (DBE) detected in SM L1 data! err_mask [%08x] is_overf [%d]",
			l1_data_ecc_uncorrected_err_status, is_l1_data_ecc_uncorrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_l1_data_ecc_uncorrected_total_err_overflow) {
			l1_data_uncorrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_l1_data_ecc_uncorrected_err_count_total_s());
		}
		g->ecc.gr.sm_l1_data_ecc_uncorrected_err_count[gpc][tpc].counter +=
							l1_data_uncorrected_err_count_delta;
		gk20a_writel(g,
			gr_pri_gpc0_tpc0_sm_l1_data_ecc_uncorrected_err_count_r() + offset,
			0);
	}

	gk20a_writel(g, gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_r() + offset,
			gr_pri_gpc0_tpc0_sm_l1_data_ecc_status_reset_task_f());

	return 0;

}

static int gr_gv11b_handle_icache_exception(struct gk20a *g, u32 gpc, u32 tpc,
			bool *post_event, struct channel_gk20a *fault_ch,
			u32 *hww_global_esr)
{
	u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
	u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
	u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
	u32 icache_ecc_status, icache_ecc_corrected_err_status = 0;
	u32 icache_ecc_uncorrected_err_status = 0;
	u32 icache_corrected_err_count_delta = 0;
	u32 icache_uncorrected_err_count_delta = 0;
	bool is_icache_ecc_corrected_total_err_overflow = 0;
	bool is_icache_ecc_uncorrected_total_err_overflow = 0;

	/* Check for L0 && L1 icache ECC errors. */
	icache_ecc_status = gk20a_readl(g,
		gr_pri_gpc0_tpc0_sm_icache_ecc_status_r() + offset);
	icache_ecc_corrected_err_status = icache_ecc_status &
		(gr_pri_gpc0_tpc0_sm_icache_ecc_status_corrected_err_l0_data_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_corrected_err_l0_predecode_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_corrected_err_l1_data_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_corrected_err_l1_predecode_m());
	icache_ecc_uncorrected_err_status = icache_ecc_status &
		(gr_pri_gpc0_tpc0_sm_icache_ecc_status_uncorrected_err_l0_data_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_uncorrected_err_l0_predecode_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_uncorrected_err_l1_data_m() |
		 gr_pri_gpc0_tpc0_sm_icache_ecc_status_uncorrected_err_l1_predecode_m());

	if ((icache_ecc_corrected_err_status == 0) && (icache_ecc_uncorrected_err_status == 0)) {
		return 0;
	}

	icache_corrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_icache_ecc_corrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_icache_ecc_corrected_err_count_r() +
				offset));
	icache_uncorrected_err_count_delta =
		gr_pri_gpc0_tpc0_sm_icache_ecc_uncorrected_err_count_total_v(
			gk20a_readl(g,
				gr_pri_gpc0_tpc0_sm_icache_ecc_uncorrected_err_count_r() +
				offset));
	is_icache_ecc_corrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_icache_ecc_status_corrected_err_total_counter_overflow_v(icache_ecc_status);
	is_icache_ecc_uncorrected_total_err_overflow =
		gr_pri_gpc0_tpc0_sm_icache_ecc_status_uncorrected_err_total_counter_overflow_v(icache_ecc_status);

	if ((icache_corrected_err_count_delta > 0) || is_icache_ecc_corrected_total_err_overflow) {
		nvgpu_log(g, gpu_dbg_fn | gpu_dbg_intr,
			"corrected error (SBE) detected in SM L0 && L1 icache! err_mask [%08x] is_overf [%d]",
			icache_ecc_corrected_err_status, is_icache_ecc_corrected_total_err_overflow);

		/* HW uses 16-bits counter */
		if (is_icache_ecc_corrected_total_err_overflow) {
			icache_corrected_err_count_delta +=
				BIT32(gr_pri_gpc0_tpc0_sm_icache_ecc_corrected_err_count_total_s());