Bug 22271

Summary: On 64bit kernel(drm-next-radeon) ioctls from 32bit application doesn't work
Product: DRI Reporter: Krzysztof A. Sobiecki <sobkas>
Component: DRM/RadeonAssignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: kdekorte, yaneti
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
My kernel configuration
none
Log with drm debug=1 on kernel 2.6.31-rc5
none
Config file for kernel 2.6.31-rc5 none

Description Krzysztof A. Sobiecki 2009-06-13 05:47:16 UTC
Created attachment 26754 [details]
My kernel configuration

I'm using jglisse kernel:
git://people.freedesktop.org/~glisse/drm-next drm-next-radeon 52c34724734132e7d416ce5ab5e934d702e8f179.
For now I have tested only KMS setup.
libdrm branch: modesetting-gem 1edb70f1b909d06f1c0ee7c9c794aec99454e488.

Bug is reproducible even without X running.

Running 32bit version of drmstat:
drmstat -v -O /dev/dri/card0:
Produces this kernel error:
[ 2446.945430] ioctl32(lt-drmstat:14975): Unknown cmd fd(3) cmd(c0246400){t:'d';sz:36} arg(08213008) on /dev/dri/card0
[ 2446.945458] ioctl32(lt-drmstat:14975): Unknown cmd fd(3) cmd(c0106407){t:'d';sz:16} arg(fffab5e0) on /dev/dri/card0
[ 2446.945464] ioctl32(lt-drmstat:14975): Unknown cmd fd(3) cmd(c0086401){t:'d';sz:8} arg(fffab5ec) on /dev/dri/card0

Starting 32bit glxinfo:
libGL: OpenDriver: trying /emul/ia32-linux/usr/lib/dri/r300_dri.so
libGL error: failed to get magic
with kernel error:
[ 2694.804332] ioctl32(glxinfo:15042): Unknown cmd fd(4) cmd(80046402){t:'d';sz:4} arg(ff938800) on /dev/dri/card0

I hope this is only error in my kernel configuration.
Comment 1 Krzysztof A. Sobiecki 2009-06-13 06:11:18 UTC
I have also tested it without KMS(radeon modeset=0) and it worked well. There was no ioctl32 error and 32bit glxinfo showed direct rendering: yes.
I think this problem is connected with KMS.
Comment 2 Krzysztof A. Sobiecki 2009-06-13 06:14:04 UTC
, memory management or something else.
Comment 3 Krzysztof A. Sobiecki 2009-06-13 14:22:58 UTC
01:00.0 VGA compatible controller [0300]: ATI Technologies Inc Radeon X1650 Pro [1002:71c1] (rev 9e)
Comment 4 Krzysztof A. Sobiecki 2009-07-28 16:50:03 UTC
Same problem on 2.6.31-rc3.
Jul 23 14:06:26 localhost kernel: [  396.992905] ioctl32(ia32-glxinfo:7752): Unknown cmd fd(4) cmd(80046402){t:'d';sz:4} arg(ffb5ba50) on /dev/dri/card0
Jul 23 14:07:01 localhost kernel: [  431.536462] ioctl32(ia32-glxinfo:7755): Unknown cmd fd(4) cmd(80046402){t:'d';sz:4} arg(fff10340) on /dev/dri/card0
Comment 5 Michel Dänzer 2009-07-29 05:24:05 UTC
Does setting .compat_ioctl = radeon_compat_ioctl for KMS as well in drivers/gpu/drm/radeon/radeon_drv.c fix the problem?
Comment 6 Krzysztof A. Sobiecki 2009-07-29 17:26:14 UTC
Setting .compat_ioctl = radeon_compat_ioctl for KMS make 32bit ioctls work. But there is still problem that stops ia32-glxinfo from working.
After starting ia32-glxinfo:
libGL: OpenDriver: trying /usr/lib32/dri/r300_dri.so
drm_radeon_getparam_t (RADEON_PARAM_DEVICE_ID): -14
libGL error: failed to create dri screen
[...]
In dmesg I only get this:
[10664.708003] [drm:radeon_info_ioctl] *ERROR* copy_to_user

I will check what drm debug=1 prints.

For now I thin that 32bit DRM_RADEON_INFO(radeon_kms.c:radeon_info_ioctl) fails here:
"
if (DRM_COPY_TO_USER(value_ptr, &value, sizeof(uint32_t))) {
        DRM_ERROR("copy_to_user\n");
        return -EFAULT;
}
"
64bit one works as excepted.
Comment 7 Krzysztof A. Sobiecki 2009-07-29 17:33:00 UTC
excepted->expected
Comment 8 Krzysztof A. Sobiecki 2009-08-04 18:26:45 UTC
Created attachment 28353 [details]
Log with drm debug=1 on kernel 2.6.31-rc5

Full log is really long so I post only relevant part. I will post full version if needed.
Comment 9 Krzysztof A. Sobiecki 2009-08-04 18:29:22 UTC
Created attachment 28354 [details]
Config file for kernel 2.6.31-rc5
Comment 10 Krzysztof A. Sobiecki 2009-08-28 17:32:57 UTC
Mesa commit: c3374bf97ecd82b915fb29c7c04951e2b75d4dbc fixed radeonGetParam problem.

I'm still unable to run any 32bit binary that uses opengl. Every time I try to start it I got something like this:
"
./fbo_firecube
Allocating 512 x 512 radeon RBO (pitch 512)
Depth renderbuffer size = 16 bits
drmRadeonCmdBuffer: -14
"
Comment 11 Krzysztof A. Sobiecki 2009-09-11 19:12:32 UTC
For "drmRadeonCmdBuffer: -14" bug I have created separate bug #23626
 
Comment 12 Kevin DeKorte 2009-09-14 15:35:45 UTC
*** Bug 23816 has been marked as a duplicate of this bug. ***
Comment 13 Kevin DeKorte 2009-09-14 15:37:42 UTC
There was a patch made to libdrm that corrects the drmRadeonCmdBuffer: -14
and setting .compat_ioctl = radeon_compat_ioctl in drm-next completes the fix.
Comment 14 Krzysztof A. Sobiecki 2009-09-15 13:29:17 UTC
It looks like commit 70ba2a374704e00df8868a7ac3d7350329d28924 in drm-next(drm-2.6) fixed this bug. I will close it, after merging of this commit into main tree. 
Comment 15 Krzysztof A. Sobiecki 2009-09-22 12:23:34 UTC
Commit migrated into main tree. I'm closing this bug.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.