From nobody Sat Feb 7 18:20:52 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 09FC31775F for ; Thu, 22 Feb 2024 03:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573593; cv=none; b=eobd3jys3wFY55YlvpmvslmjE8coqAqWLTmNVqUmy/ixlhhqmcFtGkHf8y+GaICXjCkEIe3gxxJfJJsEikxR1iGP+IbXOYVyuBABmQxhkVlGlZXmjbQnn9Vp8TdtFubJ+p1CJy4NbLLHbtn2XEwlVLR5dYZz7tqPxLLT+uqzvhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573593; c=relaxed/simple; bh=O3k+nYu1MYBPKH6TsA/y54d2ADLO3F4v2KYWl0x8bqo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=QdEOWHp0mfCqXN+ONpabgr3rfOyUjNjYGzmcmVZZlO3dDmD/DLYEq4xDkFz5X8an30L1+rXc82Rz9RtwyxpgZwVWqekO20/QrtjqUjmqgVDl1uBnvwJfP7MXWlZRCSYViL9KNMTcPOFEpel5ZzjHJvS3QUJKhZ5Maf5Tl5WKgFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VNhOeutf; arc=none smtp.client-ip=209.85.219.201 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=flex--saravanak.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VNhOeutf" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcbfe1a42a4so2828944276.2 for ; Wed, 21 Feb 2024 19:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708573591; x=1709178391; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2RZcm32i75equt/unWf5KMZ/RAcqfb/I89ao1kCyS8A=; b=VNhOeutf99wuKQ4mc9T//DCHqlek+iA/ffF7r67ow5P4Lgnh7YHO6RKcL0sOEl6Y7r DfBto8hTyDAO0HPwOKi0d14XYSAnEdip8lT5BieTWasTF67ZCn4GNAZZ49dvAsJbOMQ7 pBxVoR9Mx+G4iUqCVIKmhWBso5ydF6rdnETLa3WeJd7Vz27yEtrOtZjzQtS+mN7QWMY0 8oKgy/7yiHtaKqAtIccGj5e3apAPGlP+9lAqbwBF87oVmVxRjYDXyQ3yrX6GcdzBSukw NV/TdsQ4Jp220XbFeijE/pm8MioibnU9S8UmuII37oIUpLbRfxoMjSwCkGMItFKFF/Uu kHEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708573591; x=1709178391; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2RZcm32i75equt/unWf5KMZ/RAcqfb/I89ao1kCyS8A=; b=aaKt/HDBpxYZY4H0W/FlCvJ8O6bwQaLR6fosgk2/Py5JX7EIEzaHStvB9OEVurugan eQri5eA5gESZ8dkqRWQJRMd6p4IlYstMXXn0Zex5YY/21UfF2a+QxVkkNfv8L1l5n/Io peIUFt1gT79o0pTRcvjk7R16Hgw1Bqh56BoPEqFxYhLALC9uVnC/UKvX071noyoQlCJR LHcwzTzCNapIccHEGTheJAbiCGC5WnGJpsAGfppYbhmDgMYJzSZNNXsqzL2fsoluMLvz gtYut/jKUA077JKnn6sC7LAGSqv6xb7CVugziBI3oGdnEbnGTOf70ejumW6stFphHRfT /3HA== X-Forwarded-Encrypted: i=1; AJvYcCWTirNMsJsiOfTalhZluYi8Ex0MCgrgbnUuLAt47XYrBYPoVLauzflJ0x778J1a4R9tjLgT7C6u4RAh6ON7YPLrLVL4olwyG5dM9T19 X-Gm-Message-State: AOJu0YxE9pN35iBtNPKz68AC6uh4fsBO7J6O2oeqL+XhkX+K35z+vzXm lHGIvL5U3PN2rqixcmfTMFNW+s9lEJsaBy7fC04gMk/+kLdplmAm90I6MegM7vkqkWwlDoAYz4F U5OjvMjLHcVENNg== X-Google-Smtp-Source: AGHT+IHsDb2HtN0D1LaP7LOSjxqm+4q4hkHitLGwVd3UaC+PYoVhSFcHyYA1NaTDGTk57Hk4ADB8Bq63PJ18SdU= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:451c:c6c5:1fb1:a2a1]) (user=saravanak job=sendgmr) by 2002:a05:6902:150c:b0:dc6:e1ed:bd1a with SMTP id q12-20020a056902150c00b00dc6e1edbd1amr340344ybu.2.1708573591099; Wed, 21 Feb 2024 19:46:31 -0800 (PST) Date: Wed, 21 Feb 2024 19:46:19 -0800 In-Reply-To: <20240222034624.2970024-1-saravanak@google.com> Message-Id: <20240222034624.2970024-2-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240222034624.2970024-1-saravanak@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Subject: [PATCH v4 1/4] driver core: Adds flags param to fwnode_link_add() From: Saravana Kannan To: Saravana Kannan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow the callers to set fwnode link flags when adding fwnode links. Signed-off-by: Saravana Kannan Acked-by: Rafael J. Wysocki Reviewed-by: Rob Herring --- drivers/base/core.c | 5 +++-- drivers/firmware/efi/sysfb_efi.c | 2 +- drivers/of/property.c | 2 +- include/linux/fwnode.h | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 9828da9b933c..adeff041d472 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -92,12 +92,13 @@ static int __fwnode_link_add(struct fwnode_handle *con, return 0; } =20 -int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) +int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup, + u8 flags) { int ret; =20 mutex_lock(&fwnode_link_lock); - ret =3D __fwnode_link_add(con, sup, 0); + ret =3D __fwnode_link_add(con, sup, flags); mutex_unlock(&fwnode_link_lock); return ret; } diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_= efi.c index 456d0e5eaf78..cc807ed35aed 100644 --- a/drivers/firmware/efi/sysfb_efi.c +++ b/drivers/firmware/efi/sysfb_efi.c @@ -336,7 +336,7 @@ static int efifb_add_links(struct fwnode_handle *fwnode) if (!sup_np) return 0; =20 - fwnode_link_add(fwnode, of_fwnode_handle(sup_np)); + fwnode_link_add(fwnode, of_fwnode_handle(sup_np), 0); of_node_put(sup_np); =20 return 0; diff --git a/drivers/of/property.c b/drivers/of/property.c index b71267c6667c..bce849f21ae2 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1085,7 +1085,7 @@ static void of_link_to_phandle(struct device_node *co= n_np, tmp_np =3D of_get_next_parent(tmp_np); } =20 - fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np)); + fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0); } =20 /** diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 2a72f55d26eb..c964749953e3 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -210,7 +210,8 @@ static inline void fwnode_dev_initialized(struct fwnode= _handle *fwnode, } =20 extern bool fw_devlink_is_strict(void); -int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup); +int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup, + u8 flags); void fwnode_links_purge(struct fwnode_handle *fwnode); void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode); =20 --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Sat Feb 7 18:20:52 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 D887418627 for ; Thu, 22 Feb 2024 03:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573597; cv=none; b=jWd0/8rG18M6SzpXQVoH4hFBkZg3Wk5ZNzHsE7JrUa9d80nw3o+HGaNZuiUzsjvEqLXRDdMJZIglSRBjdD8X7gOcTeGkIE+YhmYfQHhI6WmHq8tQnufLZR1vMzkyF2YzrLF0Zd1oiK9LN3JXUDftyv09Kk2xEz7kinISUz9ptt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573597; c=relaxed/simple; bh=/z8Eu/KeLJ7IbgMJCENA0qx1maElopa30GOhgYXJfiQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=Vt/mKKgUCZuyZGs49FvmGPaoPDNGO6T11arruOETTHFst8s/z6oOvUDThVA+cYTuFFrOgdyjC1TqzNPDDl1JM4DYUk8vkcEhoeas0zgMRGRuYjsgXvnlmeocGCkLMQuUjQPviyOFUqhEoFj3SzyewXX9fDk1IXCBWdqmPbJT4sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Qhk18JYI; arc=none smtp.client-ip=209.85.219.202 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=flex--saravanak.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Qhk18JYI" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dccc49ef73eso8878115276.2 for ; Wed, 21 Feb 2024 19:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708573595; x=1709178395; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hz8i/GyBU5B3ALvYkkFzM0iQaG+ZmlRW+5k11B+Bktg=; b=Qhk18JYIGwL3GWM+1Rd5LcpQxWCDDMvoSRBadEndPXts/NfnyFIwS5BTkz9TnHF+ef udacYejdBUnvuRa1naCEirLw6crLMjA5CVNfxhveuNK4iTu0A3rpNxusk6/gPRBGvg9J wiZFepL3apuxJu9TbmhrnzYnvy5uSRCio5Ejek/akPWfrajT96v10RURaS/wsgc8roTc CBjKXenOBc7q7jipaM8ak19oHx4LCNr3Fj+iYpRwkbhMxu+x50eIuUCkM+YlbpbMiMeW 3V5TYr6m/sI545Yqu7+sJDVYHMqX1lth7/+/HXTTd9/1t3bBvNEn2wsJ5fYodRsrQ0ch hitA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708573595; x=1709178395; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hz8i/GyBU5B3ALvYkkFzM0iQaG+ZmlRW+5k11B+Bktg=; b=OoVU3urfYKmnMUkThXaCS8iWXJtzicJv0kvbc/mEy6U5OdKmxfyigxcIgXCdHcalrL CWjlv3OyP9IBClBV0qXmzANjANobWXhvvXwy/0jcIWMWnICgPxKUZFkORDuxodyPr1uK qZfWcBwNpdEbai3gvYwCpi2lpw9CwWOUsDkkIm26+laNpHTQemMr26g42MyUUHd4v2ge UNd63/OPNF+zi96LCcBd7QiptI3Rqz8ZOhhSuQONw7kk0DRa2BJdGXX8zoK7Gj4+PEHL L+/Eoss+EkvYTknYmflEL1EhYiFqOtPuY4v0yHu3ZSsXBbWzAe9TD4gbaJSkl3wECMMp 1vdw== X-Forwarded-Encrypted: i=1; AJvYcCVf8g8xlz6pz1csxGe9bsuu/E2xvUfmVsDb6ZmY/6vMtLsDKz3fCWM5rWStN+gfBoDy1Q0C6ru4yyplKGoh0bUT/L8znh/U58G55eLl X-Gm-Message-State: AOJu0YzcUZ0ehSVcmtWrslCq0wKaSgSx5+Dtb4OG7XWGpKGIJILeWbZ5 vILIBz6GLIdgyEdNcc+DDpSLDQ1zUgOk0/XcHRtvSv9qUt5fMT43tCjEAjC/O6ku/MtfE29cFl+ okuCnuRsGnWS8iw== X-Google-Smtp-Source: AGHT+IF3QQPEtZbXiIqHornd0y/4FT86dntj5KuKg8uawdGZql13WDvoR73iyo2QI20QtUg6WnsI1hRNMe7av2k= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:451c:c6c5:1fb1:a2a1]) (user=saravanak job=sendgmr) by 2002:a05:6902:1891:b0:dc6:e20f:80cb with SMTP id cj17-20020a056902189100b00dc6e20f80cbmr69205ybb.3.1708573594920; Wed, 21 Feb 2024 19:46:34 -0800 (PST) Date: Wed, 21 Feb 2024 19:46:20 -0800 In-Reply-To: <20240222034624.2970024-1-saravanak@google.com> Message-Id: <20240222034624.2970024-3-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240222034624.2970024-1-saravanak@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Subject: [PATCH v4 2/4] driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link From: Saravana Kannan To: Saravana Kannan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A fwnode link between specific supplier-consumer fwnodes can be added multiple times for multiple reasons. If that dependency doesn't exist, deleting the fwnode link once doesn't guarantee that it won't get created again. So, add FWLINK_FLAG_IGNORE flag to mark a fwnode link as one that needs to be completely ignored. Since a fwnode link's flags is an OR of all the flags passed to all the fwnode_link_add() calls to create that specific fwnode link, the FWLINK_FLAG_IGNORE flag is preserved and can be used to mark a fwnode link as on that need to be completely ignored until it is deleted. Signed-off-by: Saravana Kannan Acked-by: Rafael J. Wysocki Reviewed-by: Rob Herring --- drivers/base/core.c | 9 ++++++++- include/linux/fwnode.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index adeff041d472..fac017657d25 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1012,7 +1012,8 @@ static struct fwnode_handle *fwnode_links_check_suppl= iers( return NULL; =20 list_for_each_entry(link, &fwnode->suppliers, c_hook) - if (!(link->flags & FWLINK_FLAG_CYCLE)) + if (!(link->flags & + (FWLINK_FLAG_CYCLE | FWLINK_FLAG_IGNORE))) return link->supplier; =20 return NULL; @@ -1963,6 +1964,9 @@ static bool __fw_devlink_relax_cycles(struct device *= con, } =20 list_for_each_entry(link, &sup_handle->suppliers, c_hook) { + if (link->flags & FWLINK_FLAG_IGNORE) + continue; + if (__fw_devlink_relax_cycles(con, link->supplier)) { __fwnode_link_cycle(link); ret =3D true; @@ -2041,6 +2045,9 @@ static int fw_devlink_create_devlink(struct device *c= on, int ret =3D 0; u32 flags; =20 + if (link->flags & FWLINK_FLAG_IGNORE) + return 0; + if (con->fwnode =3D=3D link->consumer) flags =3D fw_devlink_get_flags(link->flags); else diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index c964749953e3..21699eee9641 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -53,8 +53,10 @@ struct fwnode_handle { * fwnode link flags * * CYCLE: The fwnode link is part of a cycle. Don't defer probe. + * IGNORE: Completely ignore this link, even during cycle detection. */ #define FWLINK_FLAG_CYCLE BIT(0) +#define FWLINK_FLAG_IGNORE BIT(1) =20 struct fwnode_link { struct fwnode_handle *supplier; --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Sat Feb 7 18:20:52 2026 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 9169B1B599 for ; Thu, 22 Feb 2024 03:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573602; cv=none; b=EQ1hMcqPnIG1b97n+WoDXpVqIvCb8/F6mlmE3oCP0SJTX1UtL2gwgUacGYWZf5jwAX4y7TzpiYHKw8frbk4q8M0goND4D8/jVnHyXgKoHtuk8S/Dvw20QZ9EVhL02Ug8CMxgge1JdK4jRTV8mwGUjDUNop4FeyG08GT+Sj9ufZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573602; c=relaxed/simple; bh=cp0XJ1vg7N+tq7T/hQqrmLoRlQ0Tu1sLQF3XCorNNhs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=Eme08yPV1iPSrdNEbpTM0Tl0T9JMs8NuPi+gaBG4B+aXAlbTafNrmqImpfAVoclaJyXrj+8+RoltAeuHdA0wk7eFp6xwSgClhq6dWZn6GB/5pNaW7C5T8wHp49ErRwDu4vda8Ev+Pkm+JDmuh427GKu+Bm98vWlItMUG/OaBVRk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=eKdfwIsH; arc=none smtp.client-ip=209.85.128.201 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=flex--saravanak.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eKdfwIsH" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-602dae507caso122707567b3.0 for ; Wed, 21 Feb 2024 19:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708573598; x=1709178398; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wH33w5aG2BffksVtrB54fX5fBHp+P/Q2DjXoHgc9nyE=; b=eKdfwIsH5w8eFcUFGOrDNG/nCGjXPZf/pnkbbo2V+M9kBdTsxftXqvex1bZH3QyPej vf5qtS1JqXIFAxAKDryQ3FdMVe6Mp+0bq/8FakzEjuZ6Ayub6tPlOUjT267kX4ZXMWe1 OVgbXZVa9Koexehbjaw2ii3FHjPNqATNH3DqUJwaQ7ORk+WovRD8rb/d+jknFyyxFFwA nWq3UA2LLLkKlzygJIKHDrR0Vj5AdeuXqgQvGe7tJ6P0tkyO0ECvctCa/9cKqJQpvFbM 2dAbDJMzfQWssNIDHl5xALh9sYW4wMQ0iiw5i9lvYtzMDQGjc7nG8a5ZB2zfrmHCbW4P mo8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708573598; x=1709178398; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wH33w5aG2BffksVtrB54fX5fBHp+P/Q2DjXoHgc9nyE=; b=H622Cml7eW0Wl3kdOmp9FoFgqjMX6U9hjc5jR7pqPvJpGxqO/HdvboOUsKXXZoesA3 SKu//8hfRzwGSLQYYSfFXVe4kqgAeREzbjmXXHZLtLh14y3wP4lV5jwpXZSGXH/QIslK 4FWOpGYP68xZhFHHOQ1diqdWK0GWVD6pji2jkMLY0dgObtJ1T5rWGgw83h2sFSNAP0YD uSrm0jo0UmU2DTDj3ZzbxQHJdclAH9TBasUdPXxQ8fdDFKFVc5S9JCrTCKZDaRXPN2es Kiau4ZWMFX0TS3+T1yLiSf23i6tViyXnpni3JuGiTKa38L7EGwpJcU/Pv6WCsJd+uK/U l6Fg== X-Forwarded-Encrypted: i=1; AJvYcCWnSdDqzyeenTvvc2WCwNpJmDOxuwKWRDEabsH3s15n/G/hxOH8J2IH0c8LnP1FuFiwVq6cgbz4Ag2UIvaqxKWgPbSx1guVrBLqrC0r X-Gm-Message-State: AOJu0Yz9PQeSZ2PFiGfkWVJtEeA5ZL75Q9Ps6hSCMjqY3OalowQL9jEU NVG0Y8HQJxmBKBJU5UPrNKp9KzkU1uFq9mLIz/uJUXar9E5ESrTBfO80pii8p7aDrF5kCRCnNne dO/firH12995lqw== X-Google-Smtp-Source: AGHT+IECAd++kNqbj7P3O+ZaufolEwh1k0tAwEFsFNnN5Q1YIPOlFxgE+MiOrvGczCSWeJaEYcSnAoQ6Lx71cos= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:451c:c6c5:1fb1:a2a1]) (user=saravanak job=sendgmr) by 2002:a25:ef09:0:b0:dc6:53c3:bcbd with SMTP id g9-20020a25ef09000000b00dc653c3bcbdmr325368ybd.7.1708573598675; Wed, 21 Feb 2024 19:46:38 -0800 (PST) Date: Wed, 21 Feb 2024 19:46:21 -0800 In-Reply-To: <20240222034624.2970024-1-saravanak@google.com> Message-Id: <20240222034624.2970024-4-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240222034624.2970024-1-saravanak@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Subject: [PATCH v4 3/4] dt-bindings: Add post-init-providers property From: Saravana Kannan To: Saravana Kannan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The post-init-providers property can be used to break a dependency cycle by marking some provider(s) as a post device initialization provider(s). This allows an OS to do a better job at ordering initialization and suspend/resume of the devices in a dependency cycle. Signed-off-by: Saravana Kannan Acked-by: Rafael J. Wysocki Reviewed-by: Rob Herring --- .../bindings/post-init-providers.yaml | 105 ++++++++++++++++++ MAINTAINERS | 13 ++- 2 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/post-init-providers.y= aml diff --git a/Documentation/devicetree/bindings/post-init-providers.yaml b/D= ocumentation/devicetree/bindings/post-init-providers.yaml new file mode 100644 index 000000000000..92eb9a027443 --- /dev/null +++ b/Documentation/devicetree/bindings/post-init-providers.yaml @@ -0,0 +1,105 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2020, Google LLC. All rights reserved. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/post-init-providers.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Post device initialization providers + +maintainers: + - Saravana Kannan + +description: | + This property is used to indicate that the device(s) pointed to by the + property are not needed for the initialization of the device that lists = this + property. This property does not make a device (that's previously not a + provider) into a provider. It simply downgrades an existing provider to a + post device initialization provider. + + A device can list its providers in devicetree using one or more of the + standard devicetree bindings. By default, it is assumed that the provider + device can be initialized before the consumer device is initialized. + + However, that assumption cannot be made when there are cyclic dependenci= es + between devices. Since each device is a provider (directly or indirectly= ) of + the others in the cycle, there is no guaranteed safe order for initializ= ing + the devices in a cycle. We can try to initialize them in an arbitrary or= der + and eventually successfully initialize all of them, but that doesn't alw= ays + work well. + + For example, say, + * The device tree has the following cyclic dependency X -> Y -> Z -> X (= where + -> denotes "depends on"). + * But X is not needed to fully initialize Z (X might be needed only when= a + specific functionality is requested post initialization). + + If all the other -> are mandatory initialization dependencies, then tryi= ng to + initialize the devices in a loop (or arbitrarily) will always eventually= end + up with the devices being initialized in the order Z, Y and X. + + However, if Y is an optional provider for X (where X provides limited + functionality when Y is not initialized and providing its services), then + trying to initialize the devices in a loop (or arbitrarily) could end up= with + the devices being initialized in the following order: + + * Z, Y and X - All devices provide full functionality + * Z, X and Y - X provides partial functionality + * X, Z and Y - X provides partial functionality + + However, we always want to initialize the devices in the order Z, Y and X + since that provides the full functionality without interruptions. + + One alternate option that might be suggested is to have the driver for X + notice that Y became available at a later point and adjust the functiona= lity + it provides. However, other userspace applications could have started us= ing X + with the limited functionality before Y was available and it might not be + possible to transparently transition X or the users of X to full + functionality while X is in use. + + Similarly, when it comes to suspend (resume) ordering, it's unclear which + device in a dependency cycle needs to be suspended/resumed first and try= ing + arbitrary orders can result in system crashes or instability. + + Explicitly calling out which link in a cycle needs to be broken when + determining the order, simplifies things a lot, improves efficiency, mak= es + the behavior more deterministic and maximizes the functionality that can= be + provided without interruption. + + This property is used to provide this additional information between dev= ices + in a cycle by telling which provider(s) is not needed for initializing t= he + device that lists this property. + + In the example above, Z would list X as a post-init-providers and the + initialization dependency would become X -> Y -> Z -/-> X. So the best o= rder + to initialize them becomes clear: Z, Y and then X. + +select: true + +properties: + post-init-providers: + # One or more providers can be marked as post initialization provider + description: + List of phandles to providers that are not needed for initializing or + resuming this device. + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + maxItems: 1 + +additionalProperties: true + +examples: + - | + gcc: clock-controller@1000 { + compatible =3D "vendor,soc4-gcc", "vendor,soc1-gcc"; + reg =3D <0x1000 0x80>; + clocks =3D <&dispcc 0x1>; + #clock-cells =3D <1>; + post-init-providers =3D <&dispcc>; + }; + dispcc: clock-controller@2000 { + compatible =3D "vendor,soc4-dispcc", "vendor,soc1-dispcc"; + reg =3D <0x2000 0x80>; + clocks =3D <&gcc 0xdd>; + #clock-cells =3D <1>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 9ed4d3868539..feec740239c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6060,12 +6060,6 @@ S: Maintained F: drivers/base/devcoredump.c F: include/linux/devcoredump.h =20 -DEVICE DEPENDENCY HELPER SCRIPT -M: Saravana Kannan -L: linux-kernel@vger.kernel.org -S: Maintained -F: scripts/dev-needs.sh - DEVICE DIRECT ACCESS (DAX) M: Dan Williams M: Vishal Verma @@ -8300,6 +8294,13 @@ F: include/linux/firewire.h F: include/uapi/linux/firewire*.h F: tools/firewire/ =20 +FIRMWARE DEVICE LINK (fw_devlink) +M: Saravana Kannan +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/post-init-providers.yaml +F: scripts/dev-needs.sh + FIRMWARE FRAMEWORK FOR ARMV8-A M: Sudeep Holla L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Sat Feb 7 18:20:52 2026 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 3FD2A1B819 for ; Thu, 22 Feb 2024 03:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573606; cv=none; b=c/BLYryRoq9CMTg3Y83MWqJji/+UvXWfMsuBXxzSQQn3tPNrIcjosmJrdGJOqgzR8egiIvicm4OLn07KRjO4+ZLWz8AeBAMHw6+oJE1VTuO5ny101AEOEDuSp7anjHFempAfdigM50P2AO85mjAUIgyMLA3Q+lw0bECnCm6Vrj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708573606; c=relaxed/simple; bh=BYJ0NZJqbtsDWKL5M2UsBKoeU9XD22jULrfryxgvv50=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=A2W7vmNH1ie5PWB8BloS4tVENmITJ04M8SwhlFYxAFMdb9AHRYfekz2EUFhdPbDKWriKKAWzrakzOYPIT/mhmsx2u3CA2BZ8pgDt08kcHEsO6O+TIT6GF6QchKKbQdSNtO4S81bm95JbG1tDwAwgaNiPPwqu9aEgmFqYVY7e7ZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zRy22DHV; arc=none smtp.client-ip=209.85.128.201 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=flex--saravanak.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zRy22DHV" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6085e433063so51729177b3.1 for ; Wed, 21 Feb 2024 19:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708573602; x=1709178402; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=raWZBAYgki529t/WhxJsWod/PF9BbEcSvIxTt/14UCc=; b=zRy22DHV0i/8GoOTEt5NG9RaIEs4ONI6qGKz6htHAyLu0Y+ze9SUdiW2cjkX0yaar/ 5py1BMb+AXTxLTxM/r5bmJE/TFtQveF8t6Wh4y7/mE/GObgFuXoGxWoJ0XU3zlQU9Y0l MkAZ9LzptdK/LCKuVz9Q4aohP6s4kottbwx+xHwg/6IMFQj+xwCiUSQO2oO5+zfKYP3L iCyh2XeE6ocTm9+OUU1ti8E5mdzxOUj3R+ooLnffQtg2CgOgdDcZs6Ej8ixOe5QcCubq meaulOtQklEC+J1kZ7eq6BQS8uW4mXGYNol8htPnb0gRT2+jSbrC+kG4X5ZpCydPSwNY +sgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708573602; x=1709178402; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=raWZBAYgki529t/WhxJsWod/PF9BbEcSvIxTt/14UCc=; b=ppTbO9oxSnR8hP7p7/wVKlX1prjPUwwM5JPxeBaE0kvw7Mh0CI+qMPPaYCJbb/crTd 28gO/S6VqSN7nxdK4SnFN4Q15HT7hyd7Ws15HWIcqNO1qhGVVEEchz3n68T80IbNbx/L jIFIg9jN75gy2Wu+WR9VNgt4duYC48uEvfV7H+OQKQYogMu2vYwtvqNzCFkNqh3eZ41B f988Qlo3ZUJn1xM/K0wbwcis3FUmdXuNlFz9QOLF/qWJ5hM67EKWKHVf7bMGsL6wDVyT 0ageVRSR1nitZe/+2atLBHpKeQYRAes1kV0Frrj9rlfTDSE1pS/eiMSWwk7qgqR5zdFO iFDQ== X-Forwarded-Encrypted: i=1; AJvYcCX6npc7tT/Z7vkD98llJBJd5VqG4U+TwIPhrz16zj2DF88oaWSDREUfVUGzdjFcfuMoHKLAl9WcGU8fx2ajec/6QCeLIz7+ejcH4CQM X-Gm-Message-State: AOJu0Yw86kq88dX6ry8O4EFUNcIqggRYPNR5MURQZQr9Ul+cByphPrCT Mltc5vGY1IvSipwsWY0Vx5GJn+yP1DB5kAFHDAU0zrIucHXGMkyYAAZ8Mfi7LQC2vfgPTmXo9QW fCQGZiE3usQLZ/w== X-Google-Smtp-Source: AGHT+IE/lOZLkCoDwwKEREqFgcV+j6qm2injtDVFnE3QKKkoaWAEUaYOgBuNsQDaJd9X9bCZCw8l/KV68FOgUzU= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:451c:c6c5:1fb1:a2a1]) (user=saravanak job=sendgmr) by 2002:a25:b47:0:b0:dc7:8e30:e2e3 with SMTP id 68-20020a250b47000000b00dc78e30e2e3mr329609ybl.2.1708573602344; Wed, 21 Feb 2024 19:46:42 -0800 (PST) Date: Wed, 21 Feb 2024 19:46:22 -0800 In-Reply-To: <20240222034624.2970024-1-saravanak@google.com> Message-Id: <20240222034624.2970024-5-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240222034624.2970024-1-saravanak@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Subject: [PATCH v4 4/4] of: property: fw_devlink: Add support for "post-init-providers" property From: Saravana Kannan To: Saravana Kannan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for this property so that dependency cycles can be broken and fw_devlink can do better probe/suspend/resume ordering between devices in a dependency cycle. Signed-off-by: Saravana Kannan Acked-by: Rafael J. Wysocki Reviewed-by: Rob Herring --- drivers/of/property.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index bce849f21ae2..15ccad6cba4a 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1066,7 +1066,8 @@ of_fwnode_device_get_match_data(const struct fwnode_h= andle *fwnode, } =20 static void of_link_to_phandle(struct device_node *con_np, - struct device_node *sup_np) + struct device_node *sup_np, + u8 flags) { struct device_node *tmp_np =3D of_node_get(sup_np); =20 @@ -1085,7 +1086,8 @@ static void of_link_to_phandle(struct device_node *co= n_np, tmp_np =3D of_get_next_parent(tmp_np); } =20 - fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0); + fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), + flags); } =20 /** @@ -1198,6 +1200,8 @@ static struct device_node *parse_##fname(struct devic= e_node *np, \ * to a struct device, implement this ops so fw_devlink can use it * to find the true consumer. * @optional: Describes whether a supplier is mandatory or not + * @fwlink_flags: Optional fwnode link flags to use when creating a fwnode= link + * for this property. * * Returns: * parse_prop() return values are @@ -1210,6 +1214,7 @@ struct supplier_bindings { const char *prop_name, int index); struct device_node *(*get_con_dev)(struct device_node *np); bool optional; + u8 fwlink_flags; }; =20 DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells") @@ -1240,6 +1245,7 @@ DEFINE_SIMPLE_PROP(leds, "leds", NULL) DEFINE_SIMPLE_PROP(backlight, "backlight", NULL) DEFINE_SIMPLE_PROP(panel, "panel", NULL) DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells") +DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") =20 @@ -1349,6 +1355,10 @@ static const struct supplier_bindings of_supplier_bi= ndings[] =3D { { .parse_prop =3D parse_regulators, }, { .parse_prop =3D parse_gpio, }, { .parse_prop =3D parse_gpios, }, + { + .parse_prop =3D parse_post_init_providers, + .fwlink_flags =3D FWLINK_FLAG_IGNORE, + }, {} }; =20 @@ -1393,7 +1403,8 @@ static int of_link_property(struct device_node *con_n= p, const char *prop_name) : of_node_get(con_np); matched =3D true; i++; - of_link_to_phandle(con_dev_np, phandle); + of_link_to_phandle(con_dev_np, phandle, + s->fwlink_flags); of_node_put(phandle); of_node_put(con_dev_np); } --=20 2.44.0.rc0.258.g7320e95886-goog