From patchwork Thu Feb 15 11:14:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13558148 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4338DC48BEF for ; Thu, 15 Feb 2024 11:15:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39DA58D0023; Thu, 15 Feb 2024 06:15:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 326AF8D0021; Thu, 15 Feb 2024 06:15:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1530A8D0023; Thu, 15 Feb 2024 06:15:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F02598D0021 for ; Thu, 15 Feb 2024 06:15:19 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6FCCBC08AF for ; Thu, 15 Feb 2024 11:15:19 +0000 (UTC) X-FDA: 81793781958.15.D4C26B3 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf11.hostedemail.com (Postfix) with ESMTP id 6CD3F40014 for ; Thu, 15 Feb 2024 11:15:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707995717; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gldrYfsNoE+p68z/GluCIPH2FFId53qTRmkkCqGwZoc=; b=BUIOUanXVCjrPU6vZ3qFsm6/i159wlVkmn5nQ3Hy6l2ntv2yMU3kJm3Agp9SfQ/dRNFR1C xEBSmqdxm/aBiweTvLqEAHy2eynxUp6y5vgBaEwAaMnz7MU4Lom+f5FUDiQsN7UzvRFyR0 HkrvNukJuWjS6a0gapZAgaEkTCRMo2Q= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707995717; a=rsa-sha256; cv=none; b=qtiZEJ1M01z8Wxkod9SmsAW46B8yRLATuxezKFrEG44ujJnqU/7Ps2hPYdE7BHfn0LcGdy Wj1n7Vqw1Ua1wqwGWoZoQlh7gnSQ0JxipVSTLMpy7UIOjNtcEu5bNfQdXs+CEKGQxaqk5h WMDXh7kPxnTaQiKtBHWXNkeZE2WdARU= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TbC7S09wVz6K8tY; Thu, 15 Feb 2024 19:11:48 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 8C0DE1400D4; Thu, 15 Feb 2024 19:15:15 +0800 (CST) Received: from SecurePC30232.china.huawei.com (10.122.247.234) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 15 Feb 2024 11:15:14 +0000 From: To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v6 11/12] ACPI:RAS2: Add driver for ACPI RAS2 feature table (RAS2) Date: Thu, 15 Feb 2024 19:14:53 +0800 Message-ID: <20240215111455.1462-12-shiju.jose@huawei.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20240215111455.1462-1-shiju.jose@huawei.com> References: <20240215111455.1462-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.234] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6CD3F40014 X-Stat-Signature: 4iq7rnpom39p1kz33fk1ijxw9mexa5ht X-HE-Tag: 1707995717-648638 X-HE-Meta: U2FsdGVkX1+vCAvbXYom2X/3wo16Ad5j4p9/vze73AtMx4X6C0MeBnr7HbbL6X6FCLcsuxlULyHcJDAPw8LBqdJJTSlMB6KfIT5Rq9rpRJPFgNO9L/tWW7ksjkDBZ5AyHSg8HfO24lJ76BdVjVpEvOxXPxrGrodstYcI0sg73y2kUmqL9iu64wm0y1hw+ilpgWWczwxztFmK8nfbWvO3Ci0qG2hGV4tnksR0NYFwesCA79F9Pr4+bXAZrnWHUlehf/Jxdel2/Gq7E/sw+Q5f7qU/H9AEhKpnaV0Qi7xRMY7Z7EdHTHcDofE65PFCLQwguaZKCrCnMMcMfHMNBxdXl0ZQ3l0qmhlr/aLYyajLC9ZD2uOh0KLhbmHTLmJ0dVyrURk/RyR2V+7Z5CwNSRX5kiZtg1y+gQrlJz6qYq4R94z0HwHyGK75AzOvqO5/LICoTC1mQj8OzNjpbmWAY1yIpD8Pr0p2P5+e4KT1VJb+vWgZ2bXxTgOTLob3JOJTovjD1gI0MbkmIZbrAU1XRruIH2Z2ZxCdujQjXRk05wQzXLPf7V5nR6Ep2B2BBMIyAzg6n8mHkFSPEgJy6NZcZ4wv17oK+3zjMqi0qNuj+SNJqJjyWdHV7QsH8UXQpT1aKRbmh3Sqrq3aJs0TM+EEWXnQJLrS4ymYvxrpM+HoIqC0neR+daK/aJQJz0kC+fnTamRQsTYaCETOu2Wd96+BBVdQFE2RQCeFO5jFwxmbYJBGn0eakKZHEymAHwhh+eyxuNLKpNdrTk0zgNFW5tike7Kskq7F8JB8x7Y+tGvF+sDLduUwWS7zdqV7N6O08a8cjvlsYVM3WvUxkwiQl3g3CTct+lDLBu/a3LKNtnkTulC04wwM/hCwDQYIZoMBBMQIMl1eMNamdIvFsVZbGsI7qeBq9qB1oagWcmOsIMIRiVoUUHa2d0/hJfQGAHHkS38SeAmuAUBcPP4sfDkEWRAKuxK MWorA6UN rGGkZF8hAzmTEmejQFufShM2Jkpsc6EEW7XuBH6izIvQQcPxNZGF12zIhy5JbVQa/lGnrBiMCBqLBTjSGFRgCON26ubnJ6K6nnlNjoyVxc/3t7KdpsSFZOkpmJA18mT2mSUOM/iqSv5b7QZE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Shiju Jose Add support for ACPI RAS2 feature table (RAS2) defined in the ACPI 6.5 Specification, section 5.2.21. This driver contains RAS2 Init, which extracts the RAS2 table. Driver adds platform device, for each memory feature, which binds to the RAS2 memory driver. Signed-off-by: Shiju Jose --- drivers/acpi/Makefile | 2 +- drivers/acpi/ras2_acpi.c | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 drivers/acpi/ras2_acpi.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 5c984c13de78..b2baf189ea0e 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -105,7 +105,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o -obj-$(CONFIG_ACPI_RASF) += rasf_acpi_common.o +obj-$(CONFIG_ACPI_RASF) += rasf_acpi_common.o ras2_acpi.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o diff --git a/drivers/acpi/ras2_acpi.c b/drivers/acpi/ras2_acpi.c new file mode 100755 index 000000000000..b8a7740355a8 --- /dev/null +++ b/drivers/acpi/ras2_acpi.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ras2_acpi.c - Implementation of ACPI RAS2 feature table processing + * functions. + * + * Copyright (c) 2023 HiSilicon Limited. + * + * Support for + * RAS2 - ACPI 6.5 Specification, section 5.2.21 + * + * Driver contains RAS2 init, which extracts the RAS2 table and + * registers the PCC channel for communicating with the ACPI compliant + * platform that contains RAS2 command support in hardware.Driver adds + * platform device which binds to the RAS2 memory driver. + */ + +#define pr_fmt(fmt) "ACPI RAS2: " fmt + +#include +#include +#include +#include +#include +#include + +#define RAS2_FEATURE_TYPE_MEMORY 0x00 + +int __init ras2_acpi_init(void) +{ + u8 count; + acpi_status status; + acpi_size ras2_size; + int pcc_subspace_idx; + struct platform_device *pdev; + struct acpi_table_ras2 *pRas2Table; + struct acpi_ras2_pcc_desc *pcc_desc_list; + struct platform_device **pdev_list = NULL; + struct acpi_table_header *pAcpiTable = NULL; + + status = acpi_get_table("RAS2", 0, &pAcpiTable); + if (ACPI_FAILURE(status) || !pAcpiTable) { + pr_err("ACPI RAS2 driver failed to initialize, get table failed\n"); + return RASF_FAILURE; + } + + ras2_size = pAcpiTable->length; + if (ras2_size < sizeof(struct acpi_table_ras2)) { + pr_err("ACPI RAS2 table present but broken (too short #1)\n"); + goto free_ras2_table; + } + + pRas2Table = (struct acpi_table_ras2 *)pAcpiTable; + + if (pRas2Table->num_pcc_descs <= 0) { + pr_err("ACPI RAS2 table does not contain PCC descriptors\n"); + goto free_ras2_table; + } + + pdev_list = kzalloc((pRas2Table->num_pcc_descs * sizeof(struct platform_device *)), + GFP_KERNEL); + if (!pdev_list) + goto free_ras2_table; + + pcc_desc_list = (struct acpi_ras2_pcc_desc *) + ((void *)pRas2Table + sizeof(struct acpi_table_ras2)); + count = 0; + while (count < pRas2Table->num_pcc_descs) { + if (pcc_desc_list->feature_type == RAS2_FEATURE_TYPE_MEMORY) { + pcc_subspace_idx = pcc_desc_list->channel_id; + /* Add the platform device and bind ras2 memory driver */ + pdev = rasf_add_platform_device("ras2", &pcc_subspace_idx, + sizeof(pcc_subspace_idx)); + if (!pdev) + goto free_ras2_pdev; + pdev_list[count] = pdev; + } + count++; + pcc_desc_list = pcc_desc_list + sizeof(struct acpi_ras2_pcc_desc); + } + + acpi_put_table(pAcpiTable); + return RASF_SUCCESS; + +free_ras2_pdev: + count = 0; + while (count < pRas2Table->num_pcc_descs) { + if (pcc_desc_list->feature_type == + RAS2_FEATURE_TYPE_MEMORY) + platform_device_put(pdev_list[count++]); + } + kfree(pdev_list); + +free_ras2_table: + acpi_put_table(pAcpiTable); + return RASF_FAILURE; +} +late_initcall(ras2_acpi_init)