Review request to DRM Driver for Samsung SoC Exynos4210.
inki.dae at samsung.com
Tue Aug 30 05:38:02 PDT 2011
> -----Original Message-----
> From: Dave Airlie [mailto:airlied at gmail.com]
> Sent: Tuesday, August 30, 2011 6:46 PM
> To: Inki Dae
> Cc: airlied at linux.ie; kyungmin.park at samsung.com; dri-
> devel at lists.freedesktop.org; jy0922.shim at samsung.com;
> sw0312.kim at samsung.com; eric.y.miao at gmail.com; rob at ti.com
> Subject: Re: Review request to DRM Driver for Samsung SoC Exynos4210.
> >> 2. I'm not sure why samsung_drm_fn_encoder exists, it looks like from
> >> the crtc mode set functions you call the encoder mode set functions,
> >> is it not possible to use the helper drm_crtc_helper_set_mode so that
> >> the crtc mode set is called then the encoder ones without having the
> >> explicit calls? If not please either document it or point at the
> >> explaination I missed.
> > For generic usage of crtc, we got only encoder has display controller(or
> > H/Ws) specific codes.
> > as you pointed out, I will check how we use drm_crtc_helper_set_mode
> > of samsung_drm_fb_encoder because drm_crtc_helper_set_mode calls not
> > crtc but also encoder's callbacks and in addition, we faced with vblank
> > issue. drm framework has only one irq handler but in embedded system at
> > least Samsung SoC, display controller and hdmi have independent their
> > irq. so I got crtc has common vblank operations such as enable_vblank
> > disable_vblank and each encoder's function to be called in accordance
> > activated crtc. if you think this way is wrong or not good way then do
> > have any good ideas to resolve this issue without
> > the ideas that crtc could access to encoder.?
> Ah yes I see the issue now, that is probably a good reason, we should
> think of some way to improve the vblank code to better allow this,
> though that can probably wait until the driver is in mainline.
> >> 3. Not terribly urgent but is samsung the best name for this? what
> >> happens if you bring out another chip, I also think there is a lot of
> >> samsung_drm_ in function names that seems not that useful. dropping
> >> _drm_ might help.
> > As you know, Samsung SoCs have a variety of prefixes such as s3c24xx,
> > s3c64xx, s3c, s5p, s5pv210(=s5pc110) and exynos4210(=s5pc210, =s5pv310).
> > except old SoCs, our drm driver would support only exynos4210 and later.
> > we used samsung_ as prefix to represent them. but if you think this
> > is not proper name then we would try to consider other names. And _drm_
> > would help to debug. for instance, we could know who is current
> > owner.
> Generally, I'd prefer the name to be closer to the chip than the
> manufacturer, so exynos4210 or something like that, I just worry
> calling it samsung will lead to a later samsung2. So far the driver
> hasn't much specific code in it, but that may change.
I agree with you but Samsung has no naming rule and drm framework for
Samsung Soc, drm drv, encoder, crtc, connector and so on, could be used
commonly for all Samsung SoCs. actually in case of some drivers common to
Samsung SoCs also use samsung prefix. you can refer to
drivers/tty/serial/samsung.c also drivers/mtd/onenand/samsung.c. but in case
of samsung_drm_fimd.c, I will change prefix to exynos4 because this module,
samsung_drm_fimd.c, is specific to exynos4xxx series. if you are ok then
we'd like to use so.
> >> 4 ioctls: drm_samsung_gem_map_off needs explicit padding before the
> >> 64-bit, drm_samsung_gem_mmap needs explicit padding before the
> >> 64-bit,, though I'm not sure you need these ioctls all now that the
> >> dumb interface is upstream,
> > I am afraid I don't understand what you mean fully. Could you please
> > me more details about "drm_samsung_gem_map_off needs explicit padding
> > the 64-bit, drm_samsung_gem_mmap needs explicit padding before the
> > 64-bit,,"? as DRM, I am a novice. drm_samsung_gem_map_off is used to get
> > offset that actually this is hash key that this key is used to get a gem
> > object corresponding to it at drm_gem_mmap(). and the gem object is
> > transferred to page fault handler(samsung_drm_gem_fault) with
> > vma->vm_private_data containing it. At this time, page fault handler
> gets a
> > gem object from vma object and then maps user space to physical memory.
> > call patch to drm_gem_mmap is as the following : mmap system call ->
> > samsung_drm_gem_mmap -> drm_gem_mmap
> > if the comments above are wrong way then feel free to give me your
> > and I will be pleased.
> If you have an 32-bit followed by a 64-bit, on different platforms
> that will end up aligned differently,
> generally we just try to be explicit and add another 32-bit pad after
> the first 32-bit. It might not matter on ARM (I'm not sure)
> it also might not matter until you move from 32-bit ARM to 64-bit ARM,
> but its best to deal with these early.
> > Basically gem_dumb_* and gem_* are same operation. The difference
> > them is that gem_dumb_ needs framebuffer information such width, height
> > bpp to allocate buffer and gem_ needs only size. in case of gem_dumb_,
> > would be calculated at kernel side(at samsung_drm_gem_dumb_create). do
> > think it's better using only gem_dumb_? if so, I will remove
> > gem_create_ioctl, gem_map_offset_ioctl and gem_mmap functions.
> I think using the dumb ioctls initially is a good plan, esp as you
> have no tiling or acceleration support, the idea
> behind the dumb ioctls is to give splash screens and maybe write a
> generic X.org driver in the future that can just do sw rendering.
> Like at some point I forsee you needing driver specific ioctls for
> alloc/mapping, I'd just rather wait until you have some userspace
> available to use them that we can validate them with.
Thank you for your pointing out. I will remove SAMSUNG_GEM_MAP_OFFSET and
SAMSUNG_GEM_MAP ioctls except SAMSUNG_GEM_CREATE and SAMSUNG_GEM_MMAP ioctls
because these are duplicated with dumb_*. and for alloc/mapping you
mentioned above, we have already tested them through user application.
This is example code in user level:
/* allocation. */
gem.size = 1024 * 600 * 4;
ioctl(fd, DRM_IOCTL_SAMSUNG_GEM_CREATE, &gem);
/* user space mapping. */
map.handle = gem.handle
map.offset = 0;
map.size = gem.size;
ioctl(fd, DRM_IOCTL_SAMSUNG_GEM_MMAP, &map);
/* clear buffer. */
memset(map.mapped, 0x0, map.size);
drmModeAddFB(fd, width, height, 32, 32, stride, map.handle, &fb_id);
/* release. */
gem_close.handle = gem.handle;
ioctl(fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
for application testing, we use libdrm v2.4.26. and also modetest of libdrm
also worked fine. if you want full source code then I will send it.
If there is any point I missed then point out and give me your comments or
> >> what is usr_addr in the gem create ioctl for? this seems wrong, it
> >> also looks too short for 64-bit addresses, but passing in userspace
> >> addr to kernel is generally not a great plan.
> > This is my mistake. I will remove usr_addr from drm_samsung_ge_create
> > structure. this variable isn't used anywhere.
> >> 5. you probably don't need master_create/set ops.
> For h/w lock support, I think these operations should be used. If
> > unnecessary, I will remove these operations. and could you please
> > the purpose of drm_master?. I didn't understand the master fully. I'd
> try to
> > find how we could use the master feature after understanding.
> The drm lock is only for old pre-KMS DRI1 drivers, no modern driver
> should be using it or initialising it. drm master is the process that
> controls authorisation for direct rendering clients on the DRM device.
> So if you have an X server + 3D app, the X server is a master, if you
> switch users to another X server, that becomes the master. The driver
> only really needs this stuff if handles direct rendering and has
> command submission ioctls.
Thank you for your explanation. I will remove master_create/master_set
functions because our driver supports only S/W rendering yet.
> >> Dave.
> > Thank yo for your comments again. it's been very helpful
> > Best Regards
> > Inki Dae.
Almost parts you pointed out are being applied to our driver. and we have a
plan to post next patch updated this week or next week.
More information about the dri-devel