From patchwork Wed Feb 14 22:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Harris X-Patchwork-Id: 13557168 Received: from mailout1.w2.samsung.com (mailout1.w2.samsung.com [211.189.100.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCEE51419AC; Wed, 14 Feb 2024 22:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.189.100.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707951592; cv=none; b=Ya+HvEuEisG5v6M1h1f2PAF3pOCkfcP/qSXlY4JJ4iu2CWb4DEcgPbUKU8WbXsR2bds3dnB/OxGQ3IgybbT5KTtROK08Yzhqfh6lpXRiEPTNt6qE1z7ejMrpUGswP4ELogxOBd14BvqinyqvhOmPJcLmTYlVCjF+JksgqREukbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707951592; c=relaxed/simple; bh=4dqGokGdhy1xJ0FLPp2+hNGb5PkT3Xrir0Am1s+UV3I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=UPgkJmkea5n+UKg+d48navn3tV/7ssfAM8aXzawZmiYchHbSEv0wDQ0Cm5BN/kp7F7sPaqKW1pSBuCTWqwK9QhBdpiRfZo72dPzUlrgdPQpAsk3hkz3PO8BkcjCjwRC1iiD7AT+xU6AYBqmvjbH2Qgx+RaftF6x9RFAOoqZnlS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=MlBIxBfa; arc=none smtp.client-ip=211.189.100.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MlBIxBfa" Received: from uscas1p1.samsung.com (unknown [182.198.245.206]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20240214225949usoutp01fcfef7c201676a007d1e4b6877c0a57a~z3OvmfP7g0141401414usoutp01K; Wed, 14 Feb 2024 22:59:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20240214225949usoutp01fcfef7c201676a007d1e4b6877c0a57a~z3OvmfP7g0141401414usoutp01K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707951589; bh=4dqGokGdhy1xJ0FLPp2+hNGb5PkT3Xrir0Am1s+UV3I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MlBIxBfahZgK8Vvj+fgWVrQgbowiV7gdsp9P5RLN5YkHryju3JRakvPbp673MLVbQ hBS1FvTEZbf5Sol4CH74/+ZyoX5FXt9y0BRR73K24MNfh3Hj7sWlI/00MQNY9t315S bYa1F6vv8HK50BDac6vflnK7RjE/NXEslDyqGL44= Received: from ussmges3new.samsung.com (u112.gpu85.samsung.co.kr [203.254.195.112]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214225949uscas1p2c39aa3d52cbd2300706548d583e6a2a8~z3Ovanry53221832218uscas1p2I; Wed, 14 Feb 2024 22:59:49 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges3new.samsung.com (USCPEMTA) with SMTP id FB.B6.09550.5E54DC56; Wed, 14 Feb 2024 17:59:49 -0500 (EST) Received: from ussmgxs1new.samsung.com (u89.gpu85.samsung.co.kr [203.254.195.89]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214225948uscas1p2178d37968dc620a7e317ce3b0d57ab04~z3Ou_2Y9N2193821938uscas1p2r; Wed, 14 Feb 2024 22:59:48 +0000 (GMT) X-AuditID: cbfec370-933ff7000000254e-41-65cd45e5dcbd Received: from SSI-EX1.ssi.samsung.com ( [105.128.3.67]) by ussmgxs1new.samsung.com (USCPEXMTA) with SMTP id 44.F3.50167.4E54DC56; Wed, 14 Feb 2024 17:59:48 -0500 (EST) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX1.ssi.samsung.com (105.128.2.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Wed, 14 Feb 2024 14:59:48 -0800 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Wed, 14 Feb 2024 14:59:48 -0800 From: Jim Harris To: Davidlohr Bueso , Jonathan Cameron , Dave Jiang , "Alison Schofield" , Vishal Verma , Ira Weiny , Dan Williams , Kees Cook , "Gustavo A. R. Silva" , "linux-kernel@vger.kernel.org" , "linux-cxl@vger.kernel.org" , "linux-hardening@vger.kernel.org" , Leon Romanovsky , "Jason Gunthorpe" , Alex Williamson , "pierre.cregut@orange.com" Subject: [PATCH v3 2/2] PCI/IOV: set iov->num_VFs before VFs are probed Thread-Topic: [PATCH v3 2/2] PCI/IOV: set iov->num_VFs before VFs are probed Thread-Index: AQHaX5mCLK4WlF8EHEe3pPHlJMI8cA== Date: Wed, 14 Feb 2024 22:59:48 +0000 Message-ID: <170795158776.2393.11628830004240634947.stgit@bgt-140510-bm01.eng.stellus.in> In-Reply-To: <170795147587.2393.15577527626926144858.stgit@bgt-140510-bm01.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-ID: <055EBCC164A1E949ACB3DD83D73DCBF2@ssi.samsung.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME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Jmn0pzdtNyX1HvxFNmRxar/3m2c4Ln4ZMGM9/lF63ab9BwZLLC1Wdi 2x9KsrAWvlofoet3Rq/8xIGk9oXKl04bFVdPvCskrLTcuOT925Azv6dP/+B4o8LxocR+scPV q7abvTrs9SrII5tL7v+bk9yhdoeipgWedrvY+jPTT2r60Ze/zJiz2Y78WV3Gufd84fJ3Lwx1 fvLLzVI7xnHf/qnNUisN1khdJZbijERDLeai4kQApJE7vI0DAAA= X-CMS-MailID: 20240214225948uscas1p2178d37968dc620a7e317ce3b0d57ab04 CMS-TYPE: 301P X-CMS-RootMailID: 20240214225948uscas1p2178d37968dc620a7e317ce3b0d57ab04 References: <170795147587.2393.15577527626926144858.stgit@bgt-140510-bm01.eng.stellus.in> Ensure userspace can see the updated number of VFs via sysfs sriov_numvfs before those VFs are probed. Suggested-by: Leon Romanovsky Signed-off-by: Jim Harris --- drivers/pci/iov.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 0ca20cd518d5..ebb7c6892ad6 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -673,12 +673,14 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) msleep(100); pci_cfg_access_unlock(dev); + iov->num_VFs = nr_virtfn; rc = sriov_add_vfs(dev, initial); - if (rc) + if (rc) { + iov->num_VFs = 0; goto err_pcibios; + } kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); - iov->num_VFs = nr_virtfn; return 0;