> Date: Tue, 27 Nov 2012 15:02:31 +0100
> From: Martin Pieuchot <[email protected]>
> 
> While working on drm support for macppc that makes use of non-cached
> memory I found that some platforms (amd64, i386, powerpc) use the MD
> PMAP_NOCACHE flag where others (sparc, sparc64, solbourne) use PMAP_NC
> for the same purpose.
> 
> Because I'd like to use this flag in the drm code and for coherency
> the diff below rename PMAP_NOCACHE into PMAP_NC.
> 
> Tested on macppc and amd64, ok?

Hi Martin,

These flags are not really supposed to be used in MI code.  So I don't
think the drm and agp code should use these flags, at least not
directly.  Fortunately doing so isn't really necessary, at least for
the agp stuff.  There we can do something like:


Index: agpvar.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/agpvar.h,v
retrieving revision 1.22
diff -u -p -r1.22 agpvar.h
--- agpvar.h    10 May 2010 22:06:04 -0000      1.22
+++ agpvar.h    28 Nov 2012 15:42:04 -0000
@@ -126,6 +126,7 @@ struct agp_softc {
        bus_dma_tag_t                    sc_dmat;
        pci_chipset_tag_t                sc_pc;
        pcitag_t                         sc_pcitag;
+       bus_space_tag_t                  sc_memt;
        bus_addr_t                       sc_apaddr;
        bus_size_t                       sc_apsize;
        pcireg_t                         sc_id;
Index: agp.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/agp.c,v
retrieving revision 1.35
diff -u -p -r1.35 agp.c
--- agp.c       13 Nov 2012 13:37:24 -0000      1.35
+++ agp.c       28 Nov 2012 15:42:04 -0000
@@ -187,6 +187,7 @@ agp_attach(struct device *parent, struct
        sc->sc_pcitag = pa->pa_tag;
        sc->sc_pc = pa->pa_pc;
        sc->sc_id = pa->pa_id;
+       sc->sc_memt = pa->pa_memt;
        sc->sc_dmat = pa->pa_dmat;
 
        pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP,
@@ -214,17 +215,15 @@ agpmmap(dev_t dev, off_t off, int prot)
                return (-1);
 
        if (sc->sc_apaddr) {
-
                if (off > sc->sc_apsize)
                        return (-1);
 
-               /*
-                * XXX this should use bus_space_mmap() but it's not
-                * availiable on all archs.
-                */
-               return (sc->sc_apaddr + off);
+               return bus_space_mmap(sc->sc_memt, sc->sc_apaddr, off, prot, 0);
        }
-       return (-1);
+
+       ...
+
+       return bus_dmamem_mmap(sc->sc_dmat, ...., off, prot, BUS_DMA_NOCACHE);
 }
 
 int


Where the ... bit would be the code you wrote to figure out the right
struct agp_memory for the offset.

Reply via email to