From patchwork Wed Mar 22 10:46:30 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: 13183877 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45336C6FD1F for ; Wed, 22 Mar 2023 10:46:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 798F810E8E8; Wed, 22 Mar 2023 10:46:56 +0000 (UTC) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85F0410E8E8 for ; Wed, 22 Mar 2023 10:46:54 +0000 (UTC) Received: by mail-pj1-x102f.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso23054585pjb.3 for ; Wed, 22 Mar 2023 03:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679482014; 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=taPmB4+Xp9EC511rcY4vhFNfgJl8IMtTdglowbBg2bA=; b=TRfNa5Bjym9D/QOWv3oireKkb637T2hgKBgTBhwgznroO/IjIvby1HKxj8T78xQsPf gA7BKv0GlqGZZTjg9B+pKlOcISJ5w8svZIcbRBIQKpRbmBW8arjwvK3SbvfPeK7gfrf+ pf6LJFcpkKHiwR3AHOWxcu4hh6JK9N+jVw22I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679482014; 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=taPmB4+Xp9EC511rcY4vhFNfgJl8IMtTdglowbBg2bA=; b=plh7zIoGJnIbwOHcLkrKa4wxtKUnPAnC/NFSpyWG6rKy5KycwidpB5acbPSMq/3xbs wA8QS9u1TcC/B1I7iIlU/wvL6lE2G1CXJZVBTfu11zQeowZb+q7luCf+qk7/cQAzRVN/ W6nznJ8Hyoawzf0TJWFiLkE7CDV7LY3B2kwgQYoVzbVGy2dmhzBlRlyXEOitMVte5wtQ ZLcoIg2VrPiPyTN6hKncLKF614vya8iFrddRNI7eD4hreWas9UitJM4dw1hfi1Bncen0 LvgdV/GVZJtC71bo8e3rAzkIRKGaevEtsOcRBRQwVku4WdbTJ1X/Stxef+nEu+f/8Dwh qDWw== X-Gm-Message-State: AO0yUKURiu7xv6djXBPx1Y2mLT6rTTmzAJIwwRFLOecUO359KbhXZ7TY hjm0qQu7wD/Y+eYC5lBT/DKS4w== X-Google-Smtp-Source: AK7set8NY7gSVoQ4fC5GN+MPbT1csTFpfLKJNC4YeNu9C5XL+LD4947BMZpiMhYqHKm0ufkRA9/KIg== X-Received: by 2002:a17:90b:1a81:b0:23e:f855:79f2 with SMTP id ng1-20020a17090b1a8100b0023ef85579f2mr3799890pjb.12.1679482014097; Wed, 22 Mar 2023 03:46:54 -0700 (PDT) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:343d:79bf:55f9:1da5]) by smtp.gmail.com with ESMTPSA id hg4-20020a17090b300400b002340d317f3esm9508742pjb.52.2023.03.22.03.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 03:46:53 -0700 (PDT) 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 Subject: [PATCH v14 01/10] device property: Add remote endpoint to devcon matcher Date: Wed, 22 Mar 2023 18:46:30 +0800 Message-Id: <20230322104639.221402-2-treapking@chromium.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230322104639.221402-1-treapking@chromium.org> References: <20230322104639.221402-1-treapking@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , chrome-platform@lists.linux.dev, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Pin-yen Lin , Allen Chen , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, Thomas Zimmermann , Hsin-Yi Wang , Stephen Boyd , Xin Ji , AngeloGioacchino Del Regno Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Prashant Malani When searching the device graph for device matches, check the remote-endpoint itself for a match. Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin Reviewed-by: Andy Shevchenko Reviewed-by: Sakari Ailus Reviewed-by: Heikki Krogerus --- Changes in v14: - Collect review tags Changes in v13: - Update the kernel doc of fwnode_connection_find_match Changes in v12: - Check the availability of the device node in fwnode_graph_devcon_matches - Ensured valid access to "matches" in fwnode_graph_devcon_matches - Updated the documentation in fwnode_connection_find_match(es) - Dropped collected tags due to the new changes Changes in v11: - Added missing fwnode_handle_put in drivers/base/property.c Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v6: - New in v6 drivers/base/property.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 083a95791d3b..4426ac2b16ca 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1243,6 +1243,23 @@ static unsigned int fwnode_graph_devcon_matches(const struct fwnode_handle *fwno continue; } + ret = match(node, con_id, data); + fwnode_handle_put(node); + if (ret) { + if (matches) + matches[count] = ret; + count++; + + if (matches && count >= matches_len) + break; + } + + /* + * Some drivers may register devices for endpoints. Check + * the remote-endpoints for matches in addition to the remote + * port parent. + */ + node = fwnode_graph_get_remote_endpoint(ep); ret = match(node, con_id, data); fwnode_handle_put(node); if (ret) { @@ -1293,8 +1310,11 @@ static unsigned int fwnode_devcon_matches(const struct fwnode_handle *fwnode, * @match: Function to check and convert the connection description * * Find a connection with unique identifier @con_id between @fwnode and another - * device node. @match will be used to convert the connection description to - * data the caller is expecting to be returned. + * device node. For fwnode graph connections, the graph endpoints are also + * checked. @match will be used to convert the connection description to data + * the caller is expecting to be returned. + * + * Return: The pointer to the matched node, or NULL on error. */ void *fwnode_connection_find_match(const struct fwnode_handle *fwnode, const char *con_id, void *data, @@ -1325,9 +1345,10 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match); * @matches_len: Length of @matches * * Find up to @matches_len connections with unique identifier @con_id between - * @fwnode and other device nodes. @match will be used to convert the - * connection description to data the caller is expecting to be returned - * through the @matches array. + * @fwnode and other device nodes. For fwnode graph connections, the graph + * endpoints are also checked. @match will be used to convert the connection + * description to data the caller is expecting to be returned through the + * @matches array. * If @matches is NULL @matches_len is ignored and the total number of resolved * matches is returned. *