Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6346447pxb; Mon, 8 Nov 2021 07:10:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlklKHHg6BHVsMJ2KtT/19JKrsA11wd7Q+mgZIRsU2cuYRbRhldEuEN3Miae5JAYR6ZhiK X-Received: by 2002:a17:906:1f0d:: with SMTP id w13mr571880ejj.161.1636384224576; Mon, 08 Nov 2021 07:10:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636384224; cv=none; d=google.com; s=arc-20160816; b=wEW/Q/u+/bqoYQyhhwGjqJNLgOamPsRd+75/7NFwm+1gZ9RuKcv0Drp+9lZIiVh2jY hZiuKNfgYcEtBvCkfCIMTsg+HW2kS+Jh46Gm2seDSyjRW5iGRRGXWNS619voeoHHDmXk tVLPitPRSd0vIoAF/bghS5OwkjzJvr3Ets04ApDjWFbh8Q/nMR4NJvRW+/FQ71uMNrJo bNEw30hfLATqkyFBvjwRhSmj+M+DZPzgF3RYcjNjrA1etUtGj3YE+AbQyTXI+GAmdisV razNNtPCUagtpsQ5CKFljo5z+K1qZkF+T5KvikWor8TZXBL8l0t9Q7Qh6A1E/OfSzrDI sRAg== 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:to:from:dkim-signature; bh=Ur8TtN1oFJGoyp/41LGfz3bWa0XS8ZBUdFQ9qkNzpCA=; b=tqoW3L4Eje1SoE7c/u/qE7OrrRVQCIzxy0Kcx/II/ioJK1M58syXV14rnOe1Pk2gCb QC5Mc88hYOCQb6d51TbE2C5GEjkL8YM9VyEDZbPJ+m9tvK5GK5WwB/xG+FQWBe7O6Wli rBTR1M/+Se8esyc0tE+pNbfJZq1lmIEXGBX6ahxSCC3+S95S8jbb+mmQJsNXvgOqxGfe EWW96lEApCL/KsrmQ/KqIPxOszdErWI3x5ibEiU1L9Zbniu1KwPU7zhyoHNwBsJTzR+V w2Amg6Sje9pOq6IVRvUmVQcJzfuAPAEEVkynTGD7S4DH64bqHw+SAXqj5RVp+RKxTUh+ pXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=if3XFMIA; 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=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si24792952ejd.91.2021.11.08.07.09.55; Mon, 08 Nov 2021 07:10:24 -0800 (PST) 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=@megous.com header.s=mail header.b=if3XFMIA; 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=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237883AbhKHKbb (ORCPT + 99 others); Mon, 8 Nov 2021 05:31:31 -0500 Received: from vps.xff.cz ([195.181.215.36]:41358 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237791AbhKHKb3 (ORCPT ); Mon, 8 Nov 2021 05:31:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1636367321; bh=HRSQ+/1rPbZP9SjFY8jo2peIysEbpfJpy6m4H91Z50Y=; h=From:To:Subject:Date:From; b=if3XFMIAs+VZxmHa71B3VJCRes0xFAqw9J8Fkyoi6Oj24rEtoO6K/J5cwEPp+AHsZ BExhWmf7aPRA6gbL52L/x/2Jbij6GDV+9MRfqWxwfYJBNaXtJ1LVjmPgCn4OZPR2dH YT/8EDgIarsZ/0tzIEjQxkn7eD2g96wmlkYOk9F4= From: Ondrej Jirman To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Ondrej Jirman , Badhri Jagan Sridharan , Hans de Goede , linux-usb@vger.kernel.org (open list:USB TYPEC PORT CONTROLLER DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] usb: typec: fusb302: Fix masking of comparator and bc_lvl interrupts Date: Mon, 8 Nov 2021 11:28:32 +0100 Message-Id: <20211108102833.2793803-1-megous@megous.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code that enables either BC_LVL or COMP_CHNG interrupt in tcpm_set_cc wrongly assumes that the interrupt is unmasked by writing 1 to the apropriate bit in the mask register. In fact, interrupts are enabled when the mask is 0, so the tcpm_set_cc enables interrupt for COMP_CHNG when it expects BC_LVL interrupt to be enabled. This causes inability of the driver to recognize cable unplug events in host mode (unplug is recognized only via a COMP_CHNG interrupt). In device mode this bug was masked by simultaneous triggering of the VBUS change interrupt, because of loss of VBUS when the port peer is providing power. Fixes: 48242e30532b ("usb: typec: fusb302: Revert "Resolve fixed power role contract setup"") Signed-off-by: Ondrej Jirman Cc: Hans de Goede --- drivers/usb/typec/tcpm/fusb302.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 7a2a17866a823..72f9001b07921 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -669,25 +669,27 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) ret = fusb302_i2c_mask_write(chip, FUSB_REG_MASK, FUSB_REG_MASK_BC_LVL | FUSB_REG_MASK_COMP_CHNG, - FUSB_REG_MASK_COMP_CHNG); + FUSB_REG_MASK_BC_LVL); if (ret < 0) { fusb302_log(chip, "cannot set SRC interrupt, ret=%d", ret); goto done; } chip->intr_comp_chng = true; + chip->intr_bc_lvl = false; break; case TYPEC_CC_RD: ret = fusb302_i2c_mask_write(chip, FUSB_REG_MASK, FUSB_REG_MASK_BC_LVL | FUSB_REG_MASK_COMP_CHNG, - FUSB_REG_MASK_BC_LVL); + FUSB_REG_MASK_COMP_CHNG); if (ret < 0) { fusb302_log(chip, "cannot set SRC interrupt, ret=%d", ret); goto done; } chip->intr_bc_lvl = true; + chip->intr_comp_chng = false; break; default: break; -- 2.33.1