From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 66105A0524; Thu, 6 May 2021 17:10:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2091C410EE; Thu, 6 May 2021 17:10:52 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 0071D410DB for ; Thu, 6 May 2021 17:10:49 +0200 (CEST) IronPort-SDR: V6kZKpJbn3V78eT6zK9klSFKKHe1eV5/u/I3mYEcogquPgFLs4AjtH+i/ID0odDbKjVwxzWMiZ lRcRe6YlW9Zg== X-IronPort-AV: E=McAfee;i="6200,9189,9976"; a="196473000" X-IronPort-AV: E=Sophos;i="5.82,277,1613462400"; d="scan'208";a="196473000" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2021 08:10:45 -0700 IronPort-SDR: mxSg16W0O8bikxNymMZtq7b2/3v1sy7LHP49CB4FnjZGiIwaUZj5alKs5HHcD/igNkReEAtW/i MXwo0LShNr8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,277,1613462400"; d="scan'208";a="539986524" Received: from silpixa00399126.ir.intel.com ([10.237.223.78]) by orsmga004.jf.intel.com with ESMTP; 06 May 2021 08:10:43 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: anatoly.burakov@intel.com, Bruce Richardson , Harry van Haaren Date: Thu, 6 May 2021 16:09:08 +0100 Message-Id: <20210506150908.797110-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] raw/ioat: fix bus requiring virtual addressing when no devs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/raw/ioat/idxd_bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ioat/idxd_bus.c b/drivers/raw/ioat/idxd_bus.c index 5199786785..d7c5a19cec 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 = 0; + /** 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 -- 2.30.2