DragonFly BSD
DragonFly test List (threaded) for 2012-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

PCIe memory mapped configuration


From: Romick <yellowrabbit2010@xxxxxxxxx>
Date: Tue, 19 Jun 2012 22:20:44 +1100

--Multipart_Tue_Jun_19_22:20:44_2012-1
Content-Type: text/plain; charset=US-ASCII


No more hang during boot. I'm happy :)

--Multipart_Tue_Jun_19_22:20:44_2012-1
Content-Type: text/plain; charset=US-ASCII

  with best reagrds, Yellow Rabbit
  DragonFly 3.1-DEVELOPMENT x86_64



--Multipart_Tue_Jun_19_22:20:44_2012-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="pcie.diff"
Content-Transfer-Encoding: 7bit

diff --git a/sys/bus/pci/pci.c b/sys/bus/pci/pci.c
index 7776803..1fb6d95 100644
--- a/sys/bus/pci/pci.c
+++ b/sys/bus/pci/pci.c
@@ -2455,6 +2455,7 @@ pci_add_map(device_t pcib, device_t bus, device_t dev,
     int prefetch)
 {
 	uint32_t map;
+	uint16_t old_cmd;
 	pci_addr_t base;
 	pci_addr_t start, end, count;
 	uint8_t ln2size;
@@ -2466,10 +2467,24 @@ pci_add_map(device_t pcib, device_t bus, device_t dev,
 	struct resource *res;
 
 	map = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4);
+
+   /* Disable access to device memory */
+	old_cmd = 0;
+	if (PCI_BAR_MEM(map)) {
+		old_cmd = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2);
+		cmd = old_cmd & ~PCIM_CMD_MEMEN;
+		PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, cmd, 2);
+	}
+
 	PCIB_WRITE_CONFIG(pcib, b, s, f, reg, 0xffffffff, 4);
 	testval = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4);
 	PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4);
 
+   /* Restore memory access mode */
+	if (PCI_BAR_MEM(map)) {
+		PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, old_cmd, 2);
+	}
+
 	if (PCI_BAR_MEM(map)) {
 		type = SYS_RES_MEMORY;
 		if (map & PCIM_BAR_MEM_PREFETCH)

--Multipart_Tue_Jun_19_22:20:44_2012-1--



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]