Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 0022085

Browse files
jones-drewgregkh
authored andcommitted
of/irq: Support #msi-cells=<0> in of_msi_get_domain
commit db8e811 upstream. An 'msi-parent' property with a single entry and no accompanying '#msi-cells' property is considered the legacy definition as opposed to its definition after being expanded with commit 126b16e ("Docs: dt: add generic MSI bindings"). However, the legacy definition is completely compatible with the current definition and, since of_phandle_iterator_next() tolerates missing and present-but- zero *cells properties since commit e42ee61 ("of: Let of_for_each_phandle fallback to non-negative cell_count"), there's no need anymore to special case the legacy definition in of_msi_get_domain(). Indeed, special casing has turned out to be harmful, because, as of commit 7c02523 ("dt-bindings: irqchip: Describe the IMX MU block as a MSI controller"), MSI controller DT bindings have started specifying '#msi-cells' as a required property (even when the value must be zero) as an effort to make the bindings more explicit. But, since the special casing of 'msi-parent' only uses the existence of '#msi-cells' for its heuristic, and not whether or not it's also nonzero, the legacy path is not taken. Furthermore, the path to support the new, broader definition isn't taken either since that path has been restricted to the platform-msi bus. But, neither the definition of 'msi-parent' nor the definition of '#msi-cells' is platform-msi-specific (the platform-msi bus was just the first bus that needed '#msi-cells'), so remove both the special casing and the restriction. The code removal also requires changing to of_parse_phandle_with_optional_args() in order to ensure the legacy (but compatible) use of 'msi-parent' remains supported. This not only simplifies the code but also resolves an issue with PCI devices finding their MSI controllers on riscv, as the riscv,imsics binding requires '#msi-cells=<0>'. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20240817074107.31153-2-ajones@ventanamicro.com Cc: stable@vger.kernel.org Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d657d28 commit 0022085

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

drivers/of/irq.c

+7-27
Original file line numberDiff line numberDiff line change
@@ -716,42 +716,22 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id,
716716
* @np: device node for @dev
717717
* @token: bus type for this domain
718718
*
719-
* Parse the msi-parent property (both the simple and the complex
720-
* versions), and returns the corresponding MSI domain.
719+
* Parse the msi-parent property and returns the corresponding MSI domain.
721720
*
722721
* Returns: the MSI domain for this device (or NULL on failure).
723722
*/
724723
struct irq_domain *of_msi_get_domain(struct device *dev,
725724
struct device_node *np,
726725
enum irq_domain_bus_token token)
727726
{
728-
struct device_node *msi_np;
727+
struct of_phandle_iterator it;
729728
struct irq_domain *d;
729+
int err;
730730

731-
/* Check for a single msi-parent property */
732-
msi_np = of_parse_phandle(np, "msi-parent", 0);
733-
if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) {
734-
d = irq_find_matching_host(msi_np, token);
735-
if (!d)
736-
of_node_put(msi_np);
737-
return d;
738-
}
739-
740-
if (token == DOMAIN_BUS_PLATFORM_MSI) {
741-
/* Check for the complex msi-parent version */
742-
struct of_phandle_args args;
743-
int index = 0;
744-
745-
while (!of_parse_phandle_with_args(np, "msi-parent",
746-
"#msi-cells",
747-
index, &args)) {
748-
d = irq_find_matching_host(args.np, token);
749-
if (d)
750-
return d;
751-
752-
of_node_put(args.np);
753-
index++;
754-
}
731+
of_for_each_phandle(&it, err, np, "msi-parent", "#msi-cells", 0) {
732+
d = irq_find_matching_host(it.node, token);
733+
if (d)
734+
return d;
755735
}
756736

757737
return NULL;

0 commit comments

Comments
 (0)