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 A01BEA0555; Fri, 3 Jun 2022 17:19:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41E9440694; Fri, 3 Jun 2022 17:19:09 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mails.dpdk.org (Postfix) with ESMTP id 1DDF34021E for ; Fri, 3 Jun 2022 17:19:08 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id a10so1728577wmj.5 for ; Fri, 03 Jun 2022 08:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zKkrfxrJn5sAZbdY9VyvK9EnbSgO8b/VA4gA6W1BGzw=; b=cGAWbcdfCemoCen/8z/GpfeY6FclBukXcP6JRoniKc32Q/7XNoJw+J/XW2Sq2CBUiZ k3CKbFlJISMKZSWohGpuCiBm1yveIcd30lLBVNLbR96bIh7hdJ77J8g153K5RniZ2556 VoHrrGvigkkbZYrQfduWXlKxBtpKYKoUHHaMDxiUo9mbnMFWCkVKN4B/g0/w2AA0TG2+ ZmGJvgfCVnQkhKTqdi9RG9WhQF40/x6WHhtmhkl0JhOYQmiDGo5kpwJ1qfm/wu403vbs L2uu7toPie452USPN6UIKFAfgbjXLqC/Zr4JVMo7l1hOMBcoZfDff2G2IlF8hbGMnrGp XBAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zKkrfxrJn5sAZbdY9VyvK9EnbSgO8b/VA4gA6W1BGzw=; b=uUR9z5wQlQGnDT8/oYBHPZ3oDTF5mpeBXgdqs3S4gZBuxCWg3UXB2VgJFhdu/blFt2 UUXUawwDtED/CWbpYlBCGVraesJulHaI9Qshgfxs/DstxMZH6KxpkstQSYAAUdJ9bgPt FAxmYHQzOqx9tkKNNeyu3/6n8ztKn7tRZZS4sjZ0Nl6+kh/+cMLiAvgIgeIfZDh4wz0y pK9TzNLcMmJ12yBb30NBzz5JonOebmGl1GNV6UI2Blmni8/i5YglAsR2ty6BaM6AdqWk eNAs+OTUbG587PpG+ZwhdbBYnSzNj0KJnVorwK660WHMGq5u8nHWQgjJ39WlTJK3JdSD K2hg== X-Gm-Message-State: AOAM533Bt6H7Y4CnY05hCl0eD1br51eDsGxKx4/mT724wc9kEX2wwYe7 MHe3NQJfqEv4Wc2pM7QiPOAH70n80T9QIxHt X-Google-Smtp-Source: ABdhPJxbjv3UkGy1QR0sgnLkLKH2WfeSICEPtSBsn5QgNojug6Gu/pwOw2gWL+jZuBvxybN72VXWQg== X-Received: by 2002:a05:600c:4e0c:b0:39c:2f33:4919 with SMTP id b12-20020a05600c4e0c00b0039c2f334919mr7968736wmq.58.1654269547517; Fri, 03 Jun 2022 08:19:07 -0700 (PDT) Received: from testament.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4c9400b0039749b01ea7sm10144708wmp.32.2022.06.03.08.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jun 2022 08:19:07 -0700 (PDT) From: Romain Delhomel To: dev@dpdk.org Cc: elias.boutaleb@6wind.com, guillaume.gaudonville@6wind.com, hemant.agrawal@nxp.com, olivier.matz@6wind.com, sachin.saxena@oss.nxp.com, stephane.gonauer@6wind.com, stable@dpdk.org Subject: [PATCH] bus/fslmc: fix invalid use of default VFIO config Date: Fri, 3 Jun 2022 17:18:30 +0200 Message-Id: <20220603151830.26845-1-romain.delhomel@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 At device probe, the fslmc bus driver calls rte_vfio_get_group_fd() to get a fd associated to a vfio group. This function first checks if the group is already opened, else it opens /dev/vfio/%u, and increases the number of active groups in default_vfio_cfg (which references the default vfio container). When adding the first group to a vfio_cfg, the caller is supposed to pick an IOMMU type and set up DMA mappings for container, as it's done by pci bus, but it is not done here. Instead, a new container is created and used. This prevents the pci bus driver, which uses the default_vfio_cfg container, to configure the container because default_vfio_cfg->active_group > 1. This patch fixes the issue by always creating a new container (and its associated vfio_cfg) and binding the group to it. Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group") Cc: stable@dpdk.org Signed-off-by: Romain Delhomel Acked-by: Hemant Agrawal --- drivers/bus/fslmc/fslmc_vfio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index b4704eeae4e2..abe1cab2ee20 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -979,6 +979,7 @@ fslmc_vfio_setup_group(void) { int groupid; int ret; + int vfio_container_fd; struct vfio_group_status status = { .argsz = sizeof(status) }; /* if already done once */ @@ -997,8 +998,15 @@ fslmc_vfio_setup_group(void) return 0; } + ret = rte_vfio_container_create(); + if (ret < 0) { + DPAA2_BUS_ERR("Failed to open VFIO container"); + return ret; + } + vfio_container_fd = ret; + /* Get the actual group fd */ - ret = rte_vfio_get_group_fd(groupid); + ret = rte_vfio_container_group_bind(vfio_container_fd, groupid); if (ret < 0) return ret; vfio_group.fd = ret; -- 2.30.2