Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp609899rdb; Thu, 19 Oct 2023 13:46:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx2C2Qbtnjuu7UvQYAFguE2qTG3ikI77oWHE60w0vK3ddAt4/TNITzYwSpjNN+81VJclJ0 X-Received: by 2002:a05:6a20:7da2:b0:15d:684d:f514 with SMTP id v34-20020a056a207da200b0015d684df514mr3407641pzj.6.1697748364897; Thu, 19 Oct 2023 13:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697748364; cv=none; d=google.com; s=arc-20160816; b=wNUg5zjuLDP3gVmTG9nNOZM7qbkEykXN3V6W3NfTq4gNKQikJqOhuKyYpkJAmApE9D LU1ZyviNA9mvVBmVGeH3FJ7ns+TFqqHep0Mz3BTsYe7Vw751yXlhSNh47ZVye0Zj9BZQ V5ByhQKgDWeWClV4Gzn9DEjE+5dtZV3IyNUDAdKt30PHoU+0YyAqtCYtLDXecnbLtKoK CnT3PBpuXO8jo6EoQ1DEEbV/FzAQYJvwWeQVChgXWsIW/etQTR6XtlQnHMkW9NPvrZcn QmQWLxhDQGVhS2RACZ2IJxVo20kN9iHIC1MpVMaT0vJ8juT14rvj8jNOxNH/mkV6YzvR PPFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=VVuCB44VLEjsZzvUgM1w7n2lvEI4MsHtEyH+2GVq2dY=; fh=7d7qEuVwp4xWPyV4v7fQ03SFQXayXePBDTBTkZLLl+Q=; b=uzjBXggDJFzq5+5oGhoeucyqvku8HCa+/NuWLd1sgG20yRpFTddH20lEX0vC6VR5sQ RavupLVbVONqMFpMjcXMXFcPhFbnxLekzzpVokB+pkT95jFzuJ0vANpEdZesrbho2TQl e2ghYxq15SpPpZTyl4jUzEW8JTII0sMRik64EJsaXFIVYgrRqbbXlNt7LJMLYFFs6SbF ihmIYU9FmqIw3zj93k9sXOjVLuhGfZ3z8d7//OaRX9qKH+SeV9GuxYigkacYqnnjcO5+ Mzi/n7raNyScZinTXnmfLUtA3eTvI5A03xgDfFwEZwhf6qaHR3o11RL/pjX2tOyOFljm 5mNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EulO5Oy4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f24-20020a637558000000b00578c9144910si387136pgn.410.2023.10.19.13.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 13:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EulO5Oy4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 11C0180AD24A; Thu, 19 Oct 2023 13:45:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346562AbjJSUpR (ORCPT + 99 others); Thu, 19 Oct 2023 16:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346397AbjJSUpP (ORCPT ); Thu, 19 Oct 2023 16:45:15 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17EF8124 for ; Thu, 19 Oct 2023 13:45:13 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-51e24210395so4284a12.0 for ; Thu, 19 Oct 2023 13:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697748311; x=1698353111; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VVuCB44VLEjsZzvUgM1w7n2lvEI4MsHtEyH+2GVq2dY=; b=EulO5Oy4vXgxAA88b1og3ur2Akh0sYSkPVfIpxvdGm4MMF93ZCwC1lj2M+zZLqG6eQ A2Pyy0EJ4bXkkrdo7FlBfFVZtAmXDPTVpWgs4MiadRD84rCsdV957TmoxHIs8fAh5OJR LWH+O7bqv3+BZ1CoAaTo7px+dZp2vRpOeiIoL5aSkVby89PJtAhnMCGpk9XMaHLfBIms vaynbKJref+ZTPRmPnc+Wwjun2M1X65PfBJ5TVBm2ZAJOmc1H34QGZIw5Zo2QtFK0zqL CK5pv1cXTUAZOIMeusY13UWvRnqzJaIS6rYMBqCJ7baIWJZlslahMbQxMbWwG3hfByDB F+jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697748311; x=1698353111; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VVuCB44VLEjsZzvUgM1w7n2lvEI4MsHtEyH+2GVq2dY=; b=V6XlJhOfgLZi6uDHFtUP7hPECkSA5si08lWqonfwg9qn0kX5RHquGq3LEteejvGISk IeVfpa5x4kgK1bXNsWkM9xDlWa1yu1XH8P/mKK88iFVyV6Fg28odg+BZUg8GV/5YOzYM t5NfxPLHyKayKGdPqxr3T+Wr7cjdoqUVAKuc5eVJ4omz209PPPK8S0ezc31MdI3Y0NHZ q7+JSztfQLp4Gav/kIHk/wtdPi7KHFxRmeKcEXkjOIA+w4l+FhxR/kjCeg2xX8wIWWXX 4/taaGglfwj3YKP8G8I480tACLO3YaB4mMiJkEzeKXisvY8aYGGXq7wkVCJoK6m/kivT m38w== X-Gm-Message-State: AOJu0Yx8zEBwEt3BD/Sus/pGPQcpTTRiqGXs4lk/QivEm+ldwGRXssBX e4v+T8E9mPNhzWvnEKtcHRHKC6MQVLadWzCTdNZyoQ== X-Received: by 2002:a50:9f41:0:b0:53f:91cb:6904 with SMTP id b59-20020a509f41000000b0053f91cb6904mr27602edf.4.1697748310674; Thu, 19 Oct 2023 13:45:10 -0700 (PDT) MIME-Version: 1.0 References: <20231016232816.3355132-2-rdbabiera@google.com> In-Reply-To: From: RD Babiera Date: Thu, 19 Oct 2023 13:44:59 -0700 Message-ID: Subject: Re: [PATCH v1] usb: typec: tcpm: only discover modes the port supports svids for To: Heikki Krogerus Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, badhri@google.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 13:45:27 -0700 (PDT) Hi Heikki, On Thu, Oct 19, 2023 at 1:09=E2=80=AFAM Heikki Krogerus wrote: > I'm confused here. Is the device here the port or partner (or both)? The port, I'll make sure to be more precise when describing. > Why are you skipping the first SVID? Skipping to the first SVID supported by the port when preparing the first Discover Modes message. > Please note that the Type-C specification puts priority on TBT over DP. > Is this in conflict with that? Not in this case. Assuming the port supports both TBT and DP, a Discover Modes message will be sent to both regardless of what order they return in the Discover SVIDs ACK message. > > Fixes: f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)") > > I think that's wrong commit (perhaps you want 8afe9a3548f9d instead?). 8afe9a3548f9d looks to be more concerned with the consumption and processing of the received payload, I had put f0690a25a140 because it contained the logic to determine if the Discover Mode message was being sent at all as well as preparing the response. 5e1d4c49fbc86 does touch the response formation but only the svdm_version and not the SVID. > Right now I'm not convinced that this should be considered as a fix at > all. I don't know anything about the test you are talking about, but > if this patch is just about making it pass, then there is something > seriously wrong. I use the VESA DisplayPort Alt Mode on USB Type-C CTS as a reference. In regards to this being a fix, if this ends up being more optional (discus= sed below), then I'll remove the fix tag. > If you need the modes to be discovered in some specific order, then we > need the framework to allow you to do that. So perhaps the tcpci > drivers should be able to supply the preferred order to the tcpm? > > But as such, unless I'm mistaken, this patch will change the logic so > that only the partner alt modes that the port supports get registered, > and that way are exposed to the user. You can't do that - right now > it's the only way we can inform the user about them. All partner > alternate modes (at least the SVIDs) must be exposed to the user one > way or the other, regardless does the port support them or not. The test this patch tries to fix could just be written without consideratio= n of this. My guess is that the test was designed such that the SVIDs before the DisplayPort SVID are unknown to the port under test so the mentality could have been "why should a port care about SVIDs it doesn't know about?" A defense I could make for it is that the USB PD CTS doesn't test to see if a port under test sends Discover Modes for every SVID returned in a Discover SVIDs ACK, so the interpretation isn't invalid. I've seen oth= er tcpm implementations handle Discover Modes this way as well. Regardless, you're definitely right that the user should know about all Alt Modes/SVIDs - the port would lose SVID information without registering a partner altmode for it. Currently I think the approaches to p= ass this test look like: 1. Your suggestion - let the tcpci decide if there should be a discovery order. Alternatively, let the tcpci decide if it wants to opt into this patch's behavior of only discovering modes for known SVIDs - a strict discovery flag. 2. Send a Discover Mode message to known SVIDs first in the order they come in, and then to unknown SVIDs. The test passes and no information is lost, but it's unnecessary refactoring just to pass one test for one Alt Mode. 3. Don't send a Discover Mode message to unknown SVIDs, but do register an Alt Mode with blank info for that SVID. It passes the test without havin= g to do any reordering compared to the first option and it preserves supported SVIDs. But, the port would lose information such as each SVID's Alt Modes VDO plus each SVID can support more than one Alt Mode. Let me know if any of these approaches sound worth pursuing; I do think Option 1 does make more sense than the others. --- Thanks for the feedback, RD