Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5366444rwj; Wed, 21 Dec 2022 01:26:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXuy5tLHppIUdEjYZX2ZUJ3dHHmEfmoALR935/3FTeO1DgwjKG/oulFuYo0jGOMVce+mrfMu X-Received: by 2002:a17:90a:b88c:b0:219:d999:770d with SMTP id o12-20020a17090ab88c00b00219d999770dmr530500pjr.43.1671614797011; Wed, 21 Dec 2022 01:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671614796; cv=none; d=google.com; s=arc-20160816; b=Ld0mGI4rUUhpPc8mVFUtn4oxG+81yoDddMXDZ2QJoA2e9zFaux/UMEz2L4Ec6XqXvP S1xwFlmuD1jhUgyr/ZD906TIJOYUHmQDpDVSa4NiOll2dPeG2zOKVb1at5C9+Cs/85/3 Jn3kjbq1q02v6Q1++yLsVbHwsysrYaDAOTk7fL5e7XMo+HWueO2tr8n4XzCokVrtRByE 1g++8p7cirmrkmv2U/SJsPYjUbSIWm6tdL62HiWFsrAN7JsH2R8yMV35cYOplwGGcNpt 3i38XJN5zEqZyy2/gCrOtN+G83C8VePWMPUHZk9Dc9PwxuWZ4p8t6HYFz34+mc++JhtC BvRA== 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=GdBHixmIEv6hOlchC/qp1j/sG6Htlu0RfoDp0oBFpT4=; b=iwGf4Gf1Cxwh6KeoiaGCH9GC60OTDg2d10Ven4XNidxjeH0mRkAQGZtgXXBD1650+Q Q7VQSzaNB77IPDiQ5lk1OwTFbPnkyfuIBebDVs0RC2Jx8Twdkl+j4ZVriI3lD9Sj663i fw3/cnU0ntGON//er/eYre44GSp1K1BKlHPaNlryzdL4aL74Q83flRJe4YaL5CtS7Acu IuFIWlpPYMxrYKZL9oGKSd2iw+JFKbwKo3nULosPQ6BluHmGcBKCG/Gh5S2t7MmMMAjq c4E3zn302dENgxMDd0OypTEhGoyTqEPQoy1guNefbrr9XhG2yofsgsw0uBogMVs5ZWwG e0VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D3X8mRE2; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu4-20020a17090b1b0400b00219ebe1506esi1376523pjb.131.2022.12.21.01.26.28; Wed, 21 Dec 2022 01:26:36 -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=@chromium.org header.s=google header.b=D3X8mRE2; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234558AbiLUJVI (ORCPT + 69 others); Wed, 21 Dec 2022 04:21:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234556AbiLUJVC (ORCPT ); Wed, 21 Dec 2022 04:21:02 -0500 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC32DEB4 for ; Wed, 21 Dec 2022 01:21:01 -0800 (PST) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-460bb6ec44bso10480427b3.1 for ; Wed, 21 Dec 2022 01:21:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GdBHixmIEv6hOlchC/qp1j/sG6Htlu0RfoDp0oBFpT4=; b=D3X8mRE2crBgGEVyUX3K4KS+R2JbIxF9wo/5kXFjDg8fbDrSy0+PqWSIC5f1T0gfJM YxOylDvVXQyP3YJJaa8HndLDF/D8/qvMXz4119hQqQdfy7nA0CcnCVpcq+l7WvXVxS5A /Gm5XhG1fJFmyOLA6NEbEohEyZ4QJPHt0fV4k= 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=GdBHixmIEv6hOlchC/qp1j/sG6Htlu0RfoDp0oBFpT4=; b=Law25uNaETlGqNlA5t8dofLkhdLIlWW9TnkaoNzdQBMeNtu7kC567hWU4gWCirhE/C TOoMpH93OeGTwofMbpduXGAy28gHtaUm7jqZubBK2GijFcq92d8xUdgjgNSm61HbAQDa IQDMqpHSN+KhdoNAity/LM23Lkx9F6sNN1l+dlmu3wcT+LzfBoztnCnFxcmyfRZpjvNe RqF8G0cgy/4qtvwxzkDExchrTu1KUhGtH0KGM1ThwyaztxhI/2SfXfJpaC8yfgWr+JGW ykkMx5UWvVap+4e+mWSmmu3AbODhQxOqCX1HkImhC+sVwSf/cF+qfp0vphooJaBJ0+MV NiZQ== X-Gm-Message-State: AFqh2kq7G1oUW1fvgOwcMbLxSnnKRTKsRddMSVsYEI5JXSYYgnysLxzA XHhyhA1USQhgYFQTAyBnJs+xooeYqUd3sD20taFXojoTPgqDgrDu X-Received: by 2002:a0d:cc8c:0:b0:368:70a8:9791 with SMTP id o134-20020a0dcc8c000000b0036870a89791mr129912ywd.197.1671614459562; Wed, 21 Dec 2022 01:20:59 -0800 (PST) MIME-Version: 1.0 References: <20221220055954.11197-1-zhouruihai@huaqin.corp-partner.google.com> <20221221070122.4167-1-zhouruihai@huaqin.corp-partner.google.com> In-Reply-To: <20221221070122.4167-1-zhouruihai@huaqin.corp-partner.google.com> From: Prashant Malani Date: Wed, 21 Dec 2022 01:20:47 -0800 Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: deferred probe when typec count mismatch To: Ruihai Zhou Cc: 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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 11:01 PM Ruihai Zhou wrote: > > >>> 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. > > Thank you for the reply. The "HDMI DB" refer to the daughter board > attached to the mainboard, which don't change anytime. In fact, > the corsola EC increase the port count dynamically with some delay > (no see a standard yet) during bootup. There is the EC code to > increase the port count [1]. If the cros-ec-typec get the type-c > port counts from EC before the EC increase the port counts, then > will probe failed if return -EINVAL. I think the cros-ec-typec > is replying on the fragile delay in EC, cros-ec-typec module will > not get the fake(HDMI) type-c port counts once the EC deferred > call is later than the driver probe. That is why I make this > change. For the verification, the driver always probe failed > when EC reboot without the patch. But the driver probe passed with > the patch after a few times deferred probe. Sorry, but I agree with Guenter; I don't think this is justification to add a hack for 1 board in this driver. In what situation does the EC task take so long after reboot that it occurs after a module probe (which occurs shortly after system boot up)? Why is the "corsola" board increasing the Type-C port count dynamically after some delay, and what is that delay amount? Why can't this be set via CBI/DT or its equivalent on your ARM platform? This seems like fragile code in the EC and should be fixed there. The number of Type-C ports reported by the EC really should be invariant across the boot lifecycle. I don't think this patch can be accepted. Frankly, I'm concerned that doing this might be introducing some subtle bugs in the EC Type-C code too (I'm certain there are assumptions about port count being static there too). If you really need to change the number of ports dynamically in the EC, add a board specific-hook to not respond to the EC_CMD_USB_PD_PORTS host command until you have "set" the number of ports. Best regards, - Prashant