linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] um: virt-pci: implement pcibios_get_phb_of_node()
@ 2023-01-20  8:02 Vincent Whitchurch
  2023-01-20  8:22 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Whitchurch @ 2023-01-20  8:02 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: linux-um, linux-pci, devicetree, linux-kernel,
	Vincent Whitchurch, kernel

Implement pcibios_get_phb_of_node() as x86 does in order to allow PCI
busses to be associated with devicetree nodes.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 arch/um/drivers/virt-pci.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 3ac220dafec4..6884e1be38e4 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -533,6 +533,25 @@ static void um_pci_irq_vq_cb(struct virtqueue *vq)
 	}
 }
 
+/* Copied from arch/x86/kernel/devicetree.c */
+struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
+{
+	struct device_node *np;
+
+	for_each_node_by_type(np, "pci") {
+		const void *prop;
+		unsigned int bus_min;
+
+		prop = of_get_property(np, "bus-range", NULL);
+		if (!prop)
+			continue;
+		bus_min = be32_to_cpup(prop);
+		if (bus->number == bus_min)
+			return np;
+	}
+	return NULL;
+}
+
 static int um_pci_init_vqs(struct um_pci_device *dev)
 {
 	struct virtqueue *vqs[2];

---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20230120-uml-pci-of-f21d5ba4b245

Best regards,
-- 
Vincent Whitchurch <vincent.whitchurch@axis.com>

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] um: virt-pci: implement pcibios_get_phb_of_node()
  2023-01-20  8:02 [PATCH] um: virt-pci: implement pcibios_get_phb_of_node() Vincent Whitchurch
@ 2023-01-20  8:22 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2023-01-20  8:22 UTC (permalink / raw)
  To: Vincent Whitchurch, Richard Weinberger, Anton Ivanov
  Cc: linux-um, linux-pci, devicetree, linux-kernel, kernel

On Fri, 2023-01-20 at 09:02 +0100, Vincent Whitchurch wrote:
> Implement pcibios_get_phb_of_node() as x86 does in order to allow PCI
> busses to be associated with devicetree nodes.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  arch/um/drivers/virt-pci.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
> index 3ac220dafec4..6884e1be38e4 100644
> --- a/arch/um/drivers/virt-pci.c
> +++ b/arch/um/drivers/virt-pci.c
> @@ -533,6 +533,25 @@ static void um_pci_irq_vq_cb(struct virtqueue *vq)
>  	}
>  }
>  
> +/* Copied from arch/x86/kernel/devicetree.c */
> +struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)

Hah. I was going to ask how that works without any ifdef or anything,
but then I found the __weak version :-)

Acked-by: Johannes Berg <johannes@sipsolutions.net>


Or maybe I should finally put on my tentative ARCH=um maintainer hat and
start taking patches :)

johannes


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-20  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20  8:02 [PATCH] um: virt-pci: implement pcibios_get_phb_of_node() Vincent Whitchurch
2023-01-20  8:22 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).