Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1276486lqp; Fri, 22 Mar 2024 10:05:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuUvxSlMpYG4EDfPWcJ2ohwAgPY0/4SNKoexHxFE5qoAvYdpd5Q+xoJvTvhNQ9BfU5lyLjIJuLen013beJMpqKAuxPX1q/yxV8LtDruQ== X-Google-Smtp-Source: AGHT+IG/fDt0XPxhwUV4WcHpCaLhepOQaVx/zMymJ1AHsKZKhTnuFa2vLn+jZ0vyTlkzuM8L/b1e X-Received: by 2002:a19:7708:0:b0:515:9568:fb14 with SMTP id s8-20020a197708000000b005159568fb14mr20942lfc.46.1711127147603; Fri, 22 Mar 2024 10:05:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711127147; cv=pass; d=google.com; s=arc-20160816; b=bwvH7wnq0zUsX5AFkH8Q7Wj/wBwOy/DK+sScLx+ZzqsWtZANvpgCtS4TX0zrT7JG7s /fMWA5MQlSQPOMe6f9KIPG4myreXRMsMW5TTvpxj3EM0tEy4InpeIPWwKE2is0A53FE9 hlVPzlcAbhJvOvL52MQDacS86SO3KyWzgmrwVtuL/6GpYjko4jsW9zDwN+D5j6s+igSe SbYnSu0g0jb713p79dGzxEqme89DPuIlHOYkVsm47a8fTIdK3XAusQYd3GpGZlSNI7k4 MYqQrpubV9vAb0VzdxTCEVB74gMJwJY9fsoqfYXtZowGCzy0KJaHPdVaEeowhdVUNrRZ TQtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=q28Vd0AwQ8GuBvulDEw/RIvFIP5bUcwYhbfy5+IvxWo=; fh=GfKCdEg359et2Zd8A+sgF8PXxDhEMKLYQaMTGhUOLFI=; b=SAM5IO31ciSzAPuZaMWAmIOwH+lzbqQ1GUhesJ/EaRIpAErZzw8TK1wBwT1ztcLzRf NffXhYl+akHPD/dbW0IytlB8awIFCfQL4V80I1/EDkhHlC49FbwvStdUkc0e1xP6ZEil N5uyqWo3F+3nPGtcIO4JYD9uUDJKP+z5oa0jxRlzj+P37H+ByxsJ3bJ0veWPd2Isfn2h K/2WueQSvQEnKXAPAp39HRz7LMe14hqjvbU16IwKPdt+vygOVUGGr3kJ7PVkIe5FQYUi /tzsG4914HMNmNuSmJB9/yOlr6PzGVNqW6LjruulCzXPCuR3X2C5Dj4r72PTrpOJmfJy LIoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-111841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h18-20020a170906719200b00a4731d28bc7si13996ejk.732.2024.03.22.10.05.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 10:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-111841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 50F591F23DA5 for ; Fri, 22 Mar 2024 17:05:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EDE65FDCC; Fri, 22 Mar 2024 17:05:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B83975FDC4; Fri, 22 Mar 2024 17:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127124; cv=none; b=OJRwkBZ3mmg+dmVXTdXzoCE3KeSEvYAEKs5INFuR3X1FkzsywOtof6pK4KN+bDlzfllAQMq8zFj1Eb0yPR1++q7XyCNIgmP9A690kOkrfoSXCc8NqciBk64EUDAp9laTpxWthO7vtQEN6HAX5ZQmNTdHq/JcD4csgr7F9cR1IYE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127124; c=relaxed/simple; bh=cKFHXx0uwG7dElAjjFikSr5g3gCGM6PF0iXhuZRVtLw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WVtA+PavwOPAqehs6rT6xwi/RCMZjFjY54tIG5yYO9LTrceuXxocmDy1QfWacMqz56DqPIkB99PszwXgICI9oDcODRTnD/+z9MTR1pLnyidVBh88u+RiMf1GJx7WiNtz6/xTppE1yrK7gzbtT8IOXlbkUNeVVNSY0QVUDPvk9Bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 44C32FEC; Fri, 22 Mar 2024 10:05:53 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 34BE73F67D; Fri, 22 Mar 2024 10:05:16 -0700 (PDT) Date: Fri, 22 Mar 2024 17:05:13 +0000 From: Sudeep Holla To: Marc Zyngier Cc: David Woodhouse , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Sudeep Holla , Paolo Bonzini , Jonathan Corbet , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Lorenzo Pieralisi , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Mostafa Saleh , Jean-Philippe Brucker , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-pm@vger.kernel.org Subject: Re: [RFC PATCH v3 5/5] arm64: Use SYSTEM_OFF2 PSCI call to power off for hibernate Message-ID: References: <20240319130957.1050637-1-dwmw2@infradead.org> <20240319130957.1050637-6-dwmw2@infradead.org> <86jzluz24b.wl-maz@kernel.org> <9efb39597fa7b36b6c4202ab73fae6610194e45e.camel@infradead.org> <86edc2z0hs.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86edc2z0hs.wl-maz@kernel.org> On Fri, Mar 22, 2024 at 04:37:19PM +0000, Marc Zyngier wrote: > On Fri, 22 Mar 2024 16:12:44 +0000, > David Woodhouse wrote: > > > > On Fri, 2024-03-22 at 16:02 +0000, Marc Zyngier wrote: > > > On Tue, 19 Mar 2024 12:59:06 +0000, > > > David Woodhouse wrote: > > > > > > [...] > > > > > > > +static void __init psci_init_system_off2(void) > > > > +{ > > > > +???????int ret; > > > > + > > > > +???????ret = psci_features(PSCI_FN_NATIVE(1_3, SYSTEM_OFF2)); > > > > + > > > > +???????if (ret != PSCI_RET_NOT_SUPPORTED) > > > > +???????????????psci_system_off2_supported = true; > > > > > > It'd be worth considering the (slightly broken) case where SYSTEM_OFF2 > > > is supported, but HIBERNATE_OFF is not set in the response, as the > > > spec doesn't say that this bit is mandatory (it seems legal to > > > implement SYSTEM_OFF2 without any hibernate type, making it similar to > > > SYSTEM_OFF). > > > > Such is not my understanding. If SYSTEM_OFF2 is supported, then > > HIBERNATE_OFF *is* mandatory. > > > > The next update to the spec is turning the PSCI_FEATURES response into > > a *bitmap* of the available features, and I believe it will mandate > > that bit zero is set. Correct, but we add a extra check as well to be sure even if it is mandated unless the spec relaxes in a way that psci_features(SYSTEM_OFF2) need not return the mandatory types in the bitmask which I doubt. Something like: if (ret != PSCI_RET_NOT_SUPPORTED && (ret & BIT(PSCI_1_3_HIBERNATE_TYPE_OFF))) psci_system_off2_supported = true; This will ensure the firmware will not randomly set bit[0]=0 if in the future it support some newer types as well. I understand the kernel is not conformance test for the spec but in practice especially for such features and PSCI spec in particular, kernel has become defacto conformance for firmware developers which is sad. It some feature works in the kernel, the firmware is assumed to be conformant to the spec w.r.t the feature. -- Regards, Sudeep