Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp163769pxb; Thu, 7 Apr 2022 02:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK2t2rNNYrqH6F50mfDbZMhnH76uTXAKZj0+V+xE1Egb5cT4fro3G0r4tqa/1dvHRHxGSL X-Received: by 2002:a17:906:7f02:b0:6cf:86d8:c31c with SMTP id d2-20020a1709067f0200b006cf86d8c31cmr12930446ejr.518.1649322241808; Thu, 07 Apr 2022 02:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649322241; cv=none; d=google.com; s=arc-20160816; b=xKiUVWALgtYI+e/aA8osQK5l2JSqn+/y+HulCZjFTbv9f4W+o8uRPcFTaA89WXVgNl avtrZlyC3zMDKK0oXU0mE9wc39yQC64/oLWy7aGpm7ZRqhXYXbvYLQ+sVMd4TUhkrbBK BLkUa6O8g6CxqjV5hxlhuEJo3Mvs3DAzz3w2wVUruvopzvGceLrA9S7ZIH2c5gOSNRYw mtzEsgGkMpYmgyBxuFMeZjx+t38wLO+7Fq8IisMA8jMcQlT+N1ZLUcSR2cCgA7tBI5IG SlYBcBFIcmHRsvQIgGhIlSlAP/QoAxPffFalnO3NrRUdMSoqjiVd8rviOYPZcRqblCZP 6Uwg== 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=a32qnBztE2IXtzvLnaEci16ST2DBqAaVGBlmBFvRnDc=; b=nO5kWAkN0QktO4hYvTueq1V1/xNYxjG6KQsQ9auTV3FLcI6YsmdqwTDpa6vGGnxZv3 xqu63LqbiVWeVrtohJEmre2ZFwutPmN6OLfFSYRWja2BZ4p4QgoQCrBdFUzhk4Axnrej 3JcEYQ3XMkKRW57rIFWid0xVmb7b/h11KgVA2WB11iDFfhdY6EU31/aY5/AHLMaODrR4 ZiVdz1+FvzsJ4xKhZUTHITfBCboNSa1feqga01/gD68D9YOFtmpL3bqhZ8LkTNRC3v2n YMbj2Qn7ZCnc01j4iQsIV6ddpdvaWJI9h1J90f/7UcZJMtL/fgyUBQItVjjm3RK4ZDw4 IKsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Am3wn/I/"; 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 u26-20020a17090626da00b006df76385c72si12143032ejc.274.2022.04.07.02.03.35; Thu, 07 Apr 2022 02:04:01 -0700 (PDT) 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="Am3wn/I/"; 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 S232577AbiDFVst (ORCPT + 99 others); Wed, 6 Apr 2022 17:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237743AbiDFVsR (ORCPT ); Wed, 6 Apr 2022 17:48:17 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D356615AE33 for ; Wed, 6 Apr 2022 14:32:38 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id d7so4160875edn.11 for ; Wed, 06 Apr 2022 14:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a32qnBztE2IXtzvLnaEci16ST2DBqAaVGBlmBFvRnDc=; b=Am3wn/I//RT+8eEj8AGDpa3XAgi7OxffpcM51aNFuWlwe39zYgN3D7PZ0yNbmCtitb 8XL+DUuK3lUirphpaiMnKyQHtTcKLbM9hGqiE5K3nG1hjkYzjpCbMfLYcjqj9VXadHUY 7+eJOKPbRDfaBR8hmjQR4txexhRpvrohH/03Dv4dUHm40iAgkDAUL6nxY5zatf5qFMmF OMlBQQ5e7roLBLt1v4e+U88WesZhkMtEAPZ8+bQ3LRuYmd9MKC4iUUiFMeByMa1+zH8R D8h/aSuF7uNcLC1A2g0lo9no+3zg4xnad0m77CDSPc7HbBu1+CllhuMZqV5zidnJOcnG CMcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a32qnBztE2IXtzvLnaEci16ST2DBqAaVGBlmBFvRnDc=; b=OUxVqqT9hmFQtMzpNxwN4VSAqfzLJTc2nZxPnbOKtIbtplMhF+EX84qr7mCag7n0+M TTRvY+pE+ezBKnsfR0oEidu2+qVUds5RF/mwzHnbHgZ3+0x4zmmmMo4ktvFjLM0ofXDD BZ93f5ShEEk1KuCSvNKef2QObDzReJxiwZEoEQfz1rbcWGga9T6ceLNDNhTsLxzCY0BJ +HReJ3mH+MHPWJ5op6jrneYd6EUDiFoq3QtqODbFjf7hVJv+iNVi5Uoq/LCmnsF+NHh8 TdpChsEz6ZgPloONc0swgcPNquTjCUnHoKyGuVgwz0iMFXVFfVI2C0uOWnPGm8BoBTqf cbjQ== X-Gm-Message-State: AOAM531RCOrUna+ppJxicezDAK9soyMbFU/I+uiM9SdHu/DeJ8Y+7Hti kFfr+yjpqBOKwsCfn6GaZHGyDu1q/9BVNWj8gCMi0IqQoK9sI8qE X-Received: by 2002:aa7:cb8b:0:b0:410:9aaf:2974 with SMTP id r11-20020aa7cb8b000000b004109aaf2974mr10907125edt.173.1649280757166; Wed, 06 Apr 2022 14:32:37 -0700 (PDT) MIME-Version: 1.0 References: <20220404041101.6276-1-akihiko.odaki@gmail.com> In-Reply-To: From: Guenter Roeck Date: Wed, 6 Apr 2022 14:32:26 -0700 Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Check for EC driver To: Prashant Malani Cc: Akihiko Odaki , linux-kernel , chrome-platform@lists.linux.dev, Benson Leung , Guenter Roeck 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, T_SCC_BODY_TEXT_LINE,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 Wed, Apr 6, 2022 at 2:16 PM Prashant Malani wrote: > > Hi Akihiko, > > Thanks for the patch. > > On Apr 04 13:11, Akihiko Odaki wrote: > > The EC driver may not be initialized when cros_typec_probe is called, > > particulary when CONFIG_CROS_EC_CHARDEV=m. > > > > Signed-off-by: Akihiko Odaki > > --- > > drivers/platform/chrome/cros_ec_typec.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > > index 4bd2752c0823..7cb2e35c4ded 100644 > > --- a/drivers/platform/chrome/cros_ec_typec.c > > +++ b/drivers/platform/chrome/cros_ec_typec.c > > @@ -1084,6 +1084,9 @@ static int cros_typec_probe(struct platform_device *pdev) > > } > > > > ec_dev = dev_get_drvdata(&typec->ec->ec->dev); > > + if (!ec_dev) > > + return -EPROBE_DEFER; > > + > > Just a quick check: are you still seeing this issue with 5.18-rc1, which > contains a null check for the parent EC device [1] ? > I may be missing something, but from the context I suspect this may make the problem worse. My understanding was that the problem was seen specifically if CONFIG_CROS_EC_CHARDEV=m. In that situation, it appears that the parent EC device does _not yet_ exist. If the driver returns -ENODEV in that situation, it will never be instantiated. The big question for me is why the type C device is instantiated in the first place if the parent EC device does not [yet] exist. I have not been able to identify the code path where this happens. There is a similar problem with other EC child devices which are also sometimes instantiated even though the parent EC device does not exist (ie dev_get_drvdata(pdev->dev.parent) returns NULL). That can happen if the parent EC device instantiation fails because of EC communication errors (see https://b.corp.google.com/issues/228118385 for examples [sorry, internal only, I can't make it public]). I think we need to track down why that happens and prevent child devices from being instantiated in the first place instead of trying to work around the problem in the child drivers. Guenter > Thanks, > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/chrome?id=ffebd90532728086007038986900426544e3df4e