Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3655047ybl; Sun, 12 Jan 2020 23:46:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxGqz7biIRSj/kigXuVIAik6dzdePBQzU0MBl7sthDLVhJKgBuJQrUvgBf09ZG1j9TkN8qX X-Received: by 2002:aca:4782:: with SMTP id u124mr11699314oia.93.1578901564157; Sun, 12 Jan 2020 23:46:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578901564; cv=none; d=google.com; s=arc-20160816; b=NF4b5A0iX0lj8zw8cqPEOakDFleOSMu+xOKDzvEhJRAcoYZLEoNa3RcWNBJti64BVk W9p14Rg3GlV4vu1AltPhNpO/Myv5aRFwbhkPo79cZd8n0yy/YkwsNIYHZnH6N9kCiENy kiQLqMfDd5QBSwBrPn8injAEsWkrMWpp/+WHFH1E4e4tIbrvSuwTaGGo8LI6hv3mTohk umBtoAPI2FIcTdtArNek+gTnzxmP+2arJ7O0swz+ljre0Ovu8tcghJRF6K0qQ2wxaPeO 6i+CxHyGIsXGCCDYCX0RaBWuGKqGJOtr6OSQymxcGpB1V9a+6IHjTnKdpPhZuHN2Lj4N V3mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=jHvO6GVruYv2fSmfpPmHfFSpB+yCQV44iPh3sBNaECY=; b=huaS7nWXzHLtM9j9kwtqFxwk0OzVwkUJF1RqFKU/idWSPdX7+XRxtanfRqoQlt1VKw tMiZcwPwP05+3cuVLvFKPTTm8yPK8rIdXHq2oWPV9JXT6YeGuC48uEsGqu01LfV+uhHU kHApbnYyHlB9ykOK+bla7g7YqbP5y4ex/FifKFoWBLpOIlIYW+uSb3nbId+UQWyNhkrU do6dzbvuBsRst7uXuIHM4t7S4z4L49WbTIOT9PpCrrtiJ4W5F/BVDJzjBEdQg4195/Ms nn8lB0IxUv4DvLc7X3el1sQHHlDAbpI5UdJK2sF4bsOo5v1wGbQIkLdIVtgZUTwzcsFK olZw== 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 e14si6525420oti.33.2020.01.12.23.45.51; Sun, 12 Jan 2020 23:46: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 S1728668AbgAMHox (ORCPT + 99 others); Mon, 13 Jan 2020 02:44:53 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30756 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728558AbgAMHox (ORCPT ); Mon, 13 Jan 2020 02:44:53 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00D7gLot009159 for ; Mon, 13 Jan 2020 02:44:52 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xfvvaa3nw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Jan 2020 02:44:51 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 13 Jan 2020 07:44:50 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) 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 07:44:47 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00D7ijAO30539948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2020 07:44:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E65F0AE057; Mon, 13 Jan 2020 07:44:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF999AE055; Mon, 13 Jan 2020 07:44:43 +0000 (GMT) Received: from oc0525413822.ibm.com (unknown [9.80.202.21]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 13 Jan 2020 07:44:43 +0000 (GMT) Date: Sun, 12 Jan 2020 23:44:40 -0800 From: Ram Pai To: Pratik Rajesh Sampat 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 Subject: Re: [RESEND PATCH v2 1/3] powerpc/powernv: Interface to define support and preference for a SPR Reply-To: Ram Pai References: <926baad3fd0bf0b01b0adf83c71f2f4f6e9cf1e7.1578886602.git.psampat@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <926baad3fd0bf0b01b0adf83c71f2f4f6e9cf1e7.1578886602.git.psampat@linux.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 20011307-0008-0000-0000-00000348D974 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011307-0009-0000-0000-00004A6927A5 Message-Id: <20200113074440.GC5419@oc0525413822.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-13_01:2020-01-13,2020-01-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001130065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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