mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Damien Riégel" <damien.riegel@silabs.com>
To: greybus-dev@lists.linaro.org, Johan Hovold <johan@kernel.org>,
	Alex Elder <elder@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Cc: "Silicon Labs Kernel Team" <linux-devel@silabs.com>,
	"Damien Riégel" <damien.riegel@silabs.com>
Subject: [PATCH v2 05/14] greybus: cpc: switch RX path to socket buffers
Date: Thu, 15 Jan 2026 10:57:58 -0500	[thread overview]
Message-ID: <20260115155808.36102-6-damien.riegel@silabs.com> (raw)
In-Reply-To: <20260115155808.36102-1-damien.riegel@silabs.com>

For symmetry, also convert the RX path to use socket buffers instead of
u8* buffers. The main difference is that CPC host device drivers were
responsible for allocating and freeing the buffers. Now they are only
responsible for allocating the skb and pass it to the upper layer, the
CPC "core" module will take of releasing it when it's done with it.

Signed-off-by: Damien Riégel <damien.riegel@silabs.com>
---
 drivers/greybus/cpc/host.c | 13 ++++++++-----
 drivers/greybus/cpc/host.h |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/greybus/cpc/host.c b/drivers/greybus/cpc/host.c
index b096b639182..7ffa3bf4021 100644
--- a/drivers/greybus/cpc/host.c
+++ b/drivers/greybus/cpc/host.c
@@ -203,20 +203,23 @@ void cpc_hd_message_sent(struct sk_buff *skb, int status)
 }
 EXPORT_SYMBOL_GPL(cpc_hd_message_sent);
 
-void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, u8 *data, size_t length)
+void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, struct sk_buff *skb)
 {
 	struct gb_operation_msg_hdr *gb_hdr;
 	u16 cport_id;
 
 	/* Prevent an out-of-bound access if called with non-sensical parameters. */
-	if (!data || length < sizeof(*gb_hdr))
-		return;
+	if (skb->len < sizeof(*gb_hdr))
+		goto free_skb;
 
 	/* Retrieve cport ID that was packed in Greybus header */
-	gb_hdr = (struct gb_operation_msg_hdr *)data;
+	gb_hdr = (struct gb_operation_msg_hdr *)skb->data;
 	cport_id = cpc_cport_unpack(gb_hdr);
 
-	greybus_data_rcvd(cpc_hd->gb_hd, cport_id, data, length);
+	greybus_data_rcvd(cpc_hd->gb_hd, cport_id, skb->data, skb->len);
+
+free_skb:
+	kfree_skb(skb);
 }
 EXPORT_SYMBOL_GPL(cpc_hd_rcvd);
 
diff --git a/drivers/greybus/cpc/host.h b/drivers/greybus/cpc/host.h
index 2e568bac44e..cc835f5298b 100644
--- a/drivers/greybus/cpc/host.h
+++ b/drivers/greybus/cpc/host.h
@@ -45,7 +45,7 @@ struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct devic
 int cpc_hd_add(struct cpc_host_device *cpc_hd);
 void cpc_hd_put(struct cpc_host_device *cpc_hd);
 void cpc_hd_del(struct cpc_host_device *cpc_hd);
-void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, u8 *data, size_t length);
+void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, struct sk_buff *skb);
 void cpc_hd_message_sent(struct sk_buff *skb, int status);
 
 int cpc_hd_send_skb(struct cpc_host_device *cpc_hd, struct sk_buff *skb);
-- 
2.52.0


  parent reply	other threads:[~2026-01-15 16:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 15:57 [PATCH v2 00/14] greybus: introduce CPC as transport layer Damien Riégel
2026-01-15 15:57 ` [PATCH v2 01/14] greybus: cpc: add minimal CPC Host Device infrastructure Damien Riégel
2026-01-16 15:11   ` Greg Kroah-Hartman
2026-01-27 21:11     ` Damien Riégel
2026-01-15 15:57 ` [PATCH v2 02/14] greybus: cpc: introduce CPC cport structure Damien Riégel
2026-01-15 15:57 ` [PATCH v2 03/14] greybus: cpc: use socket buffers instead of gb_message in TX path Damien Riégel
2026-01-15 15:57 ` [PATCH v2 04/14] greybus: cpc: pack cport ID in Greybus header Damien Riégel
2026-01-15 15:57 ` Damien Riégel [this message]
2026-01-15 15:57 ` [PATCH v2 06/14] greybus: cpc: introduce CPC header structure Damien Riégel
2026-01-15 21:46   ` Jérôme Pouiller
2026-01-15 15:58 ` [PATCH v2 07/14] greybus: cpc: account for CPC header size in RX and TX path Damien Riégel
2026-01-15 15:58 ` [PATCH v2 08/14] greybus: cpc: add and validate sequence numbers Damien Riégel
2026-01-15 21:46   ` Jérôme Pouiller
2026-01-15 15:58 ` [PATCH v2 09/14] greybus: cpc: acknowledge all incoming messages Damien Riégel
2026-01-15 15:58 ` [PATCH v2 10/14] greybus: cpc: use holding queue instead of sending out immediately Damien Riégel
2026-01-15 15:58 ` [PATCH v2 11/14] greybus: cpc: honour remote's RX window Damien Riégel
2026-01-15 15:58 ` [PATCH v2 12/14] greybus: cpc: let host device drivers dequeue TX frames Damien Riégel
2026-01-15 15:58 ` [PATCH v2 13/14] greybus: cpc: add private data pointer in CPC Host Device Damien Riégel
2026-01-15 15:58 ` [PATCH v2 14/14] greybus: cpc: add CPC SDIO host driver Damien Riégel
2026-01-15 21:46   ` Jérôme Pouiller
2026-01-15 22:34   ` Jérôme Pouiller
2026-01-15 21:46 ` [PATCH v2 00/14] greybus: introduce CPC as transport layer Jérôme Pouiller
2026-01-15 22:48   ` Jérôme Pouiller

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=20260115155808.36102-6-damien.riegel@silabs.com \
    --to=damien.riegel@silabs.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-devel@silabs.com \
    --cc=linux-kernel@vger.kernel.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®