<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Maxime Ripard <maxime@cerno.tech> 于2021年4月7日周三 下午6:45写道:<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>
Adding Jörg, Will and Robin,<br>
<br>
On Wed, Mar 31, 2021 at 09:21:19AM +0800, Kevin Tang wrote:<br>
> > > +static u32 check_mmu_isr(struct sprd_dpu *dpu, u32 reg_val)<br>
> > > +{<br>
> > > + struct dpu_context *ctx = &dpu->ctx;<br>
> > > + u32 mmu_mask = BIT_DPU_INT_MMU_VAOR_RD |<br>
> > > + BIT_DPU_INT_MMU_VAOR_WR |<br>
> > > + BIT_DPU_INT_MMU_INV_RD |<br>
> > > + BIT_DPU_INT_MMU_INV_WR;<br>
> > > + u32 val = reg_val & mmu_mask;<br>
> > > + int i;<br>
> > > +<br>
> > > + if (val) {<br>
> > > + drm_err(dpu->drm, "--- iommu interrupt err: 0x%04x ---\n",<br>
> > val);<br>
> > > +<br>
> > > + if (val & BIT_DPU_INT_MMU_INV_RD)<br>
> > > + drm_err(dpu->drm, "iommu invalid read error, addr:<br>
> > 0x%08x\n",<br>
> > > + readl(ctx->base + REG_MMU_INV_ADDR_RD));<br>
> > > + if (val & BIT_DPU_INT_MMU_INV_WR)<br>
> > > + drm_err(dpu->drm, "iommu invalid write error,<br>
> > addr: 0x%08x\n",<br>
> > > + readl(ctx->base + REG_MMU_INV_ADDR_WR));<br>
> > > + if (val & BIT_DPU_INT_MMU_VAOR_RD)<br>
> > > + drm_err(dpu->drm, "iommu va out of range read<br>
> > error, addr: 0x%08x\n",<br>
> > > + readl(ctx->base + REG_MMU_VAOR_ADDR_RD));<br>
> > > + if (val & BIT_DPU_INT_MMU_VAOR_WR)<br>
> > > + drm_err(dpu->drm, "iommu va out of range write<br>
> > error, addr: 0x%08x\n",<br>
> > > + readl(ctx->base + REG_MMU_VAOR_ADDR_WR));<br>
> ><br>
> > Is that the IOMMU page fault interrupt? I would expect it to be in the<br>
> > iommu driver.<br>
> <br>
> Our iommu driver is indeed an separate driver, and also in upstreaming,<br>
> but iommu fault interrupts reporting by display controller, not iommu<br>
> itself,<br>
> if use iommu_set_fault_handler() to hook in our reporting function, there<br>
> must be cross-module access to h/w registers.<br>
<br>
Can you explain a bit more the design of the hardware then? Each device<br>
connected to the IOMMU has a status register (and an interrupt) that<br>
reports when there's a fault?<br>
<br>
I'd like to get an ack at least from the IOMMU maintainers and<br>
reviewers.<br></blockquote><div>Chunyan has helped explain it. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> > > +static void sprd_dpi_init(struct sprd_dpu *dpu)<br>
> > > +{<br>
> > > + struct dpu_context *ctx = &dpu->ctx;<br>
> > > + u32 int_mask = 0;<br>
> > > + u32 reg_val;<br>
> > > +<br>
> > > + if (ctx->if_type == SPRD_DPU_IF_DPI) {<br>
> > > + /* use dpi as interface */<br>
> > > + dpu_reg_clr(ctx, REG_DPU_CFG0, BIT_DPU_IF_EDPI);<br>
> > > + /* disable Halt function for SPRD DSI */<br>
> > > + dpu_reg_clr(ctx, REG_DPI_CTRL, BIT_DPU_DPI_HALT_EN);<br>
> > > + /* select te from external pad */<br>
> > > + dpu_reg_set(ctx, REG_DPI_CTRL,<br>
> > BIT_DPU_EDPI_FROM_EXTERNAL_PAD);<br>
> > > +<br>
> > > + /* set dpi timing */<br>
> > > + reg_val = ctx->vm.hsync_len << 0 |<br>
> > > + ctx->vm.hback_porch << 8 |<br>
> > > + ctx->vm.hfront_porch << 20;<br>
> > > + writel(reg_val, ctx->base + REG_DPI_H_TIMING);<br>
> > > +<br>
> > > + reg_val = ctx->vm.vsync_len << 0 |<br>
> > > + ctx->vm.vback_porch << 8 |<br>
> > > + ctx->vm.vfront_porch << 20;<br>
> > > + writel(reg_val, ctx->base + REG_DPI_V_TIMING);<br>
> > > +<br>
> > > + if (ctx->vm.vsync_len + ctx->vm.vback_porch < 32)<br>
> > > + drm_warn(dpu->drm, "Warning: (vsync + vbp) < 32, "<br>
> > > + "underflow risk!\n");<br>
> ><br>
> > I don't think a warning is appropriate here. Maybe we should just<br>
> > outright reject any mode that uses it?<br>
> ><br>
> This issue has been fixed on the new soc, maybe I should remove it.<br>
<br>
If it still requires a workaround on older SoC, you can definitely add<br>
it but we should prevent any situation where the underflow might occur<br>
instead of reporting it once we're there.<br></blockquote><div>Thks, <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>porch parameter is obtained from the panel driver</span></span></span>, s<span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>o I think it would be</span></span></span></div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>better to check on the panel side. I will remove it here.</span></span></span> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> > > +static enum drm_mode_status sprd_crtc_mode_valid(struct drm_crtc *crtc,<br>
> > > + const struct drm_display_mode<br>
> > *mode)<br>
> > > +{<br>
> > > + struct sprd_dpu *dpu = to_sprd_crtc(crtc);<br>
> > > +<br>
> > > + drm_dbg(dpu->drm, "%s() mode: "DRM_MODE_FMT"\n", __func__,<br>
> > DRM_MODE_ARG(mode));<br>
> > > +<br>
> > > + if (mode->type & DRM_MODE_TYPE_PREFERRED) {<br>
> > > + drm_display_mode_to_videomode(mode, &dpu->ctx.vm);<br>
> ><br>
> > You don't seem to use that anywhere else? And that's a bit fragile,<br>
> > nothing really guarantees that it's the mode you're going to use, and<br>
> > even then it can be adjusted.<br>
> ><br>
> drm_mode convert to video_mode is been use in "sprd_dpu_init" and<br>
> "sprd_dpi_init "<br>
> Preferred mode should be fixed mode, we generally don’t adjust it.<br>
<br>
That's not really the assumption DRM is built upon though. The userspace<br>
is even allowed to setup its own mode and try to configure it, and your<br>
driver should take that into account.<br>
<br>
I'd just drop that mode_valid hook, and retrieve the videomode if you<br>
need it in atomic_enable or mode_set_no_fb<br></blockquote><div>Yeah, i need videomode info to setup display controller, so i will retrieve the videomode</div><div>in mode_set_no_fb.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> ><br>
> > > +<br>
> > > + if ((mode->hdisplay == mode->htotal) ||<br>
> > > + (mode->vdisplay == mode->vtotal))<br>
> > > + dpu->ctx.if_type = SPRD_DPU_IF_EDPI;<br>
> > > + else<br>
> > > + dpu->ctx.if_type = SPRD_DPU_IF_DPI;<br>
> ><br>
> > From an API PoV, you would want that to be in atomic_check. However, I'm<br>
> > not even sure what it's doing in the first place?<br>
> ><br>
> dpi interface mode: DPI(dsi video mode panel) and EDPI(dsi cmd mode panel)<br>
> dpi interface mode has been used on crtc atomic_enable foo, so we need<br>
> check dpi interface<br>
> mode before atomic_enable.<br>
> <br>
> Must be put it in atomic_check? Here is the dpi interface mode selection,<br>
> maybe here is better?<br>
<br>
This doesn't have any relationship to the htotal and vtotal though? it's<br>
something that is carried over by the MIPI-DSI functions and struct<br>
mipi_dsi_device.<br></blockquote><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>You mean DPI/EDPI should be check in the encoder driver?</span></span></span> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> ><br>
> > > + }<br>
> > > +<br>
> > > + return MODE_OK;<br>
> > > +}<br>
> > > +<br>
> > > +static void sprd_crtc_atomic_enable(struct drm_crtc *crtc,<br>
> > > + struct drm_atomic_state *state)<br>
> > > +{<br>
> > > + struct sprd_dpu *dpu = to_sprd_crtc(crtc);<br>
> > > +<br>
> > > + sprd_dpu_init(dpu);<br>
> > > +<br>
> > > + sprd_dpi_init(dpu);<br>
> > > +<br>
> > > + enable_irq(dpu->ctx.irq);<br>
> ><br>
> > Shouldn't this be in enable_vblank? And I would assume that you would<br>
> > have the interrupts enabled all the time, but disabled in your device?<br>
> ><br>
> It seems better to put in enable_vblank, i will try and test it... Thks<br>
> <br>
> And I would assume that you would<br>
> have the interrupts enabled all the time, but disabled in your device?<br>
> [kevin]I don’t quite understand this, can you help me explain it in<br>
> detail?<br>
<br>
You seem to have a register that enables and disables the interrupt in<br>
that device. The way we usually deal with them in this case is just to<br>
call request_irq in your bind/probe with the interrupts enabled at the<br>
controller level, and mask them when needed at the device level by<br>
clearing / setting that bit.<br></blockquote><div> Yeah, we have display controller interrupts setting and clear register.</div><div>But the interrupts all been enabled in bootloader(eg, lk or uboot),</div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>if the interrupt handler is active in the probe/bind phase by request_irq,</span></span></span></div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>but the whole display pipeline is not ready, <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>there maybe have some problems.</span></span></span></span></span></span></div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><br></span></span></span></span></span></span></div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>So we want to manually control interrupt handler enable/disable, <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>make sure</span></span></span> all is ready,</span></span></span></span></span></span></span></span></span></div><div><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>then enable/disable interrupt handler.</span></span></span> </span></span></span> </span></span></span> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Maxime<br>
</blockquote></div></div>