Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2021430ybv; Sun, 23 Feb 2020 20:55:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxgXGlB1AOugWbEBDfr7NhU6VChXUoFivxQFwt5003jifovcYxkTmLT4b5qxbk82eQHaOg5 X-Received: by 2002:a05:6808:7dd:: with SMTP id f29mr11560624oij.67.1582520141542; Sun, 23 Feb 2020 20:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582520141; cv=none; d=google.com; s=arc-20160816; b=kPDLzucw4JB+S2mAXREhEJv+v+OEXNj6xO7u3kvPfgXh4jdIi5Uf7Ibiv0bjK79+au mbJmT+AKrzli3KWWT5BikOHOv+fk0MKXWwyBXoW2vbKNXqQQRYYbcIWZLeymJk3FxzzW E64dS259Clms6Sa28nsTGW4zAfjC3E55B66oawOZJ+p0XyKQ+rNBERTm3eEE6al8M9E8 nfU1aprJPSyuTMZ8FoEtBRd6ktIHkGfirjZfrmFKI7t446/Vvcy7d1uZOHJu7v56al/b LMNGauLwP8VGdVq/X0GEea78nuJvtxaYBcpfkFcg8aSefAC6tCX1BFeAJG9lPEE2f4V6 IQng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=AH08mGG0Cak3sy0APXinKzOSMba0zoiRjdI6gdUOR38=; b=0xjln6khprp4gbUS0+ocGTbSGVsq/Wa4wlgCHgmvDLo8PH330M4SM1bm+HSmwK2sGO Hm6l6cb2j5msAwQsqglm0ZrqXKwz3MD2C7u7Fge/UNBgGne5Xaniiv/JEA1ckewhjq8H qqoKEu2RnYcjptkJHwLJBIUL5e7qEDbS3Q4EF+Zba+AEJojARi7qtW38otWBp68QC5v2 52iUJJsWkiMnOUaABLqochxW613ueW5kxrk10ekQW1TeqvgWNhjTRe0aZVasyxfX9rh1 kymGo6q0LzVYXhLDnULA/8yweQSVoTJsHeAdRUWlFyD69+GvXQt6KnsxPuj9YIlnTB0z BIQw== 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 c5si7134464ots.233.2020.02.23.20.55.28; Sun, 23 Feb 2020 20:55:41 -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 S1727277AbgBXEzT (ORCPT + 99 others); Sun, 23 Feb 2020 23:55:19 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30530 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727186AbgBXEzT (ORCPT ); Sun, 23 Feb 2020 23:55:19 -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 01O4oL2W050797; Sun, 23 Feb 2020 23:55:10 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yb008tudv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 23 Feb 2020 23:55:10 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01O4pL9W005423; Mon, 24 Feb 2020 04:55:09 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma02dal.us.ibm.com with ESMTP id 2yaux6cqjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Feb 2020 04:55:09 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01O4t9rY45023654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Feb 2020 04:55:09 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1847FB2064; Mon, 24 Feb 2020 04:55:09 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDCB5B205F; Mon, 24 Feb 2020 04:55:08 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.124.35.26]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 24 Feb 2020 04:55:08 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 39DCC2E3231; Mon, 24 Feb 2020 10:25:06 +0530 (IST) Date: Mon, 24 Feb 2020 10:25:06 +0530 From: Gautham R Shenoy To: Nathan Lynch Cc: "Gautham R. Shenoy" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman , Vaidyanathan Srinivasan , Kamalesh Babulal , "Naveen N. Rao" , Tyrel Datwyler Subject: Re: [PATCH v2 1/5] powerpc: Move idle_loop_prolog()/epilog() functions to header file Message-ID: <20200224045506.GA12846@in.ibm.com> Reply-To: ego@linux.vnet.ibm.com References: <1582262314-8319-1-git-send-email-ego@linux.vnet.ibm.com> <1582262314-8319-2-git-send-email-ego@linux.vnet.ibm.com> <87lfowt22z.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lfowt22z.fsf@linux.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-23_07:2020-02-21,2020-02-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 suspectscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002240040 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Nathan, On Fri, Feb 21, 2020 at 09:03:16AM -0600, Nathan Lynch wrote: > "Gautham R. Shenoy" writes: > > > From: "Gautham R. Shenoy" > > > > Currently prior to entering an idle state on a Linux Guest, the > > pseries cpuidle driver implement an idle_loop_prolog() and > > idle_loop_epilog() functions which ensure that idle_purr is correctly > > computed, and the hypervisor is informed that the CPU cycles have been > > donated. > > > > These prolog and epilog functions are also required in the default > > idle call, i.e pseries_lpar_idle(). Hence move these accessor > > functions to a common header file and call them from > > pseries_lpar_idle(). Since the existing header files such as > > asm/processor.h have enough clutter, create a new header file > > asm/idle.h. > > > > Signed-off-by: Gautham R. Shenoy > > --- > > arch/powerpc/include/asm/idle.h | 27 +++++++++++++++++++++++++++ > > arch/powerpc/platforms/pseries/setup.c | 7 +++++-- > > drivers/cpuidle/cpuidle-pseries.c | 24 +----------------------- > > 3 files changed, 33 insertions(+), 25 deletions(-) > > create mode 100644 arch/powerpc/include/asm/idle.h > > > > diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h > > new file mode 100644 > > index 0000000..f32a7d8 > > --- /dev/null > > +++ b/arch/powerpc/include/asm/idle.h > > @@ -0,0 +1,27 @@ > > +#ifndef _ASM_POWERPC_IDLE_H > > +#define _ASM_POWERPC_IDLE_H > > +#include > > + > > +static inline void idle_loop_prolog(unsigned long *in_purr) > > +{ > > + ppc64_runlatch_off(); > > + *in_purr = mfspr(SPRN_PURR); > > + /* > > + * Indicate to the HV that we are idle. Now would be > > + * a good time to find other work to dispatch. > > + */ > > + get_lppaca()->idle = 1; > > +} > > + > > +static inline void idle_loop_epilog(unsigned long in_purr) > > +{ > > + u64 wait_cycles; > > + > > + wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); > > + wait_cycles += mfspr(SPRN_PURR) - in_purr; > > + get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); > > + get_lppaca()->idle = 0; > > + > > + ppc64_runlatch_on(); > > +} > > +#endif > > Looks fine and correct as a cleanup, but asm/include/idle.h and > idle_loop_prolog, idle_loop_epilog, strike me as too generic for > pseries-specific code. Should it be prefixed with pseries , i.e pseries_idle_prolog() and pseries_idle_epilog() ? Also, I am planning another round of cleanup to move all the idle-related declaration from asm/include/processor.h to asm/include/idle.h