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: 201178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp45647dyb; Wed, 14 Feb 2024 15:24:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU/NIQzwOZxqmZShApioOl0zn2LeRTqaVqymqMdnCrRFxeTLnFfUbBbam1PA8hTvLprpeZHDMnaby6g3L83BIaw/FXOUw== X-Google-Smtp-Source: AGHT+IGvuK6WOI8kWjufDaP2EiRuiEH67QOVuIWeKWM2jX8A+p2zLNnqM57lAwC1iWJObq2q6LRB X-Received: by 2002:a05:6830:454:b0:6e2:e526:b0d9 with SMTP id d20-20020a056830045400b006e2e526b0d9mr29148otc.16.1707953049279; Wed, 14 Feb 2024 15:24:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707953049; cv=pass; d=google.com; s=arc-20160816; b=w52IDnIcTTNMjlg8BJRk4NMkWV7pcF0TaiRxU6Pr8gXxssbqu0vJPgQZg0k98lLF5d iALSh3Uh1pGmQ14EQvAg2uY1A27OIEWobYVBcCKVP3ezp2llMEdnDqwdKlDynZgdSepH iUaMLb9ndh6ze+lHfzz/xyw6Xgvn5S5YQV18Ixe13Zk8koZ4G+HKT3wMHHVwmJxrkDbc 22fGSmp0NXdQHNSiUXxsQPucGYjk21RYMrMJb/2mtwOjkEoiSBD6MzAgXrpkAp5+4f/N C8brpklownshQa7+TZdEF2nF4x5xgGw2y2c5PQyHpoC5r5xi4sMu+COtgSCz977v+WwU 1uqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-id :content-language:accept-language:in-reply-to:message-id:date :thread-index:thread-topic:subject:to:from:dkim-signature :dkim-filter; bh=4dqGokGdhy1xJ0FLPp2+hNGb5PkT3Xrir0Am1s+UV3I=; fh=WJ4xYHn7uNQrf8hTYNRFMD/YDFS8oLtFEjfreYfyNQU=; b=Wc9ggQz9DxFctM4xu5+FmBj7ppYJyr6B0jOZ9ZsmZktrPFmb43lF5uo19nxxgIMzTP aqrWvFp9CSLZ/z+uJKVvsIdf4H8DtbCEVxvX4kLxBhb91EHYr1IrZwZjYN6srM8XIB5l ZlV5EtF8NRCuLku5G3clJ1yUCaRyEPCb2V5aV/CcSrNc4v6UmrKfMqXTPPlOKz0rbHwC bDVTmyaxXDNwMfPBRAFFGVyE2FsjhRMHJ29LZ1FqCyIdagXi7Rg4oq+lKbRmyS+s14NS Pzh0bs8o8/GoXu69+YR+NcY4CQ/df5CGTU3igjVSpLgVfwp4f4MpW52S5sD6UVfQlPge QTNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MlBIxBfa; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-66090-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66090-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCWwzMqDMEOFRTzDobMEWkvz7i975yxZ4MMFpmyszigKwq+g+WJOv9JEohR0Ar91beKFZG2yBZZ1pKoNVky/dsjb10tSDA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t20-20020a63b254000000b005dc4e366f63si4626235pgo.787.2024.02.14.15.24.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:24:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66090-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MlBIxBfa; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-66090-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66090-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 19975B2676A for ; Wed, 14 Feb 2024 23:00:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D25521420CC; Wed, 14 Feb 2024 22:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MlBIxBfa" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJKsWRmVeSWpSXmKPExsWy7djX87pPXc+mGmxZy27x7X8Pm8XdxxfY LKZPvcBoceJmI5vF6ptrGC1+XZzGarH/6XMWiyv/9jBarFp4jc3iTHeuxaYNT1gszs86xWIx b/1PRovLu+awWaz/+p7N4taEY0wOAh6zGy6yeLQcecvqsXjPSyaPTas62Tx6m9+xebQ8O8nm 8X7fVTaPqbPrPT5vkgvgjOKySUnNySxLLdK3S+DKePS9gb1gC0fFg5e7WRoYZ3B0MXJySAiY SFzb/4O9i5GLQ0hgJaNE4+5ORginlUliw5HbzDBV9ze8ZoVIrGGUOPZgGxtIQkjgE6PEjwNm EIlljBIPF09nAkmwCWhK/LqyhgkkISLwkVWib8cUdpCEsIC7xLsJS1lBbBEBH4n/904yQdh6 Ev0zN4NNZRFQlfh2AqKGVyBS4sPzhWBncApESfz+/IIRxGYUEJP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P8rG0iVkMAyRom1jW4gNpuApsSvK2uYQIpEBD6y Snx+MJUdJCEs4C7xbsJSVhBbRMBH4v+9k0wQtp5E/8zNYINYBFQlvp2AqOEViJT48Hwhcxcj B9CCSIkJ10tAwpwCURK/P79gBLEZBcQkvp9aAzaGWUBc4taT+UwQVwtILNlznhnCFpV4+fgf K4StKHH/+0t2kJHMQHeu36UP0WoncfzQAagxihJTuh+yQ1wgKHFy5hMWiFZJiYMrbrBMYBSf hWTbLIRJs5BMmoVk0iwkkxYwsq5iFC8tLs5Nryg2zEst1ytOzC0uzUvXS87P3cQITB6n/x2O 3MF49NZHvUOMTByMhxglOJiVRHgn9Z5JFeJNSaysSi3Kjy8qzUktPsQozcGiJM5794FGqpBA emJJanZqakFqEUyWiYNTqoEp/5hHuALDXtYrHie3lKStF7J+r1VuqHQ2W+Hua6uWKzvjXCfK K/A3LCpP8Who+iJf4P7zTcXLthmm0pcFN7zZlNymf6qo5UFb4u6F66QmHt3S0640e3UT67L9 L35tu5byo4b9mmJs+4Jmn0pzdtNyX1HvxFNmRxar/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> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790918576653747415 X-GMAIL-MSGID: 1790918576653747415 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;