From patchwork Tue Feb 21 09:50:46 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: 59830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1773786wrn; Tue, 21 Feb 2023 01:53:05 -0800 (PST) X-Google-Smtp-Source: AK7set9r/GV24A4xcnZzVPa1TXRJAbao+43jHJBxbJoniZALTxuH8s73FZpA9urqan5KVfRCLGGd X-Received: by 2002:a17:903:41cd:b0:19c:171a:d342 with SMTP id u13-20020a17090341cd00b0019c171ad342mr5214511ple.37.1676973185372; Tue, 21 Feb 2023 01:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676973185; cv=none; d=google.com; s=arc-20160816; b=VQXR9F7K/Cjvkz+jm52o4Y/kMVT+sWEDJqvj9bx7N8S4wCyp8/dTb0mhkJOKrEoPCY 7y/Rv3IiolyMbwzwKEP59zvRVET3TTw3h2ql018QHdLA+0OXLyerpzStyTagVCWsHnTv A+mYCmaDtf5tasPCJmfv8UBxitzILeuEHNDgKuXGtYsTIrCeLR6ICfMCLQyhbPnfqjzA xUlGDBF4NqE7hRwzchI1jxeSC6Qe9+pcwagbn39oElO8NvkFEE45pz4SFJ/4Jj71zrES eybVpI7TjdT48Ylyt1CkYKZ5OWUP/qfJoTNVDhUtjtKKRqpCwyL6PmfwHb12Zpf7cRHP MzGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=84m3FSulx+pWKCpnyEJ3RgcMwe/Bo6Rt70rnUQNfHew=; b=IF7y4V64dWimzXU9rfd4EEePZ9PzgM9PALU0oi6w5sfoBHSvdiZ3GxcbX+mjKDZF5o QT8AGqX0HBWURnCGaeKuWNIZXwc+ZTdyir97yIrmB4vtk6FSyfzDW+tuP4dmsfAHpoxx /desK/Jjz5ruIDf0TU+gEHduUvlUW1gct2Ru8uCiYsfqe6+vrfz8K/ckMEabApabp/NP DAQ9a0NPGFSLbgVa6glF0aNajAQSa9U8tXzPx5yy96t2TUZJGJBehkDlcGy5GmvnXQIj t5oLRP1busBgLFo4po1INvBAKE5ns4hGTpzkeUzHpeJeA2pzX2Em5A0NFTzhhkPyJtNW udog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Teyu6n12; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a170903244e00b001966308c9dcsi13840925pls.301.2023.02.21.01.52.50; Tue, 21 Feb 2023 01:53:05 -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=Teyu6n12; 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 S234045AbjBUJvf (ORCPT + 99 others); Tue, 21 Feb 2023 04:51:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbjBUJv3 (ORCPT ); Tue, 21 Feb 2023 04:51:29 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F8DC234CC for ; Tue, 21 Feb 2023 01:51:27 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id oe18-20020a17090b395200b00236a0d55d3aso4611111pjb.3 for ; Tue, 21 Feb 2023 01:51:27 -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=84m3FSulx+pWKCpnyEJ3RgcMwe/Bo6Rt70rnUQNfHew=; b=Teyu6n12+9jHyEBpVJMRsPinTHx4mlBvUReMYsnpwoUDixoB2lEOVV2Xog1BzRpAvJ VYi/SSy+LXeg6/qYwipRJqeLiYxgN+YsKEYFdVZcVBmF+G/kGBAuKijJtP0BtO+IUFH4 GvwOruadQ0wlgGnbAyXdRip2lNBYu8fXadKC8= 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=84m3FSulx+pWKCpnyEJ3RgcMwe/Bo6Rt70rnUQNfHew=; b=ezBo64hhuyBZtx2KHECukHEifyWFjDS5ie6Ojtn1SDhMjNe9kF92L1YnmMJ+mQLRfb OUK2FkgfKGHDH7GQJ8yGavRSyKjqW0cB8Yi1j8uAGae8WK/MMaSp+dGFYQAcxH+by03U ZEOjMxytdrwDKReCc2InkoLLROHtDqr2gItfs1w/Y4IvZVATdpUXVXG5Osk4+ATi83rX SlB6aCc7aYSzFuhqr3V+aAP9O1JJKObRNSvwt8/zjQ4JxlUuUFwzYB6Iqxk6JAoSX3oB 6dneqkeGR9jVXqSNtYLfUXmfJQu0aKbT3IWfusMzyxlUHQ+u0cfKBNtArLDHZRXSorSb h1XQ== X-Gm-Message-State: AO0yUKUEDvZIpVaIKKfH9rL9VY+OphJOUhqmTjQ7JhgsfbMQuHCY0Fry mh3ICszOykxgSWEIvE2QQ/rnZg== X-Received: by 2002:a05:6a21:3394:b0:bc:cff9:f092 with SMTP id yy20-20020a056a21339400b000bccff9f092mr4888829pzb.10.1676973086834; Tue, 21 Feb 2023 01:51:26 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:a1f5:f58d:584e:5906]) by smtp.gmail.com with ESMTPSA id t25-20020a656099000000b004eca54eab50sm3524918pgu.28.2023.02.21.01.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 01:51:26 -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: Pin-yen Lin , linux-kernel@vger.kernel.org, Hsin-Yi Wang , Marek Vasut , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Xin Ji , Lyude Paul , Allen Chen , devicetree@vger.kernel.org, AngeloGioacchino Del Regno , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , chrome-platform@lists.linux.dev, Javier Martinez Canillas , linux-acpi@vger.kernel.org, Stephen Boyd , Chen-Yu Tsai Subject: [PATCH v12 02/10] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Date: Tue, 21 Feb 2023 17:50:46 +0800 Message-Id: <20230221095054.1868277-3-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230221095054.1868277-1-treapking@chromium.org> References: <20230221095054.1868277-1-treapking@chromium.org> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758433834486083102?= X-GMAIL-MSGID: =?utf-8?q?1758433834486083102?= 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 Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai Acked-by: Heikki Krogerus --- (no changes since v11) Changes in v11: - Collected Acked-by tag Changes in v10: - Collected Reviewed-by and Tested-by tags 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 001b0de95a46..bbc95a3ba5a7 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -385,6 +385,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(dev)) + 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) {