Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1675086pxj; Wed, 19 May 2021 11:11:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjc4v4XHsYEviIim2o0YNxzxWnHtonoZ3emIXnuWjDUo6aqMJmbBW3IVzjoYwaFGfe+BZi X-Received: by 2002:a05:6638:4f:: with SMTP id a15mr226172jap.134.1621447888017; Wed, 19 May 2021 11:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621447888; cv=none; d=google.com; s=arc-20160816; b=W8RWxxQpToV8ejbl3K2w28NiDJyVzA+vCkTUbVZZDaWVSPHjwnA+jrVjk32hspqsTw JR/QCCCCC57pEk55RsKLS4+bKTnPph1swidD4+K8gh1ZRqH/8mlPWSfVItSPuPiGpsor 7CrlETRErhtGjqcX+rqkhSntOtApcKsqCsGI61jJUz7cWeofElH3w2W40C2wXfvoPpdP VrJbtF+OLChxqCebjSF4ZItSTvxm81i25MN91dh+1eMfvSTxY9BAAxIOEa/ScdnYLhM4 DzIpG6Nj92TiNqTGaA1tRWNnC0sNwyI+pD3t1hrKcTh534C/EEhYZuIhtwWKO2QUTik5 c5IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=Y0bWdcnKt76oMiZyAq2ositLxrsW+Fmxc0WAeea8Xw0=; b=tYp9a22HNzzCnQF/JuuExpQgu5Dh0RGPWTjcEY3aFpSBmIjX/PccFcjl2pVIJCvs1f FfrquEv6XY85VkadehRHNxVJwQix9khrLITWuv8hfYMK3tnl1ne3XUzc1UQkdczNa1c7 q/hc3KQi0l2R6AYMlIVwDZp5xnkROqHXrAspIImAF/rbEnw7LHFVyXl0xBRXNPxdFzYC Ph2lPrjAt8KyjbdIflfbOgY0P4WjFR+J5PtHA+mUAJJBy+Lvk7B8AUiDIksi64h6O8QC uOAxnl4L4jhHYYAWQUnpSaoNXnnk4Z5DAt0MJXm1TKuuffbnPur1B09bm0vZ46mOGxuQ 8yGg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si28200832ioy.69.2021.05.19.11.11.15; Wed, 19 May 2021 11:11:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349617AbhERNa5 (ORCPT + 99 others); Tue, 18 May 2021 09:30:57 -0400 Received: from mga18.intel.com ([134.134.136.126]:58079 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245242AbhERNa4 (ORCPT ); Tue, 18 May 2021 09:30:56 -0400 IronPort-SDR: mPWJg2rYG53a6F+2A1sAmuGaLSQc1RcmotBcy/60KUYxG0C0ogFRVQ+QINN/Eqj1bl/b84UgjN 0RDCJwmtgYIA== X-IronPort-AV: E=McAfee;i="6200,9189,9987"; a="188120824" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="188120824" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 06:29:37 -0700 IronPort-SDR: u33XeXgwcBSspCFgCb9VQsgkLoJs5iposoeyDXK6WNqlnw8S9HnlCdaG1KfmLpC5uOvv4A0i5c gKAKZc7vYE/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="541972367" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 18 May 2021 06:29:34 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 18 May 2021 16:29:34 +0300 Date: Tue, 18 May 2021 16:29:34 +0300 From: Heikki Krogerus To: Benjamin Berg Cc: Bjorn Andersson , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: ucsi: Clear pending after acking connector change Message-ID: References: <20210516040953.622409-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 02:57:28PM +0200, Benjamin Berg wrote: > Hi Heikki, > > > On Mon, 2021-05-17 at 15:15 +0300, Heikki Krogerus wrote: > > On Mon, May 17, 2021 at 01:03:12PM +0300, Heikki Krogerus wrote: > > > On Sat, May 15, 2021 at 09:09:53PM -0700, Bjorn Andersson wrote: > > > > 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 > > > > > > I'm OK with this if Bejamin does not see any problems with it. I'll > > > wait for his comments before giving my reviewed-by tag. > > > > > > That workaround (commit 217504a05532) is unfortunately too fragile. > > > I'm going to now separate the processing of the connector state from > > > the event handler (interrupt handler). That way we should be fairly > > > sure we don't loose any of the connector states even if an event is > > > generated while we are still in the middle of processing the previous > > > one(s), and at the same time be sure that we also don't confuse the > > > firmware. > > > > > > So the event handler shall after that only read the connector status, > > > schedule the unique job where it's processed and ACK the event. > > > Nothing else. > > > > Seems to be straightforward to implement. I'm attaching the patch I > > made for that. I think it should actually also remove the problem you > > are seeing. Can you test it? > > Hmm, I am happy to try the patch tomorrow in the scenario where I > observed my race condition. > > Unfortunately, I don't feel it'll work. The problem that I was seeing > looked like a race condition in the PPM itself, where the window is the > time between the UCSI_GET_CONNECTOR_STATUS command and the subsequent > ACK. > For such a firmware level bug in the PPM, we need a way to detect the > race condition when it happens (or get a fix for the firmware). OK. Let me know does the patch bring the issue back for you. > Note that there was also some code to always sent a > UCSI_GET_CAM_SUPPORTED command "to ensure the PPM does not get stuck in > case it assumes we do". I have no idea where this came from or what > PPMs might require this workaround. But I doubt it is a good idea to > drop it. Sure. thanks, -- heikki