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 (Arm)" X-Patchwork-Id: 12696538 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 2F726C433FE for ; Thu, 16 Dec 2021 23:34:02 +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=WmF3L3Wcd2GV9KJdcLVcn0BYPPkEoe3RbGOFsCWqy5c=; b=0YyENeoU0obdbB WWdD+QvOaqtWmvfCS2SEqadmXnOIi/7hfNco+kckYITzPh8Ponvzq4+KrUqCKVm544x86FjOgFfwR CRlnu93jNWRFodQgwc3n6+NjcXJdKyVHmXuQ2Y/mJ1IfmY2R5mX4YvPn3+N3mNsjheF2w5F10xxHS 6+DQ0D7NVRapPtIEVsMybEQSOLXss4ei05dv/HySuE9txMuZ8cCnVI5sHncjHmNnhQFrn4LnxNnW/ HJ9kZCn5nAxZ2iw4V8cdk0mwjcLv8KlC9VFAQM3U4i//lkKDSeIyNh65jrwT7+kpUyuytXK8qi/OJ q9yLr+rOXVuJp/PPBGKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1my0Ep-007wdd-8q; Thu, 16 Dec 2021 23:32:39 +0000 Received: from mail-oi1-f172.google.com ([209.85.167.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1my0Dn-007wIp-Hw for linux-arm-kernel@lists.infradead.org; Thu, 16 Dec 2021 23:31:36 +0000 Received: by mail-oi1-f172.google.com with SMTP id w64so1111779oif.10 for ; 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=QQFvdz6JdWAI+Y38xniBbFFVjhrGKEUZnR2iqvimqAjfY2p+ErXoY6LzTGR0qHdei/ a5V20TdQFedfeViS1Z6lxubCiYv8cTJ1PGUL6rKVv1ACt2dVo8wgduc/SIfWUCn8XTEg sI7CqRZUAUahMuMCADcjVXKyU5OJ9GOjP3R2CuU2TGJM4egQxuxWxROd24Xd+uuKUvHH xYmJkJM6eFoVzJzSr2rqFkOWG4Mi17g9RnQ4cBD/lUcYD9xqXGmkC0tt6GK7vV4DD2Zw NIKxdYQXzUgw0oTWZ19Q4uxYT34Cd6gZufC3lODTXpkP7Z41y3k9EXYCmVANNNqDEq9x QKeg== X-Gm-Message-State: AOAM530NT3RjHoadY1T+y1Qz0THm2ujIs7FQmHp6JNP1PFPT+kvzEZNo Xfoj3dWFKDceDFAZMqVfxQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211216_153135_613042_6C44FE9D X-CRM114-Status: GOOD ( 15.20 ) 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 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 */