From patchwork Wed Jan 9 09:04:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 1951311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 2B0F1DF25A for ; Wed, 9 Jan 2013 09:08:13 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TsraK-0007ye-Le; Wed, 09 Jan 2013 09:04:33 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TsraH-0007xq-A7 for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 09:04:30 +0000 Received: from pizza.hi.pengutronix.de ([2001:6f8:1178:2:ca9c:dcff:febd:f1b5]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Tsra7-0000Gn-Or; Wed, 09 Jan 2013 10:04:19 +0100 Subject: Re: [PATCH 7/7] ARM i.MX51 babbage: Add display support From: Philipp Zabel To: Marek Vasut In-Reply-To: <201301081829.06441.marex@denx.de> References: <1352733809-27230-1-git-send-email-s.hauer@pengutronix.de> <201301081809.38537.marex@denx.de> <1357665800.2527.17.camel@pizza.hi.pengutronix.de> <201301081829.06441.marex@denx.de> Date: Wed, 09 Jan 2013 10:04:18 +0100 Message-ID: <1357722258.2538.2.camel@pizza.hi.pengutronix.de> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:ca9c:dcff:febd:f1b5 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130109_040429_890822_59BDBA5B X-CRM114-Status: GOOD ( 39.64 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Sascha Hauer , Shawn Guo , Fabio Estevam , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Hi Marek, Am Dienstag, den 08.01.2013, 18:29 +0100 schrieb Marek Vasut: > Dear Philipp Zabel, > > > Am Dienstag, den 08.01.2013, 18:09 +0100 schrieb Marek Vasut: > > > Dear Fabio Estevam, > > > > > > > On Tue, Jan 8, 2013 at 2:41 PM, Fabio Estevam wrote: > > > > > Hi Sascha, > > > > > > > > > > On Mon, Nov 12, 2012 at 1:23 PM, Sascha Hauer > > > > > > > > > > > wrote: > > > > >> The babbage board has a DVI-I output which allows to output analog > > > > >> and digital signals simultaneously. This patch adds support for it > > > > >> to the devicetree. The DDC signals are not wired up on the board, so > > > > >> DRM will fall back on default VESA modes. > > > > >> > > > > >> Signed-off-by: Sascha Hauer > > > > > > > > > > I am running linux-next 20130108, which has this patch applied and I > > > > > > > > > get the following on my mx51babbage: > > > > Ok, good news. I see a nice penguin on my monitor now. > > > > > > > > Discussed with Marek and he proposed a quick workaround: > > > > > > > > --- a/drivers/staging/imx-drm/ipuv3-crtc.c > > > > +++ b/drivers/staging/imx-drm/ipuv3-crtc.c > > > > @@ -343,6 +343,11 @@ static irqreturn_t ipu_irq_handler(int irq, void > > > > *dev_id) { > > > > > > > > struct ipu_crtc *ipu_crtc = dev_id; > > > > > > > > + if (!ipu_crtc->imx_crtc) { > > > > + pr_err("Spurious IPU IRQ\n"); > > > > + return IRQ_HANDLED; > > > > + } > > > > + > > > > > > > > imx_drm_handle_vblank(ipu_crtc->imx_crtc); > > > > > > > > if (ipu_crtc->newfb) { > > > > > > > > It seems that this issue happened because bootloader leaves the IPU > > > > turned on. > > > > > > To elaborate more on this stuff: > > > > > > 491 ipu_crtc->irq = ipu_idmac_channel_irq(ipu, ipu_crtc->ipu_ch, > > > 492 IPU_IRQ_EOF); > > > 493 ret = devm_request_irq(ipu_crtc->dev, ipu_crtc->irq, > > > ipu_irq_handler, 0, > > > 494 "imx_drm", ipu_crtc); > > > 495 if (ret < 0) { > > > 496 dev_err(ipu_crtc->dev, "irq request failed with > > > %d.\n", ret); > > > 497 goto err_out; > > > 498 } > > > 499 > > > 500 disable_irq(ipu_crtc->irq); > > > > > > This code in drivers/staging/imx-drm/ipuv3-crtc.c is broken. If the IPU > > > is on, it produces an interrupt before the driver is fully set up. I > > > didn't produce a patch yet, I think I might offload this to someone > > > else. Volunteers? > > > > Reordering the ipu_get_resources and imx_drm_add_crtc calls should resolve > > this: > > > > From: Philipp Zabel > > Subject: [PATCH] staging: imx/drm: add crtc before registering interrupt > > handler > > > > If the bootloader already enabled the display, the interrupt handler > > will be called as soon as it is registered. If the CRTC is not already > > added at this time, the call to imx_drm_handle_vblank will result in > > a NULL pointer dereference. > > I ain't no IPU expert, but isn't adding the component before having it fully > inited even worse? Good point, how about just moving the irq request out of ipu_get_resources into ipu_crtc_init, after adding the crtc: From: Philipp Zabel Subject: [PATCH] staging: imx/drm: request irq only after adding the crtc If the bootloader already enabled the display, the interrupt handler will be called as soon as it is registered. If the CRTC is not already added at this time, the call to imx_drm_handle_vblank will result in a NULL pointer dereference. Signed-off-by: Philipp Zabel --- drivers/staging/imx-drm/ipuv3-crtc.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 4b3a019..b028b0d 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -483,17 +483,6 @@ static int ipu_get_resources(struct ipu_crtc *ipu_crtc, goto err_out; } - ipu_crtc->irq = ipu_idmac_channel_irq(ipu, ipu_crtc->ipu_ch, - IPU_IRQ_EOF); - ret = devm_request_irq(ipu_crtc->dev, ipu_crtc->irq, ipu_irq_handler, 0, - "imx_drm", ipu_crtc); - if (ret < 0) { - dev_err(ipu_crtc->dev, "irq request failed with %d.\n", ret); - goto err_out; - } - - disable_irq(ipu_crtc->irq); - return 0; err_out: ipu_put_resources(ipu_crtc); @@ -504,6 +493,7 @@ err_out: static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, struct ipu_client_platformdata *pdata) { + struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); int ret; ret = ipu_get_resources(ipu_crtc, pdata); @@ -522,6 +512,17 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, goto err_put_resources; } + ipu_crtc->irq = ipu_idmac_channel_irq(ipu, ipu_crtc->ipu_ch, + IPU_IRQ_EOF); + ret = devm_request_irq(ipu_crtc->dev, ipu_crtc->irq, ipu_irq_handler, 0, + "imx_drm", ipu_crtc); + if (ret < 0) { + dev_err(ipu_crtc->dev, "irq request failed with %d.\n", ret); + goto err_put_resources; + } + + disable_irq(ipu_crtc->irq); + return 0; err_put_resources: