Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2112961rdb; Tue, 20 Feb 2024 18:41:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVy7iSSENdaYXKA0qXKb4zfbQOxB50VQZSTba1JV9JcT94lHwDM3za6hnd07FouGWTlp+xnMp2+ImMgCKHnf0d69QcyVaoaR+tkEk37ZQ== X-Google-Smtp-Source: AGHT+IHdXBPU+z7sdNMbWY8ZgDHTvPgPHU1WfYVraQpsZfbfOHP9K4YeCtIxNz32fXMBMr3oxEa+ X-Received: by 2002:ac8:7d90:0:b0:42d:df5b:ae3d with SMTP id c16-20020ac87d90000000b0042ddf5bae3dmr24448573qtd.3.1708483291672; Tue, 20 Feb 2024 18:41:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708483291; cv=pass; d=google.com; s=arc-20160816; b=K9UwUjIBDlXHm/VbxwIkmYQSRUCJIsAuhzGrsm9eo3030ZLSFsphasUrkpmfI7GSbT qpbMz+bhhUOrPhwQFAKuxcLYozBu0FJ/joq7acAWgoMgYG0cfWrFKOB5N+luZdeSVIiM 8GxJ6nd+eiPVebB7m/Kuti9hjvuK+6FtHRova9mkFhJTdfK/DprTbnbfaqdYZJ8SLWfB oQeW0RlM5VicY5qy7s0kEnUtNjR67ukIMNELwi28/7Dg+eObxhV67WBGfZBDghnsW7e5 p0rt0FyDdRm6AzSstmh1x3dg5BmfM+yG+/k5UsFOX6s6VwDgjVwIg3vRPhhiVsxYuH0Q 5nZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=nIFksRQNrLKsi4orC6zr7YrZCHRKvKULKcRY+vVqW6k=; fh=12s2E+IGUqDU1xoOIKMUO0spi19sOqYzyNtkXG2Dmqs=; b=Xt8zMZPSg99NiICgVhUyHR/8xmFvO27i53d1/95ep2a8ufVaLqEX97SDe8l728Xutm /nk0NlAWodVLronPWK5uPZfJdJ758QWTMbK8XUGP4jc2AmgjiCkIPLlnDRhMKd7Usmrt /x4PIudWqyihXnk5/xpAgUpRhIxduBoNPqZS3rRTfBiuHVqrwSdDnA8U/fY9R2BVnOBy M5GhvISpHVrlv7063yr5wU+sSOaz8dcnmvQ7t4EuuGzjK5I/NZM+pehABvMIKEUVWxrw gbQYsZTSGV9z6B4wwUdE9fHRYeszGO583Qdb24GbI0sY7xSxPCHxsThOjMIy3hevABHr MRTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=by0Ly4w+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c26-20020a05620a201a00b00787226c531csi10477691qka.291.2024.02.20.18.41.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 18:41:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=by0Ly4w+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 37E1E1C22444 for ; Wed, 21 Feb 2024 02:41:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF0EC2836A; Wed, 21 Feb 2024 02:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="by0Ly4w+" Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F0612574F for ; Wed, 21 Feb 2024 02:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708483281; cv=none; b=Y+YPVrvUasIyzrIT/v6eGO8L3IF+JyeF4dWShMDZJvXt8NHKJRT5UBIWAO3uXyw5WCnluEF4Q0QxBpEBGpNvTnBWJPCC6exDB/W01ZQACmgwqEu65ifeK8JIGnWL7JwxoKjlzsfFP0mwbV7YKNYHCHkFwEcRnlYtQALT8G7OeFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708483281; c=relaxed/simple; bh=yLvENca37koqXHk4DDkN36MXxCa5K53ryrsPH9SnC/4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XBE/8gEb/QOqdSqCpHtjXOKjbYva5idyheh2JhFqw02sOpTzOqMcY4c7LEgmXQydbeHorMgqS1F+xowvbdmXiSnEIzBBbV+nFdirkTlNhu8dtRGgHh6YM/lc4rwGAAqRYEo2vo6BTemSKAWsYkdqq9+vD1NUn9j8NzJ0Y+A9DrU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=by0Ly4w+; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-42db1baff53so95041cf.0 for ; Tue, 20 Feb 2024 18:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708483278; x=1709088078; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nIFksRQNrLKsi4orC6zr7YrZCHRKvKULKcRY+vVqW6k=; b=by0Ly4w+55d8tT2uUPVeAvIyth4mfXuh3IMiWsIpA4ciU6ZWuHDyN+AY+Dj/OSdbAz TYt4f923UnWaTh/dvx2W4oINnG3YhWrDDkonYTDOhvLfsptPzrDS0ts0UQMOKEF8R9hK B9cZZvq/H2VT66VsF4kL/YUiqg90Nu8Ha4JDKuR1Xl1FPMoOHiZQ+INQ3m6L7VgQA9wy 486B3uXRP/sIBLhg//90jTq2L1w76v/c6LlPJa9JNBv8M89H5eeTUv0GZ2KTPOqpUiGJ rD1SDpM31CgyoMP7xbVPOACNJ9/ZUBhhLKYxKh20lMyRBgmjFKHkcdZv8UaC4+FRXnju cbMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708483278; x=1709088078; h=content-transfer-encoding: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=nIFksRQNrLKsi4orC6zr7YrZCHRKvKULKcRY+vVqW6k=; b=YsPnUugmtjqMQ9oqZytIWPTOE3X/jGfV1gMwiWbq4tN4YVWM+Ld5mNqVpgVZkgi30o 7VEL+89xsZQ21XMX5nIrpLeDIWyB9eKTwVSW61R5ZjVr6UR5FM9ZFAcKlGIr6qL8eCpt vW/pgkZmvsy75Rzp+mABVWKxii58OQwjOOrKKKaaaJVlF8DbqiwRMvic/2zZMmOdcDxs PtFYVaRr/ppgWmaeO/AnSpuUPCK8T2SiIq0aJWjlIaMp6JgZJzHrirCyGHmd/g5eTxI3 tgjzjrDJuMHK9VHcHb2O6+BHv34+yB/ONQEKogDeK2xpCUeGhvy6F7A4Dr4FcIsJ3Rl2 XhVg== X-Forwarded-Encrypted: i=1; AJvYcCXtA9NIznvFWz3PqH0fQjyep/FSrRr83/WvXrZQvTbxn2D4pwX3pnXyr6SMtJ7ojtQzENMScCnEj9wvXnG3IB8nIWM72MBwIz6yl90L X-Gm-Message-State: AOJu0Yy3Vg80ro23pFvvGxZ1hJ76NbeHp8lm3ziz2vrc0gLWBli5VkM5 V4b3B7AOcr8iiiP2vWoOKA+cJ/Tcl3aMAVtWXWrcMEf+xJB2rJ4WwDSdobUb3GaPFWsuyqh/muD HY85TMEh+4iRYhuyZz4DPSTEUM1YGg5Bm1Y/j X-Received: by 2002:ac8:744e:0:b0:42e:3233:4924 with SMTP id h14-20020ac8744e000000b0042e32334924mr121412qtr.26.1708483278081; Tue, 20 Feb 2024 18:41:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240220111044.133776-1-herve.codina@bootlin.com> <20240220111044.133776-3-herve.codina@bootlin.com> In-Reply-To: <20240220111044.133776-3-herve.codina@bootlin.com> From: Saravana Kannan Date: Tue, 20 Feb 2024 18:40:40 -0800 Message-ID: Subject: Re: [PATCH 2/2] of: property: fw_devlink: Fix links to supplier when created from phandles To: Herve Codina Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Shawn Guo , Wolfram Sang , Mark Brown , Geert Uytterhoeven , Rob Herring , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni , stable@vger.kernel.org, Android Kernel Team Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 20, 2024 at 3:10=E2=80=AFAM Herve Codina wrote: > > Since commit 1a50d9403fb9 ("treewide: Fix probing of devices in DT > overlays"), when using device-tree overlays, the FWNODE_FLAG_NOT_DEVICE > is set on each overlay nodes. This flag is cleared when a struct device > is actually created for the DT node. > Also, when a device is created, the device DT node is parsed for known > phandle and devlinks consumer/supplier links are created between the > device (consumer) and the devices referenced by phandles (suppliers). > As these supplier device can have a struct device not already created, > the FWNODE_FLAG_NOT_DEVICE can be set for suppliers and leads the > devlink supplier point to the device's parent instead of the device > itself. > > Avoid this situation clearing the supplier FWNODE_FLAG_NOT_DEVICE just > before the devlink creation if a device is supposed to be created and > handled later in the process. > > Fixes: 1a50d9403fb9 ("treewide: Fix probing of devices in DT overlays") > Cc: > Signed-off-by: Herve Codina > --- > drivers/of/property.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 641a40cf5cf3..ff5cac477dbe 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -1097,6 +1097,7 @@ static void of_link_to_phandle(struct device_node *= con_np, > struct device_node *sup_np) > { > struct device_node *tmp_np =3D of_node_get(sup_np); > + struct fwnode_handle *sup_fwnode; > > /* Check that sup_np and its ancestors are available. */ > while (tmp_np) { > @@ -1113,7 +1114,20 @@ static void of_link_to_phandle(struct device_node = *con_np, > tmp_np =3D of_get_next_parent(tmp_np); > } > > - fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np= )); > + /* > + * In case of overlays, the fwnode are added with FWNODE_FLAG_NOT= _DEVICE > + * flag set. A node can have a phandle that references an other n= ode > + * added by the overlay. > + * Clear the supplier's FWNODE_FLAG_NOT_DEVICE so that fw_devlink= links > + * to this supplier instead of linking to its parent. > + */ > + sup_fwnode =3D of_fwnode_handle(sup_np); > + if (sup_fwnode->flags & FWNODE_FLAG_NOT_DEVICE) { > + if (of_property_present(sup_np, "compatible") && > + of_device_is_available(sup_np)) > + sup_fwnode->flags &=3D ~FWNODE_FLAG_NOT_DEVICE; > + } > + fwnode_link_add(of_fwnode_handle(con_np), sup_fwnode); Nack. of_link_to_phandle() doesn't care about any of the fwnode flags. It just creates links between the consumer and supplier nodes. Don't add more intelligence into it please. Also, "compatible" doesn't really guarantee device creation and you can have devices created out of nodes with no compatible property. I finally managed to get away from looking for the "compatible" property. So, let's not add back a dependency on that property please. Can you please give a real example where you are hitting this? I have some thoughts on solutions, but I want to understand the issue fully before I make suggestions. Thanks, Saravana