Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1353995lqt; Wed, 20 Mar 2024 00:48:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXOI0yUKM0RYmw8lCmM60Edchbarmqw9z5iBWa8CVhfQ/y5J3Jg8IsvhAfekfAJWcgcjpUPodN/fWvfDn6mdRGrXLEMMwUNL8pr8uOghw== X-Google-Smtp-Source: AGHT+IHIoE3uSPkG0djEP6I7wZxpN59PVjbifWISAlVzWRqJlz4O7+zQEWuPawZVxUuoA6H7LLFx X-Received: by 2002:a05:6a00:8685:b0:6e8:5b99:8f66 with SMTP id hh5-20020a056a00868500b006e85b998f66mr660546pfb.25.1710920934110; Wed, 20 Mar 2024 00:48:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710920934; cv=pass; d=google.com; s=arc-20160816; b=QmWDQzYwYjFJ2Sg49cKU60bsJqw4xS8zpo5aAT4+HZPmPLa6/wXi9CvAxBwfSt9j2r rqKQ8/Py1HrcTd96mjRCdJ6f2LWhQ1HRFMDqamg0ClkqVqwAK0avpQYt9whY/9K+YiP8 KUFytkryhDSfdb1asxkW0Z1QUpCM7JJuPyP7jQfKAeecHHRK3SZfPRnCP26w/j6GUvuP 7M743zaCRkfmZxtR89xYRO/vnaoGd2vizACFiGOpulEpY/4A6gn/XllIO3rgxSFU1ZGJ 0BSdN4iEY/ttxgcCkIWif6u7OrfFhcOfY/YdxwQWa8BdbEq6XrQTopz/ezsUcLd79Aih M/Rg== ARC-Message-Signature: i=2; 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=RAjoljuhvq+gG3CH/+RfTkNFh7qbLIMYHqyJwVuG2sM=; fh=t7qge2pgQ1KGYNFJFP5O5P99eTkxe/9M9cwHlxSyYyw=; b=DjAOm+D57otftmGOeQJC9L1Szw+NkbP/2gT4mMLNlpwaqdU+dZlxJBRLK6OmVoEsE9 eBC7OC7bjQMZELwdANpwFOc+Wr7qrMfVw4u7R0Si/uMVjCEQHNRLo804UWdHcWAT4xK+ NiA3/LsBZpPrLNZRnzSugIeDeKo59CJ6uAHPfW2utJlBksqXVju6jx8zMG00t+2zbBgZ 75LWQew/hMISl19BSzJ1LE1IRZ0jk2GajkhcEOAVdOGZfrBZpc7X6BJNZ+NU/Ib33m3f Lo7Ws4oHsJfpVBA4rGY1pSBg7AbNO+2CFf2+5Cq3h2r09JtjrMljqsHt1FAS+waGP3NK GIoQ==; 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-108570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108570-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 20-20020a631354000000b005d8bc1d9b5esi11852316pgt.313.2024.03.20.00.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 00:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108570-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; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-108570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108570-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 95E55283777 for ; Wed, 20 Mar 2024 07:48:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D5FE2C6B5; Wed, 20 Mar 2024 07:48:39 +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 E310E2231C; Wed, 20 Mar 2024 07:48:36 +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=1710920918; cv=none; b=JhSuh/VrFFrtsP5QBJZiXyj7tW9u3EbwSw72SKlM5X8IPktHymibfIIH3ZBDHe9K9Do5WFLlNRGF9Ro3ldPWEl1Hf6GbPbK+ugDoUVXFKsgTQ87TughLLVzux8HsusUa9gnSnDqnOw50DsCXYIwbRb1SICv73OHDSjwfmVY8wI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710920918; c=relaxed/simple; bh=6v51l2BaV+t4HJloO9qBHphewQnPu0qnDnrMTLpEHjk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=g9+s4TYPJCI9lPEyEGZfLBrmWbgKAV7/FEB5EYkzKhVuSuNqZ8tQDf+A/DeAh+h//VnXBrItehVIFc8Tjgdu5wGYbj2vTx8zXlkSYNQhEH4BTohhzYl1a2HeM4+LnGMOpKnSoGQjdQNpBwd1OfkCsGssUE6j7o0TpiIYJMVxQ/M= 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 EBA5E140551; Wed, 20 Mar 2024 08:40:01 +0100 (CET) From: "Christian A. Ehrhardt" To: linux-kernel@vger.kernel.org Cc: "Christian A. Ehrhardt" , Heikki Krogerus , Greg Kroah-Hartman , Prashant Malani , Jameson Thies , Abhishek Pandit-Subedi , Neil Armstrong , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , =?UTF-8?q?Samuel=20=C4=8Cavoj?= , linux-usb@vger.kernel.org, Kenneth Crudup Subject: [PATCH 0/5] Fix various races in UCSI Date: Wed, 20 Mar 2024 08:39:21 +0100 Message-Id: <20240320073927.1641788-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 Content-Transfer-Encoding: 8bit Fix various races in UCSI code: - The EVENT_PENDING bit should be cleared under the PPM lock to avoid spurious re-checking of the connector status. - The initial connector change notification during init may be lost which can cause a stuck UCSI controller. Observed by me and others during resume or after module reload. - Unsupported commands must be ACKed. This was uncovered by the recent change from Jameson Thies that did sent unsupported commands. - The DELL quirk still isn't quite complete and I've found a more elegant way to handle this. A connector change ack _is_ accepted on affected systems if it is bundled with a command ack. - If we do two consecutive resets or the controller is already reset at boog the second reset might complete early because the reset complete bit is already set. ucsi_ccg.c has a work around for this but it looks like an more general issue to me. NOTE: As a result of these individual fixes we could think about the question if there are additional cases where we send some type of command to the PPM while the bit that indicates its completion is already set in CCI. And in fact there is one more case where this can happen: The ack command that clears the connector change is sent directly after the ack command for the previous command. It might be possible to simply ack the connector change along with the first command ucsi_handle_connector_change() and not at the end. AFAICS the connector lock should protect us from races that might arise out of this. Christian A. Ehrhardt (5): usb: typec: ucsi: Clear EVENT_PENDING under PPM lock usb: typec: ucsi: Check for notifications after init usb: typec: ucsi: Ack unsupported commands usb: typec: ucsi_acpi: Refactor and fix DELL quirk usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset drivers/usb/typec/ucsi/ucsi.c | 56 ++++++++++++++++++++-- drivers/usb/typec/ucsi/ucsi_acpi.c | 75 +++++++++++++----------------- 2 files changed, 84 insertions(+), 47 deletions(-) -- 2.40.1