<div dir="ltr">I would be surprised if the size argument was the issue. That comes right out out of the create IOCTL unmodified. Here is the full source that I am using. <div><br></div><div><div>    // Clear the arg buffers. </div><div>    memset(&create_arg, 0, sizeof(create_arg));</div><div>    memset(&map_arg, 0, sizeof(map_arg));</div><div><br></div><div>    // ------------------------------------------------------------------------</div><div>    // Allocate</div><div><br></div><div>    // Fill in the arguments for the IOCTL. Note that we only support 32bpp</div><div>    // dumb buffers so that is hard coded here. </div><div>    create_arg.width = width;</div><div>    create_arg.height = height;</div><div>    create_arg.bpp = 32;</div><div><br></div><div>    // Allocate the dumb buffer</div><div>    if (drmIoctl(gpu->fd(), DRM_IOCTL_MODE_CREATE_DUMB, &create_arg))</div><div>    {</div><div>        svWarning(0) << "Failed: DRM_IOCTL_MODE_CREATE_DUMB - " << strerror(errno);</div><div>        return;</div><div>    }</div><div><br></div><div>    // Store the dumb buffer properties. </div><div>    mSize = create_arg.size;</div><div>    mStride = create_arg.pitch;</div><div>    mHandle = create_arg.handle;</div><div><br></div><div>    // ------------------------------------------------------------------------</div><div>    // Map</div><div><br></div><div>    // Fill in the arguments for the IOCTL. </div><div>    map_arg.handle = mHandle;</div><div><br></div><div>    // Allocate the dumb buffer</div><div>    if (drmIoctl(gpu->fd(), DRM_IOCTL_MODE_MAP_DUMB, &map_arg))</div><div>    {</div><div>        svWarning(0) << "Failed: DRM_IOCTL_MODE_MAP_DUMB - " << strerror(errno);</div><div>        return;</div><div>    }</div><div><br></div><div>    // Store the mapped memory</div><div>    if ((mVaddr = (svuint32 *)mmap(0, mSize, PROT_READ | PROT_WRITE, MAP_SHARED, gpu->fd(), map_arg.offset)) == MAP_FAILED)</div><div>    {</div><div>        // Need to clear out the address so that we don't try to use it. <br></div><div>        mVaddr = NULL;</div><div><br></div><div>        // Error out.</div><div>        svWarning(0) << "Failed: Dumb Buffer mmap - " << strerror(errno);</div><div>        return;</div><div>    }</div></div><div><br></div><div><br></div><div>When this code runs, I get the "Invalid Argument" on the mmap. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 10, 2014 at 4:14 PM, Dave Airlie <span dir="ltr"><<a href="mailto:airlied@gmail.com" target="_blank">airlied@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11 November 2014 06:33, Rian Quinn <<a href="mailto:rianquinn@gmail.com">rianquinn@gmail.com</a>> wrote:<br>
> I did another test using the following that David put up on github:<br>
><br>
> <a href="https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset.c" target="_blank">https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset.c</a><br>
><br>
> This test also fails on everything except Intel. What's really strange is<br>
> this test actually does a test to verify that dumb buffers are supported,<br>
> and the test passes in all cases. David's code is returning with the same<br>
> error of "Invalid Argument" on the mmap call. Why would the other driver's<br>
> claim to support dumb buffers, but have no means to map the memory?<br>
<br>
</span>Just a guess, the size argument is wrong.<br>
<br>
But you know you have the kernel source, stick some printks in the<br>
EINVAL return paths already.<br>
<br>
Dave.<br>
<span class="">> - Rian<br>
><br>
> On Mon, Nov 10, 2014 at 2:48 PM, Rian Quinn <<a href="mailto:rianquinn@gmail.com">rianquinn@gmail.com</a>> wrote:<br>
>><br>
>> When working with dumb buffers, DRM_IOCTL_MODE_MAP_DUMB and mmap works<br>
>> fine on Intel, but the mmap call fails on Radeon, Nouveau, and VMWGFX. I you<br>
>> look at the source for the xorg moderating driver, it only uses the dumb<br>
>> buffer IOCTL (i.e. it’s not using LibKMS), and if you look at the kernel<br>
>> source code for the dumb buffer IOCTLs for each of the Radeon, Nouveau, and<br>
>> VMWGFX drivers, they all implement the functions. Furthermore all of the<br>
>> IOCTLs succeed without error. Its only when you attempt to map the memory,<br>
>> that you get an error of “Invalid Argument”. Here is my map call:<br>
>><br>
>> mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, map_arg.offset)<br>
>><br>
>> Is this a bug, or is there a different way to map the dumb buffers for<br>
>> these drivers other than LibKMS.<br>
>><br>
>> Thanks,<br>
>> - Rian<br>
><br>
><br>
><br>
</span>> _______________________________________________<br>
> dri-devel mailing list<br>
> <a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
><br>
</blockquote></div><br></div>