Subject: Re: drm on amd64 (drmMap failed)
To: Matt Thomas <matt@3am-software.com>
From: Xning Lee <xning@soforge.com>
List: port-amd64
Date: 04/07/2007 00:43:42
Matt Thomas <matt@3am-software.com> writes:

> On Apr 5, 2007, at 11:17 PM, Xning Lee wrote:
>
>> Matt Thomas <matt@3am-software.com> writes:
>>
>>> Xning Lee wrote:
>>>> "Blair Sadewitz" <blair.sadewitz@gmail.com> writes:
>>>>
>>>>> This is exactly the same problem I had on amd64; I've since
>>>>> switched
>>>>> to i386 (for reasons other than drm; linux compatability on amd64
>>>>> for
>>>>> EMT64 processors is broken).  Could you file a PR for this, please?
>>>>>
>>>>> Thanks,
>>>>>
>>>>
>>>> The issue of 'drmMap failed' on amd64 because the function
>>>> 'udv_attach' of /usr/src/sys/uvm/uvm_device.c can't accept address
>>>> offset value more than 0x7fffffffffffffff: (the type of 'voff_t'
>>>> is int64)
>>>
>>> This is going to be, ultimately, a sign extension problem.  I'm
>>> guessing
>>> that line 176 in drm_ioctl.c would show that the address being
>>> passed in
>>> has already been sign-extended.
>>>
>>
>> that because at line 190 in drm_bufs.c, the address
>> value('map->handle') that retured by 'malloc' has been more than
>> 0x7fffffffffffffff, then at line 197 in drm_bufs.c:
>>
>> 		map->offset = (unsigned long)map->handle;
>
> Since you can't use a malloc'ed address with mmap, it's probably not
> that offset.
> mmap wants a physical address, not a virtual address.
>

that is the offset, line 129 in current drm_vm.c:
{
     ...
	case _DRM_SHM:
		phys = vtophys(offset);
	break;
     ...
}

drm log:
========
[drm:pid613:drm_addmap] offset = 0x00000000, size = 0x00010000, type = 2
[drm:pid613:drm_addmap] Added map 2 0xffff8000368c0000/0x10000
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
[drm:pid613:drm_addmap] offset = 0xfd400000, size = 0x00010000, type = 1
[drm:pid613:drm_ioremap] ioremap mem found: 0xffff8000368d0000
[drm:pid613:drm_addmap] Added map 1 0xfd400000/0x10000
[drm:pid613:drm_addmap] offset = 0xe8000000, size = 0x08000000, type = 0
[drm:pid613:drm_mtrr_add] offset=e8000000 size=134217728
[drm:pid613:drm_addmap] Added map 0 0xe8000000/0x8000000

Xorg log:
=========
(II) RADEON(0): [drm] DRM interface version 1.2
(II) RADEON(0): [drm] created "radeon" driver at busid "pci:0000:01:00.0"
(II) RADEON(0): [drm] added 8192 byte SAREA at 0xffff8000368c0000 (drm_addmap_ioctl)
                                               ^^^^^^^^^^^^^^^^^^
(II) RADEON(0): [drm] drmMap failed (mmap offset: 0xffff8000368c0000)


Ultimately, the problem is: 

'mmap' offset provided in 'drm_vm.c' and 'drm_bufs.c' is not a
physical address.