From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54DD827A90F; Tue, 24 Jun 2025 09:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756124; cv=none; b=i7TCUHW7VqLlHInOg6LjFyMEIm/pgyTCAbyzdeCTAZb3ePAfqJMKD4tAEB20TIJeA/BniXniLxKuvdLfnowtIlHi5Ib5zmSm6VxP0sbK1iDHxazHiiJqpDu0pyq5teXuu+VpVmgwfPGcRwR/DJabPP0OzAgudtJqIjsbsdWnF08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756124; c=relaxed/simple; bh=nD9Z85wNJVBrnaSiitJ62UdEMzhSwyJpACrH6JwSTmw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q2J1DGfcrrdk13uuPMtathOIidhQz7TTBkUFuJQHSn+Bucsp4Sj+xjmnQFcJq5Nq2B6j+dI/9MmMnSWnO0yIRBGwPsPIMXqwCJYR3TN29c78TLmJ3itvNq/Allr8Fh+7WaoEnb9qvB7YXGwDzSxRkprhlulhmGw9fx+KT0iy2ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lQ2DyeGu; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lQ2DyeGu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750756122; x=1782292122; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=nD9Z85wNJVBrnaSiitJ62UdEMzhSwyJpACrH6JwSTmw=; b=lQ2DyeGu/TUNuFFTn/7G+c2Mw1wK+AYye1CeWuE3sVwxEyltmSnvQJ5N EeIPHYUjiAcxZy3arq+r9wlcrVFQkseDc1Rkx54z2mXoGOepjU/8cBiu3 JbQixISUP9BZ4WbZuA/cgOXgS0SSuJ0YcUUz6xPH7/r6tiFWogawXw8Sw HPOjjR5Z+hacx+17UTFUadkHhtVO9meG2UY6C+Hbm7jZCK5ImciQmIqsb 2VNxMD10Q7otmizNV+7T/cUGPcWlUSJGzv5BCB63g7DH6cNfE7Sffhakz pCsIYLEB12+yEnx9bYhiM/UZbmjz3O+p2wRcYzuYNDp+KvSoMjiyXoifH w==; X-CSE-ConnectionGUID: C26KPgtiR1mO4tS+L3GkCw== X-CSE-MsgGUID: WvKg51XyQbGb/MI3azR0Dw== X-IronPort-AV: E=McAfee;i="6800,10657,11473"; a="53123488" X-IronPort-AV: E=Sophos;i="6.16,261,1744095600"; d="scan'208";a="53123488" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2025 02:08:41 -0700 X-CSE-ConnectionGUID: NGLu+VhQQnGaJJE3DBGd3g== X-CSE-MsgGUID: hi2eUoqAQ/exPm0GXxITBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,261,1744095600"; d="scan'208";a="157364202" Received: from kuha.fi.intel.com ([10.237.72.152]) by fmviesa004.fm.intel.com with SMTP; 24 Jun 2025 02:08:37 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 24 Jun 2025 12:08:36 +0300 Date: Tue, 24 Jun 2025 12:08:36 +0300 From: Heikki Krogerus To: Dmitry Baryshkov Cc: Greg Kroah-Hartman , Bryan O'Donoghue , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Bjorn Andersson , Konrad Dybcio , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 3/8] usb: typec: ucsi: yoga-c630: remove duplicate AltModes Message-ID: References: <20250621-c630-ucsi-v1-0-a86de5e11361@oss.qualcomm.com> <20250621-c630-ucsi-v1-3-a86de5e11361@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250621-c630-ucsi-v1-3-a86de5e11361@oss.qualcomm.com> On Sat, Jun 21, 2025 at 09:12:58PM +0300, Dmitry Baryshkov wrote: > On Lenovo Yoga C630 the EC firmware is buggy and it returns duplicate > AltModes over and over again instead of returning an empty one, as > demanded by the spec. Ignore extra altmodes by zeroing them in the > update_altmodes() callback. It is not possible to shortcut that in the > sync_control() callback since we need to know if the AltMode matches the > first reported AltMode or not. > > Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c > index 47e8dd5b255b2b306dd9c3d6ac8c3b896954981a..7cc1342d6e2f1d2c6f5b95caa48a711a280b91d3 100644 > --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c > +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c > @@ -71,6 +71,28 @@ static int yoga_c630_ucsi_async_control(struct ucsi *ucsi, u64 command) > return yoga_c630_ec_ucsi_write(uec->ec, (u8*)&command); > } > > +static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi, > + u8 recipient, > + struct ucsi_altmode *orig, > + struct ucsi_altmode *updated) > +{ > + int i; > + > + if (orig[0].svid == 0 || recipient != UCSI_RECIPIENT_SOP) > + return false; > + > + /* EC is nice and repeats altmodes again and again. Ignore copies. */ > + for (i = 1; i < UCSI_MAX_ALTMODES; i++) { > + if (orig[i].svid == orig[0].svid) { > + dev_dbg(ucsi->dev, "Found duplicate altmodes, starting from %d\n", i); > + memset(&orig[i], 0, (UCSI_MAX_ALTMODES - i) * sizeof(*orig)); > + break; > + } > + } > + > + return false; > +} > + > static const struct ucsi_operations yoga_c630_ucsi_ops = { > .read_version = yoga_c630_ucsi_read_version, > .read_cci = yoga_c630_ucsi_read_cci, > @@ -78,6 +100,7 @@ static const struct ucsi_operations yoga_c630_ucsi_ops = { > .read_message_in = yoga_c630_ucsi_read_message_in, > .sync_control = ucsi_sync_control_common, > .async_control = yoga_c630_ucsi_async_control, > + .update_altmodes = yoga_c630_ucsi_update_altmodes, > }; > > static int yoga_c630_ucsi_notify(struct notifier_block *nb, > > -- > 2.39.5 -- heikki