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 222D0A055A for ; Fri, 3 Jun 2022 17:19:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16DEB41181; Fri, 3 Jun 2022 17:19:10 +0200 (CEST) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mails.dpdk.org (Postfix) with ESMTP id 216DC40694 for ; Fri, 3 Jun 2022 17:19:08 +0200 (CEST) Received: by mail-wm1-f54.google.com with SMTP id f7-20020a1c3807000000b0039c1a10507fso4504828wma.1 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=6EP2m8bmHbN9XND3thqVQKemZnbrXc0766ookbZs+btkrcAd6raVGqQPGuNi23cXme qKgSl/0plXiTmXStpDGJ9F6h/706Lv2vCHmtxugLTYJMuo17XEcd8y7scyj1FjOMZTkZ fNU0YxJ5dfLm08uaV4NQtb65fYa5F5b1pho9Bnz8edVBLNX48e3H07t4PJaxVFN9FtEQ JBhJB2j6fOKhAhztj1tlKBh49zTFZFziRIU8V5UThdNwvtlTfIA5xq5+bHgKWydV2Cff UVWbo6w17ZNZAmtWQUUXzfgB1xoMjTnVcKp0teba78WjJZaI3FvycPlILIjVTKY8dyOE MnEw== X-Gm-Message-State: AOAM532OC0Jd+yfl9jpcRryQzaoGfq4K7tJ7NBNaxdoOq6xThnQrQd8J EA6hDRPp/nclBFEvoDtCrcRASw== 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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