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 2C454459AE; Mon, 16 Sep 2024 14:31:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16E5340E4D; Mon, 16 Sep 2024 14:31:01 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id BFA2840E4D for ; Mon, 16 Sep 2024 14:30:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726489859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HeaNCheDvYX8jiuM5k8CZ6P5c3Dbz6TTohh8l+xfosY=; b=eQt+n8+kUKzbCCLy+rU0e8t7uBpMu5mVypOSQ2QGONLLKuCwDYf/0XcJJxwCwKXCbHASKC GxrQsFQdTe1F9PepLankg0FxaV4fK2k895Or1mFxDUiKqqfyiTyHDmwrqS2lwQN8KTajpM hUOEMc/opG1cv9sDjQbtkJMWNV3aU+U= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-g9BGXcy5PkiW-8U75k7lSQ-1; Mon, 16 Sep 2024 08:30:56 -0400 X-MC-Unique: g9BGXcy5PkiW-8U75k7lSQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CEFCB1953944; Mon, 16 Sep 2024 12:30:54 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.123]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2BD6F1956086; Mon, 16 Sep 2024 12:30:52 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Anatoly Burakov , Chenbo Xia , Nipun Gupta Subject: [PATCH 2/2] bus/pci: enhance hotplug for VFIO bound devices Date: Mon, 16 Sep 2024 14:30:43 +0200 Message-ID: <20240916123044.2692301-2-david.marchand@redhat.com> In-Reply-To: <20240916123044.2692301-1-david.marchand@redhat.com> References: <20240916123044.2692301-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 VFIO modules may get loaded/initialized after DPDK initialized (like when starting an application without knowing which devices will be used, and whether their drivers require VFIO). Retry enabling VFIO if not available. This way, it is not required to restart the DPDK application anymore. Signed-off-by: David Marchand --- drivers/bus/pci/linux/pci_vfio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index adc34a5c51..5317170231 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -1319,6 +1319,12 @@ pci_vfio_mmio_write(const struct rte_pci_device *dev, int bar, int pci_vfio_is_enabled(void) { - return rte_vfio_is_enabled("vfio_pci"); + int status = rte_vfio_is_enabled("vfio_pci"); + + if (!status) { + rte_vfio_enable("vfio"); + status = rte_vfio_is_enabled("vfio_pci"); + } + return status; } #endif -- 2.46.0