From patchwork Tue Dec 19 17:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 181158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2110181dyi; Tue, 19 Dec 2023 09:48:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdBy0Dzy6a6zKosa2DnCdaG/YIQJkCQZDd/Iw47OKILMGf2WHEhg7s413qsS07TMuJgMhA X-Received: by 2002:a05:6a00:805:b0:6d8:8506:9bff with SMTP id m5-20020a056a00080500b006d885069bffmr2687041pfk.50.1703008132831; Tue, 19 Dec 2023 09:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008132; cv=none; d=google.com; s=arc-20160816; b=mk+hAeYu0cAffRq/17xF1JBdxhUauV0M/jpQR7FdbGJdGzSJVeTLzqfhb4R47aqBMK OPRmNfExaHQ806+wj8rQg4HuZ/z37Qjkp8DIU8HxZoq76boxCIHRADMGK3D6er+Naj/7 iOqhxbT4SE3JABjadPNKl9dtT9T29AAMVbMLEqIUK65bBbPE+xq9CxqIGaF7BYYQtXQn PyO5kS/8s6dZPdrq+flo+NhBbMKjr9/jHIslVfM76yS6b0+4LiI4es4BIUSirzjFP+Xd Ba+aY10lsRGQFL2cdW2abRKHMHOfFgRhs8OrAhGr+2nanfn1sSWN/3J4KOJH+YQx7O2n DXnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=0RIAUs8HTGNnAWqZ7PiMQPuwTan/lSBjxU69Rt3WcV9GaPT464yJnicO4QaliNPSgt k9oGomRyXxhgg3il7VIavAYAI2nKdhrp3EeXMU5FR5Vnj6Jwy31KDmeqecybIetc68jy IAF+vUWGhnihyJiLDwhDcx42DnKaM/l5S/PYIB6/KJdjp81Iqp76sxXrrc6Dsd7rvc8F 9AdZafzyHjHHybp5r/ngreuBRgzTjPlkXI2l7qjT28EPOH3mJU883zCpH4Oce68EsjdP Ny68jCZy64fqtNNu2/82/SKiCQAD5mq4/QpjlNFKo5C2ai6uNoG2CGsSuCaeeJqpgpua aEIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GpR0JG7y; spf=pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c31-20020a630d1f000000b00577475ee5f6si19494333pgl.618.2023.12.19.09.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GpR0JG7y; spf=pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6BBC8B2473E for ; Tue, 19 Dec 2023 17:47:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67F3D39852; Tue, 19 Dec 2023 17:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="GpR0JG7y" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 7176A38F80 for ; Tue, 19 Dec 2023 17:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d3e416f303so4778605ad.0 for ; Tue, 19 Dec 2023 09:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007958; x=1703612758; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; b=GpR0JG7y32IcVQUyyiIWXRSCTAlrdXdwpA9H5PjWS3ZEympZMiooxVdQ9QYeygpkb7 tobK/aLnf93JfNEAQ/lvhv4PI5+RyOL2XM/IBBCqoeTFK09FMY/9EUg19LVtYHkcWXx6 9zlTCDmuF/SLTaZr/9oYB9ynAeGrRGiI1ByAkIgqtoWwGd8HHhboOU1IjnXZnfOGG7Q3 30KUQ0QVK8SOcsNZzrs8HYNkW8hgcOXV1Vb+K+baNfYMUwWTKgTesubJ1IUTl5p9ehjI tMPXtSm/I/N2SjwnC2LXIt7j3nVZdsylSTGGSTAvhVr/Mdi+KofY3mND4Iz+znYlYXOz pRSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007958; x=1703612758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; b=dNGWBODsUEvlkuZ3NGd3yRdera2hw7kM6xk2fs7uwbPZgOowq+TJf08KZuipI8vV0B Bvx93FOkIYbWhwEaLFoUQbvjCqRuheHUpPimLxYXkqOKeRx1JvyFiqqC1iALCZMOBySH VZs75dX3CjqMRA7KNosqOpLWKR/YpoW28V96nJUVLkUwBgPfrt+Cciy0OB6JJo76NUM6 +X2h6EVWk3fydbcK0a6L/CKgbOqq138xoBYAXaYLSRTJg9BETbgL5VnP2nkuy1fOR9KS og/uDadqaevZAbIXxcaApQvwqlXdElqXi4nzBYvYjBnMggtEjSQruoLtM8iFpxG80Ryq LTwg== X-Gm-Message-State: AOJu0YwJvbTmAjPsDupuiQsLe/kJ2dA7T5tMAm1FiYVbjwH83YHx/1a0 w/aBplbHqlAe2/rN5DDt0A3MpsLKmsjRihC9Pr4= X-Received: by 2002:a17:902:7c8c:b0:1d2:ec9b:92e with SMTP id y12-20020a1709027c8c00b001d2ec9b092emr9877603pll.115.1703007957846; Tue, 19 Dec 2023 09:45:57 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:45:57 -0800 (PST) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 04/17] ACPI: Add fw_devlink support for ACPI fwnode for IRQ dependency Date: Tue, 19 Dec 2023 23:15:13 +0530 Message-Id: <20231219174526.2235150-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733455576800353 X-GMAIL-MSGID: 1785733455576800353 Currently ACPI doesn't support fw_devlink infrastructure which helps in ordering the driver probe in the order of dependencies. One of the dependency between devices in ACPI is GSI interrupt source. This interrupt source can be another device and mentioned as part of ResourceSource in the ASL. Or it can be indirectly determined by the GSI mapping. In either way, adding the link for this dependency avoids modifying all drivers to handle EPROBE_DEFER. So, add this new interface into ACPI's fwnode handlers. Currently, this is necessary for RISC-V architecture. So, kept the interface functional only for RISC-V. But in future other architectures also can enable this functionality or can be made common. Signed-off-by: Sunil V L --- drivers/acpi/irq.c | 18 ++++++++++++++++++ drivers/acpi/property.c | 20 ++++++++++++++++++++ include/linux/acpi.h | 9 +++++++++ 3 files changed, 47 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index 1687483ff319..b3409e2e2041 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -354,3 +354,21 @@ struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, host_data); } EXPORT_SYMBOL_GPL(acpi_irq_create_hierarchy); + +int acpi_get_gsi_parent_fwnode(acpi_handle handle, + unsigned int index, + struct fwnode_handle **parent) +{ + struct irq_fwspec fwspec; + unsigned long flags; + int rc; + + fwspec.fwnode = NULL; + rc = acpi_irq_parse_one(handle, index, &fwspec, &flags); + if (rc || !fwspec.fwnode) + return 0; + + *parent = fwspec.fwnode; + return 1; +} +EXPORT_SYMBOL_GPL(acpi_get_gsi_parent_fwnode); diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..88769acb13d4 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1572,6 +1572,25 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, return res.start; } +static int acpi_fwnode_add_links(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *parent_fwnode; + unsigned int i; + + /* This is needed primarily for RISC-V. Other architectures can + * be enabled or made this generic if required. + */ + if (!IS_ENABLED(CONFIG_RISCV)) + return 0; + + for (i = 0; + acpi_get_gsi_parent_fwnode(ACPI_HANDLE_FWNODE(fwnode), i, &parent_fwnode); + i++) + fwnode_link_add(fwnode, parent_fwnode); + + return 0; +} + #define DECLARE_ACPI_FWNODE_OPS(ops) \ const struct fwnode_operations ops = { \ .device_is_available = acpi_fwnode_device_is_available, \ @@ -1597,6 +1616,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, .graph_get_port_parent = acpi_fwnode_get_parent, \ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ .irq_get = acpi_fwnode_irq_get, \ + .add_links = acpi_fwnode_add_links, \ }; \ EXPORT_SYMBOL_GPL(ops) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index afd94c9b8b8a..e9a9659314f2 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1463,12 +1463,21 @@ static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console) #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI) int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res); +int acpi_get_gsi_parent_fwnode(acpi_handle handle, unsigned int index, + struct fwnode_handle **parent); #else static inline int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res) { return -EINVAL; } + +static inline +int acpi_get_gsi_parent_fwnode(acpi_handle handle, unsigned int index, + struct fwnode_handle **parent) +{ + return 0; +} #endif #ifdef CONFIG_ACPI_LPIT