From patchwork Thu Jan 5 13:24:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 640126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DBF5C3DA7A for ; Thu, 5 Jan 2023 13:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233422AbjAENZ2 (ORCPT ); Thu, 5 Jan 2023 08:25:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234047AbjAENZV (ORCPT ); Thu, 5 Jan 2023 08:25:21 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FCEA392DE for ; Thu, 5 Jan 2023 05:25:20 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id o8-20020a17090a9f8800b00223de0364beso1986088pjp.4 for ; Thu, 05 Jan 2023 05:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1hqQOkKrItwHNX5v+5p8BbzfdB8bkg8Yca4jGeyjDgg=; b=ShnfgUSOXuCGjRuna6wTL6cMaiNo15jKbthJwNrqZDEoFWjV+y52Bky++fVGKWPNxm TSdKdMVhcW3JgNP8dNM2EKQqaSXZgCti2M+wYScNBPeL3ExWbgqWeNvI7nKzg+eh/rJv IZAWA8zf44oLxLGeGCLsIrMHdbHb/gXBWUTYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1hqQOkKrItwHNX5v+5p8BbzfdB8bkg8Yca4jGeyjDgg=; b=ZtPADO/pE+0VPemrvLdOl28WKXwNTxZW8v7wVj+O+fbgllqah6w9ds/PW1ldJnfbc8 ZjFKz2mqu3q/xSGW9chHpuv6WBrkb43m9BAX1wyKPl6sy3MCV2pMIM1J0SY/d4BpCb8f hfgOwNSoSsa+8SUItyq+3Baq+eBu5p2u0SvXMtZ5wtwJWEu3W4e6eqTXp9Y27Suszbf0 vp3RzuuTkEIBhpS09pFtJXzYIBbv9UEvJjuKxy3WOR3JmYktOkMJhKV3h1KGhydOD3CX A+anPdoQHdMKHsn9lDhkhC2pQyKcClFd46gmRIXcpAA1+SubFpA1eBpjCeyvAxBV2v+I 4Qvw== X-Gm-Message-State: AFqh2kocJqzczxRp3ZCAyMp5DqXHkMZk3gf8F+xiWF5B37GUtafTVFdo Vm6haIBtoLbuoKZudcCPDBNYxw== X-Google-Smtp-Source: AMrXdXs2rSmGWZCqtd8p+t21jfexuxiaORDcdvHuQTqxS2qgF6MSOKcW+gdNFTSY78GsG4nyx34fPg== X-Received: by 2002:a17:90b:35d0:b0:225:f793:ab2d with SMTP id nb16-20020a17090b35d000b00225f793ab2dmr36398951pjb.46.1672925120095; Thu, 05 Jan 2023 05:25:20 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:7a61:eb85:2e3:2bd0]) by smtp.gmail.com with ESMTPSA id gk22-20020a17090b119600b00225e670e4c7sm1372682pjb.35.2023.01.05.05.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 05:25:19 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Xin Ji , AngeloGioacchino Del Regno , Thomas Zimmermann , Hsin-Yi Wang , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Lyude Paul , dri-devel@lists.freedesktop.org, chrome-platform@lists.linux.dev, Pin-yen Lin , Javier Martinez Canillas , Marek Vasut , devicetree@vger.kernel.org, Stephen Boyd Subject: [PATCH v7 2/9] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Date: Thu, 5 Jan 2023 21:24:50 +0800 Message-Id: <20230105132457.4125372-3-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105132457.4125372-1-treapking@chromium.org> References: <20230105132457.4125372-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Prashant Malani When using OF graph, the fw_devlink code will create links between the individual port driver (cros-ec-typec here) and the parent device for a Type-C switch (like mode-switch). Since the mode-switch will in turn have the usb-c-connector (i.e the child of the port driver) as a supplier, fw_devlink will not be able to resolve the cyclic dependency correctly. As a result, the mode-switch driver probe() never runs, so mode-switches are never registered. Because of that, the port driver probe constantly fails with -EPROBE_DEFER, because the Type-C connector class requires all switch devices to be registered prior to port registration. To break this deadlock and allow the mode-switch registration to occur, purge all the usb-c-connector nodes' absent suppliers. This eliminates the connector as a supplier for a switch and allows it to be probed. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin --- Changes in v7: - Fix the long comment lines Changes in v6: - New in v6 drivers/platform/chrome/cros_ec_typec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2a7ff14dc37e..30cf03c2e95d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -382,6 +382,16 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return -EINVAL; } + /* + * OF graph may have set up some device links with switches, since + * connectors have their own compatible. Purge these to avoid a deadlock + * in switch probe (the switch mistakenly assumes the connector is a + * supplier). + */ + if (dev->of_node) + device_for_each_child_node(dev, fwnode) + fw_devlink_purge_absent_suppliers(fwnode); + /* DT uses "reg" to specify port number. */ port_prop = dev->of_node ? "reg" : "port-number"; device_for_each_child_node(dev, fwnode) {