@@ -120,9 +120,9 @@ enum cci_models {
120120
121121static void pmu_write_counters (struct cci_pmu * cci_pmu ,
122122 unsigned long * mask );
123- static ssize_t cci_pmu_format_show (struct device * dev ,
123+ static ssize_t __maybe_unused cci_pmu_format_show (struct device * dev ,
124124 struct device_attribute * attr , char * buf );
125- static ssize_t cci_pmu_event_show (struct device * dev ,
125+ static ssize_t __maybe_unused cci_pmu_event_show (struct device * dev ,
126126 struct device_attribute * attr , char * buf );
127127
128128#define CCI_EXT_ATTR_ENTRY (_name , _func , _config ) \
@@ -1184,16 +1184,11 @@ static int cci_pmu_add(struct perf_event *event, int flags)
11841184 struct cci_pmu_hw_events * hw_events = & cci_pmu -> hw_events ;
11851185 struct hw_perf_event * hwc = & event -> hw ;
11861186 int idx ;
1187- int err = 0 ;
1188-
1189- perf_pmu_disable (event -> pmu );
11901187
11911188 /* If we don't have a space for the counter then finish early. */
11921189 idx = pmu_get_event_idx (hw_events , event );
1193- if (idx < 0 ) {
1194- err = idx ;
1195- goto out ;
1196- }
1190+ if (idx < 0 )
1191+ return idx ;
11971192
11981193 event -> hw .idx = idx ;
11991194 hw_events -> events [idx ] = event ;
@@ -1205,9 +1200,7 @@ static int cci_pmu_add(struct perf_event *event, int flags)
12051200 /* Propagate our changes to the userspace mapping. */
12061201 perf_event_update_userpage (event );
12071202
1208- out :
1209- perf_pmu_enable (event -> pmu );
1210- return err ;
1203+ return 0 ;
12111204}
12121205
12131206static void cci_pmu_del (struct perf_event * event , int flags )
@@ -1304,15 +1297,6 @@ static int __hw_perf_event_init(struct perf_event *event)
13041297 */
13051298 hwc -> config_base |= (unsigned long )mapping ;
13061299
1307- /*
1308- * Limit the sample_period to half of the counter width. That way, the
1309- * new counter value is far less likely to overtake the previous one
1310- * unless you have some serious IRQ latency issues.
1311- */
1312- hwc -> sample_period = CCI_PMU_CNTR_MASK >> 1 ;
1313- hwc -> last_period = hwc -> sample_period ;
1314- local64_set (& hwc -> period_left , hwc -> sample_period );
1315-
13161300 if (event -> group_leader != event ) {
13171301 if (validate_group (event ) != 0 )
13181302 return - EINVAL ;
@@ -1423,6 +1407,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev)
14231407 pmu_format_attr_group .attrs = model -> format_attrs ;
14241408
14251409 cci_pmu -> pmu = (struct pmu ) {
1410+ .module = THIS_MODULE ,
14261411 .name = cci_pmu -> model -> name ,
14271412 .task_ctx_nr = perf_invalid_context ,
14281413 .pmu_enable = cci_pmu_enable ,
@@ -1466,7 +1451,7 @@ static int cci_pmu_offline_cpu(unsigned int cpu)
14661451 return 0 ;
14671452}
14681453
1469- static struct cci_pmu_model cci_pmu_models [] = {
1454+ static __maybe_unused struct cci_pmu_model cci_pmu_models [] = {
14701455#ifdef CONFIG_ARM_CCI400_PMU
14711456 [CCI400_R0 ] = {
14721457 .name = "CCI_400" ,
@@ -1588,6 +1573,7 @@ static const struct of_device_id arm_cci_pmu_matches[] = {
15881573#endif
15891574 {},
15901575};
1576+ MODULE_DEVICE_TABLE (of , arm_cci_pmu_matches );
15911577
15921578static bool is_duplicate_irq (int irq , int * irqs , int nr_irqs )
15931579{
@@ -1709,14 +1695,27 @@ static int cci_pmu_probe(struct platform_device *pdev)
17091695 return 0 ;
17101696}
17111697
1698+ static int cci_pmu_remove (struct platform_device * pdev )
1699+ {
1700+ if (!g_cci_pmu )
1701+ return 0 ;
1702+
1703+ cpuhp_remove_state (CPUHP_AP_PERF_ARM_CCI_ONLINE );
1704+ perf_pmu_unregister (& g_cci_pmu -> pmu );
1705+ g_cci_pmu = NULL ;
1706+
1707+ return 0 ;
1708+ }
1709+
17121710static struct platform_driver cci_pmu_driver = {
17131711 .driver = {
17141712 .name = DRIVER_NAME ,
17151713 .of_match_table = arm_cci_pmu_matches ,
17161714 },
17171715 .probe = cci_pmu_probe ,
1716+ .remove = cci_pmu_remove ,
17181717};
17191718
1720- builtin_platform_driver (cci_pmu_driver );
1721- MODULE_LICENSE ("GPL" );
1719+ module_platform_driver (cci_pmu_driver );
1720+ MODULE_LICENSE ("GPL v2 " );
17221721MODULE_DESCRIPTION ("ARM CCI PMU support" );
0 commit comments