From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E2AC4A0577; Tue, 7 Apr 2020 00:23:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A2AC72B96; Tue, 7 Apr 2020 00:23:41 +0200 (CEST) Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by dpdk.org (Postfix) with ESMTP id BC0ACF12; Tue, 7 Apr 2020 00:23:39 +0200 (CEST) Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 036MNcp2001820; Mon, 6 Apr 2020 22:23:38 GMT Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0a-002e3701.pphosted.com with ESMTP id 307xu36ef2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2020 22:23:38 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id 689DC54; Mon, 6 Apr 2020 22:23:26 +0000 (UTC) Received: from nvgrid-template.ibftc.vpi.hp.com (unknown [16.214.34.106]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 25A004F; Mon, 6 Apr 2020 22:23:26 +0000 (UTC) From: Michael Haeuptle To: dev@dpdk.org Cc: xiao.w.wang@intel.com, stable@dpdk.org Date: Mon, 6 Apr 2020 22:23:23 +0000 Message-Id: <20200406222323.18609-1-michael.haeuptle@hpe.com> X-Mailer: git-send-email 2.18.2 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-06_10:2020-04-06, 2020-04-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 suspectscore=1 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060169 Subject: [dpdk-dev] [PATCH] eal: Fixes VFIO/sysfs race condition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This fix treats a 0 return value from vfio_open_group_fd in vfio_get_group_fd as the intended error condition instead of putting an incorrect 0 file descriptor in the vfio_group table. Sometimes, the creation of device files in sysfs is not instantaneously causing vfio_open_groupfd to return 0. This has been observed when hot removing/adding multiple NVMe devices (>=4). Fixes: 340b7bb8d583 ("vfio: extend data structure for multi container") Cc: xiao.w.wang@intel.com Cc: stable@dpdk.org Signed-off-by: Michael Haeuptle --- lib/librte_eal/linux/eal_vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_vfio.c index 4502aefed..1979f6fdd 100644 --- a/lib/librte_eal/linux/eal_vfio.c +++ b/lib/librte_eal/linux/eal_vfio.c @@ -379,7 +379,7 @@ vfio_get_group_fd(struct vfio_config *vfio_cfg, } vfio_group_fd = vfio_open_group_fd(iommu_group_num); - if (vfio_group_fd < 0) { + if (vfio_group_fd <= 0) { RTE_LOG(ERR, EAL, "Failed to open group %d\n", iommu_group_num); return -1; } -- 2.18.2