From: David Lechner <david@lechnology.com>
To: Sekhar Nori <nsekhar@ti.com>, Mark Brown <broonie@kernel.org>
Cc: khilman@kernel.org, linux-spi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: davinci: Allow device tree devices to use DMA
Date: Sun, 20 Nov 2016 11:01:02 -0600 [thread overview]
Message-ID: <946d60bc-ac14-7934-c1b3-e2de03831459@lechnology.com> (raw)
In-Reply-To: <79f186b5-ac71-189f-c19f-977670395043@ti.com>
On 11/20/2016 06:59 AM, Sekhar Nori wrote:
> On Saturday 19 November 2016 10:11 AM, David Lechner wrote:
>> This makes SPI devices specified in a device tree use DMA when the master
>> controller has DMA configured.
>>
>> Since device tree is supposed to only describe the hardware, adding a
>> configuration option to device tree to enable DMA per-device would not be
>> acceptable. So, this is the best we can do for now to get SPI devices
>> working with DMA when using device tree.
>>
>> Unfortunately, this excludes the possibility of using one SPI device with
>> DMA and one without on the same master.
>>
>> I have tested this on LEGO MINDSTORMS EV3 using the NOR flash. Reading the
>> flash memory would fail with -EIO when DMA is not enabled for the device.
>>
>> Signed-off-by: David Lechner <david@lechnology.com>
>> ---
>> drivers/spi/spi-davinci.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
>> index d36c11b..c6cf73a 100644
>> --- a/drivers/spi/spi-davinci.c
>> +++ b/drivers/spi/spi-davinci.c
>> @@ -388,6 +388,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
>> static int davinci_spi_of_setup(struct spi_device *spi)
>> {
>> struct davinci_spi_config *spicfg = spi->controller_data;
>> + struct davinci_spi *dspi = spi_master_get_devdata(spi->master);
>> struct device_node *np = spi->dev.of_node;
>> u32 prop;
>>
>> @@ -400,6 +401,9 @@ static int davinci_spi_of_setup(struct spi_device *spi)
>> if (!of_property_read_u32(np, "ti,spi-wdelay", &prop))
>> spicfg->wdelay = (u8)prop;
>> spi->controller_data = spicfg;
>> + /* Use DMA for device if master supports it */
>> + if (dspi->dma_rx)
>
> This should be
>
> if (!(IS_ERR(dpsi->dma_rx) || IS_ERR(dspi->dma_tx))
There is the following code in davinci_spi_probe():
ret = davinci_spi_request_dma(dspi);
if (ret == -EPROBE_DEFER) {
goto free_clk;
} else if (ret) {
dev_info(&pdev->dev, "DMA is not supported (%d)\n", ret);
dspi->dma_rx = NULL;
dspi->dma_tx = NULL;
}
So, I does not look like it is possible to get anything other than NULL
or a valid pointer for dpsi->dma_rx and that checking dpsi->dma_tx is
not necessary.
So, I think if (dspi->dma_rx) is sufficient. In fact the same check is
used during unwinding if the probe function fails.
>
>> + spicfg->io_type = SPI_IO_TYPE_DMA;
>
> Otherwise looks good to me.
>
> Thanks,
> Sekhar
>
next prev parent reply other threads:[~2016-11-20 17:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-19 4:41 David Lechner
2016-11-20 12:59 ` Sekhar Nori
2016-11-20 17:01 ` David Lechner [this message]
2016-11-21 8:37 ` Sekhar Nori
2016-12-07 2:28 ` David Lechner
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=946d60bc-ac14-7934-c1b3-e2de03831459@lechnology.com \
--to=david@lechnology.com \
--cc=broonie@kernel.org \
--cc=khilman@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=nsekhar@ti.com \
/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
all inboxes | Powered by JetHome®