From patchwork Tue Nov 16 01:39:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1555587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=jKkbTKHm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtTJn6FpVz9sX3 for ; Tue, 16 Nov 2021 12:40:09 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mmnS4-00008a-7a; Tue, 16 Nov 2021 01:40:00 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mmnS1-00005T-Qm for kernel-team@lists.ubuntu.com; Tue, 16 Nov 2021 01:39:57 +0000 Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id A461741DEC for ; Tue, 16 Nov 2021 01:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1637026797; bh=/7bDHUxk8g9o0LisWCGBGnXDI2tn28UvsA8MsOFfXN4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jKkbTKHmGAYSEPZGF4EJ5dNBF5wMMSmA8n4zYx9/8fg8CoUbkvp8J1++20bc9cU61 dNH/PPU+DpDihGm2dAPHHa/D4wDUXGOjHQXvppoxA+Zd66tJQbOCy+LaMO9cQ55x1d yGpuZe/hTkbUMKn1Cnu/8e4eUqTQn3+CzRyzI2vO6F78f58h5Y+2uMGs6T4NJjQE5s LboTuX0oPAKJ9hW/bQksyoY8yOE0FT6HXW4c4H7f3xShRr7CQ8tx2kFsaUEdrfYeRV Oz0UHG58b5x6r2c75KQWOthd6bA4qty/8pX+tqeo/7lLATaxPXkWAl3Mie50pS9hMv Uo3XcWO6RMU4A== From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [Unstable/OEM-5.14] [PATCH 5/7] usb: typec: ucsi: Check the partner alt modes always if there is PD contract Date: Tue, 16 Nov 2021 09:39:03 +0800 Message-Id: <20211116013905.313937-6-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211116013905.313937-1-kai.heng.feng@canonical.com> References: <20211116013905.313937-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Heikki Krogerus BugLink: https://bugs.launchpad.net/bugs/1950974 UCSI does not tell the driver explicitly when the firmware (PPM in UCSI lingo) has actually detected the partner alternate modes, there is no specific change event for that. That's why they have to be checked with any notification that informs that PD contract with that partner has been achieved. Previously the alternate modes were checked always when the firmware (PPM) informed that something with the partner had changed, but on some platforms the EC firmware does not generate separate events for generic partner changes at all. On those platforms the EC firmware notifies the driver only about connections, or separately about the PD contract if it was not achieved soon enough after the initial connection event. Signed-off-by: Heikki Krogerus Link: https://lore.kernel.org/r/20210920142419.54493-6-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 6cbe4b2d5a3f290fba764e722b19cb55968a84d2) Signed-off-by: Kai-Heng Feng --- drivers/usb/typec/ucsi/ucsi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 8af292141fe7b..188181737acf0 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -627,6 +627,7 @@ static void ucsi_pwr_opmode_change(struct ucsi_connector *con) con->rdo = con->status.request_data_obj; typec_set_pwr_opmode(con->port, TYPEC_PWR_MODE_PD); ucsi_get_src_pdos(con, 1); + ucsi_partner_task(con, ucsi_check_altmodes, 30, 0); break; case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5: con->rdo = 0; @@ -726,8 +727,6 @@ static void ucsi_partner_change(struct ucsi_connector *con) if (ret) dev_err(con->ucsi->dev, "con:%d: failed to set usb role:%d\n", con->num, u_role); - - ucsi_partner_task(con, ucsi_check_altmodes, 30, 0); } static void ucsi_handle_connector_change(struct work_struct *work) @@ -878,10 +877,15 @@ static void ucsi_handle_connector_change(struct work_struct *work) break; } - if (con->status.flags & UCSI_CONSTAT_CONNECTED) + if (con->status.flags & UCSI_CONSTAT_CONNECTED) { ucsi_register_partner(con); - else + + if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == + UCSI_CONSTAT_PWR_OPMODE_PD) + ucsi_partner_task(con, ucsi_check_altmodes, 30, 0); + } else { ucsi_unregister_partner(con); + } ucsi_port_psy_changed(con); @@ -1244,7 +1248,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) ret = 0; } - if (con->partner) + if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD) ucsi_check_altmodes(con); trace_ucsi_register_port(con->num, &con->status);