From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbcBEXaW (ORCPT ); Fri, 5 Feb 2016 18:30:22 -0500 Received: from mxout1.idt.com ([157.165.5.25]:40099 "EHLO mxout1.idt.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbcBEX2h (ORCPT ); Fri, 5 Feb 2016 18:28:37 -0500 X-Greylist: delayed 506 seconds by postgrey-1.27 at vger.kernel.org; Fri, 05 Feb 2016 18:28:35 EST From: Alexandre Bounine To: Andrew Morton Cc: Alexandre Bounine , Matt Porter , Aurelien Jacquiot , Andre van Herk , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 11/30] rapidio/rionet: add shutdown event handling Date: Fri, 5 Feb 2016 18:19:27 -0500 Message-Id: <1454714386-15259-12-git-send-email-alexandre.bounine@idt.com> X-Mailer: git-send-email 1.7.8.4 In-Reply-To: <1454714386-15259-1-git-send-email-alexandre.bounine@idt.com> References: <1454714386-15259-1-git-send-email-alexandre.bounine@idt.com> X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add shutdown notification handler which terminates active connections with remote RapidIO nodes. This prevents remote nodes from sending packets to the powered off node and eliminates hardware error events on remote nodes. Signed-off-by: Alexandre Bounine Cc: Matt Porter Cc: Aurelien Jacquiot Cc: Andre van Herk Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/rionet.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index d3d6e35..f994fa1 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -24,6 +24,7 @@ #include #include #include +#include #define DRV_NAME "rionet" #define DRV_VERSION "0.3" @@ -599,6 +600,30 @@ out: return rc; } +static int rionet_shutdown(struct notifier_block *nb, unsigned long code, + void *unused) +{ + struct rionet_peer *peer, *tmp; + int i; + + pr_debug("%s: %s\n", DRV_NAME, __func__); + + for (i = 0; i < RIONET_MAX_NETS; i++) { + if (!nets[i].ndev) + continue; + + list_for_each_entry_safe(peer, tmp, &nets[i].peers, node) { + if (nets[i].active[peer->rdev->destid]) { + rio_send_doorbell(peer->rdev, + RIONET_DOORBELL_LEAVE); + nets[i].active[peer->rdev->destid] = NULL; + } + } + } + + return NOTIFY_DONE; +} + #ifdef MODULE static struct rio_device_id rionet_id_table[] = { {RIO_DEVICE(RIO_ANY_ID, RIO_ANY_ID)}, @@ -615,8 +640,20 @@ static struct subsys_interface rionet_interface = { .remove_dev = rionet_remove_dev, }; +static struct notifier_block rionet_notifier = { + .notifier_call = rionet_shutdown, +}; + static int __init rionet_init(void) { + int ret; + + ret = register_reboot_notifier(&rionet_notifier); + if (ret) { + pr_err("%s: failed to register reboot notifier (err=%d)\n", + DRV_NAME, ret); + return ret; + } return subsys_interface_register(&rionet_interface); } @@ -648,6 +685,7 @@ static void __exit rionet_exit(void) } } + unregister_reboot_notifier(&rionet_notifier); subsys_interface_unregister(&rionet_interface); } -- 1.7.8.4