From patchwork Tue Jan 24 15:40:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 13114316 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 C1F04C38142 for ; Tue, 24 Jan 2023 15:42: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bHexwyQkeii2+aknlx/fmgxP3gWwfmgGI5tkZQUHxXQ=; b=lsbDuGI5S9vMdx 7Lrn+kL0DgzWTkAKXVFuWFe88zpWMc9qhKCdjgAXuZ7pc8XOFJM+/oCbpwbj8ff22KsqLYzDYBoDL toPGTZk86yAAVZtEfOpWjmFp6CvVHxaa1mpLLvh+1L0LPvxT6uCtjhIxbI8ebQhTN+gkqqNyg4GBK Xvb3JijS40dadRs56M0JHcM8GpcIBw0earnY/djb1bJv/lcSP53S98I7P6vEIeZtJl7ZIIhogMDoy 9TZ1xOzOlLwGbMeFvE4gz6VFZ/lX18H3IegBsfGRrTNUHdpqe9aRDucEtlojGOREhchG42kF6norU eq8GpvorCTmlFbUpovBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQH-004ZgR-L8; Tue, 24 Jan 2023 15:41:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQE-004Zes-Fq for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 15:41:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33A0BC14; Tue, 24 Jan 2023 07:41:57 -0800 (PST) Received: from cam-smtp0.cambridge.arm.com (pierre123.nice.arm.com [10.34.100.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 01B003F5A1; Tue, 24 Jan 2023 07:41:12 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Conor Dooley , Dan Carpenter , Pierre Gondois , kernel test robot , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Palmer Dabbelt , Oliver Upton , Akihiko Odaki , Gavin Shan , Jeremy Linton , linux-arm-kernel@lists.infradead.org Subject: [PATCH -next v2 1/3] cacheinfo: Initialize variables in fetch_cache_info() Date: Tue, 24 Jan 2023 16:40:46 +0100 Message-Id: <20230124154053.355376-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124154053.355376-1-pierre.gondois@arm.com> References: <20230124154053.355376-1-pierre.gondois@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_074118_593154_43BD27B2 X-CRM114-Status: GOOD ( 10.47 ) 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 Set potentially uninitialized variables to 0. This is particularly relevant when CONFIG_ACPI_PPTT is not set. Reported-by: kernel test robot Link: https://lore.kernel.org/all/202301052307.JYt1GWaJ-lkp@intel.com/ Reported-by: Dan Carpenter Link: https://lore.kernel.org/all/Y86iruJPuwNN7rZw@kili/ Fixes: 5944ce092b97 ("arch_topology: Build cacheinfo from primary CPU") Signed-off-by: Pierre Gondois Reviewed-by: Conor Dooley --- drivers/base/cacheinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 418a18acc8f9..f6573c335f4c 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -424,7 +424,7 @@ int allocate_cache_info(int cpu) int fetch_cache_info(unsigned int cpu) { struct cpu_cacheinfo *this_cpu_ci; - unsigned int levels, split_levels; + unsigned int levels = 0, split_levels = 0; int ret; if (acpi_disabled) { From patchwork Tue Jan 24 15:40:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 13114317 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 9A906C25B4E for ; Tue, 24 Jan 2023 15:42:31 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YLy/RS24yAd+MvX3FNQdTAuJvzfy6v20Vi35+QdwqZs=; b=4nwWVFMdBTWdeQ U9bUGS6z2loQIpVdUBW/slnlyuSbQcf1b8GAvmePESYduN/D7uvkYXlfVrL/mpDLg03bpHq2RqQUX H2ja7ClDjn9kvxR/7FkP7IwFQjisin4GKlBMTKmspvlEDnS7ID5GVijIwvLbewUpEe5gUJLEzZrc7 o3sS2yW4VhHK3sUMAKeZq8q5eXhdJVArOSTBzgPHN3Zqaz9LITN+5Q6B3deVOsz1XSysNwYZr/uS9 W1C96mOMMCkbL4EtG9pW3zYSgQOAN5qONYDBcvXpg/LvF5GIUfi4685dYKQW4eAY71uthcGp2VgTs QTwNeM+Vvd+LOQAM5g4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQT-004ZkZ-9S; Tue, 24 Jan 2023 15:41:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQJ-004Zh0-Op for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 15:41:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B66AE4B3; Tue, 24 Jan 2023 07:42:04 -0800 (PST) Received: from cam-smtp0.cambridge.arm.com (pierre123.nice.arm.com [10.34.100.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E9F893F5A1; Tue, 24 Jan 2023 07:41:20 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Conor Dooley , Dan Carpenter , Pierre Gondois , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Akihiko Odaki , Palmer Dabbelt , Gavin Shan , linux-arm-kernel@lists.infradead.org Subject: [PATCH -next v2 2/3] cacheinfo: Make default acpi_get_cache_info() return an error Date: Tue, 24 Jan 2023 16:40:47 +0100 Message-Id: <20230124154053.355376-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124154053.355376-1-pierre.gondois@arm.com> References: <20230124154053.355376-1-pierre.gondois@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_074123_880919_A534506D X-CRM114-Status: GOOD ( 14.32 ) 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 commit bd500361a937 ("ACPI: PPTT: Update acpi_find_last_cache_level() to acpi_get_cache_info()") updates the prototype of acpi_get_cache_info(). The cache 'levels' is update through a pointer and not the return value of the function. If CONFIG_ACPI_PPTT is not defined, acpi_get_cache_info() doesn't update its *levels and *split_levels parameters and returns 0. This can lead to a faulty behaviour. Make acpi_get_cache_info() return an error code if CONFIG_ACPI_PPTT is not defined. Also, In init_cache_level(), if no PPTT is present or CONFIG_ACPI_PPTT is not defined, instead of aborting if acpi_get_cache_info() returns an error code, just continue. This allows to try fetching the cache information from clidr_el1. Signed-off-by: Pierre Gondois --- arch/arm64/kernel/cacheinfo.c | 2 +- include/linux/cacheinfo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c index d3fe9542c370..bf348b8d321f 100644 --- a/arch/arm64/kernel/cacheinfo.c +++ b/arch/arm64/kernel/cacheinfo.c @@ -59,7 +59,7 @@ int init_cache_level(unsigned int cpu) } else { ret = acpi_get_cache_info(cpu, &fw_level, NULL); if (ret < 0) - return ret; + fw_level = 0; } if (fw_level < 0) diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index dfef57077cd0..908e19d17f49 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -100,7 +100,7 @@ static inline int acpi_get_cache_info(unsigned int cpu, unsigned int *levels, unsigned int *split_levels) { - return 0; + return -ENOENT; } #else int acpi_get_cache_info(unsigned int cpu, From patchwork Tue Jan 24 15:40:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 13114318 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 69718C38142 for ; Tue, 24 Jan 2023 15:42:44 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7JjwULbKb8b65b5j8O48Jf9gcT0mdqI9x54INfZaPhE=; b=W4xIUlo8yApxxI Q0O1w31DDONsoDFI3rfuuhjhidKelJdIUU/c9BB/jfUwJ6fyVGNyM19TVnPswVL/EKHaKA6Fd10hC 70uPw6EBMr/+de5wg8VAyYFOfEQdH+6TrFLdpCrsvtHl5j9Bylm0KCWSbG5wcXufvr2Le78uySeOo 07jSP0aV8Fng8ceaw9VUsUpxjCgb9lxtm28Fdkcln0SKZpHrV1EkoE/4djlO0Ifgy8f2ghyxpTN03 PJOEbdHhAR7+dwWULUu9xFVK2et5Pq3zXz8wdydE/Imn6ZkfV1VrFu6FZML8tJpb5EhATryRululS 5lHmAwgX8feKnXNBo3+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQe-004Zo8-41; Tue, 24 Jan 2023 15:41:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKLQR-004Zjx-NG for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 15:41:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 143ADFEC; Tue, 24 Jan 2023 07:42:12 -0800 (PST) Received: from cam-smtp0.cambridge.arm.com (pierre123.nice.arm.com [10.34.100.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E3903F5A1; Tue, 24 Jan 2023 07:41:28 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Conor Dooley , Dan Carpenter , Pierre Gondois , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Akihiko Odaki , Palmer Dabbelt , Gavin Shan , linux-arm-kernel@lists.infradead.org Subject: [PATCH -next v2 3/3] cacheinfo: Remove unused check in init_cache_level() Date: Tue, 24 Jan 2023 16:40:48 +0100 Message-Id: <20230124154053.355376-4-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124154053.355376-1-pierre.gondois@arm.com> References: <20230124154053.355376-1-pierre.gondois@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_074131_832604_DFCBB4FE X-CRM114-Status: GOOD ( 10.10 ) 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 commit e75d18cecbb3 ("arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level") checks the fw_level value in init_cache_level() in case the value is negative. Remove this check as the error code is not returned through fw_level anymore, and reset fw_level if acpi_get_cache_info() failed. This allows to try fetching the cache information from clidr_el1. Signed-off-by: Pierre Gondois --- arch/arm64/kernel/cacheinfo.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c index bf348b8d321f..c307f69e9b55 100644 --- a/arch/arm64/kernel/cacheinfo.c +++ b/arch/arm64/kernel/cacheinfo.c @@ -62,9 +62,6 @@ int init_cache_level(unsigned int cpu) fw_level = 0; } - if (fw_level < 0) - return fw_level; - if (level < fw_level) { /* * some external caches not specified in CLIDR_EL1