Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp170649ybl; Tue, 20 Aug 2019 17:45:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqytoz8MBQxyx1N4vkQ85BU+SJy1okfVVDbszUjQyHI0WxqkqfVhJftJWWCtaRYzci/xFRbk X-Received: by 2002:a17:90a:8408:: with SMTP id j8mr2658340pjn.24.1566348305848; Tue, 20 Aug 2019 17:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566348305; cv=none; d=google.com; s=arc-20160816; b=ZO9Cs5dTnVkamqm+7B9EyU1hMH2uWuDLUqQG33HLx1u95p8XCkO/5ImMYiU5otIWyY c2b9dNjGNvrLZ1+fERF8hra1i8wu4xpcEeWNcximgl73R5Em/8jQlMNngsigOKrQoPeL iuackNIA/w/ufubqGshi9zXY3SfCLiQjDEo3TZPZgzuaptqG0wtptB6zrObLbubsdSkN ZPd0uMpnftCVn74xtTJpsBSIG7MDUhixQjC9LpI0xie/thaPFUXZl4REHq11KKF5lmo4 m3ff2rKJdfzfuCAI1xpJD8DMEFbenvvFwi0UoAV6rroMISIrAoYyFWv+e6+8tEMrNN53 TfXg== 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; bh=7kzUMExUz2kT6YI2RQxjxlgqbIf6eyJBMXYNORW3A6U=; b=B0bQqmlcKNTD8+egVfce1BxAvjd005GtE5eBstIt0gAc8RAZWyJS8WNDD9fX5i1/BO A+d6lYLzT9mbFxbXNJxkl+s0YQLoby0B7n2S2E3fdgd8L4g6euG01xVuc5NmxoqIq51+ OX0l7yUUSiDF6WNN5OeNw6hrA3zw9M5+7B8ojxvzU9eJlWd8wL2v6Jiirzi4DlmQanb3 0sIEFiHyPlVoamA/ZfMrDBuaMYL+1RUA655//dn1tPTfWVncqCvsX15dCmcoFxb9XLE0 93ZdURK7uq8R6/+vVPnGVtVGO2gB+I+w/K3fsEdtSa1mxCxU1XwybZ2U92a9XlppahZL P10Q== 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 c130si14540050pfc.103.2019.08.20.17.44.50; Tue, 20 Aug 2019 17:45:05 -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 S1726596AbfHUAmo (ORCPT + 99 others); Tue, 20 Aug 2019 20:42:44 -0400 Received: from verein.lst.de ([213.95.11.211]:32992 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfHUAmo (ORCPT ); Tue, 20 Aug 2019 20:42:44 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 7B5F168B20; Wed, 21 Aug 2019 02:42:41 +0200 (CEST) Date: Wed, 21 Aug 2019 02:42:41 +0200 From: "hch@lst.de" To: Atish Patra Cc: "hch@lst.de" , "paul.walmsley@sifive.com" , "palmer@sifive.com" , "linux-riscv@lists.infradead.org" , Damien Le Moal , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 08/15] riscv: provide native clint access for M-mode Message-ID: <20190821004241.GA20250@lst.de> References: <20190813154747.24256-1-hch@lst.de> <20190813154747.24256-9-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 21, 2019 at 12:24:31AM +0000, Atish Patra wrote: > > +static inline void clint_set_timer(unsigned long delta) > > +{ > > + writeq_relaxed(clint_read_timer() + delta, > > + clint_time_cmp + > > cpuid_to_hartid_map(smp_processor_id()));' > > This is not compatible with 32 bit mode. IIRC, timecmp is a 64 bit on > RV32 as well. Here is the implementation in OpenSBI. writeq alwasy writes 64-bit anyway, but the deltas is just 32-bit per the Linux clocksource API. > > +static inline cycles_t get_cycles(void) > > +{ > > +#ifdef CONFIG_64BIT > > + return readq_relaxed(clint_time_val); > > +#else > > + return readl_relaxed(clint_time_val); > > +#endif > > Same comment as above. Both RV32 & RV64 bit have 64 bit have 64 bit > precission for timer val. You have to read 32 bits at a time and "or" > them to get 64 bit value. Here is the implementation from OpenSBI But the Linux API is only going to read 32-bits of that, same as for the rdtime pseudo-instruction used by the current SBI-based code. Note that I've reworked this area a bit for v4, which I'm going to send out soon, including cleanups to the existing code to make a few of these things more obvious: http://git.infradead.org/users/hch/riscv.git/shortlog/refs/heads/riscv-nommu.4