Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp339474pxb; Thu, 19 Nov 2020 02:33:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrpTH8CAWImBPmorsEH0bxdF1T/jHxLfzt3RFmgkEM5mxv6S75f1Nq/09GzEI0sETzOzRq X-Received: by 2002:a17:907:7205:: with SMTP id dr5mr6075844ejc.335.1605782033574; Thu, 19 Nov 2020 02:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605782033; cv=none; d=google.com; s=arc-20160816; b=aAPl4fjbsFjBw/fAiIvNzYifmU2ZZEqo9ka03bCtELwX9U4BUNO6oVArgcsBorfoUT 7OaZ9EZ+U9UGzDu0Jsgwm4o0v27Jy/hArQFVk3rgXMrZxvNA5vY6DyDcE/Qwo/v6LnWi YcXYBTzZ9JuIJfdVMXT/30Xh6Za1KM6maH2N/e/zBhFx8Mz5WuwsTY4H7O/VnarrriyS +2KQic4ubGVA4cFHEzGRmhp2iiNt6ISmdD0j6ngkMvYdnkBJxlc/bOQuQKZauMF2NiN3 1xWTrwTtEQjVhLSu0pPU5vdUAWWBdPklANbWMPn3tyX4qSzf9NTMa3cPMOBH53MjrRcy f9IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=tpd5RZFpstT09gTei2wvHM1D0nBgK/DhVnpvj+YO9FE=; b=sCkAodma/tOyLXoM3GZnSh4AciRjcxZGhudPF1C0ItFx/xfAHxR2DwVuPyf/I1Alur QBze1/MDcwSbBct5IFkLmwEcpcP0IlZwUc0739s1z4Hb/kHUfvlp6zd7UB5WYSfg9YsB x/pNyfDrE1cmSDAc11VIZpvpj26fg4mmJWlug4veqYP1AI7T0SXSaiz4SmP0W25CRZKm 1Q37MuJgsQ5+WYrd20XQiZ9UuqV4nRrqWUPk/UVLuepe4L5D9O5GzBqS0+UX4niRc8Nb aZtHIbHUEfV4//mKdrb/daU2ggGoWrlj8yQ9hfUyjGJbBrovDhRGst/BKQUaHcO1oX+O C0og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="dW3/UQQt"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="tFFDfRT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si17292457ejz.442.2020.11.19.02.33.30; Thu, 19 Nov 2020 02:33:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="dW3/UQQt"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="tFFDfRT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726485AbgKSKbz (ORCPT + 99 others); Thu, 19 Nov 2020 05:31:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgKSKbz (ORCPT ); Thu, 19 Nov 2020 05:31:55 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2122DC0613CF for ; Thu, 19 Nov 2020 02:31:55 -0800 (PST) Date: Thu, 19 Nov 2020 11:31:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605781913; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tpd5RZFpstT09gTei2wvHM1D0nBgK/DhVnpvj+YO9FE=; b=dW3/UQQtGlFgGY1CgMpAFEz2JARXtXiYS5AowMkxMQiKYH9sf33uho/ai+JXyRUxaKMesO 40bdrX7S6dsK1lmwlNWV6WeGwxuKcdO/6iXn78zTIuy/38NJVdpX2IX9YDlRtowPsOQIMR qk2hg2LSA2mUqo68eHeT8aGCl/b2C8eYScB3xRT+1n8Pi0ZOf+4ZIm3Y1sOw33qH8Iikcm UJXMboHpGRP24aFIpzXXaOP9l0s5oB67Iyz/4/9eDSPv6N64lJbOS5xKDHh0YbDgTqeFaj c4eT4Fgb4o45yIOieyigW/+mw181kEzGuC/xfw7I7CZRy9R43cHdcYvNhIWkZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605781913; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tpd5RZFpstT09gTei2wvHM1D0nBgK/DhVnpvj+YO9FE=; b=tFFDfRT/pFLMP9416qiwyrk5a6wAJIMNa02eMg5LsKnUnmyMale498pyQi9cGD01GjHnYs Y2ABKe5p4uXvmfAg== From: Sebastian Andrzej Siewior To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Cliff Whickman , Arnd Bergmann , Robin Holt , Steve Wahl , Dimitri Sivanich , Russ Anderson Subject: [PATCH v2] misc/sgi-xp: Replace in_interrupt() usage Message-ID: <20201119103151.ppo45mj53ulbxjx4@linutronix.de> References: <20201119081354.836813-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =46rom: Thomas Gleixner The usage of in_interrupt() in xpc_partition_disengaged() is clearly intended to avoid canceling the timeout timer when the function is invoked =66rom the timer callback. While in_interrupt() is deprecated and ill defined as it does not provide what the name suggests it catches the intended case. Add an argument to xpc_partition_disengaged() which is true if called =66rom timer and otherwise false. Use del_timer_sync() instead of del_singleshot_timer_sync() which is the same thing. Note: This does not prevent reentrancy into the function as the function has no concurrency control and timer callback and regular task context callers can happen concurrently on different CPUs or the timer can interrupt the task context before it is able to cancel it. While the only driver which is providing the arch_xpc_ops callbacks (xpc_uv) seems not to have a reentrancy problem and the only negative effect would be a double dev_info() entry in dmesg, the whole mechanism is conceptually broken. But that's not subject of this cleanup endeavour and left as an exercise to the folks who might have interest to make that code fully correct. [bigeasy: Add the argument, use del_timer_sync().] Signed-off-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior Cc: Greg Kroah-Hartman Cc: Cliff Whickman Cc: Arnd Bergmann Cc: Robin Holt Cc: Steve Wahl Cc: Dimitri Sivanich Cc: Russ Anderson --- v1=E2=80=A6v2: Use xpc_partition_disengaged_from_timer() and don't export t= he argument. Suggested by Greg. drivers/misc/sgi-xp/xpc.h | 1 + drivers/misc/sgi-xp/xpc_main.c | 2 +- drivers/misc/sgi-xp/xpc_partition.c | 20 +++++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h index 71db60edff655..225f2bb84e39b 100644 --- a/drivers/misc/sgi-xp/xpc.h +++ b/drivers/misc/sgi-xp/xpc.h @@ -634,6 +634,7 @@ extern int xpc_setup_rsvd_page(void); extern void xpc_teardown_rsvd_page(void); extern int xpc_identify_activate_IRQ_sender(void); extern int xpc_partition_disengaged(struct xpc_partition *); +extern int xpc_partition_disengaged_from_timer(struct xpc_partition *part); extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *); extern void xpc_mark_partition_inactive(struct xpc_partition *); extern void xpc_discovery(void); diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index e5244fc1dab30..84610bbcc1314 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c @@ -179,7 +179,7 @@ xpc_timeout_partition_disengage(struct timer_list *t) =20 DBUG_ON(time_is_after_jiffies(part->disengage_timeout)); =20 - (void)xpc_partition_disengaged(part); + xpc_partition_disengaged_from_timer(part); =20 DBUG_ON(part->disengage_timeout !=3D 0); DBUG_ON(xpc_arch_ops.partition_engaged(XPC_PARTID(part))); diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_= partition.c index 57df06820bae2..1999d02923dee 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c @@ -262,8 +262,8 @@ xpc_get_remote_rp(int nasid, unsigned long *discovered_= nasids, * from us. Though we requested the remote partition to deactivate with re= gard * to us, we really only need to wait for the other side to disengage from= us. */ -int -xpc_partition_disengaged(struct xpc_partition *part) +static int __xpc_partition_disengaged(struct xpc_partition *part, + bool from_timer) { short partid =3D XPC_PARTID(part); int disengaged; @@ -289,9 +289,9 @@ xpc_partition_disengaged(struct xpc_partition *part) } part->disengage_timeout =3D 0; =20 - /* cancel the timer function, provided it's not us */ - if (!in_interrupt()) - del_singleshot_timer_sync(&part->disengage_timer); + /* Cancel the timer function if not called from it */ + if (!from_timer) + del_timer_sync(&part->disengage_timer); =20 DBUG_ON(part->act_state !=3D XPC_P_AS_DEACTIVATING && part->act_state !=3D XPC_P_AS_INACTIVE); @@ -303,6 +303,16 @@ xpc_partition_disengaged(struct xpc_partition *part) return disengaged; } =20 +int xpc_partition_disengaged(struct xpc_partition *part) +{ + return __xpc_partition_disengaged(part, false); +} + +int xpc_partition_disengaged_from_timer(struct xpc_partition *part) +{ + return __xpc_partition_disengaged(part, true); +} + /* * Mark specified partition as active. */ --=20 2.29.2