Thread (24 messages) flat view 24 messages, 4 authors, 2021-06-18

Re: [PATCH v4 3/6] ACPI: Add driver for the VIOT table

From: Jean-Philippe Brucker <hidden>
Date: 2021-06-18 08:00:02
Also in: linux-acpi, linux-arm-kernel, linux-iommu

On Thu, Jun 17, 2021 at 01:50:59PM +0200, Rafael J. Wysocki wrote:
quoted
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index be7da23fad76..b835ca702ff0 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -27,6 +27,7 @@
 #include <linux/dmi.h>
 #endif
 #include <linux/acpi_iort.h>
+#include <linux/acpi_viot.h>
 #include <linux/pci.h>
 #include <acpi/apei.h>
 #include <linux/suspend.h>
@@ -1339,6 +1340,7 @@ static int __init acpi_init(void)
        pci_mmcfg_late_init();
        acpi_iort_init();
        acpi_scan_init();
+       acpi_viot_init();
Is there a specific reason why to call it right here?

In particular, does it need to be called after acpi_scan_init()?  And
does it need to be called before the subsequent functions?  If so,
then why?
It does need to be called after acpi_scan_init(), because it relies on
struct device and their fwnode to be initialized. In particular to find a
PCI device we call pci_get_domain_bus_and_slot(), which needs the PCI
topology made available by acpi_scan_init().

It does not need to be before the subsequent functions however, I can move
it at the end.
quoted
+void __init acpi_viot_init(void)
+{
+       int i;
+       acpi_status status;
+       struct acpi_table_header *hdr;
+       struct acpi_viot_header *node;
+
+       status = acpi_get_table(ACPI_SIG_VIOT, 0, &hdr);
+       if (ACPI_FAILURE(status)) {
+               if (status != AE_NOT_FOUND) {
+                       const char *msg = acpi_format_exception(status);
+
+                       pr_err("Failed to get table, %s\n", msg);
+               }
+               return;
+       }
+
+       viot = (void *)hdr;
+
+       node = ACPI_ADD_PTR(struct acpi_viot_header, viot, viot->node_offset);
+       for (i = 0; i < viot->node_count; i++) {
+               if (viot_parse_node(node))
+                       return;
+
+               node = ACPI_ADD_PTR(struct acpi_viot_header, node,
+                                   node->length);
+       }
Do you still need the table after the above is complete?  If not,
release the reference on it acquired above.
We don't need the table anymore, I'll drop the reference

Thanks,
Jean

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help