From: Stephen Boyd <sboyd@kernel.org>
To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
chrome-platform@lists.linux.dev, heikki.krogerus@linux.intel.com,
linux-usb@vger.kernel.org, tzungbi@kernel.org
Cc: akuchynski@google.com, pmalani@chromium.org, jthies@google.com,
dmitry.baryshkov@linaro.org, badhri@google.com,
rdbabiera@google.com,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 5/7] platform/chrome: cros_ec_typec: Displayport support
Date: Wed, 11 Dec 2024 13:58:30 -0800 [thread overview]
Message-ID: <2bfe74d6a29ca13a7f89f116a2f0c6be.sboyd@kernel.org> (raw)
In-Reply-To: <20241206153813.v4.5.I142fc0c09df58689b98f0cebf1c5e48b9d4fa800@changeid>
Quoting Abhishek Pandit-Subedi (2024-12-06 15:38:16)
> diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c
> new file mode 100644
> index 000000000000..bb7c7ad2ff6e
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_typec_altmode.c
> @@ -0,0 +1,281 @@
[...]
> +
> +static const struct typec_altmode_ops cros_typec_altmode_ops = {
> + .enter = cros_typec_altmode_enter,
> + .exit = cros_typec_altmode_exit,
> + .vdm = cros_typec_altmode_vdm,
> +};
> +
> +#if IS_ENABLED(CONFIG_TYPEC_DP_ALTMODE)
> +int cros_typec_displayport_status_update(struct typec_altmode *altmode,
> + struct typec_displayport_data *data)
> +{
> + struct cros_typec_dp_data *dp_data =
> + typec_altmode_get_drvdata(altmode);
How does this work? I see that the type of the drvdata is struct
cros_typec_altmode_data per the allocation in
cros_typec_register_displayport(), but here we're treating it as the
type struct cros_typec_dp_data, which has a struct
cros_typec_altmode_data as the first member. The allocation is too small
from what I can tell. The same problem looks to be there in
cros_typec_displayport_vdm().
> + struct cros_typec_altmode_data *adata = &dp_data->adata;
> +
> + if (!dp_data->pending_status_update) {
> + dev_dbg(&altmode->dev,
> + "Got DPStatus without a pending request");
> + return 0;
> + }
> +
> + if (dp_data->configured && dp_data->data.conf != data->conf)
> + dev_dbg(&altmode->dev,
> + "DP Conf doesn't match. Requested 0x%04x, Actual 0x%04x",
> + dp_data->data.conf, data->conf);
> +
> + mutex_lock(&adata->lock);
> +
> + dp_data->data = *data;
> + dp_data->pending_status_update = false;
> + adata->header |= VDO_CMDT(CMDT_RSP_ACK);
> + adata->vdo_data = &dp_data->data.status;
> + adata->vdo_size = 2;
> + schedule_work(&adata->work);
> +
> + mutex_unlock(&adata->lock);
> +
> + return 0;
> +}
> +
> +struct typec_altmode *
> +cros_typec_register_displayport(struct cros_typec_port *port,
> + struct typec_altmode_desc *desc,
> + bool ap_mode_entry)
> +{
> + struct typec_altmode *alt;
> + struct cros_typec_altmode_data *data;
> +
> + alt = typec_port_register_altmode(port->port, desc);
> + if (IS_ERR(alt))
> + return alt;
> +
> + data = devm_kzalloc(&alt->dev, sizeof(*data), GFP_KERNEL);
> + if (!data) {
> + typec_unregister_altmode(alt);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + INIT_WORK(&data->work, cros_typec_altmode_work);
> + mutex_init(&data->lock);
> + data->alt = alt;
> + data->port = port;
> + data->ap_mode_entry = ap_mode_entry;
> + data->sid = desc->svid;
> + data->mode = desc->mode;
> +
> + typec_altmode_set_ops(alt, &cros_typec_altmode_ops);
> + typec_altmode_set_drvdata(alt, data);
'data' is of type struct cros_typec_altmode_data here
> +
> + return alt;
> +}
next prev parent reply other threads:[~2024-12-11 21:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 23:38 [PATCH v4 0/7] Thunderbolt and DP altmode support for cros-ec-typec Abhishek Pandit-Subedi
2024-12-06 23:38 ` [PATCH v4 1/7] usb: typec: Only use SVID for matching altmodes Abhishek Pandit-Subedi
2024-12-11 9:40 ` Heikki Krogerus
2024-12-06 23:38 ` [PATCH v4 2/7] usb: typec: Add driver for Thunderbolt 3 Alternate Mode Abhishek Pandit-Subedi
2024-12-09 4:28 ` kernel test robot
2024-12-11 0:21 ` Stephen Boyd
2024-12-13 17:55 ` Abhishek Pandit-Subedi
2024-12-06 23:38 ` [PATCH v4 3/7] usb: typec: Print err when displayport fails to enter Abhishek Pandit-Subedi
2024-12-11 10:09 ` Heikki Krogerus
2024-12-06 23:38 ` [PATCH v4 4/7] platform/chrome: cros_ec_typec: Update partner altmode active Abhishek Pandit-Subedi
2024-12-10 23:32 ` Stephen Boyd
2024-12-13 18:01 ` Abhishek Pandit-Subedi
2024-12-06 23:38 ` [PATCH v4 5/7] platform/chrome: cros_ec_typec: Displayport support Abhishek Pandit-Subedi
2024-12-11 0:08 ` Stephen Boyd
2024-12-13 18:29 ` Abhishek Pandit-Subedi
2024-12-16 19:46 ` Stephen Boyd
2024-12-11 21:58 ` Stephen Boyd [this message]
2024-12-13 18:33 ` Abhishek Pandit-Subedi
2024-12-16 19:49 ` Stephen Boyd
2024-12-06 23:38 ` [PATCH v4 6/7] platform/chrome: cros_ec_typec: Thunderbolt support Abhishek Pandit-Subedi
2024-12-06 23:38 ` [PATCH v4 7/7] platform/chrome: cros_ec_typec: Disable tbt on port Abhishek Pandit-Subedi
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=2bfe74d6a29ca13a7f89f116a2f0c6be.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@google.com \
--cc=badhri@google.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.baryshkov@linaro.org \
--cc=groeck@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pmalani@chromium.org \
--cc=rdbabiera@google.com \
--cc=tzungbi@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