Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2012 19:26:40 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r233677 - head/sys/dev/pci
Message-ID:  <201203291926.q2TJQerd006952@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Mar 29 19:26:39 2012
New Revision: 233677
URL: http://svn.freebsd.org/changeset/base/233677

Log:
  Revert r233662 and generalize the hack.  Writing zero to BAR actually does
  not disable it and it is even harmful as hselasky found out.  Historically,
  this code was originated from (OLDCARD) CardBus driver and later leaked into
  PCI driver when CardBus was newbus'ified and refactored with PCI driver.
  However, it is not really necessary even for CardBus.
  
  Reviewed by:	hselasky, imp, jhb

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==============================================================================
--- head/sys/dev/pci/pci.c	Thu Mar 29 19:03:22 2012	(r233676)
+++ head/sys/dev/pci/pci.c	Thu Mar 29 19:26:39 2012	(r233677)
@@ -2590,27 +2590,6 @@ pci_write_bar(device_t dev, struct pci_m
 	struct pci_devinfo *dinfo;
 	int ln2range;
 
-	/*
-	 * Don't disable BARs on AGP devices. In general: Don't
-	 * disable BARs on any PCI display devices, because doing that
-	 * can sometimes cause the main memory bus to stop working,
-	 * causing all memory reads to return nothing but 0xFFFFFFFF,
-	 * even though the memory location was previously written.
-	 * After a while a privileged instruction fault will appear
-	 * and then nothing more can be debugged.
-	 * The reason for this behaviour is unknown.
-	 */
-	if (base == 0 && pci_get_class(dev) == PCIC_DISPLAY) {
-		device_printf(device_get_parent(dev),
-		    "pci%d:%d:%d:%d BARs on display devices "
-		    "should not be disabled.\n",
-		    pci_get_domain(dev),
-		    pci_get_bus(dev),
-		    pci_get_slot(dev),
-		    pci_get_function(dev));
-		return;
-	}
-
 	/* The device ROM BAR is always a 32-bit memory BAR. */
 	dinfo = device_get_ivars(dev);
 	if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg))
@@ -2838,16 +2817,15 @@ pci_add_map(device_t bus, device_t dev, 
 	    prefetch ? RF_PREFETCHABLE : 0);
 	if (res == NULL) {
 		/*
-		 * If the allocation fails, clear the BAR and delete
-		 * the resource list entry to force
-		 * pci_alloc_resource() to allocate resources from the
-		 * parent.
+		 * If the allocation fails, delete the resource list entry
+		 * to force pci_alloc_resource() to allocate resources
+		 * from the parent.
 		 */
 		resource_list_delete(rl, type, reg);
-		start = 0;
-	} else
+	} else {
 		start = rman_get_start(res);
-	pci_write_bar(dev, pm, start);
+		pci_write_bar(dev, pm, start);
+	}
 	return (barlen);
 }
 
@@ -4381,19 +4359,6 @@ pci_delete_resource(device_t dev, device
 			    type, rid, rman_get_start(rle->res));
 			return;
 		}
-
-#ifndef __PCI_BAR_ZERO_VALID
-		/*
-		 * If this is a BAR, clear the BAR so it stops
-		 * decoding before releasing the resource.
-		 */
-		switch (type) {
-		case SYS_RES_IOPORT:
-		case SYS_RES_MEMORY:
-			pci_write_bar(child, pci_find_bar(child, rid), 0);
-			break;
-		}
-#endif
 		resource_list_unreserve(rl, dev, child, type, rid);
 	}
 	resource_list_delete(rl, type, rid);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203291926.q2TJQerd006952>