Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755687AbdGTR5r (ORCPT ); Thu, 20 Jul 2017 13:57:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40288 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755663AbdGTR5n (ORCPT ); Thu, 20 Jul 2017 13:57:43 -0400 From: Victor Aoqui To: rjw@rjwysocki.net, daniel.lezcano@linaro.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: ltc-interlock@lists.linux.ibm.com, victora@br.ibm.com, victora@linux.vnet.ibm.com, mauricfo@linux.vnet.ibm.com Subject: [PATCH] drivers: cpuidle: Disable preemption before get_lppaca function call in pseries_idle_probe function Date: Thu, 20 Jul 2017 14:57:35 -0300 X-Mailer: git-send-email 2.11.0 (Apple Git-81) X-TM-AS-MML: disable x-cbid: 17072017-1523-0000-0000-000002B5C73B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072017-1524-0000-0000-00002A4F09C8 Message-Id: <20170720175735.3957-1-victora@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-20_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707200275 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1273 Lines: 41 When CONFIG_PREEMPT=y, the following warning shows up: BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1 caller is pseries_processor_idle_init+0x58/0x21c This warning shows up because preemption cannot occur when using get_paca(), otherwise the paca_struct it points to may be the wrong one just after. For this reason, preemption needs to be disabled before lppaca_shared_proc(get_lppaca()). Signed-off-by: Victor Aoqui --- drivers/cpuidle/cpuidle-pseries.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index e9b3853..d6dda8c 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -233,12 +233,16 @@ static int pseries_cpuidle_driver_init(void) */ static int pseries_idle_probe(void) { + int retval; if (cpuidle_disable != IDLE_NO_OVERRIDE) return -ENODEV; if (firmware_has_feature(FW_FEATURE_SPLPAR)) { - if (lppaca_shared_proc(get_lppaca())) { + preempt_disable(); + retval = lppaca_shared_proc(get_lppaca()); + preempt_enable(); + if (retval) { cpuidle_state_table = shared_states; max_idle_state = ARRAY_SIZE(shared_states); } else { -- 1.8.3.1