Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Leave it entirely up to the driver whether to ma...



details:   https://anonhg.NetBSD.org/src/rev/53e8df35cb18
branches:  trunk
changeset: 967194:53e8df35cb18
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Dec 02 17:13:13 2019 +0000

description:
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.

diffstat:

 sys/dev/pci/pci_map.c |  22 ++--------------------
 1 files changed, 2 insertions(+), 20 deletions(-)

diffs (43 lines):

diff -r 327e57e87b76 -r 53e8df35cb18 sys/dev/pci/pci_map.c
--- a/sys/dev/pci/pci_map.c     Mon Dec 02 16:59:28 2019 +0000
+++ b/sys/dev/pci/pci_map.c     Mon Dec 02 17:13:13 2019 +0000
@@ -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 @@
        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;
 



Home | Main Index | Thread Index | Old Index