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 4F3F4A0542; Tue, 31 May 2022 11:28:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2E2C400EF; Tue, 31 May 2022 11:28:12 +0200 (CEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 4497E400D6 for ; Tue, 31 May 2022 11:28:12 +0200 (CEST) Received: by mail-wr1-f49.google.com with SMTP id k19so9641371wrd.8 for ; Tue, 31 May 2022 02:28:12 -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=2SVmC4d+JMS+IyKR0M1T1oo+fnECR3bnVQrhlqg3VTM=; b=BB8Zv+9510JHj+tQgcSMduvxz39BJ/aiaOg+TurHIy+OoEBRr0YFIc/ej2Gje60zhK pkmesPmNBtaCtYr324MmhzMqDYZ1pLpoEsgqXMH7yYwgM0CYiO7Xr4fP+8zF/vntz1eF 5z9ujr2aMp8+4jf8Xju0vYVA3jmfG6rfOL/iQXlvxorCtP24e1AfHibQO7StI7fptdBr yX+4XaL+derXigdNlU3PKHahOn72jwL1UWcgvajNpgTLw9CGEqTUzhLcr5ALRhIeZa9e pmoMDKqGeSKpluosXTyF7k2jbVsCJks805+hBG2IVznNL+2AiTinZt9Yl+LznBFAgak/ LhLg== 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=2SVmC4d+JMS+IyKR0M1T1oo+fnECR3bnVQrhlqg3VTM=; b=pxntHtRjLuLvyhBQfCssi1D193/kyMRAtqfDZFZypVS7n8YqxjAljV0Qye7NSarH2y 9ssbWQHoMBJ3LY+ZiOimscDlAgS4bJXJpiAhlNp/zDhJjSah1m3M419af4Ugh9ztzp4a HPTekC5yiuxZLidSlx/Q79SYTa9Wp5e6V73vOplwvbIalTooFsmTBNz83pzDTZSO8WL8 nHfurp+9N6aqbcJVwcp259NlkjrbzhjAMnhpHlDHVZe7itkVvJAMzxIC3YsLHeqmwQr8 gQyEpEHqHzSUHcqY87x113o+Md9htxBPN5vjui60nK4T06XpwQ8Ff5fl2fHTSt3cIG2I MaLg== X-Gm-Message-State: AOAM530gOqsN+zS3QCBmlW4Jm8BMP/Hg6YJClb6EODr1dqJA/fxWkPQd YbIhF2QpS3o3sBHAgsDi44S92Q== X-Google-Smtp-Source: ABdhPJx9mry5C88H6FGd2k8/OdRpEm4Yk06v32XNF6BUe89ap+U3vJbeAk88tQ0a1vdO2SH1yeIW/w== X-Received: by 2002:adf:f2cd:0:b0:20e:5bf9:8e32 with SMTP id d13-20020adff2cd000000b0020e5bf98e32mr49551663wrp.161.1653989291955; Tue, 31 May 2022 02:28:11 -0700 (PDT) Received: from testament.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5546000000b002100aa69469sm11291654wrw.2.2022.05.31.02.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 02:28:11 -0700 (PDT) From: Romain Delhomel To: hemant.agrawal@nxp.com, sachin.saxena@oss.nxp.com Cc: dev@dpdk.org, olivier.matz@6wind.com, stephane.gonauer@6wind.com, guillaume.gaudonville@6wind.com, elias.boutaleb@6wind.com Subject: [RFC v2] bus/fslmc: fix invalid use of default VFIO config Date: Tue, 31 May 2022 11:27:53 +0200 Message-Id: <20220531092753.10825-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") Signed-off-by: Romain Delhomel --- v2: * Fix wrong indentation 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