lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220823170949.2066916-1-rajat.khandelwal@intel.corp-partner.google.com>
Date:   Tue, 23 Aug 2022 22:39:49 +0530
From:   Rajat Khandelwal <rajat.khandelwal@...el.corp-partner.google.com>
To:     heikki.krogerus@...ux.intel.com, gregkh@...uxfoundation.org
Cc:     rajat.khandelwal@...el.com, shawn.c.lee@...el.com,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] Enter safe mode only when pins need to be reconfigured

From: Lee Shawn C <shawn.c.lee@...el.com>

There is no point to enter safe mode during DP/TBT configuration
if the DP/TBT was already configured in mux. This is because safe
mode is only applicable when there is a need to reconfigure the
pins in order to avoid damage within/to port partner.

1. if HPD interrupt arrives and DP mode was already configured,
safe mode is entered again which is not desired.
2. in chrome systems, IOM/mux is already configured before OS
comes up. Thus, when driver is probed, it blindly enters safe
mode due to PD negotiations but only after gfx driver lowers
dp_phy_ownership, will the IOM complete safe mode and send
ack to PMC.
Since, that never happens, we see IPC timeout.

Hence, allow safe mode only when pin reconfiguration is not
required, which makes sense.

Signed-off-by: Rajat Khandelwal <rajat.khandelwal@...el.com>
Signed-off-by: Lee Shawn C <shawn.c.lee@...el.com>

---
 drivers/usb/typec/mux/intel_pmc_mux.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index d238913e996a..4bf84466d1ff 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -432,6 +432,25 @@ static int pmc_usb_connect(struct pmc_usb_port *port, enum usb_role role)
 	return pmc_usb_command(port, msg, sizeof(msg));
 }
 
+static bool
+pmc_usb_mux_allow_to_enter_safe_mode(struct pmc_usb_port *port,
+				      struct typec_mux_state *state)
+{
+	if ((IOM_PORT_ACTIVITY_IS(port->iom_status, DP) ||
+	     IOM_PORT_ACTIVITY_IS(port->iom_status, DP_MFD)) &&
+	     state->alt &&
+	     state->alt->svid == USB_TYPEC_DP_SID)
+		return false;
+
+	if ((IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
+	     IOM_PORT_ACTIVITY_IS(port->iom_status, ALT_MODE_TBT_USB)) &&
+	     state->alt &&
+	     state->alt->svid == USB_TYPEC_TBT_SID)
+		return false;
+
+	return true;
+}
+
 static int
 pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
 {
@@ -442,8 +461,13 @@ pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
 	if (port->orientation == TYPEC_ORIENTATION_NONE || port->role == USB_ROLE_NONE)
 		return 0;
 
-	if (state->mode == TYPEC_STATE_SAFE)
+	if (state->mode == TYPEC_STATE_SAFE) {
+		if (!pmc_usb_mux_allow_to_enter_safe_mode(port, state))
+			return 0;
+
 		return pmc_usb_mux_safe_state(port);
+	}
+
 	if (state->mode == TYPEC_STATE_USB)
 		return pmc_usb_connect(port, port->role);
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