Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5115401rwj; Tue, 20 Dec 2022 20:59:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3BYk70jzZyzSUp18iTRoB1aXfk3WDeCxmu3YFE4xJ3OsY2sCR/MvdIyrvG2XtD+EAWLyW X-Received: by 2002:a05:6402:194b:b0:45c:834b:eb44 with SMTP id f11-20020a056402194b00b0045c834beb44mr393622edz.15.1671598782591; Tue, 20 Dec 2022 20:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671598782; cv=none; d=google.com; s=arc-20160816; b=yrdqHMhT9nKfR9v3jZ90zy6uOb4Taj8IFZkY8FTUoI73ZIR8ECrrdDKg+nMKxsy/Pg bmxL86nALZZtnjkwbtoIkn5QvtPYOnjxM2AgIgqVv03ra3L/SGMTvGPJM+XLilGA1jBc e4irCW7IMPh5Je3Z9ue435q/Mla1xl1s6vxgcxMmIfBbAOgvcFLgkf5n/OS7i3tNxJIN eYGgjJsdM4aKNLUXNGJFDd4xORvAWfxXmvemXiar14yTlH7AzaBQUpy20qNJ/YC6UK5w Obz9Ms/nx0cpUbpQ6+S4SIZqbwKBJmtDN9rFitbYg5U+KR9B8uzpV1w40cuGU7AbbG98 Vv4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mzx67yLOttbqOH0rGRIjrW4YxbQAYmEJCNbwtahfAIs=; b=VgTkzbwgo+TMQDaKpSNA8aiPLUJVQ/OD+ew7Tztbrcnoh7l8UQZMdA7jmInSZPhvgt 8T1nByn9zLFlnQDcg2/Fo2NGjFPeqPABRSbXAxGkWzUsOtXTeB3bqdFzefaGJxJX+0/I 1C0/FE9tCrOBFsZ93B9o+BBQKzLvK3XFsjJtYmVMhh5HL80/0PgnDbg9kufVn9DA55XA QLcTCcaTmz1EoWFkLSSYcHl8m5lkErQ9H9QCyErWY0dbVEkU7gNqSejbHj+tpJT0bGdY NqKqLYjxqPyvSpJokKLm+82fTAsvnS2TuUclOUwePohs9k/nLjwl/oMbh494SmN9QO8q qW0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zi4+Y3LF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020aa7c1ce000000b0046a7ad0bb17si2683222edp.586.2022.12.20.20.59.26; Tue, 20 Dec 2022 20:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zi4+Y3LF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234419AbiLUELY (ORCPT + 70 others); Tue, 20 Dec 2022 23:11:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234367AbiLUELB (ORCPT ); Tue, 20 Dec 2022 23:11:01 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33C5EC75C for ; Tue, 20 Dec 2022 20:10:55 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id qk9so33972040ejc.3 for ; Tue, 20 Dec 2022 20:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mzx67yLOttbqOH0rGRIjrW4YxbQAYmEJCNbwtahfAIs=; b=Zi4+Y3LFrUE/QpUhGprR6trG1kxgqYCD+C+8VW5lmE6NfhhTaCrKaYE2DRkxvXHHYq Z3EnLxCis6VJ/TiXlflnT/8W5J64Z2PrhgVusB3wgQE/ML5H9ywJSvAqLSTj0CiUmMg5 YRa/TV1UOVkRcLnv/2nfM1SaNTBBj5CnI8C7PFZKdjqzdTm+OwGr39H2Xwsmjy8esYL4 mtbEK30/4ES1p49aYxOr4pBLp1qIcht6/RnoE49cXJRfXR9EgKV4bsNG6SBHHk9yacku X1vaZt8kIxeNAPmmXbuRfz+qzXl8jTkFVNpGdR+Drf/JGlT5kIZdCm8NvpVVom/92PeI dhIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=mzx67yLOttbqOH0rGRIjrW4YxbQAYmEJCNbwtahfAIs=; b=4bs5uXnS0CLiIKCtD753ZjjBPWh8Taz+NHg/EqR4yZ+AkfXwrKQ9Ptu5mwBVUXUtnd DogTXFCKLPp2Tm/vjCG2ytquMXLjVxdl0j1eCRU9Lc8wc+k2QMw72bPV29y+edQNtKCN IfzOX8RgmWRso2U8xrraP0qLWU6mq/lsmlx13V+UA59LOdYKLw9YxOmMJ3mOFjznhK19 CZEvEVK8UaXcTS6drqiZ1tjWrk2vxASjZ/4bzYq+8TOfQ1nE7tkq7JAcbnRnBu3RLc/u I5eqBfRwTCoijz0EY82ftfitWtP2m2xAt3isrdogduvlSD+OBS5CkNhazV/C66mz2QNt qhMA== X-Gm-Message-State: AFqh2kqx/4pKB+HGWLdP+wkGxVVBT++WACT7+Y6CpWhrupReBeuhAeG2 hKpQ68ohlO8aJXCBnR9bhQcxJoLgzP52SrtExonVbw== X-Received: by 2002:a17:906:4bcb:b0:82d:1d5f:2618 with SMTP id x11-20020a1709064bcb00b0082d1d5f2618mr8070ejv.107.1671595853542; Tue, 20 Dec 2022 20:10:53 -0800 (PST) MIME-Version: 1.0 References: <20221220055954.11197-1-zhouruihai@huaqin.corp-partner.google.com> In-Reply-To: From: Guenter Roeck Date: Tue, 20 Dec 2022 20:10:42 -0800 Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: deferred probe when typec count mismatch To: Ruihai Zhou Cc: pmalani@chromium.org, bleung@chromium.org, groeck@chromium.org, knoxchiou@chromium.org, weishunc@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2022 at 6:10 PM Ruihai Zhou wrote: >> >> I think that is problematic. It might as well be that nports > >> EC_USB_PD_MAX_PORTS. >> > Yes, you're right. so we should consider it's a invalid argument and return -EINVAL if nports > EC_USB_PD_MAX_PORTS. right? Why ? While this would be a bug, it should hopefully be found early in development and never hit the field. I don't see a reason for changing the code. >> >> Is this really seen in the field ? The EC should never report a wrong >> (random) number of ports. If it is not ready, there should be _some_ >> indication that it isn't ready. Does it really report a more or less >> random number in this case ? > > Yes, I saw this on corsola board. The EC report a wrong number(not random), because corsola emulates HDMI MUX over the current > type-c mux stack. The ec has to fake a type-c port to pass the MUX info. But the task are not initiated on starting up, and increase the > type-c port counts after the tasks finished. In this case, I saw the typec->num_ports = 1, but the nports = 2, which will be probe failed and > block the HDMI mux function. > > I will send v2 patch, if nports > EC_USB_PD_MAX_PORTS, then return -EINVAL, but if nports > typec->num_ports, we consider wait a second > to ec task increase the type-c port counts if there're a HDMI DB attach, then return -EPROBE_DEFER The current code just reduces nports if it is larger than EC_USB_PD_MAX_PORTS. Again, I don't see a reason to change that. Anyway, I am not sure if the above will work reliably. I am not sure what "HDMI DB" refers to, but if it is an external connector its status could change anytime. In that situation, no amount of waiting would help. Either case, the EC on corsola should really not change the number of ports it supports. Either it is a constant that should not change, or it is dynamic and the EC would need to tell the host if the number of ports changes (up or down). Trying to fix this in cros_ec_typec without well defined protocol exchange with the EC is at best a kludge, but not a real solution. Thanks, Guenter