The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Jérôme Pouiller" <jerome.pouiller@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,
	"Damien Riégel" <damien.riegel@silabs.com>
Cc: "Silicon Labs Kernel Team" <linux-devel@silabs.com>,
	"Gabriel Beaulieu" <gabriel.beaulieu@silabs.com>,
	"Damien Riégel" <damien.riegel@silabs.com>
Subject: Re: [PATCH v2 14/14] greybus: cpc: add CPC SDIO host driver
Date: Thu, 15 Jan 2026 23:34:34 +0100	[thread overview]
Message-ID: <7976899.0VBMTVartN@nb0018864> (raw)
In-Reply-To: <20260115155808.36102-15-damien.riegel@silabs.com>

On Thursday 15 January 2026 16:58:07 Central European Standard Time Damien Riégel wrote:
> From: Gabriel Beaulieu <gabriel.beaulieu@silabs.com>
> 
> This introduces a new module gb-cpc-sdio, in order to communicate with a
> Greybus CPC device over SDIO.
> 
> Most of the complexity stems from aggregation: packets are aggregated to
> minimize the number of CMD53s. In the first block, the first le32 is the
> number of packets in this transfer. Immediately after that are all the
> packet headers (CPC + Greybus). This lets the device process all the
> headers in a single interrupt, and prepare the ADMA descriptors for all
> the payloads in one go.
> 
> Payloads start at the beginning of the second block and are concatained.
> Their lengths must be 32-bit aligned, so the driver takes care of adding
> and removing padding if necessary.
> 
> Signed-off-by: Gabriel Beaulieu <gabriel.beaulieu@silabs.com>
> Signed-off-by: Damien Riégel <damien.riegel@silabs.com>
> ---
> Changes in v2:
>   - change formatting from %lu to %zu when printing size_t's
>   - remove "/**" kernel-doc marker for static functions not actually
>     using the kernel-doc format
>   - reduce header inclusion list
>   - use reverse christmas tree variable declarations consistently
>   - update aggregation functions to try to be more legible
>   - use define instead of constant value 0x0C for the address where to
>     read the number of bytes the device wants to send
>   - remove padding between headers and payloads when aggregating packets
> 
>  drivers/greybus/cpc/Kconfig  |  12 +
>  drivers/greybus/cpc/Makefile |   3 +
>  drivers/greybus/cpc/sdio.c   | 533 +++++++++++++++++++++++++++++++++++
>  3 files changed, 548 insertions(+)
>  create mode 100644 drivers/greybus/cpc/sdio.c
> 
> diff --git a/drivers/greybus/cpc/Kconfig b/drivers/greybus/cpc/Kconfig
> index ab96fedd0de..8223f56795f 100644
> --- a/drivers/greybus/cpc/Kconfig
> +++ b/drivers/greybus/cpc/Kconfig
> @@ -8,3 +8,15 @@ config GREYBUS_CPC
>  
>  	  To compile this code as a module, chose M here: the module will be
>  	  called gb-cpc.ko
> +
> +config GREYBUS_CPC_SDIO
> +	tristate "Greybus CPC over SDIO"
> +	depends on GREYBUS_CPC && MMC

Don't you think, this PR should also be sent to the SDIO maintainers
(linux-mmc@vger.kernel.org)?

> +	help
> +	  This driver provides Greybus CPC host support for devices
> +	  connected via SDIO interface.

For now, I believe only some Silicon Labs device provide this interface.
Maybe it would help the user to mention that.

> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called gb-cpc-sdio.
> +
> +	  If unsure, say N.

[...]

> diff --git a/drivers/greybus/cpc/sdio.c b/drivers/greybus/cpc/sdio.c
> new file mode 100644
> index 00000000000..aeeb8378dea
> --- /dev/null
> +++ b/drivers/greybus/cpc/sdio.c
> @@ -0,0 +1,533 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025, Silicon Laboratories, Inc.
> + */
> +
> +#include <linux/kthread.h>
> +#include <linux/mmc/sdio_func.h>
> +#include <linux/mmc/sdio_ids.h>
> +#include <linux/skbuff.h>
> +#include <linux/workqueue.h>
> +
> +#include "cpc.h"
> +#include "header.h"
> +#include "host.h"
> +
> +#define GB_CPC_SDIO_MSG_SIZE_MAX 4096
> +#define GB_CPC_SDIO_BLOCK_SIZE 256U

What is the purpose of the "U"?

> +#define GB_CPC_SDIO_FIFO_ADDR 0
> +#define GB_CPC_SDIO_RX_BYTES_CNT_ADDR 0x0C

It took me a bit of time to understand the meaning of these two
definitions. I suggest to separate them from the other defines and
use a common prefix:

  #define GB_CPC_SDIO_ADDR_FIFO         0x00
  #define GB_CPC_SDIO_ADDR_RX_BYTES_CNT 0x0c


> +#define GB_CPC_SDIO_ALIGNMENT 4
> +#define GB_CPC_SDIO_DEFAULT_AGGREGATION 1

This number seems arbitrary and it used only once. I feel it just add
one layer of indirection rather than improving the readability.

> +#define CPC_FRAME_HEADER_SIZE (CPC_HEADER_SIZE + GREYBUS_HEADER_SIZE)
> +#define GB_CPC_SDIO_MAX_AGGREGATION ((GB_CPC_SDIO_BLOCK_SIZE - sizeof(u32)) / CPC_FRAME_HEADER_SIZE)

Orphan?

> +

[...]

> +static int gb_cpc_sdio_wake_tx(struct cpc_host_device *cpc_hd)
> +{
> +	struct cpc_sdio *ctx = cpc_hd_to_cpc_sdio(cpc_hd);
> +
> +	if (test_bit(CPC_SDIO_FLAG_SHUTDOWN, &ctx->flags))
> +		return 0;
> +
> +	/* Use system workqueue for TX processing */

I wonder if these trivial comments are useful or rather pollute the code.

[...]

> +static const struct sdio_device_id sdio_ids[] = {
> +       {
> +               SDIO_DEVICE(0x0296, 0x5347),
                              ^^^^^^

You have to add an entry in include/linux/mmc/sdio_ids.h. But, it seems
there is a conflict with SDIO_VENDOR_ID_MICROCHIP_WILC.

> +       },
> +       {},
> +};

[...]

-- 
Jérôme Pouiller



  parent reply	other threads:[~2026-01-15 22:34 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 ` [PATCH v2 05/14] greybus: cpc: switch RX path to socket buffers Damien Riégel
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 [this message]
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=7976899.0VBMTVartN@nb0018864 \
    --to=jerome.pouiller@silabs.com \
    --cc=damien.riegel@silabs.com \
    --cc=elder@kernel.org \
    --cc=gabriel.beaulieu@silabs.com \
    --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