lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aFpsLpuE1VYjxtJy@kuha.fi.intel.com>
Date: Tue, 24 Jun 2025 12:13:18 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Bryan O'Donoghue <bryan.odonoghue@...aro.org>,
	Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
	Bjorn Andersson <andersson@...nel.org>,
	Konrad Dybcio <konradybcio@...nel.org>, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH 5/8] usb: typec: ucsi: yoga-c630: fake AltModes for port 0

On Sat, Jun 21, 2025 at 09:13:00PM +0300, Dmitry Baryshkov wrote:
> EC firmware provides information about partner AltModes and handles the
> DisplayPort AltMode internally, however it doesn't report AltModes of
> the port to the host. Fake the DP AltMode for port0 in order to let
> Linux bind displayport AltMode driver.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>

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

> ---
>  drivers/usb/typec/ucsi/ucsi.h           |  1 +
>  drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index d02f6a3e2f50a4044eb3f22276931017cc624532..b711e1ecc3785eeb34e407e58df939f2d29bdb38 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -50,6 +50,7 @@ struct dentry;
>  /* Command Status and Connector Change Indication (CCI) bits */
>  #define UCSI_CCI_CONNECTOR(_c_)		(((_c_) & GENMASK(7, 1)) >> 1)
>  #define UCSI_CCI_LENGTH(_c_)		(((_c_) & GENMASK(15, 8)) >> 8)
> +#define UCSI_SET_CCI_LENGTH(_c_)	((_c_) << 8)
>  #define UCSI_CCI_NOT_SUPPORTED		BIT(25)
>  #define UCSI_CCI_CANCEL_COMPLETE	BIT(26)
>  #define UCSI_CCI_RESET_COMPLETE		BIT(27)
> diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> index 2005f64ebfe43ca2bcada2231ff99c578fdce877..506faf31b6e3a056e067f2bb69f5e9e5ea40e514 100644
> --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> @@ -76,6 +76,28 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
>  				       u32 *cci,
>  				       void *data, size_t size)
>  {
> +	int ret;
> +
> +	/*
> +	 * EC doesn't return connector's DP mode even though it is supported.
> +	 * Fake it.
> +	 */
> +	if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
> +	    UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 1 &&
> +	    UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_CON &&
> +	    UCSI_ALTMODE_OFFSET(command) == 0) {
> +		static const struct ucsi_altmode alt = {
> +			.svid = USB_TYPEC_DP_SID,
> +			.mid = USB_TYPEC_DP_MODE,
> +		};
> +
> +		dev_dbg(ucsi->dev, "faking DP altmode for con1\n");
> +		memset(data, 0, size);
> +		memcpy(data, &alt, min(sizeof(alt), size));
> +		*cci = UCSI_CCI_COMMAND_COMPLETE | UCSI_SET_CCI_LENGTH(sizeof(alt));
> +		return 0;
> +	}
> +
>  	/*
>  	 * EC can return AltModes present on CON1 (port0, right) for CON2
>  	 * (port1, left) too. Ignore all requests going to CON2 (it doesn't
> 
> -- 
> 2.39.5

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