Received: by 10.223.176.46 with SMTP id f43csp704521wra; Sat, 20 Jan 2018 03:13:58 -0800 (PST) X-Google-Smtp-Source: AH8x225LNZniHVp4oUVK8B+c7FErdN28XF7AL4veZ0Jmj7sdRNBFAbK48oznn1OwJR3A5jwd6jJy X-Received: by 10.98.215.30 with SMTP id b30mr1990146pfh.50.1516446838555; Sat, 20 Jan 2018 03:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516446838; cv=none; d=google.com; s=arc-20160816; b=kRwd9vdUoYKy/87iW+xQ+fmmU0crp9RM+TkAqhW7IHhMxRqWmKNe5Ho5K3tavNXVNp DY85cy8Wnu+0CVe6nHfwY/oEZPF0yt6B9lHmKgcK5bZdBQ+AsrPtV+69fqCrjRDCZIvO IDyv3R9zpWOwf+s7ncOW1PJT/CEQ7H8OHo6lfr18POzT4HK2FrwWvs8ZxuAas443TEWb T7dcnK/mKhwWPUSXyDfHF6UBRUSZAT3+BCqAVJtGNgyAlbVbnbmla4HQCLguxP9wNjDw HXh1tS7myQRnUYFm5nL8E8hN2C/iZTQuHUot0kO2Uw7Sr1ZpRL5Okx8XMiJhL3YoWEaO 7LtQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=57bX/3BiH68zRdaDwRbABeHXIIwDAUyr99+lVYXFAig=; b=G794Zt0pRj/4N5xynwoSWuOVyjdxJbT7GAm3DyIARda0w2C7O/VbTJEFH9aRZlkTCk PgbUbR+BeBlfoK44Fhkb4zYlXYqrnFO5sKHz040khlyciY7O2MQceldfJDBEy6H7krEB jyDVmN7Vhtrjja7yQOEcnCuXD+zkGuyyT9akdPNcyow1hRNiCKetRsSWdDcIo94zdQB9 yRtO2aqPvdCJBlZxOIk8l2F4b8d934AOQhv21NVBkuvJc3IAPB5AaM026Y3jDCp8D+Lj +WomnNtqGwckJWdhXMD3prM6hqdVcYvNTBbftB5RFT2n9+euv1uDvltzj4w5L3sDAg1M HM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RFkBEd/2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h186si6477976pgc.707.2018.01.20.03.13.44; Sat, 20 Jan 2018 03:13:58 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RFkBEd/2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754862AbeATLLe (ORCPT + 99 others); Sat, 20 Jan 2018 06:11:34 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:46749 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbeATLLY (ORCPT ); Sat, 20 Jan 2018 06:11:24 -0500 Received: by mail-io0-f193.google.com with SMTP id f34so4778485ioi.13; Sat, 20 Jan 2018 03:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=57bX/3BiH68zRdaDwRbABeHXIIwDAUyr99+lVYXFAig=; b=RFkBEd/247tKl+woRueo9jc7lI+n/Yn+G/kgZRjsWc7zyGuZNDo95zqvMUgqMfTW/p pUl89JCQSrQpXl//5qULSEfvfvCWaLkg5hLgSH+9+2ufCIlqI4qPNjqWJN7TYywU90NN 8NN8RZ25lriUZcj/PBov/WMWVypTK9IxDspZY/qauBGgcz0oXH9yHMPaFOWweje5KCDN t/YbnsSX4b7Smi73W7DyBJTR8k4ZISCfp5QyYwmOkEQQoZgq5LMd6fOXvgH5TEzHoeo2 YUfhaPjYHtZ65ztyzaHQ3BkURY5jE5pkspgUYN2Prlen/pEuW0L2duIqZNSOEdi4zrdo cUyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=57bX/3BiH68zRdaDwRbABeHXIIwDAUyr99+lVYXFAig=; b=oHfS2qX446SAuTMN+HeQgN1Bkt2/qHgIf5+XzOwBXgEhOFQkQVLNNQiyb3zmvOGXv4 rhWAbF9KZXZ4xCWYVRBWhiexSNVh/FuVkw46qIFXVYJnPe/TE3Apqg+/aPPjHP+7N0W1 TmcNgcknvFtCv5iwVpuOeSs+yKoKej9UCZDF9ud0lIYGmtnT11eENzjmheLSkvfH6Cao vNu2UW6og3XuStxgCCrZzmpfeCZ4rDK0OdMVQupYMWbxnfytBzP5dGIqAwa2pavacGeO /Jethg2MgjijneLZ7ttP3UWsNLFseYmQ29QG7pU8Wt0QixX0qYR1vAwVbPKQlMZKIKs0 CxMg== X-Gm-Message-State: AKwxytd1VXtK92apoqHmOzCm/uCxeBA/PxIS8WCKitx++3ZIXDgQPe3R pUCVuggAeP6nbjNdJFgdUw3VaDcShYCXcdPelOw= X-Received: by 10.107.180.207 with SMTP id d198mr1570501iof.187.1516446683344; Sat, 20 Jan 2018 03:11:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.175.34 with HTTP; Sat, 20 Jan 2018 03:11:22 -0800 (PST) In-Reply-To: References: From: Vincent Chen Date: Sat, 20 Jan 2018 19:11:22 +0800 Message-ID: Subject: Re: [PATCH v6 2/3] clocksource/drivers/atcpit100: VDSO support To: Arnd Bergmann Cc: Greentime Hu , Greentime , Linux Kernel Mailing List , linux-arch , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Networking , DTML , Al Viro , David Howells , Will Deacon , Daniel Lezcano , linux-serial@vger.kernel.org, Geert Uytterhoeven , Linus Walleij , Mark Rutland , Greg KH , Guo Ren , Randy Dunlap , David Miller , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Rick Chen , Rick Chen , Vincent Chen 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 2018-01-18 19:08 GMT+08:00 Arnd Bergmann : > On Mon, Jan 15, 2018 at 6:57 AM, Greentime Hu wrote: >> From: Rick Chen >> >> VDSO needs real-time cycle count to ensure the time accuracy. >> Unlike others, nds32 architecture does not define clock source, >> hence VDSO needs atcpit100 offering real-time cycle count >> to derive the correct time. >> >> Signed-off-by: Vincent Chen >> Signed-off-by: Rick Chen >> Signed-off-by: Greentime Hu > > I'm a bit puzzled by this patch, can you explain how the vdso actually > manages to access the clock hardware? It looks like you make the > physical address and the register offset available to user space, but > how does it end up accessing it? > > Arnd Dear Arnd: Accessing clock hardware in vdso can be divided to 2 step. 1. Setup an additional memory mapping for clock hardware in user space when establishing vdso-needed memory mapping In arch_setup_additional_pages(), kernel establishes memory mapping for vdso's text and vdata page in user space. In order to make clock hardware be accessible in user space, we try to establish an additional memory mapping for clock hardware here based on clock information from driver. This page is located between vdata page and vdso text page. For safety, this region for clock accessing is read-only. 2. Accessing clock hardware in vdso After step 1, clock hardware is accessible in user space through memory-mapped IO. However, it is not enough to access a specific register. Therefore, we store register offset information in vdata page to make it visible in user space. Now, vdso can derive the address of counter register by summation of __get_timerpage() and counter register offset where __get_timerpage() is used to derive the virtual address of memory-mapped clock. Vincent