Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Oct 2005 11:29:50 +0200
From:      German Tischler <tanis@gaspode.franken.de>
To:        freebsd-multimedia@freebsd.org
Subject:   DRI on PCIe Radeon X300SE
Message-ID:  <4340FA0E.8000009@gaspode.franken.de>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------080506060601040701030604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi.

Has someone had success with any ATI Radeon PCI express cards and DRI ? 
dri-devel in the ports just locks up my machine (as expected, according 
to some postings on the DRI mailing lists, this was not supported for 
the version that is available in the ports). Using DRM from CVS and 
applying the attached patch, I end up with

drm0: <ATI Radeon X300SE> port 0x9000-0x90ff mem 
0xc0000000-0xc7ffffff,0xcf000000-0xcf00ffff irq 18 at device 0.0 on pci1
info: [drm] Initialized radeon 1.19.0 20050911
error: [drm:pid576:radeon_do_init_cp] *ERROR* Cannot use PCI Express 
without GART in FB memory

so I guess I have to update Mesa and/or the X-server to a version that 
places GART in the framebuffer memory. However I cannot get Mesa from 
CVS to compile, so I don't know, if it would be of any help. The patch 
is also not complete for every DRM module, but it lets me compile the 
drm.ko and radeon.ko modules.

Has someone else also looked at this or has patches to make a 
sufficiently recent version of Mesa compile on FreeBSD ?

regards
German Tischler


--------------080506060601040701030604
Content-Type: text/plain;
 name="drm.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="drm.patch"

diff -r -c drm/bsd-core/ati_pcigart.c drm-patched/bsd-core/ati_pcigart.c
*** drm/bsd-core/ati_pcigart.c	Fri Aug 26 21:07:03 2005
--- drm-patched/bsd-core/ati_pcigart.c	Sun Oct  2 17:24:11 2005
***************
*** 35,49 ****
  #define ATI_MAX_PCIGART_PAGES		8192	/* 32 MB aperture, 4K pages */
  #define ATI_PCIGART_TABLE_SIZE		32768
  
