Message ID | 20231204131008.384583-1-ayushdevel1325@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2751836vqy; Mon, 4 Dec 2023 05:13:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWkcamNUb3TUSVqy8UbSOm8PGz7uoPqaOlVRi1Og1yueR7UnRBaaTt/MyoJ4y+6a1VHtMm X-Received: by 2002:a05:6a00:150b:b0:6ce:477b:5c06 with SMTP id q11-20020a056a00150b00b006ce477b5c06mr1187646pfu.58.1701695596316; Mon, 04 Dec 2023 05:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701695596; cv=none; d=google.com; s=arc-20160816; b=ahp4vkwMi7k6JTDOcjBzSQ0MltY2btamZpti58zVBfiWoq/ISdjZ4sPKZ767s4z6zc SB1JlSuo7M306xLs7UwDggRpI3Tkapfpb8RSwE3s6D3FxntOSvoNgeopSd7hB8yDqM6a 8okoXRGHWHecYrdQDAWN3ZO6Qucq4P0T/E1Aydo3MNNa0N8pQYDx0Ed7NXhnxCFVN9/F x7qmEhqhITAalMS95OdfOuvzmeLhJ5kWjEBolpwNDKV0UIXkcIz+1HC9Uose69zrGMvF N4JVjFGJGlsXOkOBoyzHXXB/N2xcyxyc+dyaCafU3ScksfVYluxDH+Z4BNX4ivjjtHPI 3q1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=YEZs6AO2flglBsYRf33FcA1+MeCcJm84o+twFj/3LKE=; fh=3/TDM0VKyeEwR/D51+Id+IFBXV+CnuDpYD6ip4jz1wE=; b=kKXYx8dIjqFSv5pSwUbf5t+V/vCFQAuzB1cQGg+D5+6VuZumnyeJNqzyttRtWQzxJb bXbpYb3RhqUd9tWPA2ets7b0kWWq2rte5GDU3tL/NTVEeHPQfgslI3M7I1amNKhRgBcb g0RYjZgU6l6qcU1COdqa58rDFRf2IYaZ9j3dDEN+By6FBD84DwaMXiMRgArB+hbdLDjP ot5pXwlR/G+b1X9hZzSz7MipZELPGHgv0ALqHb6mKStIi2EiYsufx+axmTF+MVoVXMhC s+4lEO5dhfR8fQ4WUsa3BQ2qulkwaV0iqXPZYfhuERZg1WvovJRDt+vXHkZayKmBlVId yu2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DY7j7x2w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g21-20020a056a0023d500b006cbb2cd545esi7931538pfc.5.2023.12.04.05.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DY7j7x2w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4A2FB80564B6; Mon, 4 Dec 2023 05:13:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233570AbjLDNM5 (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 08:12:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235352AbjLDNKb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 08:10:31 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83456184 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 05:10:24 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cfb4d28c43so14942555ad.1 for <linux-kernel@vger.kernel.org>; Mon, 04 Dec 2023 05:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701695424; x=1702300224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YEZs6AO2flglBsYRf33FcA1+MeCcJm84o+twFj/3LKE=; b=DY7j7x2wlkXaD4UalshzkAjBhVEhd98Rf5MEmY88XUtZCwFsvP9lh3TU9v81uDNDwZ xAVJIT8OR15vRS79EeYaT1YajIRAOAsZtRGntiUl5Pbw/z1Wo3ZzbLR0jVHfjMbQ/PHr qGMVwhba8Pb/dRagIgxWPoLzo1UCqbdtekrTDvvrJMJ+or2N6YB9NYMsjXQaEXx8pqOx 92ixK4Z7lHUqUwnBFRP8V1W4sgHHgef+q/SvK0mmuFiyTG5P/87gHy2Uk7WHQE757mdj b/P8QDm43fLcxbhlDVKUaDcMde0p6UFXWZQgFeIw3L1CTNmS65PrcD5pp5hZnUKpE/0g HMkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701695424; x=1702300224; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YEZs6AO2flglBsYRf33FcA1+MeCcJm84o+twFj/3LKE=; b=p3ZQ35dbMDx/IVnUJVxtgdrcEMnUal9Zs2Oi+7nMX6NmlAMFeQSH7bZ+0xktKfVjCc xq6kMKH3Heuqy9lVPDnP/Kyl6pZ/3n9rGRsCPsw10RWdwQlykiH9rl1CYrqCvJ4lwsO0 nxCNIQB/8GM7vUB/QT89olF82waUx6FU4jkaiOZr3mAt+a4RYsALBJgovtN/kc1q69rf RPWGyBpUcNFn6U+4ALN/kG07UbqcqPHXhZmi+t+vcNiwXaLuqjmFoKYJKRxeUWUW9rud COz+i0AszWMkyPpHNitUiZwUlW4pMYLXOtubAiUvT2dBKOKif0XmvDlQzZc7qvIggzw9 phtw== X-Gm-Message-State: AOJu0YwKQ5yAuQ1TzCOT1R4Ynyd/jBxA/pGAx60U4l3bwa0tMJtJhsfa iPohCka3P4gW4MaEMbd+FkMN8MaazRY= X-Received: by 2002:a17:903:191:b0:1d0:727b:251d with SMTP id z17-20020a170903019100b001d0727b251dmr1325812plg.137.1701695423710; Mon, 04 Dec 2023 05:10:23 -0800 (PST) Received: from toolbox.. ([2401:4900:1f3e:53bf:50c7:2988:e019:4b97]) by smtp.gmail.com with ESMTPSA id e5-20020a170902744500b001d049ef0c1fsm6699156plt.190.2023.12.04.05.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:10:23 -0800 (PST) From: Ayush Singh <ayushdevel1325@gmail.com> To: greybus-dev@lists.linaro.org Cc: Ayush Singh <ayushdevel1325@gmail.com>, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, jkridner@beagleboard.org, kernel test robot <yujie.liu@intel.com> Subject: [PATCH V3] greybus: gb-beagleplay: Ensure le for values in transport Date: Mon, 4 Dec 2023 18:40:06 +0530 Message-ID: <20231204131008.384583-1-ayushdevel1325@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 05:13:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784357161310617968 X-GMAIL-MSGID: 1784357161310617968 |
Series |
[V3] greybus: gb-beagleplay: Ensure le for values in transport
|
|
Commit Message
Ayush Singh
Dec. 4, 2023, 1:10 p.m. UTC
Ensure that the following values are little-endian:
- header->pad (which is used for cport_id)
- header->size
Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver")
Reported-by: kernel test robot <yujie.liu@intel.com>
Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
---
V3:
- Fix endiness while sending.
V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/
- Ensure endianess for header->pad
V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/
drivers/greybus/gb-beagleplay.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: > Ensure that the following values are little-endian: > - header->pad (which is used for cport_id) > - header->size > > Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") > Reported-by: kernel test robot <yujie.liu@intel.com> > Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ > Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> > --- > V3: > - Fix endiness while sending. > V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ > - Ensure endianess for header->pad > V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ > > drivers/greybus/gb-beagleplay.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c > index 43318c1993ba..8b21c3e1e612 100644 > --- a/drivers/greybus/gb-beagleplay.c > +++ b/drivers/greybus/gb-beagleplay.c > @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) > memcpy(&cport_id, hdr->pad, sizeof(cport_id)); > > dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", > - hdr->operation_id, hdr->type, cport_id, hdr->result); > + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); > > - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); > + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); This looks broken; a quick against mainline (and linux-next) check shows cport_id to be u16. I think you want get_unaligned_le16() or something instead of that memcpy() above. But that just begs the question: why has this driver repurposed the pad bytes like this? The header still says that these shall be set to zero. > } > > static void hdlc_rx_dbg_frame(const struct gb_beagleplay *bg, const char *buf, u16 len) > @@ -340,14 +340,15 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messa > { > struct gb_beagleplay *bg = dev_get_drvdata(&hd->dev); > struct hdlc_payload payloads[2]; > + __le16 cport_id = cpu_to_le16(cport); > > dev_dbg(&hd->dev, "Sending greybus message with Operation %u, Type: %X on Cport %u", > msg->header->operation_id, msg->header->type, cport); > > - if (msg->header->size > RX_HDLC_PAYLOAD) > + if (le16_to_cpu(msg->header->size) > RX_HDLC_PAYLOAD) > return dev_err_probe(&hd->dev, -E2BIG, "Greybus message too big"); > > - memcpy(msg->header->pad, &cport, sizeof(cport)); > + memcpy(msg->header->pad, &cport_id, sizeof(cport_id)); put_unaligned_le16(), if the driver should be messing with the pad bytes like this at all... > > payloads[0].buf = msg->header; > payloads[0].len = sizeof(*msg->header); Johan
On 12/4/23 19:42, Johan Hovold wrote: > On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: >> Ensure that the following values are little-endian: >> - header->pad (which is used for cport_id) >> - header->size >> >> Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") >> Reported-by: kernel test robot <yujie.liu@intel.com> >> Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ >> Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> >> --- >> V3: >> - Fix endiness while sending. >> V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ >> - Ensure endianess for header->pad >> V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ >> >> drivers/greybus/gb-beagleplay.c | 9 +++++---- >> 1 file changed, 5 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c >> index 43318c1993ba..8b21c3e1e612 100644 >> --- a/drivers/greybus/gb-beagleplay.c >> +++ b/drivers/greybus/gb-beagleplay.c >> @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) >> memcpy(&cport_id, hdr->pad, sizeof(cport_id)); >> >> dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", >> - hdr->operation_id, hdr->type, cport_id, hdr->result); >> + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); >> >> - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); >> + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); > This looks broken; a quick against mainline (and linux-next) check shows > cport_id to be u16. > > I think you want get_unaligned_le16() or something instead of that > memcpy() above. Thanks, will do. > > But that just begs the question: why has this driver repurposed the pad > bytes like this? The header still says that these shall be set to zero. So, the reason is multiplexing. The original gbridge setup used to do this, so I followed it when I moved gbridge to the coprocessor (during GSoC). Using the padding for storing cport information allows not having to wrap the message in some other format at the two transport layers (UART and TCP sockets) beagle connect is using.This also seems better than trying to do something bespoke, especially since the padding bytes are not being used for anything else. The initial spec was for project Ara (modular smartphone), so the current use for IoT is significantly different from the initial goals of the protocol. Maybe a future version of the spec can be more focused on IoT, but that will probably only happen once it has proven somewhat useful in this space. Ayush Singh
On Mon, Dec 04, 2023 at 09:58:55PM +0530, Ayush Singh wrote: > > On 12/4/23 19:42, Johan Hovold wrote: > > On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: > > > Ensure that the following values are little-endian: > > > - header->pad (which is used for cport_id) > > > - header->size > > > > > > Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") > > > Reported-by: kernel test robot <yujie.liu@intel.com> > > > Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ > > > Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> > > > --- > > > V3: > > > - Fix endiness while sending. > > > V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ > > > - Ensure endianess for header->pad > > > V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ > > > > > > drivers/greybus/gb-beagleplay.c | 9 +++++---- > > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c > > > index 43318c1993ba..8b21c3e1e612 100644 > > > --- a/drivers/greybus/gb-beagleplay.c > > > +++ b/drivers/greybus/gb-beagleplay.c > > > @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) > > > memcpy(&cport_id, hdr->pad, sizeof(cport_id)); > > > dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", > > > - hdr->operation_id, hdr->type, cport_id, hdr->result); > > > + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); > > > - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); > > > + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); > > This looks broken; a quick against mainline (and linux-next) check shows > > cport_id to be u16. > > > > I think you want get_unaligned_le16() or something instead of that > > memcpy() above. > Thanks, will do. > > > > But that just begs the question: why has this driver repurposed the pad > > bytes like this? The header still says that these shall be set to zero. > > So, the reason is multiplexing. The original gbridge setup used to do this, > so I followed it when I moved gbridge to the coprocessor (during GSoC). > > Using the padding for storing cport information allows not having to wrap > the message in some other format at the two transport layers (UART and TCP > sockets) beagle connect is using.This also seems better than trying to do > something bespoke, especially since the padding bytes are not being used for > anything else. > > The initial spec was for project Ara (modular smartphone), so the current > use for IoT is significantly different from the initial goals of the > protocol. Maybe a future version of the spec can be more focused on IoT, but > that will probably only happen once it has proven somewhat useful in this > space. Please don't violate the spec today this way, I missed that previously, that's not ok. We can change the spec for new things if you need it, but to not follow it, and still say it is "greybus" isn't going to work and will cause problems in the long-run. Should I just disable the driver for now until this is fixed up? thanks, greg k-h
On 12/5/23 05:44, Greg KH wrote: > On Mon, Dec 04, 2023 at 09:58:55PM +0530, Ayush Singh wrote: >> On 12/4/23 19:42, Johan Hovold wrote: >>> On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: >>>> Ensure that the following values are little-endian: >>>> - header->pad (which is used for cport_id) >>>> - header->size >>>> >>>> Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") >>>> Reported-by: kernel test robot <yujie.liu@intel.com> >>>> Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ >>>> Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> >>>> --- >>>> V3: >>>> - Fix endiness while sending. >>>> V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ >>>> - Ensure endianess for header->pad >>>> V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ >>>> >>>> drivers/greybus/gb-beagleplay.c | 9 +++++---- >>>> 1 file changed, 5 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c >>>> index 43318c1993ba..8b21c3e1e612 100644 >>>> --- a/drivers/greybus/gb-beagleplay.c >>>> +++ b/drivers/greybus/gb-beagleplay.c >>>> @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) >>>> memcpy(&cport_id, hdr->pad, sizeof(cport_id)); >>>> dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", >>>> - hdr->operation_id, hdr->type, cport_id, hdr->result); >>>> + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); >>>> - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); >>>> + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); >>> This looks broken; a quick against mainline (and linux-next) check shows >>> cport_id to be u16. >>> >>> I think you want get_unaligned_le16() or something instead of that >>> memcpy() above. >> Thanks, will do. >>> But that just begs the question: why has this driver repurposed the pad >>> bytes like this? The header still says that these shall be set to zero. >> So, the reason is multiplexing. The original gbridge setup used to do this, >> so I followed it when I moved gbridge to the coprocessor (during GSoC). >> >> Using the padding for storing cport information allows not having to wrap >> the message in some other format at the two transport layers (UART and TCP >> sockets) beagle connect is using.This also seems better than trying to do >> something bespoke, especially since the padding bytes are not being used for >> anything else. >> >> The initial spec was for project Ara (modular smartphone), so the current >> use for IoT is significantly different from the initial goals of the >> protocol. Maybe a future version of the spec can be more focused on IoT, but >> that will probably only happen once it has proven somewhat useful in this >> space. > Please don't violate the spec today this way, I missed that previously, > that's not ok. We can change the spec for new things if you need it, > but to not follow it, and still say it is "greybus" isn't going to work > and will cause problems in the long-run. > > Should I just disable the driver for now until this is fixed up? > > thanks, > > greg k-h Well, I will look into some ways to pass along the cport information (maybe using a wrapper over greybus message) for now. However, I would prefer having some bytes in greybus messages reserved for passing around this information in a transport agnostic way. Ayush Singh
On Tue, Dec 05, 2023 at 05:15:33PM +0530, Ayush Singh wrote: > > On 12/5/23 05:44, Greg KH wrote: > > On Mon, Dec 04, 2023 at 09:58:55PM +0530, Ayush Singh wrote: > > > On 12/4/23 19:42, Johan Hovold wrote: > > > > On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: > > > > > Ensure that the following values are little-endian: > > > > > - header->pad (which is used for cport_id) > > > > > - header->size > > > > > > > > > > Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") > > > > > Reported-by: kernel test robot <yujie.liu@intel.com> > > > > > Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ > > > > > Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> > > > > > --- > > > > > V3: > > > > > - Fix endiness while sending. > > > > > V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ > > > > > - Ensure endianess for header->pad > > > > > V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ > > > > > > > > > > drivers/greybus/gb-beagleplay.c | 9 +++++---- > > > > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c > > > > > index 43318c1993ba..8b21c3e1e612 100644 > > > > > --- a/drivers/greybus/gb-beagleplay.c > > > > > +++ b/drivers/greybus/gb-beagleplay.c > > > > > @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) > > > > > memcpy(&cport_id, hdr->pad, sizeof(cport_id)); > > > > > dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", > > > > > - hdr->operation_id, hdr->type, cport_id, hdr->result); > > > > > + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); > > > > > - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); > > > > > + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); > > > > This looks broken; a quick against mainline (and linux-next) check shows > > > > cport_id to be u16. > > > > > > > > I think you want get_unaligned_le16() or something instead of that > > > > memcpy() above. > > > Thanks, will do. > > > > But that just begs the question: why has this driver repurposed the pad > > > > bytes like this? The header still says that these shall be set to zero. > > > So, the reason is multiplexing. The original gbridge setup used to do this, > > > so I followed it when I moved gbridge to the coprocessor (during GSoC). > > > > > > Using the padding for storing cport information allows not having to wrap > > > the message in some other format at the two transport layers (UART and TCP > > > sockets) beagle connect is using.This also seems better than trying to do > > > something bespoke, especially since the padding bytes are not being used for > > > anything else. > > > > > > The initial spec was for project Ara (modular smartphone), so the current > > > use for IoT is significantly different from the initial goals of the > > > protocol. Maybe a future version of the spec can be more focused on IoT, but > > > that will probably only happen once it has proven somewhat useful in this > > > space. > > Please don't violate the spec today this way, I missed that previously, > > that's not ok. We can change the spec for new things if you need it, > > but to not follow it, and still say it is "greybus" isn't going to work > > and will cause problems in the long-run. > > > > Should I just disable the driver for now until this is fixed up? > > > > thanks, > > > > greg k-h > > Well, I will look into some ways to pass along the cport information (maybe > using a wrapper over greybus message) for now. However, I would prefer > having some bytes in greybus messages reserved for passing around this > information in a transport agnostic way. I'm confused, what exactly is needed here to be sent that isn't in the existing message definition. And as to your original statement, the protocol definition was not designed for any specific use case that would make IoT "special" here that I can see. It was designed to provide a discoverable way to describe and control hardware on an unknown transport layer for devices that are not discoverable by definition (serial, i2c, etc.) The fact that we implemented this on both USB and unipro successfully provided that the transport layer for the data should be working and agnositic. thanks, greg k-h
On 12/6/23 01:15, Greg KH wrote: > I'm confused, what exactly is needed here to be sent that isn't in the > existing message definition. > > And as to your original statement, the protocol definition was not > designed for any specific use case that would make IoT "special" here > that I can see. It was designed to provide a discoverable way to > describe and control hardware on an unknown transport layer for devices > that are not discoverable by definition (serial, i2c, etc.) > > The fact that we implemented this on both USB and unipro successfully > provided that the transport layer for the data should be working and > agnositic. > > thanks, > > greg k-h So, the missing information is the AP cport which is sending the message/for which the message is intended. Each AP cport will be connected to a cport in some greybus node. For a simple case like USB, where AP can directly talk to the node, and we do not really need the cport information outside of kernel driver. I think under normal circumstances, the kernel driver is supposed to directly communicate with the node. However, in beagle play, the subghz transport is only present in CC1352 coprocessor. This means CC1352 needs to act as the middle man between AP and node (aka perform the APBridge tasks). So it needs to maintain a way to keep track of all active greybus connections, and route the messages between AP and Node cports. I am not quite sure where SVC is supposed to be in Linux kernel greybus setup. Since SVC needs to be able to detect module insertion/removal, it needs to be able to access the same transport as APBridge. Thus, CC1352 (and gbridge in old setup) are responsible for both SVC and APBridge roles. Simply put, if the kernel driver cannot directly connect to the node, the processor / network entity handling APBridge tasks will need to cport information. And it probably is good to make it possible to separate APBridge from AP in complex networks. Feel free to ask questions if I was unclear regarding something. Also feel free to correct me if I got something wrong since I only started working on greybus this summer. Ayush Singh
On 12/5/23 2:32 PM, Ayush Singh wrote: > On 12/6/23 01:15, Greg KH wrote: > >> I'm confused, what exactly is needed here to be sent that isn't in the >> existing message definition. >> >> And as to your original statement, the protocol definition was not >> designed for any specific use case that would make IoT "special" here >> that I can see. It was designed to provide a discoverable way to >> describe and control hardware on an unknown transport layer for devices >> that are not discoverable by definition (serial, i2c, etc.) >> >> The fact that we implemented this on both USB and unipro successfully >> provided that the transport layer for the data should be working and >> agnositic. >> >> thanks, >> >> greg k-h > > So, the missing information is the AP cport which is sending the > message/for which the message is intended. Each AP cport will be > connected to a cport in some greybus node. For a simple case like USB, > where AP can directly talk to the node, and we do not really need the > cport information outside of kernel driver. I think I lack some context here, but as Greg said Greybus is intended to be a pure transport, and anything using it should be able to get all information it needs as a layered protocol on top of it. If the BeaglePlay stuff requires CPort information, it sounds like it's not managing the layering of abstractions properly. > I think under normal circumstances, the kernel driver is supposed to > directly communicate with the node. However, in beagle play, the subghz > transport is only present in CC1352 coprocessor. This means CC1352 needs > to act as the middle man between AP and node (aka perform the APBridge > tasks). So it needs to maintain a way to keep track of all active > greybus connections, and route the messages between AP and Node cports. > > I am not quite sure where SVC is supposed to be in Linux kernel greybus > setup. Since SVC needs to be able to detect module insertion/removal, it > needs to be able to access the same transport as APBridge. Thus, CC1352 > (and gbridge in old setup) are responsible for both SVC and APBridge roles. It sounds like CC1352 is serving in an SVC role... sort of? Again, I don't have enough context right now to understand. Greybus was developed for a particular hardware platform, and it included an SVC. The SVC was an independent processor that managed the "endo", or the basic hardware "backplane" that held modules). The AP bridge was how the AP connected to that, and the GP bridge was how a given module interface connected to that. It seems to me (this is partly from an impression I had a few years ago) that the BeaglePlay model doesn't align perfectly with that. And if that's the case, we need to figure out how to resolve any mismatches. (I'm not sure this is very helpful, but it's a little background.) -Alex > Simply put, if the kernel driver cannot directly connect to the node, > the processor / network entity handling APBridge tasks will need to > cport information. And it probably is good to make it possible to > separate APBridge from AP in complex networks. > > Feel free to ask questions if I was unclear regarding something. Also > feel free to correct me if I got something wrong since I only started > working on greybus this summer. > > Ayush Singh >
On 12/6/23 20:22, Alex Elder wrote: > On 12/5/23 2:32 PM, Ayush Singh wrote: >> On 12/6/23 01:15, Greg KH wrote: >> >>> I'm confused, what exactly is needed here to be sent that isn't in the >>> existing message definition. >>> >>> And as to your original statement, the protocol definition was not >>> designed for any specific use case that would make IoT "special" here >>> that I can see. It was designed to provide a discoverable way to >>> describe and control hardware on an unknown transport layer for devices >>> that are not discoverable by definition (serial, i2c, etc.) >>> >>> The fact that we implemented this on both USB and unipro successfully >>> provided that the transport layer for the data should be working and >>> agnositic. >>> >>> thanks, >>> >>> greg k-h >> >> So, the missing information is the AP cport which is sending the >> message/for which the message is intended. Each AP cport will be >> connected to a cport in some greybus node. For a simple case like >> USB, where AP can directly talk to the node, and we do not really >> need the cport information outside of kernel driver. > > I think I lack some context here, but as Greg said Greybus > is intended to be a pure transport, and anything using it > should be able to get all information it needs as a layered > protocol on top of it. > > If the BeaglePlay stuff requires CPort information, it sounds > like it's not managing the layering of abstractions properly. Well, I used gbridge as a reference during my GSoC work. So I just followed it's lead of using pad bytes for cport information. > >> I think under normal circumstances, the kernel driver is supposed to >> directly communicate with the node. However, in beagle play, the >> subghz transport is only present in CC1352 coprocessor. This means >> CC1352 needs to act as the middle man between AP and node (aka >> perform the APBridge tasks). So it needs to maintain a way to keep >> track of all active greybus connections, and route the messages >> between AP and Node cports. >> >> I am not quite sure where SVC is supposed to be in Linux kernel >> greybus setup. Since SVC needs to be able to detect module >> insertion/removal, it needs to be able to access the same transport >> as APBridge. Thus, CC1352 (and gbridge in old setup) are responsible >> for both SVC and APBridge roles. > > It sounds like CC1352 is serving in an SVC role... sort of? Again, I > don't have enough context right now to understand. > > Greybus was developed for a particular hardware platform, and it > included an SVC. The SVC was an independent processor that managed > the "endo", or the basic hardware "backplane" that held modules). > The AP bridge was how the AP connected to that, and the GP bridge > was how a given module interface connected to that. > > It seems to me (this is partly from an impression I had a few years > ago) that the BeaglePlay model doesn't align perfectly with that. > And if that's the case, we need to figure out how to resolve any > mismatches. > > (I'm not sure this is very helpful, but it's a little background.) > > -Alex Yes, the BeaglePlay (and older gbridge) model does deviate from that. You can read more about beagle connect technology here [1] and the initial presentation [2]. However, to put it simply, it is trying to use greybus over transports other than Unipro. This means we do not have a Unipro switch. Instead, we use a coprocessor (CC1352) running specialized firmware to handle all the things Unipro switch would. The current focus is 6lowpan (due to it's range). However, CC1352 also has a 2.4 and 5 ghz antenna, so in the future, that might also be used for transportation. Since I am not much aware of greybus use outside of beagle connect, I do not have much knowledge of how it is supposed to be used in a traditional setting. I have submitted new patches that remove the need for using pad bytes. Ayush Singh [1]: https://docs.beagleboard.org/latest/projects/beagleconnect/index.html [2]: https://www.youtube.com/watch?v=7H50pv-4YXw
diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c index 43318c1993ba..8b21c3e1e612 100644 --- a/drivers/greybus/gb-beagleplay.c +++ b/drivers/greybus/gb-beagleplay.c @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) memcpy(&cport_id, hdr->pad, sizeof(cport_id)); dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", - hdr->operation_id, hdr->type, cport_id, hdr->result); + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); } static void hdlc_rx_dbg_frame(const struct gb_beagleplay *bg, const char *buf, u16 len) @@ -340,14 +340,15 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messa { struct gb_beagleplay *bg = dev_get_drvdata(&hd->dev); struct hdlc_payload payloads[2]; + __le16 cport_id = cpu_to_le16(cport); dev_dbg(&hd->dev, "Sending greybus message with Operation %u, Type: %X on Cport %u", msg->header->operation_id, msg->header->type, cport); - if (msg->header->size > RX_HDLC_PAYLOAD) + if (le16_to_cpu(msg->header->size) > RX_HDLC_PAYLOAD) return dev_err_probe(&hd->dev, -E2BIG, "Greybus message too big"); - memcpy(msg->header->pad, &cport, sizeof(cport)); + memcpy(msg->header->pad, &cport_id, sizeof(cport_id)); payloads[0].buf = msg->header; payloads[0].len = sizeof(*msg->header);