From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Pooja Katiyar <pooja.katiyar@intel.com>,
linux-usb@vger.kernel.org, gregkh@linuxfoundation.org
Cc: heikki.krogerus@linux.intel.com
Subject: Re: [PATCH v2 1/3] usb: typec: ucsi: Add support for message out data structure
Date: Sat, 28 Jun 2025 04:40:12 +0300 [thread overview]
Message-ID: <da49edc4-4aa9-462f-94d4-a2f2c920619a@oss.qualcomm.com> (raw)
In-Reply-To: <cc0b7701c4ea3d1001fefeb3df65caeb3e624722.1751042810.git.pooja.katiyar@intel.com>
On 27/06/2025 21:10, 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.
>
> Additionally, update ucsi_send_command to accept message_out data
> and .sync_control function to pass message_out data to
> write_message_out function if the command is UCSI_SET_PDOS.
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com>
> ---
> Changelog v2:
> - Moved write_message_out operation to .sync_control.
> - Updated ucsi_send_command to accept message_out data.
>
> drivers/usb/typec/ucsi/cros_ec_ucsi.c | 4 +-
> drivers/usb/typec/ucsi/debugfs.c | 4 +-
> drivers/usb/typec/ucsi/displayport.c | 6 +--
> drivers/usb/typec/ucsi/ucsi.c | 64 ++++++++++++++++-----------
> drivers/usb/typec/ucsi/ucsi.h | 10 +++--
> drivers/usb/typec/ucsi/ucsi_acpi.c | 20 ++++++++-
> drivers/usb/typec/ucsi/ucsi_ccg.c | 4 +-
> 7 files changed, 72 insertions(+), 40 deletions(-)
>
[...]
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 01ce858a1a2b..c8410c88b45b 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -56,7 +56,7 @@ void ucsi_notify_common(struct ucsi *ucsi, u32 cci)
> EXPORT_SYMBOL_GPL(ucsi_notify_common);
>
> int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
> - void *data, size_t size)
> + void *data, size_t size, void *message_out)
Missing size for message_out. Also logically it should be:
int ucsi_sync_control_common(struct ucsi *ucsi, u64 command,
void *message_out, size_t message_out_size,
u32 *cci,
void *data, size_t size)
This way in params are separated from out.
> {
> bool ack = UCSI_COMMAND(command) == UCSI_ACK_CC_CI;
> int ret;
> @@ -68,6 +68,18 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
>
> reinit_completion(&ucsi->complete);
>
> + if (message_out) {
> + if (!ucsi->ops->write_message_out) {
> + ret = -EOPNOTSUPP;
> + goto out_clear_bit;
> + }
> +
> + ret = ucsi->ops->write_message_out(ucsi, message_out,
> + UCSI_COMMAND_DATA_LEN(command));
I think it should be other way around. write message_out, then set the
DataLength field of the command.
> + 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_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
> index 6b92f296e985..c0426bb1e81b 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 ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_WRITE);
Why do we need extra WRITE? Isn't the one performed by
ucsi_acpi_async_control() not enough?
> +}
> +
> static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
> {
> struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
--
With best wishes
Dmitry
next prev parent reply other threads:[~2025-06-28 1:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 18:10 [PATCH v2 0/3] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-06-27 18:10 ` [PATCH v2 1/3] usb: typec: ucsi: Add support for message out data structure Pooja Katiyar
2025-06-28 1:40 ` Dmitry Baryshkov [this message]
2025-07-01 9:03 ` Heikki Krogerus
2025-06-28 14:51 ` Greg KH
2025-07-01 8:46 ` Heikki Krogerus
2025-07-01 8:50 ` Dmitry Baryshkov
2025-07-01 10:05 ` Heikki Krogerus
2025-07-01 10:11 ` Dmitry Baryshkov
2025-07-01 12:51 ` Heikki Krogerus
2025-07-03 4:28 ` Katiyar, Pooja
2025-07-03 12:55 ` Dmitry Baryshkov
2025-06-27 18:10 ` [PATCH v2 2/3] usb: typec: ucsi: Enable debugfs for message_out " Pooja Katiyar
2025-06-28 1:43 ` Dmitry Baryshkov
2025-06-27 18:10 ` [PATCH v2 3/3] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-06-28 1:43 ` Dmitry Baryshkov
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=da49edc4-4aa9-462f-94d4-a2f2c920619a@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--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