From patchwork Tue May 23 13:27:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Walbon X-Patchwork-Id: 765976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3wXGbS4CY5z9sPJ; Tue, 23 May 2017 23:29:40 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dD9sX-0002KP-Rq; Tue, 23 May 2017 13:29:37 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dD9sH-0002EY-Jd for kernel-team@lists.ubuntu.com; Tue, 23 May 2017 13:29:21 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4NDTDWY045099 for ; Tue, 23 May 2017 09:29:20 -0400 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 2amn1nua8a-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 23 May 2017 09:29:18 -0400 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 23 May 2017 10:29:08 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 23 May 2017 10:29:06 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4NDT50466650246 for ; Tue, 23 May 2017 10:29:06 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4NDT5oj009756 for ; Tue, 23 May 2017 10:29:05 -0300 Received: from localhost (gwalbon.br.ibm.com [9.18.235.110] (may be forged)) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4NDT5SC009751; Tue, 23 May 2017 10:29:05 -0300 From: Gustavo Walbon To: kernel-team@lists.ubuntu.com Subject: [Zesty][PATCH v2 11/13] powerpc: Add optional smp_ops->prepare_cpu SMP callback Date: Tue, 23 May 2017 10:27:46 -0300 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170523132748.19944-1-gwalbon@linux.vnet.ibm.com> References: <20170523132748.19944-1-gwalbon@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17052313-0024-0000-0000-0000017739EC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052313-0025-0000-0000-0000163E8DA8 Message-Id: <20170523132748.19944-12-gwalbon@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-23_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705230070 Cc: mauricfo@linux.vnet.ibm.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Benjamin Herrenschmidt Buglink : http://bugs.launchpad.net/bugs/1691973 Some platforms (will) need to perform allocations before bringing a new CPU online. Doing it from smp_ops->setup_cpu is the wrong thing to do: - It has no useful failure path (too late) - Calling any allocator will enable interrupts prematurely causing problems with large decrementer among others Instead, add a new callback that is called from __cpu_up (so from the context trying to online the new CPU) at a point where we can safely allocate and handle failures. This will be used by XIVE support. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Michael Ellerman (cherry picked from commit 14d4ae5c4cb89c05262fe41cb7a26f6ba949d8df in linux-next) Signed-off-by: Gustavo Walbon --- arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/kernel/smp.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index edd939e76d52..56ba9daefaa6 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -45,6 +45,7 @@ struct smp_ops_t { #endif void (*probe)(void); int (*kick_cpu)(int nr); + int (*prepare_cpu)(int nr); void (*setup_cpu)(int nr); void (*bringup_done)(void); void (*take_timebase)(void); diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 95eefa00abb3..84f7ac4b9a33 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -519,6 +519,16 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle) cpu_idle_thread_init(cpu, tidle); + /* + * The platform might need to allocate resources prior to bringing + * up the CPU + */ + if (smp_ops->prepare_cpu) { + rc = smp_ops->prepare_cpu(cpu); + if (rc) + return rc; + } + /* Make sure callin-map entry is 0 (can be leftover a CPU * hotplug */