aboutsummaryrefslogtreecommitdiffstats
path: root/pci/pci-test-that-drivers-properly-call-pci_set_master.patch
blob: f3e1502991268e9ce7598e04bf189ea3051baeda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From torvalds@osdl.org Wed Mar  8 16:58:31 2006
Date: Wed, 8 Mar 2006 16:58:22 -0800 (PST)
From: Linus Torvalds <torvalds@osdl.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>, gregkh@suse.de
Subject: PCI: test that drivers properly call pci_set_master(dev)
Message-ID: <Pine.LNX.4.64.0603081654540.32577@g5.osdl.org>

[Note, this will not be sent to mainline, but is very good to have for -mm (gkh)]

Btw, this patch obviously depends on all drivers that depend on DMA doing
the proper "pci_set_master(dev)", but all the good drivers should do that
anyway.

The point being that this is not for general use, because it certainly
_can_ break some setups. But it should be an easy first thing to test, and
if it breaks some driver, that's interesting information in itself.


---
---
 drivers/pci/probe.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- gregkh-2.6.orig/drivers/pci/probe.c
+++ gregkh-2.6/drivers/pci/probe.c
@@ -639,6 +639,7 @@ static void pci_read_irq(struct pci_dev 
  */
 static int pci_setup_device(struct pci_dev * dev)
 {
+	u16 cmd;
 	u32 class;
 
 	sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
@@ -664,6 +665,12 @@ static int pci_setup_device(struct pci_d
 		if (class == PCI_CLASS_BRIDGE_PCI)
 			goto bad;
 		pci_read_irq(dev);
+		pci_read_config_word(dev, PCI_COMMAND, &cmd);
+		if (cmd & PCI_COMMAND_MASTER) {
+			printk("Turning off bus mastering on %s\n", pci_name(dev));
+			cmd &= ~PCI_COMMAND_MASTER;
+			pci_write_config_word(dev, PCI_COMMAND, cmd);
+		}
 		pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
 		pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor);
 		pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device);