From 2a510b496362a87d2220eb19b9910f9b38a745f1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 21 Jan 2025 18:10:36 +0100 Subject: [PATCH] delete some of patches from 5.10 as they break the build --- ...s-add-support-for-3-address-cell-bus.patch | 189 ----------------- ...ddress-translation-when-address-size.patch | 129 ------------ ...rve-the-flags-portion-on-1-1-dma-ran.patch | 50 ----- ...-address-remove-duplicated-functions.patch | 72 ------- ...-number-of-bus-flag-cells-rather-tha.patch | 85 -------- ...ddress-use-is_enabled-for-config_pci.patch | 129 ------------ ...address-and-of_get_pci_address-imple.patch | 193 ------------------ ...-add-bus-address-range-parsing-tests.patch | 96 --------- queue-5.10/series | 8 - 9 files changed, 951 deletions(-) delete mode 100644 queue-5.10/of-address-add-support-for-3-address-cell-bus.patch delete mode 100644 queue-5.10/of-address-fix-address-translation-when-address-size.patch delete mode 100644 queue-5.10/of-address-preserve-the-flags-portion-on-1-1-dma-ran.patch delete mode 100644 queue-5.10/of-address-remove-duplicated-functions.patch delete mode 100644 queue-5.10/of-address-store-number-of-bus-flag-cells-rather-tha.patch delete mode 100644 queue-5.10/of-address-use-is_enabled-for-config_pci.patch delete mode 100644 queue-5.10/of-merge-of_get_address-and-of_get_pci_address-imple.patch delete mode 100644 queue-5.10/of-unittest-add-bus-address-range-parsing-tests.patch diff --git a/queue-5.10/of-address-add-support-for-3-address-cell-bus.patch b/queue-5.10/of-address-add-support-for-3-address-cell-bus.patch deleted file mode 100644 index 6941c6f52fc..00000000000 --- a/queue-5.10/of-address-add-support-for-3-address-cell-bus.patch +++ /dev/null @@ -1,189 +0,0 @@ -From 700240b95c9636d364dbc31d7ceb5adeedadc860 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Tue, 28 Mar 2023 15:15:58 -0500 -Subject: of/address: Add support for 3 address cell bus - -From: Rob Herring - -[ Upstream commit 3d5089c4263d3594dc055e0f9c5cb990505cdd64 ] - -There's a few custom bus bindings (e.g. fsl,qoriq-mc) which use a -3 cell format with custom flags in the high cell. We can match these -buses as a fallback if we didn't match on PCI bus which is the only -standard bus binding with 3 address cells. - -Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-3-e2456c3e77ab@kernel.org -Signed-off-by: Rob Herring -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 22 ++++++++ - drivers/of/unittest-data/tests-address.dtsi | 9 +++- - drivers/of/unittest.c | 58 ++++++++++++++++++++- - 3 files changed, 87 insertions(+), 2 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 068a134f6df7..2aebce8f4a76 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -97,11 +97,17 @@ static int of_bus_default_translate(__be32 *addr, u64 offset, int na) - return 0; - } - -+static unsigned int of_bus_default_flags_get_flags(const __be32 *addr) -+{ -+ return of_read_number(addr, 1); -+} -+ - static unsigned int of_bus_default_get_flags(const __be32 *addr) - { - return IORESOURCE_MEM; - } - -+ - #ifdef CONFIG_PCI - static unsigned int of_bus_pci_get_flags(const __be32 *addr) - { -@@ -328,6 +334,11 @@ static unsigned int of_bus_isa_get_flags(const __be32 *addr) - return flags; - } - -+static int of_bus_default_flags_match(struct device_node *np) -+{ -+ return of_bus_n_addr_cells(np) == 3; -+} -+ - /* - * Array of bus specific translators - */ -@@ -357,6 +368,17 @@ static struct of_bus of_busses[] = { - .has_flags = true, - .get_flags = of_bus_isa_get_flags, - }, -+ /* Default with flags cell */ -+ { -+ .name = "default-flags", -+ .addresses = "reg", -+ .match = of_bus_default_flags_match, -+ .count_cells = of_bus_default_count_cells, -+ .map = of_bus_default_map, -+ .translate = of_bus_default_translate, -+ .has_flags = true, -+ .get_flags = of_bus_default_flags_get_flags, -+ }, - /* Default */ - { - .name = "default", -diff --git a/drivers/of/unittest-data/tests-address.dtsi b/drivers/of/unittest-data/tests-address.dtsi -index 6604a52bf6cb..bc0029cbf8ea 100644 ---- a/drivers/of/unittest-data/tests-address.dtsi -+++ b/drivers/of/unittest-data/tests-address.dtsi -@@ -14,7 +14,7 @@ - #size-cells = <1>; - /* ranges here is to make sure we don't use it for - * dma-ranges translation */ -- ranges = <0x70000000 0x70000000 0x40000000>, -+ ranges = <0x70000000 0x70000000 0x50000000>, - <0x00000000 0xd0000000 0x20000000>; - dma-ranges = <0x0 0x20000000 0x40000000>; - -@@ -43,6 +43,13 @@ - <0x42000000 0x0 0xc0000000 0x20000000 0x0 0x10000000>; - }; - -+ bus@a0000000 { -+ #address-cells = <3>; -+ #size-cells = <2>; -+ ranges = <0xf00baa 0x0 0x0 0xa0000000 0x0 0x100000>, -+ <0xf00bee 0x1 0x0 0xb0000000 0x0 0x200000>; -+ }; -+ - }; - }; - }; -diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c -index cb199ace8681..1659d4dceded 100644 ---- a/drivers/of/unittest.c -+++ b/drivers/of/unittest.c -@@ -1044,7 +1044,7 @@ static void __init of_unittest_bus_ranges(void) - "for_each_of_range wrong flags on node %pOF flags=%x (expected %x)\n", - np, range.flags, IORESOURCE_MEM); - if (!i) { -- unittest(range.size == 0x40000000, -+ unittest(range.size == 0x50000000, - "for_each_of_range wrong size on node %pOF size=%llx\n", - np, range.size); - unittest(range.cpu_addr == 0x70000000, -@@ -1070,6 +1070,61 @@ static void __init of_unittest_bus_ranges(void) - of_node_put(np); - } - -+static void __init of_unittest_bus_3cell_ranges(void) -+{ -+ struct device_node *np; -+ struct of_range range; -+ struct of_range_parser parser; -+ int i = 0; -+ -+ np = of_find_node_by_path("/testcase-data/address-tests/bus@a0000000"); -+ if (!np) { -+ pr_err("missing testcase data\n"); -+ return; -+ } -+ -+ if (of_range_parser_init(&parser, np)) { -+ pr_err("missing ranges property\n"); -+ return; -+ } -+ -+ /* -+ * Get the "ranges" from the device tree -+ */ -+ for_each_of_range(&parser, &range) { -+ if (!i) { -+ unittest(range.flags == 0xf00baa, -+ "for_each_of_range wrong flags on node %pOF flags=%x\n", -+ np, range.flags); -+ unittest(range.size == 0x100000, -+ "for_each_of_range wrong size on node %pOF size=%llx\n", -+ np, range.size); -+ unittest(range.cpu_addr == 0xa0000000, -+ "for_each_of_range wrong CPU addr (%llx) on node %pOF", -+ range.cpu_addr, np); -+ unittest(range.bus_addr == 0x0, -+ "for_each_of_range wrong bus addr (%llx) on node %pOF", -+ range.pci_addr, np); -+ } else { -+ unittest(range.flags == 0xf00bee, -+ "for_each_of_range wrong flags on node %pOF flags=%x\n", -+ np, range.flags); -+ unittest(range.size == 0x200000, -+ "for_each_of_range wrong size on node %pOF size=%llx\n", -+ np, range.size); -+ unittest(range.cpu_addr == 0xb0000000, -+ "for_each_of_range wrong CPU addr (%llx) on node %pOF", -+ range.cpu_addr, np); -+ unittest(range.bus_addr == 0x100000000, -+ "for_each_of_range wrong bus addr (%llx) on node %pOF", -+ range.pci_addr, np); -+ } -+ i++; -+ } -+ -+ of_node_put(np); -+} -+ - static void __init of_unittest_parse_interrupts(void) - { - struct device_node *np; -@@ -3371,6 +3426,7 @@ static int __init of_unittest(void) - of_unittest_parse_dma_ranges(); - of_unittest_pci_dma_ranges(); - of_unittest_bus_ranges(); -+ of_unittest_bus_3cell_ranges(); - of_unittest_match_node(); - of_unittest_platform_populate(); - of_unittest_overlay(); --- -2.39.5 - diff --git a/queue-5.10/of-address-fix-address-translation-when-address-size.patch b/queue-5.10/of-address-fix-address-translation-when-address-size.patch deleted file mode 100644 index 15788f64c53..00000000000 --- a/queue-5.10/of-address-fix-address-translation-when-address-size.patch +++ /dev/null @@ -1,129 +0,0 @@ -From d3faf872f43180dfb978054e0c48e19a47708f8b Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Tue, 17 Oct 2023 13:02:16 +0200 -Subject: of: address: Fix address translation when address-size is greater - than 2 - -From: Herve Codina - -[ Upstream commit 42604f8eb7ba04b589375049cc76282dad4677d2 ] - -With the recent addition of of_pci_prop_ranges() in commit 407d1a51921e -("PCI: Create device tree node for bridge"), the ranges property can -have a 3 cells child address, a 3 cells parent address and a 2 cells -child size. - -A range item property for a PCI device is filled as follow: - 0 0 - <-- Child --> <-- Parent (PCI definition) --> <- BAR size (64bit) --> - -This allow to translate BAR addresses from the DT. For instance: -pci@0,0 { - #address-cells = <0x03>; - #size-cells = <0x02>; - device_type = "pci"; - compatible = "pci11ab,100", "pciclass,060400", "pciclass,0604"; - ranges = <0x82000000 0x00 0xe8000000 - 0x82000000 0x00 0xe8000000 - 0x00 0x4400000>; - ... - dev@0,0 { - #address-cells = <0x03>; - #size-cells = <0x02>; - compatible = "pci1055,9660", "pciclass,020000", "pciclass,0200"; - /* Translations for BAR0 to BAR5 */ - ranges = <0x00 0x00 0x00 0x82010000 0x00 0xe8000000 0x00 0x2000000 - 0x01 0x00 0x00 0x82010000 0x00 0xea000000 0x00 0x1000000 - 0x02 0x00 0x00 0x82010000 0x00 0xeb000000 0x00 0x800000 - 0x03 0x00 0x00 0x82010000 0x00 0xeb800000 0x00 0x800000 - 0x04 0x00 0x00 0x82010000 0x00 0xec000000 0x00 0x20000 - 0x05 0x00 0x00 0x82010000 0x00 0xec020000 0x00 0x2000>; - ... - pci-ep-bus@0 { - #address-cells = <0x01>; - #size-cells = <0x01>; - compatible = "simple-bus"; - /* Translate 0xe2000000 to BAR0 and 0xe0000000 to BAR1 */ - ranges = <0xe2000000 0x00 0x00 0x00 0x2000000 - 0xe0000000 0x01 0x00 0x00 0x1000000>; - ... - }; - }; -}; - -During the translation process, the "default-flags" map() function is -used to select the matching item in the ranges table and determine the -address offset from this matching item. -This map() function simply calls of_read_number() and when address-size -is greater than 2, the map() function skips the extra high address part -(ie part over 64bit). This lead to a wrong matching item and a wrong -offset computation. -Also during the translation itself, the extra high part related to the -parent address is not present in the translated address. - -Fix the "default-flags" map() and translate() in order to take into -account the child extra high address part in map() and the parent extra -high address part in translate() and so having a correct address -translation for ranges patterns such as the one given in the example -above. - -Signed-off-by: Herve Codina -Link: https://lore.kernel.org/r/20231017110221.189299-2-herve.codina@bootlin.com -Signed-off-by: Rob Herring -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 30 ++++++++++++++++++++++++++++-- - 1 file changed, 28 insertions(+), 2 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 2aebce8f4a76..f1c4f987ef95 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -107,6 +107,32 @@ static unsigned int of_bus_default_get_flags(const __be32 *addr) - return IORESOURCE_MEM; - } - -+static u64 of_bus_default_flags_map(__be32 *addr, const __be32 *range, int na, -+ int ns, int pna) -+{ -+ u64 cp, s, da; -+ -+ /* Check that flags match */ -+ if (*addr != *range) -+ return OF_BAD_ADDR; -+ -+ /* Read address values, skipping high cell */ -+ cp = of_read_number(range + 1, na - 1); -+ s = of_read_number(range + na + pna, ns); -+ da = of_read_number(addr + 1, na - 1); -+ -+ pr_debug("default flags map, cp=%llx, s=%llx, da=%llx\n", cp, s, da); -+ -+ if (da < cp || da >= (cp + s)) -+ return OF_BAD_ADDR; -+ return da - cp; -+} -+ -+static int of_bus_default_flags_translate(__be32 *addr, u64 offset, int na) -+{ -+ /* Keep "flags" part (high cell) in translated address */ -+ return of_bus_default_translate(addr + 1, offset, na - 1); -+} - - #ifdef CONFIG_PCI - static unsigned int of_bus_pci_get_flags(const __be32 *addr) -@@ -374,8 +400,8 @@ static struct of_bus of_busses[] = { - .addresses = "reg", - .match = of_bus_default_flags_match, - .count_cells = of_bus_default_count_cells, -- .map = of_bus_default_map, -- .translate = of_bus_default_translate, -+ .map = of_bus_default_flags_map, -+ .translate = of_bus_default_flags_translate, - .has_flags = true, - .get_flags = of_bus_default_flags_get_flags, - }, --- -2.39.5 - diff --git a/queue-5.10/of-address-preserve-the-flags-portion-on-1-1-dma-ran.patch b/queue-5.10/of-address-preserve-the-flags-portion-on-1-1-dma-ran.patch deleted file mode 100644 index bf5c2fbb2aa..00000000000 --- a/queue-5.10/of-address-preserve-the-flags-portion-on-1-1-dma-ran.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 390a61201e9816ab7f3b6191a6d9efe5f1158166 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Sun, 24 Nov 2024 11:05:37 +0100 -Subject: of: address: Preserve the flags portion on 1:1 dma-ranges mapping - -From: Andrea della Porta - -[ Upstream commit 7f05e20b989ac33c9c0f8c2028ec0a566493548f ] - -A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma -translations. In this specific case, the current behaviour is to zero out -the entire specifier so that the translation could be carried on as an -offset from zero. This includes address specifier that has flags (e.g. -PCI ranges). - -Once the flags portion has been zeroed, the translation chain is broken -since the mapping functions will check the upcoming address specifier -against mismatching flags, always failing the 1:1 mapping and its entire -purpose of always succeeding. - -Set to zero only the address portion while passing the flags through. - -Fixes: dbbdee94734b ("of/address: Merge all of the bus translation code") -Cc: stable@vger.kernel.org -Signed-off-by: Andrea della Porta -Tested-by: Herve Codina -Link: https://lore.kernel.org/r/e51ae57874e58a9b349c35e2e877425ebc075d7a.1732441813.git.andrea.porta@suse.com -Signed-off-by: Rob Herring (Arm) -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 2bbbc4f5e196..d995033fb661 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -475,7 +475,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, - } - if (ranges == NULL || rlen == 0) { - offset = of_read_number(addr, na); -- memset(addr, 0, pna * 4); -+ /* set address to zero, pass flags through */ -+ memset(addr + pbus->flag_cells, 0, (pna - pbus->flag_cells) * 4); - pr_debug("empty ranges; 1:1 translation\n"); - goto finish; - } --- -2.39.5 - diff --git a/queue-5.10/of-address-remove-duplicated-functions.patch b/queue-5.10/of-address-remove-duplicated-functions.patch deleted file mode 100644 index 66045b2337a..00000000000 --- a/queue-5.10/of-address-remove-duplicated-functions.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 81e795c7ebfcf01f32c0f7bf1dfd8e23ba390ae9 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Tue, 17 Oct 2023 13:02:17 +0200 -Subject: of: address: Remove duplicated functions - -From: Herve Codina - -[ Upstream commit 3eb030c60835668997d5763b1a0c7938faf169f6 ] - -The recently added of_bus_default_flags_translate() performs the exact -same operation as of_bus_pci_translate() and of_bus_isa_translate(). - -Avoid duplicated code replacing both of_bus_pci_translate() and -of_bus_isa_translate() with of_bus_default_flags_translate(). - -Signed-off-by: Herve Codina -Link: https://lore.kernel.org/r/20231017110221.189299-3-herve.codina@bootlin.com -Signed-off-by: Rob Herring -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 13 ++----------- - 1 file changed, 2 insertions(+), 11 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index f1c4f987ef95..6b03adec12a7 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -222,10 +222,6 @@ static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int na, int ns, - return da - cp; - } - --static int of_bus_pci_translate(__be32 *addr, u64 offset, int na) --{ -- return of_bus_default_translate(addr + 1, offset, na - 1); --} - #endif /* CONFIG_PCI */ - - int of_pci_address_to_resource(struct device_node *dev, int bar, -@@ -343,11 +339,6 @@ static u64 of_bus_isa_map(__be32 *addr, const __be32 *range, int na, int ns, - return da - cp; - } - --static int of_bus_isa_translate(__be32 *addr, u64 offset, int na) --{ -- return of_bus_default_translate(addr + 1, offset, na - 1); --} -- - static unsigned int of_bus_isa_get_flags(const __be32 *addr) - { - unsigned int flags = 0; -@@ -378,7 +369,7 @@ static struct of_bus of_busses[] = { - .match = of_bus_pci_match, - .count_cells = of_bus_pci_count_cells, - .map = of_bus_pci_map, -- .translate = of_bus_pci_translate, -+ .translate = of_bus_default_flags_translate, - .has_flags = true, - .get_flags = of_bus_pci_get_flags, - }, -@@ -390,7 +381,7 @@ static struct of_bus of_busses[] = { - .match = of_bus_isa_match, - .count_cells = of_bus_isa_count_cells, - .map = of_bus_isa_map, -- .translate = of_bus_isa_translate, -+ .translate = of_bus_default_flags_translate, - .has_flags = true, - .get_flags = of_bus_isa_get_flags, - }, --- -2.39.5 - diff --git a/queue-5.10/of-address-store-number-of-bus-flag-cells-rather-tha.patch b/queue-5.10/of-address-store-number-of-bus-flag-cells-rather-tha.patch deleted file mode 100644 index fa49b024c61..00000000000 --- a/queue-5.10/of-address-store-number-of-bus-flag-cells-rather-tha.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 6d2a462f7524d46f03edd94dcc037d6ba436b576 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 26 Oct 2023 08:53:58 -0500 -Subject: of: address: Store number of bus flag cells rather than bool - -From: Rob Herring - -[ Upstream commit 88696db08b7efa3b6bb722014ea7429e78f6be32 ] - -It is more useful to know how many flags cells a bus has rather than -whether a bus has flags or not as ultimately the number of cells is the -information used. Replace 'has_flags' boolean with 'flag_cells' count. - -Acked-by: Herve Codina -Link: https://lore.kernel.org/r/20231026135358.3564307-2-robh@kernel.org -Signed-off-by: Rob Herring -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 14 +++++--------- - 1 file changed, 5 insertions(+), 9 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 6b03adec12a7..2bbbc4f5e196 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -50,7 +50,7 @@ struct of_bus { - u64 (*map)(__be32 *addr, const __be32 *range, - int na, int ns, int pna); - int (*translate)(__be32 *addr, u64 offset, int na); -- bool has_flags; -+ int flag_cells; - unsigned int (*get_flags)(const __be32 *addr); - }; - -@@ -370,7 +370,7 @@ static struct of_bus of_busses[] = { - .count_cells = of_bus_pci_count_cells, - .map = of_bus_pci_map, - .translate = of_bus_default_flags_translate, -- .has_flags = true, -+ .flag_cells = 1, - .get_flags = of_bus_pci_get_flags, - }, - #endif /* CONFIG_PCI */ -@@ -382,7 +382,7 @@ static struct of_bus of_busses[] = { - .count_cells = of_bus_isa_count_cells, - .map = of_bus_isa_map, - .translate = of_bus_default_flags_translate, -- .has_flags = true, -+ .flag_cells = 1, - .get_flags = of_bus_isa_get_flags, - }, - /* Default with flags cell */ -@@ -393,7 +393,7 @@ static struct of_bus of_busses[] = { - .count_cells = of_bus_default_count_cells, - .map = of_bus_default_flags_map, - .translate = of_bus_default_flags_translate, -- .has_flags = true, -+ .flag_cells = 1, - .get_flags = of_bus_default_flags_get_flags, - }, - /* Default */ -@@ -760,7 +760,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, - int na = parser->na; - int ns = parser->ns; - int np = parser->pna + na + ns; -- int busflag_na = 0; -+ int busflag_na = parser->bus->flag_cells; - - if (!range) - return NULL; -@@ -770,10 +770,6 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, - - range->flags = parser->bus->get_flags(parser->range); - -- /* A extra cell for resource flags */ -- if (parser->bus->has_flags) -- busflag_na = 1; -- - range->bus_addr = of_read_number(parser->range + busflag_na, na - busflag_na); - - if (parser->dma) --- -2.39.5 - diff --git a/queue-5.10/of-address-use-is_enabled-for-config_pci.patch b/queue-5.10/of-address-use-is_enabled-for-config_pci.patch deleted file mode 100644 index cfafb83acef..00000000000 --- a/queue-5.10/of-address-use-is_enabled-for-config_pci.patch +++ /dev/null @@ -1,129 +0,0 @@ -From fae3d11e5b37adf684317c00baa2549606b90419 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 27 May 2021 14:45:46 -0500 -Subject: of: address: Use IS_ENABLED() for !CONFIG_PCI - -From: Rob Herring - -[ Upstream commit c3c0dc75774b488770f33598109161040d291367 ] - -Convert address.c to use IS_ENABLED() instead of ifdefs for the -public PCI functions. This simplifies the ifdefs in of_address.h. - -Cc: Frank Rowand -Signed-off-by: Rob Herring -Link: https://lore.kernel.org/r/20210527194547.1287934-4-robh@kernel.org -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 8 +++++++- - include/linux/of_address.h | 39 ++++++++++++++++++-------------------- - 2 files changed, 25 insertions(+), 22 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 0455271a26ac..068a134f6df7 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -194,6 +194,7 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na) - { - return of_bus_default_translate(addr + 1, offset, na - 1); - } -+#endif /* CONFIG_PCI */ - - int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r) -@@ -202,6 +203,9 @@ int of_pci_address_to_resource(struct device_node *dev, int bar, - u64 size; - unsigned int flags; - -+ if (!IS_ENABLED(CONFIG_PCI)) -+ return -ENOSYS; -+ - addrp = of_get_pci_address(dev, bar, &size, &flags); - if (addrp == NULL) - return -EINVAL; -@@ -232,6 +236,9 @@ int of_pci_range_to_resource(struct of_pci_range *range, - res->parent = res->child = res->sibling = NULL; - res->name = np->full_name; - -+ if (!IS_ENABLED(CONFIG_PCI)) -+ return -ENOSYS; -+ - if (res->flags & IORESOURCE_IO) { - unsigned long port; - err = pci_register_io_range(&np->fwnode, range->cpu_addr, -@@ -262,7 +269,6 @@ int of_pci_range_to_resource(struct of_pci_range *range, - return err; - } - EXPORT_SYMBOL(of_pci_range_to_resource); --#endif /* CONFIG_PCI */ - - /* - * ISA bus specific translator -diff --git a/include/linux/of_address.h b/include/linux/of_address.h -index b72807faf037..45598dbec269 100644 ---- a/include/linux/of_address.h -+++ b/include/linux/of_address.h -@@ -61,6 +61,11 @@ extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser, - extern struct of_pci_range *of_pci_range_parser_one( - struct of_pci_range_parser *parser, - struct of_pci_range *range); -+extern int of_pci_address_to_resource(struct device_node *dev, int bar, -+ struct resource *r); -+extern int of_pci_range_to_resource(struct of_pci_range *range, -+ struct device_node *np, -+ struct resource *res); - extern bool of_dma_is_coherent(struct device_node *np); - #else /* CONFIG_OF_ADDRESS */ - static inline void __iomem *of_io_request_and_map(struct device_node *device, -@@ -100,6 +105,19 @@ static inline struct of_pci_range *of_pci_range_parser_one( - return NULL; - } - -+static inline int of_pci_address_to_resource(struct device_node *dev, int bar, -+ struct resource *r) -+{ -+ return -ENOSYS; -+} -+ -+static inline int of_pci_range_to_resource(struct of_pci_range *range, -+ struct device_node *np, -+ struct resource *res) -+{ -+ return -ENOSYS; -+} -+ - static inline bool of_dma_is_coherent(struct device_node *np) - { - return false; -@@ -124,27 +142,6 @@ static inline void __iomem *of_iomap(struct device_node *device, int index) - #endif - #define of_range_parser_init of_pci_range_parser_init - --#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI) --extern int of_pci_address_to_resource(struct device_node *dev, int bar, -- struct resource *r); --extern int of_pci_range_to_resource(struct of_pci_range *range, -- struct device_node *np, -- struct resource *res); --#else /* CONFIG_OF_ADDRESS && CONFIG_PCI */ --static inline int of_pci_address_to_resource(struct device_node *dev, int bar, -- struct resource *r) --{ -- return -ENOSYS; --} -- --static inline int of_pci_range_to_resource(struct of_pci_range *range, -- struct device_node *np, -- struct resource *res) --{ -- return -ENOSYS; --} --#endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */ -- - static inline const __be32 *of_get_address(struct device_node *dev, int index, - u64 *size, unsigned int *flags) - { --- -2.39.5 - diff --git a/queue-5.10/of-merge-of_get_address-and-of_get_pci_address-imple.patch b/queue-5.10/of-merge-of_get_address-and-of_get_pci_address-imple.patch deleted file mode 100644 index 297b02d7f62..00000000000 --- a/queue-5.10/of-merge-of_get_address-and-of_get_pci_address-imple.patch +++ /dev/null @@ -1,193 +0,0 @@ -From 83a68f7ded70bd823ff3b463647c3610d6b55722 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 27 May 2021 14:45:45 -0500 -Subject: of: Merge of_get_address() and of_get_pci_address() implementations - -From: Rob Herring - -[ Upstream commit 050a2c62dfc7d9ef457405f6ab4b715e9a2e32d7 ] - -of_get_address() and of_get_pci_address() are the same implementation -except of_get_pci_address() takes the PCI BAR number rather than an -index. Modify the of_get_address() implementation to work on either -index or BAR and provide wrapper functions for the existing functions. - -Cc: Frank Rowand -Signed-off-by: Rob Herring -Link: https://lore.kernel.org/r/20210527194547.1287934-3-robh@kernel.org -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/address.c | 62 ++++++++------------------------------ - include/linux/of_address.h | 27 ++++++++++------- - 2 files changed, 29 insertions(+), 60 deletions(-) - -diff --git a/drivers/of/address.c b/drivers/of/address.c -index 7e2bfbb22430..0455271a26ac 100644 ---- a/drivers/of/address.c -+++ b/drivers/of/address.c -@@ -195,50 +195,6 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na) - return of_bus_default_translate(addr + 1, offset, na - 1); - } - --const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, -- unsigned int *flags) --{ -- const __be32 *prop; -- unsigned int psize; -- struct device_node *parent; -- struct of_bus *bus; -- int onesize, i, na, ns; -- -- /* Get parent & match bus type */ -- parent = of_get_parent(dev); -- if (parent == NULL) -- return NULL; -- bus = of_match_bus(parent); -- if (strcmp(bus->name, "pci")) { -- of_node_put(parent); -- return NULL; -- } -- bus->count_cells(dev, &na, &ns); -- of_node_put(parent); -- if (!OF_CHECK_ADDR_COUNT(na)) -- return NULL; -- -- /* Get "reg" or "assigned-addresses" property */ -- prop = of_get_property(dev, bus->addresses, &psize); -- if (prop == NULL) -- return NULL; -- psize /= 4; -- -- onesize = na + ns; -- for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) { -- u32 val = be32_to_cpu(prop[0]); -- if ((val & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { -- if (size) -- *size = of_read_number(prop + na, ns); -- if (flags) -- *flags = bus->get_flags(prop); -- return prop; -- } -- } -- return NULL; --} --EXPORT_SYMBOL(of_get_pci_address); -- - int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r) - { -@@ -671,8 +627,8 @@ u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr) - } - EXPORT_SYMBOL(of_translate_dma_address); - --const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, -- unsigned int *flags) -+const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no, -+ u64 *size, unsigned int *flags) - { - const __be32 *prop; - unsigned int psize; -@@ -685,6 +641,10 @@ const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, - if (parent == NULL) - return NULL; - bus = of_match_bus(parent); -+ if (strcmp(bus->name, "pci") && (bar_no >= 0)) { -+ of_node_put(parent); -+ return NULL; -+ } - bus->count_cells(dev, &na, &ns); - of_node_put(parent); - if (!OF_CHECK_ADDR_COUNT(na)) -@@ -697,17 +657,21 @@ const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, - psize /= 4; - - onesize = na + ns; -- for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) -- if (i == index) { -+ for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) { -+ u32 val = be32_to_cpu(prop[0]); -+ /* PCI bus matches on BAR number instead of index */ -+ if (((bar_no >= 0) && ((val & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0))) || -+ ((index >= 0) && (i == index))) { - if (size) - *size = of_read_number(prop + na, ns); - if (flags) - *flags = bus->get_flags(prop); - return prop; - } -+ } - return NULL; - } --EXPORT_SYMBOL(of_get_address); -+EXPORT_SYMBOL(__of_get_address); - - static int parser_init(struct of_pci_range_parser *parser, - struct device_node *node, const char *name) -diff --git a/include/linux/of_address.h b/include/linux/of_address.h -index 88bc943405cd..b72807faf037 100644 ---- a/include/linux/of_address.h -+++ b/include/linux/of_address.h -@@ -51,8 +51,8 @@ void __iomem *of_io_request_and_map(struct device_node *device, - * the address space flags too. The PCI version uses a BAR number - * instead of an absolute index - */ --extern const __be32 *of_get_address(struct device_node *dev, int index, -- u64 *size, unsigned int *flags); -+extern const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no, -+ u64 *size, unsigned int *flags); - - extern int of_pci_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node); -@@ -75,8 +75,8 @@ static inline u64 of_translate_address(struct device_node *np, - return OF_BAD_ADDR; - } - --static inline const __be32 *of_get_address(struct device_node *dev, int index, -- u64 *size, unsigned int *flags) -+static inline const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no, -+ u64 *size, unsigned int *flags) - { - return NULL; - } -@@ -125,8 +125,6 @@ static inline void __iomem *of_iomap(struct device_node *device, int index) - #define of_range_parser_init of_pci_range_parser_init - - #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI) --extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, -- u64 *size, unsigned int *flags); - extern int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r); - extern int of_pci_range_to_resource(struct of_pci_range *range, -@@ -139,11 +137,6 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar, - return -ENOSYS; - } - --static inline const __be32 *of_get_pci_address(struct device_node *dev, -- int bar_no, u64 *size, unsigned int *flags) --{ -- return NULL; --} - static inline int of_pci_range_to_resource(struct of_pci_range *range, - struct device_node *np, - struct resource *res) -@@ -152,4 +145,16 @@ static inline int of_pci_range_to_resource(struct of_pci_range *range, - } - #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */ - -+static inline const __be32 *of_get_address(struct device_node *dev, int index, -+ u64 *size, unsigned int *flags) -+{ -+ return __of_get_address(dev, index, -1, size, flags); -+} -+ -+static inline const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, -+ u64 *size, unsigned int *flags) -+{ -+ return __of_get_address(dev, -1, bar_no, size, flags); -+} -+ - #endif /* __OF_ADDRESS_H */ --- -2.39.5 - diff --git a/queue-5.10/of-unittest-add-bus-address-range-parsing-tests.patch b/queue-5.10/of-unittest-add-bus-address-range-parsing-tests.patch deleted file mode 100644 index f818b07fa0f..00000000000 --- a/queue-5.10/of-unittest-add-bus-address-range-parsing-tests.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 29f2f3ced2ef45609c453f87d322c18589ce7c33 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Tue, 28 Mar 2023 15:15:56 -0500 -Subject: of: unittest: Add bus address range parsing tests - -From: Rob Herring - -[ Upstream commit 6d32dadb11a6480be62c6ada901bbdcbda1775c9 ] - -While there are tests for "dma-ranges" helpers, "ranges" is missing any -tests. It's the same underlying code, but for completeness add a test -for "ranges" parsing iterators. This is in preparation to add some -additional "ranges" helpers. - -Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-1-e2456c3e77ab@kernel.org -Signed-off-by: Rob Herring -Stable-dep-of: 7f05e20b989a ("of: address: Preserve the flags portion on 1:1 dma-ranges mapping") -Signed-off-by: Sasha Levin ---- - drivers/of/unittest.c | 53 +++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 53 insertions(+) - -diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c -index a334c68db339..cb199ace8681 100644 ---- a/drivers/of/unittest.c -+++ b/drivers/of/unittest.c -@@ -1018,6 +1018,58 @@ static void __init of_unittest_pci_dma_ranges(void) - of_node_put(np); - } - -+static void __init of_unittest_bus_ranges(void) -+{ -+ struct device_node *np; -+ struct of_range range; -+ struct of_range_parser parser; -+ int i = 0; -+ -+ np = of_find_node_by_path("/testcase-data/address-tests"); -+ if (!np) { -+ pr_err("missing testcase data\n"); -+ return; -+ } -+ -+ if (of_range_parser_init(&parser, np)) { -+ pr_err("missing ranges property\n"); -+ return; -+ } -+ -+ /* -+ * Get the "ranges" from the device tree -+ */ -+ for_each_of_range(&parser, &range) { -+ unittest(range.flags == IORESOURCE_MEM, -+ "for_each_of_range wrong flags on node %pOF flags=%x (expected %x)\n", -+ np, range.flags, IORESOURCE_MEM); -+ if (!i) { -+ unittest(range.size == 0x40000000, -+ "for_each_of_range wrong size on node %pOF size=%llx\n", -+ np, range.size); -+ unittest(range.cpu_addr == 0x70000000, -+ "for_each_of_range wrong CPU addr (%llx) on node %pOF", -+ range.cpu_addr, np); -+ unittest(range.bus_addr == 0x70000000, -+ "for_each_of_range wrong bus addr (%llx) on node %pOF", -+ range.pci_addr, np); -+ } else { -+ unittest(range.size == 0x20000000, -+ "for_each_of_range wrong size on node %pOF size=%llx\n", -+ np, range.size); -+ unittest(range.cpu_addr == 0xd0000000, -+ "for_each_of_range wrong CPU addr (%llx) on node %pOF", -+ range.cpu_addr, np); -+ unittest(range.bus_addr == 0x00000000, -+ "for_each_of_range wrong bus addr (%llx) on node %pOF", -+ range.pci_addr, np); -+ } -+ i++; -+ } -+ -+ of_node_put(np); -+} -+ - static void __init of_unittest_parse_interrupts(void) - { - struct device_node *np; -@@ -3318,6 +3370,7 @@ static int __init of_unittest(void) - of_unittest_dma_get_max_cpu_address(); - of_unittest_parse_dma_ranges(); - of_unittest_pci_dma_ranges(); -+ of_unittest_bus_ranges(); - of_unittest_match_node(); - of_unittest_platform_populate(); - of_unittest_overlay(); --- -2.39.5 - diff --git a/queue-5.10/series b/queue-5.10/series index 04f8f46b5cf..a3755cbdfd6 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -57,14 +57,6 @@ block-remove-the-update_bdev-parameter-to-set_capaci.patch zram-use-set_capacity_and_notify.patch drivers-block-zram-zram_drv.c-do-not-keep-dangling-z.patch zram-fix-uninitialized-zram-not-releasing-backing-de.patch -of-merge-of_get_address-and-of_get_pci_address-imple.patch -of-address-use-is_enabled-for-config_pci.patch -of-unittest-add-bus-address-range-parsing-tests.patch -of-address-add-support-for-3-address-cell-bus.patch -of-address-fix-address-translation-when-address-size.patch -of-address-remove-duplicated-functions.patch -of-address-store-number-of-bus-flag-cells-rather-tha.patch -of-address-preserve-the-flags-portion-on-1-1-dma-ran.patch phy-usb-add-wake-on-functionality-for-newer-synopsis.patch phy-usb-toggle-the-phy-power-during-init.patch ocfs2-correct-return-value-of-ocfs2_local_free_info.patch -- 2.47.3