Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4470447ybi; Mon, 27 May 2019 19:28:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqylDC4LGW2K5Yzo+/wUO7BBd4kMoilk77oQ0tg0vb/3VCci7mZDH4p9KgDVpz5Xj0kEMM++ X-Received: by 2002:a65:5781:: with SMTP id b1mr18729852pgr.110.1559010539050; Mon, 27 May 2019 19:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559010539; cv=none; d=google.com; s=arc-20160816; b=cIAdgJsF7BJ4zbdsLKcCIB9Kr4RpMCSe/vlmic9NAZPvHfg1I54ouFmXOUPMoNPohe swsQATZZskvMAVjZ2I9sfBFhT6ij2D3d3Nt+oIG4RUveWwyTblqC26ucge4dNp/+92u3 OsDevFJMe6EEVqbx+3JPXND+UTLHIfP+M5zyVtZ6mFxCoqQhhiVFXZmRB18PcN/v92xi sLVuR0CtWUqYR12nH68ixqEBBqPtOJyFxUKBEotS33exLWYHPTI7Sla7NL1j3tAYEOp8 H/1XeSKrDYgVA8AlfBVTfRsxqyv2OjYd291y397RmQ2Bi4E8A+fuQx6WlUkLiTntDqGQ sMPw== 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=6tEXYEseSrv1UbX98ysiISTfwpcHvrJawEQffl3byaE=; b=vkQVtLdfTYgNRD4djtJWjT8/NjKVuf71IyWJiHt+92zWsX9oJe7tjTz983W8R0nNKy NlXA6GXrUIULg1judYoBxVrQ0jf39ol8K8gTwIPrY9jKl5xHvH8FUQQuaovxMLEFrnf5 upVHG7GzfQn5krQ8bqCd2lTyYnoHVxm2ELcnTaJXqWxJDCbn/TCXw+EZ5gGKDqP+BiTO 6p1zci6Q/9m1sjiqnFmpQBrntcXWzvcaDIYsjZ5hLflsiWX806lFUoKkECYcKiO0EeEb YFtQMWeUg/Dmsyk2PDvydYPCZ6sTkDzFhP6TscTDscEInM0jWg8jeXe20BuXHI7W2ma7 BWtA== 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 g2si20300242plg.336.2019.05.27.19.28.43; Mon, 27 May 2019 19:28:59 -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 S1727993AbfE1CSk (ORCPT + 99 others); Mon, 27 May 2019 22:18:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17585 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727763AbfE1CSj (ORCPT ); Mon, 27 May 2019 22:18:39 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9AEC4840B8F2F504D4EB; Tue, 28 May 2019 10:18:37 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 28 May 2019 10:18:30 +0800 From: Shaokun Zhang To: , CC: Shaokun Zhang , Catalin Marinas , Will Deacon , Sudeep Holla , Jeremy Linton , Zhenfa Qiu Subject: [PATCH v4 2/2] arm64: cacheinfo: Update cache_line_size detected from DT or PPTT Date: Tue, 28 May 2019 10:16:54 +0800 Message-ID: <1559009814-17004-2-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559009814-17004-1-git-send-email-zhangshaokun@hisilicon.com> References: <1559009814-17004-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..0c0cd4d26b87 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_GPL(cache_line_size); + static inline enum cache_type get_cache_type(int level) { u64 clidr; -- 2.7.4