From: Harald Mommer <harald.mommer@opensynergy.com>
To: Mark Brown <broonie@kernel.org>
Cc: virtio-dev@lists.oasis-open.org,
Haixu Cui <quic_haixcui@quicinc.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Harald.Mommer@gmail.com, quic_ztu@quicinc.com,
Matti Moell <Matti.Moell@opensynergy.com>,
Mikhail Golubev <Mikhail.Golubev@opensynergy.com>
Subject: Re: [RFC PATCH v1 3/3] SPI: Add virtio SPI driver (V4 draft specification).
Date: Wed, 6 Dec 2023 18:23:08 +0100 [thread overview]
Message-ID: <75e473b2-f4d2-476c-8d1c-1085446d8b41@opensynergy.com> (raw)
In-Reply-To: <ZUjuxfKdwRQgbfdb@finisterre.sirena.org.uk>
On 06.11.23 14:48, Mark Brown wrote:
> On Fri, Oct 27, 2023 at 06:10:16PM +0200, Harald Mommer wrote:
>
>> +config SPI_VIRTIO
>> + tristate "Virtio SPI SPI Controller"
>> + depends on VIRTIO
>> + help
>> + This enables the Virtio SPI driver.
>> +
>> + Virtio SPI is an SPI driver for virtual machines using Virtio.
>> +
>> + If your Linux is a virtual machine using Virtio, say Y here.
>> +
> This advice is going to be inappropriate for the majortiy of guests.
Reminder for me: Need still to address this, but this is not code I'm
currently working on, so comes later.
>> + // clang-format off
>> + struct spi_transfer_head transfer_head ____cacheline_aligned;
>> + const uint8_t *tx_buf ____cacheline_aligned;
>> + uint8_t *rx_buf ____cacheline_aligned;
>> + struct spi_transfer_result result ____cacheline_aligned;
>> + // clang-format on
> Remove this clang-format stuff.
Not needed any more, will be removed. Maybe I should remove this
____cacheline_aligned. It's only there because I looked too deeply into
struct virtio_i2c_req, not because I think this ____cacheline_aligned is
decisive here.
>> +static struct spi_board_info board_info = {
>> + .modalias = "spi-virtio",
>> + .max_speed_hz = 125000000, /* Arbitrary very high limit */
>> + .bus_num = 0, /* Patched later during initialization */
>> + .chip_select = 0, /* Patched later during initialization */
>> + .mode = SPI_MODE_0,
>> +};
>> +/* Compare with file i2c_virtio.c structure virtio_i2c_msg_done */
> In what way is one supposed to compare with the i2c driver? What
> happens if the I2C driver changes? It would be better to ensure that
> the code can be read and understood as a standalone thing.
It was a reminder for me from where I got some inspiration and to reveal
that not everything was invented by me. Served it's purpose, all such
comment references to foreign code is being removed.
>> + /* Fill struct spi_transfer_head */
>> + th->slave_id = spi->chip_select;
> If the spec just copied the Linux terminology it'd have few issues :(
Spec changed this in the meantime so I can do also.
>> + th->bits_per_word = spi->bits_per_word;
>> + th->cs_change = xfer->cs_change;
> The virtio spec for cs_change is *not* what the Linux cs_change field
> does, this will not do the right thing.
This is a hard one. Linux says (spi.h):
"@cs_change: affects chipselect after this transfer completes
...
All SPI transfers start with the relevant chipselect active. Normally
it stays selected until after the last transfer in a message. Drivers
can affect the chipselect signal using cs_change."
V8 of the draft spec says:
"cs_change indicates whether to deselect device before starting the next
SPI transfer, 0 means chipselect
keep asserted and 1 means chipselect deasserted then asserted again."
What I understand here (unfortunately in both texts) is
- at the start of a transfer CS is made active
- it is kept active during the transfer
- when cs_change is 0 after the transfer CS is kept active (not changed)
- when cs_change is 1 after the transfer CS is de-asserted
So if cs_change is 0 keep CS asserted after transfer, otherwise
de-assert after transfer.
I fear there is some subtle thing I haven't gotten yet but I don't
understand / see it.What is it?
>> + th->tx_nbits = xfer->tx_nbits;
>> + th->rx_nbits = xfer->rx_nbits;
>> + th->reserved[0] = 0;
>> + th->reserved[1] = 0;
>> + th->reserved[2] = 0;
>> +
>> +#if (VIRTIO_SPI_CPHA != SPI_CPHA)
>> +#error VIRTIO_SPI_CPHA != SPI_CPHA
>> +#endif
> BUILD_BUG_ON()
Thanks for this one, didn't know yet.
next prev parent reply other threads:[~2023-12-06 17:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231027161016.26625-1-Harald.Mommer@opensynergy.com>
[not found] ` <ZTvrEFjL3nCRRQnY@finisterre.sirena.org.uk>
2023-10-27 17:03 ` [RFC PATCH] Virtio SPI Linux driver Harald Mommer
2023-10-27 17:16 ` Mark Brown
2023-11-06 13:39 ` Mark Brown
[not found] ` <20231027161016.26625-4-Harald.Mommer@opensynergy.com>
2023-11-06 13:48 ` [RFC PATCH v1 3/3] SPI: Add virtio SPI driver (V4 draft specification) Mark Brown
2023-12-06 17:23 ` Harald Mommer [this message]
2023-11-10 2:34 ` Haixu Cui
2023-12-13 9:53 ` [virtio-dev] " Viresh Kumar
2023-12-14 16:52 ` Harald Mommer
2023-12-15 6:11 ` Viresh Kumar
[not found] ` <20231027161016.26625-3-Harald.Mommer@opensynergy.com>
2023-12-12 10:34 ` [virtio-dev] [RFC PATCH v1 2/3] virtio-spi: Add virtio-spi.h " Viresh Kumar
2023-12-12 18:58 ` Harald Mommer
2023-12-13 6:33 ` Viresh Kumar
2023-12-14 17:20 ` Harald Mommer
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=75e473b2-f4d2-476c-8d1c-1085446d8b41@opensynergy.com \
--to=harald.mommer@opensynergy.com \
--cc=Harald.Mommer@gmail.com \
--cc=Matti.Moell@opensynergy.com \
--cc=Mikhail.Golubev@opensynergy.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=quic_haixcui@quicinc.com \
--cc=quic_ztu@quicinc.com \
--cc=virtio-dev@lists.oasis-open.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
all inboxes | Powered by JetHome®