diff mbox series

[v10,3/7] PCI/ERR: add mutex to synchronize recovery

Message ID 1519315332-26852-4-git-send-email-poza@codeaurora.org
State Superseded
Headers show
Series Address error and recovery for AER and DPC | expand

Commit Message

Oza Pawandeep Feb. 22, 2018, 4:02 p.m. UTC
This patch protects pci_do_recovery with mutex.

Signed-off-by: Oza Pawandeep <poza@codeaurora.org>

Comments

Christoph Hellwig Feb. 22, 2018, 6:36 p.m. UTC | #1
On Thu, Feb 22, 2018 at 09:32:08PM +0530, Oza Pawandeep wrote:
> This patch protects pci_do_recovery with mutex.

Do we really want a global mutex for this and not one per root complex
at very least?
Oza Pawandeep Feb. 23, 2018, 5:27 a.m. UTC | #2
On 2018-02-23 00:06, Christoph Hellwig wrote:
> On Thu, Feb 22, 2018 at 09:32:08PM +0530, Oza Pawandeep wrote:
>> This patch protects pci_do_recovery with mutex.
> 
> Do we really want a global mutex for this and not one per root complex
> at very least?

This protects pcie_do_recovery, which is called by port service drivers.
mainly aer and dpc as of now. so the association is not root complex 
agents
instead service drivers who attempts to do link recovery.

so I think we are good here.
diff mbox series

Patch

diff --git a/drivers/pci/pcie/pcie-err.c b/drivers/pci/pcie/pcie-err.c
index a532fe0..8318c84 100644
--- a/drivers/pci/pcie/pcie-err.c
+++ b/drivers/pci/pcie/pcie-err.c
@@ -20,6 +20,8 @@ 
 #include <linux/pcieport_if.h>
 #include "portdrv.h"
 
+static DEFINE_MUTEX(pci_err_recovery_lock);
+
 struct aer_broadcast_data {
 	enum pci_channel_state state;
 	enum pci_ers_result result;
@@ -283,6 +285,8 @@  void pci_do_recovery(struct pci_dev *dev, int severity)
 	pci_ers_result_t status, result = PCI_ERS_RESULT_RECOVERED;
 	enum pci_channel_state state;
 
+	mutex_lock(&pci_err_recovery_lock);
+
 	if (severity == AER_FATAL)
 		state = pci_channel_io_frozen;
 	else
@@ -326,9 +330,11 @@  void pci_do_recovery(struct pci_dev *dev, int severity)
 				report_resume);
 
 	dev_info(&dev->dev, "Device recovery successful\n");
+	mutex_unlock(&pci_err_recovery_lock);
 	return;
 
 failed:
 	/* TODO: Should kernel panic here? */
 	dev_info(&dev->dev, "Device recovery failed\n");
+	mutex_unlock(&pci_err_recovery_lock);
 }