Module Name:    src
Committed By:   riastradh
Date:           Mon Dec  2 17:13:13 UTC 2019

Modified Files:
        src/sys/dev/pci: pci_map.c

Log Message:
Leave it entirely up to the driver whether to map prefetchable.

We have only a few drivers that pass BUS_SPACE_MAP_PREFETCHABLE to
pci_mapreg_map -- dev/pci/if_hme_pci.c, dev/pci/igma.c,
dev/pci/radeonfb.c, dev/pci/wcfb.c -- and they all do it for ROM or
framebuffers.

Based on a subthread from macallan@ in the earlier discussion:

https://mail-index.NetBSD.org/tech-kern/2017/03/23/msg021685.html

The thrust is that:
- a driver not asking for prefetchable mappings shouldn't get it
- some devices are correctly used with prefetchable mappings, but for
  some reason fail to set the prefetchable bit in the BAR
- nobody could identify any classes of device for which
  (a) the driver asks for prefetchable mappings, but
  (b) certain matching devices can't actually be used with
      prefetchable mappings

This brings pci_mapreg_map in line with what the documentation says;
the documentation never advertised that the prefetchable bit in the
BAR could cause the bus_space mapping to be prefetchable.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/pci_map.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci_map.c
diff -u src/sys/dev/pci/pci_map.c:1.38 src/sys/dev/pci/pci_map.c:1.39
--- src/sys/dev/pci/pci_map.c:1.38	Mon Dec  2 08:33:42 2019
+++ src/sys/dev/pci/pci_map.c	Mon Dec  2 17:13:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_map.c,v 1.38 2019/12/02 08:33:42 riastradh Exp $	*/
+/*	$NetBSD: pci_map.c,v 1.39 2019/12/02 17:13:13 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.38 2019/12/02 08:33:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.39 2019/12/02 17:13:13 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -328,24 +328,6 @@ pci_mapreg_submap(const struct pci_attac
 	if (realmaxsize < (offset + reqsize))
 		return 1;
 
-	/*
-	 * If the BAR doesn't say prefetchable, assume the mapping
-	 * cannot be prefetchable.  In other words, we will use
-	 * BUS_SPACE_MAP_PREFETCHABLE only if the driver requested it
-	 * _and_ the BAR indicates it is prefetchable.
-	 *
-	 * Drivers that expect prefetchable memory will issue the
-	 * appropriate barriers, whereas drivers that do not expect
-	 * prefetchable memory will be terribly confused if the memory
-	 * is mapped prefetchable.
-	 *
-	 * Drivers that want to override the BAR and map it with
-	 * BUS_SPACE_MAP_PREFETCHABLE anyway can use pci_mapreg_map and
-	 * bus_space_map explicitly.
-	 */
-	if (!ISSET(flags, BUS_SPACE_MAP_PREFETCHABLE))
-		busflags &= ~BUS_SPACE_MAP_PREFETCHABLE;
-
 	if (bus_space_map(tag, base, reqsize, busflags, &handle))
 		return 1;
 

Reply via email to