From patchwork Sun Jan 7 00:16:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 18789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp333481dyq; Sat, 6 Jan 2024 16:18:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXy0gjE+I8DpWYGBnABpI+VzhGfSHaDs5r00RsA1GyunlYD3UWCs7Pf+oDtLq5EmzA2zrJ X-Received: by 2002:a05:620a:4a:b0:77e:fba3:939a with SMTP id t10-20020a05620a004a00b0077efba3939amr1778508qkt.124.1704586687350; Sat, 06 Jan 2024 16:18:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704586687; cv=none; d=google.com; s=arc-20160816; b=t7T7Ai1CA/LQO57fTJk6O8jzbIGRPCrYPNACI4bVq9wkEmA9khy0HTwvAByCEG53S/ EGDjdyyGDMUwF9aY9x/3D2uUgkvpG0kyorf29ZB35FDDqhEuSsCycfNV1NckEzXEWIKk HVZ831KLAIVGxSoanzgvxxcfwR9gBAuzWKi7AdY9Bpl1f48/Kbn9THTc7r1iM3b3osy4 STsad/+h2LtkhFaSuzyz9pwLC5SBQAt83/7T9GG8yEAGLB30p/MPJr/0QX9ZUFdIN6G+ gyHNh8Pj/S1ev6wtmtubY1iPL0G4Qms///0gCFycQJwS+A8YE/7SCD5qUfRuYq1OtY1Y rzOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=MY0GXDwkBjAiMuyq89mfUYqqD1LmmHiQapPLQlRvYWs=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=eSRPyQfxCMVpLeo0bFUig+lR+g6RH3/VAMyXf+K1vWHw43Y6f/6yqtdypLSbIk/ao2 IWdsEM45jeQnUf6bywhYQ6KxtciZTGrDm5bG/FGc6xx4SiBx4nVXowv65+T0y37ITQQT pFJmydOiWF7CFyed+yN0q4limaJZgfop1zB09WNWzhvNGV2FtSfdDlKdX99SqwbxRdqs KMGi6+9Lxoqbq2OAFdif0VkfJ5h+rN7QxVsydViCSyIMxA/OQ8Hg/JrNeEicZOrByQj8 3S+KSvkchc9n4QI0ZVrV3bOINFmRDYoNxY1PZgiGDdf2J1lshCXrsbtS/iwW9VFZx7F1 4VuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18742-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18742-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id oq32-20020a05620a612000b00781711b5778si4630524qkn.107.2024.01.06.16.18.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 16:18:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18742-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18742-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18742-ouuuleilei=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 272911C20E2E for ; Sun, 7 Jan 2024 00:18:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 396ED20E1; Sun, 7 Jan 2024 00:17:49 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66C897EC; Sun, 7 Jan 2024 00:17:43 +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 9BC681402B8; Sun, 7 Jan 2024 01:17:41 +0100 (CET) From: "Christian A. Ehrhardt" To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: "Christian A. Ehrhardt" , Dell.Client.Kernel@dell.com, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Jack Pham , Fabrice Gasnier , =?utf-8?q?Samuel_=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 0/4] Make UCSI on Dell Latitude work Date: Sun, 7 Jan 2024 01:16:57 +0100 Message-Id: <20240107001701.130535-1-lk@c--e.de> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787388690330306088 X-GMAIL-MSGID: 1787388690330306088 The UCSI interface on a Dell Latitude 5431 stops working after the first async event with: GET_CONNECTOR_STATUS failed (-110) The core problem is that when sending the ACK_CC_CI command to clear the connector status changed condition the PPM expects us to send anothr ack for the command completion condition. However, the UCSI spec states that no ack for the command completion is required when the command is ACK_CC_CI (or PPM_RESET). There are various reports that suggest that several Dell laptops are affected by this problem. E.g. the kernel bugzilla has this report which is most likely an instance of this bug: https://bugzilla.kernel.org/show_bug.cgi?id=216426 This led me to the somewhat bold conclusion that the quirk should probably be applied to all Dell systems. However, I'm open to suggestions on how to proceed with this. While debugging another issue was found that is present for all systems but only triggered with the quirk active: The ACK_CC_CI command to ack the connector status change is sent without any lock which allows for a race where this command is sent while another command is currently in progress. The series consists of 4 changes: - Add the missing lock around ucsi_acknowledge_connector_change. This change is a generic bugfix. - Add infrastructure for quirks and a quirk override module parameter to the typec_ucsi module. There's at least one other change in the works that wants something similar here: https://lore.kernel.org/all/20231023215327.695720-2-dmitry.baryshkov@linaro.org/ Additionally, doing the dell quirk is a bit easier in the gereric UCSI code. The module parameter will allow users to fix things if the DMI matching goes wrong. Additionally, we can easily ask users to test different quirks without the need to recompile. - Actually add the required quirk to ucsi.c. - Finally, refactor DMI matching in ucsi_acpi.c and enable the new quirk for all DELL systems. The latter is kind of bold and I'm open to suggestings on how to proceed here. I'm CC'ing Dell.Client.Kernel@dell.com because this seems to be a list where Dell people are that might be able to provide more insight on this. Christian A. Ehrhardt (4): usb: ucsi: Add quirk infrastructure usb: ucsi: Add missing ppm_lock usb: ucsi: Quirk to ack a connector change ack cmd usb: ucsi: Apply UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD to DELL systems .../admin-guide/kernel-parameters.txt | 5 +++ drivers/usb/typec/ucsi/ucsi.c | 21 ++++++++- drivers/usb/typec/ucsi/ucsi.h | 7 ++- drivers/usb/typec/ucsi/ucsi_acpi.c | 45 ++++++++++++++++--- drivers/usb/typec/ucsi/ucsi_ccg.c | 2 +- drivers/usb/typec/ucsi/ucsi_glink.c | 2 +- drivers/usb/typec/ucsi/ucsi_stm32g0.c | 2 +- 7 files changed, 73 insertions(+), 11 deletions(-)