Commit 3cf48554 authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Joerg Roedel
Browse files

ACPI: Add driver for the VIOT table



The ACPI Virtual I/O Translation Table describes topology of
para-virtual platforms, similarly to vendor tables DMAR, IVRS and IORT.
For now it describes the relation between virtio-iommu and the endpoints
it manages.

Three steps are needed to configure DMA of endpoints:

(1) acpi_viot_init(): parse the VIOT table, find or create the fwnode
    associated to each vIOMMU device. This needs to happen after
    acpi_scan_init(), because it relies on the struct device and their
    fwnode to be available.

(2) When probing the vIOMMU device, the driver registers its IOMMU ops
    within the IOMMU subsystem. This step doesn't require any
    intervention from the VIOT driver.

(3) viot_iommu_configure(): before binding the endpoint to a driver,
    find the associated IOMMU ops. Register them, along with the
    endpoint ID, into the device's iommu_fwspec.

If step (3) happens before step (2), it is deferred until the IOMMU is
initialized, then retried.

Tested-by: default avatarEric Auger <eric.auger@redhat.com>
Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20210618152059.1194210-4-jean-philippe@linaro.org


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 11a8c5e3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -431,6 +431,14 @@ W: https://01.org/linux-acpi
B:	https://bugzilla.kernel.org
F:	drivers/acpi/acpi_video.c
ACPI VIOT DRIVER
M:	Jean-Philippe Brucker <jean-philippe@linaro.org>
L:	linux-acpi@vger.kernel.org
L:	iommu@lists.linux-foundation.org
S:	Maintained
F:	drivers/acpi/viot.c
F:	include/linux/acpi_viot.h
ACPI WMI DRIVER
L:	platform-driver-x86@vger.kernel.org
S:	Orphan
+3 −0
Original line number Diff line number Diff line
@@ -526,6 +526,9 @@ endif

source "drivers/acpi/pmic/Kconfig"

config ACPI_VIOT
	bool

endif	# ACPI

config X86_PM_TIMER
+2 −0
Original line number Diff line number Diff line
@@ -118,3 +118,5 @@ video-objs += acpi_video.o video_detect.o
obj-y				+= dptf/

obj-$(CONFIG_ARM64)		+= arm64/

obj-$(CONFIG_ACPI_VIOT)		+= viot.o
+2 −0
Original line number Diff line number Diff line
@@ -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>
@@ -1345,6 +1346,7 @@ static int __init acpi_init(void)
	acpi_wakeup_device_init();
	acpi_debugger_init();
	acpi_setup_sb_notify_handler();
	acpi_viot_init();
	return 0;
}

+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/acpi_iort.h>
#include <linux/acpi_viot.h>
#include <linux/iommu.h>
#include <linux/signal.h>
#include <linux/kthread.h>
@@ -1556,6 +1557,8 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,
		return ops;

	err = iort_iommu_configure_id(dev, id_in);
	if (err && err != -EPROBE_DEFER)
		err = viot_iommu_configure(dev);

	/*
	 * If we have reason to believe the IOMMU driver missed the initial
Loading