diff options
author | Hanjun Guo <hanjun.guo@linaro.org> | 2017-07-26 06:15:49 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2017-08-10 11:22:50 -0400 |
commit | fdf6e7a8c96ebe115b6460768c82dd136ecbd8db (patch) | |
tree | 6721ee2b8e99796086f126c0cc95fe8dfa495ada | |
parent | c017d21147848fe017772764a77a7f32c5b017f9 (diff) |
irqchip/gic-v3-its: Allow GIC ITS number more than MAX_NUMNODES
When enabling ITS NUMA support on D05, I got the boot log:
[ 0.000000] SRAT: PXM 0 -> ITS 0 -> Node 0
[ 0.000000] SRAT: PXM 0 -> ITS 1 -> Node 0
[ 0.000000] SRAT: PXM 0 -> ITS 2 -> Node 0
[ 0.000000] SRAT: PXM 1 -> ITS 3 -> Node 1
[ 0.000000] SRAT: ITS affinity exceeding max count[4]
This is wrong on D05 as we have 8 ITSs with 4 NUMA nodes.
So dynamically alloc the memory needed instead of using
its_srat_maps[MAX_NUMNODES], which count the number of
ITS entry(ies) in SRAT and alloc its_srat_maps as needed,
then build the mapping of numa node to ITS ID. Of course,
its_srat_maps will be freed after ITS probing because
we don't need that after boot.
After doing this, I got what I wanted:
[ 0.000000] SRAT: PXM 0 -> ITS 0 -> Node 0
[ 0.000000] SRAT: PXM 0 -> ITS 1 -> Node 0
[ 0.000000] SRAT: PXM 0 -> ITS 2 -> Node 0
[ 0.000000] SRAT: PXM 1 -> ITS 3 -> Node 1
[ 0.000000] SRAT: PXM 2 -> ITS 4 -> Node 2
[ 0.000000] SRAT: PXM 2 -> ITS 5 -> Node 2
[ 0.000000] SRAT: PXM 2 -> ITS 6 -> Node 2
[ 0.000000] SRAT: PXM 3 -> ITS 7 -> Node 3
Fixes: dbd2b8267233 ("irqchip/gic-v3-its: Add ACPI NUMA node mapping")
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | drivers/irqchip/irq-gic-v3-its.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 3bfbf8d96a0e..5fd5f62c925d 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
@@ -1843,7 +1843,7 @@ struct its_srat_map { | |||
1843 | u32 its_id; | 1843 | u32 its_id; |
1844 | }; | 1844 | }; |
1845 | 1845 | ||
1846 | static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata; | 1846 | static struct its_srat_map *its_srat_maps __initdata; |
1847 | static int its_in_srat __initdata; | 1847 | static int its_in_srat __initdata; |
1848 | 1848 | ||
1849 | static int __init acpi_get_its_numa_node(u32 its_id) | 1849 | static int __init acpi_get_its_numa_node(u32 its_id) |
@@ -1857,6 +1857,12 @@ static int __init acpi_get_its_numa_node(u32 its_id) | |||
1857 | return NUMA_NO_NODE; | 1857 | return NUMA_NO_NODE; |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header, | ||
1861 | const unsigned long end) | ||
1862 | { | ||
1863 | return 0; | ||
1864 | } | ||
1865 | |||
1860 | static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | 1866 | static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, |
1861 | const unsigned long end) | 1867 | const unsigned long end) |
1862 | { | 1868 | { |
@@ -1873,12 +1879,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | |||
1873 | return -EINVAL; | 1879 | return -EINVAL; |
1874 | } | 1880 | } |
1875 | 1881 | ||
1876 | if (its_in_srat >= MAX_NUMNODES) { | ||
1877 | pr_err("SRAT: ITS affinity exceeding max count[%d]\n", | ||
1878 | MAX_NUMNODES); | ||
1879 | return -EINVAL; | ||
1880 | } | ||
1881 | |||
1882 | node = acpi_map_pxm_to_node(its_affinity->proximity_domain); | 1882 | node = acpi_map_pxm_to_node(its_affinity->proximity_domain); |
1883 | 1883 | ||
1884 | if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { | 1884 | if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { |
@@ -1897,14 +1897,37 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, | |||
1897 | 1897 | ||
1898 | static void __init acpi_table_parse_srat_its(void) | 1898 | static void __init acpi_table_parse_srat_its(void) |
1899 | { | 1899 | { |
1900 | int count; | ||
1901 | |||
1902 | count = acpi_table_parse_entries(ACPI_SIG_SRAT, | ||
1903 | sizeof(struct acpi_table_srat), | ||
1904 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, | ||
1905 | gic_acpi_match_srat_its, 0); | ||
1906 | if (count <= 0) | ||
1907 | return; | ||
1908 | |||
1909 | its_srat_maps = kmalloc(count * sizeof(struct its_srat_map), | ||
1910 | GFP_KERNEL); | ||
1911 | if (!its_srat_maps) { | ||
1912 | pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n"); | ||
1913 | return; | ||
1914 | } | ||
1915 | |||
1900 | acpi_table_parse_entries(ACPI_SIG_SRAT, | 1916 | acpi_table_parse_entries(ACPI_SIG_SRAT, |
1901 | sizeof(struct acpi_table_srat), | 1917 | sizeof(struct acpi_table_srat), |
1902 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, | 1918 | ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, |
1903 | gic_acpi_parse_srat_its, 0); | 1919 | gic_acpi_parse_srat_its, 0); |
1904 | } | 1920 | } |
1921 | |||
1922 | /* free the its_srat_maps after ITS probing */ | ||
1923 | static void __init acpi_its_srat_maps_free(void) | ||
1924 | { | ||
1925 | kfree(its_srat_maps); | ||
1926 | } | ||
1905 | #else | 1927 | #else |
1906 | static void __init acpi_table_parse_srat_its(void) { } | 1928 | static void __init acpi_table_parse_srat_its(void) { } |
1907 | static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } | 1929 | static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } |
1930 | static void __init acpi_its_srat_maps_free(void) { } | ||
1908 | #endif | 1931 | #endif |
1909 | 1932 | ||
1910 | static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, | 1933 | static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, |
@@ -1951,6 +1974,7 @@ static void __init its_acpi_probe(void) | |||
1951 | acpi_table_parse_srat_its(); | 1974 | acpi_table_parse_srat_its(); |
1952 | acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, | 1975 | acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, |
1953 | gic_acpi_parse_madt_its, 0); | 1976 | gic_acpi_parse_madt_its, 0); |
1977 | acpi_its_srat_maps_free(); | ||
1954 | } | 1978 | } |
1955 | #else | 1979 | #else |
1956 | static void __init its_acpi_probe(void) { } | 1980 | static void __init its_acpi_probe(void) { } |