From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752434AbdJNIN3 (ORCPT ); Sat, 14 Oct 2017 04:13:29 -0400 Received: from mail.gw90.de ([46.4.124.165]:34848 "EHLO mail.gw90.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbdJNIN0 (ORCPT ); Sat, 14 Oct 2017 04:13:26 -0400 X-Greylist: delayed 2708 seconds by postgrey-1.27 at vger.kernel.org; Sat, 14 Oct 2017 04:13:25 EDT Message-ID: <1507966084.12309.129.camel@users.sourceforge.net> Subject: Re: [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions. From: Paul Menzel To: Eric Anholt Cc: Boris Brezillon , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Sat, 14 Oct 2017 09:28:04 +0200 In-Reply-To: <20171014001255.32005-1-eric@anholt.net> References: <20171014001255.32005-1-eric@anholt.net> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-q9iEcIsXGN0dG5ZGjWBV" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-q9iEcIsXGN0dG5ZGjWBV Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Eric, Some nit picks where stuff contradicts the coding style. Am Freitag, den 13.10.2017, 17:12 -0700 schrieb Eric Anholt: > VC4's DSI1 has a bug where the AXI connection is broken for 32-bit > writes from the CPU, so we use the DMA engine to DMA 32-bit values > into registers instead. That sleeps, so we can't do it from the top > half. >=20 > As a solution, use an interrupt thread so that all our writes happen > when sleeping is is allowed. >=20 > v2: Use IRQF_ONESHOT (suggested by Boris) >=20 > Signed-off-by: Eric Anholt > --- >=20 > Boris, that cleanup ended up working and it looks great. Thanks! >=20 > drivers/gpu/drm/vc4/vc4_dsi.c | 31 +++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.= c > index 554605af344e..3b74fda5662d 100644 > --- a/drivers/gpu/drm/vc4/vc4_dsi.c > +++ b/drivers/gpu/drm/vc4/vc4_dsi.c > @@ -1360,6 +1360,25 @@ static void dsi_handle_error(struct vc4_dsi *dsi, > *ret =3D IRQ_HANDLED; > } > =20 > +/* Initial handler for port 1 where we need the reg_dma workaround. > + * The register DMA writes sleep, so we can't do it in the top half. > + * Instead we use IRQF_ONESHOT so that the IRQ gets disabled in the > + * parent interrupt contrller until our interrupt thread is done. > + */ There should be a =E2=80=9Cblank comment line=E2=80=9D at the beginning [1]= . > The preferred style for long (multi-line) comments is: >=20 > /* > * This is the preferred style for multi-line > * comments in the Linux kernel source code. > * Please use it consistently. > * > * Description: A column of asterisks on the left side, > * with beginning and ending almost-blank lines. > */ > +static irqreturn_t vc4_dsi_irq_defer_to_thread_handler(int irq, void *da= ta) > +{ > + struct vc4_dsi *dsi =3D data; > + u32 stat =3D DSI_PORT_READ(INT_STAT); > + > + if (!stat) > + return IRQ_NONE; > + > + return IRQ_WAKE_THREAD; > +} > + > +/* Normal IRQ handler for port 0, or the threaded IRQ handler for port > + * 1 where we need the reg_dma workaround. > + */ > static irqreturn_t vc4_dsi_irq_handler(int irq, void *data) > { > struct vc4_dsi *dsi =3D data; > @@ -1539,8 +1558,16 @@ static int vc4_dsi_bind(struct device *dev, struct= device *master, void *data) > /* Clear any existing interrupt state. */ > DSI_PORT_WRITE(INT_STAT, DSI_PORT_READ(INT_STAT)); > =20 > - ret =3D devm_request_irq(dev, platform_get_irq(pdev, 0), > - vc4_dsi_irq_handler, 0, "vc4 dsi", dsi); > + if (dsi->reg_dma_mem) { > + ret =3D devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), > + vc4_dsi_irq_defer_to_thread_handler, > + vc4_dsi_irq_handler, > + IRQF_ONESHOT, > + "vc4 dsi", dsi); > + } else { > + ret =3D devm_request_irq(dev, platform_get_irq(pdev, 0), > + vc4_dsi_irq_handler, 0, "vc4 dsi", dsi); > + } The braces should be removed [2]. > Do not unnecessarily use braces where a single statement will do. > if (ret) { > if (ret !=3D -EPROBE_DEFER) > dev_err(dev, "Failed to get interrupt: %d\n", ret); Thanks, Paul [1] https://www.kernel.org/doc/html/v4.13/process/coding-style.html#comment= ing [2] https://www.kernel.org/doc/html/v4.13/process/coding-style.html#placing= -braces-and-spaces --=-q9iEcIsXGN0dG5ZGjWBV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQQ8+w9d414FAVARIpk9fVorbA4dWAUCWeG8hgAKCRA9fVorbA4d WHaNAJ9axqRuXwSRA9cRrK0+AU2BlJwcqwCghkfFZd3wHs3iG5KLwAqk7IZKzfY= =ztlU -----END PGP SIGNATURE----- --=-q9iEcIsXGN0dG5ZGjWBV--