Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1455303pxk; Fri, 4 Sep 2020 09:44:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaRxD5x45W8j0jSemY8asFY2vNe/KlBplpmiuLJUv0azkT5vhfnrMLj6EoE20yBaMuh4Hr X-Received: by 2002:a50:cd5e:: with SMTP id d30mr9343056edj.190.1599237894610; Fri, 04 Sep 2020 09:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599237894; cv=none; d=google.com; s=arc-20160816; b=Mgp69FA6h6ZUWvlOoIraPP7/Kh3UGc6TFCh5Av0ml8CiGLwPzbHxFB2GV/5xlaP+wj yyzCwU479lIMjpETcg/ig4WN6IpldE5ATBycpQTJ4ZfHVr4zmg22qU22ilnott8H4KBF EiJ6lWs6/URSftj3c+I7pzACScf/mm74O2hnT6JOyE1uzP3m2bEm4TflQBh7sIZGEk69 rW1QUyobWDytGttwngRTx9OXc8yVbLOXLop7/2Uxqv0LfnaO2aCdjpt4WA3qbbSkidR9 vh6aj2vArqUk+J16rZxPyJaKq3s1DWBeuVBcAFm5TjhM8o1kxmY4eYybFekg0Y1jkDP6 gCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nAm7MkjzNXisCy7+ch7x2r9mkDHgpbPGhxOYS7CWrr8=; b=cHfdV+opxSNWvM+4yYT45U8CF1C5rfM4xjQwKYzBhQiFOUR+Wu3tdvPKwkwhvYGZhc 65LOwRf0XFSYo0bpSTnE0h5zmZKLL88SikYDchzoqlIsYv9dcwzIovqxhCyNcLdyyc5N tZi0zJPtSHWAI9AciBp9edqZj4GotUgD9wqDoV4NUP0w5SWwiP2rqSv0ZY/zQpG1+KLQ pGf0bUhE1BUGa+hSn/EIbD9GY2tDlaiIRpv6UuycwNKj7Inum/TwU4JnCTQoQkRIsJs9 fWFRXGMVJoW80f9I/P+uOWMwOCxFti1ev6LG+oN5uw5I860CdxjpldRE1sxh83NsijqJ lcLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=pMgwV8Aw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si3990370edb.20.2020.09.04.09.44.30; Fri, 04 Sep 2020 09:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=pMgwV8Aw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbgIDQne (ORCPT + 99 others); Fri, 4 Sep 2020 12:43:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgIDQnd (ORCPT ); Fri, 4 Sep 2020 12:43:33 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E371C061244 for ; Fri, 4 Sep 2020 09:43:31 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id 2so3460971pjx.5 for ; Fri, 04 Sep 2020 09:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nAm7MkjzNXisCy7+ch7x2r9mkDHgpbPGhxOYS7CWrr8=; b=pMgwV8AwEVjWFwQEo3b9bjaCVQOzRhRYlj67mzvuxz41dYkiFtbEa7de9YWFJBt4oo C+yXh9XQ+jGgCfDBdLREUZlqAbm+cGapY3Icls5ablcKOZx/kSMafbPFxakLEtKhNhjz sYjup3WZCwImNdUhySG86Xxpu9chVsn3Q833DtxkIBYkRWH9bvMQk1LelqvcaaeJCbRm C22tw26aDLzp+dp0ZgmT7oQbrAeVg0uiUCPmTUSuEtre2JXyXXpTxk8JAngl06yauasd PkYAqJjnVl5iEp1ju9BWgHrS9ZGl905m1H+404bcSDjZVgTv7aCdfLPI/h+z31GEggHm gE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nAm7MkjzNXisCy7+ch7x2r9mkDHgpbPGhxOYS7CWrr8=; b=NHPeoxolrJbWbtf8RdLa/ri6L983jbQDBVy8TeBAnolvnJnsPiDiKxs/+nbFp5qT83 fz7PxlkCu0D9lrAWLyL16xo4HIN2C2BJk/n9/5S735G/KKmzrLVgGVvQfxKAc/o2BFt6 Lmtb9KBHvsIognC/uAAjCzLsEK5gS97ZCnhZSeWMgf3OqkcW9p9hokvwe/vCApciMdtC TqkE4IiWjkfH8RWLp9eL5cBlDZv/1fnsdBq+WZYsymFl+c11Qt9f+Igl4XwtIiTsZARI IXRrM4YZudbli6NhHoe3dOusP8yQwd17sTL7kfpv5tXwTpbnxtB9Z6IDMPM7TkvnAXtG EAGw== X-Gm-Message-State: AOAM530jRxsImhLKi5eYlTS5FeCTnKrwiZGBUkABPhsKVrKQKZFwaEQr rpLgQ1RR2oNIFKm04Nhl1bzw9k6Cl48rn29yB6HJTw== X-Received: by 2002:a17:90b:360a:: with SMTP id ml10mr8567244pjb.198.1599237810537; Fri, 04 Sep 2020 09:43:30 -0700 (PDT) MIME-Version: 1.0 References: <20200904162121.279578-1-anup.patel@wdc.com> <20200904162530.GA32095@lst.de> In-Reply-To: <20200904162530.GA32095@lst.de> From: Anup Patel Date: Fri, 4 Sep 2020 22:13:18 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: Allow drivers to provide custom read_cycles64 for M-mode kernel To: Christoph Hellwig Cc: Anup Patel , Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Albert Ou , Atish Patra , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 4, 2020 at 9:55 PM Christoph Hellwig wrote: > > On Fri, Sep 04, 2020 at 09:51:21PM +0530, Anup Patel wrote: > > The TIME CSR is usually not present on most RISC-V systems so the > > M-mode firmware will emulate the TIME CSR for the S-mode (MMU) kernel > > whereas the M-mode (NoMMU) kernel will have to use MMIO clocksource. > > > > Currently, the get_cycles() implementation in asm/timex.h does not > > consider the above fact so we provide alternate implementation of > > the get_cycles() for the M-mode (NoMMU) kernel which expects drivers > > to provide custom MMIO based read_cycles64() method. > > Please just go back to the previous working version without all the > crazy indirections. > > The whole timer and irq code has been turned into a giant maze of > indirections lately. I respectfully disagree. IMHO, the previous code made the RISC-V timer driver convoluted (both SBI call and CLINT in one place) and mandated CLINT for NoMMU kernel. In fact, RISC-V spec does not mandate CLINT or PLIC. The RISC-V SOC vendors are free to implement their own timer device, IPI device and interrupt controller. We already have RISC-V systems (e.g. Andes AE350) where we have a different timer and IPI device instead of CLINT. The current code is more flexible and allows SOC vendors to write their own timer driver under drivers/clocksource. Regards, Anup