Hi Xiang
On 07/01/2022 08:41, chenxiang wrote:
> From: Xiang Chen <chenxiang66(a)hisilicon.com>
>
> If not up all the cpus with command line "maxcpus=x", system will be
> blocked.
> We find that some amba devices such as ETM devices, are associated with
> special cpus, and if the cpu is not up, the register of associated device
> is not allowed to access. BIOS reports all the ETM device nodes and a
> amba device is created for every ETM device, so even if one cpu is not up,
> the amba device will still be created for the associated device, and also
> the register of device (pid and cid) will be accessed when adding amba
> device which will cause the issue.
> To fix it, skip creating amba device if it is associated with a cpu which
> is not online.
I understand the issue. We do not have an issue at least on DT based
platforms with a similar environment (Juno). The key is the power
management for the components.
There are two separate issues at play here :
1) Power management with ACPI. I believe there is a solution in progress
to address this.
2) The ETM is in the same power domain as that of the CPU and normal
device power management may not work without the CPU being online.
3) Additionally we have other issue of supporting system instructions
with ACPI, which do not appear on the AMBA bus.
Considering all of these, the ideal solution is to :
1) Implement power management for ACPI, which is anyway in progress
(at least for SCMI based systems)
2) Move the ETM driver away from the AMBA framework. That would make
the CPU online problem and the (3) above easier to solve.
Anshuman is going to look into this.
In the meantime, we could have this temporary fix in and solve it
forever by moving away from the AMBA.
>
> Signed-off-by: Xiang Chen <chenxiang66(a)hisilicon.com>
> ---
> drivers/acpi/acpi_amba.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c
> index ab8a4e0191b1..2369198f734b 100644
> --- a/drivers/acpi/acpi_amba.c
> +++ b/drivers/acpi/acpi_amba.c
> @@ -16,6 +16,7 @@
> #include <linux/ioport.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> +#include <acpi/processor.h>
>
> #include "internal.h"
>
> @@ -45,6 +46,35 @@ static void amba_register_dummy_clk(void)
> clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);
> }
>
> +static int acpi_handle_to_cpuid(acpi_handle handle)
> +{
> + int cpu = -1;
> + struct acpi_processor *pr;
> +
> + for_each_possible_cpu(cpu) {
> + pr = per_cpu(processors, cpu);
> + if (pr && pr->handle == handle)
> + break;
> + }
> +
> + return cpu;
> +}
> +
Please could we reuse the function in coresight-platform.c ?
i.e, move it to a generic location and share it, rather than
duplicating it ?
> +static int acpi_dev_get_cpu(struct acpi_device *adev)
> +{
> + acpi_handle cpu_handle;
> + acpi_status status;
> + int cpu;
> +
> + status = acpi_get_parent(adev->handle, &cpu_handle);
> + if (ACPI_FAILURE(status))
> + return -1;
> + cpu = acpi_handle_to_cpuid(cpu_handle);
> + if (cpu >= nr_cpu_ids)
> + return -1;
> + return cpu;
> +}
> +
> static int amba_handler_attach(struct acpi_device *adev,
> const struct acpi_device_id *id)
> {
> @@ -54,11 +84,17 @@ static int amba_handler_attach(struct acpi_device *adev,
> bool address_found = false;
> int irq_no = 0;
> int ret;
> + int cpu;
>
> /* If the ACPI node already has a physical device attached, skip it. */
> if (adev->physical_node_count)
> return 0;
>
> + /* If the cpu associated with the device is not online, skip it. */
> + cpu = acpi_dev_get_cpu(adev);
> + if (cpu >= 0 && !cpu_online(cpu))
> + return 0;
> +
Except for the comment above, the patch looks good to me.
Suzuki
Hi Cheng,
I am severely behind in my patch review process and as such will not
be able to start reviewing your work before the week of February 7th.
Thanks,
Mathieu
On Fri, 7 Jan 2022 at 01:47, chenxiang <chenxiang66(a)hisilicon.com> wrote:
>
> From: Xiang Chen <chenxiang66(a)hisilicon.com>
>
> If not up all the cpus with command line "maxcpus=x", system will be
> blocked.
> We find that some amba devices such as ETM devices, are associated with
> special cpus, and if the cpu is not up, the register of associated device
> is not allowed to access. BIOS reports all the ETM device nodes and a
> amba device is created for every ETM device, so even if one cpu is not up,
> the amba device will still be created for the associated device, and also
> the register of device (pid and cid) will be accessed when adding amba
> device which will cause the issue.
> To fix it, skip creating amba device if it is associated with a cpu which
> is not online.
>
> Signed-off-by: Xiang Chen <chenxiang66(a)hisilicon.com>
> ---
> drivers/acpi/acpi_amba.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c
> index ab8a4e0191b1..2369198f734b 100644
> --- a/drivers/acpi/acpi_amba.c
> +++ b/drivers/acpi/acpi_amba.c
> @@ -16,6 +16,7 @@
> #include <linux/ioport.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> +#include <acpi/processor.h>
>
> #include "internal.h"
>
> @@ -45,6 +46,35 @@ static void amba_register_dummy_clk(void)
> clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);
> }
>
> +static int acpi_handle_to_cpuid(acpi_handle handle)
> +{
> + int cpu = -1;
> + struct acpi_processor *pr;
> +
> + for_each_possible_cpu(cpu) {
> + pr = per_cpu(processors, cpu);
> + if (pr && pr->handle == handle)
> + break;
> + }
> +
> + return cpu;
> +}
> +
> +static int acpi_dev_get_cpu(struct acpi_device *adev)
> +{
> + acpi_handle cpu_handle;
> + acpi_status status;
> + int cpu;
> +
> + status = acpi_get_parent(adev->handle, &cpu_handle);
> + if (ACPI_FAILURE(status))
> + return -1;
> + cpu = acpi_handle_to_cpuid(cpu_handle);
> + if (cpu >= nr_cpu_ids)
> + return -1;
> + return cpu;
> +}
> +
> static int amba_handler_attach(struct acpi_device *adev,
> const struct acpi_device_id *id)
> {
> @@ -54,11 +84,17 @@ static int amba_handler_attach(struct acpi_device *adev,
> bool address_found = false;
> int irq_no = 0;
> int ret;
> + int cpu;
>
> /* If the ACPI node already has a physical device attached, skip it. */
> if (adev->physical_node_count)
> return 0;
>
> + /* If the cpu associated with the device is not online, skip it. */
> + cpu = acpi_dev_get_cpu(adev);
> + if (cpu >= 0 && !cpu_online(cpu))
> + return 0;
> +
> dev = amba_device_alloc(dev_name(&adev->dev), 0, 0);
> if (!dev) {
> dev_err(&adev->dev, "%s(): amba_device_alloc() failed\n",
> --
> 2.33.0
>
On Tue, Jan 25, 2022 at 07:50:30PM +0530, Anshuman Khandual wrote:
> This series adds three different workarounds in the TRBE driver for
> Cortex-A510 specific erratas. But first, this adds Cortex-A510 specific cpu
> part number definition in the platform. This series applies on 5.17-rc1.
>
> Relevant errata documents can be found here.
>
> https://developer.arm.com/documentation/SDEN2397239/900
> https://developer.arm.com/documentation/SDEN2397589/900
>
> Changes in V3:
>
> https://lore.kernel.org/all/1641872346-3270-1-git-send-email-anshuman.khand…
>
> - Moved the comment inside trbe_needs_drain_after_disable()
> - Moved the comment inside trbe_needs_ctxt_sync_after_enable()
>
> Changes in V2:
>
> https://lore.kernel.org/all/1641517808-5735-1-git-send-email-anshuman.khand…
>
> Accommodated most review comments from the previous version.
>
> - Split all patches into CPU errata definition, detection and TRBE workarounds
> - s/TRBE_WORKAROUND_SYSREG_WRITE_FAILURE/TRBE_NEEDS_DRAIN_AFTER_DISABLE
> - s/TRBE_WORKAROUND_CORRUPTION_WITH_ENABLE/TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE
> - s/trbe_may_fail_sysreg_write()/trbe_needs_drain_after_disable()
> - s/trbe_may_corrupt_with_enable()/trbe_needs_ctxt_sync_after_enable()
> - Updated Kconfig help message for config ARM64_ERRATUM_1902691
> - Updated error message for trbe_is_broken() detection
> - Added new trblimitr parameter to set_trbe_enabled(), improving performance
> - Added COMPILE_TEST dependency in the errata, until TRBE part is available
>
> Changes in V1:
>
> https://lore.kernel.org/lkml/1641359159-22726-1-git-send-email-anshuman.kha…
>
> Cc: Catalin Marinas <catalin.marinas(a)arm.com>
> Cc: Will Deacon <will(a)kernel.org>
> Cc: Mathieu Poirier <mathieu.poirier(a)linaro.org>
> Cc: Suzuki Poulose <suzuki.poulose(a)arm.com>
> Cc: coresight(a)lists.linaro.org
> Cc: linux-doc(a)vger.kernel.org
> Cc: linux-arm-kernel(a)lists.infradead.org
> Cc: linux-kernel(a)vger.kernel.org
>
> Anshuman Khandual (7):
> arm64: Add Cortex-A510 CPU part definition
> arm64: errata: Add detection for TRBE ignored system register writes
> arm64: errata: Add detection for TRBE invalid prohibited states
> arm64: errata: Add detection for TRBE trace data corruption
> coresight: trbe: Work around the ignored system register writes
> coresight: trbe: Work around the invalid prohibited states
> coresight: trbe: Work around the trace data corruption
>
> Documentation/arm64/silicon-errata.rst | 6 +
> arch/arm64/Kconfig | 59 ++++++++++
> arch/arm64/include/asm/cputype.h | 2 +
> arch/arm64/kernel/cpu_errata.c | 27 +++++
> arch/arm64/tools/cpucaps | 3 +
> drivers/hwtracing/coresight/coresight-trbe.c | 114 ++++++++++++++-----
> drivers/hwtracing/coresight/coresight-trbe.h | 8 --
> 7 files changed, 183 insertions(+), 36 deletions(-)
I have applied this set and sent a pull request to Catalin for the arm64
portion.
Thanks,
Mathieu
>
> --
> 2.25.1
>
On 25/01/2022 03:21, Anshuman Khandual wrote:
>
>
> On 1/11/22 9:08 AM, Anshuman Khandual wrote:
>> This series adds three different workarounds in the TRBE driver for
>> Cortex-A510 specific erratas. But first, this adds Cortex-A510 specific cpu
>> part number definition in the platform. This series applies on 5.16.
>>
>> Relevant errata documents can be found here.
>>
>> https://developer.arm.com/documentation/SDEN2397239/900
>> https://developer.arm.com/documentation/SDEN2397589/900
>>
>> Changes in V3:
>>
>> - Moved the comment inside trbe_needs_drain_after_disable()
>> - Moved the comment inside trbe_needs_ctxt_sync_after_enable()
>>
>> Changes in V2:
>>
>> https://lore.kernel.org/all/1641517808-5735-1-git-send-email-anshuman.khand…
>>
>> Accommodated most review comments from the previous version.
>>
>> - Split all patches into CPU errata definition, detection and TRBE workarounds
>> - s/TRBE_WORKAROUND_SYSREG_WRITE_FAILURE/TRBE_NEEDS_DRAIN_AFTER_DISABLE
>> - s/TRBE_WORKAROUND_CORRUPTION_WITH_ENABLE/TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE
>> - s/trbe_may_fail_sysreg_write()/trbe_needs_drain_after_disable()
>> - s/trbe_may_corrupt_with_enable()/trbe_needs_ctxt_sync_after_enable()
>> - Updated Kconfig help message for config ARM64_ERRATUM_1902691
>> - Updated error message for trbe_is_broken() detection
>> - Added new trblimitr parameter to set_trbe_enabled(), improving performance
>> - Added COMPILE_TEST dependency in the errata, until TRBE part is available
>>
>> Changes in V1:
>>
>> https://lore.kernel.org/lkml/1641359159-22726-1-git-send-email-anshuman.kha…
>>
>> Cc: Catalin Marinas <catalin.marinas(a)arm.com>
>> Cc: Will Deacon <will(a)kernel.org>
>> Cc: Mathieu Poirier <mathieu.poirier(a)linaro.org>
>> Cc: Suzuki Poulose <suzuki.poulose(a)arm.com>
>> Cc: coresight(a)lists.linaro.org
>> Cc: linux-doc(a)vger.kernel.org
>> Cc: linux-arm-kernel(a)lists.infradead.org
>> Cc: linux-kernel(a)vger.kernel.org
>>
>> Anshuman Khandual (7):
>> arm64: Add Cortex-A510 CPU part definition
>> arm64: errata: Add detection for TRBE ignored system register writes
>> arm64: errata: Add detection for TRBE invalid prohibited states
>> arm64: errata: Add detection for TRBE trace data corruption
>> coresight: trbe: Work around the ignored system register writes
>> coresight: trbe: Work around the invalid prohibited states
>> coresight: trbe: Work around the trace data corruption
>
> Hello Catalin/Mathieu,
>
> I am wondering how this series is going to be merged i.e via arm64 or coresight
> tree ? Also will this require rebasing (and resend) against v5.17-rc1 release.
> Please do suggest. Thank you.
I would recommend rebasing on rc1.
Thanks
Suzuki
Hi Jay,
On Tue, Jan 25, 2022 at 10:33:45AM +0800, Jiankang Chen wrote:
> Hi Mathieu
>
> 在 2022/1/25 04:08, Mathieu Poirier 写道:
> > On Mon, 24 Jan 2022 at 04:00, Jay Chen <jkchen(a)linux.alibaba.com> wrote:
> > > Currently, there are 130 etr and etf on our machine,
> > > but the current coresight tmc driver uses misc_register
> > > to register the device, which leads to the error that
> > > the device number is not enough.
> > >
> > > coresight-tmc: probe of xxxxx failed with error -16
> > >
> > > This patch changes the device registration method
> > > to cdev's dynamic registration method to solve the
> > > problem of insufficient device numbers.
> > This patch is still not labelled properly and as such being dropped.
>
> Hello, about the label of this patch, what kind of patch should I add?
You could use "git format" command with option "-v" to add the version
number, e.g. if you are committing patch version 4, so you can generate
patch like:
$ git format-patch HEAD~1 -v4
Or if you want to generate patch for a specific commit:
$ git format-patch -1 patch_commit -v4
Every time when you generate a new version's patch, you could
increment the version number with option "-v4", "-v5", and so on.
P.s. I strongly suggest Marc Zyngier's great talk for how to upstream
kernel patch in a good way:
https://events19.linuxfoundation.org/wp-content/uploads/2017/12/Getting-You…
Thanks,
Leo
On 24/01/2022 03:15, Anshuman Khandual wrote:
> Errata ARM64_ERRATUM_[2119858|2224489] also affect some Cortex-X2 ranges as
> well. This series updates the errata definition and detection as required.
> This series applies on v5.17-rc1.
>
> Relevant identification document can be found here.
>
> https://developer.arm.com/documentation/101803/0200/AArch64-system-register…
> AArch64-identification-register-summary/MIDR-EL1--Main-ID-Register
>
> Relevant errata document can be found here.
>
> https://developer.arm.com/documentation/SDEN1775100
>
> Cc: Catalin Marinas <catalin.marinas(a)arm.com>
> Cc: Will Deacon <will(a)kernel.org>
> Cc: Mathieu Poirier <mathieu.poirier(a)linaro.org>
> Cc: Suzuki Poulose <suzuki.poulose(a)arm.com>
> Cc: coresight(a)lists.linaro.org
> Cc: linux-arm-kernel(a)lists.infradead.org
> Cc: linux-kernel(a)vger.kernel.org
>
For the series:
Reviewed-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>