Received: by 10.223.185.116 with SMTP id b49csp562420wrg; Wed, 21 Feb 2018 03:13:32 -0800 (PST) X-Google-Smtp-Source: AH8x224xijddfhPblawu4GZoUrIl/2jEozLJ1Y6t/RzQSs3udHDhLx3GEFp5IIiPuDmCGgnBPBdB X-Received: by 10.101.81.4 with SMTP id f4mr2554278pgq.30.1519211612855; Wed, 21 Feb 2018 03:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519211612; cv=none; d=google.com; s=arc-20160816; b=eYiNIJyBOJDGkdjz/aINMK+3wEcMxIXSlfInc53PRY/BowVBd3X+9m5XbuuInFRWkr mvaHk6ochAUXku1p0QcPwa5+N+N6l97Z0DerXAOE04+LEvwowgd5upt+6AkSNA6tcLRQ Xds5lOSs3AdXqQRys7CKGbfIkyIuWjwKuXd3nGm/B2XoNcwM7Zvpd3UngqsY+D6yrXLx tEUJt434aFj6jxR/ehHozJCrjLFjwFc5b+oLuZw9xwqtuEg8rq2AiEJ2bvdluO3IzNEF guMU8nR39nFwiJLutMsnCYGjAC8ZCYREY5F0XHor8KMqjdigsl/wsEPBLMQEPS8ILKAi AFOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ceVDA7D3PEsOJpPq5qmNDKlyocoCfS1ObP1+TsrZcFI=; b=vlg1AS+CPD1lG1d9a3ZZ6sEj5Qhi3PbXA3TtLeSrxTpRRDkzegJPLCdE9m/qG5hU27 qe7BXb/O1ADB/p24vxjXBtaKh7QkyIdmKM6XGwG99yVWaqrGhaWlHFXqIFZ32CW6MyMx 4NBnEEEX6myegBug6VWQOK0PxZ8mf6OM+MHSaSOTH2y/GovZidqcOnLIgFqfgpuwjQfx dfhJRDrb4M7x+SjYQmqbJkZra+BtQP2jmW6cBiqKOkUS45IDgl2ms8B6O7OJOpJe54d2 D1SZPFb0HxgNZeVwgTtwC3sV/zKbdxIyNI2uT8E6ndVjBrcCzOAaHcxuwFQ6kPKesLC3 G+8g== 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 w8si10919338pfk.17.2018.02.21.03.13.18; Wed, 21 Feb 2018 03:13:32 -0800 (PST) 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 S1753529AbeBULMj (ORCPT + 99 others); Wed, 21 Feb 2018 06:12:39 -0500 Received: from foss.arm.com ([217.140.101.70]:53070 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752871AbeBULMh (ORCPT ); Wed, 21 Feb 2018 06:12:37 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87FCB80D; Wed, 21 Feb 2018 03:12:37 -0800 (PST) Received: from localhost (unknown [10.1.27.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4A8493F487; Wed, 21 Feb 2018 03:12:37 -0800 (PST) Received: from cmarinas by localhost with local (Exim 4.89) (envelope-from ) id 1eoSKA-0005T8-5i; Wed, 21 Feb 2018 11:12:34 +0000 Date: Wed, 21 Feb 2018 11:12:33 +0000 From: Catalin Marinas To: Shanker Donthineni Cc: Will Deacon , linux-kernel , linux-arm-kernel , kvmarm , Marc Zyngier , Thomas Speier , Philip Elcan , Vikram Sethi Subject: Re: [PATCH v2] arm64: Add support for new control bits CTR_EL0.DIC and CTR_EL0.IDC Message-ID: <20180221111233.gylb6v4yxqnn6gyj@localhost> References: <1519095546-24420-1-git-send-email-shankerd@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519095546-24420-1-git-send-email-shankerd@codeaurora.org> X-TUID: 7WkJpRZE/L/p User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 19, 2018 at 08:59:06PM -0600, Shanker Donthineni wrote: > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index f55fe5b..4061210 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -1095,6 +1095,27 @@ config ARM64_RAS_EXTN > and access the new registers if the system supports the extension. > Platform RAS features may additionally depend on firmware support. > > +config ARM64_CACHE_IDC > + bool "Enable support for DCache clean PoU optimization" > + default y > + help > + The data cache clean to the point of unification is not required > + for instruction to be data coherence if CTR_EL0.IDC has value 1. > + > + Selecting this feature will allow the kernel to optimize the POU > + cache maintaince operations where it requires 'DC CVAU'. > + > +config ARM64_CACHE_DIC > + bool "Enable support for ICache invalidation PoU optimization" > + default y > + help > + Instruction cache invalidation to the point of unification is not > + required for instruction to be data coherence if CTR_EL0.DIC has > + value 1. > + > + Selecting this feature will allow the kernel to optimize the POU > + cache maintaince operations where it requires 'IC IVAU'. A single Kconfig entry is sufficient for both features. > @@ -864,6 +864,22 @@ static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int __unus > ID_AA64PFR0_FP_SHIFT) < 0; > } > > +#ifdef CONFIG_ARM64_CACHE_IDC > +static bool has_cache_idc(const struct arm64_cpu_capabilities *entry, > + int __unused) > +{ > + return !!(read_sanitised_ftr_reg(SYS_CTR_EL0) & (1UL << CTR_IDC_SHIFT)); > +} > +#endif > + > +#ifdef CONFIG_ARM64_CACHE_DIC > +static bool has_cache_dic(const struct arm64_cpu_capabilities *entry, > + int __unused) > +{ > + return !!(read_sanitised_ftr_reg(SYS_CTR_EL0) & (1UL << CTR_DIC_SHIFT)); > +} > +#endif Nitpick: no need for !! since the function type is bool already. > diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S > index 758bde7..7d37d71 100644 > --- a/arch/arm64/mm/cache.S > +++ b/arch/arm64/mm/cache.S > @@ -50,6 +50,9 @@ ENTRY(flush_icache_range) > */ > ENTRY(__flush_cache_user_range) > uaccess_ttbr0_enable x2, x3, x4 > +alternative_if ARM64_HAS_CACHE_IDC > + b 8f > +alternative_else_nop_endif > dcache_line_size x2, x3 > sub x3, x2, #1 > bic x4, x0, x3 > @@ -60,6 +63,11 @@ user_alt 9f, "dc cvau, x4", "dc civac, x4", ARM64_WORKAROUND_CLEAN_CACHE > b.lo 1b > dsb ish > > +8: > +alternative_if ARM64_HAS_CACHE_DIC > + mov x0, #0 > + b 1f > +alternative_else_nop_endif > invalidate_icache_by_line x0, x1, x2, x3, 9f > mov x0, #0 > 1: You can add another label at mov x0, #0 below this hunk and keep a single instruction in the alternative path. However, my worry is that in an implementation with DIC set, we also skip the DSB/ISB sequence in the invalidate_icache_by_line macro. For example, in an implementation with transparent PoU, we could have: str , [addr] // no cache maintenance or barrier br Is an ISB required between the instruction store and execution? I would say yes but maybe Will has a better opinion here. -- Catalin