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: 771571 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 8CB9D79DB for ; Sat, 10 Feb 2024 03:05:57 +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=1707534360; cv=none; b=HF1yElYmjoVAdFk431ds7rZADHeu1geNSNLEZawy8a5V9VMidlG8BL6Rc99KhrfEhs9Lu8C90ZVHdu+rAUgXakGy7SAXvCJ9pAXfFAEOeAA28xKe6uauS2T3QhR8hyE8yPsPDWMSe59BXhLp9dzlx0FxPH16NpF79cwgZmb7KH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534360; c=relaxed/simple; bh=sWUmF3vh9o4HGU5Ho8G3VWDldprPEGq5gO9RSRL2L2Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=F3pdWFYHfUADO2Vcwjw3lHC9NkuXaKc/8ipzpKYsmx/PqbDoS9ivAYB65zoQMdurtos4XMJZmBb/yAge/vEtx+3oX2TmQfzyCzCldkQzoj7N3i1GTTz9cW6lVKA8nNHgOQFIDMnbqief/HazRN0IWDHpSjLUEk2QzeM6IepGo+8= 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.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="ACCkEIVQ" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf216080f5so2492695276.1 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=eAH0JjjV6H/oRBYnbZTywyQmsz3sFLRvLx9zT4X6oQv05uPNgVjgFIZQQMnAkWAxsu OGAGlvKVgeupg8o3SarY3CZIrNqpXNcQ18T2y6xiaiwUBypH2Vg3scbyN7gurlT4tURs ls4KYgNqF7fYK/qnuEbk5ConhX9Oj0bVTQ/JsdGp/iMZxWEet6oztKgvdZhyNWR4GzI5 14jWO0GGCHYOd9/m5YJh+vU9z5nQYJLl6YxVvGQ/lL0j9wVcIewpPW0z4Sq3OpcqcnmE 37p8lq0gyLIijzjbIZDvtIOQnR1Xin7/U2+EAwo+rNtFuD4yC1CVfK5kGtW+2vA+wgla srYw== X-Gm-Message-State: AOJu0YwNlhyn+TN9jSkumZuHSl2KPYbS1BqrJnMwLtV5UnrkELGEjYr8 nUjcU0I28YcX122/U+ZFBlF6hfrs5nCn+oejnVQchV0W7RY3PBOcpaCJMZUsBeAYAmNxKrdbUfp PRxNYYxPs7Z2qLg== 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-acpi@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: 771860 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 AAEDD15E9B for ; Sat, 10 Feb 2024 03:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534363; cv=none; b=dLQ0dF+JEqhtFsI0lAGg+UKlGcwZMjgZJtPG3+C2ff7QPxEkItVxYVYfJo3LCMP4KZp8O12L6fm7BO5fQKhw7tvQo6NE+pq5B5QVHtdHTkkrIYRC6YU4o57f4EZBJ5ppm7Ud5+gmSL3z2Po3IHqsf2hWzQtN4XkFSLgyUjhtLrM= 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.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="RJK37S4E" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1d932f1c0fbso18808615ad.0 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=neVBAlUCBvmu6+ssnnqLSUloZyWAf0fLzUidGh4dv9nNv143W/gE42dysljkM5xym9 XZCllVmVaC5DH/UHkAobdYn9VnyOC5m1SF+Y91yEott+abF2RFuFxdab2RE8eru1371A 4iwNlWPpze4XpF6ozmc8H79QPS/cgtL2sEQPbbi2Dva5xsm0QX5OFaqEbaQRJ4GNC2hO jWm15q0T+jGt9MTO6rC/VepZU3chwWQRasZSSY22iHvMV+NxcqE9m2DuHrmIsj8wpNhM o0TlUIRcVC3K3w8H/3rWMZJwLBCE6qCxlHHPcIEBiuAf6l44GduckM5d2fnHuIZeiNNQ BkGA== X-Forwarded-Encrypted: i=1; AJvYcCUj/EZrpSP8ZUZ+9q4MKQjQUbFYTfWwlyTptc4x8cOBQhhUwNSlXSPV8vyKnUPAJb/FP4zgjTulnD2PTmL3G9i8FoI8R90QwaYtBw== X-Gm-Message-State: AOJu0Yz5DljKY9oijAYkTBFoEejqHX3dtWfVsjPNOl04T1+/7eswoyPl pyGhLLzjZoVzXMYxMoEeEfOLg8rugXgcd29pDrkDidPzhZgk3jP5htIsy5+CYrNH3KkO59o1X9l LK1X+fX4CZs72cQ== 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-acpi@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: 771570 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 68E6C1EA73 for ; Sat, 10 Feb 2024 03:06:06 +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=1707534368; cv=none; b=hCOPPOvm0pA9c+F/XRjaz4d6D1g9lF02a3xYVRYnhfhGdDOTgxaAhD/3A06QtmbLTLX/iCWzz34q4yk3yqzOrxOcSVIpkhdolnirA2iC5jIljhZk318FSJvcO2YdnGdzKbnnNHJzyK7rUa7B4SxEEw6vpwmVBozVkSjw3mCcqJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707534368; c=relaxed/simple; bh=DDHVFJw3laeMHNAD1vbR4GSUPDGUWbNquUH9HPPVOrQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=kBDgIC0AcV1Ahy+MIBeF0Yj6oL+/2AA+v8Xvb7ohVUSoKY0vofdaduX/v43H5daODEmBPuuwIryst/9noCtQSIniDvXqw+q/YhSk3+94L2SvMiaWcHtQra4WBHrPfPccbg1x3FXx5L9qr936z01UY3zgwxUWgQeiPdzy+9PYREQ= 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.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="MmwUDtzn" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-604ab15463aso28182947b3.3 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=QADzxFq1Y0T9UFMXyPOVUrt90tc3OhorPp57o83pEdwDWUDZtIJHUbnKEgxcTrJcv1 12fav1peHA8CsaKdVuEgpQaUkAqPnG7ZJfy1mhdIzFJLThoDDibodZYN5rnH6KalKW9h 1yWKpDgkrdPA41zV0gSHgXe5/k+4B44//kTmeRe6LhCKuDmYpbZymWDzyxOGvlR/ohIP YNWayRav69ghtvAIOwRVIHKQYXnh+8QkHPFL0wrkLwmxmGMz85fCfA54vs8c0hVT3HwJ FkD/uSaCTVf7wzpCz6xG3dXPUM/8NQiMcMK/gdUhKof6lwKdyVfdm/qn1vOuFGB20+xV JAvA== X-Gm-Message-State: AOJu0YwXCxmyb/h1hbRUP8rKm00DnMWs/k68ta71+f51Fry8S/0nOeOD a/wnPNGfTjMK+q5NuGwVQ3wIZJ/L1ll1/wQolnnREDRbOZARLNmnNBWDC12zCR0JyizkDoMY8SX 1w4AoKJIDgU03bg== 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-acpi@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: 771859 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 815292B9C2 for ; Sat, 10 Feb 2024 03:06:10 +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=1707534372; cv=none; b=kTBULyc8Apwt61clu1GPlaPOSirz57yjyFYOb7/OsT1W7y3+3jjywBe1ME2HDoQxyXIOcWBbRibrmrFuYJvdc59M21nGq5SYvb+xhu0i0gMf+l9rQK3K6yWmxilyZtV01PqrOGG+T0rvbagXUZIFckPia5gW315dM9nboLnI4FI= 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.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="pvopdkzM" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-604ac3c75ebso33303737b3.0 for ; Fri, 09 Feb 2024 19:06:10 -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=E9CNSBtL2WQldw2jvMzCcYoIEGPYMuLjejxX3N4IooGN4hSZV1X56V5GGHmpqh4WlQ WARQ3r8L1urx9O/+MB2lPMbUqWjNCx6M+BIqDz7YWF3N69B/9MpO4RokBopcFOBx0fRj qRqlh/AzAOhAIu1s607+Hu35UoaRyQBmFkto55+BC8ks4H3zvNBA5eJXVzqWe4qz/t5y jOQMZlTgtqiiAiYsz1vZ1ctdaWBiFZpkPp9OENaYGwAqqLfwf/GyNXZ6CJ7fZVLpY7Yr ZPq8YYiJ9hDbT69OF2t6MaLsLcPuKKvVKq8RF5XhvfU87Z3J5E+i0mO7UNKMAsTMDkTK gqmg== X-Gm-Message-State: AOJu0Yz2czNeBjWi17AWhVnfPNoixHxbC8g/2VZ4G0nlj5zi0Brhl8Aa u5FyZO7Vvaj7vynATIad721nI0BQ+uKj4+uvRxM0x4iIDFW0wHHt2+pK4+wDCEAlEc1qJNJybe2 5XsokQowAebRQ3w== 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-acpi@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); }