@@ -232,25 +232,6 @@ static int etm4_cpu_id(struct coresight_device *csdev)
232232 return drvdata -> cpu ;
233233}
234234
235- int etm4_read_alloc_trace_id (struct etmv4_drvdata * drvdata )
236- {
237- int trace_id ;
238-
239- /*
240- * This will allocate a trace ID to the cpu,
241- * or return the one currently allocated.
242- * The trace id function has its own lock
243- */
244- trace_id = coresight_trace_id_get_cpu_id (drvdata -> cpu );
245- if (IS_VALID_CS_TRACE_ID (trace_id ))
246- drvdata -> trcid = (u8 )trace_id ;
247- else
248- dev_err (& drvdata -> csdev -> dev ,
249- "Failed to allocate trace ID for %s on CPU%d\n" ,
250- dev_name (& drvdata -> csdev -> dev ), drvdata -> cpu );
251- return trace_id ;
252- }
253-
254235void etm4_release_trace_id (struct etmv4_drvdata * drvdata )
255236{
256237 coresight_trace_id_put_cpu_id (drvdata -> cpu );
@@ -810,9 +791,9 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
810791
811792static int etm4_enable_perf (struct coresight_device * csdev ,
812793 struct perf_event * event ,
813- struct coresight_trace_id_map * id_map )
794+ struct coresight_path * path )
814795{
815- int ret = 0 , trace_id ;
796+ int ret = 0 ;
816797 struct etmv4_drvdata * drvdata = dev_get_drvdata (csdev -> dev .parent );
817798
818799 if (WARN_ON_ONCE (drvdata -> cpu != smp_processor_id ())) {
@@ -825,22 +806,7 @@ static int etm4_enable_perf(struct coresight_device *csdev,
825806 if (ret )
826807 goto out ;
827808
828- /*
829- * perf allocates cpu ids as part of _setup_aux() - device needs to use
830- * the allocated ID. This reads the current version without allocation.
831- *
832- * This does not use the trace id lock to prevent lock_dep issues
833- * with perf locks - we know the ID cannot change until perf shuts down
834- * the session
835- */
836- trace_id = coresight_trace_id_read_cpu_id_map (drvdata -> cpu , id_map );
837- if (!IS_VALID_CS_TRACE_ID (trace_id )) {
838- dev_err (& drvdata -> csdev -> dev , "Failed to set trace ID for %s on CPU%d\n" ,
839- dev_name (& drvdata -> csdev -> dev ), drvdata -> cpu );
840- ret = - EINVAL ;
841- goto out ;
842- }
843- drvdata -> trcid = (u8 )trace_id ;
809+ drvdata -> trcid = path -> trace_id ;
844810
845811 /* And enable it */
846812 ret = etm4_enable_hw (drvdata );
@@ -849,7 +815,7 @@ static int etm4_enable_perf(struct coresight_device *csdev,
849815 return ret ;
850816}
851817
852- static int etm4_enable_sysfs (struct coresight_device * csdev )
818+ static int etm4_enable_sysfs (struct coresight_device * csdev , struct coresight_path * path )
853819{
854820 struct etmv4_drvdata * drvdata = dev_get_drvdata (csdev -> dev .parent );
855821 struct etm4_enable_arg arg = { };
@@ -866,10 +832,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev)
866832
867833 spin_lock (& drvdata -> spinlock );
868834
869- /* sysfs needs to read and allocate a trace ID */
870- ret = etm4_read_alloc_trace_id (drvdata );
871- if (ret < 0 )
872- goto unlock_sysfs_enable ;
835+ drvdata -> trcid = path -> trace_id ;
873836
874837 /*
875838 * Executing etm4_enable_hw on the cpu whose ETM is being enabled
@@ -886,7 +849,6 @@ static int etm4_enable_sysfs(struct coresight_device *csdev)
886849 if (ret )
887850 etm4_release_trace_id (drvdata );
888851
889- unlock_sysfs_enable :
890852 spin_unlock (& drvdata -> spinlock );
891853
892854 if (!ret )
@@ -895,7 +857,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev)
895857}
896858
897859static int etm4_enable (struct coresight_device * csdev , struct perf_event * event ,
898- enum cs_mode mode , struct coresight_trace_id_map * id_map )
860+ enum cs_mode mode , struct coresight_path * path )
899861{
900862 int ret ;
901863
@@ -906,10 +868,10 @@ static int etm4_enable(struct coresight_device *csdev, struct perf_event *event,
906868
907869 switch (mode ) {
908870 case CS_MODE_SYSFS :
909- ret = etm4_enable_sysfs (csdev );
871+ ret = etm4_enable_sysfs (csdev , path );
910872 break ;
911873 case CS_MODE_PERF :
912- ret = etm4_enable_perf (csdev , event , id_map );
874+ ret = etm4_enable_perf (csdev , event , path );
913875 break ;
914876 default :
915877 ret = - EINVAL ;
0 commit comments