[rfc] Radeon AGP support patches

Tijl Coosemans tijl at FreeBSD.org
Sun Oct 26 15:25:57 UTC 2014


Hi,

I worked on AGP support for Radeon cards this week.  Please take a look
at the attached patches.

Patch 1:
Adds support for AGP_USER_TYPES to sys/dev/agp.  For normal memory types
a vm_object is allocated, for user types only a vm_page array.  It is
then up to the caller (e.g. TTM code) to manage this array.  Arbitrary
pages can be mapped into the GTT this way.

Patch 2:
This isn't needed for AGP support but it's something I ran into when
chasing a bug.  The handle field in our drm_local_map_t is different
than in Linux.  On Linux this field contains a unique ID for user space
maps and a virtual address for kernel space maps.  On FreeBSD this
field always contains a unique ID and the virtual address of kernel
space maps is stored in another field named virtual.  See the old DRM
code in sys/dev/drm.  I think most of the changes in the patch are in
dead code (unless the driver still supports running old DRMv1 X servers).

Patch 3:
Enable AGP support in sys/dev/drm2.  In PCI mode the GTT exists on the
graphics card so when accessing system memory it already does its own
virtual address translation and only physical addresses appear on the
system bus.  The CPU can access the same addresses with its own VM
system like it always does.  In AGP mode, translation is done by the
AGP chipset so fictitious addresses appear on the system bus.  For the
CPU cache management to work correctly it needs to use these same
fictitious addresses instead of using the real physical addresses
directly.  The patch marks the AGP aperture range fictitious in
radeon_device.c where the VRAM aperture is also marked fictitious such
that PHYS_TO_VM_PAGE in ttm_bo_vm_fault works for addresses in this
range.

The rest of the patch is mostly porting to our agp_* API.  It also
fixes two memory leaks in ttm_agp_backend.c.  One is a missing free in
ttm_agp_tt_create.  The other is because ttm_agp_bind allocates an
agp_memory struct but ttm_agp_unbind does not free it.  So when calling
ttm_agp_bind a second time the reference to the struct is lost.  The
patch changes ttm_agp_bind so the allocation only happens in the first
call.  The struct is released in ttm_agp_destroy.

The changes to ttm_page_alloc.c reduce the diff with Linux.

Patch 4:
Something else I ran into.  In function ttm_bo_kmap_ttm when mapping a
TTM buffer object in kernel space that may be cached (TTM_PL_FLAG_CACHED)
use normal WB caching like Linux does instead of WC.  I think this may be
a copy-paste error from similar looking code in ttm_bo_ioremap that is
defined right above this function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: radeon-agp-1.patch
Type: text/x-patch
Size: 5236 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-x11/attachments/20141026/1df676bd/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: radeon-agp-2.patch
Type: text/x-patch
Size: 11289 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-x11/attachments/20141026/1df676bd/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: radeon-agp-3.patch
Type: text/x-patch
Size: 8941 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-x11/attachments/20141026/1df676bd/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: radeon-agp-4.patch
Type: text/x-patch
Size: 544 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-x11/attachments/20141026/1df676bd/attachment-0003.bin>


More information about the freebsd-x11 mailing list