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 0824DA0562; Tue, 31 Mar 2020 18:57:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B86B42C15; Tue, 31 Mar 2020 18:57:02 +0200 (CEST) Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by dpdk.org (Postfix) with ESMTP id 9436E2BCE for ; Tue, 31 Mar 2020 18:57:01 +0200 (CEST) Received: from pps.filterd (m0134425.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02VGomSQ030754 for ; Tue, 31 Mar 2020 16:57:00 GMT Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 304655a9us-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 31 Mar 2020 16:57:00 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id 4DEAF71 for ; Tue, 31 Mar 2020 16:57:00 +0000 (UTC) Received: from nvgrid-template.ibftc.vpi.hp.com (unknown [16.99.164.195]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 30FC548 for ; Tue, 31 Mar 2020 16:57:00 +0000 (UTC) From: Michael Haeuptle To: dev@dpdk.org Date: Tue, 31 Mar 2020 16:56:57 +0000 Message-Id: <20200331165657.29368-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 suspectscore=1 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=997 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310147 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