From: Bruce Richardson Date: Thu, 6 May 2021 15:09:08 +0000 (+0100) Subject: raw/ioat: skip VA requirement for bus without device X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f51c826f84448304aef2e80a548824c55dc78175;p=dpdk.git raw/ioat: skip VA requirement for bus without device If after a bus scan, there are no devices using a particular bus, then that bus should not be taken into account when deciding whether DPDK should be run in VA or PA addressing mode. This becomes an issue when the DSA bus driver code is used on a system without an IOMMU. The PCI bus correctly reports that it only works in PA mode, while the DSA bus - also correctly - reports that it works only in VA mode. The difference is that there will be no devices found in a scan for the DSA bus, since the kernel driver can only present those to userspace in the presence of an IOMMU. While we could change DSA instance to always report that it does not care about the addressing mode, this would imply that it could be used with DPDK in PA mode which is not the case. Therefore, this patch changes the driver to report DC (don't care) in the case where no devices are present, and VA otherwise. NOTE: this addressing mode use of VA-only applies only in the case of using DSA through the idxd kernel driver. The use of DSA though vfio-pci is unaffected and works as with other PCI devices. Fixes: b7aaf417f936 ("raw/ioat: add bus driver for device scanning automatically") Reported-by: Harry van Haaren Signed-off-by: Bruce Richardson Tested-by: Anatoly Burakov Tested-by: Harry van Haaren Tested-by: Conor Walsh --- diff --git a/drivers/raw/ioat/idxd_bus.c b/drivers/raw/ioat/idxd_bus.c index 5199786785..af400079ab 100644 --- a/drivers/raw/ioat/idxd_bus.c +++ b/drivers/raw/ioat/idxd_bus.c @@ -19,6 +19,8 @@ #define DSA_DEV_PATH "/dev/dsa" #define DSA_SYSFS_PATH "/sys/bus/dsa/devices" +static unsigned int devcount; + /** unique identifier for a DSA device/WQ instance */ struct dsa_wq_addr { uint16_t device_id; @@ -307,6 +309,7 @@ dsa_scan(void) dev->device.bus = &dsa_bus.bus; strlcpy(dev->wq_name, wq->d_name, sizeof(dev->wq_name)); TAILQ_INSERT_TAIL(&dsa_bus.device_list, dev, next); + devcount++; read_device_int(dev, "numa_node", &numa_node); dev->device.numa_node = numa_node; @@ -338,7 +341,8 @@ dsa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, static enum rte_iova_mode dsa_get_iommu_class(void) { - return RTE_IOVA_VA; + /* if there are no devices, report don't care, otherwise VA mode */ + return devcount > 0 ? RTE_IOVA_VA : RTE_IOVA_DC; } static int