Skip to contentSkip to conversation

PCIE AER: PCI access remove spinlock protection in aer_inject

PATCH In review Youquan,Song 2 participants 2 messages Jan 28, 2010 – Jan 29, 2010 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCIE AER: PCI access remove spinlock protection in aer_inject

Move the PCI configuration access code out of the spin_lock protection because pci_read_aer already includes spin_lock protection which will replace the PCI access method if have aer error injected.

---

drivers/pci/pcie/aer/aer_inject.c +16 -18
index 8c30a95..953a0b9 100644
@@ -357,6 +357,22 @@ static int aer_inject(struct aer_error_inj *einj)
 		goto out_put;
 	}
 
+	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_COR_MASK, &mask);
+	if (einj->cor_status && !(einj->cor_status & ~mask)) {
+		ret = -EINVAL;
+		printk(KERN_WARNING "The correctable error(s) is masked "
+				"by device\n");
+		goto out_put;
+	}
+
+	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_UNCOR_MASK, &mask);
+	if (einj->uncor_status && !(einj->uncor_status & ~mask)) {
+		ret = -EINVAL;
+		printk(KERN_WARNING "The uncorrectable error(s) is masked "
+				"by device\n");
+		goto out_put;
+	}
+
 	spin_lock_irqsave(&inject_lock, flags);
 
 	err = __find_aer_error_by_dev(dev);
@@ -374,24 +390,6 @@ static int aer_inject(struct aer_error_inj *einj)
 	err->header_log2 = einj->header_log2;
 	err->header_log3 = einj->header_log3;
 
-	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_COR_MASK, &mask);
-	if (einj->cor_status && !(einj->cor_status & ~mask)) {
-		ret = -EINVAL;
-		printk(KERN_WARNING "The correctable error(s) is masked "
-				"by device\n");
-		spin_unlock_irqrestore(&inject_lock, flags);
-		goto out_put;
-	}
-
-	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_UNCOR_MASK, &mask);
-	if (einj->uncor_status && !(einj->uncor_status & ~mask)) {
-		ret = -EINVAL;
-		printk(KERN_WARNING "The uncorrectable error(s) is masked "
-				"by device\n");
-		spin_unlock_irqrestore(&inject_lock, flags);
-		goto out_put;
-	}
-
 	rperr = __find_aer_error_by_dev(rpdev);
 	if (!rperr) {
 		rperr = rperr_alloc;
#1 lore raw
Quoted 7 lines · Youquan,Song

Move the PCI configuration access code out of the spin_lock protection because pci_read_aer already includes spin_lock protection which will replace the PCI access method if have aer error injected.

---

I posted a similar patch on the linux-pci mailing list -- details at:

http://www.spinics.net/lists/linux-pci/msg07609.html

This version has already been accepted in the linux-pci tree. I should have cc'd lkml.

Andrew

Quoted 58 lines
drivers/pci/pcie/aer/aer_inject.c +16 -19
index 8c30a95..953a0b9 100644
@@ -357,6 +357,22 @@ static int aer_inject(struct aer_error_inj *einj)
 		goto out_put;
 	}
 
+	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_COR_MASK, &mask);
+	if (einj->cor_status && !(einj->cor_status & ~mask)) {
+		ret = -EINVAL;
+		printk(KERN_WARNING "The correctable error(s) is masked "
+				"by device\n");
+		goto out_put;
+	}
+
+	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_UNCOR_MASK, &mask);
+	if (einj->uncor_status && !(einj->uncor_status & ~mask)) {
+		ret = -EINVAL;
+		printk(KERN_WARNING "The uncorrectable error(s) is masked "
+				"by device\n");
+		goto out_put;
+	}
+
 	spin_lock_irqsave(&inject_lock, flags);
 
 	err = __find_aer_error_by_dev(dev);
@@ -374,24 +390,6 @@ static int aer_inject(struct aer_error_inj *einj)
 	err->header_log2 = einj->header_log2;
 	err->header_log3 = einj->header_log3;
 
-	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_COR_MASK, &mask);
-	if (einj->cor_status && !(einj->cor_status & ~mask)) {
-		ret = -EINVAL;
-		printk(KERN_WARNING "The correctable error(s) is masked "
-				"by device\n");
-		spin_unlock_irqrestore(&inject_lock, flags);
-		goto out_put;
-	}
-
-	pci_read_config_dword(dev, pos_cap_err + PCI_ERR_UNCOR_MASK, &mask);
-	if (einj->uncor_status && !(einj->uncor_status & ~mask)) {
-		ret = -EINVAL;
-		printk(KERN_WARNING "The uncorrectable error(s) is masked "
-				"by device\n");
-		spin_unlock_irqrestore(&inject_lock, flags);
-		goto out_put;
-	}
-
 	rperr = __find_aer_error_by_dev(rpdev);
 	if (!rperr) {
 		rperr = rperr_alloc;
--

To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Andrew Patterson
Hewlett-Packard