Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3748799ybl; Mon, 13 Jan 2020 01:52:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyo8GJyGH2rldYzciHm8Hdepc2K3yDQ2fewXNvCJw9zWTvK0wLC4I/oWuNQ0+gpEM48s6TX X-Received: by 2002:aca:c74e:: with SMTP id x75mr12372600oif.140.1578909124582; Mon, 13 Jan 2020 01:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578909124; cv=none; d=google.com; s=arc-20160816; b=VUS0loUs0EWsmZPLc6CdVcomZvyPANEFMEuEil/Qlk28pjvyM+M+B47ls/JXMLH2x0 tN5fVCOEAOwOs9R6UrneehFHh7HfZgI1GT0MFD/g3tEXJifDCvfU1EOUnPXrRqW3V/56 RsAA8Beiqi9Zk9+ZggWXVD7grgAvG5z+n9c7H2UzmqICBvCZtivgy9Pk8Y+vxN5Vn600 i54Z0eWhxAo607X7ub6NyBrTv8NXJEZ1zvD0lUPFNLR/q6L+9VRKrcKAm8aTT7TTQOND QD3ymblDiTLRadoNJiS4fQx0D8WUwYXRKci0QqNW1O98lw1mL6FR/85o/J4iUSWU7Gx7 0wkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject; bh=8fc2AocJTisTD4FzuDnf4qa4bQKHDjumgF8BJVpYANM=; b=IEAMmC34F7m0Iw2gufDGJA4l43q2OGx60SdSGc7gJsm3XoNJdOW/76iePbAOLgCxFD vdvCiwqbfB4lCMZfL7MViSFEkeXqpkI9sdE9Kly+FlmgRGIxgUPfYT/3vfx25QHcaRPl EgJC5OZCMMpVxJ8VpP3AFApZ+B9rqNAu10rxVvLvz/Y0izO/gJvo0LWXdGw9v+GGVwo6 ecOQF7eKiT6FGCk4H6iH3rRGjEwIe4VYLoeA9yuJVYwGUhuYETZGxeTgtf2C25TA7VIn r72nBvanCIHKRYWC7TWA2JkhMEbB75ECJU2zsqvBaOTB4adK2KwvT9RgRJ8fC8PuTKDo gniA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si6232517otq.31.2020.01.13.01.51.52; Mon, 13 Jan 2020 01:52:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728760AbgAMJtN (ORCPT + 99 others); Mon, 13 Jan 2020 04:49:13 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55920 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgAMJtM (ORCPT ); Mon, 13 Jan 2020 04:49:12 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00D9cP4Z181078 for ; Mon, 13 Jan 2020 04:49:10 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xfa253u49-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Jan 2020 04:49:10 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 13 Jan 2020 09:49:09 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 13 Jan 2020 09:49:06 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00D9n5Yf48169160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2020 09:49:05 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F21C84204B; Mon, 13 Jan 2020 09:49:04 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B16F42041; Mon, 13 Jan 2020 09:49:03 +0000 (GMT) Received: from [9.124.31.88] (unknown [9.124.31.88]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 13 Jan 2020 09:49:03 +0000 (GMT) Subject: Re: [RESEND PATCH v2 1/3] powerpc/powernv: Interface to define support and preference for a SPR To: Ram Pai Cc: linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, mpe@ellerman.id.au, svaidy@linux.ibm.com, ego@linux.vnet.ibm.com, pratik.sampat@in.ibm.com, pratik.r.sampat@gmail.com References: <926baad3fd0bf0b01b0adf83c71f2f4f6e9cf1e7.1578886602.git.psampat@linux.ibm.com> <20200113074440.GC5419@oc0525413822.ibm.com> From: Pratik Sampat Date: Mon, 13 Jan 2020 15:19:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200113074440.GC5419@oc0525413822.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 20011309-4275-0000-0000-00000397124B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011309-4276-0000-0000-000038AB07AA Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-13_02:2020-01-13,2020-01-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001130082 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the review. The support just signifies what is default. Self restore is known to be supported by legacy systems. I'll mention a comment saying that this can change when the system is initialized. On 13/01/20 1:14 pm, Ram Pai wrote: > On Mon, Jan 13, 2020 at 09:15:07AM +0530, Pratik Rajesh Sampat wrote: >> Define a bitmask interface to determine support for the Self Restore, >> Self Save or both. >> >> Also define an interface to determine the preference of that SPR to >> be strictly saved or restored or encapsulated with an order of preference. >> >> The preference bitmask is shown as below: >> ---------------------------- >> |... | 2nd pref | 1st pref | >> ---------------------------- >> MSB LSB >> >> The preference from higher to lower is from LSB to MSB with a shift of 8 >> bits. >> Example: >> Prefer self save first, if not available then prefer self >> restore >> The preference mask for this scenario will be seen as below. >> ((SELF_RESTORE_STRICT << PREFERENCE_SHIFT) | SELF_SAVE_STRICT) >> --------------------------------- >> |... | Self restore | Self save | >> --------------------------------- >> MSB LSB >> >> Finally, declare a list of preferred SPRs which encapsulate the bitmaks >> for preferred and supported with defaults of both being set to support >> legacy firmware. >> >> This commit also implements using the above interface and retains the >> legacy functionality of self restore. >> >> Signed-off-by: Pratik Rajesh Sampat >> --- >> arch/powerpc/platforms/powernv/idle.c | 327 +++++++++++++++++++++----- >> 1 file changed, 271 insertions(+), 56 deletions(-) >> >> diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c >> index 78599bca66c2..2f328403b0dc 100644 >> --- a/arch/powerpc/platforms/powernv/idle.c >> +++ b/arch/powerpc/platforms/powernv/idle.c >> @@ -32,9 +32,106 @@ >> #define P9_STOP_SPR_MSR 2000 >> #define P9_STOP_SPR_PSSCR 855 >> >> +/* Interface for the stop state supported and preference */ >> +#define SELF_RESTORE_TYPE 0 >> +#define SELF_SAVE_TYPE 1 >> + >> +#define NR_PREFERENCES 2 >> +#define PREFERENCE_SHIFT 4 >> +#define PREFERENCE_MASK 0xf >> + >> +#define UNSUPPORTED 0x0 >> +#define SELF_RESTORE_STRICT 0x1 >> +#define SELF_SAVE_STRICT 0x2 >> + >> +/* >> + * Bitmask defining the kind of preferences available. >> + * Note : The higher to lower preference is from LSB to MSB, with a shift of >> + * 4 bits. >> + * ---------------------------- >> + * | | 2nd pref | 1st pref | >> + * ---------------------------- >> + * MSB LSB >> + */ >> +/* Prefer Restore if available, otherwise unsupported */ >> +#define PREFER_SELF_RESTORE_ONLY SELF_RESTORE_STRICT >> +/* Prefer Save if available, otherwise unsupported */ >> +#define PREFER_SELF_SAVE_ONLY SELF_SAVE_STRICT >> +/* Prefer Restore when available, otherwise prefer Save */ >> +#define PREFER_RESTORE_SAVE ((SELF_SAVE_STRICT << \ >> + PREFERENCE_SHIFT)\ >> + | SELF_RESTORE_STRICT) >> +/* Prefer Save when available, otherwise prefer Restore*/ >> +#define PREFER_SAVE_RESTORE ((SELF_RESTORE_STRICT <<\ >> + PREFERENCE_SHIFT)\ >> + | SELF_SAVE_STRICT) >> static u32 supported_cpuidle_states; >> struct pnv_idle_states_t *pnv_idle_states; >> int nr_pnv_idle_states; >> +/* Caching the lpcr & ptcr support to use later */ >> +static bool is_lpcr_self_save; >> +static bool is_ptcr_self_save; >> + >> +struct preferred_sprs { >> + u64 spr; >> + u32 preferred_mode; >> + u32 supported_mode; >> +}; >> + >> +struct preferred_sprs preferred_sprs[] = { >> + { >> + .spr = SPRN_HSPRG0, >> + .preferred_mode = PREFER_RESTORE_SAVE, >> + .supported_mode = SELF_RESTORE_STRICT, >> + }, >> + { >> + .spr = SPRN_LPCR, >> + .preferred_mode = PREFER_RESTORE_SAVE, >> + .supported_mode = SELF_RESTORE_STRICT, >> + }, >> + { >> + .spr = SPRN_PTCR, >> + .preferred_mode = PREFER_SAVE_RESTORE, >> + .supported_mode = SELF_RESTORE_STRICT, >> + }, > This confuses me. It says SAVE takes precedence over RESTORE. > and than it says it is strictly 'RESTORE' only. > > Maybe you should not initialize the 'supported_mode' ? > or put a comment somewhere here, saying this value will be overwritten > during system initialization? > > > Otherwise the code looks correct. > > Reviewed-by: Ram Pai > RP