From patchwork Mon Aug 12 00:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A509C52D7C for ; Mon, 12 Aug 2024 01:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NyT6cN8D5liKpPSjxuT+WNfJdW5iQPmfWVPhMOf6F2U=; b=07CQPKfevBkSpr bfzCyWO41QoGvpFTrBisNqQD6Z6FQufMPZ4EFLKbiVyOUI3RsbluxeUdiYkYljTXk2XWB8qb5DE6u fG2bMiAoZYoFjs02jcGJWFKImtuBwMNpLtOtwHnLB5NviDlGIFd4eJ9pomkqwmNGCMz8lJmK/qMn+ QD63dWVaTGez4YLsDnF4bCMLjNX8Jdy6m4z7ia6iAaiEsXHaPjqFQ5nJUBzxbqbeuQtRnB7x51o5/ BHLN6WTlua7387E1HPuUMgkD/PjzREZSE4mu+Y/JJe3OKr7PCE21QXVw6dQqydGmvVOLpc7y8NAHg 5AOuBaa4SiQGbgB8HH3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJVm-0000000Gc2f-37lB; Mon, 12 Aug 2024 01:06:14 +0000 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQT-0000000GaDB-3Icl for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:47 +0000 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5d5bb03fe42so1988340eaf.3 for ; Sun, 11 Aug 2024 18:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424444; x=1724029244; darn=lists.infradead.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=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=jrEfLovZJ6qM50knRFvZMu9GISbyg/53AZNIrTy07Lf03A1kvDs0/3qMYbQcjW6HzF Gax+uhqdMzdP/6+4LB32hwB13vILKmoWmQcRbcI7RWig5Y1WM2coPOLODt1CCuA8KF8H wBO0qRuOLCicDJvQnlilvjRqu7eBtxnw9H2+f2cDezTz37vl1ioPwo7US9K/gPFzHiSw G1afJd98zNWsb2cjOH39JIRIPuYm2uhtOmS7MIuB/zEUefTxYe+fpe563E5zNzDt6nHw wc/V4xilaz//jvVIzyxDpVlBqtXJH6amltuxdz5DbFaRzzmOYlD7+EW4EUr5gInQcrbb dqdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424444; x=1724029244; 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=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=vcagfr7PLyyhmo1lgsgAsYKhCsCyK/gFN3jtV9n4MhXfjUEyNrqkygjvHwQaJMJu67 bBFsW1iLeAEBsudCOCeWF/JgT9GW5jgKSmjxGWm1bK4EYVvZxN8s6NZGDymlBkT3LlO8 5Qe3i5op/DTY72aY0Z7O37CeF7QsR0U06KEvsb6vbGVE+OqcO4FVz+cVKRxPxiGL+9PL 0dXaWaJ0ssOa6jrMuXdOZpB/aHuzkMS/rmQTjm16w2rV3WWiFq9iYp/NPMQXF78ZahUJ /uxnDqgpLcC7iag5vYO0+2hnhlFSFemWuBV1PzA5Mc5d3t3Lgtmsj9GqKWLkW4C36Zkl u0sQ== X-Forwarded-Encrypted: i=1; AJvYcCUDtoia3N4FCiIF3XkItE+aAX42j/3uGGvTMdZrhoFXqxZGOhVNi6DCJczqbi+qldXGjDLfKBvfq4TuVt1dum0UgzKU7xvrYmB6Fo2EGv8S X-Gm-Message-State: AOJu0YwZl+rjVgT+1/MtNn3HxqVB7sKRbGOX6SOXJJql1QCRmNxsvsit t3BeIBJ54weChXVnOz8ayfv6svboRq3IoUs25gcM5qIzQiT0W4UlsJFUFeI86GA= X-Google-Smtp-Source: AGHT+IGtpWS7DBc6qnLRa7J1XKsHLrlfePxKw3cHvC5D7SmpvnVph24/oUKeRjRFTeAU1sM99c7TNA== X-Received: by 2002:a05:6870:1585:b0:260:e7f9:f4e9 with SMTP id 586e51a60fabf-26c62f21db8mr8563110fac.35.1723424444123; Sun, 11 Aug 2024 18:00:44 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:43 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 12 Aug 2024 06:29:22 +0530 Message-ID: <20240812005929.113499-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180045_849104_AEFB48C4 X-CRM114-Status: GOOD ( 16.17 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On RISC-V platforms, the RINTC structures should be probed before any other interrupt controller structures and IMSIC before APLIC. This order is established by using MADT sub table types which are ordered in the incremental order from the RINTC. So, add the architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy like below. ACPI_MADT_TYPE_RINTC = 24, ACPI_MADT_TYPE_IMSIC = 25, ACPI_MADT_TYPE_APLIC = 26, ACPI_MADT_TYPE_PLIC = 27 This means processing all RINTC structures (in the order of appearance in MADT), followed by IMSIC strucutre and then all APLIC/PLIC structures. Signed-off-by: Sunil V L Tested-by: Björn Töpel --- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 877de00d1b50..a96fdf1e2cb8 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o init.o +obj-y += rhct.o init.o irq.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc.o diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c new file mode 100644 index 000000000000..835eb6eccd53 --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, Ventana Micro Systems Inc + * Author: Sunil V L + */ + +#include +#include + +static int irqchip_cmp_func(const void *in0, const void *in1) +{ + struct acpi_probe_entry *elem0 = (struct acpi_probe_entry *)in0; + struct acpi_probe_entry *elem1 = (struct acpi_probe_entry *)in1; + + return (elem0->type > elem1->type) - (elem0->type < elem1->type); +} + +/* + * On RISC-V, RINTC structures in MADT should be probed before any other + * interrupt controller structures and IMSIC before APLIC. The interrupt + * controller subtypes in MADT of ACPI spec for RISC-V are defined in + * the incremental order like RINTC(24)->IMSIC(25)->APLIC(26)->PLIC(27). + * Hence, simply sorting the subtypes in incremental order will + * establish the required order. + */ +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) +{ + struct acpi_probe_entry *ape = ap_head; + + if (nr == 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) + return; + sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); +}