@@ -89,10 +89,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
89
89
if (!type )
90
90
return NULL ;
91
91
92
- type -> box_ctrl_die = kcalloc (__uncore_max_dies , sizeof (u64 ), GFP_KERNEL );
93
- if (!type -> box_ctrl_die )
94
- goto free_type ;
95
-
96
92
type -> units = RB_ROOT ;
97
93
98
94
type -> access_type = unit -> access_type ;
@@ -102,12 +98,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
102
98
rb_add (& type -> node , & discovery_tables , __type_less );
103
99
104
100
return type ;
105
-
106
- free_type :
107
- kfree (type );
108
-
109
- return NULL ;
110
-
111
101
}
112
102
113
103
static struct intel_uncore_discovery_type *
@@ -230,13 +220,10 @@ void uncore_find_add_unit(struct intel_uncore_discovery_unit *node,
230
220
231
221
static void
232
222
uncore_insert_box_info (struct uncore_unit_discovery * unit ,
233
- int die , bool parsed )
223
+ int die )
234
224
{
235
225
struct intel_uncore_discovery_unit * node ;
236
226
struct intel_uncore_discovery_type * type ;
237
- unsigned int * ids ;
238
- u64 * box_offset ;
239
- int i ;
240
227
241
228
if (!unit -> ctl || !unit -> ctl_offset || !unit -> ctr_offset ) {
242
229
pr_info ("Invalid address is detected for uncore type %d box %d, "
@@ -253,79 +240,21 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
253
240
node -> id = unit -> box_id ;
254
241
node -> addr = unit -> ctl ;
255
242
256
- if (parsed ) {
257
- type = search_uncore_discovery_type (unit -> box_type );
258
- if (!type ) {
259
- pr_info ("A spurious uncore type %d is detected, "
260
- "Disable the uncore type.\n" ,
261
- unit -> box_type );
262
- kfree (node );
263
- return ;
264
- }
265
-
266
- uncore_find_add_unit (node , & type -> units , & type -> num_units );
267
-
268
- /* Store the first box of each die */
269
- if (!type -> box_ctrl_die [die ])
270
- type -> box_ctrl_die [die ] = unit -> ctl ;
243
+ type = get_uncore_discovery_type (unit );
244
+ if (!type ) {
245
+ kfree (node );
271
246
return ;
272
247
}
273
248
274
- type = get_uncore_discovery_type (unit );
275
- if (!type )
276
- goto free_node ;
277
-
278
- box_offset = kcalloc (type -> num_boxes + 1 , sizeof (u64 ), GFP_KERNEL );
279
- if (!box_offset )
280
- goto free_node ;
281
-
282
- ids = kcalloc (type -> num_boxes + 1 , sizeof (unsigned int ), GFP_KERNEL );
283
- if (!ids )
284
- goto free_box_offset ;
285
-
286
249
uncore_find_add_unit (node , & type -> units , & type -> num_units );
287
250
288
251
/* Store generic information for the first box */
289
- if (!type -> num_boxes ) {
290
- type -> box_ctrl = unit -> ctl ;
291
- type -> box_ctrl_die [die ] = unit -> ctl ;
252
+ if (type -> num_units == 1 ) {
292
253
type -> num_counters = unit -> num_regs ;
293
254
type -> counter_width = unit -> bit_width ;
294
255
type -> ctl_offset = unit -> ctl_offset ;
295
256
type -> ctr_offset = unit -> ctr_offset ;
296
- * ids = unit -> box_id ;
297
- goto end ;
298
257
}
299
-
300
- for (i = 0 ; i < type -> num_boxes ; i ++ ) {
301
- ids [i ] = type -> ids [i ];
302
- box_offset [i ] = type -> box_offset [i ];
303
-
304
- if (unit -> box_id == ids [i ]) {
305
- pr_info ("Duplicate uncore type %d box ID %d is detected, "
306
- "Drop the duplicate uncore unit.\n" ,
307
- unit -> box_type , unit -> box_id );
308
- goto free_ids ;
309
- }
310
- }
311
- ids [i ] = unit -> box_id ;
312
- box_offset [i ] = unit -> ctl - type -> box_ctrl ;
313
- kfree (type -> ids );
314
- kfree (type -> box_offset );
315
- end :
316
- type -> ids = ids ;
317
- type -> box_offset = box_offset ;
318
- type -> num_boxes ++ ;
319
- return ;
320
-
321
- free_ids :
322
- kfree (ids );
323
-
324
- free_box_offset :
325
- kfree (box_offset );
326
-
327
- free_node :
328
- kfree (node );
329
258
}
330
259
331
260
static bool
@@ -404,7 +333,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
404
333
if (uncore_ignore_unit (& unit , ignore ))
405
334
continue ;
406
335
407
- uncore_insert_box_info (& unit , die , * parsed );
336
+ uncore_insert_box_info (& unit , die );
408
337
}
409
338
410
339
* parsed = true;
@@ -474,7 +403,6 @@ void intel_uncore_clear_discovery_tables(void)
474
403
rb_erase (node , & type -> units );
475
404
kfree (pos );
476
405
}
477
- kfree (type -> box_ctrl_die );
478
406
kfree (type );
479
407
}
480
408
}
@@ -738,41 +666,23 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
738
666
struct intel_uncore_discovery_type * type )
739
667
{
740
668
uncore -> type_id = type -> type ;
741
- uncore -> num_boxes = type -> num_boxes ;
742
669
uncore -> num_counters = type -> num_counters ;
743
670
uncore -> perf_ctr_bits = type -> counter_width ;
744
- uncore -> box_ids = type -> ids ;
671
+ uncore -> perf_ctr = (unsigned int )type -> ctr_offset ;
672
+ uncore -> event_ctl = (unsigned int )type -> ctl_offset ;
673
+ uncore -> boxes = & type -> units ;
674
+ uncore -> num_boxes = type -> num_units ;
745
675
746
676
switch (type_id ) {
747
677
case UNCORE_ACCESS_MSR :
748
678
uncore -> ops = & generic_uncore_msr_ops ;
749
- uncore -> perf_ctr = (unsigned int )type -> ctr_offset ;
750
- uncore -> event_ctl = (unsigned int )type -> ctl_offset ;
751
- uncore -> box_ctl = (unsigned int )type -> box_ctrl ;
752
- uncore -> msr_offsets = type -> box_offset ;
753
- uncore -> boxes = & type -> units ;
754
- uncore -> num_boxes = type -> num_units ;
755
679
break ;
756
680
case UNCORE_ACCESS_PCI :
757
681
uncore -> ops = & generic_uncore_pci_ops ;
758
- uncore -> perf_ctr = (unsigned int )UNCORE_DISCOVERY_PCI_BOX_CTRL (type -> box_ctrl ) + type -> ctr_offset ;
759
- uncore -> event_ctl = (unsigned int )UNCORE_DISCOVERY_PCI_BOX_CTRL (type -> box_ctrl ) + type -> ctl_offset ;
760
- uncore -> box_ctl = (unsigned int )UNCORE_DISCOVERY_PCI_BOX_CTRL (type -> box_ctrl );
761
- uncore -> box_ctls = type -> box_ctrl_die ;
762
- uncore -> pci_offsets = type -> box_offset ;
763
- uncore -> boxes = & type -> units ;
764
- uncore -> num_boxes = type -> num_units ;
765
682
break ;
766
683
case UNCORE_ACCESS_MMIO :
767
684
uncore -> ops = & generic_uncore_mmio_ops ;
768
- uncore -> perf_ctr = (unsigned int )type -> ctr_offset ;
769
- uncore -> event_ctl = (unsigned int )type -> ctl_offset ;
770
- uncore -> box_ctl = (unsigned int )type -> box_ctrl ;
771
- uncore -> box_ctls = type -> box_ctrl_die ;
772
- uncore -> mmio_offsets = type -> box_offset ;
773
685
uncore -> mmio_map_size = UNCORE_GENERIC_MMIO_SIZE ;
774
- uncore -> boxes = & type -> units ;
775
- uncore -> num_boxes = type -> num_units ;
776
686
break ;
777
687
default :
778
688
return false;
0 commit comments