lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250705004036.3828-6-damien.riegel@silabs.com>
Date: Fri,  4 Jul 2025 20:40:35 -0400
From: Damien Riégel <damien.riegel@...abs.com>
To: greybus-dev@...ts.linaro.org
Cc: linux-kernel@...r.kernel.org, linux-devel@...abs.com,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alex Elder <elder@...nel.org>, Johan Hovold <johan@...nel.org>,
        Damien Riégel <damien.riegel@...abs.com>
Subject: [RFC 5/6] greybus: match device with bundle ID

When matching a device, only the vendor ID and product ID are used. As
all bundles in an interface share the same VID and PID, there is no way
to differentiate between two bundles, and they are forced to use the
same driver.

To allow using several vendor bundles in the same device, include the
bundle ID when matching. The assumption here is that bundle IDs are
stable across the lifespan of a product and never change.

The goal of this change is to open the discussion. Greybus standardizes
a bunch of protocols like GPIO, SPI, etc. but also has provisioning for
vendor bundle and protocol. There is only one ID reserved for vendor,
0xFF, so the question is did Greybus ever envision supporting several
vendor bundles, or one vendor bundle with several vendor cports in it?
Or the assumption always was that there could be at most only vendor
cport?

Signed-off-by: Damien Riégel <damien.riegel@...abs.com>
---
 drivers/greybus/core.c             | 4 ++++
 include/linux/greybus.h            | 7 ++++---
 include/linux/greybus/greybus_id.h | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/greybus/core.c b/drivers/greybus/core.c
index 313eb65cf70..a4968a24a08 100644
--- a/drivers/greybus/core.c
+++ b/drivers/greybus/core.c
@@ -68,6 +68,10 @@ static bool greybus_match_one_id(struct gb_bundle *bundle,
 	    (id->product != bundle->intf->product_id))
 		return false;
 
+	if ((id->match_flags & GREYBUS_ID_MATCH_BUNDLE_ID) &&
+	    (id->bundle_id != bundle->id))
+		return false;
+
 	if ((id->match_flags & GREYBUS_ID_MATCH_CLASS) &&
 	    (id->class != bundle->class))
 		return false;
diff --git a/include/linux/greybus.h b/include/linux/greybus.h
index 4d58e27ceaf..9c29a1099a4 100644
--- a/include/linux/greybus.h
+++ b/include/linux/greybus.h
@@ -38,12 +38,13 @@
 #define GREYBUS_VERSION_MINOR	0x01
 
 #define GREYBUS_ID_MATCH_DEVICE \
-	(GREYBUS_ID_MATCH_VENDOR | GREYBUS_ID_MATCH_PRODUCT)
+	(GREYBUS_ID_MATCH_VENDOR | GREYBUS_ID_MATCH_PRODUCT | GREYBUS_ID_MATCH_BUNDLE_ID)
 
-#define GREYBUS_DEVICE(v, p)					\
+#define GREYBUS_DEVICE(v, p, id)				\
 	.match_flags	= GREYBUS_ID_MATCH_DEVICE,		\
 	.vendor		= (v),					\
-	.product	= (p),
+	.product	= (p),					\
+	.bundle_id	= (id),
 
 #define GREYBUS_DEVICE_CLASS(c)					\
 	.match_flags	= GREYBUS_ID_MATCH_CLASS,		\
diff --git a/include/linux/greybus/greybus_id.h b/include/linux/greybus/greybus_id.h
index f4c8440093e..3e0728e1f44 100644
--- a/include/linux/greybus/greybus_id.h
+++ b/include/linux/greybus/greybus_id.h
@@ -15,6 +15,7 @@ struct greybus_bundle_id {
 	__u32	vendor;
 	__u32	product;
 	__u8	class;
+	__u8	bundle_id;
 
 	kernel_ulong_t	driver_info __aligned(sizeof(kernel_ulong_t));
 };
@@ -23,5 +24,6 @@ struct greybus_bundle_id {
 #define GREYBUS_ID_MATCH_VENDOR		BIT(0)
 #define GREYBUS_ID_MATCH_PRODUCT	BIT(1)
 #define GREYBUS_ID_MATCH_CLASS		BIT(2)
+#define GREYBUS_ID_MATCH_BUNDLE_ID	BIT(3)
 
 #endif /* __LINUX_GREYBUS_ID_H */
-- 
2.49.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