From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Tim Harvey <tharvey@gateworks.com>
Cc: "open list" <linux-kernel@vger.kernel.org>,
linux-can@vger.kernel.org,
"Wolfgang Grandegger" <wg@grandegger.com>,
"Timo Schlüßler" <schluessler@krause.de>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH] can: mcp251x: convert to half-duplex SPI
Date: Wed, 26 Feb 2020 08:37:02 +0100 [thread overview]
Message-ID: <0b351fe3-8fe9-572f-fd85-e2aed22873e3@pengutronix.de> (raw)
In-Reply-To: <CAJ+vNU3vk92_1UnrYH72QgD3-q9Oy9As=jCiup42jzx_2LG9FA@mail.gmail.com>
On 2/25/20 11:25 PM, Tim Harvey wrote:
>> On 2/25/20 7:35 PM, Tim Harvey wrote:
>>> Some SPI host controllers such as the Cavium Thunder do not support
>>> full-duplex SPI. Using half-duplex transfers allows the driver to work
>>> with those host controllers.
Hmmm, at least none of the spi-cavium*.c have HALF_DUPLEX set....
I only find these ones:
> drivers/spi/spi-falcon.c:404: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-lp8841-rtc.c:194: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-mt7621.c:360: master->flags = SPI_CONTROLLER_HALF_DUPLEX;
> drivers/spi/spi-mxs.c:576: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-omap-uwire.c:490: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-pic32-sqi.c:651: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-pl022.c:1714: SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) {
> drivers/spi/spi-qcom-qspi.c:478: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-sprd-adi.c:521: ctlr->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-stm32.c:160:#define STM32H7_SPI_HALF_DUPLEX 3
> drivers/spi/spi-stm32.c:1469: mode = STM32H7_SPI_HALF_DUPLEX;
> drivers/spi/spi-stm32.c:1472: mode = STM32H7_SPI_HALF_DUPLEX;
> drivers/spi/spi-ti-qspi.c:758: master->flags = SPI_MASTER_HALF_DUPLEX;
> drivers/spi/spi-xcomm.c:222: master->flags = SPI_MASTER_HALF_DUPLEX;
>> There are several transfers left in the driver, where both rx_buf and
>> tx_buf are set. How does your host controller driver know which one to
>> handle?
I'm trying to answer my question:
I think the spi host controller sets SPI_MASTER_HALF_DUPLEX if it only
supports half duplex and the spi framework checks that only either TX or
RX is set during one transfer.
> Your right... there is the mcp251x_hw_rx_frame() call that also uses
> spi_rx_buf after a synchronous transfer (I didn't see any others).
> I'll look at this again.
Have you hardware to test your changes? I think the SPI framework would
return an -EINVAL in that case....though the return value is sometimes
not checked by the driver :/
> In general is it an ok approach to switch the driver to half-duplex
> for this issue without the need of complicating things with a
> module/dt param?
AFAICS the chip doesn't do real full duplex. It either send or receives
data at the same time. With splitting one pseudo full duplex transfer
into two half duplex transfers brings some minor overhead, but I think
that's hardly measurable.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2020-02-26 7:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 18:35 [PATCH] can: mcp251x: convert to half-duplex SPI Tim Harvey
2020-02-25 21:43 ` Marc Kleine-Budde
2020-02-25 22:25 ` Tim Harvey
2020-02-26 7:37 ` Marc Kleine-Budde [this message]
2020-02-26 10:19 ` Marc Kleine-Budde
[not found] ` <7b85e098-b9a9-dd14-203f-100cdf2e703e-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2020-05-21 20:19 ` Tim Harvey
[not found] ` <CAJ+vNU06DHVS25OQR1Kqyzy2ZxLVq-HdwenGv-jN5Rb3r8F86Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-05-21 21:08 ` Mark Brown
2020-05-25 11:17 ` Marc Kleine-Budde
2020-05-25 11:31 ` Mark Brown
[not found] ` <20200525113106.GB4544-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2020-05-25 12:41 ` Marc Kleine-Budde
[not found] ` <a337c8ea-66e2-13c2-f625-fbe93e367d44-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2020-05-25 12:57 ` Mark Brown
2020-05-25 13:12 ` Marc Kleine-Budde
2020-05-25 13:27 ` Mark Brown
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=0b351fe3-8fe9-572f-fd85-e2aed22873e3@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schluessler@krause.de \
--cc=tharvey@gateworks.com \
--cc=wg@grandegger.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