public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Pooja Katiyar <pooja.katiyar@intel.com>
Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
	dmitry.baryshkov@oss.qualcomm.com
Subject: Re: [PATCH v4 2/4] usb: typec: ucsi: Add support for message out data structure
Date: Mon, 15 Sep 2025 15:18:53 +0300	[thread overview]
Message-ID: <aMgELQ2IFw_cHpkO@kuha.fi.intel.com> (raw)
In-Reply-To: <429be91c2fdc038c266103083457ff9086e26d2e.1757374784.git.pooja.katiyar@intel.com>

On Tue, Sep 09, 2025 at 06:52:05PM -0700, Pooja Katiyar wrote:
> Add support for updating message out data structure for UCSI
> ACPI interface for UCSI 2.1 and UCSI 3.0 commands such as
> Set PDOs and LPM Firmware Update.
> 
> Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com>
> ---
> Changelog v4:
> - Fixed build errors reported by kernel test robot.
> - Added changelogs.

I'm not sure anything has changed in this patch. The first patch was
the one with a problem. In any case:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> Changelog v3:
> - Added message_out fields to UCSI structure and updated sync_control
>   to perform write operation.
> - Removed extra DSM Write call.
> 
> Changelog v2:
> - Moved write_message_out operation to .sync_control.
> - Updated ucsi_send_command to accept message_out data.
> 
>  drivers/usb/typec/ucsi/ucsi.c      | 14 ++++++++++++++
>  drivers/usb/typec/ucsi/ucsi.h      |  2 ++
>  drivers/usb/typec/ucsi/ucsi_acpi.c | 16 ++++++++++++++++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 073b80cfa414..a82088554a40 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -67,6 +67,20 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)
>  
>  	reinit_completion(&ucsi->complete);
>  
> +	if (ucsi->message_out_size > 0) {
> +		if (!ucsi->ops->write_message_out) {
> +			ucsi->message_out_size = 0;
> +			ret = -EOPNOTSUPP;
> +			goto out_clear_bit;
> +		}
> +
> +		ret = ucsi->ops->write_message_out(ucsi, ucsi->message_out,
> +						   ucsi->message_out_size);
> +		ucsi->message_out_size = 0;
> +		if (ret)
> +			goto out_clear_bit;
> +	}
> +
>  	ret = ucsi->ops->async_control(ucsi, command);
>  	if (ret)
>  		goto out_clear_bit;
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index ba21fea53cb7..e6ca70f7fa1f 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -69,6 +69,7 @@ struct dentry;
>   * @read_cci: Read CCI register
>   * @poll_cci: Read CCI register while polling with notifications disabled
>   * @read_message_in: Read message data from UCSI
> + * @write_message_out: Write message data to UCSI
>   * @sync_control: Blocking control operation
>   * @async_control: Non-blocking control operation
>   * @update_altmodes: Squashes duplicate DP altmodes
> @@ -84,6 +85,7 @@ struct ucsi_operations {
>  	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
>  	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
>  	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
> +	int (*write_message_out)(struct ucsi *ucsi, void *data, size_t data_len);
>  	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci);
>  	int (*async_control)(struct ucsi *ucsi, u64 command);
>  	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
> diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
> index f1d1f6917b09..f9beeb835238 100644
> --- a/drivers/usb/typec/ucsi/ucsi_acpi.c
> +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
> @@ -86,6 +86,21 @@ static int ucsi_acpi_read_message_in(struct ucsi *ucsi, void *val, size_t val_le
>  	return 0;
>  }
>  
> +static int ucsi_acpi_write_message_out(struct ucsi *ucsi, void *data, size_t data_len)
> +{
> +	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
> +
> +	if (!data || !data_len)
> +		return -EINVAL;
> +
> +	if (ucsi->version <= UCSI_VERSION_1_2)
> +		memcpy(ua->base + UCSI_MESSAGE_OUT, data, data_len);
> +	else
> +		memcpy(ua->base + UCSIv2_MESSAGE_OUT, data, data_len);
> +
> +	return 0;
> +}
> +
>  static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
>  {
>  	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
> @@ -101,6 +116,7 @@ static const struct ucsi_operations ucsi_acpi_ops = {
>  	.read_cci = ucsi_acpi_read_cci,
>  	.poll_cci = ucsi_acpi_poll_cci,
>  	.read_message_in = ucsi_acpi_read_message_in,
> +	.write_message_out = ucsi_acpi_write_message_out,
>  	.sync_control = ucsi_sync_control_common,
>  	.async_control = ucsi_acpi_async_control
>  };
> -- 
> 2.43.0

-- 
heikki

  reply	other threads:[~2025-09-15 12:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10  1:52 [PATCH v4 0/4] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-09-10  1:52 ` [PATCH v4 1/4] usb: typec: ucsi: Update UCSI structure to have message in and message out fields Pooja Katiyar
2025-09-15 12:16   ` Heikki Krogerus
2025-09-10  1:52 ` [PATCH v4 2/4] usb: typec: ucsi: Add support for message out data structure Pooja Katiyar
2025-09-15 12:18   ` Heikki Krogerus [this message]
2025-09-10  1:52 ` [PATCH v4 3/4] usb: typec: ucsi: Enable debugfs for message_out " Pooja Katiyar
2025-09-15 12:20   ` Heikki Krogerus
2025-09-10  1:52 ` [PATCH v4 4/4] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-09-15 12:21   ` Heikki Krogerus

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=aMgELQ2IFw_cHpkO@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pooja.katiyar@intel.com \
    /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