mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: Abhishek Sahu <absahu@codeaurora.org>,
	boris.brezillon@free-electrons.com
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
	marek.vasut@gmail.com, richard@nod.at,
	cyrille.pitchen@wedev4u.fr, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	devicetree@vger.kernel.org, andy.gross@linaro.org,
	sricharan@codeaurora.org
Subject: Re: [PATCH v4 12/20] mtd: nand: qcom: QPIC data descriptors handling
Date: Wed, 16 Aug 2017 11:11:16 +0530	[thread overview]
Message-ID: <3797ccb1-6e39-ed4a-6b93-2863a2944a29@codeaurora.org> (raw)
In-Reply-To: <1502451575-15712-13-git-send-email-absahu@codeaurora.org>



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:
> 1. Add the data descriptor preparation function which will be used
>     only by BAM DMA for forming the data SGL’s
> 2. Add clear BAM transaction and call it before every new request
> 3. Check DMA mode for ADM or BAM and call the appropriate
>     descriptor formation function.

Reviewed-by: Archit Taneja <architt@codeaurora.org>

Thanks,
Archit

> 
> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
> ---
>   drivers/mtd/nand/qcom_nandc.c | 76 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 76 insertions(+)
> 
> diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
> index ae873d3..85fbe00 100644
> --- a/drivers/mtd/nand/qcom_nandc.c
> +++ b/drivers/mtd/nand/qcom_nandc.c
> @@ -470,6 +470,27 @@ static void free_bam_transaction(struct qcom_nand_controller *nandc)
>   	return bam_txn;
>   }
>   
> +/* Clears the BAM transaction indexes */
> +static void clear_bam_transaction(struct qcom_nand_controller *nandc)
> +{
> +	struct bam_transaction *bam_txn = nandc->bam_txn;
> +
> +	if (!nandc->props->is_bam)
> +		return;
> +
> +	bam_txn->cmd_sgl_pos = 0;
> +	bam_txn->cmd_sgl_start = 0;
> +	bam_txn->tx_sgl_pos = 0;
> +	bam_txn->tx_sgl_start = 0;
> +	bam_txn->rx_sgl_pos = 0;
> +	bam_txn->rx_sgl_start = 0;
> +
> +	sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage *
> +		      QPIC_PER_CW_CMD_SGL);
> +	sg_init_table(bam_txn->data_sgl, nandc->max_cwperpage *
> +		      QPIC_PER_CW_DATA_SGL);
> +}
> +
>   static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
>   {
>   	return container_of(chip, struct qcom_nand_host, chip);
> @@ -701,6 +722,41 @@ static int prepare_bam_async_desc(struct qcom_nand_controller *nandc,
>   	return 0;
>   }
>   
> +/*
> + * Prepares the data descriptor for BAM DMA which will be used for NAND
> + * data reads and writes.
> + */
> +static int prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read,
> +				  const void *vaddr,
> +				  int size, unsigned int flags)
> +{
> +	int ret;
> +	struct bam_transaction *bam_txn = nandc->bam_txn;
> +
> +	if (read) {
> +		sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos],
> +			   vaddr, size);
> +		bam_txn->rx_sgl_pos++;
> +	} else {
> +		sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos],
> +			   vaddr, size);
> +		bam_txn->tx_sgl_pos++;
> +
> +		/*
> +		 * BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag
> +		 * is not set, form the DMA descriptor
> +		 */
> +		if (!(flags & NAND_BAM_NO_EOT)) {
> +			ret = prepare_bam_async_desc(nandc, nandc->tx_chan,
> +						     DMA_PREP_INTERRUPT);
> +			if (ret)
> +				return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>   static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read,
>   			     int reg_off, const void *vaddr, int size,
>   			     bool flow_control)
> @@ -848,6 +904,9 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first,
>   static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
>   			 const u8 *vaddr, int size, unsigned int flags)
>   {
> +	if (nandc->props->is_bam)
> +		return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags);
> +
>   	return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false);
>   }
>   
> @@ -862,6 +921,9 @@ static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
>   static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
>   			  const u8 *vaddr, int size, unsigned int flags)
>   {
> +	if (nandc->props->is_bam)
> +		return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags);
> +
>   	return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false);
>   }
>   
> @@ -1149,6 +1211,10 @@ static void pre_command(struct qcom_nand_host *host, int command)
>   	host->last_command = command;
>   
>   	clear_read_regs(nandc);
> +
> +	if (command == NAND_CMD_RESET || command == NAND_CMD_READID ||
> +	    command == NAND_CMD_PARAM || command == NAND_CMD_ERASE1)
> +		clear_bam_transaction(nandc);
>   }
>   
>   /*
> @@ -1553,6 +1619,7 @@ static int qcom_nandc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
>   	data_buf = buf;
>   	oob_buf = oob_required ? chip->oob_poi : NULL;
>   
> +	clear_bam_transaction(nandc);
>   	ret = read_page_ecc(host, data_buf, oob_buf);
>   	if (ret) {
>   		dev_err(nandc->dev, "failure to read page\n");
> @@ -1578,6 +1645,8 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd,
>   	oob_buf = chip->oob_poi;
>   
>   	host->use_ecc = false;
> +
> +	clear_bam_transaction(nandc);
>   	update_rw_regs(host, ecc->steps, true);
>   	config_nand_page_read(nandc);
>   
> @@ -1649,6 +1718,7 @@ static int qcom_nandc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
>   	int ret;
>   
>   	clear_read_regs(nandc);
> +	clear_bam_transaction(nandc);
>   
>   	host->use_ecc = true;
>   	set_address(host, 0, page);
> @@ -1672,6 +1742,7 @@ static int qcom_nandc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
>   	int i, ret;
>   
>   	clear_read_regs(nandc);
> +	clear_bam_transaction(nandc);
>   
>   	data_buf = (u8 *)buf;
>   	oob_buf = chip->oob_poi;
> @@ -1737,6 +1808,7 @@ static int qcom_nandc_write_page_raw(struct mtd_info *mtd,
>   	int i, ret;
>   
>   	clear_read_regs(nandc);
> +	clear_bam_transaction(nandc);
>   
>   	data_buf = (u8 *)buf;
>   	oob_buf = chip->oob_poi;
> @@ -1813,11 +1885,13 @@ static int qcom_nandc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
>   
>   	host->use_ecc = true;
>   
> +	clear_bam_transaction(nandc);
>   	ret = copy_last_cw(host, page);
>   	if (ret)
>   		return ret;
>   
>   	clear_read_regs(nandc);
> +	clear_bam_transaction(nandc);
>   
>   	/* calculate the data and oob size for the last codeword/step */
>   	data_size = ecc->size - ((ecc->steps - 1) << 2);
> @@ -1870,6 +1944,7 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs)
>   	 */
>   	host->use_ecc = false;
>   
> +	clear_bam_transaction(nandc);
>   	ret = copy_last_cw(host, page);
>   	if (ret)
>   		goto err;
> @@ -1900,6 +1975,7 @@ static int qcom_nandc_block_markbad(struct mtd_info *mtd, loff_t ofs)
>   	int page, ret, status = 0;
>   
>   	clear_read_regs(nandc);
> +	clear_bam_transaction(nandc);
>   
>   	/*
>   	 * to mark the BBM as bad, we flash the entire last codeword with 0s.
> 

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2017-08-16  5:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 11:39 [PATCH v4 00/20] Add QCOM QPIC NAND support Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 01/20] mtd: nand: qcom: fix read failure without complete bootchain Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 02/20] mtd: nand: qcom: support for NAND controller properties Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 03/20] mtd: nand: qcom: add bam property for QPIC NAND controller Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 04/20] mtd: nand: qcom: add and initialize QPIC DMA resources Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 05/20] mtd: nand: qcom: DMA mapping support for register read buffer Abhishek Sahu
2017-08-16  3:35   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 06/20] mtd: nand: qcom: allocate BAM transaction Abhishek Sahu
2017-08-16  3:40   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 07/20] mtd: nand: qcom: add BAM DMA descriptor handling Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 08/20] mtd: nand: qcom: support for passing flags in transfer functions Abhishek Sahu
2017-08-16  4:18   ` Archit Taneja
2017-08-16  7:23     ` Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 09/20] mtd: nand: qcom: support for read location registers Abhishek Sahu
2017-08-16  4:34   ` Archit Taneja
2017-08-16  7:34     ` Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 10/20] mtd: nand: qcom: erased codeword detection configuration Abhishek Sahu
2017-08-16  4:44   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 11/20] mtd: nand: qcom: enable BAM or ADM mode Abhishek Sahu
2017-08-16  4:50   ` Archit Taneja
2017-08-16  8:49     ` Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 12/20] mtd: nand: qcom: QPIC data descriptors handling Abhishek Sahu
2017-08-16  5:41   ` Archit Taneja [this message]
2017-08-11 11:39 ` [PATCH v4 13/20] mtd: nand: qcom: support for different DEV_CMD register offsets Abhishek Sahu
2017-08-16  5:52   ` Archit Taneja
2017-08-16  8:57     ` Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 14/20] mtd: nand: qcom: add command elements in BAM transaction Abhishek Sahu
2017-08-16  5:53   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 15/20] mtd: nand: qcom: support for command descriptor formation Abhishek Sahu
2017-08-16  6:00   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 16/20] dt-bindings: qcom_nandc: fix the ipq806x device tree example Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 17/20] dt-bindings: qcom_nandc: IPQ4019 QPIC NAND documentation Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 18/20] dt-bindings: qcom_nandc: IPQ8074 " Abhishek Sahu
2017-08-11 11:39 ` [PATCH v4 19/20] mtd: nand: qcom: support for IPQ4019 QPIC NAND controller Abhishek Sahu
2017-08-16  6:02   ` Archit Taneja
2017-08-11 11:39 ` [PATCH v4 20/20] mtd: nand: qcom: support for IPQ8074 " Abhishek Sahu
2017-08-16  6:02   ` Archit Taneja
2017-08-13  7:47 ` [PATCH v4 00/20] Add QCOM QPIC NAND support Boris Brezillon
2017-08-14 12:28   ` Abhishek Sahu

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=3797ccb1-6e39-ed4a-6b93-2863a2944a29@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=absahu@codeaurora.org \
    --cc=andy.gross@linaro.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=sricharan@codeaurora.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

Powered by JetHome