From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757981AbcIHJiG (ORCPT ); Thu, 8 Sep 2016 05:38:06 -0400 Received: from foss.arm.com ([217.140.101.70]:42224 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbcIHJiE (ORCPT ); Thu, 8 Sep 2016 05:38:04 -0400 Date: Thu, 8 Sep 2016 10:38:01 +0100 From: Will Deacon To: Vincent Siles Cc: Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: lsl / lsr possible confusion in v7_flush_dcache_all Message-ID: <20160908093801.GB1493@arm.com> References: <20160908091520.GE14909@vsiles-Desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160908091520.GE14909@vsiles-Desktop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 08, 2016 at 11:15:20AM +0200, Vincent Siles wrote: > While reading the v7_flush_dcache_all (arch/arm/mm/cache-v7.S), I > stumbled upon this line: > > # r10 is the current cache level > 127: add r2, r10, r10, lsr #1 @ work out 3x current cache level > > If we want r2 to be 3 * r10, we should compute r10 + (r10 << 1), which > is lsl, not lsr. > > I check for a recent kernel, the issue seems to still be here: > repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > revision: d71f058617564750261b673ea9b3352382b9cde4 This code is take pretty much verbatim from the ARM ARM and, despite being fairly obfuscated, does what it says on the tin. r10 is incremented by 2 each time round the loop, so this is basically doing 2i + (2i / 2). Will