Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3271418ybi; Sun, 26 May 2019 19:11:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWKkollWxv28gcetdm3n6i87opfHHLHRE2K8mB6hwLLexOj3ruM3ZbiyIrmxe+qXdgCi+D X-Received: by 2002:a63:e24:: with SMTP id d36mr26818136pgl.80.1558923069192; Sun, 26 May 2019 19:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558923069; cv=none; d=google.com; s=arc-20160816; b=KXLpdBQ3wi6fP/SgKNxoOVxJ+gDN/60zkzI05pqBjltuqJhKoNKgOs10WU4rbJPiDs BnVf0/TfDu39n+wQPFnCgaNJYhXEGGfn+uULWqQY7zQBFrGlqbVatrIP+pb3NAQzkFsb MCwc/Z4Tv8KerUJ9yhF5vlVzs+UFmnG9kB7CLJCX7aVSva/o66Ej5e1h2BtQObXhmnYN BivwZpcw1aWZ0Z4cMK+ff0i/s7FbMM83sV1cpY+oF/pBiIpOcZC+tP2zfTqmanTH+rs4 cTKO2Ofp8B5F9/bjELcmpML/3purMoOpgfccU5ePDuwk4Kg9Y1SjAA5+NI2Z49X84ppm S+7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ggpgHydRVOWbabA0tPaMFrccNxGSv5vdRYuMIwWjkYc=; b=T7ow+efeE8tE3uZL7UXj3TOSE9K6+Ym+DbYDRl1T1gUHWWupFg80BtwJQvM2HGcRp7 y+PpeCG0SbH0RnpZ8K35hkVjhwCEokkIWZlX9bh4dEsBuClF+QjeUyMM32ftKmRs/Wl/ QhJ5m2NrNBiyN3y75z1Ot+UhPrMsY3gRwPzzEh3Z+VC9WpmIqbKDRdDsXTe/xv2W+DOC 0m2NQLmGZJCSz98bfjIEh5AjDnSmdoqY+c0a3eYRTZdMSyJ/UfVV0zdT3jlF0qyPhs1m +trgHT0TfTYzZZQTShWkBXRsSY93JZD/0zONWlo3J0xPS4zlDO85SFyVpYMTqzM6Xyxc rPTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg10si16671220plb.28.2019.05.26.19.10.53; Sun, 26 May 2019 19:11:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726209AbfE0CHz (ORCPT + 99 others); Sun, 26 May 2019 22:07:55 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17578 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725886AbfE0CHz (ORCPT ); Sun, 26 May 2019 22:07:55 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 67E4C2D1CCFD67CCE6FA; Mon, 27 May 2019 10:07:53 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Mon, 27 May 2019 10:07:45 +0800 From: Shaokun Zhang To: , CC: Shaokun Zhang , Catalin Marinas , Will Deacon , Sudeep Holla , Jeremy Linton , Zhenfa Qiu Subject: [PATCH v3 2/2] arm64: cacheinfo: Update cache_line_size detected from DT or PPTT Date: Mon, 27 May 2019 10:06:08 +0800 Message-ID: <1558922768-29155-2-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558922768-29155-1-git-send-email-zhangshaokun@hisilicon.com> References: <1558922768-29155-1-git-send-email-zhangshaokun@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cache_line_size is derived from CTR_EL0.CWG field and is called mostly for I/O device drivers. For HiSilicon certain plantform, like the Kunpeng920 server SoC, cache line sizes are different between L1/2 cache and L3 cache while L1 cache line size is 64-byte and L3 is 128-byte, but CTR_EL0.CWG is misreporting using L1 cache line size. We shall correct the right value which is important for I/O performance. Let's update the cache line size if it is detected from DT or PPTT information. Cc: Catalin Marinas Cc: Will Deacon Cc: Sudeep Holla Cc: Jeremy Linton Cc: Zhenfa Qiu Reported-by: Zhenfa Qiu Suggested-by: Catalin Marinas Signed-off-by: Shaokun Zhang --- arch/arm64/include/asm/cache.h | 6 +----- arch/arm64/kernel/cacheinfo.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/cache.h b/arch/arm64/include/asm/cache.h index 926434f413fa..758af6340314 100644 --- a/arch/arm64/include/asm/cache.h +++ b/arch/arm64/include/asm/cache.h @@ -91,11 +91,7 @@ static inline u32 cache_type_cwg(void) #define __read_mostly __attribute__((__section__(".data..read_mostly"))) -static inline int cache_line_size(void) -{ - u32 cwg = cache_type_cwg(); - return cwg ? 4 << cwg : ARCH_DMA_MINALIGN; -} +int cache_line_size(void); /* * Read the effective value of CTR_EL0. diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c index 0bf0a835122f..3d54b0024246 100644 --- a/arch/arm64/kernel/cacheinfo.c +++ b/arch/arm64/kernel/cacheinfo.c @@ -28,6 +28,17 @@ #define CLIDR_CTYPE(clidr, level) \ (((clidr) & CLIDR_CTYPE_MASK(level)) >> CLIDR_CTYPE_SHIFT(level)) +int cache_line_size(void) +{ + u32 cwg = cache_type_cwg(); + + if (coherency_max_size != 0) + return coherency_max_size; + + return cwg ? 4 << cwg : ARCH_DMA_MINALIGN; +} +EXPORT_SYMBOL(cache_line_size); + static inline enum cache_type get_cache_type(int level) { u64 clidr; -- 2.7.4