Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1549253iob; Fri, 29 Apr 2022 07:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS3qXv6EIK906vMBDyzvG8SthsmD4+WRSntU8pkEbhxieqEY45KfcVZJAh8pGyaDwgFxlh X-Received: by 2002:a17:90b:384b:b0:1d2:df41:3213 with SMTP id nl11-20020a17090b384b00b001d2df413213mr4343852pjb.164.1651243368649; Fri, 29 Apr 2022 07:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651243368; cv=none; d=google.com; s=arc-20160816; b=gBQmZLzaquTahhHKUFathvSUvWsz0Vlh3/1AUi5Ruyiqu5v9836XzJf2aV6c0V5n9X +0dYrf5We7TlnSAKPiiXhc+NZWT4fj5KODe/0+EvtWmcotgc59P+bHLomScPXTyOAdUY MLltO93NDV0GCshp9fFTbG78ZxizcJqv0gAluJ4cFbIa7zqRCa6plsvtvrLFbSYkR1YU zVeLdacgsfhT3OFmJKd/DFxqOz7OXtKsjhZ4VAbgLekD0WkPfrwQKZDVaNocw8vvU92K I7yTsd37tSLf6GIsbeLznDg8GkYt0SDxKOIyZhHv28hDULTy9DLiW2Ne5tLMN4dlyLMZ aUWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=cyVZf8iny+WZgSiJDlrRUPO19Yoe+qpQSWaG4z1p0Aw=; b=qeES2fFppPcn/hvq4mm4y0ZrClo01o5/5mHEYBAxBln0orrA0nQexiv2ulaeEiFN6y GMLesOU8HnDEFaV0bs6V6QbAyyo1v1uCzaPjfhjpfln4lxJgYq+uGOo6wwhngzNiJUjJ Lgp40iYB+konpJCZKMniodmTUk1qphkpWX4NN1Kbe1eWObSXGHeg0xinK7JFI3x8JUp7 fam44DDezc6a+orFH8vHTlPW5vout5bdP+1m+V7o9cc7QCTgcDYBqk/LmAPCecmMGACy /sAA7cnwqE42ATeg5kU2/ANUlex3mk03oXdzq2weXOZeBw+1K33wuZQCRgV3Cmp3QQER lduQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x207-20020a6331d8000000b003ab1fc361a7si7097257pgx.807.2022.04.29.07.42.31; Fri, 29 Apr 2022 07:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345106AbiD2K7W (ORCPT + 99 others); Fri, 29 Apr 2022 06:59:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358074AbiD2K7N (ORCPT ); Fri, 29 Apr 2022 06:59:13 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18F3EA76DD; Fri, 29 Apr 2022 03:55:54 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 97E2792009C; Fri, 29 Apr 2022 12:55:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 8B80892009B; Fri, 29 Apr 2022 11:55:53 +0100 (BST) Date: Fri, 29 Apr 2022 11:55:53 +0100 (BST) From: "Maciej W. Rozycki" To: Thomas Bogendoerfer cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] MIPS: Fix CP0 counter erratum detection for R4k CPUs In-Reply-To: <20220429100128.GB11365@alpha.franken.de> Message-ID: References: <20220429100128.GB11365@alpha.franken.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Apr 2022, Thomas Bogendoerfer wrote: > > Fix the discrepancy between the two places we check for the CP0 counter > > erratum in along with the incorrect comparison of the R4400 revision > > number against 0x30 which matches none and consistently consider all > > R4000 and R4400 processors affected, as documented in processor errata > > publications[1][2][3], following the mapping between CP0 PRId register > > values and processor models: > > > > PRId | Processor Model > > ---------+-------------------- > > 00000422 | R4000 Revision 2.2 > > 00000430 | R4000 Revision 3.0 > > 00000440 | R4400 Revision 1.0 > > 00000450 | R4400 Revision 2.0 > > 00000460 | R4400 Revision 3.0 > > interesting, where is this documented ? And it's quite funny that so far > everybody messed up revision printing for R4400 CPUs. That's just observation combined with past discussions with Ralf. Basically the PRId implementation number is 0x04 for both the R4000 and the R4400 (the only difference between the two CPUs is the addition of the write-back buffer in the latter one, making it weakly ordered). And then the PRId revision number matches exactly the documented CPU revision for the R4000, while for the R4400 you need to subtract 3 from the PRId revision number to get the documented CPU revision (i.e. what would be R4000 Revision 4.0 actually became R4400 Revision 1.0). At this time no old MIPSer from the SGI days may be around to confirm or contradict this observation. Documentation explicitly says[1]: "The revision number can distinguish some chip revisions, however there is no guarantee that changes to the chip will necessarily be reflected in the PRId register, or that changes to the revision number necessarily reflect real chip changes. For this reason, these values are not listed and software should not rely on the revision number in the PRId register to characterize the chip." but surely the author didn't have errata workarounds in mind plus all CPU revisions have already been manufactured so the mapping has been fixed. > > Conversely a system can do without a high-precision clock source, in > > which case jiffies will be used. Of course such a system will suffer if > > used for precision timekeeping, but such is the price for broken hardware. > > Don't SNI systems have any alternative timer available, not even the > > venerable 8254? > > all SNI systems have a i8254 in their EISA/PCI chipsets. But they aren't > that nice for clock events as their interupts are connected via an i8259 > addresses via ISA PIO. Interrupts are used for clock events, so you don't need one here. For clock sources you just read the counter. That said reading from the 8254 is messy too and you may need a spinlock (you need to write the Counter Latch or Read-Back command to the control register and then issue consecutive two reads to the requested timer's data register[2]). Which is I guess why support for it has been removed from x86 code. For non-SMP it might be good enough. > > With the considerations above in mind, please apply. > > will do later. Great, thanks! References: [1] Joe Heinrich: "MIPS R4000 Microprocessor User's Manual", Second Edition, MIPS Technologies, Inc., April 1, 1994, Chapter 4 "Memory Management", p.90 [2] "8254 Programmable Interval Timer", Intel Corporation, Order Number: 231164-005, September 1993, Section "Read Operations", pp.7-9 Maciej