[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223183142.31897-4-damien.riegel@silabs.com>
Date: Tue, 23 Dec 2025 13:31:37 -0500
From: Damien Riégel <damien.riegel@...abs.com>
To: greybus-dev@...ts.linaro.org
Cc: linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>,
Alex Elder <elder@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-devel@...abs.com,
Damien Riégel <damien.riegel@...abs.com>
Subject: [PATCH 3/8] greybus: force CPort ID allocation in P2P mode
In the classic Greybus topology, a connection is created by issuing a
command to the SVC, with AP CPort ID, Interface ID, and Intf CPort ID,
that way the SVC knows that when a message is issued by the host and
targets "AP CPort ID", it must be routed to the "Intf CPort ID" of the
right interface. The interface CPort ID is the ID as listed in the
manifest.
For instance with GB BeaglePlay, the SVC does a kind of CPort ID
translation: when it receives a message targeting "AP CPort ID", it
forwards the message to the right interface and replaces the AP CPort ID
by the Interface CPort ID. The same thing is done in gbridge, a
userspace application that acts as an SVC.
When working in P2P mode, there is no SVC to translate CPort IDs, the
host device speaks directly with an interface. For the interface to
understand what the CPort ID means, the host device must use the same
IDs as the ones present in the manifest. These changes to connection
create functions force the CPort ID allocated by the host to match the
interface.
Signed-off-by: Damien Riégel <damien.riegel@...abs.com>
---
drivers/greybus/connection.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/greybus/connection.c b/drivers/greybus/connection.c
index f9287f2f4c9..072b47cdd9b 100644
--- a/drivers/greybus/connection.c
+++ b/drivers/greybus/connection.c
@@ -235,7 +235,9 @@ gb_connection_create_static(struct gb_host_device *hd, u16 hd_cport_id,
struct gb_connection *
gb_connection_create_control(struct gb_interface *intf)
{
- return _gb_connection_create(intf->hd, -1, intf, NULL, 0, NULL,
+ int hd_cport_id = intf->type == GB_INTERFACE_TYPE_P2P ? 0 : -1;
+
+ return _gb_connection_create(intf->hd, hd_cport_id, intf, NULL, 0, NULL,
GB_CONNECTION_FLAG_CONTROL |
GB_CONNECTION_FLAG_HIGH_PRIO);
}
@@ -245,8 +247,9 @@ gb_connection_create(struct gb_bundle *bundle, u16 cport_id,
gb_request_handler_t handler)
{
struct gb_interface *intf = bundle->intf;
+ int hd_cport_id = intf->type == GB_INTERFACE_TYPE_P2P ? cport_id : -1;
- return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id,
+ return _gb_connection_create(intf->hd, hd_cport_id, intf, bundle, cport_id,
handler, 0);
}
EXPORT_SYMBOL_GPL(gb_connection_create);
@@ -257,11 +260,12 @@ gb_connection_create_flags(struct gb_bundle *bundle, u16 cport_id,
unsigned long flags)
{
struct gb_interface *intf = bundle->intf;
+ int hd_cport_id = intf->type == GB_INTERFACE_TYPE_P2P ? cport_id : -1;
if (WARN_ON_ONCE(flags & GB_CONNECTION_FLAG_CORE_MASK))
flags &= ~GB_CONNECTION_FLAG_CORE_MASK;
- return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id,
+ return _gb_connection_create(intf->hd, hd_cport_id, intf, bundle, cport_id,
handler, flags);
}
EXPORT_SYMBOL_GPL(gb_connection_create_flags);
--
2.49.0
Powered by blists - more mailing lists