<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 25, 2020 at 3:38 PM Thomas Zimmermann <<a href="mailto:tzimmermann@suse.de">tzimmermann@suse.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi<br>
<br>
Am 23.02.20 um 05:26 schrieb tang pengchuan:<br>
> <br>
> <br>
> On Sun, Feb 23, 2020 at 5:27 AM Sam Ravnborg <<a href="mailto:sam@ravnborg.org" target="_blank">sam@ravnborg.org</a><br>
> <mailto:<a href="mailto:sam@ravnborg.org" target="_blank">sam@ravnborg.org</a>>> wrote:<br>
> <br>
>     Hi Kevin/tang.<br>
> <br>
>     Thanks for the quick and detailed feedback.<br>
>     Your questions are addressed below.<br>
> <br>
>             Sam<br>
> <br>
> <br>
>     > > > +static int sprd_drm_bind(struct device *dev)<br>
>     > > > +{<br>
>     > > > +     struct drm_device *drm;<br>
>     > > > +     struct sprd_drm *sprd;<br>
>     > > > +     int err;<br>
>     > > > +<br>
>     > > > +     drm = drm_dev_alloc(&sprd_drm_drv, dev);<br>
>     > > > +     if (IS_ERR(drm))<br>
>     > > > +             return PTR_ERR(drm);<br>
>     > > You should embed drm_device in struct sprd_drm.<br>
>     > > See example code in drm/drm_drv.c<br>
>     > ><br>
>     > > This is what modern drm drivers do.<br>
>     > ><br>
>     > > I *think* you can drop the component framework if you do this.<br>
>     > ><br>
>     > I have read it(drm/drm_drv.c) carefully, if drop the component<br>
>     framework,<br>
>     > the whole our drm driver maybe need to redesign, so i still want<br>
>     to keep<br>
>     > current design.<br>
>     OK, fine.<br>
> <br>
>     > > > +     sprd_drm_mode_config_init(drm);<br>
>     > > > +<br>
>     > > > +     /* bind and init sub drivers */<br>
>     > > > +     err = component_bind_all(drm->dev, drm);<br>
>     > > > +     if (err) {<br>
>     > > > +             DRM_ERROR("failed to bind all component.\n");<br>
>     > > > +             goto err_dc_cleanup;<br>
>     > > > +     }<br>
>     > > When you have a drm_device - which you do here.<br>
>     > > Then please use drm_err() and friends for error messages.<br>
>     > > Please verify all uses of DRM_XXX<br>
>     > ><br>
>     >   modern drm drivers need drm_xxx to replace DRM_XXX?<br>
>     Yes, use of DRM_XXX is deprecated - when you have a drm_device.<br>
> <br>
>     > ><br>
>     > > > +     /* with irq_enabled = true, we can use the vblank<br>
>     feature. */<br>
>     > > > +     drm->irq_enabled = true;<br>
>     > > I cannot see any irq being installed. This looks wrong.<br>
>     > ><br>
>     > Our display controller isr is been register on crtc<br>
>     driver(sprd_dpu.c), not<br>
>     > here.<br>
> <br>
>     I think you just need to move this to next patch and then it is fine.<br>
> <br>
> Here is the advice given by Thomas Zimmermann, similar to the advice you<br>
> gave.<br>
> I have given thomas feedback about my questions, maybe thomas didn't see<br>
> my email, so there is no reply.<br>
<br>
I have been busy last week. Sorry for not getting back to you.<br>
<br>
> <br>
> But I've always been confused, because irq is initialized in drm driver<br>
> for other guys, why not for me?<br>
<br>
Do you have an example?<br></blockquote><div>Hi Thomas,</div><div><div>The the irq is initialized in the sub-device code, but the device state is set on kms driver.</div><div><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-">E.g<br></span></span></span></span></div><div><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-">Here is the device state set on kms driver:<br></span></span></span></span></div><div><pre><span id="gmail-scope_id_c6d1be76" class="gmail-scope-head"><a class="gmail-l gmail-selected" name="206" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#206">206 </a><a style="cursor: pointer;" id="gmail-scope_id_c6d1be76_fold_icon"><span class="gmail-fold-icon"> </span></a><b>static</b> <b>int</b> <a class="gmail-xf" name="mtk_drm_kms_init"></a><a href="http://10.0.1.79:8081/s?refs=mtk_drm_kms_init&project=sprdroidr_trunk" class="gmail-xf gmail-intelliWindow-symbol">mtk_drm_kms_init</a>(<b>struct</b> <a href="http://10.0.1.79:8081/s?defs=drm_device&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">drm_device</a> *<a class="gmail-xa" name="drm"></a><a href="http://10.0.1.79:8081/s?refs=drm&project=sprdroidr_trunk" class="gmail-xa gmail-intelliWindow-symbol">drm</a>)<br>......<br></span></pre><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"></span></span></span></span></div><div><pre><span id="gmail-scope_id_c6d1be76_fold" class="gmail-scope-body"><a class="gmail-l gmail-selected" name="298" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#298">298 </a><span class="gmail-fold-space"> </span>      <span class="gmail-c">/*
<a class="gmail-l gmail-selected" name="299" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#299">299 </a><span class="gmail-fold-space"> </span>  * We don't use the drm_irq_install() helpers provided by the DRM
<a class="gmail-hl gmail-selected" name="300" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#300">300 </a><span class="gmail-fold-space"> </span>         * core, so we need to set this manually in order to allow the
<a class="gmail-l gmail-selected" name="301" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#301">301 </a><span class="gmail-fold-space"> </span>  * DRM_IOCTL_WAIT_VBLANK to operate correctly.
<a class="gmail-l gmail-selected" name="302" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#302">302 </a><span class="gmail-fold-space"> </span>  */</span>
<a class="gmail-l gmail-selected" name="303" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_drm_drv.c#303">303 </a><span class="gmail-fold-space"> </span> <a href="http://10.0.1.79:8081/s?defs=drm&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">drm</a>-><a href="http://10.0.1.79:8081/s?defs=irq_enabled&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">irq_enabled</a> = <b>true</b>;<br><br>Here is irq install on subdev:<br><span id="gmail-scope_id_b3948385" class="gmail-scope-head"><a class="gmail-l gmail-selected" name="265" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_disp_rdma.c#265">265 </a><a style="cursor: pointer;" id="gmail-scope_id_b3948385_fold_icon"><span class="gmail-fold-icon"> </span></a><b>static</b> <b>int</b> <a class="gmail-xf" name="mtk_disp_rdma_probe"></a><a href="http://10.0.1.79:8081/s?refs=mtk_disp_rdma_probe&project=sprdroidr_trunk" class="gmail-xf gmail-intelliWindow-symbol">mtk_disp_rdma_probe</a>(<b>struct</b> <a href="http://10.0.1.79:8081/s?defs=platform_device&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">platform_device</a> *<a class="gmail-xa" name="pdev"></a><a href="http://10.0.1.79:8081/s?refs=pdev&project=sprdroidr_trunk" class="gmail-xa gmail-intelliWindow-symbol">pdev</a>)<br>......<br></span><span id="gmail-scope_id_b3948385_fold" class="gmail-scope-body"><a class="gmail-l gmail-target gmail-selected" name="298" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_disp_rdma.c#298">298 </a><span class="gmail-fold-space"> </span>        <a href="http://10.0.1.79:8081/s?defs=ret&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">ret</a> = <a href="http://10.0.1.79:8081/s?defs=devm_request_irq&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">devm_request_irq</a>(<a href="http://10.0.1.79:8081/s?defs=dev&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">dev</a>, <a href="http://10.0.1.79:8081/s?defs=irq&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">irq</a>, <a class="gmail-d gmail-intelliWindow-symbol" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_disp_rdma.c#mtk_disp_rdma_irq_handler">mtk_disp_rdma_irq_handler</a>,
<a class="gmail-l gmail-selected" name="299" href="http://10.0.1.79:8081/xref/sprdroidr_trunk/bsp/kernel/kernel5.4/drivers/gpu/drm/mediatek/mtk_disp_rdma.c#299">299 </a><span class="gmail-fold-space"> </span>                              <a href="http://10.0.1.79:8081/s?defs=IRQF_TRIGGER_NONE&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">IRQF_TRIGGER_NONE</a>, <a href="http://10.0.1.79:8081/s?defs=dev_name&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">dev_name</a>(<a href="http://10.0.1.79:8081/s?defs=dev&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">dev</a>), <a href="http://10.0.1.79:8081/s?defs=priv&project=sprdroidr_trunk" class="gmail-intelliWindow-symbol">priv</a>);<br><br><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-">I'm not sure if my understanding is wrong...</span></span></span></span></pre><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-"></span></span></span></span></div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Best regards<br>
Thomas<br>
<br>
> Can you help to tell the reason in detail, looking forward to your answers.<br>
> <br>
> Thomas's suggestion:<br>
> -------------------------------------------------------------------------------------------<br>
> <br>
> This line indicates the problem's design. The irq is initialized in the<br>
> sub-device code, but the device state is set here. Instead both should<br>
> be set in the same place.<br>
> <br>
>> +<br>
>> +     /* reset all the states of crtc/plane/encoder/connector */<br>
>> +     drm_mode_config_reset(drm);<br>
>> +<br>
>> +     /* init kms poll for handling hpd */<br>
>> +     drm_kms_helper_poll_init(drm);<br>
> <br>
> Most of this function's code should be moved into the sub-device bind<br>
> function.<br>
> <br>
> Here, maybe do:<br>
> <br>
>  * allocate device structures<br>
>  * call component_bind_all()<br>
>  * on success, register device<br>
> <br>
> The sub-device function should then do<br>
> <br>
>  * init modesetting, crtc, planes, etc.<br>
>  * do drm_mode_config_reset()<br>
>  * init vblanking<br>
>  * init the irq<br>
>  * do drm_kms_helper_poll_init()<br>
> <br>
> roughtly in that order. It makes sense to call drm_vblank_init() after<br>
> drm_mode_config_reset(), as vblanking uses some of the mode-config fields. <br>
> ------------------------------------------------------------------------------------------------------<br>
> <br>
> <br>
>             Sam<br>
> <br>
> <br>
> _______________________________________________<br>
> dri-devel mailing list<br>
> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
> <br>
<br>
-- <br>
Thomas Zimmermann<br>
Graphics Driver Developer<br>
SUSE Software Solutions Germany GmbH<br>
Maxfeldstr. 5, 90409 Nürnberg, Germany<br>
(HRB 36809, AG Nürnberg)<br>
Geschäftsführer: Felix Imendörffer<br>
<br>
</blockquote></div></div>