All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sinan Kaya <okaya@codeaurora.org>
To: linux-pci@vger.kernel.org, timur@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Sinan Kaya <okaya@codeaurora.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: [PATCH V2 1/7] PCI: protect restore with device lock to be consistent
Date: Mon, 27 Nov 2017 01:20:22 -0500	[thread overview]
Message-ID: <1511763628-11856-2-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1511763628-11856-1-git-send-email-okaya@codeaurora.org>

Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage
with device_lock()") added protection around pci_dev_restore() function so
that device specific remove callback does not cause a race condition
against hotplug.

pci_dev_lock() usage has been forgotten in two different places in the
code. Adding locks for pci_slot_restore() and moving pci_dev_restore()
inside the locks for pci_try_reset_function().

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6078dfc..23681f4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4344,9 +4344,9 @@ int pci_try_reset_function(struct pci_dev *dev)
 
 	pci_dev_save_and_disable(dev);
 	rc = __pci_reset_function_locked(dev);
+	pci_dev_restore(dev);
 	pci_dev_unlock(dev);
 
-	pci_dev_restore(dev);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(pci_try_reset_function);
@@ -4546,7 +4546,9 @@ static void pci_slot_restore(struct pci_slot *slot)
 	list_for_each_entry(dev, &slot->bus->devices, bus_list) {
 		if (!dev->slot || dev->slot != slot)
 			continue;
+		pci_dev_lock(dev);
 		pci_dev_restore(dev);
+		pci_dev_unlock(dev);
 		if (dev->subordinate)
 			pci_bus_restore(dev->subordinate);
 	}
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Sinan Kaya <okaya@codeaurora.org>
To: linux-pci@vger.kernel.org, timur@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Sinan Kaya <okaya@codeaurora.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH V2 1/7] PCI: protect restore with device lock to be consistent
Date: Mon, 27 Nov 2017 01:20:22 -0500	[thread overview]
Message-ID: <1511763628-11856-2-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1511763628-11856-1-git-send-email-okaya@codeaurora.org>

Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage
with device_lock()") added protection around pci_dev_restore() function so
that device specific remove callback does not cause a race condition
against hotplug.

pci_dev_lock() usage has been forgotten in two different places in the
code. Adding locks for pci_slot_restore() and moving pci_dev_restore()
inside the locks for pci_try_reset_function().

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6078dfc..23681f4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4344,9 +4344,9 @@ int pci_try_reset_function(struct pci_dev *dev)
 
 	pci_dev_save_and_disable(dev);
 	rc = __pci_reset_function_locked(dev);
+	pci_dev_restore(dev);
 	pci_dev_unlock(dev);
 
-	pci_dev_restore(dev);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(pci_try_reset_function);
@@ -4546,7 +4546,9 @@ static void pci_slot_restore(struct pci_slot *slot)
 	list_for_each_entry(dev, &slot->bus->devices, bus_list) {
 		if (!dev->slot || dev->slot != slot)
 			continue;
+		pci_dev_lock(dev);
 		pci_dev_restore(dev);
+		pci_dev_unlock(dev);
 		if (dev->subordinate)
 			pci_bus_restore(dev->subordinate);
 	}
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Sinan Kaya <okaya@codeaurora.org>
To: linux-pci@vger.kernel.org, timur@codeaurora.org
Cc: Sinan Kaya <okaya@codeaurora.org>,
	linux-arm-msm@vger.kernel.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	open list <linux-kernel@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 1/7] PCI: protect restore with device lock to be consistent
Date: Mon, 27 Nov 2017 01:20:22 -0500	[thread overview]
Message-ID: <1511763628-11856-2-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1511763628-11856-1-git-send-email-okaya@codeaurora.org>

Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage
with device_lock()") added protection around pci_dev_restore() function so
that device specific remove callback does not cause a race condition
against hotplug.

pci_dev_lock() usage has been forgotten in two different places in the
code. Adding locks for pci_slot_restore() and moving pci_dev_restore()
inside the locks for pci_try_reset_function().

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6078dfc..23681f4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4344,9 +4344,9 @@ int pci_try_reset_function(struct pci_dev *dev)
 
 	pci_dev_save_and_disable(dev);
 	rc = __pci_reset_function_locked(dev);
+	pci_dev_restore(dev);
 	pci_dev_unlock(dev);
 
