From patchwork Thu Dec 16 23:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 525873 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0B40C433F5 for ; Thu, 16 Dec 2021 23:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbhLPXba (ORCPT ); Thu, 16 Dec 2021 18:31:30 -0500 Received: from mail-ot1-f54.google.com ([209.85.210.54]:35663 "EHLO mail-ot1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbhLPXb3 (ORCPT ); Thu, 16 Dec 2021 18:31:29 -0500 Received: by mail-ot1-f54.google.com with SMTP id x43-20020a056830246b00b00570d09d34ebso808839otr.2; Thu, 16 Dec 2021 15:31:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4CeoqAJqaVjfhKA4w5q6EV5uHP8MjvTT5rLWnYTWgO0=; b=OSr7yUYVmK7GKTzU/T7h4QIK+aGPZLZmhGynfzOquyxIklaFd2bhDAIHdEwgPeE62d bhvfC5qMdwIphsP8D7SH08peyxnBpscA9iaLSAgtSgleLU9Pmr7X3oBkur+vDo54s/1m ple9Da+GBcpS/ofajLoUnRotflgBAiLW4W35LCgT7Hj7dmISV28VV/w4jrakiSXJGdoT waR+s/pJ8+7Woakz4vOsjtiem52SQTIHva0u5WbGjAFgmujKMzubgk7nWTn5rD9O9FKo XN85+wD8gRBX1vDXa0RWuTdfJSJ9nenf5zTs0wLlA/yJCPrMXqAQJk5OhFdJ02jhQ9f8 BADQ== X-Gm-Message-State: AOAM531yDyObYxaCzpmukX1B4Tl2S22Ffkwuo+1vGk9i+XXJojSTpG4y 7ebbpRIfNiyhoh6rs+9sLw== X-Google-Smtp-Source: ABdhPJyRWgdmPmwqOixG+a/R4k7YU6rVBoJiG5qt9epniQEIzD8xrctDnOgNQDBQZkPK0EiqPA6Tqw== X-Received: by 2002:a9d:7cda:: with SMTP id r26mr329913otn.5.1639697488458; Thu, 16 Dec 2021 15:31:28 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:27 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 1/6] cacheinfo: Allow for >32-bit cache 'id' Date: Thu, 16 Dec 2021 17:31:20 -0600 Message-Id: <20211216233125.1130793-2-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In preparation to set the cache 'id' based on the CPU h/w ids which are 64-bit on arm64, allow for a 64-bit bit 'id' value. The only case that needs this is arm64, so unsigned long is sufficient. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Reviewed-by: Sudeep Holla Signed-off-by: Rob Herring --- drivers/base/cacheinfo.c | 8 +++++++- include/linux/cacheinfo.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index dad296229161..66d10bdb863b 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -366,13 +366,19 @@ static ssize_t file_name##_show(struct device *dev, \ return sysfs_emit(buf, "%u\n", this_leaf->object); \ } -show_one(id, id); show_one(level, level); show_one(coherency_line_size, coherency_line_size); show_one(number_of_sets, number_of_sets); show_one(physical_line_partition, physical_line_partition); show_one(ways_of_associativity, ways_of_associativity); +static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct cacheinfo *this_leaf = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%lu\n", this_leaf->id); +} + static ssize_t size_show(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 2f909ed084c6..b2e7f3e40204 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -48,7 +48,7 @@ extern unsigned int coherency_max_size; * keeping, the remaining members form the core properties of the cache */ struct cacheinfo { - unsigned int id; + unsigned long id; enum cache_type type; unsigned int level; unsigned int coherency_line_size; From patchwork Thu Dec 16 23:31:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 524596 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E960C433F5 for ; Thu, 16 Dec 2021 23:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbhLPXbc (ORCPT ); Thu, 16 Dec 2021 18:31:32 -0500 Received: from mail-oi1-f180.google.com ([209.85.167.180]:35398 "EHLO mail-oi1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhLPXba (ORCPT ); Thu, 16 Dec 2021 18:31:30 -0500 Received: by mail-oi1-f180.google.com with SMTP id m6so1171584oim.2; Thu, 16 Dec 2021 15:31:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XJxuQtRLTVfIiHxosQQwj5MJ9jgW00UdvVH4T37a4e0=; b=XBuaIGSmeZnCZwdW/QkU7UDvP7DuL7eUGodLzs7bCXGQOUuHRTMsE/9o44IZ20G+Sw lNKu0KdKuuBCdGPrgT6dOQ3A0xyf4KsXNKScDfVrCaRtquNEmE8kn6w3blxbj00eF922 d6syGkP8OgQqxS5QFw0lUswOyWWDNf37VUT0c4YUyr/swTKDVu50Q+HE1v962Z/EqBCw 25GgI92WBOgKGocMUpc/FqZ7tEyi9EXBD7q5rpVaUPUUsPk+w9omSWEMEx1D9OWuAkM5 /Mmx062hWGqLKbasCxuAUDDD/UOPKPtPAljOZLx8Ua+teKhp06ZImk5+IGbTwCaysaff EWgg== X-Gm-Message-State: AOAM5318Rgkfayjgo1VrkRn73VB+PqAda10IP4daYGrleLXxkZ94bmkS w5guH6RASBDHi9MXjUMEb/LG5V9hzQ== X-Google-Smtp-Source: ABdhPJy3osxEec/uFfDfvEc9vw+RCg25N1CQDsD8MFEWyLn67kai6YEnfUJhllbsJNoUI1R1/4kVtg== X-Received: by 2002:a05:6808:4d2:: with SMTP id a18mr136647oie.99.1639697489825; Thu, 16 Dec 2021 15:31:29 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:29 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 2/6] cacheinfo: Set cache 'id' based on DT data Date: Thu, 16 Dec 2021 17:31:21 -0600 Message-Id: <20211216233125.1130793-3-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Use the minimum CPU h/w id of the CPUs associated with the cache for the cache 'id'. This will provide a stable id value for a given system. As we need to check all possible CPUs, we can't use the shared_cpu_map which is just online CPUs. There's not a cache to CPUs mapping in DT, so we have to walk all CPU nodes and then walk cache levels. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Rob Herring --- v2: - Loop with for_each_possible_cpu instead of for_each_of_cpu_node as we will need the logical cpu numbers. --- drivers/base/cacheinfo.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 66d10bdb863b..21accddf8f5f 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -136,6 +136,36 @@ static bool cache_node_is_unified(struct cacheinfo *this_leaf, return of_property_read_bool(np, "cache-unified"); } +static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np) +{ + int cpu; + unsigned long min_id = ~0UL; + + for_each_possible_cpu(cpu) { + u64 id; + struct device_node *cache_node, *cpu_node; + + cache_node = cpu_node = of_get_cpu_node(cpu, NULL); + id = of_get_cpu_hwid(cpu_node, 0); + while ((cache_node = of_find_next_cache_node(cache_node))) { + if (cache_node == np) { + if (id < min_id) { + min_id = id; + of_node_put(cache_node); + break; + } + } + of_node_put(cache_node); + } + of_node_put(cpu_node); + } + + if (min_id != ~0UL) { + this_leaf->id = min_id; + this_leaf->attributes |= CACHE_ID; + } +} + static void cache_of_set_props(struct cacheinfo *this_leaf, struct device_node *np) { @@ -151,6 +181,7 @@ static void cache_of_set_props(struct cacheinfo *this_leaf, cache_get_line_size(this_leaf, np); cache_nr_sets(this_leaf, np); cache_associativity(this_leaf); + cache_of_set_id(this_leaf, np); } static int cache_setup_of_node(unsigned int cpu) From patchwork Thu Dec 16 23:31:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 525871 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06903C4332F for ; Thu, 16 Dec 2021 23:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbhLPXbi (ORCPT ); Thu, 16 Dec 2021 18:31:38 -0500 Received: from mail-ot1-f43.google.com ([209.85.210.43]:34361 "EHLO mail-ot1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbhLPXbb (ORCPT ); Thu, 16 Dec 2021 18:31:31 -0500 Received: by mail-ot1-f43.google.com with SMTP id x19-20020a9d7053000000b0055c8b39420bso810007otj.1; Thu, 16 Dec 2021 15:31:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4o9kmT6MVqI4c+B16gX5bvAJwnYM06bebAI8lgZufvw=; b=xsgwhi/9Zy2IB4a3hVrF1hCi90QfrqkyLiGx/7i/C/QMxAxyvJOT2iryoEIOgOA6qh BMjY4ONCCoc3mqalNSKylGY+Ewh8a8zUwrXQgive+aA/Ufi6rCK3J/EF1+C4eClslcLc 7UpQglfybcoi8CDK76w22NM10e8oWTvwfQhT7zhPNCnYCRFkjT9AqTn2MXcch9aHZ73X mRRMF2rtulEMAkZJMG32u04JuHhuaY2KwphqHfMZmaTUuTag/4UIMoW0XGIGCuS4WrbS YutEAfZ33vG2tS6Cc7LPjq30iiYzGtLM0ZtpA+SqzemlSFu8CHXP25PRNlwrR1hfyD3W gzJg== X-Gm-Message-State: AOAM531tS0QCLliXA/LJ9ICGRrUt9hlhT9xXS9Ep1qee6FiOPx7QhmUQ Wp4ujPq0+RSe8M1a/HjXMgJ4LmLhrw== X-Google-Smtp-Source: ABdhPJwJPckhRY71EAGczW5EOQ0K0FofxnZ4dWNjrtnwwnajnzwS1hMcl3WucPCL0Utsr711wG02+g== X-Received: by 2002:a9d:69ce:: with SMTP id v14mr335246oto.312.1639697491144; Thu, 16 Dec 2021 15:31:31 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:30 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 3/6] cacheinfo: Add cpu_affinity_map to store affinity for all CPUs Date: Thu, 16 Dec 2021 17:31:22 -0600 Message-Id: <20211216233125.1130793-4-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently, getting the cache CPU affinity for all possible CPUs requires walking the DT or ACPI tables. As that is already done once (for each CPU online event), let's save the affinity for possible CPUs so it can be retrieved later. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Rob Herring --- drivers/base/cacheinfo.c | 1 + include/linux/cacheinfo.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 21accddf8f5f..c9e5b48fac42 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -149,6 +149,7 @@ static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np) id = of_get_cpu_hwid(cpu_node, 0); while ((cache_node = of_find_next_cache_node(cache_node))) { if (cache_node == np) { + cpumask_set_cpu(cpu, &this_leaf->cpu_affinity_map); if (id < min_id) { min_id = id; of_node_put(cache_node); diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index b2e7f3e40204..37652cfdd8dc 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -56,7 +56,8 @@ struct cacheinfo { unsigned int ways_of_associativity; unsigned int physical_line_partition; unsigned int size; - cpumask_t shared_cpu_map; + cpumask_t cpu_affinity_map; /* possible CPUs */ + cpumask_t shared_cpu_map; /* online CPUs */ unsigned int attributes; #define CACHE_WRITE_THROUGH BIT(0) #define CACHE_WRITE_BACK BIT(1) From patchwork Thu Dec 16 23:31:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 525872 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 586B8C4321E for ; Thu, 16 Dec 2021 23:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbhLPXbe (ORCPT ); Thu, 16 Dec 2021 18:31:34 -0500 Received: from mail-oi1-f179.google.com ([209.85.167.179]:46835 "EHLO mail-oi1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhLPXbd (ORCPT ); Thu, 16 Dec 2021 18:31:33 -0500 Received: by mail-oi1-f179.google.com with SMTP id s139so1086937oie.13; Thu, 16 Dec 2021 15:31:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fStO5BsDAphXFibF4lRjLZT7FGTV609d5dBo3Se1e80=; b=DH3e2j+RjRxqEdP9cMpZ6tr1ScZdqaRUfZt5RC+mrgInMDf5QTkW5tKkl6/pQSMnSQ b7ParZHLLrMKoL8GMVCbm0IPXXVJp53aCSU1FvCyvpP/RawcoSB8Q9RoHtWIKvnDvifk KWbfti1VP00YEfJYHYvGeXyRatrS+FKE3T6dmQ/E47rOsKLfYxVkPX1C/xX/Zg07b9/W qxFXvEuc2EXTy6Qy1n+TmG0X9hRi0+S/RLmyrU1vORkIPvGS17VzWFb//vAJrGu00cN4 n1SJuFr5geXp6sN6wiMuJGwCtctI6llmr8pTeWXm+ZioF2S6tGA/4c7Wu0hVl6nci4kw y65g== X-Gm-Message-State: AOAM533qJqbiCLNwqhfy7PM5G84abAbL1UQsTHPBcOsUHrWpc4K/Zk5s So6Cu7kIgiK/zKyRJwzmcg== X-Google-Smtp-Source: ABdhPJx/pvFlJR8Gy0p3sOQ+0qXrZMYTlyfTf5U3XrIIVBVC1Am5JLBvV/CdZf5UED59JsXXYVeuaw== X-Received: by 2002:aca:120f:: with SMTP id 15mr154257ois.132.1639697492411; Thu, 16 Dec 2021 15:31:32 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:31 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 4/6] ACPI / PPTT: Populate the cacheinfo.cpu_affinity_map Date: Thu, 16 Dec 2021 17:31:23 -0600 Message-Id: <20211216233125.1130793-5-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The cacheinfo.cpu_affinity_map was added to list the possible CPUs a cache is associated with. Populate the cpu_affinity_map when parsing the ACPI PPTT for cacheinfo. With this, the cache CPU affinities are represented in the same way for DT and ACPI. Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: linux-acpi@vger.kernel.org Signed-off-by: Rob Herring --- drivers/acpi/pptt.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 701f61c01359..686018f4e7ed 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -418,6 +418,30 @@ static void update_cache_properties(struct cacheinfo *this_leaf, } } +static void acpi_set_cache_cpumask(struct acpi_table_header *table, + struct cacheinfo *this_leaf, + struct acpi_pptt_processor *match_cpu_node) +{ + int cpu; + + /* + * If we found the cache first, we'd still need to walk from each cpu. + */ + for_each_possible_cpu(cpu) { + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + struct acpi_pptt_processor *cpu_node; + struct acpi_pptt_cache *cache; + + cache = acpi_find_cache_node(table, acpi_cpu_id, + this_leaf->type, + this_leaf->level, &cpu_node); + if (!cache || cpu_node != match_cpu_node) + continue; + + cpumask_set_cpu(cpu, &this_leaf->cpu_affinity_map); + } +} + static void cache_setup_acpi_cpu(struct acpi_table_header *table, unsigned int cpu) { @@ -435,10 +459,11 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table, this_leaf->level, &cpu_node); pr_debug("found = %p %p\n", found_cache, cpu_node); - if (found_cache) + if (found_cache) { update_cache_properties(this_leaf, found_cache, cpu_node, table->revision); - + acpi_set_cache_cpumask(table, this_leaf, cpu_node); + } index++; } } From patchwork Thu Dec 16 23:31:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 524595 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAC22C433EF for ; Thu, 16 Dec 2021 23:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhLPXbj (ORCPT ); Thu, 16 Dec 2021 18:31:39 -0500 Received: from mail-ot1-f54.google.com ([209.85.210.54]:35672 "EHLO mail-ot1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhLPXbe (ORCPT ); Thu, 16 Dec 2021 18:31:34 -0500 Received: by mail-ot1-f54.google.com with SMTP id x43-20020a056830246b00b00570d09d34ebso809051otr.2; Thu, 16 Dec 2021 15:31:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ycz4c/Gy+gSmZUry4vxqmr8soODhiW4Pk4hS4ry0XPo=; b=I12Py2D0UcIzuNph1FKMMkWIcPQDGr6Y7Bm5ovLU3Nn4f0CUEGkrAtzptxnieavyQi bZ+8DBVpCKagkiQatcNHVdtGyzFGjiOTdP2rx/CWRaSr548QFV1f6qCDEU9/ITxRHL5k iPaXGYARhmXLUe7k7VwIp4Vwe2Ot996CbfmWPa4sHZscdCKPxO1iOHNg04JzcrHSRYPB 9lALCo1GG9xPc9BtaC9z8Zqr3H8f1GDcBjmyQbKdGMSFy/RtAWaej67tm8R1fUXWK2kZ qB2hUZzmyHk3Kdxaowol1zlvaNh5eFWEVwb9kgDqHaK6gcSqKZt8VKvShn6bbwi+0KPc ePYQ== X-Gm-Message-State: AOAM533MLgZt0xPfAJHwP5rvBtc3VhT/c8GRMIVgyRdJ+cLHkK51BxdX SLRnf/g0LhIJxTJNiYagZg== X-Google-Smtp-Source: ABdhPJyh4CVWOSFgpPwp/C989LpGlcZ4EDHX0BCRj+KlvLZBQOUm6n+RD5gWqzZBNKys7NRir5sPEQ== X-Received: by 2002:a9d:6001:: with SMTP id h1mr317714otj.257.1639697493658; Thu, 16 Dec 2021 15:31:33 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:33 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 5/6] cacheinfo: Use cpu_affinity_map for populating shared_cpu_map Date: Thu, 16 Dec 2021 17:31:24 -0600 Message-Id: <20211216233125.1130793-6-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Now that we have a full map of possible shared CPUs, we can iterate over just the cache's cpu_affinity_map instead of all online CPUs to populate the shared_cpu_map. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Rob Herring --- drivers/base/cacheinfo.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index c9e5b48fac42..d7129b2fa9dc 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -32,12 +32,6 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) } #ifdef CONFIG_OF -static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, - struct cacheinfo *sib_leaf) -{ - return sib_leaf->fw_token == this_leaf->fw_token; -} - /* OF properties to query for a given cache type */ struct cache_type_info { const char *size_prop; @@ -228,16 +222,6 @@ static int cache_setup_of_node(unsigned int cpu) } #else static inline int cache_setup_of_node(unsigned int cpu) { return 0; } -static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, - struct cacheinfo *sib_leaf) -{ - /* - * For non-DT/ACPI systems, assume unique level 1 caches, system-wide - * shared caches for all other levels. This will be used only if - * arch specific code has not populated shared_cpu_map - */ - return !(this_leaf->level == 1); -} #endif int __weak cache_setup_acpi(unsigned int cpu) @@ -274,16 +258,15 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) continue; cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); - for_each_online_cpu(i) { + for_each_cpu(i, &this_leaf->cpu_affinity_map) { struct cpu_cacheinfo *sib_cpu_ci = get_cpu_cacheinfo(i); if (i == cpu || !sib_cpu_ci->info_list) continue;/* skip if itself or no cacheinfo */ + sib_leaf = sib_cpu_ci->info_list + index; - if (cache_leaves_are_shared(this_leaf, sib_leaf)) { - cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); - cpumask_set_cpu(i, &this_leaf->shared_cpu_map); - } + cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); + cpumask_set_cpu(i, &this_leaf->shared_cpu_map); } /* record the maximum cache line size */ if (this_leaf->coherency_line_size > coherency_max_size) From patchwork Thu Dec 16 23:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 524594 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DE7BC4321E for ; Thu, 16 Dec 2021 23:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbhLPXbo (ORCPT ); Thu, 16 Dec 2021 18:31:44 -0500 Received: from mail-oi1-f173.google.com ([209.85.167.173]:39475 "EHLO mail-oi1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhLPXbf (ORCPT ); Thu, 16 Dec 2021 18:31:35 -0500 Received: by mail-oi1-f173.google.com with SMTP id bf8so1148882oib.6; Thu, 16 Dec 2021 15:31:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tg2oCBFq5G88h+ck8cHgDUdDvDFgPbXH7dXGlomqHsQ=; b=bkhaFBoUjW+8we8ZsYlDsX9gi1mQkHAWGeCvgCRRHoG0vWA77O0iVpAXp7tG+fVljM VLgxMbNxcQJ8AmhbkHSiTxXNxE+Y+NSYjZ1956QtSIvRMj8KPLCGQ6Xsyc3+tmpZbu0a II/Rj4OztF9aEqwb1S2PnSqK3+yNdKUNTJymnB6mRsXwbH6dWFInaXJouiQI6sKRgwAl QLIJVH2lgjWPfg+J/oKQ/jRuUZlvYgcXnfTRdkMwYQj44yMkASlNtFm/2f2DcJftMB1k ArzADVKScZYfRiw21TgWqOMmdS3Ux/xHLp7GQ1c5psj1EVoMcPbbVJCtIKdfdlQk44DJ VXvA== X-Gm-Message-State: AOAM533goHL6HKh7X2a1HiP2nTC3W27L2XHCRvYLRI7sBGGna6X/pgfq +hIvrSFNGnMfwOSYBdMWououJ6kU0Q== X-Google-Smtp-Source: ABdhPJzvFgF0rdegvhuQuQN0VTaHMD+mkgyRbm/qcieGt8GT8s/5GRC4K1MdoZJ+46/yeYCuwAF3Yw== X-Received: by 2002:a05:6808:218b:: with SMTP id be11mr169423oib.80.1639697494978; Thu, 16 Dec 2021 15:31:34 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:34 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 6/6] cacheinfo: Add cacheinfo_get_cache_affinity() function Date: Thu, 16 Dec 2021 17:31:25 -0600 Message-Id: <20211216233125.1130793-7-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add a cacheinfo_get_cache_affinity() function to retrieve the CPU affinity mask for a given cache identified by level and cache id. This is needed by Arm MPAM to get the CPU affinity of MPAM enabled caches. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Rob Herring --- include/linux/cacheinfo.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 37652cfdd8dc..5e72420cdc75 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -123,4 +123,28 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level) return -1; } +/* + * Get the CPU affinity of the cache associated with @cpu at level @level and + * with identifier @id. + * cpuhp lock must be held. + */ +static inline int cacheinfo_get_cache_affinity(int cpu, int level, int id, + cpumask_t *mask) +{ + struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu); + int i; + + for (i = 0; ci->info_list && i < ci->num_leaves; i++) { + if ((ci->info_list[i].level == level) && + (ci->info_list[i].attributes & CACHE_ID) && + (ci->info_list[i].id == id)) { + cpumask_copy(mask, &ci->info_list[i].cpu_affinity_map); + return 0; + } + } + + return -EINVAL; +} + + #endif /* _LINUX_CACHEINFO_H */