Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760235AbcLAPem (ORCPT ); Thu, 1 Dec 2016 10:34:42 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:37060 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759438AbcLAPeE (ORCPT ); Thu, 1 Dec 2016 10:34:04 -0500 x-originating-ip: 72.167.245.219 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com Cc: "K. Y. Srinivasan" Subject: [PATCH 09/15] hv: change clockevents unbind tactics Date: Thu, 1 Dec 2016 09:28:46 -0800 Message-Id: <1480613332-7788-9-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1480613332-7788-1-git-send-email-kys@exchange.microsoft.com> References: <1480613287-7748-1-git-send-email-kys@exchange.microsoft.com> <1480613332-7788-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfD/TdCNlhl9FzVBMa0Zwvv+cyoMbDmjFcFH4gYvt5ovg/QlG916+8bctCWDTE4j0BtRHCd1fJcKmGHwwSK/SJKepwwvcwSwDvn1r/XL2/oXZ3a/C3Yb2 Z6Zu+emdcoLKveNT5hPAet1QjLtUDEfedrmuDBSOaC0s0utGnqguap9WvHxR0grSbLQXJmf3QOfPliboZ33iMaRLGzZKZ7OVLd1QDH5sccA+2bDAgFvUSKiU QmL23L8fxDWDLx1CE7HmN2rtQ1GeOGuGPwwJmGCSb4UlNj1pcZwlmBywVCP3qMmvnWEipS12uUa3m4WLKpt7eMr0g+m6hyiTh8zYGf0y8hBLLqy/u3+k4pKo Kk2HFgN9pJj4erlwxQf1l1nTzijh8TLwgLg+vOnJfKTHtEyvvcOufijumM38QtezrL4m5WyrBb0WR0bqmAbqq1HKqBOoBQL3D7M6XaQBycJ/VFTOsZ8= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1715 Lines: 46 From: Vitaly Kuznetsov 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(). There 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 Signed-off-by: K. Y. Srinivasan --- drivers/hv/hv.c | 6 ++++-- 1 files 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); -- 1.7.4.1