-	pci_dev_restore(dev);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(pci_try_reset_function);
@@ -4546,7 +4546,9 @@ static void pci_slot_restore(struct pci_slot *slot)
 	list_for_each_entry(dev, &slot->bus->devices, bus_list) {
 		if (!dev->slot || dev->slot != slot)
 			continue;
+		pci_dev_lock(dev);
 		pci_dev_restore(dev);
+		pci_dev_unlock(dev);
 		if (dev->subordinate)
 			pci_bus_restore(dev->subordinate);
 	}
-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: okaya@codeaurora.org (Sinan Kaya)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 1/7] PCI: protect restore with device lock to be consistent
Date: Mon, 27 Nov 2017 01:20:22 -0500	[thread overview]
Message-ID: <1511763628-11856-2-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1511763628-11856-1-git-send-email-okaya@codeaurora.org>

Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage
with device_lock()") added protection around pci_dev_restore() function so
that device specific remove callback does not cause a race condition
against hotplug.

pci_dev_lock() usage has been forgotten in two different places in the
code. Adding locks for pci_slot_restore() and moving pci_dev_restore()
inside the locks for pci_try_reset_function().

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6078dfc..23681f4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4344,9 +4344,9 @@ int pci_try_reset_function(struct pci_dev *dev)
 
 	pci_dev_save_and_disable(dev);
 	rc = __pci_reset_function_locked(dev);
+	pci_dev_restore(dev);
 	pci_dev_unlock(dev);
 
-	pci_dev_restore(dev);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(pci_try_reset_function);
@@ -4546,7 +4546,9 @@ static void pci_slot_restore(struct pci_slot *slot)
 	list_for_each_entry(dev, &slot->bus->devices, bus_list) {
 		if (!dev->slot || dev->slot != slot)
 			continue;
+		pci_dev_lock(dev);
 		pci_dev_restore(dev);
+		pci_dev_unlock(dev);
 		if (dev->subordinate)
 			pci_bus_restore(dev->subordinate);
 	}
-- 
1.9.1

  reply	other threads:[~2017-11-27  6:20 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27  6:20 [PATCH V2 0/7] PCI: handle CRS response following Hot Reset and D3hot->D0 Sinan Kaya
2017-11-27  6:20 ` Sinan Kaya
2017-11-27  6:20 ` Sinan Kaya [this message]
2017-11-27  6:20   ` [PATCH V2 1/7] PCI: protect restore with device lock to be consistent Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:36   ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-27  6:20 ` [PATCH V2 2/7] PCI: handle FLR failure and allow other reset types Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:36   ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-29 17:36     ` Christoph Hellwig
2017-11-27  6:20 ` [PATCH V2 3/7] PCI: make pci_flr_wait() generic and rename to pci_dev_wait() Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:38   ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-12-04 13:17     ` Sinan Kaya
2017-12-04 13:17       ` Sinan Kaya
2017-12-04 13:17       ` Sinan Kaya
2017-12-13 22:43   ` Bjorn Helgaas
2017-12-13 22:43     ` Bjorn Helgaas
2017-12-13 22:43     ` Bjorn Helgaas
2018-01-02 15:47     ` Sinan Kaya
2018-01-02 15:47       ` Sinan Kaya
2017-11-27  6:20 ` [PATCH V2 4/7] PCI: wait device ready after pci_pm_reset() Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:38   ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-11-27  6:20 ` [PATCH V2 5/7] PCI: add a return type for pci_reset_bridge_secondary_bus() Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:38   ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-11-29 17:38     ` Christoph Hellwig
2017-11-27  6:20 ` [PATCH V2 6/7] PCI: add device wait after slot and bus reset Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-29 17:39   ` Christoph Hellwig
2017-11-29 17:39     ` Christoph Hellwig
2017-11-29 17:39     ` Christoph Hellwig
2017-11-27  6:20 ` [PATCH V2 7/7] PCI: make reset poll time adjustable Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-27  6:20   ` Sinan Kaya
2017-11-28 14:20   ` Bjorn Helgaas
2017-11-28 14:20     ` Bjorn Helgaas
2017-11-28 14:20     ` Bjorn Helgaas
2017-11-28 14:26     ` Sinan Kaya
2017-11-28 14:26       ` Sinan Kaya

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=1511763628-11856-2-git-send-email-okaya@codeaurora.org \
    --to=okaya@codeaurora.org \
    --cc=bhelgaas@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=timur@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.