From patchwork Mon Oct 14 06:57:39 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: 13834203 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 C733FCF259D for ; Mon, 14 Oct 2024 06:59:24 +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: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:In-Reply-To:References: List-Owner; bh=9Ryi5ZCwUa29loc/VCc+j3/Sigpl3P9yBAsnZyKRQSE=; b=OIW66kOU0PDrrV OcpfkK029MimZHNWMRTxb9MjJcXDKnGQashTCM6EIwMIZvsTWxTcYf3gyLnBHpQDwEOrA+IDbXTM7 3RUI2eNvmGBiImirheCaysQYOSWixj+XIkbzpSaNc3gZcsfAQ7NWr6WHjkYP7//x+K93Ksc+crolm B6+WwTqQuRRLRwzSmm1o0NTAJrb4tkUpATF6r93Dqg1Z+nTyDnPCaEB2FatDYFEXSvZMbKn1yFCve Jw2W8ncwXCozqgaVRH3aIUVlLk6d0LrGyPfrqRPHQ13mPBtBiIev+yz0H3Wdm9ZBOD4UJLPlGmX+X FfN3P/JLv8mRTVtqmdZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0F2x-00000003yDd-1s51; Mon, 14 Oct 2024 06:59:15 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0F1a-00000003xvr-0IsZ for linux-riscv@lists.infradead.org; Mon, 14 Oct 2024 06:57:51 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-7ea12e0dc7aso2429275a12.3 for ; Sun, 13 Oct 2024 23:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1728889067; x=1729493867; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Rbc6XJjTsJcUlouhG07nINxP0CXcC/f2VOnFjv0x5Ns=; b=D3d78vhXoVuEcdyKh4FpM7+rqVEOmevGgPCBmGLaJ5LMTB6CWW+uyOa2idaBTlU2Dw fxs3IVozpvdI0DkP9vF9b2rQqIplVj6HLyOboZBts3ZWoCtlxxhE2szf3M1gzKPPOA2c pOrJVxs3BmOQRt2b/8g8uXuyO95ST35yBO0S+yrUEPa5VQvJNjOD5vphSw1xIZv4TMAL He+fbd66Gx//yNd0p/uTpVMFVxAGFg45Eggl0NrJAOpSr8XoGCihGfcdXjAxlcrjqY1u dkfUUwWZT/IguwtAfxYfIuuo2vLpGtC0KuJHeL2axpMBgRIakzcubekNmHDBPBcL1LdQ TYZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728889067; x=1729493867; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Rbc6XJjTsJcUlouhG07nINxP0CXcC/f2VOnFjv0x5Ns=; b=o+PsbcnEZDVtZbjOFN1jygiZdi7Bi2N/TqFwdiQV7aJ6I0h8PWgIa3Xl1pjMJeRkt9 GFXYMhSwQrjTUsq1STOHNgGjYywDyi+8pxiMWRKlcHF70jKtLkssU4VsnDdGt0zs5k/I m6EUW4kDfCF+D8T42U+vO9++JfELn/dgojfvYdrGgtproLSSlbqZacYZHT+3czxDjNI1 DOlhq4Oa7EUbzKELBsysannJ6Vr0+Juo0frrT7sdcwzMHP1Ia8hro1sBnwC/ANNnxsnW /665Gq+Bx6wWmfOiA5FiMAEtz02pSppkd/lAhHCbQK8F+7u54iOunhOfkEVVkHGzBBXf 01GA== X-Gm-Message-State: AOJu0Yw3PW+OnBaRTizKvqsesgo8VLfXnif09Qwmve4o+xt4qVdaGc9D nKYKqQlFLgmO2AYUeKK+Rkyk6TulhEhKiBDgImANMV+NfU4QgnOn6hwpFDsxstEC3rfo+hzvV8K rsxE= X-Google-Smtp-Source: AGHT+IGyd+pL/ndfFmOv6vLWrI3D0Qpobrjvr+ZrdZ9LrtfowVZj1cOB8MrRM6MMFrz4gjs+FCB7TQ== X-Received: by 2002:a05:6a21:2d08:b0:1d6:de67:91c0 with SMTP id adf61e73a8af0-1d8c95abca4mr10553848637.27.1728889067325; Sun, 13 Oct 2024 23:57:47 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.192.229]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ea448f93a7sm6229120a12.20.2024.10.13.23.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 23:57:46 -0700 (PDT) From: Sunil V L To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] irqchip/riscv-intc: Fix no-SMP boot with ACPI Date: Mon, 14 Oct 2024 12:27:39 +0530 Message-ID: <20241014065739.656959-1-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241013_235750_142123_2900DA63 X-CRM114-Status: GOOD ( 12.04 ) 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 , Anup Patel , "Rafael J . Wysocki" , =?utf-8?b?QmrDtnJuIFQ=?= =?utf-8?b?w7ZwZWw=?= , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When CONFIG_SMP is disabled, the static array rintc_acpi_data with size NR_CPUS will not be sufficient to hold all RINTC structures passed from the firmware. All RINTC structures are required to configure IMSIC/APLIC/PLIC properly irrespective of SMP in the OS. So, allocate dynamic memory based on the number of RINTC structures in MADT to fix this issue. Fixes: f8619b66bdb1 ("irqchip/riscv-intc: Add ACPI support for AIA") Reported-by: Björn Töpel Closes: https://github.com/linux-riscv/linux-riscv/actions/runs/11280997511/job/31375229012 Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Alexandre Ghiti --- drivers/irqchip/irq-riscv-intc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 8c5411386220..f653c13de62b 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -265,7 +265,7 @@ struct rintc_data { }; static u32 nr_rintc; -static struct rintc_data *rintc_acpi_data[NR_CPUS]; +static struct rintc_data **rintc_acpi_data; #define for_each_matching_plic(_plic_id) \ unsigned int _plic; \ @@ -329,13 +329,30 @@ int acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res) return 0; } +static int __init riscv_intc_acpi_match(union acpi_subtable_headers *header, + const unsigned long end) +{ + return 0; +} + static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_rintc *rintc; struct fwnode_handle *fn; + int count; int rc; + if (!rintc_acpi_data) { + count = acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, riscv_intc_acpi_match, 0); + if (count <= 0) + return -EINVAL; + + rintc_acpi_data = kcalloc(count, sizeof(*rintc_acpi_data), GFP_KERNEL); + if (!rintc_acpi_data) + return -ENOMEM; + } + rintc = (struct acpi_madt_rintc *)header; rintc_acpi_data[nr_rintc] = kzalloc(sizeof(*rintc_acpi_data[0]), GFP_KERNEL); if (!rintc_acpi_data[nr_rintc])