linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Abhishek Sahu <absahu@codeaurora.org>
To: Archit Taneja <architt@codeaurora.org>
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
	boris.brezillon@free-electrons.com, marek.vasut@gmail.com,
	richard@nod.at, cyrille.pitchen@wedev4u.fr, robh+dt@kernel.org,
	mark.rutland@arm.com, devicetree@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mtd@lists.infradead.org, andy.gross@linaro.org,
	sricharan@codeaurora.org
Subject: Re: [PATCH 02/14] qcom: mtd: nand: add and initialize QPIC DMA resources
Date: Mon, 17 Jul 2017 11:56:37 +0530	[thread overview]
Message-ID: <f23d6ef150d1a4405301423b6be8d481@codeaurora.org> (raw)
In-Reply-To: <9fa676a5-db6b-4792-dd86-7603c01cd12d@codeaurora.org>

On 2017-07-03 10:47, Archit Taneja wrote:
> On 06/29/2017 12:45 PM, Abhishek Sahu wrote:
>> 1. The QPIC NAND uses 3 BAM channels: command, data tx and
>>     data rx while EBI2 NAND uses only single ADM channel.
>> 
>> 2. The EBI2 NAND uses normal register read buffer since this
>>     buffer will be remapped with dma_map_sg. The QPIC NAND will give
>>     register read buffer in command descriptor and the command
>>     descriptor will be mapped with dma_map_sg so the register buffer
>>     should be DMA coherent.
> 
> It isn't entirely clear from this commit message why we require
> reg_read_buf to be DMA coherent for QPIC NAND. Could you please explain 
> this
> better?

  I have used DMA coherent since we need to pass this memory in
  command descriptor where BAM will fill the register contents.
  Now for v2, I have planned to use streaming DMA API's and its
  working fine.



