On 7/3/05, Paul Mackerras <[EMAIL PROTECTED]> wrote:
> Jon Smirl writes:
> 
> > drmMap never cares about the handle since drmMap turns into mmap and
> > mmap doesn't know about DRM maps.
> 
> Huh?  drm_mmap certainly does know about DRM maps.

I see now that drmMap is overriding mmap's offset to pass in the
handle. So the reason my code is working is that the DRM handle and
offset are currently the same number.

int drmMap(int fd,
           drm_handle_t handle,
           drmSize size,
           drmAddressPtr address)
{
    static unsigned long pagesize_mask = 0;

    if (fd < 0) return -EINVAL;

    if (!pagesize_mask)
        pagesize_mask = getpagesize() - 1;

    size = (size + pagesize_mask) & ~pagesize_mask;

    *address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle);
    if (*address == MAP_FAILED) return -errno;
    return 0;
}

I had switched to using offset since sarea had a handle of zero. A
handle of zero doesn't work because it trips this code at the
beginning of drm_mmap.

int drm_mmap(struct file *filp, struct vm_area_struct *vma)
{
        DRM_DEBUG("start = 0x%lx, end = 0x%lx, offset = 0x%lx\n",
                  vma->vm_start, vma->vm_end, VM_OFFSET(vma));

        if (!priv->authenticated)
                return -EACCES;

        /* We check for "dma". On Apple's UniNorth, it's valid to have
         * the AGP mapped at physical address 0
         * --BenH.
         */
        if (!VM_OFFSET(vma)
#if __OS_HAS_AGP
            && (!dev->agp
                || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
#endif
            )
                return drm_mmap_dma(filp, vma);

When I passed in sarea's handle I was ending up in drm_mmap_dma.

> The trouble with using the offset returned by drmGetMap is that if
> your program is a 32-bit program running on a 64-bit kernel, and the
> kernel map->offset value for the map you want is > 4G, then your
> 32-bit program will only see the bottom 32 bits of the offset value,
> and you end up with no way for your 32-bit program to mmap the map.
> That's why I am suggesting that the kernel should create a 32-bit
> token for each map and return it in the handle field, and the program
> should use that as the mmap offset when mmapping the map.

I'm fine with switching to true handles. I'm not really sure what the
check for 'dma' is looking for. But we need to fix sarea to have a
proper handle.

-- 
Jon Smirl
[EMAIL PROTECTED]


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to