<br><br><div class="gmail_quote">2012/11/9 Ville Syrjälä <span dir="ltr"><<a href="mailto:ville.syrjala@linux.intel.com" target="_blank">ville.syrjala@linux.intel.com</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<div class="im">On Fri, Nov 09, 2012 at 04:39:30PM +0900, Inki Dae wrote:<br>
> This patch fixes access issue to invalid memory region.<br>
><br>
> crtc had only one drm_framebuffer object so when framebuffer<br>
> cleanup was requested after page flip, it'd try to disable<br>
> hardware overlay to current crtc.<br>
> But if current crtc points to another drm_framebuffer,<br>
> This may induce invalid memory access.<br>
><br>
> Assume that some application are doing page flip with two<br>
> drm_framebuffer objects. At this time, if second drm_framebuffer<br>
> is set to current crtc and the cleanup to first drm_framebuffer<br>
> is requested once drm release is requested, then first<br>
> drm_framebuffer would be cleaned up without disabling<br>
> hardware overlay because current crtc points to second<br>
> drm_framebuffer. After that, gem buffer to first drm_framebuffer<br>
> would be released and this makes dma access invalid memory region.<br>
><br>
> This patch adds drm_framebuffer to drm_crtc structure as member<br>
<br>
</div>That is exactly the reverse of what you're doing in the patch.<br>
We already have crtc.fb, and you're adding fb.crtc.<br>
<div class="im"><br>
> and makes drm_framebuffer_cleanup function check if fb->crtc is<br>
> same as desired fb. And also when setcrtc and pageflip are<br>
> requested, it makes each drm_framebuffer point to current crtc.<br>
<br>
</div>Looks like you're just setting the crtc.fb and fb.crtc pointers to<br>
exactly mirror each other in the page flip ioctl. That can't fix<br>
anything.<br>
<br></blockquote><div> </div><div>At least, when drm is released, the crtc to framebuffer that was recently used for scanout can be disabled correctly.</div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">

First of all multiple crtcs can scan out from the same fb, so a single<br>
fb.crtc pointer is clearly not enough to represent the relationship<br>
between fbs and crtcs.<br>
<br>
Also you're not clearing the fb.crtc pointer anywhere, so now<br>
destroying any framebuffer that was once used for scanout, would disable<br>
some crtc.<br>
<br></blockquote><div> </div><div>It looks like that you missed my previous comment. Plaese, see the previous comment. And that was already pointed out by <span class="hb"><span class="g2" name="Prathyush">Prathyush. fb.crtc will be cleared at drm_mode_rmfb(). With this, is there my missing point?  I really wonder that with this patch, drm framwork could be faced with any problem.</span></span></div>
<div> </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><p>
So it looks like you're making things worse, not better.<br>
<br>
Anyway I'll just nack the whole idea. What you need to do is track the<br>
pending page flips, and make sure the old buffer is not freed too early.<br>
Just grab a reference to the old gem object when issuing the page flip,<br>
and unref it when you're sure the flip has occured. Or you could use the<br>
new drm_framebuffer refcount, but personally I don't see much point in<br>
that when you already have the gem object refcount at your disposal.<br>
</p><p> </p></blockquote><div> </div><div>And it seems like that your saying is that each specific drivers should resolve this issue(access to invalid memory region) tracking the pending page flip. But I think that this issue may be a missing point drm framework missed so specific drivers is processing this instead. And with this patch, couldn't some codes you mentioned be removed from specific drivers? because it doesn't need to track the pending page flips and relevant things anymore.</div>
<div> </div><div>There may be my missing point. I'd welcome to any comments and advices.</div><div> </div><div>Thanks,</div><div>Inki Dae</div><div> </div></div>