Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6985116rwb; Tue, 22 Nov 2022 23:58:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vepYausVZcVp/moVLggvUTuVvdPNmmS99zDnxXo/boOrsTsXOYCVJta4KgQmJg9GESy3L X-Received: by 2002:a62:6083:0:b0:56d:3180:c7fc with SMTP id u125-20020a626083000000b0056d3180c7fcmr10600273pfb.41.1669190296258; Tue, 22 Nov 2022 23:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669190296; cv=none; d=google.com; s=arc-20160816; b=rWFdT3nWsV/5qSVUGUdfOheLi+97gwWfKmgLOYToDrmJyg49YaOk9fcTA7JP1jZMKN 6dR7nIs+PZJDPvH8R+pQhTFPxuoH3SIHj54K+6N/OVM3dciSXMOh0hwIjKyYvIOT1HUv cPvxWq6aTsCHn5ySOAol/V1egNY7g7fsL4ulOwRbruYaWzi+yhWNHAw4zSyiE8mytzNo wX0dEhRhzhh12msjHWNyLhadcvCkQErHV0gEUvyeLwQzVgourZIX/iV3DHZXAxNydQ6q 7ZOt0zX7mIpGhxJKvZ+gue6dTCBprIoGbescjgP2Id8pzSsTvqdncoH2gZjQ2P520Fmo Uy0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=pfeTiyTSvdx8Cc3qRibAIg5+skkpZxzHNm/gNig9/9c=; b=tZTpvCKWNEVwRI9UPBOMpWus0r9i040XutHTWTzWp99R6EGUJBzzf0CWOZ62tAYuYA Ck/BCxISEHcZu2XSVsiJN1fA2DFAlaTcbyCuKoWwn7up5k+xdxKMyQRVvex405cp/Euc cFK1eVo9FUfTVhAEhKmCvHcb7npsxgSJLOdVj6iAKToaoymyP1xLvqHjSt4S38H9+OQ3 gGZxj4j/dPCLnny9ReQwem8vSjL9pvtQzLQproTImZsz5TWxdhKuMt/VhHLLXbYJZDAI 4XQslSgxjSn5ax63Q7ocELcXWsfH7lqSrWPjUmAl2O5vcYCQMTnPkWCNykQEUNfL9NMv xNDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=eFN0A6oR; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=nyzsSRaY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a056a000c8b00b0056301324a24si17067146pfv.133.2022.11.22.23.58.04; Tue, 22 Nov 2022 23:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=eFN0A6oR; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=nyzsSRaY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235928AbiKWGuE (ORCPT + 89 others); Wed, 23 Nov 2022 01:50:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiKWGuA (ORCPT ); Wed, 23 Nov 2022 01:50:00 -0500 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D87F1DB8; Tue, 22 Nov 2022 22:49:59 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 8160632009DF; Wed, 23 Nov 2022 01:49:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 23 Nov 2022 01:49:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1669186198; x= 1669272598; bh=pfeTiyTSvdx8Cc3qRibAIg5+skkpZxzHNm/gNig9/9c=; b=e FN0A6oRN9O/xv7J156ZmkLwxbTXz2Dmd2TyNUmarzl/qmxeOEaEunuTVxPzaCCcA LHAYZDbups+ot7VqMfdmvWF2OjgjOAd1BborzfBSfNn6eIys19RPbF4/QQ29Cqi+ NRe9PTG5Vte7xMgXg7i3qV5hitgOdDC7ceI43zsisy/Ne86fqMy7rFFZssGTvqJj 0bbaVXmAyaM++HQKbErZ39HUsde1Ci9KunX2mVhjkRGWPUKBQ9/MXsKPH8G5EHSL xvkFRhXxvMgwvFdk92QyeORfbl/wsUNC1B24f53BTLdXWQjmBtCoqPHHk6iIO8w9 RFY1Y6+S50OoqdoT/RzwA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1669186198; x= 1669272598; bh=pfeTiyTSvdx8Cc3qRibAIg5+skkpZxzHNm/gNig9/9c=; b=n yzsSRaYFQXeyjx7VjGM+ohaijzyErdeZf1wvgUvTZxrpVarAV5QTywF3ybcLk1Kv o1ixcmjBTvulgZEZ1OgHrjJo8OqWuX0BQuOmpk0SLN+CYVNRT7FmHRQNcCwIVsbY ndWyjGhv0+VOfuy/fIDa4kz81jy0yV7uhSzBy6UJwoOa18TyxdyKAy+t+qneDX5M CHyY6WsrWyZG16xM5VmLJrViifff7RXNrG2T1o9cfr4IoikTr+pKCeIRHDPx/Lod DPXzDb5mMWOCFj+Cpsnyl2A7xZQG9R8IK9UQpjbhfs3O7F1iYUTUNn1NLNdk6plZ AeVK/4lbBjs7G7ckA3l8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedtgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfvfevfhfhufgjtgfgsehtjeertddtfeejnecuhfhrohhmpefurghm uhgvlhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenuc ggtffrrghtthgvrhhnpeejgfffhfdujeeftdeuudeguedttefgieetffffheejuefguedv heejteeftdfftdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Nov 2022 01:49:56 -0500 (EST) Message-ID: Date: Wed, 23 Nov 2022 00:49:56 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux ppc64le; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , conor.dooley@microchip.com, Conor Dooley , rafael@kernel.org, daniel.lezcano@linaro.org, Paul Walmsley , aou@eecs.berkeley.edu, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com References: <57114829-c205-dece-abdb-1100947286d4@sholland.org> <4e9a46e2-eaa2-04cb-8b95-2fe9a091a96d@sholland.org> From: Samuel Holland Subject: Re: [PATCH] cpuidle: riscv-sbi: Stop using non-retentive suspend In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/23/22 00:41, Anup Patel wrote: > On Wed, Nov 23, 2022 at 11:57 AM Samuel Holland wrote: >> >> On 11/23/22 00:10, Anup Patel wrote: >>> On Wed, Nov 23, 2022 at 11:08 AM Samuel Holland wrote: >>>> >>>> Hi Anup, >>>> >>>> On 11/22/22 23:35, Anup Patel wrote: >>>>> On Wed, Nov 23, 2022 at 10:41 AM Samuel Holland wrote: >>>>>> On 11/22/22 09:28, Palmer Dabbelt wrote: >>>>>>> I also think we should stop entering non-retentive suspend until we can >>>>>>> sort out how reliably wake up from it, as the SBI makes that a >>>>>>> platform-specific detail. If the answer there is "non-retentive suspend >>>>>>> is fine on the D1 as long as we don't use the SBI timers" then that >>>>>>> seems fine, we just need some way to describe that in Linux -- that >>>>>>> doesn't fix other platforms and other interrupts, but at least it's a >>>>>>> start. >>>>>> >>>>>> We need some way to describe the situation from the SBI implementation >>>>>> to Linux. >>>>>> >>>>>> Non-retentive suspend is fine on the D1 as long as either one of these >>>>>> conditions is met: >>>>>> 1) we don't use the SBI timers, or >>>>>> 2) the SBI timer implementation does not use the CLINT >>>>>> >>>>>> And it is up to the SBI implementation which timer hardware it uses, so >>>>>> the SBI implementation needs to patch this information in to the DT at >>>>>> runtime. >>>>> >>>>> Rather than SBI implementation patching information in DT, it is much >>>>> simpler to add a quirk in RISC-V timer driver for D1 platform (i.e. based >>>>> on D1 compatible string in root node). >>>> >>>> It would be simpler, but it would be wrong, as I just explained. >>>> >>>> Only the SBI implementation knows if the SBI timer extension can wake >>>> any given CPU from any given non-retentive suspend state. >>> >>> The SBI implementation would derive this information from platform >>> compatible string which is already available to the Linux kernel so >>> why does SBI implementation have to patch the DTB and put the >>> same information in a different way ? >> >> It is not the same information. The SBI implementation also chooses, at >> runtime, which timer hardware (CLINT, platform-specific MMIO timer, >> etc.) is used to implement the SBI timer extension. The value of the >> sbi-timer-can-wake-cpu property depends on this choice. >> >> Using D1 as an example, there are two MMIO timer peripherals ("sun4i" >> TIMER and "sun5i" HSTIMER) where the sbi-timer-can-wake-cpu property >> should be set. But the property should not be set if the CLINT is used >> by SBI. >> >> It would be perfectly reasonable for the SBI implementation to claim one >> of the wakeup-capable MMIO timers for itself, mark it as "reserved" in >> the DT passed to Linux, and thus force Linux to use the SBI timer or a >> native CLINT driver (C906 CLINT has S-mode extensions). Then the SBI >> timer _would_ be capable of waking the CPU from non-retentive suspend. > > Fair enough but the DT property should not be SBI specific because same > situation can happen with Sstc as well where a particular non-retentive state > does not preserve the state of stimecmp CSRs in the HARTs. > > Better to keep the DT property name as "riscv,timer-can-wake-cpu". Consider a platform where the Sstc-based timer cannot wake the CPU, but the SBI timer can, because it uses different timer hardware or a different interrupt delivery method. It seems like we need two different properties, one for Sstc and the other for the SBI timer. If both are supported, firmware cannot know which one S-mode software will use. Regards, Samuel