From: Vinod Koul <vinod.koul@intel.com>
To: Andrew Bresticker <abrestic@chromium.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Grant Likely <grant.likely@linaro.org>,
James Hartley <james.hartley@imgtec.com>,
James Hogan <james.hogan@imgtec.com>,
Ezequiel Garcia <ezequiel.garcia@imgtec.com>,
Damien Horsley <Damien.Horsley@imgtec.com>,
Arnd Bergmann <arnd@arndb.de>,
dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 2/2] dmaengine: Add driver for IMG MDC
Date: Wed, 24 Dec 2014 10:52:18 +0530 [thread overview]
Message-ID: <20141224052218.GR16827@intel.com> (raw)
In-Reply-To: <1418338757-10022-3-git-send-email-abrestic@chromium.org>
On Thu, Dec 11, 2014 at 02:59:17PM -0800, Andrew Bresticker wrote:
> Add support for the IMG Multi-threaded DMA Controller (MDC) found on
> certain IMG SoCs. Currently this driver supports the variant present
> on the MIPS-based Pistachio SoC.a
Overall looks okay. I also need some review by DT folks on the bindings
> +static void mdc_list_desc_config(struct mdc_chan *mchan,
> + struct mdc_hw_list_desc *ldesc,
> + enum dma_transfer_direction dir,
> + dma_addr_t src, dma_addr_t dst, size_t len)
> +{
> + struct mdc_dma *mdma = mchan->mdma;
> + unsigned int max_burst, burst_size;
> +
> + ldesc->gen_conf = MDC_GENERAL_CONFIG_IEN | MDC_GENERAL_CONFIG_LIST_IEN |
> + MDC_GENERAL_CONFIG_LEVEL_INT | MDC_GENERAL_CONFIG_PHYSICAL_W |
> + MDC_GENERAL_CONFIG_PHYSICAL_R;
> + ldesc->readport_conf =
> + (mchan->thread << MDC_READ_PORT_CONFIG_STHREAD_SHIFT) |
> + (mchan->thread << MDC_READ_PORT_CONFIG_RTHREAD_SHIFT) |
> + (mchan->thread << MDC_READ_PORT_CONFIG_WTHREAD_SHIFT);
> + ldesc->read_addr = src;
> + ldesc->write_addr = dst;
> + ldesc->xfer_size = len - 1;
> + ldesc->node_addr = 0;
> + ldesc->cmds_done = 0;
> + ldesc->ctrl_status = MDC_CONTROL_AND_STATUS_LIST_EN |
> + MDC_CONTROL_AND_STATUS_EN;
> + ldesc->next_desc = NULL;
> +
> + if (IS_ALIGNED(dst, mdma->bus_width) &&
> + IS_ALIGNED(src, mdma->bus_width))
> + max_burst = mdma->bus_width * mdma->max_burst_mult;
> + else
> + max_burst = mdma->bus_width * (mdma->max_burst_mult - 1);
> +
> + if (dir == DMA_MEM_TO_DEV) {
> + ldesc->gen_conf |= MDC_GENERAL_CONFIG_INC_R;
> + ldesc->readport_conf |= MDC_READ_PORT_CONFIG_DREQ_ENABLE;
> + mdc_set_read_width(ldesc, mdma->bus_width);
> + mdc_set_write_width(ldesc, mchan->config.dst_addr_width);
> + burst_size = min(max_burst, mchan->config.dst_maxburst *
> + mchan->config.dst_addr_width);
why is this calculation done for burst size? Shouldn't we take the
config.dst_maxburst value configured by client?
> +static struct dma_async_tx_descriptor *mdc_prep_slave_sg(
> + struct dma_chan *chan, struct scatterlist *sgl,
> + unsigned int sg_len, enum dma_transfer_direction dir,
> + unsigned long flags, void *context)
> +{
> + struct mdc_chan *mchan = to_mdc_chan(chan);
> + struct mdc_dma *mdma = mchan->mdma;
> + struct mdc_tx_desc *mdesc;
> + struct scatterlist *sg;
> + struct mdc_hw_list_desc *curr, *prev = NULL;
> + dma_addr_t curr_phys, prev_phys;
> + unsigned int i;
> +
> + if (!sgl)
> + return NULL;
> +
> + if (!is_slave_direction(dir))
> + return NULL;
> +
> + if (mdc_check_slave_width(mchan, dir) < 0)
> + return NULL;
> +
> + mdesc = kzalloc(sizeof(*mdesc), GFP_NOWAIT);
> + if (!mdesc)
> + return NULL;
> + mdesc->chan = mchan;
> +
> + for_each_sg(sgl, sg, sg_len, i) {
> + dma_addr_t buf = sg_dma_address(sg);
> + size_t buf_len = sg_dma_len(sg);
> +
> + while (buf_len > 0) {
> + size_t xfer_size;
> +
> + curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT,
> + &curr_phys);
> + if (!curr)
> + goto free_desc;
> +
> + if (!prev) {
> + mdesc->list_phys = curr_phys;
> + mdesc->list = curr;
> + } else {
> + prev->node_addr = curr_phys;
> + prev->next_desc = curr;
> + }
> +
> + xfer_size = min_t(size_t, mdma->max_xfer_size,
> + buf_len);
> +
> + if (dir == DMA_MEM_TO_DEV) {
> + mdc_list_desc_config(mchan, curr, dir, buf,
> + mchan->config.dst_addr,
> + xfer_size);
> + } else {
> + mdc_list_desc_config(mchan, curr, dir,
> + mchan->config.src_addr,
> + buf, xfer_size);
> + }
> +
> + prev = curr;
> + prev_phys = curr_phys;
> +
> + mdesc->list_len++;
> + mdesc->list_xfer_size += xfer_size;
> + buf += xfer_size;
> + buf_len -= xfer_size;
i see this pattern is repeat in all the .prepare calls, can we make it bit
generic and use that in the these three calls..
> + dma_cap_zero(mdma->dma_dev.cap_mask);
> + dma_cap_set(DMA_SLAVE, mdma->dma_dev.cap_mask);
> + dma_cap_set(DMA_PRIVATE, mdma->dma_dev.cap_mask);
> + dma_cap_set(DMA_CYCLIC, mdma->dma_dev.cap_mask);
and you dont seen to support pause/resume, though not a blocker but is it
not supported in HW or driver doesn't?
--
~Vinod
next prev parent reply other threads:[~2014-12-24 5:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 22:59 [PATCH V3 0/2] dmaengine: Support for IMG MDC Andrew Bresticker
2014-12-11 22:59 ` [PATCH V3 1/2] dmaengine: Add binding document " Andrew Bresticker
[not found] ` <1418338757-10022-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2014-12-11 22:59 ` [PATCH V3 2/2] dmaengine: Add driver " Andrew Bresticker
2014-12-11 22:59 ` Andrew Bresticker
2014-12-24 5:22 ` Vinod Koul [this message]
2014-12-24 17:21 ` Andrew Bresticker
2014-12-24 20:06 ` James Hartley
2015-01-27 10:00 ` [PATCH V3 0/2] dmaengine: Support " Andrew Bresticker
2015-01-27 10:00 ` Andrew Bresticker
2015-02-05 2:13 ` Vinod Koul
2015-02-05 2:13 ` Vinod Koul
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=20141224052218.GR16827@intel.com \
--to=vinod.koul@intel.com \
--cc=Damien.Horsley@imgtec.com \
--cc=abrestic@chromium.org \
--cc=arnd@arndb.de \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=ezequiel.garcia@imgtec.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=james.hartley@imgtec.com \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.