From patchwork Wed Feb 14 22:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Harris X-Patchwork-Id: 201173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp33984dyb; Wed, 14 Feb 2024 15:01:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUhAmk/KRm4PTiq0s3IAIJTRnD4Pt4ULJ38TJE7vXNNyCDtOJFid9V9B8y1zN9RWy7afzarEQ93PmBaBFY0oQXJmWJaAA== X-Google-Smtp-Source: AGHT+IGh85qKq3sl5Nt/q62sIvvQ+Hl9ix+zgLyPcqWvhI//bU+Lp2/4rzJFo8Qa8Pr9Em+67IM7 X-Received: by 2002:a05:6808:16a0:b0:3bd:bef9:84b9 with SMTP id bb32-20020a05680816a000b003bdbef984b9mr251784oib.33.1707951667009; Wed, 14 Feb 2024 15:01:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707951666; cv=pass; d=google.com; s=arc-20160816; b=t3ydDTzjTAo683p044dDeHFDaY0knslrw48LewKvRhlPYIpE8Ifsx2kKCZBmokv0io Lc8Oc/vTseQZbI+ucpuHKfmv18H9J3oom5PvFD57M7HDor4nAkBZEw+kvRYidjaDCYn2 76zfhoGtaO5huykAzbIn1CKBbFbhJ7/nt6fq3Acmq4QpBIbt7qne9q7RSCo7m2Bvk2ng MdYVgn03qi6TjaPGb1mXmY76UyilRn+aRAEw5XXABER3v4JjFJTSqYP1RRyI4XI6SCly 3ayQaRiC/hzQ5aefxKg+qs/hDjQLkwjC6rNkn1iNTAdgUzSoop4b/wVAOIwrrps3b2hP POiQ== 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=NWHjQPlaGIQ9OtliJHmGY1JMnvToGgMO8MA8ryL6e5g=; fh=JCCJgeotx/m0tnisC8Wo8fH5XA3UmgP9gd185wPI8pc=; b=QLF+Dt+fqFBZNw6lgYd27xTdIncNKOs9J3FNlTrnSx6j86e4BLCRCfwCLoV3o180AD Rp2AQUAVZFFzgzFLDT5ln65xlggqSI/wmhzPZSP+AMXECuX/zp2r9d505TvXMfk1WkNw hdsd+Zpw2mx32fVrOmr6I+lEMEJMh86N1RIaqFTezWqJcDXpbZQlCkBdxQ75cyd56GOd inVM+W1bufrG2iIdNNlqJpHXvpne+M1LFCkYt7KetztbrWymfD7/3E1Vw3i6wwQM64Vo KBtZXKoXvzJ+P7+W+h/E3Pijk5lS1P2u9QX1G7TH0oGpy0wdZ/E1XXQxPIrsi2z7ECxs C3/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iISglxAa; 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-66091-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66091-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f16-20020ac84710000000b0042bee82eeb1si2947qtp.633.2024.02.14.15.01.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:01:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66091-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iISglxAa; 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-66091-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66091-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 766411C26548 for ; Wed, 14 Feb 2024 23:00:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 639091420D3; Wed, 14 Feb 2024 22:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="iISglxAa" Received: from mailout2.w2.samsung.com (mailout2.w2.samsung.com [211.189.100.12]) (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 1C5E21419B1; Wed, 14 Feb 2024 22:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.189.100.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707951593; cv=none; b=bjj6MSPI8tQMYHXecL3F54QmII+uSXRpqlT+Fx7X+goPIuEiGtviOOPgLe588tYJuS2sqiv+JROW8z+XchgMTbbJ4cfii23vkzH34k+xYh+D9/3Hx/Er36sdrQPG5L946TOrW0w0JGUf2Rdl/DnCSEb3WkPt3aCThcl1bWS4TRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707951593; c=relaxed/simple; bh=NWHjQPlaGIQ9OtliJHmGY1JMnvToGgMO8MA8ryL6e5g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=pNeGITCqI5rJPkL/Zfv9SSGJ4rUtqEtjKU4Nv29BSmWP65fsGy3zSYfEIOk0BdEKcR4FQ2Ao3z8wTCIackDWa5J/UW4h9ws4Fn4dzxQpF45+U/TMXoOHoBSPi5qKN5sVsNu5PGDesz+DnFkzw/1eWiDbr2iQtT3cCHN2D0gEnlc= 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=iISglxAa; arc=none smtp.client-ip=211.189.100.12 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 mailout2.w2.samsung.com (KnoxPortal) with ESMTP id 20240214225944usoutp029bb5161cc91390c85bc25f43697aa417~z3OrJ-v6e1082210822usoutp02V; Wed, 14 Feb 2024 22:59:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w2.samsung.com 20240214225944usoutp029bb5161cc91390c85bc25f43697aa417~z3OrJ-v6e1082210822usoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707951584; bh=NWHjQPlaGIQ9OtliJHmGY1JMnvToGgMO8MA8ryL6e5g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iISglxAa5pWGqgz0yG661PwTZzPlrNEUvdZ31H5On9wxXgrN1X2iShK05O9Ks6NAx 4A4+a0CB9WUE8a0AFvmq4yiNI4BR0w08DXVbCm+5khhNoTb7+kt0mqtfnVKn83Ka8y qQDfOeaA9qQhxMTnp0HZLmDaHq7KPgQHsd7UznT0= Received: from ussmges3new.samsung.com (u112.gpu85.samsung.co.kr [203.254.195.112]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214225944uscas1p26fa9f885a7fd56b6dfe1c7f1b7945330~z3Oqvi9Qb1133111331uscas1p2K; Wed, 14 Feb 2024 22:59:44 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges3new.samsung.com (USCPEMTA) with SMTP id 78.B6.09550.0E54DC56; Wed, 14 Feb 2024 17:59:44 -0500 (EST) Received: from ussmgxs2new.samsung.com (u91.gpu85.samsung.co.kr [203.254.195.91]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214225943uscas1p21ffa8b362bac11379168b83e42159160~z3OqcL0Yr3221832218uscas1p2B; Wed, 14 Feb 2024 22:59:43 +0000 (GMT) X-AuditID: cbfec370-bbbfe7000000254e-32-65cd45e06f44 Received: from SSI-EX2.ssi.samsung.com ( [105.128.3.66]) by ussmgxs2new.samsung.com (USCPEXMTA) with SMTP id 11.D5.45319.FD54DC56; Wed, 14 Feb 2024 17:59:43 -0500 (EST) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX2.ssi.samsung.com (105.128.2.227) 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:42 -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:42 -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 1/2] PCI/IOV: Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" Thread-Topic: [PATCH v3 1/2] PCI/IOV: Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" Thread-Index: AQHaX5l/Y5bHR2DvZ0+eeI1J9u0GaA== Date: Wed, 14 Feb 2024 22:59:42 +0000 Message-ID: <170795158249.2393.6069168125066679172.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: <84A3C9C8FC63C94C827BCF517FA70757@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+NgFnrJKsWRmVeSWpSXmKPExsWy7djX87oPXM+mGjz+yWnx7X8Pm8XdxxfY LKZPvcBoceJmI5vF6ptrGC1+XZzGarH/6XMWiyv/9jBarFp4jc3iTHeuxaYNT1gszs86xWIx b/1PRovLu+awWaz/+p7N4taEY0wOAh6zGy6yeLQcecvqsXjPSyaPTas62Tx6m9+xebQ8O8nm 8X7fVTaPqbPrPT5vkgvgjOKySUnNySxLLdK3S+DKaJqxh6Vgm0DF7cUN7A2MDQJdjJwcEgIm Ev2nd7F0MXJxCAmsZJS4fPAxlNPKJDF/8mQ2mKrNKydAJdYwSix9e58NwvnEKNF67AZUZhmj xN+fbxhBWtgENCV+XVnDBJIQEfjIKtG3Ywo7SEJYIFHi0LdbrCC2iECaxPreHhYIW0/i1/2l YM0sAqoS35r6wGp4BSIkdp76BRbnFIiS+P35BZjNKCAm8f0UyAJODmYBcYlbT+YzQdwqKLFo 9h5mCFtM4t+uh1A/KErc//4S6AYOoHpNifW79CFa7SQm3bnABmErSkzpfsgOsVZQ4uTMJywQ rZISB1fcgLJXc0p0H1aBsF0kLs1ay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7wACrVnid5DkCurmvAzSScj4bTLgjdLIaRqLLRNTGnJy7sQrq2JPfY E0ah0SHn5DqAs9DPxpLJSAL6onaHScDXhqjY2kzwPBP19YwJeZ6Hun72ebgjiYmepVWBvDUY ZXe0UDzPQznnPnjwDWaghnwHyVtnI9uNt6QO+BqnXDP+TzJOSTJOSTJOSboMhGbgq+Y4peII tzyeTQng5EpOHa8I2H9YaQET/+PZWM3u+8De/i2gGghoUA0QTch8xNna56xEHC0/eoxVHd6r UsexXDWYQ5MyX3Fn9yJWAhXyJPYQyyawqn+qgPaUagSrDaZcvwjTgAomZ9qcm6TNpuCycOvn K9kiadHn9qaYus2XfqH09LvRI6GSjsf5tbO5zDQdQSt2yZ7FnihuXiPcFvJBvGFRXOV0KUgp rG+ojbQ1zNp+Kef019bGrMvKCLF9Ey0ThTrrF/qZThlGVuC8GrV/mD61TWlpWrAjTIiZ+akV q7Tvd/annJ5W931r75or906aiwtW3tl4ZnC3s3AwMfFVLqpQv+6vr5AQYu+UtgVeMtLVUZ7A 7omwN4mCJHnbHxRFMsezjFu8uqwvbJu33aZ7l3uVrw46mpisfNP5RD8t1DXXKcl6WLk02Xmx hwzvPvhW4dhnX4tD+tZXyUguRr5sMaHi5H8Ami8tP44DAAA= X-CMS-MailID: 20240214225943uscas1p21ffa8b362bac11379168b83e42159160 CMS-TYPE: 301P X-CMS-RootMailID: 20240214225943uscas1p21ffa8b362bac11379168b83e42159160 References: <170795147587.2393.15577527626926144858.stgit@bgt-140510-bm01.eng.stellus.in> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790917127015027935 X-GMAIL-MSGID: 1790917127015027935 If an SR-IOV enabled device is held by vfio, and the device is removed, vfio will hold device lock and notify userspace of the removal. If userspace reads the sriov_numvfs sysfs entry, that thread will be blocked since sriov_numvfs_show() also tries to acquire the device lock. If that same thread is responsible for releasing the device to vfio, it results in a deadlock. The proper way to detect a change to the num_VFs value is to listen for a sysfs event, not to add a device_lock() on the attribute _show() in the kernel. This reverts commit 35ff867b76576e32f34c698ccd11343f7d616204. Revert had a small conflict, the sprintf() is now changed to sysfs_emit(). Link: https://lore.kernel.org/linux-pci/ZXJI5+f8bUelVXqu@ubuntu/ Suggested-by: Leon Romanovsky Reviewed-by: Leon Romanovsky Signed-off-by: Jim Harris --- drivers/pci/iov.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index aaa33e8dc4c9..0ca20cd518d5 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -395,14 +395,8 @@ static ssize_t sriov_numvfs_show(struct device *dev, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); - u16 num_vfs; - - /* Serialize vs sriov_numvfs_store() so readers see valid num_VFs */ - device_lock(&pdev->dev); - num_vfs = pdev->sriov->num_VFs; - device_unlock(&pdev->dev); - return sysfs_emit(buf, "%u\n", num_vfs); + return sysfs_emit(buf, "%u\n", pdev->sriov->num_VFs); } /* 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+/IIRxGYUEJP4fmoNWC+zgLjErSfzmSBO FZRYNHsP1NliEv92PWSDsBUl7n9/CXQDB1C9psT6XfoQrXYSxw8dgBqjKDGl+yE7xFpBiZMz n7BAtEpKHFxxgwXkFwmB9ZwSpxdNgJrvIrH072OovdISV69PhYpnS6xc38EEsktCoECi4UgQ RNhaYuGf9VC7+CT+/nrEOIFReRaSD2YhXDcLyXWzkFw3C8l1CxhZVzGKlxYX56anFhvnpZbr FSfmFpfmpesl5+duYgSmxtP/DhfsYLx166PeIUYmDsZDjBIczEoivJN6z6QK8aYkVlalFuXH F5XmpBYfYpTmYFES5zW0PZksJJCeWJKanZpakFoEk2Xi4JRqYLJ99ezBstcOy1oXLY9Icc4W kv9irslXOaN0LheD/I7q3UZ1R0IYMyVde/u/dS75NWeZXMfDK+veuYX/vXYxOTJBLLCGY8d3 r5+GDHmNblbyv38lnn7nfv2s6JN/q4r25zz9cODiz9X/b8Q8eZveZc0xb25HgrU416+35+qf H/2v0fX6jLmn4Ytmm9UXdt8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tu5byo4b9mmJs+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;