Message ID | 20200722172040.1299289-5-suzuki.poulose@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | coresight: Support for ETMv4.4 system instructions | expand |
On Wed, Jul 22, 2020 at 06:20:30PM +0100, Suzuki K Poulose wrote: > etm4_init_arch_data is called early during the device probe, > even before the coresight_device is registered. Since we are > about to replace the direct access via abstraction layer, we > need a way to pass in the csdev_access for the given device. > Towards this free up the argument, which is already available > via etmdrvdata[smp_processor_id()]. > > Cc: Mathieu Poirier <mathieu.poirier@linaro.org> > Cc: Mike Leach <mike.leach@linaro.org> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > --- > drivers/hwtracing/coresight/coresight-etm4x.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c > index 7bb74c659c4f..67deb4a4e618 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x.c > @@ -614,7 +614,8 @@ static const struct coresight_ops etm4_cs_ops = { > .source_ops = &etm4_source_ops, > }; > > -static void etm4_init_arch_data(void *info) > + > +static void etm4_init_arch_data(void *__unused) > { > u32 etmidr0; > u32 etmidr1; > @@ -622,8 +623,14 @@ static void etm4_init_arch_data(void *info) > u32 etmidr3; > u32 etmidr4; > u32 etmidr5; > - struct etmv4_drvdata *drvdata = info; > - int i; > + struct etmv4_drvdata *drvdata; > + int i, cpu; > + > + cpu = raw_smp_processor_id(); Can you provide details on the motivation to use the raw_ version over the regular one? As far as I can see in linux/smp.h there is no difference between them unless DEBUB_PREEMPT is enabled. Even then the debug version won't complain since the task is CPU affined. > + drvdata = etmdrvdata[cpu]; > + > + if (WARN_ON(!etmdrvdata[cpu])) > + return; > > /* Make sure all registers are accessible */ > etm4_os_unlock(drvdata); > @@ -1517,7 +1524,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) > etmdrvdata[drvdata->cpu] = drvdata; > > if (smp_call_function_single(drvdata->cpu, > - etm4_init_arch_data, drvdata, 1)) > + etm4_init_arch_data, NULL, 1)) > dev_err(dev, "ETM arch init failed\n"); > > ret = etm4_pm_setup_cpuslocked(); > -- > 2.24.1 >
On 07/30/2020 06:31 PM, Mathieu Poirier wrote: > On Wed, Jul 22, 2020 at 06:20:30PM +0100, Suzuki K Poulose wrote: >> etm4_init_arch_data is called early during the device probe, >> even before the coresight_device is registered. Since we are >> about to replace the direct access via abstraction layer, we >> need a way to pass in the csdev_access for the given device. >> Towards this free up the argument, which is already available >> via etmdrvdata[smp_processor_id()]. >> >> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> >> Cc: Mike Leach <mike.leach@linaro.org> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> --- >> drivers/hwtracing/coresight/coresight-etm4x.c | 15 +++++++++++---- >> 1 file changed, 11 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c >> index 7bb74c659c4f..67deb4a4e618 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x.c >> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c >> @@ -614,7 +614,8 @@ static const struct coresight_ops etm4_cs_ops = { >> .source_ops = &etm4_source_ops, >> }; >> >> -static void etm4_init_arch_data(void *info) >> + >> +static void etm4_init_arch_data(void *__unused) >> { >> u32 etmidr0; >> u32 etmidr1; >> @@ -622,8 +623,14 @@ static void etm4_init_arch_data(void *info) >> u32 etmidr3; >> u32 etmidr4; >> u32 etmidr5; >> - struct etmv4_drvdata *drvdata = info; >> - int i; >> + struct etmv4_drvdata *drvdata; >> + int i, cpu; >> + >> + cpu = raw_smp_processor_id(); > > Can you provide details on the motivation to use the raw_ version over the regular > one? As far as I can see in linux/smp.h there is no difference between them > unless DEBUB_PREEMPT is enabled. Even then the debug version won't complain > since the task is CPU affined. > Right, it is partly my misunderstanding. debug_smp_processor_id() is to detect cases where smp_processor_id() is called in pre-emptible contexts. This is not the case here. So it is fine to use the smp_processor_id(). I will switch to that in the next version. Thanks Suzuki
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 7bb74c659c4f..67deb4a4e618 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -614,7 +614,8 @@ static const struct coresight_ops etm4_cs_ops = { .source_ops = &etm4_source_ops, }; -static void etm4_init_arch_data(void *info) + +static void etm4_init_arch_data(void *__unused) { u32 etmidr0; u32 etmidr1; @@ -622,8 +623,14 @@ static void etm4_init_arch_data(void *info) u32 etmidr3; u32 etmidr4; u32 etmidr5; - struct etmv4_drvdata *drvdata = info; - int i; + struct etmv4_drvdata *drvdata; + int i, cpu; + + cpu = raw_smp_processor_id(); + drvdata = etmdrvdata[cpu]; + + if (WARN_ON(!etmdrvdata[cpu])) + return; /* Make sure all registers are accessible */ etm4_os_unlock(drvdata); @@ -1517,7 +1524,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) etmdrvdata[drvdata->cpu] = drvdata; if (smp_call_function_single(drvdata->cpu, - etm4_init_arch_data, drvdata, 1)) + etm4_init_arch_data, NULL, 1)) dev_err(dev, "ETM arch init failed\n"); ret = etm4_pm_setup_cpuslocked();
etm4_init_arch_data is called early during the device probe, even before the coresight_device is registered. Since we are about to replace the direct access via abstraction layer, we need a way to pass in the csdev_access for the given device. Towards this free up the argument, which is already available via etmdrvdata[smp_processor_id()]. Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- drivers/hwtracing/coresight/coresight-etm4x.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)