Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754042AbcKYM4M (ORCPT ); Fri, 25 Nov 2016 07:56:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35380 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753888AbcKYM4F (ORCPT ); Fri, 25 Nov 2016 07:56:05 -0500 From: Vitaly Kuznetsov To: devel@linuxdriverproject.org Cc: linux-kernel@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Dexuan Cui , Stephen Hemminger Subject: [PATCH 4/7] hv: change clockevents unbind tactics Date: Fri, 25 Nov 2016 13:48:40 +0100 Message-Id: <1480078123-17582-5-git-send-email-vkuznets@redhat.com> In-Reply-To: <1480078123-17582-1-git-send-email-vkuznets@redhat.com> References: <1480078123-17582-1-git-send-email-vkuznets@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 25 Nov 2016 12:48:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1609 Lines: 43 To get prepared to CPU offlining support we need co change the way how we unbind clockevent devices. As one CPU may go online/offline multiple times we need to bind it in hv_synic_init() and unbind it in hv_synic_cleanup(). The is an additional corner case: when we unload the module completely we need to switch to some other clockevent mechanism before stopping VMBus or we will hang. We can't call hv_synic_cleanup() before unloading VMBus as we won't be able to send UNLOAD request and get a response so hv_synic_clockevents_cleanup() has to live. Luckily, we can always call clockevents_unbind_device(), even if it wasn't bound before and there is no issue if we call it twice. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index a2567a4..c11393c 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -575,7 +575,7 @@ void hv_synic_clockevents_cleanup(void) if (!(ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE)) return; - for_each_online_cpu(cpu) + for_each_present_cpu(cpu) clockevents_unbind_device(hv_context.clk_evt[cpu], cpu); } @@ -594,8 +594,10 @@ void hv_synic_cleanup(void *arg) return; /* Turn off clockevent device */ - if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) + if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) { + clockevents_unbind_device(hv_context.clk_evt[cpu], cpu); hv_ce_shutdown(hv_context.clk_evt[cpu]); + } rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); -- 2.7.4