]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
coresight: catu: Fix number of pages while using 64k pages
authorIlkka Koskinen <ilkka@os.amperecomputing.com>
Thu, 9 Jan 2025 21:53:48 +0000 (21:53 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Fri, 21 Feb 2025 16:08:18 +0000 (16:08 +0000)
Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
This happens due to a bug in calculating the number of table pages, which
returns zero. Fix the issue by rounding up.

$ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
failed to mmap with 12 (Cannot allocate memory)

Fixes: 8ed536b1e283 ("coresight: catu: Add support for scatter gather tables")
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20250109215348.5483-1-ilkka@os.amperecomputing.com
drivers/hwtracing/coresight/coresight-catu.c

index 275cc0d9f505fb0c1b2847da94fdfd468c49c6c4..3378bb77e6b41d288e349ad4961891de34c5479a 100644 (file)
@@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int node,
         * Each table can address upto 1MB and we can have
         * CATU_PAGES_PER_SYSPAGE tables in a system page.
         */
-       nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
+       nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
        catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
                                        size >> PAGE_SHIFT, pages);
        if (IS_ERR(catu_table))