@@ -89,10 +89,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
8989 if (!type )
9090 return NULL ;
9191
92- type -> box_ctrl_die = kcalloc (__uncore_max_dies , sizeof (u64 ), GFP_KERNEL );
93- if (!type -> box_ctrl_die )
94- goto free_type ;
95-
9692 type -> units = RB_ROOT ;
9793
9894 type -> access_type = unit -> access_type ;
@@ -102,12 +98,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
10298 rb_add (& type -> node , & discovery_tables , __type_less );
10399
104100 return type ;
105-
106- free_type :
107- kfree (type );
108-
109- return NULL ;
110-
111101}
112102
113103static struct intel_uncore_discovery_type *
@@ -230,13 +220,10 @@ void uncore_find_add_unit(struct intel_uncore_discovery_unit *node,
230220
231221static void
232222uncore_insert_box_info (struct uncore_unit_discovery * unit ,
233- int die , bool parsed )
223+ int die )
234224{
235225 struct intel_uncore_discovery_unit * node ;
236226 struct intel_uncore_discovery_type * type ;
237- unsigned int * ids ;
238- u64 * box_offset ;
239- int i ;
240227
241228 if (!unit -> ctl || !unit -> ctl_offset || !unit -> ctr_offset ) {
242229 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,
253240 node -> id = unit -> box_id ;
254241 node -> addr = unit -> ctl ;
255242
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 );
271246 return ;
272247 }
273248
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-
286249 uncore_find_add_unit (node , & type -> units , & type -> num_units );
287250
288251 /* 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 ) {
292253 type -> num_counters = unit -> num_regs ;
293254 type -> counter_width = unit -> bit_width ;
294255 type -> ctl_offset = unit -> ctl_offset ;
295256 type -> ctr_offset = unit -> ctr_offset ;
296- * ids = unit -> box_id ;
297- goto end ;
298257 }
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 );
329258}
330259
331260static bool
@@ -404,7 +333,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
404333 if (uncore_ignore_unit (& unit , ignore ))
405334 continue ;
406335
407- uncore_insert_box_info (& unit , die , * parsed );
336+ uncore_insert_box_info (& unit , die );
408337 }
409338
410339 * parsed = true;
@@ -474,7 +403,6 @@ void intel_uncore_clear_discovery_tables(void)
474403 rb_erase (node , & type -> units );
475404 kfree (pos );
476405 }
477- kfree (type -> box_ctrl_die );
478406 kfree (type );
479407 }
480408}
@@ -738,41 +666,23 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
738666 struct intel_uncore_discovery_type * type )
739667{
740668 uncore -> type_id = type -> type ;
741- uncore -> num_boxes = type -> num_boxes ;
742669 uncore -> num_counters = type -> num_counters ;
743670 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 ;
745675
746676 switch (type_id ) {
747677 case UNCORE_ACCESS_MSR :
748678 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 ;
755679 break ;
756680 case UNCORE_ACCESS_PCI :
757681 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 ;
765682 break ;
766683 case UNCORE_ACCESS_MMIO :
767684 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 ;
773685 uncore -> mmio_map_size = UNCORE_GENERIC_MMIO_SIZE ;
774- uncore -> boxes = & type -> units ;
775- uncore -> num_boxes = type -> num_units ;
776686 break ;
777687 default :
778688 return false;
0 commit comments