public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] [PCI] Check that MWI bit really did get set
@ 2006-10-06 19:05 Matthew Wilcox
  2006-10-06 19:05 ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2006-10-06 19:05 UTC (permalink / raw)
  To: Val Henson, Greg Kroah-Hartman
  Cc: netdev, linux-pci, linux-kernel, Matthew Wilcox

Since some devices may not implement the MWI bit, we should check that
the write did set it and return an error if it didn't.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..3d041f4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -900,13 +900,17 @@ #endif
 		return rc;
 
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	if (! (cmd & PCI_COMMAND_INVALIDATE)) {
-		pr_debug("PCI: Enabling Mem-Wr-Inval for device %s\n", pci_name(dev));
-		cmd |= PCI_COMMAND_INVALIDATE;
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	
-	return 0;
+	if (cmd & PCI_COMMAND_INVALIDATE)
+		return 0;
+
+	pr_debug("PCI: Enabling Mem-Wr-Inval for device %s\n", pci_name(dev));
+	cmd |= PCI_COMMAND_INVALIDATE;
+	pci_write_config_word(dev, PCI_COMMAND, cmd);
+
+	/* read result from hardware (in case bit refused to enable) */
+	pci_read_config_word(dev, PCI_COMMAND, &cmd);
+
+	return (cmd & PCI_COMMAND_INVALIDATE) ? 0 : -EINVAL;
 }
 
 /**

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-10-07 14:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.5vbPpPQ5p6Rqb6w5IQvYeIEZ+o4@ifi.uio.no>
     [not found] ` <fa.5fHFiSyxiA8IzX/z36b4ccRdkwk@ifi.uio.no>
     [not found]   ` <fa.xexLYpZ2s3jlzi3H4j8CMu5nU5M@ifi.uio.no>
     [not found]     ` <fa.DScE5F/ioZsTJQxVaKgCvzyY/+o@ifi.uio.no>
     [not found]       ` <fa.lMwhGlM7h3gT94gAUyYURPCF1Qg@ifi.uio.no>
2006-10-07  0:15         ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Robert Hancock
2006-10-06 19:05 [PATCH 1/2] [PCI] Check that MWI bit really did get set Matthew Wilcox
2006-10-06 19:05 ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Matthew Wilcox
2006-10-06 19:15   ` Jeff Garzik
2006-10-06 19:28     ` Matthew Wilcox
2006-10-06 19:59       ` Jeff Garzik
2006-10-07  5:34         ` Grant Grundler
2006-10-07 14:44           ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox