Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5223339yba; Mon, 13 May 2019 07:24:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/ZAHqUxogGYe2WbFGUO43Bc/5vw/DDA0YmmwoRnsdvh45pIw8ng1QxwPyoEnaDZ/sxe+G X-Received: by 2002:a65:6295:: with SMTP id f21mr31682915pgv.129.1557757458100; Mon, 13 May 2019 07:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557757458; cv=none; d=google.com; s=arc-20160816; b=k0IxRzjuRtbIab/wuAppHeHz3Ifa8O5a2D5+SuNQg/tEZyqsYjElcn7i1oFONgzV0y 1lj8zE+F5TD57ASc7ZXz27Nm/pCKqNVxZIl+WSiph2xq1pfl/xsq+otlZA5G1BnSYQXG xfmRKRU0gQzd9bItaz/xxXdGxBrSW66PnJPxq5O/RTxClBYv6n3QdC3qVVoaaxFRuJGg cGI6wPEtUWRdkFGJXdmwAbExBz34qIsHhrNY2h9/BuKasf3Mj9iThcrcvi6Rssee3EiY micDytYuRDudm06gQkcOqPLX9WWIG/TGq1outMwk9VddCSsxyHqJWTwt6qwV72Fljn1j tJUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=qsB8mONNRQdOykcbEvsV450l7EoJeG+DifZn5TSN7ps=; b=dixpOMpIpvqetBOutArrBPO6eD6JhIV5DGE3YEdcowuNCcRe5ZFhpeUvo4eL2bbODK 5BNOXV1xVkAWbNE3GLOMrAo6DH4P+wx/lLVPP/RB07QCrg/2WbcuqAjpabx+CcXGMPAE IbQdIw+elS32DbUzmBcejBy7HlzLe1YNdEO6u0hB4JmqGCXGT7pi8PtGV0I5OXsXlnWu 7uEyt6c0yDaGb2Ox9t+mjCYVf+pbHTLUqja7qYoLoI079Wbl7wU6bLGhnxUhiwj0C0M4 YqfeIej3VFLC6ceIVeFbCKirO0aexiMiZe8xid7LtRNDjLDwtH7nJrp8ndO74XnZ7c/m WauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ay4NVZxh; 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=QUARANTINE 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 31si17010309pli.390.2019.05.13.07.24.01; Mon, 13 May 2019 07:24:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ay4NVZxh; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730424AbfEMOGa (ORCPT + 99 others); Mon, 13 May 2019 10:06:30 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42850 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbfEMOGa (ORCPT ); Mon, 13 May 2019 10:06:30 -0400 Received: by mail-lj1-f195.google.com with SMTP id 188so11075516ljf.9; Mon, 13 May 2019 07:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=qsB8mONNRQdOykcbEvsV450l7EoJeG+DifZn5TSN7ps=; b=Ay4NVZxhPPakV2Xa8ZzJZzt3f9h2e8RV0ysLwuqZz0ywIO4mjHDRP+QgbsWRG8UYaI 6CXEPjftNdlGuxQ/Q+CN6MFP4Oap/4Cfj12cN9xFnPMgdO4se0gSY6txfe1DwIrrg1OR gNQcV+ZJhBpJqfHtK3Lvn8/jg2hhsBk4jdQjDe7N3kr//KZ+2YrmFkrzI2k5JH9bZn6m iSMWPGK7l4Y1ONN16e5vprNbcQINWLuS3dT2UjK+klPjGxJ+kNKTTJSXoUFzJhix7HBR fELI6THhsonzWifsdS+wn+FXrjDnANjHl0AMvidipn0DYWrUS80lUYFHqK6n1Gq4V2Lm AxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=qsB8mONNRQdOykcbEvsV450l7EoJeG+DifZn5TSN7ps=; b=EeE5ZfbnglyJEAViSusKKSYF4fgyo5sN/JADSfEBEsle9FzrWjVQAz+EgP8jClATL/ hk1D/umJKwPuIBNBkZxP4PLR+dxKy+Ufef24NU5BWKBL5f5IgoWyK6/kF0JYkENimlMK BRPiZls8MmHgnIqLM+ZZTWkqXwzqnAP69xyQEDqtoZjCXFdeWuhMnalFxR+MmLL30Shp /k6RUgNORiS9FijRUE4BXm1+9c8d84Y6IKW+LQ3SPJjTa/4GA4d6BqwfY3fYmUvlc8Im AKCLfRAoF7p8VeDXOYyhzXA4aPkEkzim5JzFcfahxlpMKMN/sSDbH8qXuxqh2vw9ZEDE tghA== X-Gm-Message-State: APjAAAXHvQ0jqdxygoDRJI1ImtZ5HHj5Mi4Gg5ZEjlXRpli8122KljEe hUrEsv3EQHq7wEeOWXOXxno= X-Received: by 2002:a2e:4555:: with SMTP id s82mr13823604lja.15.1557756387312; Mon, 13 May 2019 07:06:27 -0700 (PDT) Received: from [10.17.182.120] (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id h29sm3137491ljb.49.2019.05.13.07.06.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 07:06:26 -0700 (PDT) Subject: Re: [RFC PATCH] ARM: mach-shmobile: Parse DT to get ARCH timer memory region To: Julien Grall , linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: horms@verge.net.au, magnus.damm@gmail.com, linux@armlinux.org.uk, Oleksandr Tyshchenko References: <1557505377-28577-1-git-send-email-olekstysh@gmail.com> From: Oleksandr Message-ID: Date: Mon, 13 May 2019 17:06:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13.05.19 12:19, Julien Grall wrote: > Hi, Hi, Julien, Geert > > On 5/10/19 5:22 PM, Oleksandr Tyshchenko wrote: >> From: Oleksandr Tyshchenko >> >> Don't use hardcoded address, retrieve it from device-tree instead. >> >> And besides, this patch fixes the memory error when running >> on top of Xen hypervisor: >> >> (XEN) traps.c:1999:d0v0 HSR=0x93830007 pc=0xc0b097f8 gva=0xf0805000 >>        gpa=0x000000e6080000 >> >> Which shows that VCPU0 in Dom0 is trying to access an address in memory >> it is not allowed to access (0x000000e6080000). >> Put simply, Xen doesn't know that it is a device's register memory >> since it wasn't described in a host device tree (which Xen parses) >> and as the result this memory region wasn't assigned to Dom0 at >> domain creation time. >> >> Signed-off-by: Oleksandr Tyshchenko >> >> --- >> >> This patch is meant to get feedback from the community before >> proceeding further. If we decide to go this direction, all Gen2 >> device-trees should be updated (add memory region) before >> this patch going in. >> >> e.g. r8a7790.dtsi: >> >> ... >> timer { >>     compatible = "arm,armv7-timer"; >>     interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | >> IRQ_TYPE_LEVEL_LOW)>, >>                   <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | >> IRQ_TYPE_LEVEL_LOW)>, >>                   <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | >> IRQ_TYPE_LEVEL_LOW)>, >>                   <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | >> IRQ_TYPE_LEVEL_LOW)>; >> +     reg = <0 0xe6080000 0 0x1000>; > > This looks incorrect, the "arm,armv7-timer" bindings doesn't offer you > the possibility to specify an MMIO region. This makes sense because it > is meant to describe the Arch timer that is only access via > co-processor registers. > > Looking at the code, I think the MMIO region corresponds to the > coresight (based on the register name). So you may want to describe > the coresight in the Device-Tree. > > Also, AFAICT, the code is configuring and turning on the timer if it > has not been done yet. If you are here running on Xen, then you have > probably done something wrong. Indeed, it means Xen would not be able > to use the timer until Dom0 has booted. But, shouldn't newer U-boot do > it for you? Let me elaborate a bit more on this... Indeed, my PSCI patch series for U-Boot includes a patch [1] for configuring that "counter module". So, if PSCI is available (psci_smp_available() == true), then most likely we are running on PSCI-enabled U-Boot which, we assume, has already taken care of configuring timer (as well as resetting CNTVOFF). So, when running on Xen, the timer was configured beforehand in U-Boot, and Xen is able to use it from the very beginning, these is no need to wait for Dom0 to configure it. (XEN) Generic Timer IRQ: phys=30 hyp=26 virt=27 Freq: 10000 KHz So, the code in brackets won't be called when using PSCI/running Xen, since the timer is already both enabled and configured: if ((ioread32(base + CNTCR) & 1) == 0 ||         ioread32(base + CNTFID0) != freq) {         /* Update registers with correct frequency */         iowrite32(freq, base + CNTFID0);         asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));         /* make sure arch timer is started by setting bit 0 of CNTCR */         iowrite32(1, base + CNTCR); } But, the problem here is the first read access from timer register (when we check whether the timer requires enabling) results in hypervisor trap: (XEN) traps.c:1999:d0v0 HSR=0x93830007 pc=0xc0b097f8 gva=0xf0805000 gpa=0x000000e6080000 So, if the DT bindings for the counter module is not an option (if I correctly understood a discussion pointed by Geert in another letter), we should probably prevent all timer code here from being executed if PSCI is in use. What I mean is to return to [2], but with the modification to use psci_smp_available() helper as an indicator of PSCI usage. Julien, Geert, what do you think? [1] https://marc.info/?l=u-boot&m=154895714510154&w=2 [2] https://lkml.org/lkml/2019/4/17/810 > > Cheers, > -- Regards, Oleksandr Tyshchenko