! int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
! 			 dma_addr_t *bus_addr, int is_pcie)
  {
  	unsigned long pages;
  	u32 *pci_gart = 0, page_base;
  	int i, j;
  
! 	*addr = 0;
! 	*bus_addr = 0;
  
  	if (dev->sg == NULL) {
  		DRM_ERROR( "no scatter/gather memory!\n" );
--- 35,48 ----
  #define ATI_MAX_PCIGART_PAGES		8192	/* 32 MB aperture, 4K pages */
  #define ATI_PCIGART_TABLE_SIZE		32768
  
! int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
  {
  	unsigned long pages;
  	u32 *pci_gart = 0, page_base;
  	int i, j;
  
! 	gart_info->addr = 0;
! 	gart_info->bus_addr = 0;
  
  	if (dev->sg == NULL) {
  		DRM_ERROR( "no scatter/gather memory!\n" );
***************
*** 57,64 ****
  		return 0;
  	}
  
! 	*addr = (long)dev->sg->dmah->vaddr;
! 	*bus_addr = dev->sg->dmah->busaddr;
  	pci_gart = (u32 *)dev->sg->dmah->vaddr;
  
  	pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
--- 56,63 ----
  		return 0;
  	}
  
! 	gart_info->addr = (long)dev->sg->dmah->vaddr;
! 	gart_info->bus_addr = dev->sg->dmah->busaddr;
  	pci_gart = (u32 *)dev->sg->dmah->vaddr;
  
  	pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
***************
*** 71,77 ****
  		page_base = (u32) dev->sg->busaddr[i];
  
  		for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
! 			if (is_pcie) {
  				*pci_gart = (cpu_to_le32(page_base)>>8) | 0xc;
  				DRM_DEBUG("PCIE: %d %08X %08X to %p\n", i,
  				    page_base, (cpu_to_le32(page_base)>>8)|0xc,
--- 70,76 ----
  		page_base = (u32) dev->sg->busaddr[i];
  
  		for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
! 			if (gart_info->is_pcie) {
  				*pci_gart = (cpu_to_le32(page_base)>>8) | 0xc;
  				DRM_DEBUG("PCIE: %d %08X %08X to %p\n", i,
  				    page_base, (cpu_to_le32(page_base)>>8)|0xc,
***************
*** 88,95 ****
  	return 1;
  }
  
! int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
! 			    dma_addr_t bus_addr)
  {
  	if (dev->sg == NULL) {
  		DRM_ERROR( "no scatter/gather memory!\n" );
--- 87,93 ----
  	return 1;
  }
  
! int drm_ati_pcigart_cleanup(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
  {
  	if (dev->sg == NULL) {
  		DRM_ERROR( "no scatter/gather memory!\n" );
diff -r -c drm/bsd-core/drmP.h drm-patched/bsd-core/drmP.h
*** drm/bsd-core/drmP.h	Mon Sep 12 07:35:51 2005
--- drm-patched/bsd-core/drmP.h	Sun Oct  2 17:24:11 2005
***************
*** 274,279 ****
--- 274,290 ----
  typedef u_int16_t u16;
  typedef u_int8_t u8;
  
+ /* location of GART table */
+ #define DRM_ATI_GART_MAIN 1
+ #define DRM_ATI_GART_FB   2
+ 
+ typedef struct ati_pcigart_info {
+ 	int gart_table_location;
+ 	int is_pcie;
+ 	unsigned long addr;
+ 	dma_addr_t bus_addr;
+ } drm_ati_pcigart_info;
+ 
  /* DRM_READMEMORYBARRIER() prevents reordering of reads.
   * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
   * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
***************
*** 828,835 ****
  void	*drm_realloc(void *oldpt, size_t oldsize, size_t size,
  				   int area);
  void	drm_free(void *pt, size_t size, int area);
! void	*drm_ioremap(drm_device_t *dev, drm_local_map_t *map);
! void	drm_ioremapfree(drm_local_map_t *map);
  int	drm_mtrr_add(unsigned long offset, size_t size, int flags);
  int	drm_mtrr_del(unsigned long offset, size_t size, int flags);
  
--- 839,847 ----
  void	*drm_realloc(void *oldpt, size_t oldsize, size_t size,
  				   int area);
  void	drm_free(void *pt, size_t size, int area);
! void    *drm_ioremap(unsigned long offset, unsigned long size,
!                                    drm_device_t * dev);
! void	drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev);
  int	drm_mtrr_add(unsigned long offset, size_t size, int flags);
  int	drm_mtrr_del(unsigned long offset, size_t size, int flags);
  
***************
*** 907,916 ****
--- 919,934 ----
  #endif /* __FreeBSD__ */
  
  /* ATI PCIGART support (ati_pcigart.c) */
+ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
+ #if 0
  int	drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
  			     dma_addr_t *bus_addr, int is_pcie);
+ #endif
+ int drm_ati_pcigart_cleanup(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
+ #if 0
  int	drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
  				dma_addr_t bus_addr);
+ #endif
  
  /* Locking IOCTL support (drm_drv.c) */
  int	drm_lock(DRM_IOCTL_ARGS);
***************
*** 984,995 ****
  /* Inline replacements for DRM_IOREMAP macros */
  static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
  {
! 	map->handle = drm_ioremap(dev, map);
  }
  static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
  {
  	if ( map->handle && map->size )
! 		drm_ioremapfree(map);
  }
  
  static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
--- 1002,1013 ----
  /* Inline replacements for DRM_IOREMAP macros */
  static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
  {
! 	map->handle = drm_ioremap(map->offset,map->size,dev);
  }
  static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
  {
  	if ( map->handle && map->size )
! 		drm_ioremapfree(map->handle,map->size,dev);
  }
  
  static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
diff -r -c drm/bsd-core/drm_bufs.c drm-patched/bsd-core/drm_bufs.c
*** drm/bsd-core/drm_bufs.c	Sat Aug 27 01:27:19 2005
--- drm-patched/bsd-core/drm_bufs.c	Sun Oct  2 17:24:11 2005
***************
*** 153,159 ****
  
  	switch ( map->type ) {
  	case _DRM_REGISTERS:
! 		map->handle = drm_ioremap(dev, map);
  		if (!(map->flags & _DRM_WRITE_COMBINING))
  			break;
  		/* FALLTHROUGH */
--- 153,159 ----
  
  	switch ( map->type ) {
  	case _DRM_REGISTERS:
! 		map->handle = drm_ioremap(map->offset,map->size,dev);
  		if (!(map->flags & _DRM_WRITE_COMBINING))
  			break;
  		/* FALLTHROUGH */
***************
*** 290,296 ****
  	switch (map->type) {
  	case _DRM_REGISTERS:
  		if (map->bsr == NULL)
! 			drm_ioremapfree(map);
  		/* FALLTHROUGH */
  	case _DRM_FRAME_BUFFER:
  		if (map->mtrr) {
--- 290,296 ----
  	switch (map->type) {
  	case _DRM_REGISTERS:
  		if (map->bsr == NULL)
! 			drm_ioremapfree(map->handle,map->size,dev);
  		/* FALLTHROUGH */
  	case _DRM_FRAME_BUFFER:
  		if (map->mtrr) {
diff -r -c drm/bsd-core/drm_memory.c drm-patched/bsd-core/drm_memory.c
*** drm/bsd-core/drm_memory.c	Sat Apr 16 05:02:52 2005
--- drm-patched/bsd-core/drm_memory.c	Sun Oct  2 17:24:11 2005
***************
*** 75,84 ****
  	free(pt, M_DRM);
  }
  
! void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map)
  {
  #ifdef __FreeBSD__
! 	return pmap_mapdev(map->offset, map->size);
  #elif defined(__NetBSD__) || defined(__OpenBSD__)
  	map->bst = dev->pa.pa_memt;
  	if (bus_space_map(map->bst, map->offset, map->size, 
--- 75,85 ----
  	free(pt, M_DRM);
  }
  
! void *drm_ioremap(unsigned long offset, unsigned long size,
!                                    drm_device_t * dev)
  {
  #ifdef __FreeBSD__
! 	return pmap_mapdev(offset, size);
  #elif defined(__NetBSD__) || defined(__OpenBSD__)
  	map->bst = dev->pa.pa_memt;
  	if (bus_space_map(map->bst, map->offset, map->size, 
***************
*** 88,97 ****
  #endif
  }
  
! void drm_ioremapfree(drm_local_map_t *map)
  {
  #ifdef __FreeBSD__
! 	pmap_unmapdev((vm_offset_t) map->handle, map->size);
  #elif defined(__NetBSD__) || defined(__OpenBSD__)
  	bus_space_unmap(map->bst, map->bsh, map->size);
  #endif
--- 89,98 ----
  #endif
  }
  
! void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev)
  {
  #ifdef __FreeBSD__
! 	pmap_unmapdev((vm_offset_t) pt, size);
  #elif defined(__NetBSD__) || defined(__OpenBSD__)
  	bus_space_unmap(map->bst, map->bsh, map->size);
  #endif
diff -r -c drm/shared-core/drm_pciids.txt drm-patched/shared-core/drm_pciids.txt
*** drm/shared-core/drm_pciids.txt	Mon Sep 12 06:37:52 2005
--- drm-patched/shared-core/drm_pciids.txt	Sun Oct  2 17:24:11 2005
***************
*** 66,71 ****
--- 66,72 ----
  0x1002 0x516B CHIP_R200 "ATI Radeon Qk R200"
  0x1002 0x516C CHIP_R200 "ATI Radeon Ql R200"
  0x1002 0x5460 CHIP_RV350 "ATI Radeon X300"
+ 0x1002 0x5B60 CHIP_RV350 "ATI Radeon X300SE"
  0x1002 0x554F CHIP_R350 "ATI Radeon X800"
  0x1002 0x5834 CHIP_RS300|CHIP_IS_IGP "ATI Radeon RS300 IGP"
  0x1002 0x5835 CHIP_RS300|CHIP_IS_IGP|CHIP_IS_MOBILITY "ATI Radeon RS300 Mobility IGP"

--------------080506060601040701030604--



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