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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e10594dd-cfc2-4d5e-bc1f-35aca05be027@linaro.org>
Date: Thu, 9 Oct 2025 18:42:50 +0200
From: Neil Armstrong <neil.armstrong@...aro.org>
To: Konrad Dybcio <konrad.dybcio@....qualcomm.com>,
 Vinod Koul <vkoul@...nel.org>, Kishon Vijay Abraham I <kishon@...nel.org>,
 Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>, Bjorn Andersson <andersson@...nel.org>,
 Konrad Dybcio <konradybcio@...nel.org>
Cc: Xilin Wu <sophon@...xa.com>, linux-arm-msm@...r.kernel.org,
 linux-phy@...ts.infradead.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org,
 Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
Subject: Re: [PATCH v5 2/3] phy: qcom: qmp-combo: get the USB3 & DisplayPort
 lanes mapping from DT

On 10/8/25 11:31, Konrad Dybcio wrote:
> On 10/6/25 3:55 PM, Neil Armstrong wrote:
>> The QMP USB3/DP Combo PHY hosts an USB3 phy and a DP PHY on top
>> of a combo glue to route either lanes to the 4 shared physical lanes.
>>
>> The routing of the lanes can be:
>> - 2 DP + 2 USB3
>> - 4 DP
>> - 2 USB3
>>
>> Get the lanes mapping from DT and stop registering the USB-C
>> muxes in favor of a static mode and orientation detemined
>> by the lanes mapping.
>>
>> This allows supporting boards with direct connection of USB3 and
>> DisplayPort lanes to the QMP Combo PHY lanes, not using the
>> USB-C Altmode feature.
>>
>> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
>> Signed-off-by: Neil Armstrong <neil.armstrong@...aro.org>
>> ---
> 
> [...]
> 
>> +static int qmp_combo_get_dt_lanes_mapping(struct device *dev, unsigned int endpoint,
>> +					  u32 *data_lanes, unsigned int max,
>> +					  unsigned int *count)
>> +{
>> +	struct device_node *ep;
>> +	int ret;
>> +
>> +	ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, endpoint);
>> +	if (!ep)
>> +		return -EINVAL;
>> +
>> +	ret = of_property_count_u32_elems(ep, "data-lanes");
>> +	if (ret < 0)
>> +		goto err_node_put;
>> +
>> +	*count = ret;
>> +
>> +	ret = of_property_read_u32_array(ep, "data-lanes", data_lanes,
>> +					 max_t(unsigned int, *count, max));
> 
> if (*count > max)
> 	return -EINVAL;

Yep

> 
>> +
>> +err_node_put:
>> +	of_node_put(ep);
> 
> __free(device_node)

why ? ep is not allocated, it goes up to:

static struct device_node *__of_get_next_child(const struct device_node *node,
						struct device_node *prev)
{
	struct device_node *next;

	if (!node)
		return NULL;

	next = prev ? prev->sibling : node->child;
	of_node_get(next);
	of_node_put(prev);
	return next;
}

> 
>> +
>> +	return ret;
>> +}
>> +
>> +static int qmp_combo_get_dt_dp_orientation(struct device *dev,
>> +					     enum typec_orientation *orientation)
>> +{
>> +	unsigned int count;
>> +	u32 data_lanes[4];
>> +	int ret;
>> +
>> +	/* DP is described on the first endpoint of the first port */
>> +	ret = qmp_combo_get_dt_lanes_mapping(dev, 0, data_lanes, 4, &count);
>> +	if (ret < 0)
>> +		return ret == -EINVAL ? 0 : ret;
>> +
>> +	/* Search for a match and only update orientation if found */
>> +	qmp_combo_find_lanes_orientation(dp_data_lanes, ARRAY_SIZE(dp_data_lanes),
>> +					 data_lanes, count, orientation);
> 
> You can zero-initialize `count` and drop the custom error parsing above

Good idea


Thanks,
Neil

> 
> Konrad


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