From patchwork Sat Feb 10 03:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 771976 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 8852E6FC2 for ; Sat, 10 Feb 2024 03:05:57 +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=1707534359; cv=none; b=Ik28qGwjW2PuxqYfKF8V9AwoW6OcFy92p2w/1ad/OIzF11Z/soVOXmr7NgAYesO95xwBpOxWvnZwucbcAbBzIyOe7iWlWZkzxLX0V42Vowp1miiY2xYTcc0fslKebbGUrMnmAsevZrk5rwS+P6dbilVNZWy8u+6D9W7n8MRoJUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534359; c=relaxed/simple; bh=sWUmF3vh9o4HGU5Ho8G3VWDldprPEGq5gO9RSRL2L2Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=Vv0GhUguSUMPfA/yY6DuqFfzr48m2M3abwKOU2QhwWSM9FUjLSKWXFNtH2A+dOxCwa8zEuVIqrPmnHZDAj8UrAQi+g/o1ox5QEdmpwwmbnCb3AjSSHTIxhicZKOEAcsfwMbmndFPGsyYq9di7d3CxW9uUIoaNPTwjtGybLjRqcY= 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=ACCkEIVQ; 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="ACCkEIVQ" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so3339894276.2 for ; Fri, 09 Feb 2024 19:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707534356; x=1708139156; 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=+K3jZfz6ZJpM1n2dt5cwkWjr08+sSZMq2mLrsQ52mPs=; b=ACCkEIVQNhE4KkCsOxGvClYjkLYikGN2KYCOSdw7UtVsYTRhlxr4hCAHd0R/txQoQp 5gOShlogs+aw7kplnJEtN4GS2LeVT06Fb6gfhjOTC4g3Bp4WFB4Tgv84999Ch4/XTg1k XqVVk+eTOC8RlCF/F0jfJn3wiSJicTdw2oWtxCgVVZEasg+mgg+1Ky1i55kDf1rDr1pR WoVP3ktZ2zEZZNFf7oCTe4v1coTqLZNwh4X8tVzSqP32sS3EuKCBOSL1RDgck2zC+cGq L6cGeA4rPkfzGE4ltFsoJwxP7VMEWUmXobJsFySuQ/eYRGjiMyX3jkoDcy0SrASyn9Xq ba2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707534356; x=1708139156; 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=+K3jZfz6ZJpM1n2dt5cwkWjr08+sSZMq2mLrsQ52mPs=; b=BmVWqGpYWvg0XPtQ1VFFMhRRip9vfroFDxYZQenmwcQtRXHxwQNdaxIifkE1xYihdf 77ftGY/oXXVL6z3aG47B6QDH1MLqBt5DaxszCzFWljABowQm5pLMXhYWa6xLKCaTVyrm QbnAc4VUcUuAszpSyKKCF023dkP1A9eXIlu7bHZKi7ILXqD0gn2x8eccgj4DSul23NPY DEtm+i2OqUCIrNu+qD49oa6XHaE89ApaBNC9KVYS72AS4E9F5RaiiOLSgjO6KXX+IQFy 2Iw5+/ZogZYug2LVsndPOGUFtXRiCZnIAbDxm7ryuPqyfU+0lBoXmRdf1F+2n0i6hV3a x4mw== X-Gm-Message-State: AOJu0YzwUXCpAAh4RR8qt3JDjbx5cmdlzpcZqA7S0U2DOaXoT9klZQu0 fmYfZm1/kgQYgBuYxkMl+oSjQwZPXcwquaJNB1py+g7byUxMB5e1PhNdmv83Zv+uz+Kj7MAtrX+ Y36jbfp9Xl0sG0Q== X-Google-Smtp-Source: AGHT+IEuUhIzB6NfgqOv1GYf9HANpIJ7RQGUvhcvkW1GTzdVOwt9FN9NCTQ/qcg0HSbdsnUJKsK+9yZPAri1Q0M= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6b44:91e7:13e1:5d92]) (user=saravanak job=sendgmr) by 2002:a05:6902:4d0:b0:dc6:f59d:73fe with SMTP id v16-20020a05690204d000b00dc6f59d73femr242739ybs.13.1707534356597; Fri, 09 Feb 2024 19:05:56 -0800 (PST) Date: Fri, 9 Feb 2024 19:05:44 -0800 In-Reply-To: <20240210030549.4048795-1-saravanak@google.com> Message-Id: <20240210030549.4048795-2-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240210030549.4048795-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 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 Allow the callers to set fwnode link flags when adding fwnode links. Signed-off-by: Saravana Kannan --- 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 14d46af40f9a..33055001e08e 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; } -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; mutex_lock(&fwnode_link_lock); - ret = __fwnode_link_add(con, sup, 0); + ret = __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; - fwnode_link_add(fwnode, of_fwnode_handle(sup_np)); + fwnode_link_add(fwnode, of_fwnode_handle(sup_np), 0); of_node_put(sup_np); return 0; diff --git a/drivers/of/property.c b/drivers/of/property.c index 39a3ee1dfb58..751c11a28f33 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1085,7 +1085,7 @@ static void of_link_to_phandle(struct device_node *con_np, tmp_np = of_get_next_parent(tmp_np); } - 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); } /** 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, } 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); From patchwork Sat Feb 10 03:05:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 771622 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 AE57415E9C for ; Sat, 10 Feb 2024 03:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534363; cv=none; b=FZ4iElR8Orp9BYHWPl3A+HoBJRRhJqI/23Hikj18PlsNmHD94nyLKtpDh7BoB/AuRXgbu3OKc5OfvEiBSOsajlQEODQfJF106CoUhK62S5z1vUzBN22gBPv/Z1mo5BZu1SGlQ0XQufd0W/21tghWRt9urs4lAUeMnjejvXuzdcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534363; c=relaxed/simple; bh=iEDFuhE8mOQtSS/B79HZRgChFrCS7/VJXwJaloRdLeI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=QkxEU5F8LwWaeEDV38BWmnKgr3zartzNGc0C5RtiSdY8v/o4YsZVL0EZ/2u/uA51fafO+gDP3aHym+jzWXHK9MIjdpmC8xqqDaRa4t2tTujr4M2ZT/xrNm+9E79r1TJXnZPHlIYWtfpq1AbJh3ivmhbHEGIOn5/fjuzt2OhY2TU= 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=RJK37S4E; arc=none smtp.client-ip=209.85.214.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="RJK37S4E" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1d968aebbd1so18658305ad.1 for ; Fri, 09 Feb 2024 19:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707534361; x=1708139161; 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=5fSy7E0mRmW50qOB3N+Jt7mdFvxY1Kvxhhy9gLys//A=; b=RJK37S4EgogTgmG8r4v6aIVIVO9nqQFNXTAaU1tT2aRuHhL0IXlmIl3UcqVF0P+nsm 20lzJw1/s5hMABm7QxC5NOEuI0hIdfErY1usuhpHFCs0tl5v9ZSOGus/z3zrFZDNoJqA aeHf+f3RprulHXkbfiOAkG9xeaSqswgPShQXHJX4WowQxb2st6Aawr7zPSr3WKOytRhj sRZeKsidmhC9xO5ufN2pHzlkWKYIDuLWEMGuf8b6o/YdM/FAu2yG4gUnCNY1Pf1No+ky Ct/NksQG/Xvl/EuAdjTuwk6zzJxITcV3MgNC/oqVGX4376xG64Ayaq3QSkO5Gq4SDDaL 4xVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707534361; x=1708139161; 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=5fSy7E0mRmW50qOB3N+Jt7mdFvxY1Kvxhhy9gLys//A=; b=Fyh4Z7TIplWPXEtJDqK3b9UUbMpck8H26vp/RDdtputDpc+dOgNvr4SLWzq1YXT27n D0aJc7pi5tfUk2dB1sE4K8MQ5ZKNNzxpM6PMqwAZq9UFFEl9BK3OiSnEV0f15gMMNEWs VrrP4tnQffZtfJLzTPbR3fJgSNjgSB2hlfRBnSopWeiMNTYR2g1U33JfRU/HQqPkIflJ zVLb3aekn5eH1YvO7EmtYGw1ux/32HF8H9rG5nRFU0vOly3D8rBslLSRfevvlB4mZJjD FLxJ1Y7tO/RAGJxAvC9v753r1yllH8gxDG3FCEU6D+4jvt9FDlXhhjXNAb+cEBLKTACf 1dwA== X-Forwarded-Encrypted: i=1; AJvYcCXOJhwj5WvMAiMy9KzuCu8mGKxfQyIhQDSzncywsnaeQl/B/o1AUyC+l1uUAzO5iftnC71amFsrbVuioR+BpjeSWXaHjUdn8Xfr X-Gm-Message-State: AOJu0YziuwiQtLktRO/sIW/+RcubTnuY43lwldkgyn0c8euD8Pw0+7oE SIWnAc00m+r1PDf6qqln3aH+FVsXviEcFpLpnr772T/F57KOu0sk4Lc418X+ZyC+/Hi0LjGKMhc Pz0YikKzK+UYiJg== X-Google-Smtp-Source: AGHT+IFWQd3ADLGIN9R/9xvZhHRJ+RPurPLpihD0sq3xyJZb/dJ7ssC6WTUszuSQfK+LYMB6XWbO5ag2vHFXWK0= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6b44:91e7:13e1:5d92]) (user=saravanak job=sendgmr) by 2002:a17:902:d4ca:b0:1d9:5d39:9438 with SMTP id o10-20020a170902d4ca00b001d95d399438mr2814plg.4.1707534360849; Fri, 09 Feb 2024 19:06:00 -0800 (PST) Date: Fri, 9 Feb 2024 19:05:45 -0800 In-Reply-To: <20240210030549.4048795-1-saravanak@google.com> Message-Id: <20240210030549.4048795-3-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240210030549.4048795-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 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 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 --- 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 33055001e08e..bd762d90dac0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1010,7 +1010,8 @@ static struct fwnode_handle *fwnode_links_check_suppliers( return NULL; 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; return NULL; @@ -1960,6 +1961,9 @@ static bool __fw_devlink_relax_cycles(struct device *con, } 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 = true; @@ -2033,6 +2037,9 @@ static int fw_devlink_create_devlink(struct device *con, int ret = 0; u32 flags; + if (link->flags & FWLINK_FLAG_IGNORE) + return 0; + if (con->fwnode == link->consumer) flags = 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) struct fwnode_link { struct fwnode_handle *supplier; From patchwork Sat Feb 10 03:05:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 771975 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 6DDF31EB49 for ; Sat, 10 Feb 2024 03:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534369; cv=none; b=mnvFAFGrWJ6pTRH8z9DTCGi6AHk7eKTbMgllwp+EYgA/7T27LEk+uZbLPhpIahUDp6/P1coe4meiC+gslTSY+HQfz4ESY9h3YKym5FX9bQifE5V+3VPhvPfOTmSR2qIchD/pAicrsdHIUDJ/0KGv1o+P7WfUqRN0FQcSavnDJPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534369; c=relaxed/simple; bh=DDHVFJw3laeMHNAD1vbR4GSUPDGUWbNquUH9HPPVOrQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=p5uIXY7Gw6zOr1smgGDawfCca5HrowP7sAsfz8YQeVPMMxzo2kYpT+xgr/Ye4eR4wDBu6eVaalw1A+ZeL7JhGOuikrruHfsAk8dPfP9SScm9vmn/zixFrllo/rSxktej9Ac35nOY3EyJuw3XqBDsTsGCw7eA5Kc0i7gOzfp+oVI= 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=MmwUDtzn; arc=none smtp.client-ip=209.85.128.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="MmwUDtzn" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-604a4923adaso29403217b3.0 for ; Fri, 09 Feb 2024 19:06:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707534365; x=1708139165; 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=EuboiLM3PiYaUht/sxY2s97Ou0aQoJajqakxuwnzARA=; b=MmwUDtznU4pxEV4YFkbbIuvyK8q+MXrRpXGgAtD4vZCbDvQHhZ8VOe8H4NXU/A7iEp k6c7lTUevqRFn/tAlvcZxnv29/YviWAEdZVHZ3sFNj9Svs2WHV1k5oxqZWcCIPOTOx9C 5zEBzpCPUNzTrT3Y1AKjUaceKNe2nREYuB7AtTaBfoRFn8n8aOthXZ+e2vAFOw93n9AQ EZKB5pgOEGDw7rRJMVW3mqrmnCS4181Uv+dJEG9fcodVrroqyZIRy8wjTiF1jPwVEaOf Td3NDLI0u5TQJYZMzrH1cICk97SEVJcELB+Y/2AyYj9HdWF8qZ4fa9FNnPh8ZHw8iQGl Avqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707534365; x=1708139165; 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=EuboiLM3PiYaUht/sxY2s97Ou0aQoJajqakxuwnzARA=; b=qvA9GuMbK+UiPvp+wRAJPw96LiGmexyDWr8Jxs1bumavp/sVUgXkBgwZ20ZjYba1mr wkg8G57BuWoLUhG2LiEpJHhcyy4G0SUnmnwk1SkLyBvk64IoGA3EOg5WJKJiq4bi+My8 rXwGkamqnlQR8SpmwbHFUhm3FgCPyYPIse+vG8csuHtpWk+Ub+LI/EcPMQsP5guzcYjn vFUj1hPHUs7Bm8Bb53z2eWhY94gpFbAERyRhBIebCX7USlyXrFsCZAzLtS485Ft1aYNt v8gUkDL9dhN2sZfbsTJVpk2hj8BVcix07CVBgk6JwLh5wg2gbLL/SeieLfc/XWszBXxf l2vA== X-Gm-Message-State: AOJu0YweJWl3Bd8axCy9TQF+t/AUNcyb4qgrGxv7jZYfzlvt5sxo5h2U zCQy3g0LqDMO5wzS0QJU54sBtbLZGrpdeu0dDqRiJC/kHmqnd3AuZRBBserdPXd5KFnQJIkineE xrC7OSA4PNtc/HA== X-Google-Smtp-Source: AGHT+IE/vc7byscSKQlhBHSuEvA98GUKQoY9I3PklaoxpxmeP7d7CBzzkKxMJj2zLKm1tFym5Jaqg+ad29EuZwY= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6b44:91e7:13e1:5d92]) (user=saravanak job=sendgmr) by 2002:a05:690c:884:b0:604:d53e:4616 with SMTP id cd4-20020a05690c088400b00604d53e4616mr179243ywb.6.1707534365489; Fri, 09 Feb 2024 19:06:05 -0800 (PST) Date: Fri, 9 Feb 2024 19:05:46 -0800 In-Reply-To: <20240210030549.4048795-1-saravanak@google.com> Message-Id: <20240210030549.4048795-4-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240210030549.4048795-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 3/4] dt-bindings: Add post-init-supplier 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 The post-init-supplier property can be used to break a dependency cycle by marking some supplier(s) as a post device initialization supplier(s). This allows the kernel to do a better job at ordering initialization and suspend/resume of the devices in a dependency cycle. Signed-off-by: Saravana Kannan --- .../bindings/post-init-supplier.yaml | 99 +++++++++++++++++++ MAINTAINERS | 3 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml diff --git a/Documentation/devicetree/bindings/post-init-supplier.yaml b/Documentation/devicetree/bindings/post-init-supplier.yaml new file mode 100644 index 000000000000..cf9071ecd06e --- /dev/null +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2018 Linaro Ltd. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/post-init-supplier.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Post device initialization supplier + +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. + + A device can list its suppliers in devicetree using one or more of the + standard devicetree bindings. By default, it would be safe to assume the + supplier device can be initialized before the consumer device is initialized. + + However, that assumption cannot be made when there are cyclic dependecies + between devices. Since each device is a supplier (directly or indirectly) of + the others in the cycle, there is no guaranteed safe order for initalizing + the devices in a cycle. We can try to initialize them in an arbitrary order + and eventually successfully initialize all of them, but that doesn't always + 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 if requested post initialization). + + If all the other -> are mandatory initialization dependencies, then trying 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 supplier 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 functionality + it provides. However, other userspace applications could have started using 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 trying + 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, makes + the behavior more deterministic and maximizes the functionality that can be + provided without interruption. + + This property is used to provide this additional information between devices + in a cycle by telling which supplier(s) is not needed for initializing the + device that lists this property. + + In the example above, Z would list X as a post-init-supplier and the + initialization dependency would become X -> Y -> Z -/-> X. So the best order + to initialize them become clear: Z, Y and then X. + +properties: + # A dictionary of DT properties for this binding schema + post-init-supplier: + # One or more suppliers can be marked as post initialization supplier + minItems: 1 + description: + List of phandles to suppliers that are not needed for initializing or + resuming this device. + $ref: /schemas/types.yaml#/definitions/phandle + +examples: + - | + gcc: general-clock-controller@1000 { + compatible = "vendor,soc4-gcc", "vendor,soc1-gcc"; + reg = <0x1000 0x80>; + clocks = <&dispcc 0x1> + #clock-cells = <1>; + post-init-supplier = <&dispcc>; + }; + dispcc: display-clock-controller@2000 { + compatible = "vendor,soc4-dispcc", "vendor,soc1-dispcc"; + reg = <0x2000 0x80>; + clocks = <&gcc 0xdd> + #clock-cells = <1>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3dfe7ea25320..40fd498543a5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6055,10 +6055,11 @@ S: Maintained F: drivers/base/devcoredump.c F: include/linux/devcoredump.h -DEVICE DEPENDENCY HELPER SCRIPT +FIRMWARE DEVICE LINK (fw_devlink) M: Saravana Kannan L: linux-kernel@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/post-init-supplier.yaml F: scripts/dev-needs.sh DEVICE DIRECT ACCESS (DAX) From patchwork Sat Feb 10 03:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 771621 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 531362A1AA for ; Sat, 10 Feb 2024 03:06:11 +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=1707534372; cv=none; b=Jy15pxrZk4GF3TxBFEwaWj9zja2+edA30vUEsa52N40uqPn4zVpcHzfA79/cn1OJuzC/Fwew/nP0FfuADMQ9H5tnRewkZNACkXrrsQ6kFT2DL+Yy40c8WmggKkPMH8PoYg7H6etLJdkveZ13aKWnyJ0s8sMgqEYAAY6W17PWblM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534372; c=relaxed/simple; bh=09nOuvy1xCjK1iYqCopDQXrnPVKpNm2a5rJaJXsm9lU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=V62XNQCNaSyQs0APOrTIRyAdFp5qKgLp/ECrs9ap1hd4NgZqVylNQijGT+GHg8JlBCW1odd3sWPTAoim3bP35ifb5By7CAXRjhQIykicoKAyFXp5ibnzUt3UA3zdDlPNYtRi2V5fPugfkX41IccSzj/ziUYQbjQXnKLCSYTddmQ= 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=pvopdkzM; 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="pvopdkzM" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc647f65573so2774488276.2 for ; Fri, 09 Feb 2024 19:06:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707534370; x=1708139170; 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=F5s7UC2LI5606ztlkySRh4zEDw9ZNIX2+7Suzh+XsVU=; b=pvopdkzMyY7gcSDnmuhMe1Lrbk1BKJR51rbeNR4MJLexjtGVOpCgs29lJ/dds4s8ZQ ECWW/fQO6z9RAjRwBm4vQXP9XTyrPdmqm+UIvEAkCwh680T3W4TY9rOHlqDbQULHo7aK g7eAqBA1kpjkaqgGNM2mPe1eqhWyqI0bcmpk7BTziBBYJsFEzyqzit+Otvz/EhnFxzxq U9Dj4wP6V25ucXHOLUR4KAD0yvVCfiFo8CKXfTDB8zWUE/WicBMsrE/XfxJwTnUK54HR wr+m7byxq6mJw9Vsgvdq0s5oOMMrcpRmKd61MAX3ws+RdxKOpydJtWCE3ct4Jq3ELdbn nRmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707534370; x=1708139170; 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=F5s7UC2LI5606ztlkySRh4zEDw9ZNIX2+7Suzh+XsVU=; b=QL0WvWJs8VrTdWy0Xjg04gfkFtu6+LfgLMYMhOAxGnD8ssB4fgYKQ0B0YawAnzOeBx lDtTvhrCV6UC8kTp4NA/bVt2kvY4C6YnbbY7NHhP2EipDGoOiQfOtGFkUKl7UlWJWXZh diRTThXUDK5VXAunhoQ7K9U9bJUwSaLeXSR3COFFrALqDfg9zc0Lhhw6A8WDoE/87Mpl v/sO63uYoc+GXhjWqMMJUHJQG7MxB9gvsZ8VuzePUoCxHp4zSBjXSJepxQUp6duZuJd7 KTULZMno7iTf1Rhn1socHSbiXax/AoQg/6UwodI/WyMfeMD00vPPcuEjbpnSHlyPZeQN jbWQ== X-Gm-Message-State: AOJu0YxUs923EgpxAv516AGXf649h4FR6P62veAiqbCISRXRWUPqio5v oJwYvMrg1OvRzuAnClgbm+6mZQaAS0N3spQU5I58eDmisrY5gaYQtUcOJ1Oc31eQGXPtlq9EKsL GdU6vCU5h0NUYAA== X-Google-Smtp-Source: AGHT+IHoaOrZfU2X7gvo32Z9ygKKDDC9jkDgw9ONDzx/dRL4i+TQaBCi1II8RxJpDFCvyqRwNSZSkNWR2n60Ftk= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6b44:91e7:13e1:5d92]) (user=saravanak job=sendgmr) by 2002:a05:6902:1006:b0:dc6:ee88:ced2 with SMTP id w6-20020a056902100600b00dc6ee88ced2mr254743ybt.12.1707534369357; Fri, 09 Feb 2024 19:06:09 -0800 (PST) Date: Fri, 9 Feb 2024 19:05:47 -0800 In-Reply-To: <20240210030549.4048795-1-saravanak@google.com> Message-Id: <20240210030549.4048795-5-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240210030549.4048795-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 4/4] of: property: fw_devlink: Add support for "post-init-supplier" 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 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 --- 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 751c11a28f33..dce451161c99 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1066,7 +1066,8 @@ of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, } 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 = of_node_get(sup_np); @@ -1085,7 +1086,8 @@ static void of_link_to_phandle(struct device_node *con_np, tmp_np = of_get_next_parent(tmp_np); } - 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); } /** @@ -1198,6 +1200,8 @@ static struct device_node *parse_##fname(struct device_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; }; 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_supplier, "post-init-supplier", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") @@ -1349,6 +1355,10 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, }, + { + .parse_prop = parse_post_init_supplier, + .fwlink_flags = FWLINK_FLAG_IGNORE, + }, {} }; @@ -1393,7 +1403,8 @@ static int of_link_property(struct device_node *con_np, const char *prop_name) : of_node_get(con_np); matched = 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); }