public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: kernel@pengutronix.de, Boris Brezillon <bbrezillon@kernel.org>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org, NXP Linux Team <linux-imx@nxp.com>,
	Fabio Estevam <festevam@gmail.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Han Xu <han.xu@nxp.com>, Shawn Guo <shawnguo@kernel.org>
Subject: Re: [PATCH 12/14] dma: mxs: Add header file to be shared with gpmi nand driver
Date: Tue, 23 Apr 2019 10:54:30 +0530	[thread overview]
Message-ID: <20190423052430.GI28103@vkoul-mobl> (raw)
In-Reply-To: <20190409113421.3037-13-s.hauer@pengutronix.de>

On 09-04-19, 13:34, Sascha Hauer wrote:
> The mxs dma driver can do PIO transfers. A pointer to the PIO words
> to transfer is passed in the struct scatterlist * argument of
> dmaengine_prep_slave_sg(). It's quite ugly and non obvious to cast
> u32 * to struct scatterlist * each time when calling
> dmaengine_prep_slave_sg(), so add a static inline wrapper function
> to be called by the user along with a description what is going on.

Again after fixing subsystem tag to dmanegine: 

Acked-by: Vinod Koul <vkoul@kernel.org>

> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/dma/mxs-dma.c                      |  1 +
>  drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 36 +++++++++-------------
>  include/linux/dma/mxs-dma.h                | 21 +++++++++++++
>  3 files changed, 36 insertions(+), 22 deletions(-)
>  create mode 100644 include/linux/dma/mxs-dma.h
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index ce92a3626ea4..62ee9328aea1 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -24,6 +24,7 @@
>  #include <linux/of_device.h>
>  #include <linux/of_dma.h>
>  #include <linux/list.h>
> +#include <linux/dma/mxs-dma.h>
>  
>  #include <asm/irq.h>
>  
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index a6e769afc89a..cf016ec0b1c6 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -15,6 +15,7 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/dma/mxs-dma.h>
>  #include "gpmi-nand.h"
>  #include "gpmi-regs.h"
>  #include "bch-regs.h"
> @@ -913,9 +914,8 @@ static int gpmi_send_command(struct gpmi_nand_data *this)
>  		| BM_GPMI_CTRL0_ADDRESS_INCREMENT
>  		| BF_GPMI_CTRL0_XFER_COUNT(this->command_length);
>  	pio[1] = pio[2] = 0;
> -	desc = dmaengine_prep_slave_sg(channel,
> -					(struct scatterlist *)pio,
> -					ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, ARRAY_SIZE(pio),
> +				      DMA_TRANS_NONE, 0);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -988,8 +988,8 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf,
>  		| BF_GPMI_CTRL0_ADDRESS(address)
>  		| BF_GPMI_CTRL0_XFER_COUNT(len);
>  	pio[1] = 0;
> -	desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio,
> -					ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, ARRAY_SIZE(pio),
> +				      DMA_TRANS_NONE, 0);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -1025,9 +1025,8 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len)
>  		| BF_GPMI_CTRL0_ADDRESS(BV_GPMI_CTRL0_ADDRESS__NAND_DATA)
>  		| BF_GPMI_CTRL0_XFER_COUNT(len);
>  	pio[1] = 0;
> -	desc = dmaengine_prep_slave_sg(channel,
> -					(struct scatterlist *)pio,
> -					ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, ARRAY_SIZE(pio),
> +				      DMA_TRANS_NONE, 0);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -1083,10 +1082,8 @@ static int gpmi_send_page(struct gpmi_nand_data *this,  dma_addr_t payload,
>  	pio[4] = payload;
>  	pio[5] = auxiliary;
>  
> -	desc = dmaengine_prep_slave_sg(channel,
> -					(struct scatterlist *)pio,
> -					ARRAY_SIZE(pio), DMA_TRANS_NONE,
> -					DMA_CTRL_ACK);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, ARRAY_SIZE(pio),
> +				      DMA_TRANS_NONE, DMA_CTRL_ACK);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -1117,9 +1114,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this,
>  		| BF_GPMI_CTRL0_ADDRESS(address)
>  		| BF_GPMI_CTRL0_XFER_COUNT(0);
>  	pio[1] = 0;
> -	desc = dmaengine_prep_slave_sg(channel,
> -				(struct scatterlist *)pio, 2,
> -				DMA_TRANS_NONE, 0);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, 2, DMA_TRANS_NONE, 0);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -1144,10 +1139,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this,
>  	pio[3] = geo->page_size;
>  	pio[4] = payload;
>  	pio[5] = auxiliary;
> -	desc = dmaengine_prep_slave_sg(channel,
> -					(struct scatterlist *)pio,
> -					ARRAY_SIZE(pio), DMA_TRANS_NONE,
> -					DMA_CTRL_ACK);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, ARRAY_SIZE(pio),
> +				      DMA_TRANS_NONE, DMA_CTRL_ACK);
>  	if (!desc)
>  		return -EINVAL;
>  
> @@ -1163,9 +1156,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this,
>  		| BF_GPMI_CTRL0_XFER_COUNT(geo->page_size);
>  	pio[1] = 0;
>  	pio[2] = 0; /* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */
> -	desc = dmaengine_prep_slave_sg(channel,
> -				(struct scatterlist *)pio, 3,
> -				DMA_TRANS_NONE, DMA_CTRL_ACK);
> +	desc = mxs_dmaengine_prep_pio(channel, pio, 3, DMA_TRANS_NONE,
> +				      DMA_CTRL_ACK);
>  	if (!desc)
>  		return -EINVAL;
>  
> diff --git a/include/linux/dma/mxs-dma.h b/include/linux/dma/mxs-dma.h
> new file mode 100644
> index 000000000000..092b2a7b92ac
> --- /dev/null
> +++ b/include/linux/dma/mxs-dma.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _MXS_DMA_H_
> +#define _MXS_DMA_H_
> +
> +#include <linux/dmaengine.h>
> +
> +/*
> + * The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words
> + * in the second argument to dmaengine_prep_slave_sg when the direction is
> + * set to DMA_TRANS_NONE. To make this clear and to prevent users from doing
> + * the error prone casting we have this wrapper function
> + */
> +static inline struct dma_async_tx_descriptor *mxs_dmaengine_prep_pio(
> +        struct dma_chan *chan, u32 *pio, unsigned int npio,
> +        enum dma_transfer_direction dir, unsigned long flags)
> +{
> +	return dmaengine_prep_slave_sg(chan, (struct scatterlist *)pio, npio,
> +				       dir, flags);
> +}
> +
> +#endif /* _MXS_DMA_H_ */
> -- 
> 2.20.1

