From patchwork Fri Oct 9 14:40:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 11826159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18AC814D5 for ; Fri, 9 Oct 2020 14:41:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07E0B222C2 for ; Fri, 9 Oct 2020 14:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388891AbgJIOlF (ORCPT ); Fri, 9 Oct 2020 10:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388691AbgJIOlE (ORCPT ); Fri, 9 Oct 2020 10:41:04 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A068C0613D2; Fri, 9 Oct 2020 07:41:04 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kQtZr-002KHD-Q5; Fri, 09 Oct 2020 16:41:00 +0200 From: Benjamin Berg To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Guenter Roeck , linux-kernel@vger.kernel.org, Benjamin Berg , Hans de Goede , Heikki Krogerus Subject: [PATCH 0/2] UCSI race condition resulting in wrong port state Date: Fri, 9 Oct 2020 16:40:45 +0200 Message-Id: <20201009144047.505957-1-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Benjamin Berg Hi all, so, I kept running in an issue where the UCSI port information was saying that power was being delivered (online: 1), while no cable was attached. The core of the problem is that there are scenarios where UCSI change notifications are lost. This happens because querying the changes that happened is done using the GET_CONNECTOR_STATUS command while clearing the bitfield happens from the separate ACK command. Any change in between will be lost. Note that the problem may be almost invisible in the UI as e.g. GNOME will still show the battery as discharging. But some policies like automatic suspend may be applied incorrectly. Cc: Hans de Goede Cc: Heikki Krogerus Benjamin Berg (2): usb: typec: ucsi: acpi: Always decode connector change information usb: typec: ucsi: Work around PPM losing change information drivers/usb/typec/ucsi/ucsi.c | 125 ++++++++++++++++++++++++----- drivers/usb/typec/ucsi/ucsi.h | 2 + drivers/usb/typec/ucsi/ucsi_acpi.c | 5 +- 3 files changed, 110 insertions(+), 22 deletions(-) Acked-by: Heikki Krogerus