public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Reddy, MallikarjunaX" <mallikarjunax.reddy@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
	robh+dt@kernel.org, linux-kernel@vger.kernel.org,
	andriy.shevchenko@intel.com, chuanhua.lei@linux.intel.com,
	cheol.yong.kim@intel.com, qi-ming.wu@intel.com,
	malliamireddy009@gmail.com, peter.ujfalusi@ti.com
Subject: Re: [PATCH v9 2/2] Add Intel LGM SoC DMA support.
Date: Fri, 20 Nov 2020 19:30:26 +0800	[thread overview]
Message-ID: <a4ea240f-b121-5bc9-a046-95bbcff87553@linux.intel.com> (raw)
In-Reply-To: <20201118173840.GW50232@vkoul-mobl>

Hi Vinod,

Thanks for the review. My comments inline.

On 11/19/2020 1:38 AM, Vinod Koul wrote:
> On 12-11-20, 13:38, Amireddy Mallikarjuna reddy wrote:
>> Add DMA controller driver for Lightning Mountain (LGM) family of SoCs.
>>
>> The main function of the DMA controller is the transfer of data from/to any
>> peripheral to/from the memory. A memory to memory copy capability can also
>> be configured.
>>
>> This ldma driver is used for configure the device and channnels for data
>> and control paths.
>>
>> Signed-off-by: Amireddy Mallikarjuna reddy <mallikarjunax.reddy@linux.intel.com>
>> ---
>> v1:
>> - Initial version.
> You have a cover letter, use that to keep track of these changes
ok.
>
>> +++ b/drivers/dma/lgm/Kconfig
>> @@ -0,0 +1,9 @@
>> +# SPDX-License-Identifier: GPL-2.0-only
>> +config INTEL_LDMA
>> +	bool "Lightning Mountain centralized low speed DMA and high speed DMA controllers"
> Do we have any other speeds :D
No other speeds :-)
>
>> +++ b/drivers/dma/lgm/lgm-dma.c
>> @@ -0,0 +1,1742 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Lightning Mountain centralized low speed and high speed DMA controller driver
>> + *
>> + * Copyright (c) 2016 ~ 2020 Intel Corporation.
> I think you mean 2016 - 2020, a dash which refers to duration
ok.
>
>> +struct dw2_desc {
>> +	struct {
>> +		u32 len		:16;
>> +		u32 res0	:7;
>> +		u32 bofs	:2;
>> +		u32 res1	:3;
>> +		u32 eop		:1;
>> +		u32 sop		:1;
>> +		u32 c		:1;
>> +		u32 own		:1;
>> +	} __packed field;
> Another one, looks like folks adding dmaengine patches love this
> approach, second one for the day..
>
> Now why do you need the bit fields, why not use register defines and
> helpers in bitfield.h to help configure the fields See FIELD_GET,
> FIELD_PREP etc
Let me check on this...
>
>> +struct dma_dev_ops {
>> +	int (*device_alloc_chan_resources)(struct dma_chan *chan);
>> +	void (*device_free_chan_resources)(struct dma_chan *chan);
>> +	int (*device_config)(struct dma_chan *chan,
>> +			     struct dma_slave_config *config);
>> +	int (*device_pause)(struct dma_chan *chan);
>> +	int (*device_resume)(struct dma_chan *chan);
>> +	int (*device_terminate_all)(struct dma_chan *chan);
>> +	void (*device_synchronize)(struct dma_chan *chan);
>> +	enum dma_status (*device_tx_status)(struct dma_chan *chan,
>> +					    dma_cookie_t cookie,
>> +					    struct dma_tx_state *txstate);
>> +	struct dma_async_tx_descriptor *(*device_prep_slave_sg)
>> +		(struct dma_chan *chan, struct scatterlist *sgl,
>> +		unsigned int sg_len, enum dma_transfer_direction direction,
>> +		unsigned long flags, void *context);
>> +	void (*device_issue_pending)(struct dma_chan *chan);
>> +};
> Heh! why do you have a copy of dmaengine ops here?
Ok, i will remove the ops and update the code accordingly.
>
>> +static int ldma_chan_desc_cfg(struct ldma_chan *c, dma_addr_t desc_base,
>> +			      int desc_num)
>> +{
>> +	struct ldma_dev *d = to_ldma_dev(c->vchan.chan.device);
>> +
>> +	if (!desc_num) {
>> +		dev_err(d->dev, "Channel %d must allocate descriptor first\n",
>> +			c->nr);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (desc_num > DMA_MAX_DESC_NUM) {
>> +		dev_err(d->dev, "Channel %d descriptor number out of range %d\n",
>> +			c->nr, desc_num);
>> +		return -EINVAL;
>> +	}
>> +
>> +	ldma_chan_desc_hw_cfg(c, desc_base, desc_num);
>> +
>> +	c->flags |= DMA_HW_DESC;
>> +	c->desc_cnt = desc_num;
>> +	c->desc_phys = desc_base;
> So you have a custom API which is used to configure this flag, a number
> and an address. The question is why, can you please help explain this?
LDMA used as general purpose dma(ver == DMA_VER22) and also supports DMA 
capability for GSWIP in their network packet processing.( ver > DMA_VER22)

Each Ingress(IGP) & Egress(EGP) ports of CQM use a dma channel.

desc needs to be configure for each dma channel and the remapped address 
of the IGP & EGP is desc base adress.
CQM client is using ldma_chan_desc_cfg() to configure the descriptior.
>
>> +static void dma_issue_pending(struct dma_chan *chan)
>> +{
>> +	struct ldma_chan *c = to_ldma_chan(chan);
>> +	struct ldma_dev *d = to_ldma_dev(c->vchan.chan.device);
>> +	unsigned long flags;
>> +
>> +	if (d->ver == DMA_VER22) {
> why is this specific to this version?
Only dma0 instance (ver == DMA_VER22) is used as a general purpose slave 
DMA. we set both control and datapath here.
Other instances (ver > DMA_VER22) we set only control path. data path is 
taken care by dma client(GSWIP).
Only thing needs to do is get the channel, set the descriptor and just 
'ON' the channel.

CQM is highly low level register configurable/programmable take care 
about the the packet processing through the register configurations.
>
>> +static enum dma_status
>> +dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
>> +	      struct dma_tx_state *txstate)
>> +{
>> +	struct ldma_chan *c = to_ldma_chan(chan);
>> +	struct ldma_dev *d = to_ldma_dev(c->vchan.chan.device);
>> +	enum dma_status status = DMA_COMPLETE;
>> +
>> +	if (d->ver == DMA_VER22)
>> +		status = dma_cookie_status(chan, cookie, txstate);
> so for non DMA_VER22 status is always complete, even if I may havent
> invoked issue_pending() right!
Yes.
client(CQM) make sure use this callback only once the transfer is success.

  we just 'ON' the channel in issue_pending() for non DMA_VER22.
>
>> new file mode 100644
>> index 000000000000..6942e0ef0977
>> --- /dev/null
>> +++ b/include/linux/dma/lgm_dma.h
>> @@ -0,0 +1,27 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Copyright (c) 2016 ~ 2020 Intel Corporation.
>> + */
>> +#ifndef LGM_DMA_H
>> +#define LGM_DMA_H
>> +
>> +#include <linux/types.h>
>> +#include <linux/dmaengine.h>
>> +
>> +/*!
>> + * \fn int intel_dma_chan_desc_cfg(struct dma_chan *chan, dma_addr_t desc_base,
>> + *                                 int desc_num)
>> + * \brief Configure low level channel descriptors
>> + * \param[in] chan   pointer to DMA channel that the client is using
>> + * \param[in] desc_base   descriptor base physical address
>> + * \param[in] desc_num   number of descriptors
>> + * \return   0 on success
>> + * \return   kernel bug reported on failure
> See Documentation/process/coding-style.rst!
  Ok, Got it. i will fix the kernel-doc comments in the next patch.

and also

%s/2016 ~ 2020/2016 - 2020
>

  reply	other threads:[~2020-11-20 11:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12  5:38 [PATCH v9 0/2] Add Intel LGM SoC DMA support Amireddy Mallikarjuna reddy
2020-11-12  5:38 ` [PATCH v9 1/2] dt-bindings: dma: Add bindings for Intel LGM SoC Amireddy Mallikarjuna reddy
2020-11-16 19:19   ` Rob Herring
2020-11-18 15:55   ` Vinod Koul
2020-11-20 11:30     ` Reddy, MallikarjunaX
2020-11-21 12:19       ` Vinod Koul
2020-11-23 16:30         ` Reddy, MallikarjunaX
2020-11-24 17:23           ` Vinod Koul
2020-11-25 10:39             ` Reddy, MallikarjunaX
2020-11-12  5:38 ` [PATCH v9 2/2] Add Intel LGM SoC DMA support Amireddy Mallikarjuna reddy
2020-11-18 17:38   ` Vinod Koul
2020-11-20 11:30     ` Reddy, MallikarjunaX [this message]
2020-11-21 12:17       ` Vinod Koul
2020-11-23 16:29         ` Reddy, MallikarjunaX
2020-11-24 17:21           ` Vinod Koul
2020-11-25 10:39             ` Reddy, MallikarjunaX
2020-11-26  4:50               ` Vinod Koul
2020-11-30  6:20                 ` Reddy, MallikarjunaX

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=a4ea240f-b121-5bc9-a046-95bbcff87553@linux.intel.com \
    --to=mallikarjunax.reddy@linux.intel.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=cheol.yong.kim@intel.com \
    --cc=chuanhua.lei@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malliamireddy009@gmail.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=qi-ming.wu@intel.com \
    --cc=robh+dt@kernel.org \
    --cc=vkoul@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