Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp31357rdb; Mon, 15 Jan 2024 10:58:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFYLQJc6L/W7lJlM3H+4S6CyFVUurpaNx1QwB/8SdLtYoWcKyP9l/X625o45UP1FrU/G0z X-Received: by 2002:a05:6a00:3cc1:b0:6d9:8b96:d453 with SMTP id ln1-20020a056a003cc100b006d98b96d453mr8643084pfb.42.1705345111652; Mon, 15 Jan 2024 10:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705345111; cv=none; d=google.com; s=arc-20160816; b=Gh74We92J1zAjk/4eYx9HvHJopdDFDrUONpyRU+w9b4GVuVOlzlIypK7MiSRptlJng 7bYyGMmKBqr1W1wVfB92s33WInXF063J7ykITYctjX9Yxd3vPNRYViBuYRJ48d32KD6o kitEX5QjnyNW/FF/Vz1HOzeIURNIOZUs/Zl5Ic7iFdi22xSgmg01ewFtyz4fw5lXO2Aj phWwTWKRVm6SoK3oFcNluea5q9kysyK9pnfuBEV+BIR/tNgL4W6C51e8rCMN4PIPC16h BhJz4XeWkZFbk1rc4V9DjE5L5D3ToJcrK+bVGom0Jhcc4tOv/USZWLXb0HPZUgrHD3Nt 1RpQ== ARC-Message-Signature: i=1; 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=g0rqbvJt1OQy+LEknx8fqZaIIK5mchZUwQ7+LZp+pX0=; fh=SP6ICHlHabtfwk5KPHeSV5nH/LmXZk1fgtTm7hbcrD4=; b=HCsiD57XJV7YN3Jha0wba/YShnQrHLdEPya+aaOf1bzEJLSMGBav0pi4pgWXJubdGz UIhr8nf96AV4jeR5A08reM7vtGbtEpoP61a5072QdhvDzoPQPesKDIQ6S84c+5z6SU4p K9dlexNKe66E1V4RXLrzGPP+8gNL/7twu8S7P6yY01g/Zv2DkUAQkkNcKpFRn5fTLCnz aL7aHsqB6ZUg0XBShc+Gax0llpV84nLqrvIv52uLgYjHEKBqCQ4p7awIwk6w9gngZ7gQ l8FtslKnSZn2GdvYwNTkJZYyEF6om8yYphNei8DEwMlGQCSqlmVOt9C5i9AjjDTAyHeI 8ZZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26421-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b186-20020a6334c3000000b005cf1ddb15a1si9639061pga.93.2024.01.15.10.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:58:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26421-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 48E0F283A3D for ; Mon, 15 Jan 2024 18:57:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24FFF18E2F; Mon, 15 Jan 2024 18:55:24 +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 0B0E118E1F; Mon, 15 Jan 2024 18:55:18 +0000 (UTC) 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 EBB1314035E; Mon, 15 Jan 2024 19:55:15 +0100 (CET) Date: Mon, 15 Jan 2024 19:55:15 +0100 From: "Christian A. Ehrhardt" To: Heikki Krogerus Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Mario Limonciello , Saranya Gopal , linux-kernel@vger.kernel.org Subject: Re: [RFC] Fix stuck UCSI controller on DELL Message-ID: References: <20240103100635.57099-1-lk@c--e.de> 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 Heikki, sorry to bother you again with this but I'm afraid there's a misunderstanding wrt. the nature of the quirk. See below: On Thu, Jan 04, 2024 at 01:59:02PM +0200, Heikki Krogerus wrote: > Hi Christian, > > On Wed, Jan 03, 2024 at 11:06:35AM +0100, Christian A. Ehrhardt wrote: > > I have a DELL Latitude 5431 where typec only works somewhat. > > After the first plug/unplug event the PPM seems to be stuck and > > commands end with a timeout (GET_CONNECTOR_STATUS failed (-110)). > > > > This patch fixes it for me but according to my reading it is in > > violation of the UCSI spec. On the other hand searching through > > the net it appears that many DELL models seem to have timeout problems > > with UCSI. > > > > Do we want some kind of quirk here? There does not seem to be a quirk > > framework for this part of the code, yet. Or is it ok to just send the > > additional ACK in all cases and hope that the PPM will do the right > > thing? > > We can use DMI quirks. Something like the attached diff (not tested). > > thanks, > > -- > heikki > diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c > index 6bbf490ac401..7e8b1fcfa024 100644 > --- a/drivers/usb/typec/ucsi/ucsi_acpi.c > +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c > @@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_ > return 0; > } > > -static const struct ucsi_operations ucsi_zenbook_ops = { > - .read = ucsi_zenbook_read, > - .sync_write = ucsi_acpi_sync_write, > - .async_write = ucsi_acpi_async_write > -}; > +static int ucsi_dell_sync_write(struct ucsi *ucsi, unsigned int offset, > + const void *val, size_t val_len) > +{ > + u64 ctrl = *(u64 *)val; > + int ret; > + > + ret = ucsi_acpi_sync_write(ucsi, offset, val, val_len); > + if (ret && (ctrl & (UCSI_ACK_CC_CI | UCSI_ACK_CONNECTOR_CHANGE))) { > + ctrl= UCSI_ACK_CC_CI | UCSI_ACK_COMMAND_COMPLETE; > + > + dev_dbg(ucsi->dev->parent, "%s: ACK failed\n", __func__); > + ret = ucsi_acpi_sync_write(ucsi, UCSI_CONTROL, &ctrl, sizeof(ctrl)); > + } Unfortunately, this has the logic reversed. The quirk (i.e. the additional UCSI_ACK_COMMAND_COMPLETE) is required after a _successful_ UCSI_ACK_CONNECTOR_CHANGE. Otherwise, _subsequent_ commands will timeout (usually the next GET_CONNECTOR_CHANGE). This means the quirk must be applied _before_ we detect any failure. Consequently, the quirk has the potential to break working systems. Sorry, if that wasn't clear from my original mail. Please let me know if this changes how you want the quirks handled. Thanks Christian