Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4660196imm; Mon, 30 Jul 2018 20:13:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLyUEYdecrATiNBkBwaU4GH/OtD3pxuU047DWSJmlNrUhzNCPA8F5EuxS8B/WXcwdut43t X-Received: by 2002:a17:902:a5:: with SMTP id a34-v6mr19096390pla.60.1533006781679; Mon, 30 Jul 2018 20:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533006781; cv=none; d=google.com; s=arc-20160816; b=NKMKzs2e+Coo/SlwhwD74cAYW2WZlMsTy+pt6tExzMLZEHuXF7qqrXxTxjKcBgsxBI fHfPJpbhrQDtWqGJ4OIZ/JLCW9UCC3KpBccJudLqFLHfZrDpfwJ38smInK1iNEz0TihQ H0UKTjKtnWot/AI/dzi4y0vzWeoDZsW2p4KOY85J9Lc344OxsRM+hINBKBGmNPEasCpr wOAjK9oCxsELDbavpQoeuyHuIhrPPOXZVGKKTzGoj3Od30usBPImZqQ92xM6gAD1gLKp fF1hfrqrt+P9/N116FZgeIMK0cKwr7zp2bRA3VVTeLHkxeR71WNMwtqU05JGqOFwqD4P yFPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=xuUxIuBR1M46+u1lel5XrEXu3LJXeQSAT8HdS6H6wzw=; b=aCym0GHg5r3XyqgIpQMb5gEshFMRSss5oGMNMpxRXZ3nBn3Ma/FOAP7/Lgi1GdxveC P6I7IvM6iGFft41UY/zgfZ5/C3hLx3bqm0wA1xIHXIEEy4Fx7P+NY7WEI4sn0Bz+yNam qpy/cI4vaBzEd1786h+vHZkSoWw4NROEXyV9ksyR5SpIz6FWOfLp32EpuAMrUIt3K3K1 QuetwdARfINdndTqWI+OjQ2KcnmfWdb3HHJO92AjVZT+jgXl4PfQsE/PjbIhwNnVFCIH j2Dn4E8DsrJzUAxeL5n9xzt2wShEMTn5KGFr+ZW1D1ut7m0w95ChHN8IMM8IwDcgIKU3 jEgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H8n2h4o+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21-v6si12190623pgl.165.2018.07.30.20.12.47; Mon, 30 Jul 2018 20:13:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H8n2h4o+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbeGaEuE (ORCPT + 99 others); Tue, 31 Jul 2018 00:50:04 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36557 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbeGaEuE (ORCPT ); Tue, 31 Jul 2018 00:50:04 -0400 Received: by mail-pl0-f67.google.com with SMTP id e11-v6so6474070plb.3 for ; Mon, 30 Jul 2018 20:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to; bh=xuUxIuBR1M46+u1lel5XrEXu3LJXeQSAT8HdS6H6wzw=; b=H8n2h4o+Koh/PHwJC0xMyMc+Le3CLETwpQ/r8JBDfGBcJfZGty0TO0w3clVa/RQ4nG 0TmVBkg6JXosFcjnfJCruos5oe5f2WqPGgWqrdbA8wnzPKAPwqUzL636zZWFqwbiMatP gvXbzaf52yznwTgK7Ngp8QGZRzoNUa3GKifGSAXC1WA0/5qy5toS27AhHVz0d57y64Q4 srOW06WqLmxO44wdtrJnlk6TKIV/8jr7SVLQXDV7kxiT1a2deXGCVFLU17CYVpj1RiK2 JoTJ1223V0NJ9SefNKWYo61phjmSZm80XNqVDIXIhutDODyKXLfbWvDSc+zMimT4n9hC ZhqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xuUxIuBR1M46+u1lel5XrEXu3LJXeQSAT8HdS6H6wzw=; b=DYMDlBuMo/pG1B1PjzXAbEuHJyVdBZOajFRd/XsQ5XAGiJavp6vqs5K9hRLJo2kZr4 ACDrgmPB/g0q+1AH8xJoYpO9Zk9E6kY5HMwZlnnKhakIAaWY7W9s0CtiGiWglXU1m9IV uaFI3UoqDz7LuLsbTn8hfkmJzx8WiFHVMcaLv5wp1d9b50KlXZ73R8YKoOjz6oCsCT2O urmvZKu5HstLAJKUHlkZa1YkQA76Kb+PJ0JLH4QwWlk3i+Cjmg+DFcEY9TuCy5nbVSNh aDlfLqqzD2fAYGAsMG8S5IHX/s2s3WlbT7dRRwIpGyKeABlmH70aTVMJOdY3E7V02Vtc lLLQ== X-Gm-Message-State: AOUpUlE/lDFq8YF3odXAHBU6OCnCpJIK5W2P+xsB55Esc8J26IIXSSwS 5YiE2V6YJEs6UCwsDFbFSkw= X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr18567411plo.281.1533006720799; Mon, 30 Jul 2018 20:12:00 -0700 (PDT) Received: from mhkkerneltest.corp.microsoft.com ([131.107.160.207]) by smtp.gmail.com with ESMTPSA id t88-v6sm33300246pfg.10.2018.07.30.20.11.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 20:12:00 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mikelley@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, marcelo.cerri@canonical.com, sthemmin@microsoft.com, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH char-misc 1/1] Drivers: hv: vmbus: Make synic_initialized flag per-cpu Date: Mon, 30 Jul 2018 19:34:44 -0700 Message-Id: <1533004484-3937-1-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 Reply-To: mikelley@microsoft.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kelley The synic_initialized flag is part of the global hv_context structure. But the Hyper-V synthetic interrupt controller is fundamentally a per-cpu device, and other synic related fields are in hv_per_cpu_context. In a multi-CPU system, synic_initialized gets set multiple times, making the test in hv_synic_cleanup() invalid. Fix this by moving the flag to hv_per_cpu_context and adjusting the references. Signed-off-by: Michael Kelley --- drivers/hv/hv.c | 16 +++++++--------- drivers/hv/hyperv_vmbus.h | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 312fe5e..8d4fe0e 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -33,9 +33,7 @@ #include "hyperv_vmbus.h" /* The one and only */ -struct hv_context hv_context = { - .synic_initialized = false, -}; +struct hv_context hv_context; /* * If false, we're using the old mechanism for stimer0 interrupts @@ -315,7 +313,7 @@ int hv_synic_init(unsigned int cpu) hv_set_synic_state(sctrl.as_uint64); - hv_context.synic_initialized = true; + hv_cpu->synic_initialized = true; /* * Register the per-cpu clockevent source. @@ -354,6 +352,8 @@ void hv_synic_clockevents_cleanup(void) */ int hv_synic_cleanup(unsigned int cpu) { + struct hv_per_cpu_context *hv_cpu + = per_cpu_ptr(hv_context.cpu_context, cpu); union hv_synic_sint shared_sint; union hv_synic_simp simp; union hv_synic_siefp siefp; @@ -362,7 +362,7 @@ int hv_synic_cleanup(unsigned int cpu) bool channel_found = false; unsigned long flags; - if (!hv_context.synic_initialized) + if (!hv_cpu->synic_initialized) return -EFAULT; /* @@ -395,12 +395,8 @@ int hv_synic_cleanup(unsigned int cpu) /* Turn off clockevent device */ if (ms_hyperv.features & HV_MSR_SYNTIMER_AVAILABLE) { - struct hv_per_cpu_context *hv_cpu - = this_cpu_ptr(hv_context.cpu_context); - clockevents_unbind_device(hv_cpu->clk_evt, cpu); hv_ce_shutdown(hv_cpu->clk_evt); - put_cpu_ptr(hv_cpu); } hv_get_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64); @@ -428,5 +424,7 @@ int hv_synic_cleanup(unsigned int cpu) sctrl.enable = 0; hv_set_synic_state(sctrl.as_uint64); + hv_cpu->synic_initialized = false; + return 0; } diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 72eaba3..eadd3df 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -202,6 +202,8 @@ enum { struct hv_per_cpu_context { void *synic_message_page; void *synic_event_page; + bool synic_initialized; + /* * buffer to post messages to the host. */ @@ -230,8 +232,6 @@ struct hv_context { void *tsc_page; - bool synic_initialized; - struct hv_per_cpu_context __percpu *cpu_context; /* -- 1.8.3.1