Received: by 10.223.176.46 with SMTP id f43csp715498wra; Sat, 20 Jan 2018 03:27:42 -0800 (PST) X-Google-Smtp-Source: AH8x226BMU+4nvZk6mbnpBsMJM38UMxv5T43bXTsS1Pnk2pD0UQfMn/yj83NoWlUFIpdx3qYZ7yV X-Received: by 10.99.97.208 with SMTP id v199mr1643877pgb.387.1516447662869; Sat, 20 Jan 2018 03:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516447662; cv=none; d=google.com; s=arc-20160816; b=gRwGCSL/yBXlNAuvyDDnZnv0RXypf3cZheaD3ySnTrqmImu+PCc0/IYtbLhcKggQ0R EUJxmz3EpsE3I78bwAuHJeyogCK4uQ+8YEk+W8BRYG3nbOdHqCAl43PTjjYZIqrZW1Zr IGL656VDXuYAyjl4r++c7fwO4jyjl/cmFKCWrD6vG75glKBFyWmY2cmSyeOlwFbHFdr2 W7akECXWVbv6CW+MT3tFesRtJwdVNE4+UyQ8hobyYqZcq6v37//wjKPrDRRGQFny0qRk ueaNFk4hUYTqxqqcvoVzJISwEyA3r7prW8qxkLG91eCvRja71WNZvZURptaFSpGy5Azc 3aOg== 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=/hNxdggRu81irsxRwkRYqDqLySBB+xExZ9g77vJ6A5E=; b=v5LURIKTM51y8tiJv0GWZQxK8hGDIg+DsZ+Fe0FbhcPodUo+CHgQp4EzJsu30JyTKn c6dIAt5YzsHgCFt9Yfy6aWG4Tm1t3HZsYgkJLoNHJ9dXU0wrAAWHUrd9SkquYTAG3bGJ 83rFV3VwOaZBnb940P77aIW/PYqU9/gzolfsDEQJXR2q9wQbg+OeRpDueiZzH+P6rapb N3PDbvXHnVguAZf4rLTCRYF7FIS3qkpt9PTKf6acnVJpjwiXXidHxcZmFoHFLVI/NpLU QeaU1cwwbYCs61x/jZwIuL8GdsiChNO61hpfYCsiPRd1stOYKBAC/N/EH6YI9vgLRtoS CQ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sUAP/wWz; 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 r29si2206811pfj.102.2018.01.20.03.27.18; Sat, 20 Jan 2018 03:27:42 -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=sUAP/wWz; 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 S1754637AbeATLYA (ORCPT + 99 others); Sat, 20 Jan 2018 06:24:00 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:36794 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbeATLXw (ORCPT ); Sat, 20 Jan 2018 06:23:52 -0500 Received: by mail-it0-f67.google.com with SMTP id p124so4947322ite.1; Sat, 20 Jan 2018 03:23:51 -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=/hNxdggRu81irsxRwkRYqDqLySBB+xExZ9g77vJ6A5E=; b=sUAP/wWzcSO/02V2BJd9Edk7alBUtuoAG2/4nScsORn/yHkzyHoqKiHjCAOdne2IhB 0iEUr4nEsFOT4VoSu0hwcR23avfzDE8ql/V4bKxzkdoJP78W9/rC8WO3CLVUjN+uaZQq hFDd2liTyLjYbZWF4fsI7fNsMW5bTbxTn0EqG+Hu+fqsyUcgw5MEekMI//MZrYY1eMAR 1Kj3ZFoliUJlulHNJnCRM2XsF0G83j1qYgfnXCkdYuDWcgARcK0rce82X3qicU25Ypnv nPbKWqvBc3bTkQOEWMz0xboNNITBLkigKUzpnAC9qnhSOyTSj5IIcjd3gL+ANIVO0nvJ qXCA== 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=/hNxdggRu81irsxRwkRYqDqLySBB+xExZ9g77vJ6A5E=; b=sgdlaSmvLb+2XcHZi+LyFxOv9WXMqxvg44KGRWir0gvqdNCbc3ziIf+1R1UedD+SLS EVhTGH7XS025IuXV9D0i1HonLtjmqp3fNbnGzHFCELlzP1FCVo/tRHxD2CYTBldjPMkA ek5AzjVn6tvgn7gVc+htKM50QsYwrQ4X8uKWHsm0zhbyRHUyxJnKYpnHFcBFPeqnd8Zn Xs90YgElhm9Uo/hm9YPviwXat5hcrNccIksNwyaElVw0AbgTFW4SC2v66Sdarm/PWU6r mpxuEoqVzPGWA/k+howmH5ljyWL/Uq0w20i8BjgPpDMicPpcUmdqw1L1W0FlNBSydglV /TSg== X-Gm-Message-State: AKwxyte8ZmYPwen0uDFsENYuC5zz00SU94N8JAyci/r/L1fLbCd02WOg ZpKut7kKot1eBkL/kq1dQQ64ramFmClpEFFpGJU= X-Received: by 10.36.14.86 with SMTP id 83mr1259726ite.77.1516447431448; Sat, 20 Jan 2018 03:23:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.175.34 with HTTP; Sat, 20 Jan 2018 03:23:51 -0800 (PST) In-Reply-To: References: From: Vincent Chen Date: Sat, 20 Jan 2018 19:23:51 +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 Correct the composition Dear Arnd: 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. 2018-01-20 19:11 GMT+08:00 Vincent Chen : > 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