Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp256685lqe; Wed, 10 Apr 2024 00:41:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhhqr0npaouUpy7GZvWqRRromt0P0JX8gXrY1j+J5YO4VmrOi7S5gnekGREl9YolajxxDuSIDekYdlAZSCOYJUt8ZpWuyb8MKLRe1Lyw== X-Google-Smtp-Source: AGHT+IErp+E5NOUfvREgrb4d1jJpdObEQ+lP1zjKaC9gGtkR3EZDWpg6oAeSST8Zp5bdMGn7GPoI X-Received: by 2002:ac5:c193:0:b0:4d3:1ef2:c97d with SMTP id z19-20020ac5c193000000b004d31ef2c97dmr1905743vkb.2.1712734917376; Wed, 10 Apr 2024 00:41:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712734917; cv=pass; d=google.com; s=arc-20160816; b=hWRvcec26PJ8V2Rimovi0ZfJuHEQQlrGhGgeytXFlUc2XHs5IcrLwF26Qf2rFU0NJ6 1f7XZ+jFvTQLRJIhNL8KfOEIbn4wdZXC3m1Mqd+tcb0uQhhmNL/GHuLYBDslV4g318iA 2JCdfdyET80vyLHfUjkzBuZvyejzcHdQyep4IN8TQ2KVjojI558wgz9kW7fTwdCUDWO3 0aNjPVPdGlwwGXbva21Uj6fBDoF0lDqtamHqfItqFYBSZxOTx82vRYcrDnGpdN2AI4kA zBz2VcyM+3/BtOUdDXgTg0NAA0w8amdjWdBR3nNtmPskq59+EBU/RkRdwh9mSUZu6F3M 3h9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=hB5oW33tnYUx9xUWOwkKVoqgUR+jPQ+jI7RbH+93nR0=; fh=ajYrquqyr6UWbATu+Hl6jO5fUas1YcmXTJOegDh1o2s=; b=gBNmCPOq1DrdW8QT7oxXOQBjggw3IPnieKR2Syubbkls5MbwXuusAZLgvAZSG4nvNl Doe8dVmh+Qo1d1NmDJdm5NINjMdNGiijuN/+8vRy9HQVAz/8XnH0u6k8rkd0FRNLlks4 vCyc6mdn+uP+DyVsemUKrtkN0bVzFSAO6aZlaahLgGnxIlLwmmu4nFUj/eD4HmzxIDgI WRUN76eBm7cg+l73dwLTcNAM40O+FKs4JnAuO2lqPQdQvaohWEzNDkkRFimDqCekvORN hrcMdAt95tc0OClJNhtyIZYlAzv+deFBxahS98S0dv2BRJSaPXoBUIqZVupi0t7Gsz6M LK5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-138084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138084-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jz4-20020a05622a81c400b004349685c6a0si5942258qtb.534.2024.04.10.00.41.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 00:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-138084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138084-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1F2E31C21096 for ; Wed, 10 Apr 2024 07:41:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E30E613D297; Wed, 10 Apr 2024 07:41:45 +0000 (UTC) Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16B2E53E00; Wed, 10 Apr 2024 07:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712734905; cv=none; b=quOLI4Pxdyp6IpSzpqWTlLKWoZYiAFjoBgA+kGh5LfcdA1PDu6MX/wI80wxA9/WpAHWKOQayap4eTS2iQb6DU6QlIV/peAmgvPm28s0uuJD2RWkigoH3a8BIu+2Jqr5psUElEv+Bn1oXXqjyoaBBvzTj0m8wKC5wbPWgFPPv7cI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712734905; c=relaxed/simple; bh=kWiFrLwu4of9a6CZEkiRvrLXBxbvVCraLpNjKjlu+kA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fECDYBk3IMdv2KX/yRHWpyLSigkGD+wiZhwPLrieQ0Hz6v9vLPkCCpv3McIMd4rTOuC9XK8LMHSeUvOegREAULwu/CyBZdzvAoyi8oVqWXrkG0iQNtyB8AHGtGVcgniemSddNkYtBsADFOsuT75rQuZ6PYVWoqb5f1t5R0zTTAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 28A9C140562; Wed, 10 Apr 2024 09:41:39 +0200 (CEST) Date: Wed, 10 Apr 2024 09:41:39 +0200 From: "Christian A. Ehrhardt" To: Dmitry Baryshkov Cc: Heikki Krogerus , Greg Kroah-Hartman , Neil Armstrong , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2 3/3] usb: typec: ucsi_glink: drop special handling for CCI_BUSY Message-ID: References: <20240409-qcom-ucsi-fixes-bis-v2-0-6d3a09faec90@linaro.org> <20240409-qcom-ucsi-fixes-bis-v2-3-6d3a09faec90@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@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: Hi Dmitry, On Wed, Apr 10, 2024 at 01:58:58AM +0300, Dmitry Baryshkov wrote: > On Tue, 9 Apr 2024 at 22:26, Christian A. Ehrhardt wrote: > > > > > > Hi Dmitry, > > > > On Tue, Apr 09, 2024 at 06:29:18PM +0300, Dmitry Baryshkov wrote: > > > Newer Qualcomm platforms (sm8450+) successfully handle busy state and > > > send the Command Completion after sending the Busy state. Older devices > > > have firmware bug and can not continue after sending the CCI_BUSY state, > > > but the command that leads to CCI_BUSY is already forbidden by the > > > NO_PARTNER_PDOS quirk. > > > > > > Follow other UCSI glue drivers and drop special handling for CCI_BUSY > > > event. Let the UCSI core properly handle this state. > > > > > > Reviewed-by: Heikki Krogerus > > > Signed-off-by: Dmitry Baryshkov > > > --- > > > drivers/usb/typec/ucsi/ucsi_glink.c | 10 ++++------ > > > 1 file changed, 4 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c > > > index 9ffea20020e7..fe9b951f5228 100644 > > > --- a/drivers/usb/typec/ucsi/ucsi_glink.c > > > +++ b/drivers/usb/typec/ucsi/ucsi_glink.c > > > @@ -176,7 +176,8 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset, > > > left = wait_for_completion_timeout(&ucsi->sync_ack, 5 * HZ); > > > if (!left) { > > > dev_err(ucsi->dev, "timeout waiting for UCSI sync write response\n"); > > > - ret = -ETIMEDOUT; > > > + /* return 0 here and let core UCSI code handle the CCI_BUSY */ > > > + ret = 0; > > > } else if (ucsi->sync_val) { > > > dev_err(ucsi->dev, "sync write returned: %d\n", ucsi->sync_val); > > > } > > > @@ -243,11 +244,8 @@ static void pmic_glink_ucsi_notify(struct work_struct *work) > > > ucsi_connector_change(ucsi->ucsi, con_num); > > > } > > > > > > - if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) { > > > - ucsi->sync_val = -EBUSY; > > > - complete(&ucsi->sync_ack); > > > - } else if (ucsi->sync_pending && > > > - (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) { > > > + if (ucsi->sync_pending && > > > + (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) { > > > complete(&ucsi->sync_ack); > > > } > > > } > > > > This handling of the command completion turned out to be racy in > > the ACPI case: If a normal command was sent one should wait for > > UCSI_CCI_COMMAND_COMPLETE only. In case of an UCSI_ACK_CC_CI > > command the completion is indicated by UCSI_CCI_ACK_COMPLETE. > > > > While not directly related, a port of this > > https://lore.kernel.org/all/20240121204123.275441-3-lk@c--e.de/ > > would nicely fit into this series. > > Ack, I'll take a look. Thanks. > However... I can not stop but notice that CCG and STM32 glue drivers > use the same old approach as we do. Which probably means that they > might have the same issue. I did ping the ccg people wrt. this but they have a different workaround that saves them at least most of the time, so I let this drop. > Could you please consider pulling up that > code into the UCSI driver? Maybe the low-level code really should just > read/write the messages, leaving all completions and CCI parsing to > the core layer? I did consider that but one of the ideas behind the new API for UCSI backends was that backends can send commands (e.g. as part of a quirk) even in the middle of a ->sync_write() call. Currently, I don't really see how to combine this with completion handling in the UCSI core. > > I don't have the hardware to do this myself. I did propose other changes to the API with little respone here: https://lore.kernel.org/all/20240218222039.822040-1-lk@c--e.de/ That could possibly be extended to achieve this. But again, that would require testers for all the backends. Best regards, Christian