linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops
       [not found] <20220719150000.383722-1-biju.das.jz@bp.renesas.com>
@ 2022-07-19 15:00 ` Biju Das
  2022-07-19 17:43   ` Mark Brown
  2022-07-21  9:48   ` Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Biju Das @ 2022-07-19 15:00 UTC (permalink / raw)
  To: Mark Brown
  Cc: Biju Das, linux-spi, Vinod Koul, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

RSPI IP on RZ/{A, G2L} SoC's has the same signal for both interrupt and
DMA transfer request. Setting DMARS register for DMA transfer
makes the signal to work as a DMA transfer request signal and
subsequent interrupt requests to the interrupt controller
are masked.

Currently, DMA to interrupt mode switching does not work because of this
masking.

This patch adds need_dmar_clr device configuration flag to spi_ops
and it makes the signal to work as an interrupt request by clearing
DMARS after DMA callback.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
 * Fixed the typo need_dmar_clr->rspi->ops->need_dmar_clr.
---
 drivers/spi/spi-rspi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 7a014eeec2d0..8e316f0025e4 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -249,6 +249,7 @@ struct spi_ops {
 	u16 flags;
 	u16 fifo_size;
 	u8 num_hw_ss;
+	bool need_dmar_clr;
 };
 
 static void rspi_set_rate(struct rspi_data *rspi)
@@ -613,6 +614,12 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 					       rspi->dma_callbacked, HZ);
 	if (ret > 0 && rspi->dma_callbacked) {
 		ret = 0;
+		if (rspi->ops->need_dmar_clr) {
+			if (tx)
+				dmaengine_synchronize(rspi->ctlr->dma_tx);
+			if (rx)
+				dmaengine_synchronize(rspi->ctlr->dma_rx);
+		}
 	} else {
 		if (!ret) {
 			dev_err(&rspi->ctlr->dev, "DMA timeout\n");
@@ -1196,6 +1203,7 @@ static const struct spi_ops rspi_rz_ops = {
 	.flags =		SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX,
 	.fifo_size =		8,	/* 8 for TX, 32 for RX */
 	.num_hw_ss =		1,
+	.need_dmar_clr =	true,
 };
 
 static const struct spi_ops qspi_ops = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops
  2022-07-19 15:00 ` [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops Biju Das
@ 2022-07-19 17:43   ` Mark Brown
  2022-07-21  9:48   ` Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-07-19 17:43 UTC (permalink / raw)
  To: Biju Das
  Cc: linux-spi, Vinod Koul, Geert Uytterhoeven, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

On Tue, Jul 19, 2022 at 04:00:00PM +0100, Biju Das wrote:
> RSPI IP on RZ/{A, G2L} SoC's has the same signal for both interrupt and
> DMA transfer request. Setting DMARS register for DMA transfer
> makes the signal to work as a DMA transfer request signal and
> subsequent interrupt requests to the interrupt controller
> are masked.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops
  2022-07-19 15:00 ` [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops Biju Das
  2022-07-19 17:43   ` Mark Brown
@ 2022-07-21  9:48   ` Geert Uytterhoeven
  2022-07-21 10:24     ` Biju Das
  1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2022-07-21  9:48 UTC (permalink / raw)
  To: Biju Das
  Cc: Mark Brown, linux-spi, Vinod Koul, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad, Linux-Renesas

Hi Biju,

On Tue, Jul 19, 2022 at 5:00 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> RSPI IP on RZ/{A, G2L} SoC's has the same signal for both interrupt and
> DMA transfer request. Setting DMARS register for DMA transfer
> makes the signal to work as a DMA transfer request signal and
> subsequent interrupt requests to the interrupt controller
> are masked.
>
> Currently, DMA to interrupt mode switching does not work because of this
> masking.
>
> This patch adds need_dmar_clr device configuration flag to spi_ops
> and it makes the signal to work as an interrupt request by clearing
> DMARS after DMA callback.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
>  * Fixed the typo need_dmar_clr->rspi->ops->need_dmar_clr.

Thanks for your patch!

> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -249,6 +249,7 @@ struct spi_ops {
>         u16 flags;
>         u16 fifo_size;
>         u8 num_hw_ss;
> +       bool need_dmar_clr;

Do you need this flag? See below.

>  };
>
>  static void rspi_set_rate(struct rspi_data *rspi)
> @@ -613,6 +614,12 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
>                                                rspi->dma_callbacked, HZ);
>         if (ret > 0 && rspi->dma_callbacked) {
>                 ret = 0;
> +               if (rspi->ops->need_dmar_clr) {
> +                       if (tx)
> +                               dmaengine_synchronize(rspi->ctlr->dma_tx);
> +                       if (rx)
> +                               dmaengine_synchronize(rspi->ctlr->dma_rx);
> +               }

Why not call it unconditionally?
If the DMAC driver does not provide a .device_synchronize(), it is
a no-op anyway.

BTW, I don't think there is a hard dependency on patch 1/2, so
I think this patch can go in through the SPI tree.

>         } else {
>                 if (!ret) {
>                         dev_err(&rspi->ctlr->dev, "DMA timeout\n");

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops
  2022-07-21  9:48   ` Geert Uytterhoeven
@ 2022-07-21 10:24     ` Biju Das
  0 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2022-07-21 10:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, linux-spi, Vinod Koul, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad, Linux-Renesas

Hi Geert,

Thanks for the feedback.

> Subject: Re: [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops
> 
> Hi Biju,
> 
> On Tue, Jul 19, 2022 at 5:00 PM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > RSPI IP on RZ/{A, G2L} SoC's has the same signal for both interrupt
> > and DMA transfer request. Setting DMARS register for DMA transfer
> > makes the signal to work as a DMA transfer request signal and
> > subsequent interrupt requests to the interrupt controller are masked.
> >
> > Currently, DMA to interrupt mode switching does not work because of
> > this masking.
> >
> > This patch adds need_dmar_clr device configuration flag to spi_ops and
> > it makes the signal to work as an interrupt request by clearing DMARS
> > after DMA callback.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v1->v2:
> >  * Fixed the typo need_dmar_clr->rspi->ops->need_dmar_clr.
> 
> Thanks for your patch!
> 
> > --- a/drivers/spi/spi-rspi.c
> > +++ b/drivers/spi/spi-rspi.c
> > @@ -249,6 +249,7 @@ struct spi_ops {
> >         u16 flags;
> >         u16 fifo_size;
> >         u8 num_hw_ss;
> > +       bool need_dmar_clr;
> 
> Do you need this flag? See below.

Ok.

> 
> >  };
> >
> >  static void rspi_set_rate(struct rspi_data *rspi) @@ -613,6 +614,12
> > @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct
> sg_table *tx,
> >                                                rspi->dma_callbacked,
> HZ);
> >         if (ret > 0 && rspi->dma_callbacked) {
> >                 ret = 0;
> > +               if (rspi->ops->need_dmar_clr) {
> > +                       if (tx)
> > +                               dmaengine_synchronize(rspi->ctlr-
> >dma_tx);
> > +                       if (rx)
> > +                               dmaengine_synchronize(rspi->ctlr-
> >dma_rx);
> > +               }
> 
> Why not call it unconditionally?
> If the DMAC driver does not provide a .device_synchronize(), it is a no-
> op anyway.

OK, currently rcar has this callback and it calls synchronize_irq();
So I guess it should be ok as we are calling this after wait_event
Synchronization with DMA callback.

> 
> BTW, I don't think there is a hard dependency on patch 1/2, so I think
> this patch can go in through the SPI tree.

OK.

Cheers,
Biju

> 
> >         } else {
> >                 if (!ret) {
> >                         dev_err(&rspi->ctlr->dev, "DMA timeout\n");
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker.
> But when I'm talking to journalists I just say "programmer" or something
> like that.
>                                 -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-21 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220719150000.383722-1-biju.das.jz@bp.renesas.com>
2022-07-19 15:00 ` [PATCH v2 2/2] spi: spi-rspi: Add need_dmar_clr to spi_ops Biju Das
2022-07-19 17:43   ` Mark Brown
2022-07-21  9:48   ` Geert Uytterhoeven
2022-07-21 10:24     ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).