> 
> Besides Marek's comment to splitting the patch, it looks okay to me.
> 
> Thanks,
> Archit
> 
>> 
>> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
>> ---
>>   .../devicetree/bindings/mtd/qcom_nandc.txt         |  25 +++--
>>   drivers/mtd/nand/qcom_nandc.c                      | 106 
>> ++++++++++++++++-----
>>   2 files changed, 99 insertions(+), 32 deletions(-)
>> 
>> diff --git a/Documentation/devicetree/bindings/mtd/qcom_nandc.txt 
>> b/Documentation/devicetree/bindings/mtd/qcom_nandc.txt
>> index 5d0f7ae..87b9a56 100644
>> --- a/Documentation/devicetree/bindings/mtd/qcom_nandc.txt
>> +++ b/Documentation/devicetree/bindings/mtd/qcom_nandc.txt
>> @@ -9,15 +9,17 @@ Required properties:
>>   - clock-names:		must contain "core" for the core clock and "aon" for 
>> the
>>   			always on clock
>>   - dmas:			DMA specifier, consisting of a phandle to the ADM DMA
>> -			controller node and the channel number to be used for
>> -			NAND. Refer to dma.txt and qcom_adm.txt for more details
>> -- dma-names:		must be "rxtx"
>> -- qcom,cmd-crci:	must contain the ADM command type CRCI block 
>> instance
>> -			number specified for the NAND controller on the given
>> -			platform
>> -- qcom,data-crci:	must contain the ADM data type CRCI block instance
>> -			number specified for the NAND controller on the given
>> -			platform
>> +			or BAM DMA controller node and the channel number to
>> +			be used for NAND. Refer to dma.txt, qcom_adm.txt(ADM)
>> +			and qcom/bam_dma.txt(BAM) for more details
>> +- dma-names:		"rxtx" - ADM
>> +			"tx", "rx", "cmd" - BAM
>> +- qcom,cmd-crci:	Only required for ADM DMA. must contain the ADM 
>> command
>> +			type CRCI block instance number specified for the NAND
>> +			controller on the given platform.
>> +- qcom,data-crci:	Only required for ADM DMA. must contain the ADM 
>> data
>> +			type CRCI block instance number specified for the NAND
>> +			controller on the given platform.
>>   - #address-cells:	<1> - subnodes give the chip-select number
>>   - #size-cells:		<0>
>> 
>> @@ -95,6 +97,11 @@ nand@79b0000 {
>>   		<&gcc GCC_QPIC_AHB_CLK>;
>>   	clock-names = "core", "aon";
>> 
>> +	dmas = <&qpicbam 0>,
>> +		<&qpicbam 1>,
>> +		<&qpicbam 2>;
>> +	dma-names = "tx", "rx", "cmd";
>> +
>>   	#address-cells = <1>;
>>   	#size-cells = <0>;
>> 
>> diff --git a/drivers/mtd/nand/qcom_nandc.c 
>> b/drivers/mtd/nand/qcom_nandc.c
>> index f55f728..520add9 100644
>> --- a/drivers/mtd/nand/qcom_nandc.c
>> +++ b/drivers/mtd/nand/qcom_nandc.c
>> @@ -226,6 +226,7 @@ struct nandc_regs {
>>    *				by upper layers directly
>>    * @buf_size/count/start:	markers for chip->read_buf/write_buf 
>> functions
>>    * @reg_read_buf:		local buffer for reading back registers via DMA
>> + * @reg_read_buf_phys:		contains dma address for register read buffer
>>    * @reg_read_pos:		marker for data read in reg_read_buf
>>    *
>>    * @regs:			a contiguous chunk of memory for DMA register
>> @@ -249,9 +250,19 @@ struct qcom_nand_controller {
>>   	struct clk *core_clk;
>>   	struct clk *aon_clk;
>> 
>> -	struct dma_chan *chan;
>> -	unsigned int cmd_crci;
>> -	unsigned int data_crci;
>> +	union {
>> +		struct {
>> +			struct dma_chan *tx_chan;
>> +			struct dma_chan *rx_chan;
>> +			struct dma_chan *cmd_chan;
>> +		};
>> +		struct {
>> +			struct dma_chan *chan;
>> +			unsigned int cmd_crci;
>> +			unsigned int data_crci;
>> +		};
>> +	};
>> +
>>   	struct list_head desc_list;
>> 
>>   	u8		*data_buffer;
>> @@ -261,6 +272,7 @@ struct qcom_nand_controller {
>>   	int		buf_start;
>> 
>>   	__le32 *reg_read_buf;
>> +	dma_addr_t reg_read_buf_phys;
>>   	int reg_read_pos;
>> 
>>   	struct nandc_regs *regs;
>> @@ -1956,16 +1968,48 @@ static int qcom_nandc_alloc(struct 
>> qcom_nand_controller *nandc)
>>   	if (!nandc->regs)
>>   		return -ENOMEM;
>> 
>> -	nandc->reg_read_buf = devm_kzalloc(nandc->dev,
>> -				MAX_REG_RD * sizeof(*nandc->reg_read_buf),
>> -				GFP_KERNEL);
>> -	if (!nandc->reg_read_buf)
>> -		return -ENOMEM;
>> 
>> -	nandc->chan = dma_request_slave_channel(nandc->dev, "rxtx");
>> -	if (!nandc->chan) {
>> -		dev_err(nandc->dev, "failed to request slave channel\n");
>> -		return -ENODEV;
>> +	if (!nandc->dma_bam_enabled) {
>> +		nandc->reg_read_buf =
>> +			devm_kzalloc(nandc->dev, MAX_REG_RD *
>> +				     sizeof(*nandc->reg_read_buf), GFP_KERNEL);
>> +
>> +		if (!nandc->reg_read_buf)
>> +			return -ENOMEM;
>> +
>> +		nandc->chan = dma_request_slave_channel(nandc->dev, "rxtx");
>> +		if (!nandc->chan) {
>> +			dev_err(nandc->dev,
>> +				"failed to request slave channel\n");
>> +			return -ENODEV;
>> +		}
>> +	} else {
>> +		nandc->reg_read_buf =
>> +			dmam_alloc_coherent(nandc->dev, MAX_REG_RD *
>> +					    sizeof(*nandc->reg_read_buf),
>> +					    &nandc->reg_read_buf_phys,
>> +					    GFP_KERNEL);
>> +
>> +		if (!nandc->reg_read_buf)
>> +			return -ENOMEM;
>> +
>> +		nandc->tx_chan = dma_request_slave_channel(nandc->dev, "tx");
>> +		if (!nandc->tx_chan) {
>> +			dev_err(nandc->dev, "failed to request tx channel\n");
>> +			return -ENODEV;
>> +		}
>> +
>> +		nandc->rx_chan = dma_request_slave_channel(nandc->dev, "rx");
>> +		if (!nandc->rx_chan) {
>> +			dev_err(nandc->dev, "failed to request rx channel\n");
>> +			return -ENODEV;
>> +		}
>> +
>> +		nandc->cmd_chan = dma_request_slave_channel(nandc->dev, "cmd");
>> +		if (!nandc->cmd_chan) {
>> +			dev_err(nandc->dev, "failed to request cmd channel\n");
>> +			return -ENODEV;
>> +		}
>>   	}
>> 
>>   	INIT_LIST_HEAD(&nandc->desc_list);
>> @@ -1978,7 +2022,19 @@ static int qcom_nandc_alloc(struct 
>> qcom_nand_controller *nandc)
>> 
>>   static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc)
>>   {
>> -	dma_release_channel(nandc->chan);
>> +	if (nandc->dma_bam_enabled) {
>> +		if (nandc->tx_chan)
>> +			dma_release_channel(nandc->tx_chan);
>> +
>> +		if (nandc->rx_chan)
>> +			dma_release_channel(nandc->rx_chan);
>> +
>> +		if (nandc->cmd_chan)
>> +			dma_release_channel(nandc->cmd_chan);
>> +	} else {
>> +		if (nandc->chan)
>> +			dma_release_channel(nandc->chan);
>> +	}
>>   }
>> 
>>   /* one time setup of a few nand controller registers */
>> @@ -2063,16 +2119,20 @@ static int qcom_nandc_parse_dt(struct 
>> platform_device *pdev)
>>   	struct device_node *np = nandc->dev->of_node;
>>   	int ret;
>> 
>> -	ret = of_property_read_u32(np, "qcom,cmd-crci", &nandc->cmd_crci);
>> -	if (ret) {
>> -		dev_err(nandc->dev, "command CRCI unspecified\n");
>> -		return ret;
>> -	}
>> +	if (!nandc->dma_bam_enabled) {
>> +		ret = of_property_read_u32(np, "qcom,cmd-crci",
>> +					   &nandc->cmd_crci);
>> +		if (ret) {
>> +			dev_err(nandc->dev, "command CRCI unspecified\n");
>> +			return ret;
>> +		}
>> 
>> -	ret = of_property_read_u32(np, "qcom,data-crci", &nandc->data_crci);
>> -	if (ret) {
>> -		dev_err(nandc->dev, "data CRCI unspecified\n");
>> -		return ret;
>> +		ret = of_property_read_u32(np, "qcom,data-crci",
>> +					   &nandc->data_crci);
>> +		if (ret) {
>> +			dev_err(nandc->dev, "data CRCI unspecified\n");
>> +			return ret;
>> +		}
>>   	}
>> 
>>   	return 0;
>> @@ -2128,7 +2188,7 @@ static int qcom_nandc_probe(struct 
>> platform_device *pdev)
>> 
>>   	ret = qcom_nandc_alloc(nandc);
>>   	if (ret)
>> -		return ret;
>> +		goto err_core_clk;
>> 
>>   	ret = clk_prepare_enable(nandc->core_clk);
>>   	if (ret)
>> 

-- 
Abhishek Sahu

  reply	other threads:[~2017-07-17  6:27 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  7:15 [PATCH 00/14] Add QCOM QPIC NAND support Abhishek Sahu
2017-06-29  7:15 ` [PATCH 01/14] qcom: mtd: nand: Add driver data for QPIC DMA Abhishek Sahu
2017-06-29  9:46   ` Marek Vasut
2017-07-03  4:38   ` Archit Taneja
2017-07-03 19:41     ` Boris Brezillon
2017-07-17  6:11       ` Abhishek Sahu
2017-07-17  7:22         ` Boris Brezillon
2017-07-17  8:49           ` Abhishek Sahu
2017-07-03  6:21   ` Sricharan R
2017-06-29  7:15 ` [PATCH 02/14] qcom: mtd: nand: add and initialize QPIC DMA resources Abhishek Sahu
2017-06-29  9:48   ` Marek Vasut
2017-07-17  6:36     ` Abhishek Sahu
2017-07-03  5:17   ` Archit Taneja
2017-07-17  6:26     ` Abhishek Sahu [this message]
2017-07-03  6:24   ` Sricharan R
2017-07-03  6:32   ` Sricharan R
2017-06-29  7:15 ` [PATCH 03/14] qcom: mtd: nand: Fixed config error for BCH Abhishek Sahu
2017-06-29  9:49   ` Marek Vasut
2017-07-03 19:47     ` Boris Brezillon
2017-07-17  6:38       ` Abhishek Sahu
2017-07-03  6:25   ` Sricharan R
2017-06-29  7:15 ` [PATCH 04/14] qcom: mtd: nand: reorganize nand devices probing Abhishek Sahu
2017-06-29  7:15 ` [PATCH 05/14] qcom: mtd: nand: allocate bam transaction Abhishek Sahu
2017-06-29  9:50   ` Marek Vasut
2017-07-17  6:42     ` Abhishek Sahu
2017-07-03  8:22   ` Sricharan R
2017-07-17  6:44     ` Abhishek Sahu
2017-06-29  7:15 ` [PATCH 06/14] qcom: mtd: nand: add bam dma descriptor handling Abhishek Sahu
2017-07-04  6:10   ` Archit Taneja
2017-07-17  6:47     ` Abhishek Sahu
2017-06-29  7:15 ` [PATCH 07/14] qcom: mtd: nand: support for passing flags in transfer functions Abhishek Sahu
2017-06-29  9:52   ` Marek Vasut
2017-07-04  6:49   ` Archit Taneja
2017-07-10 14:10     ` Sricharan R
2017-07-17  6:59       ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 08/14] qcom: mtd: nand: Add support for additional CSRs Abhishek Sahu
2017-07-04  6:54   ` Archit Taneja
2017-07-17  7:10     ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 09/14] qcom: mtd: nand: BAM support for read page Abhishek Sahu
2017-07-04  9:40   ` Archit Taneja
2017-07-10 14:15     ` Sricharan R
2017-07-17  7:17     ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 10/14] qcom: mtd: nand: support for QPIC Page read/write Abhishek Sahu
2017-07-04  9:44   ` Archit Taneja
2017-07-17  7:25     ` Abhishek Sahu
2017-07-10 14:18   ` Sricharan R
2017-07-17  7:36     ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 11/14] qcom: mtd: nand: BAM raw read and write support Abhishek Sahu
2017-06-29  7:16 ` [PATCH 12/14] qcom: mtd: nand: change register offset defines with enums Abhishek Sahu
2017-07-04  9:55   ` Archit Taneja
2017-07-17  7:31     ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 13/14] qcom: mtd: nand: support for QPIC version 1.5.0 Abhishek Sahu
2017-07-04  9:57   ` Archit Taneja
2017-07-17  7:32     ` Abhishek Sahu
2017-06-29  7:16 ` [PATCH 14/14] qcom: mtd: nand: programmed NAND_DEV_CMD_VLD register 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=f23d6ef150d1a4405301423b6be8d481@codeaurora.org \
    --to=absahu@codeaurora.org \
    --cc=andy.gross@linaro.org \
    --cc=architt@codeaurora.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=mark.rutland@arm.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).