diff options
Diffstat (limited to 'bsd')
-rw-r--r-- | bsd/ati_pcigart.h | 2 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 20 | ||||
-rw-r--r-- | bsd/drm_os_netbsd.h | 20 |
3 files changed, 32 insertions, 10 deletions
diff --git a/bsd/ati_pcigart.h b/bsd/ati_pcigart.h index 0cc63a3a..b5fe35c8 100644 --- a/bsd/ati_pcigart.h +++ b/bsd/ati_pcigart.h @@ -86,6 +86,8 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, } } + DRM_MEMORYBARRIER(); + ret = 1; done: diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 8331d246..7b19acc2 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -114,7 +114,6 @@ #define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 #define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) #define DRM_FREE(pt,size) free( pt, DRM(M_DRM) ) -#define DRM_VTOPHYS(addr) vtophys(addr) /* Read/write from bus space, with byteswapping to le if necessary */ #define DRM_READ8(map, offset) *(volatile u_int8_t *) (((unsigned long)(map)->handle) + (offset)) @@ -206,10 +205,21 @@ while (!condition) { \ #define DRM_GET_USER_UNCHECKED(val, uaddr) \ ((val) = fuword(uaddr), 0) -#define DRM_WRITEMEMORYBARRIER( map ) \ - bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, 0); -#define DRM_READMEMORYBARRIER( map ) \ - bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, BUS_SPACE_BARRIER_READ); +/* DRM_READMEMORYBARRIER() prevents reordering of reads. + * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. + * DRM_MEMORYBARRIER() prevents reordering of reads and writes. + */ +#if defined(__i386__) +#define DRM_READMEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%esp)" : : : "memory"); +#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); +#define DRM_MEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%esp)" : : : "memory"); +#elif defined(__alpha__) +#define DRM_READMEMORYBARRIER() alpha_mb(); +#define DRM_WRITEMEMORYBARRIER() alpha_wmb(); +#define DRM_MEMORYBARRIER() alpha_mb(); +#endif #define PAGE_ALIGN(addr) round_page(addr) diff --git a/bsd/drm_os_netbsd.h b/bsd/drm_os_netbsd.h index 7a6f9821..246ebdc6 100644 --- a/bsd/drm_os_netbsd.h +++ b/bsd/drm_os_netbsd.h @@ -94,7 +94,6 @@ extern const int DRM(M_DRM) = M_DEVBUF; #endif /* __NetBSD_Version__ */ #define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) #define DRM_FREE(pt,size) free( pt, DRM(M_DRM) ) -#define DRM_VTOPHYS(addr) vtophys(addr) #define DRM_READ8(map, offset) bus_space_read_1( (map)->iot, (map)->ioh, (offset) ) #define DRM_READ32(map, offset) bus_space_read_4( (map)->iot, (map)->ioh, (offset) ) @@ -173,10 +172,21 @@ while (!condition) { \ #define DRM_GET_USER_UNCHECKED(val, uaddr) \ ((val) = fuword(uaddr), 0) -#define DRM_WRITEMEMORYBARRIER( map ) \ - bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, 0); -#define DRM_READMEMORYBARRIER( map ) \ - bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, BUS_SPACE_BARRIER_READ); +/* DRM_READMEMORYBARRIER() prevents reordering of reads. + * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. + * DRM_MEMORYBARRIER() prevents reordering of reads and writes. + */ +#if defined(__i386__) +#define DRM_READMEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%esp)" : : : "memory"); +#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); +#define DRM_MEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%esp)" : : : "memory"); +#elif defined(__alpha__) +#define DRM_READMEMORYBARRIER() alpha_mb(); +#define DRM_WRITEMEMORYBARRIER() alpha_wmb(); +#define DRM_MEMORYBARRIER() alpha_mb(); +#endif #define DRM_WAKEUP(w) wakeup((void *)w) #define DRM_WAKEUP_INT(w) wakeup(w) |