linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pierre Crégut" <pierre.cregut@orange.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Pierre Crégut" <pierre.cregut@orange.com>
Subject: [PATCH v2] PCI/IOV: avoid giving back wrong numvfs
Date: Wed, 11 Sep 2019 09:27:36 +0200	[thread overview]
Message-ID: <20190911072736.32091-1-pierre.cregut@orange.com> (raw)

When numvfs is being updated, reply to numvfs queries with EAGAIN.
As drivers may notify changes on numvfs before they are implemented,
it is advisable to not reply rather than giving back an outdated value.
Clients will notice that the value is still unknown and will retry
to get it.

The patch relies on the status of the device mutex as an
overapproximation of when numvfs is modified.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=202991
Signed-off-by: Pierre Crégut <pierre.cregut@orange.com>
---

This is an updated version of "PCI/IOV: update num_VFs earlier" and a
reply to your mail sent on 14/06/19. Sorry I completely missed it.
The commit message was changed as the implementation principle was
modified.

 drivers/pci/pci-sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 965c72104150..493eea261d40 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -568,6 +568,8 @@ static ssize_t sriov_numvfs_show(struct device *dev,
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 
+	if (mutex_is_locked(&dev->mutex))
+		return -EAGAIN;
 	return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
 }
 
-- 
2.17.1


                 reply	other threads:[~2019-09-11  7:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190911072736.32091-1-pierre.cregut@orange.com \
    --to=pierre.cregut@orange.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).