* [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions.
@ 2017-10-14 0:12 Eric Anholt
2017-10-14 7:28 ` Paul Menzel
2017-10-14 7:53 ` Boris Brezillon
0 siblings, 2 replies; 3+ messages in thread
From: Eric Anholt @ 2017-10-14 0:12 UTC (permalink / raw)
To: dri-devel; +Cc: linux-kernel, Boris Brezillon, 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.
As a solution, use an interrupt thread so that all our writes happen
when sleeping is is allowed.
v2: Use IRQF_ONESHOT (suggested by Boris)
Signed-off-by: Eric Anholt <eric@anholt.net>
---
Boris, that cleanup ended up working and it looks great. Thanks!
drivers/gpu/drm/vc4/vc4_dsi.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
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 = IRQ_HANDLED;
}
+/* 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.
+ */
+static irqreturn_t vc4_dsi_irq_defer_to_thread_handler(int irq, void *data)
+{
+ struct vc4_dsi *dsi = data;
+ u32 stat = 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 = 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));
- ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
- vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
+ if (dsi->reg_dma_mem) {
+ ret = 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 = devm_request_irq(dev, platform_get_irq(pdev, 0),
+ vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
+ }
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get interrupt: %d\n", ret);
--
2.14.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions.
2017-10-14 0:12 [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions Eric Anholt
@ 2017-10-14 7:28 ` Paul Menzel
2017-10-14 7:53 ` Boris Brezillon
1 sibling, 0 replies; 3+ messages in thread
From: Paul Menzel @ 2017-10-14 7:28 UTC (permalink / raw)
To: Eric Anholt; +Cc: Boris Brezillon, linux-kernel, dri-devel
[-- Attachment #1: Type: text/plain, Size: 3373 bytes --]
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.
>
> As a solution, use an interrupt thread so that all our writes happen
> when sleeping is is allowed.
>
> v2: Use IRQF_ONESHOT (suggested by Boris)
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> ---
>
> Boris, that cleanup ended up working and it looks great. Thanks!
>
> drivers/gpu/drm/vc4/vc4_dsi.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> 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 = IRQ_HANDLED;
> }
>
> +/* 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 “blank comment line” at the beginning [1].
> The preferred style for long (multi-line) comments is:
>
> /*
> * 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 *data)
> +{
> + struct vc4_dsi *dsi = data;
> + u32 stat = 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 = 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));
>
> - ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
> - vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
> + if (dsi->reg_dma_mem) {
> + ret = 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 = 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 != -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#commenting
[2] https://www.kernel.org/doc/html/v4.13/process/coding-style.html#placing-braces-and-spaces
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions.
2017-10-14 0:12 [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions Eric Anholt
2017-10-14 7:28 ` Paul Menzel
@ 2017-10-14 7:53 ` Boris Brezillon
1 sibling, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2017-10-14 7:53 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, linux-kernel
On Fri, 13 Oct 2017 17:12:55 -0700
Eric Anholt <eric@anholt.net> wrote:
> 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.
>
> As a solution, use an interrupt thread so that all our writes happen
> when sleeping is is allowed.
>
> v2: Use IRQF_ONESHOT (suggested by Boris)
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>
> Boris, that cleanup ended up working and it looks great. Thanks!
>
> drivers/gpu/drm/vc4/vc4_dsi.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> 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 = IRQ_HANDLED;
> }
>
> +/* 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.
> + */
> +static irqreturn_t vc4_dsi_irq_defer_to_thread_handler(int irq, void *data)
> +{
> + struct vc4_dsi *dsi = data;
> + u32 stat = 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 = 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));
>
> - ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
> - vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
> + if (dsi->reg_dma_mem) {
> + ret = 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 = devm_request_irq(dev, platform_get_irq(pdev, 0),
> + vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
> + }
> if (ret) {
> if (ret != -EPROBE_DEFER)
> dev_err(dev, "Failed to get interrupt: %d\n", ret);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-14 8:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-14 0:12 [PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions Eric Anholt
2017-10-14 7:28 ` Paul Menzel
2017-10-14 7:53 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox