@@ -69,6 +69,17 @@ static int xive_irq_bitmap_add(int base, int count)
69
69
return 0 ;
70
70
}
71
71
72
+ static void xive_irq_bitmap_remove_all (void )
73
+ {
74
+ struct xive_irq_bitmap * xibm , * tmp ;
75
+
76
+ list_for_each_entry_safe (xibm , tmp , & xive_irq_bitmaps , list ) {
77
+ list_del (& xibm -> list );
78
+ kfree (xibm -> bitmap );
79
+ kfree (xibm );
80
+ }
81
+ }
82
+
72
83
static int __xive_irq_bitmap_alloc (struct xive_irq_bitmap * xibm )
73
84
{
74
85
int irq ;
@@ -802,7 +813,7 @@ bool __init xive_spapr_init(void)
802
813
u32 val ;
803
814
u32 len ;
804
815
const __be32 * reg ;
805
- int i ;
816
+ int i , err ;
806
817
807
818
if (xive_spapr_disabled ())
808
819
return false;
@@ -818,32 +829,35 @@ bool __init xive_spapr_init(void)
818
829
/* Resource 1 is the OS ring TIMA */
819
830
if (of_address_to_resource (np , 1 , & r )) {
820
831
pr_err ("Failed to get thread mgmnt area resource\n" );
821
- return false ;
832
+ goto err_put ;
822
833
}
823
834
tima = ioremap (r .start , resource_size (& r ));
824
835
if (!tima ) {
825
836
pr_err ("Failed to map thread mgmnt area\n" );
826
- return false ;
837
+ goto err_put ;
827
838
}
828
839
829
840
if (!xive_get_max_prio (& max_prio ))
830
- return false ;
841
+ goto err_unmap ;
831
842
832
843
/* Feed the IRQ number allocator with the ranges given in the DT */
833
844
reg = of_get_property (np , "ibm,xive-lisn-ranges" , & len );
834
845
if (!reg ) {
835
846
pr_err ("Failed to read 'ibm,xive-lisn-ranges' property\n" );
836
- return false ;
847
+ goto err_unmap ;
837
848
}
838
849
839
850
if (len % (2 * sizeof (u32 )) != 0 ) {
840
851
pr_err ("invalid 'ibm,xive-lisn-ranges' property\n" );
841
- return false ;
852
+ goto err_unmap ;
842
853
}
843
854
844
- for (i = 0 ; i < len / (2 * sizeof (u32 )); i ++ , reg += 2 )
845
- xive_irq_bitmap_add (be32_to_cpu (reg [0 ]),
846
- be32_to_cpu (reg [1 ]));
855
+ for (i = 0 ; i < len / (2 * sizeof (u32 )); i ++ , reg += 2 ) {
856
+ err = xive_irq_bitmap_add (be32_to_cpu (reg [0 ]),
857
+ be32_to_cpu (reg [1 ]));
858
+ if (err < 0 )
859
+ goto err_mem_free ;
860
+ }
847
861
848
862
/* Iterate the EQ sizes and pick one */
849
863
of_property_for_each_u32 (np , "ibm,xive-eq-sizes" , prop , reg , val ) {
@@ -854,10 +868,19 @@ bool __init xive_spapr_init(void)
854
868
855
869
/* Initialize XIVE core with our backend */
856
870
if (!xive_core_init (np , & xive_spapr_ops , tima , TM_QW1_OS , max_prio ))
857
- return false ;
871
+ goto err_mem_free ;
858
872
873
+ of_node_put (np );
859
874
pr_info ("Using %dkB queues\n" , 1 << (xive_queue_shift - 10 ));
860
875
return true;
876
+
877
+ err_mem_free :
878
+ xive_irq_bitmap_remove_all ();
879
+ err_unmap :
880
+ iounmap (tima );
881
+ err_put :
882
+ of_node_put (np );
883
+ return false;
861
884
}
862
885
863
886
machine_arch_initcall (pseries , xive_core_debug_init );
0 commit comments