Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6391874pxb; Mon, 8 Nov 2021 07:54:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP2zmSingNDNV38CgSfOzyJlYEEt6c4Gmawc0n+Pn0Tj9zeQQJsiUi92fp01PouGM5NwD9 X-Received: by 2002:a92:ca05:: with SMTP id j5mr37219ils.262.1636386861553; Mon, 08 Nov 2021 07:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636386861; cv=none; d=google.com; s=arc-20160816; b=wYhLdtdyfdRw5PFi3D7rsVBMaFxWlm7j/O9TWZVFCLCW1omhAc9c2sFXaQzS7s1xLc 3qZhFv9x45TUrcsDKiovTye+zqyeH/QlyOaYqaTXqZTsGEfq4FDAptRZgHGc/sB3KiCS rfjf/yCRNBRszh65H2rQ7NbUJsZfLm0kt/aQYk46ArmbCeZSeJHSW3Vl0VJiNG17BiJ+ j7Bx1AgUWlBwM2RoSCt1EPh5sXtnqP3/NmnaEMvztbIbl0G+f5EYtSJ+igghRy9JNzXC sJaBxoiXPzetK8wle8qn/lTeyg4nGEEzVk5Xtsxy3WLvZDKOVKTdHLZ8a/8D38eULvGx eRVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=d9STRiI6KucgPVBhAUB/ZaQYLqQS9QZpyJnKok3uPOc=; b=wgws0COfGrXw/SOQqNbnyybNFz1AqLbV4MAvG9qk1L4MjgB/15NQL8sR+bXaymBtOt vg6IxQriNjwjn5UtkycFJB2S6KBl3N53H8UYyYEWGO6IABDga2sYoTZ0Nsa7wDLW0ZP0 CvVnhNddZ6+ZRsu/cnRS838wIvRIptZCrmv8ht/sM7nWocX4jIhIlwHIFBkf5/ZmpgW4 Takbho2BGpJOHksB0T/nHmhwCPqf+wLnMExEjcR9flzsyDiLttAJ8Ac1nbaLxplU+WbO BZi2VAkrKTCRk3d9iksJGlfr4Z37z0rtSVWOqu+DXxyn6Rkgaqa0dPXPK5FRxxd3ZK52 zwjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X2yXPhO8; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si21247280jaa.55.2021.11.08.07.54.04; Mon, 08 Nov 2021 07:54:21 -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=@redhat.com header.s=mimecast20190719 header.b=X2yXPhO8; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239229AbhKHL1j (ORCPT + 99 others); Mon, 8 Nov 2021 06:27:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31241 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239220AbhKHL1j (ORCPT ); Mon, 8 Nov 2021 06:27:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636370694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d9STRiI6KucgPVBhAUB/ZaQYLqQS9QZpyJnKok3uPOc=; b=X2yXPhO8A4E0Axa8oxiLD2GD3MQlmvUL0CDD0R6ktaDSNMCWlJadYXfii9MUWYRouzNBSn TyrUyfft/watIqE2MdtFsky3EPD6MV50GvlofHaWxuVly8boQ1d1ZGRIhf9cOC8q+Irrk2 3eJqULniYifRr8KfPKehacah1ABiXK4= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-nXh_RO-sPpO8iwrT8Vzjzw-1; Mon, 08 Nov 2021 06:24:53 -0500 X-MC-Unique: nXh_RO-sPpO8iwrT8Vzjzw-1 Received: by mail-ed1-f71.google.com with SMTP id f20-20020a0564021e9400b003e2ad3eae74so14580774edf.5 for ; Mon, 08 Nov 2021 03:24:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=d9STRiI6KucgPVBhAUB/ZaQYLqQS9QZpyJnKok3uPOc=; b=q0hNm9ZyX3dUwbBqprGw0NrmGBTcKZChpUb6DS9Q3OM4Hf994pBHNQMWUYRaTZfLSV qt3fS1xyyfZZbkL5B0JX7mS+GvX3MvFsa+xf6CkAUSxmN8KxzzKW+rFIKvwzvOEHvqpz xQv2VjwxEkJ3U6x0w7nd3kx36o5MQOQVH0X2PKjwl6AmkCBjZ4yw1Ky8EL6MukVWZc3p SelNCAoLaLur+LWYfr38l4sAiTXR0pdmTlvrlMvSqBDZak/jQUnTOkmYT8t8iYvImZeF QSAT/at76YpOrOFOnVAJ0fdwo7cKg6af6vuJRdJF5KuKgs//2ED53pd81mVD5uX0oKPL oqEA== X-Gm-Message-State: AOAM532DAEC/canBlTpu0aB89RfanoIkS86oVA3mT/oKGWk9DZ4px690 MgfZ2iohX85GsMCi2jTCV7mBX01LjDxNK8cWBXmtBN7gkqcM0DejG9wPzvcUK/Mhn281Lcp4+FF YpMLbJyKPqM9gI5nJ7mudHWXR X-Received: by 2002:a17:907:7f18:: with SMTP id qf24mr55204558ejc.568.1636370692015; Mon, 08 Nov 2021 03:24:52 -0800 (PST) X-Received: by 2002:a17:907:7f18:: with SMTP id qf24mr55204542ejc.568.1636370691856; Mon, 08 Nov 2021 03:24:51 -0800 (PST) Received: from [10.40.1.223] ([81.30.35.201]) by smtp.gmail.com with ESMTPSA id k23sm9106957edv.22.2021.11.08.03.24.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 03:24:51 -0800 (PST) Message-ID: <3e646803-346c-8650-d407-21af3f017366@redhat.com> Date: Mon, 8 Nov 2021 12:24:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2] usb: typec: fusb302: Fix masking of comparator and bc_lvl interrupts Content-Language: en-US To: Ondrej Jirman , Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Badhri Jagan Sridharan , "open list:USB TYPEC PORT CONTROLLER DRIVERS" , open list References: <20211108102833.2793803-1-megous@megous.com> From: Hans de Goede In-Reply-To: <20211108102833.2793803-1-megous@megous.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11/8/21 11:28, Ondrej Jirman wrote: > 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 Thanks, patch looks good to me: Reviewed-by: Hans de Goede Regards, Hans > --- > 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; FWIW this is not necessary because the fusb302_set_toggling(chip, TOGGLING_MODE_OFF) already does this, but it makes the code more clear, so lets keep it. > 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; Idem. > break; > default: > break; > Regards, Hans