From: "M, Krishnamoorthi" <krishnamoorthi.m@amd.com>
To: YH Chung <yh_chung@aspeedtech.com>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Greg KH <gregkh@linuxfoundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"broonie@kernel.org" <broonie@kernel.org>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"akshata.mukundshetty@amd.com" <akshata.mukundshetty@amd.com>,
"bleung@chromium.org" <bleung@chromium.org>,
"groeck@chromium.org" <groeck@chromium.org>,
"chrome-platform@lists.linux.dev"
<chrome-platform@lists.linux.dev>,
"corbet@lwn.net" <corbet@lwn.net>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>,
YC Hsieh <yc_hsieh@aspeedtech.com>,
Maciej Lawniczak <maciej.lawniczak@intel.com>,
Ryan Chen <ryan_chen@aspeedtech.com>
Subject: Re: [RFC PATCH 0/4] espi: introduce eSPI bus framework
Date: Tue, 18 Aug 2026 18:55:42 +0530 [thread overview]
Message-ID: <d1bdc779-724a-4851-8c26-7e02981bae7a@amd.com> (raw)
In-Reply-To: <KL1PR0601MB42768F2FB7E907618E1DAB4E90DE2@KL1PR0601MB4276.apcprd06.prod.outlook.com>
Hi Chung,
On 8/10/2026 11:43 AM, YH Chung wrote:
> Hi Krishnamoorthi,
>
>> YH Chung, would you be open to collaborating on the slave-side
>> interfaces of the new eSPI framework? Happy to discuss further on the
>> list or off-list to align on the design before the next revision.
>
> Thanks for reaching out. I am glad to share some design considerations
> from a target-side point of view.
>
> After reading the series, I think it might be useful to align on the
> layering between the eSPI core, channel implementations, and hardware
> drivers as part of defining the target-side interfaces.
>
> 1. Reuse existing kernel subsystems for the individual channels
>
> I agree that we should reuse existing kernel subsystems where their
> semantics match, for example GPIO for general-purpose Virtual Wire
> groups, MCTP for MCTP-over-OOB, and MTD for flash access. Other Virtual
> Wire groups and OOB protocols may need different consumers.
>
> The eSPI subsystem could provide common adapters between those
> subsystems and the corresponding channel instead of requiring each
> controller or target hardware driver to implement the integration
> independently.
>
> For example, Controller Attached Flash Sharing (CAFS) and Target
> Attached Flash Sharing (TAFS) have different ownership and transaction
> directions, but share the eSPI Flash packet and request/completion
> semantics. A common Flash layer could provide that protocol handling,
> with a requester-side MTD frontend that turns MTD operations into eSPI
> requests and a provider-side backend that services requests using
> locally attached flash.
Reusing GPIO for VWire, MCTP for OOB, and MTD for Flash where semantics
match is the right direction.
For CAFS/TAFS, the same espi-flash channel type is used on both sides: a
requester role exposing an MTD frontend (controller owns flash), and a
provider role servicing requests from local flash (target owns flash).
It's the same channel/protocol layer and packet/completion semantics on
each side; on any given endpoint, only one role is active.
>
> 2. Consider the boundary between channel semantics and hardware transport
>
> The current struct espi_controller_ops exposes high-level operations
> such as periph_io_read(), oob_send(), and flash_read(). These may be
> useful as channel-consumer APIs, but I wonder whether they are too
> high-level for the hardware-driver interface itself.
>
> Would it make sense to keep high-level behavior in the channel layers
> while defining the hardware-facing boundary in terms of per-channel
> transmit and receive primitives?
>
> Conceptually:
>
> TX: core/channel -> *_tx() -> hardware
> RX: hardware IRQ -> espi_*_rx() -> core/channel
>
> The packet or request structure could remain channel-specific. The main
> idea is to keep register, FIFO, and DMA handling below this boundary and
> eSPI channel semantics above it.
>
> For example, a controller read from target-attached flash could use the
> same transport interface on both sides:
>
> Controller (requester) Target (flash owner)
> ---------------------- --------------------
>
> MTD frontend
> |
> Flash layer
> |
> build READ request
> |
> flash_tx() ------- READ -------> espi_flash_rx()
> |
> Flash provider
> |
> local MTD read
> |
> espi_flash_rx() <-- COMPLETION --- flash_tx()
> |
> match request
> |
> complete MTD read
>
> One option would be for controller and target drivers to use the same
> low-level endpoint interface, including the same per-channel *_tx()
> callbacks and espi_*_rx() entry points. A common endpoint object could
> carry the role, for example:
>
> enum espi_role {
> ESPI_ROLE_CONTROLLER,
> ESPI_ROLE_TARGET,
> };
>
> The endpoint role and capabilities would determine which transaction
> types are valid and which optional operations are implemented. Object
> lifetime, capabilities, packet definitions, and request state could
> also be shared. Linux SPI's shared spi_controller infrastructure for
> host and target roles may be a useful reference, although eSPI's
> role-specific protocol behavior is more asymmetric.
>
> The benefit of this boundary is that common packet and channel protocol
> handling can be implemented once while each hardware driver remains
> focused on its registers, FIFOs, DMA, and interrupts. It should reduce
> duplication and role-specific divergence, make support for additional
> controller or target hardware easier to add, and allow both roles to be
> tested against the same transport contract.
>
> Channel-independent commands such as GET/SET_CONFIGURATION and
> GET_STATUS may likewise need role-specific callbacks within this common
> endpoint interface: command submission/completion on the controller
> side and configuration-provider callbacks on the target side. These
> callbacks could be optional to support hardware-assisted
> implementations.
The TX/RX boundary is a clean separation and we agree hardware drivers
should focus purely on registers, FIFOs and DMA while channel semantics
live above. That means the current high-level ops (flash_read(),
oob_send(), ...) move up into the channel layers, and the hardware
boundary becomes your per-channel *_tx() / espi_*_rx() primitives.
As an alternative to a shared espi_role endpoint, we are considering one
device per channel under the target (CS#), single target shown for
clarity:
espi0 (controller)
`-- espi0-cs0 (target at Chip Select 0)
|-- espi0-cs0-periph -> I/O + memory
|-- espi0-cs0-vwire -> gpiochip (GP VWire groups; system
| VWires handled separately)
|-- espi0-cs0-oob -> MCTP
`-- espi0-cs0-flash -> MTD
Both controller and target drivers populate the same per-channel ops and
the role (requester/provider) stays local to each channel driver and
decides direction and which optional callbacks exist. The
channel-independent commands (GET/SET_CONFIGURATION, GET_STATUS) are
link-level, so they stay on the controller device with role-specific
callbacks. This gives the same separation as your endpoint model.
>
> 3. Leave room for asynchronous deferred transaction handling
>
> This does not necessarily need to be implemented in the initial
> framework. A synchronous API may be a practical first step, provided
> the hardware-facing interface does not prevent asynchronous handling
> from being added later.
>
> As a future improvement, the common channel layer could track
> outstanding non-posted Peripheral and Flash requests and complete them
> when the corresponding completion packets arrive. For tagged requests,
> this state would be scoped by endpoint/Chip Select#, channel, and tag.
> A complete request object would also need to handle split completions,
> timeouts, errors, and cancellation during channel or link reset.
>
Agreed on synchronous first. We will keep the boundary open for later
async tracking of non-posted requests, scoped by CS#/channel/tag.
Thanks for the detailed design considerations. Do you have any
comments/suggestions about the per channel approach as a starting point?
Happy to continue on or off the list.
Thanks,
Krishna
> The exact model could remain channel-specific because OOB is
> message-oriented and Virtual Wire is event/state-oriented. Keeping this
> possibility open would allow asynchronous handling to be added later
> without changing the hardware-driver interface.
>
> These are my initial thoughts from the target-side implementation
> perspective. I hope they are useful when considering the layering and
> public interfaces for the next revision, and I would be interested in
> your thoughts on the proposed transport boundary and common endpoint
> model.
>
> Regards,
> Yun-Hsuan Chung
next prev parent reply other threads:[~2026-08-18 23:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 11:52 [RFC PATCH 0/4] espi: introduce eSPI bus framework Krishnamoorthi M
2026-08-04 11:52 ` [RFC PATCH 1/4] espi: add core " Krishnamoorthi M
2026-08-06 13:31 ` Uwe Kleine-König
2026-08-12 12:50 ` M, Krishnamoorthi
2026-08-12 16:30 ` Uwe Kleine-König
2026-08-17 10:57 ` M, Krishnamoorthi
2026-08-04 11:52 ` [RFC PATCH 2/4] espi: add slave device model and event notification Krishnamoorthi M
2026-08-04 11:52 ` [RFC PATCH 3/4] Documentation: espi: add subsystem overview and MAINTAINERS entry Krishnamoorthi M
2026-08-04 16:39 ` Randy Dunlap
2026-08-04 19:14 ` M, Krishnamoorthi
2026-08-04 11:52 ` [RFC PATCH 4/4] espi: amd: add AMD eSPI controller driver Krishnamoorthi M
2026-08-04 12:18 ` [RFC PATCH 0/4] espi: introduce eSPI bus framework Greg KH
2026-08-04 13:26 ` Greg KH
2026-08-05 0:42 ` Andrew Jeffery
2026-08-05 18:35 ` M, Krishnamoorthi
2026-08-10 6:13 ` YH Chung
2026-08-18 13:25 ` M, Krishnamoorthi [this message]
2026-08-20 6:25 ` YH Chung
2026-08-20 13:54 ` M, Krishnamoorthi
2026-08-05 10:14 ` M, Krishnamoorthi
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=d1bdc779-724a-4851-8c26-7e02981bae7a@amd.com \
--to=krishnamoorthi.m@amd.com \
--cc=akshata.mukundshetty@amd.com \
--cc=andrew@codeconstruct.com.au \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=maciej.lawniczak@intel.com \
--cc=openbmc@lists.ozlabs.org \
--cc=ryan_chen@aspeedtech.com \
--cc=skhan@linuxfoundation.org \
--cc=yc_hsieh@aspeedtech.com \
--cc=yh_chung@aspeedtech.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