From mboxrd@z Thu Jan 1 00:00:00 1970 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 F3695C3DA4A for ; Mon, 29 Jul 2024 14:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=agFjrQOa9xEbEpf1jzUh9w0ICc WSzgwLGgtU/juUUGnwYtyEWPU7bKlfWZIS7WYrZcfVQQmM24YmuW5lCszdG0xKxIqpxA/9U3yC7Ws 46so9qtLflJN17Z+ItmKnBLPRkH+2SJH9sbOu28lW/E5BF7sY+6LPVlD6B95G7xpZNg+MqWUsKsFU o4a12m8NEviOz45SNN3kMCNEJXeuWsWJrvVhqNwKyFpM/W1huf/cuhGMa8z8vFRdJHJXaVAcEMQFk gcGpQgAdGtR2gMHKVGDEr+ZaDLI9XLXzk1L6/g68fV42pflpENQT14ELZfadp1jzBsrkGAmZuo/1j ljmc13qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRnG-0000000BlE9-0dYl; Mon, 29 Jul 2024 14:56:10 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRI0-0000000BYue-2fmR for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 14:23:54 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fc5296e214so22932405ad.0 for ; Mon, 29 Jul 2024 07:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263032; x=1722867832; 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=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=njtDhEk4Wvc64or7d5sMwyM28mLkg6FOnldPvyQI2IydXqJb/mGlS+0/LjhCmh+UtE cFv8++qiVd1UfcIV5wpBHrfiwBVq1au8H/nx7RZinLPlnFPAdvfdUZ4pixN0FIsxiWcN 0yhTOj9MBRNAPNY6PEJSX2+C0hg7btC4e2A/OA4v4TzcQJVCFYYWZ+m8ypakNZ8hGwgV 4F2FGIcqDGqMtbJvShPKfD3Ri/MFsHm5OhKMOjozBvvbDwWOfoZijeZLU2vF7sW2uoau acreoulj5NjMdf0ABfZvjSeEoBmsevcFFqluiAMY3Kkn9BRP5gYRj7+PgjoUYpg5L788 tw8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263032; x=1722867832; 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=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=qDkSQxLN7m2IXsIevNMz4Nk4b7pHWJpadcFN6cNB4gq8R0rVcSmakq+asy8O60Ugzz J63puIHTsZAK7q+jP7HRs+NYJS1jp5Yb4X3X/50gZNk7WKMpG5uB6Zr5qdFtGWvdjttq jVQbkUlxFc3F0bvK+HEKLx7TbUHzsm1Z5kvmUva8ijLQ1mKDhjRngd5MCnATe7e18hG1 Ov94liukMMbj7mdjLThFwDOtmJKZELRiD4G17pdZ4Vtm1+mJ+O6G2966LE0TuEks4bXQ H4uVmjPnvH/STWp0dlZekuwF/jgaaelwyHgLRcCJC6iACZbOdGEtWBEYeRzW8CXZy+ru oWpQ== X-Forwarded-Encrypted: i=1; AJvYcCX4dL/ux5FkV7P/hswfRoXRboLUdnFgJ4UEbazEJPmcpJ6p4aGaTTCxH8lpdGUEsBMUJrrZ/ptsu0ApWH8UjCd5LfpLyX2j3fBHf8yuQJBBuAGzfwI= X-Gm-Message-State: AOJu0YxXjspT1JqTmFCMDCh9nyMGhgzMhwrA2auYkxTcfTVlXHOurHwO arU+XE9gvV0woI38lJRPE0Lh5ifH8nTtxaAbb0HUPX58mtK0+d0ms+707r9y38E= X-Google-Smtp-Source: AGHT+IFH4IFEEqFnFuD3LFxB9/YGdoZ1voAL0RS56DOiFLXrkbkYEDIaLZyWRT2+lCXe+UQYlpMB3Q== X-Received: by 2002:a17:902:d4ce:b0:1fd:a360:447b with SMTP id d9443c01a7336-1ff048b7daemr104566225ad.52.1722263031612; Mon, 29 Jul 2024 07:23:51 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:51 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 29 Jul 2024 19:52:32 +0530 Message-ID: <20240729142241.733357-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072352_742671_2E4966B3 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- 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); +} -- 2.43.0