Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1753007pxj; Sun, 16 May 2021 03:08:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGV13QTHek4cts0aeFIb7uc/23fCWXrermnY/b1s4MMD7coFnTOmVL71PMArHHZiQkneVR X-Received: by 2002:aa7:c150:: with SMTP id r16mr64210358edp.82.1621159717492; Sun, 16 May 2021 03:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621159717; cv=none; d=google.com; s=arc-20160816; b=a9ToYGqmS3Yzy/5nfD/QV1pOVIisb9Vkw0tErbw7GR/qC7Y1JDxmzD4sPeGUifqSh1 qU8RSQRi8l8OEGWRSCB9VWYDq/cXTCkvvip1NuYrAeuVSI+KJLyfJ1DcuhI5bCHh3dbN cv2+vaPXE5u04SJCgvAUh9QJE8qx5xJeh5hc/hzuJmH1XK8WVOw7D5pusyqv39VUaQAe JTTw8MjFISE8KQsHIhep547KJ2qo9Yk5p93zWR9zTS3BfbX5USXm7lrww78pSiXPwTJv 7Y93cAKqL62GZUSB1hWJRBNhPEhxRKKDCN2MbazvBgFdtSNCImV9o24WolBsxvKFawb2 6fOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=p+n8knY1AhNlxa/4+sSt2iV2/z4kOsoddvvQNZinhOI=; b=iBMo/8UWczwgq3d+0HQNeeV78cAIoX/gomS8PEDmKi/E68OZsNghkuzlUiQqwbSlaS rU+riiEhUutyiFFfm/wvvvvy/WiE85To2rOBNJIQ9o4rRfoVQt8ufv5PRfXasxgVnMys LBaerm7SFdL640HhTKuCsRf1W9oanHN1OqJDpADxzgEfG3J+VJK1Kg6yyDuMn51e4Sfq +LQeIJYoI5UGYpTfysE5I1LeIDhsLscbtDr5jlA7r9q//BvIn2Am/xchZXzrg5m1nfYf 87hWwK5KPdFZRb8XSmqctZOC+Ykz5WzQjnQsDITjNWgLf3Lb78BCU3uFz+sVizKOhc3D K0+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIQD4Jg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si12006549edd.329.2021.05.16.03.08.13; Sun, 16 May 2021 03:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIQD4Jg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbhEPEL1 (ORCPT + 99 others); Sun, 16 May 2021 00:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbhEPEL1 (ORCPT ); Sun, 16 May 2021 00:11:27 -0400 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FEE4C06174A for ; Sat, 15 May 2021 21:10:12 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id u19-20020a0568302493b02902d61b0d29adso2776176ots.10 for ; Sat, 15 May 2021 21:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p+n8knY1AhNlxa/4+sSt2iV2/z4kOsoddvvQNZinhOI=; b=dIQD4Jg5OvVLbM85iRn9Wdb6zWoSJHOTRqfAMo16awQaPc84wIm5fJKmUMkeXyoWPC u1ZSvTuvXkR2KGo7JUt1vlxp4GAI8jhmfhVlzBYKDzujdi8XYqvs7GUPL7rHAWGLboDX WWOSm2IcE3WwKNS9Kg8qBCPxrUqu4uWTFfXApERU8Ba9Z6BN9Q6WsxMTPnxZw4RYq7X2 SBju5rpw82tNnKdPGS9EGUmi59yjTTvv+8xxpfHlXYs7uM3bwp148OobiJGIVGSsU2od 1uHzsfJRsMU1kUit2KRvozOCC9aq29AeWAbEaB5NLP7/m+jcDWF7JQ1Zch4ora2UHdLk XSdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p+n8knY1AhNlxa/4+sSt2iV2/z4kOsoddvvQNZinhOI=; b=n0ZC+tERH7InYIl5ShwvMWXvdeUUw1dqRQ7m0idBFNFc3KXXpn+IlZ8PSwGv3Oqkpx z0vQcnyl2MDWbmUgB+HUUeLOCux/l4CMqaB4IrDC9uY0TMHkh6qORbR8k4pemSPcJ9yh ByRRUSLnK6mtkVLUE1NCpFkDWChXLAMubsJvOjH9J4hNuN8fencfhRv0WiH97XDcyC3o Ew5SQ1w3YMeOJvv3WRNlhMqB04nQ7nHLpw8Wi1nNtT6VkX/n9nKZEczuEOXbXzuKt73v gOSihJFmfrVUOfbooavDU5qYF+lEuQ2ItS3ptrtARLyiQbZUSmkftUISVoy5Mh9kkYYh XcRQ== X-Gm-Message-State: AOAM532lJ4yZqONH/vMziC38yCFEyDQJqgNtM/k3G/uBw6VU0Hxgfgyf CkKGEqkZaEdySP/MO18OgW+YhKp/XoYWow== X-Received: by 2002:a9d:491:: with SMTP id 17mr45588270otm.184.1621138210984; Sat, 15 May 2021 21:10:10 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id r19sm2358369ooj.5.2021.05.15.21.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 21:10:10 -0700 (PDT) From: Bjorn Andersson To: Heikki Krogerus , Greg Kroah-Hartman , Benjamin Berg Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: typec: ucsi: Clear pending after acking connector change Date: Sat, 15 May 2021 21:09:53 -0700 Message-Id: <20210516040953.622409-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's possible that the interrupt handler for the UCSI driver signals a connector changes after the handler clears the PENDING bit, but before it has sent the acknowledge request. The result is that the handler is invoked yet again, to ack the same connector change. At least some versions of the Qualcomm UCSI firmware will not handle the second - "spurious" - acknowledgment gracefully. So make sure to not clear the pending flag until the change is acknowledged. Any connector changes coming in after the acknowledgment, that would have the pending flag incorrectly cleared, would afaict be covered by the subsequent connector status check. Fixes: 217504a05532 ("usb: typec: ucsi: Work around PPM losing change information") Signed-off-by: Bjorn Andersson --- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 282c3c825c13..f451ce0132a9 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -694,8 +694,8 @@ static void ucsi_handle_connector_change(struct work_struct *work) ucsi_send_command(con->ucsi, command, NULL, 0); /* 3. ACK connector change */ - clear_bit(EVENT_PENDING, &ucsi->flags); ret = ucsi_acknowledge_connector_change(ucsi); + clear_bit(EVENT_PENDING, &ucsi->flags); if (ret) { dev_err(ucsi->dev, "%s: ACK failed (%d)", __func__, ret); goto out_unlock; -- 2.29.2