Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp77412rdb; Tue, 19 Dec 2023 09:48:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLiPtzm7mRhn/ECzXq5qsqFq173jAflNupNH9RpN/Zae8qfxCw9i4FnnkuP6lmfaIpuKfV X-Received: by 2002:a05:6359:1c0c:b0:170:8cda:674b with SMTP id us12-20020a0563591c0c00b001708cda674bmr14734456rwb.15.1703008082311; Tue, 19 Dec 2023 09:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008082; cv=none; d=google.com; s=arc-20160816; b=yp0qNEeko0R/7U+qoRCMkZ+sUmQb39mT3l981EZ4bsM02yXIKHJcfOKFsk3JH+kJf0 0DMJL8C6SQ2EroGVvgsxoEo+6mIPgBNUDine2dgRyZ5pjGFFCZXB+YCng3y8r9TL1qSN 4wVLhtXH0D/sTm5DYXh5qM6jUy6fvDji2vHMdT/a2jtrQ8+eFnWCEPYgS/mc9fhwztub 9e64CbabNtkEuLqilnZvKw0bkeJHbbTNarjTLfojkgshCRs6481N+Oi7hMHcAouLe5Pf GIc7LdtcNi7SdlFADGILavhN6CJAEN8Lxk7N77o0BWDP/JhdTpd4sImA7cUX9E9OT/em 0Qrg== 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=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=QnQyyw8qTkcQ0bXDWiElCa/VuYUzXNcVzcjDMq2d0NJtZTWuvmV4AXHHBBSt52m22Q mjQEk7Bv9sBahWXfk9rt6qsZHeCPIeluS2hWXRnoKaUUgFNhaVqhH0UjfOUjiCEyqqdK NQvvgb3enY8ocA3wjTE0ZOKnyGgeHEj+gfm4VoqnCUp/NqPxU61SGw1vdUkq/xhJH++z 2U+zSfOYaZ2B6Us+N2PnptqwLF/9jNvj4kTKfeRJn7aSztuE/KGB8KIKOa4QDTONUQ4Q T3FhcPaNqCS1OxkiKLpuFvkBCXAntkFvPEmMPchK54TlWFuR6mV6rJzmRXrdUkvpd8tu ixAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IVkfP62W; spf=pass (google.com: domain of linux-kernel+bounces-5718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5718-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g36-20020a632024000000b005cdc5c9d6a2si434669pgg.576.2023.12.19.09.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IVkfP62W; spf=pass (google.com: domain of linux-kernel+bounces-5718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5718-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BA4492874BB for ; Tue, 19 Dec 2023 17:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE33D3984A; Tue, 19 Dec 2023 17:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="IVkfP62W" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 90D9339AD0 for ; Tue, 19 Dec 2023 17:46:09 +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-f175.google.com with SMTP id d9443c01a7336-1d3e6c86868so4412655ad.1 for ; Tue, 19 Dec 2023 09:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007969; x=1703612769; 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=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; b=IVkfP62WI+qGPDHiQNflIsShzQ0QzHA4Q6atD5bgBaFLqE9/Bep0FLhLg9kmkF3ej5 S2/ZXXXNuwvsjBE5wa9G87UzGrN6olr6AifbNiaIIJE7hxSOmLVMowG8iWUPn1l3tcPD 4PWfx+GjMtyGxMqAivoX4jVBdhzurZwB0o+yLDLyLTcUw4FWG03+V+FC6o6GHt+zi8ya CLontBxmsHcpUAx18wa/Ev6lS0nvwLQ5w5vClVsXrY9s038d7mOtqH164fzy6BNSYmCn UcjrWZsqMROHvQGIC84agyGZ1iBXyLJbjby9gO9kVSyWU0UtJuq1VmKIcMx/76ftRlk3 7+Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007969; x=1703612769; 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=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; b=cX0dLoV9HMa6LzcpZOK+P+5/HWf4GO6o3YItMUJFQIkeAvODebmsCkMYMYOntC+lkZ 5mfT4/pxaUodZ+D1ABVlraNwYMcCQ78rGsob6rf8tKQQfIyFyLe2jx9P50n756KC2aTg GE7PdM07UL+d9Zm2aiYqhGZlXxT4l6bqc9vXsOzdN5mnpL9a02wjMz7xz5mDgecOAlF6 sPH1986B3EoJxUyzl35qTV/2g2+7pUOpqPC8ktwpFzgTwjrwrWNCguSkRzetHAqbEVWv QL9Vs00IOyApWOYe9zPoy7c1l19PPWamSFeNkDTW8BJY1pFlDPgjb/eQpsbnYwj2YSFe JPMQ== X-Gm-Message-State: AOJu0Yzze5Jp98ddmp+3Niv7QttLU+yvE8eHmtZks9abkWyLj+3I2+0e 76Xw1DO5hSdC8mUIrIyBwh8hMw== X-Received: by 2002:a17:903:1206:b0:1d0:7d9a:3bca with SMTP id l6-20020a170903120600b001d07d9a3bcamr23158609plh.52.1703007968947; Tue, 19 Dec 2023 09:46:08 -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.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:08 -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?q?Bj=C3=B6rn=20T=C3=B6pel?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 06/17] pnp.h: Reconfigure IRQ in pnp_irq() to support deferred probe Date: Tue, 19 Dec 2023 23:15:15 +0530 Message-Id: <20231219174526.2235150-7-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 Content-Transfer-Encoding: 8bit PNP devices add the IRQ resources to PNP data structure early during boot from ACPI resource structure. As part of this, the Interrupt resource (GSI) are registered and appropriate linux IRQ is saved directly in PNP data structure while creating PNP devices. But at this time, the interrupt controller for the GSI (either via GSI vector mapping or via ResourceSource in Interrupt()) may not be probed and initialized. Hence, the IRQ number in PNP data structure may not be the linux IRQ number. When the actual driver for the PNP device get probed, it will get incorrect linux IRQ number. Fix this issue similar to how platform devices handle this. Basically, while creating PNP devices, the hwirq number is saved in PNP device and marked as disabled since acpi_register_gsi() would have failed. When the actual driver calls pnp_irq(), get the linux IRQ number again if the IRQ is disabled. Signed-off-by: Sunil V L --- drivers/pnp/pnpacpi/core.c | 7 +++++++ include/linux/pnp.h | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 6ab272c84b7b..239355977d4c 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -326,3 +326,10 @@ static int __init pnpacpi_setup(char *str) } __setup("pnpacpi=", pnpacpi_setup); + +void pnpacpi_reconfigure_irq(struct pnp_dev *dev, unsigned int index, struct resource *res) +{ + if (has_acpi_companion(&dev->dev)) + acpi_irq_get(ACPI_HANDLE(&dev->dev), index, res); +} +EXPORT_SYMBOL(pnpacpi_reconfigure_irq); diff --git a/include/linux/pnp.h b/include/linux/pnp.h index c2a7cfbca713..8753eb4275b0 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -26,6 +26,7 @@ struct pnp_dev; #ifdef CONFIG_PNP struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type, unsigned int num); + #else static inline struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type, unsigned int num) @@ -146,13 +147,22 @@ static inline resource_size_t pnp_mem_len(struct pnp_dev *dev, return 0; } +#ifdef CONFIG_PNPACPI +void pnpacpi_reconfigure_irq(struct pnp_dev *dev, unsigned int index, struct resource *res); +#endif -static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar) +static inline int pnp_irq(struct pnp_dev *dev, unsigned int bar) { struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar); - if (pnp_resource_valid(res)) + if (pnp_resource_valid(res)) { +#ifdef CONFIG_PNPACPI + if (!pnp_resource_enabled(res)) + pnpacpi_reconfigure_irq(dev, bar, res); +#endif return res->start; + } + return -1; } -- 2.39.2