-- 
~Vinod

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-04-23  5:24 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 11:34 [PATCH v2 00/14] Implement exec_op for GPMI nand driver Sascha Hauer
2019-04-09 11:34 ` [PATCH 01/14] mtd: rawnand: export nand operation tracer Sascha Hauer
2019-04-17 10:22   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 02/14] mtd: rawnand: fsmc: Use nand_op_trace for operation tracing Sascha Hauer
2019-04-17 10:22   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 03/14] mtd: rawnand: gpmi: move all driver code into single file Sascha Hauer
2019-04-17 10:23   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 04/14] mtd: rawnand: gpmi: remove unused variable Sascha Hauer
2019-04-17 10:24   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 05/14] mtd: rawnand: gpmi: Remove unnecessary variables Sascha Hauer
2019-04-17 10:24   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 06/14] mtd: rawnand: gpmi: read buf in nand_read_page_op Sascha Hauer
2019-04-17 10:25   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 07/14] mtd: rawnand: gpmi: remove unused parameters Sascha Hauer
2019-04-17 10:26   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 08/14] mtd: rawnand: gpmi: Drop unnecessary restoring of previous chipselection Sascha Hauer
2019-04-17 10:27   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 09/14] mtd: rawnand: gpmi: use runtime PM to manage clocks Sascha Hauer
2019-04-17 10:28   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 10/14] dma: mxs: Drop unnecessary flag Sascha Hauer
2019-04-17  8:16   ` Miquel Raynal
2019-04-23  5:21     ` Vinod Koul
2019-04-23  5:22   ` Vinod Koul
2019-04-09 11:34 ` [PATCH 11/14] mtd: rawnand: gpmi: drop " Sascha Hauer
2019-04-17 10:28   ` Miquel Raynal
2019-04-09 11:34 ` [PATCH 12/14] dma: mxs: Add header file to be shared with gpmi nand driver Sascha Hauer
2019-04-23  5:24   ` Vinod Koul [this message]
2019-04-09 11:34 ` [PATCH 13/14] dma: mxs: rename custom flag Sascha Hauer
2019-04-23  5:25   ` Vinod Koul
2019-04-09 11:34 ` [PATCH 14/14] mtd: rawnand: gpmi: Implement exec_op Sascha Hauer
2019-04-17 10:33   ` Miquel Raynal
2019-04-24  7:09     ` Sascha Hauer
2019-04-29  7:23       ` Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190423052430.GI28103@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=bbrezillon@kernel.org \
    --cc=festevam@gmail.com \
    --cc=han.xu@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox