From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757513AbcIGRTs (ORCPT ); Wed, 7 Sep 2016 13:19:48 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:49840 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbcIGRTq (ORCPT ); Wed, 7 Sep 2016 13:19:46 -0400 From: Boris Ostrovsky To: david.vrabel@citrix.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, bigeasy@linutronix.de, boris.ostrovsky@oracle.com Subject: [PATCH v2 2/2] xen/events: Convert to hotplug state machine Date: Wed, 7 Sep 2016 13:19:01 -0400 Message-Id: <1473268741-3555-3-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473268741-3555-1-git-send-email-boris.ostrovsky@oracle.com> References: <1473268741-3555-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior Install the callbacks via the state machine. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Boris Ostrovsky --- drivers/xen/events/events_fifo.c | 34 ++++++++++++---------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c index 266c2c7..7ef27c6 100644 --- a/drivers/xen/events/events_fifo.c +++ b/drivers/xen/events/events_fifo.c @@ -418,30 +418,18 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu) return ret; } -static int evtchn_fifo_cpu_notification(struct notifier_block *self, - unsigned long action, - void *hcpu) +static int xen_evtchn_cpu_prepare(unsigned int cpu) { - int cpu = (long)hcpu; - int ret = 0; - - switch (action) { - case CPU_UP_PREPARE: - if (!per_cpu(cpu_control_block, cpu)) - ret = evtchn_fifo_alloc_control_block(cpu); - break; - case CPU_DEAD: - __evtchn_fifo_handle_events(cpu, true); - break; - default: - break; - } - return ret < 0 ? NOTIFY_BAD : NOTIFY_OK; + if (!per_cpu(cpu_control_block, cpu)) + return evtchn_fifo_alloc_control_block(cpu); + return 0; } -static struct notifier_block evtchn_fifo_cpu_notifier = { - .notifier_call = evtchn_fifo_cpu_notification, -}; +static int xen_evtchn_cpu_dead(unsigned int cpu) +{ + __evtchn_fifo_handle_events(cpu, true); + return 0; +} int __init xen_evtchn_fifo_init(void) { @@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; - register_cpu_notifier(&evtchn_fifo_cpu_notifier); + cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE, + "CPUHP_XEN_EVTCHN_PREPARE", + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out: put_cpu(); return ret; diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 33d352f..5f60316 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -22,6 +22,7 @@ enum cpuhp_state { CPUHP_SMPCFD_PREPARE, CPUHP_RCUTREE_PREP, CPUHP_XEN_PREPARE, + CPUHP_XEN_EVTCHN_PREPARE, CPUHP_NOTIFY_PREPARE, CPUHP_TIMERS_DEAD, CPUHP_BRINGUP_CPU, -- 2.7.4