2001-12-11 00:35:12

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH] agpgart chipset knowledge encapsulation

The point of this patch is to remove a chipset dependency from DRM so it
can cleanly support both the Intel 460GX and an HP IA64 chipset. I would
normally send this to Jeff Hartmann, but he seems to have disappeared,
leaving agpgart without an obvious maintainer.

DRM needs to know the physical addresses of pages bound into the AGP
aperture, and today that information is communicated from agpgart to DRM
in the memory[] array of the agp_memory structure. The problem is that
the values in the array are not simple physical addresses. Rather, they
are the physical addresses mangled to be suitable for direct insertion
into the GATT (the hardware-visible translation table).

Hence, DRM needs a way to unmangle these values to get the physical
address back. Today, agpgart exports a "page_mask" value, so DRM does the
equivalent of this:

paddr = agpmem->memory->memory[offset] & dev->agp->page_mask;

This isn't sufficient for the 460GX, because its mangling function
requires a shift as well as a mask. The 460GX code (which is still in the
ia64 patch, not in the mainstream kernel) looks like this:

paddr = (agpmem->memory->memory[offset] & 0xffffff) << 12;

So DRM currently has this chipset-specific code in it to unmangle the
values in memory[], while there's no reason I know of for the mangled
values to ever be exported from agpgart.

The attached patch against 2.4.16 remedies this by leaving the plain
physical addresses in memory[]. The chipset-specific mangling is then
done at the point where it is needed, when those values are inserted into
the GATT.

It's a little tricky because the DRM code is distributed with XFree86 as
well as with the kernel. All the combinations (old DRM + new kernel; new
DRM + old kernel; new DRM + new kernel) should still work, but DRM has to
check the kernel version it's compiled against, so there are three
KERNEL_VERSION(...) instances in the patch that need to be adjusted to
reflect the first version containing these changes.

Any feedback is welcome, especially if you can test it. I've been able to
test 460GX & ATI Radeon, HP & ATI Radeon, and Serverworks HE & MGA G400,
but obviously that's not exhaustive.

Bjorn Helgaas
--
Linux Systems Operation R&D
Hewlett-Packard Company
Fort Collins, CO


Attachments:
pagemask.diff.gz (2.25 kB)