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 95550A0562; Tue, 31 Mar 2020 19:05:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C7DA1C025; Tue, 31 Mar 2020 19:05:58 +0200 (CEST) Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by dpdk.org (Postfix) with ESMTP id CF5181BFC5 for ; Tue, 31 Mar 2020 18:51:42 +0200 (CEST) Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02VGpfKB002487 for ; Tue, 31 Mar 2020 16:51:41 GMT Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0a-002e3701.pphosted.com with ESMTP id 304759hr94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 31 Mar 2020 16:51:41 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 4CF8E9B for ; Tue, 31 Mar 2020 16:51:31 +0000 (UTC) Received: from nvgrid-template.ibftc.vpi.hp.com (unknown [16.99.164.195]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 2CF8739 for ; Tue, 31 Mar 2020 16:51:31 +0000 (UTC) From: Michael Haeuptle To: dev@dpdk.org Date: Tue, 31 Mar 2020 16:51:28 +0000 Message-Id: <20200331165128.29321-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-03-31_07:2020-03-31, 2020-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 adultscore=0 bulkscore=0 suspectscore=1 spamscore=0 phishscore=0 priorityscore=1501 mlxlogscore=873 clxscore=1011 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310147 X-Mailman-Approved-At: Tue, 31 Mar 2020 19:05:57 +0200 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). 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