Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp54442rdb; Tue, 16 Jan 2024 14:54:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcFSX2Z0W6s6j8Uf8OKj1OLfj1RZYILSQ9lawGxFmifI1PuHZ/pQtb1ApjhF8AqpcHWsDq X-Received: by 2002:a92:d704:0:b0:35d:a4a9:7bb7 with SMTP id m4-20020a92d704000000b0035da4a97bb7mr9264888iln.63.1705445673835; Tue, 16 Jan 2024 14:54:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705445673; cv=pass; d=google.com; s=arc-20160816; b=TLyfFCePnFaT5lfiorARI3hub9swNDBYA+kETj0KXqC7W6E0SxQHUwBwqeJZHH+dt9 IdXzz9USTwASZ3JBCrFm76KJklXacyOr7gqjF2L0fCe4y6d1vXa5QjdS1JmiLCPq2Cyh dAV+JcvQ6ZynQWRPDDXO0MBiA0MeNqWmR5P2cmW/oZLcmQd/PdlEMykMvV/WO3Z6zQs3 6XloJq7jz9WXs1O+tJMwQJVHE2aGDmrHiVUHnTkBRDMWIW4/m4L9udZIRh5cm/yw4d71 jBGUzfDJUz1N7DjaeGQCu7MClnq+luMVc58ucqNTGtrm5VJ8baNZz9X9IrU5RsLFgM3b 1qZw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kSUObrCSDT4osilsbyHmtDC/yHeRgSISzhA6TjOCbLA=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=eISFAsKorPbFZ+fBTIQkkFkr05iiue60yRUvjxEJTTXMFKHGABJVLfwXOM0aTfL9Um HtDzeZ9VQJ92r7RgYaMOmGdVTTLyC5kgW8ZzPHb2kSsDxroBrNIyKo2Ba2R5NcsZqhXU BHFpU3qQPMGnsn/zJnM8rghjsMcz1sM90wATgrKNsmtguhgiXdQJyH2vd3a0FTbY6Fdt ryc6HnMTx/CNlPoimLfhlg31ylD5LLS3EKsyOu/DD2Yh4qzjmhCTOJ4NZkNNS3AoxlNo AG4GsUZJLpg9lGI2pIJMPXHBiWQhaZd/vxzAM9iKEMBINtJJXKzFPKhg/ips6rvoK0Au UFkg== 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-28359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28359-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 i33-20020a635861000000b005cdf48b01f4si11367660pgm.717.2024.01.16.14.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28359-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-28359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28359-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 BC8312950E2 for ; Tue, 16 Jan 2024 22:46:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F21521DA35; Tue, 16 Jan 2024 22:41:14 +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 B1D8C1C2BB; Tue, 16 Jan 2024 22:41:10 +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=1705444874; cv=none; b=B8YYuUIfznMHO7fuELZoMbU2+megX0Qg5qyPjMVMEG5EAR2fXI4OjjRlO6G/5/FLxsDqsz4HcplVUBO/ihv0p46hykKoq2ux8aBSLVIib7AiBj5oVJFibE2NZSHC42RfCA8VAZ0jAJbhJ/FN7F6Xiv7bL3ApbFIXn7D2W6inalg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705444874; c=relaxed/simple; bh=crRkzrseVP9YPMxkcPGvSv5ziYVUbab0uAzK43mUOHc=; h=Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=jeY65XovLFzaYDPlbSR6gTNCDpIMVhRlMWHVzvNxatuoDfjEiV4ta/RBZAtnHaB9xs3EoBAMsqTa7rYPm6YObUNwNh6sH5PJn8xeanvgdDseKGGC6NVA6luL6KSxmW+5N+AQGST4ESy4QlvR5sX80tkM/xOrWlTQiERu7FatZSM= 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 6E2E6140346; Tue, 16 Jan 2024 23:41:09 +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=20=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] usb: ucsi: Add missing ppm_lock Date: Tue, 16 Jan 2024 23:40:39 +0100 Message-Id: <20240116224041.220740-2-lk@c--e.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240116224041.220740-1-lk@c--e.de> References: <20240116224041.220740-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-Transfer-Encoding: 8bit Calling ->sync_write must be done while holding the PPM lock as the mailbox logic does not support concurrent commands. Thus protect the only call to ucsi_acknowledge_connector_change with the PPM lock as it calls ->sync_write. All other calls to ->sync_write already happen under the PPM lock. Signed-off-by: Christian A. Ehrhardt --- NOTE: This is not a theoretical issue. I've seen problems resulting from the missing lock on real hardware. drivers/usb/typec/ucsi/ucsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 61b64558f96c..8f9dff993b3d 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -935,7 +935,9 @@ static void ucsi_handle_connector_change(struct work_struct *work) clear_bit(EVENT_PENDING, &con->ucsi->flags); + mutex_lock(&ucsi->ppm_lock); ret = ucsi_acknowledge_connector_change(ucsi); + mutex_unlock(&ucsi->ppm_lock); if (ret) dev_err(ucsi->dev, "%s: ACK failed (%d)", __func__, ret); -- 2.40.1