From patchwork Mon Jun 15 17:06:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jake Oshins X-Patchwork-Id: 484439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E2EF114010F for ; Tue, 16 Jun 2015 03:09:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sendgrid.me header.i=@sendgrid.me header.b=wbaxdDHC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931AbbFORIa (ORCPT ); Mon, 15 Jun 2015 13:08:30 -0400 Received: from o1.f.az.sendgrid.net ([208.117.55.132]:27017 "EHLO o1.f.az.sendgrid.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755753AbbFORIQ (ORCPT ); Mon, 15 Jun 2015 13:08:16 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:cc:subject:in-reply-to:references; s=smtpapi; bh=4piWyMGZTJJtYAxXgHtOZGe2xDQ=; b=wbaxdDHChG/dBPGiQyVQH77KyqD6X IiSLFcP+R1NBC4ql2/cHLRt9xjEffgFGYGZmtPvWqrEP5K2/G2dJ1NIzS+pPyDvs d1menOpF5o9Wnt8vAUC+EDTpv6zCBTLICONOSrlO0KjiwevtELYjIZiqEnZVDG9d zMJFUNkioqTfnY= Received: by filter-326.sjc1.sendgrid.net with SMTP id filter-326.9099.557F06411E 2015-06-15 17:07:13.730855303 +0000 UTC Received: from jakeoshinsu2.jakeoshinsu2.d1.internal.cloudapp.net (unknown [104.210.40.47]) by ismtpd-091 (SG) with ESMTP id 14df8307058.28ee.104ceb Mon, 15 Jun 2015 17:07:13 +0000 (UTC) From: jakeo@microsoft.com To: gregkh@linuxfoundation.org, kys@microsoft.com, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, bhelgaas@google.com, linux-pci@vger.kernel.org, pebolle@tiscali.nl, haiyangz@microsoft.com, mebersol@microsoft.com Cc: Jake Oshins Subject: [PATCH v2 4/6] drivers:hv: Export a function that maps Linux proc num onto Hyper-V proc num Date: Mon, 15 Jun 2015 17:06:37 +0000 Message-Id: <1434387999-1885-5-git-send-email-jakeo@microsoft.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434387999-1885-1-git-send-email-jakeo@microsoft.com> References: <1434387999-1885-1-git-send-email-jakeo@microsoft.com> X-SG-EID: lfnueJVzSjg1mfuVqqukVH7tZvRy9mfCIcBnfbfzaMMAeeVlbCmBCzRyZ1cgoqqmApNiJjlEzJuDa8 4a2ZphfMtfgsPsyHEatqs69CRPuVrr+/52WotveHieiqontW9MV46Dr/EUpdzJN8+ccQW8gbylvXWp VWMfg8iNdVmbWuQ= Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jake Oshins This patch exports a function which maps Linux processor number onto Hyper-V virtual processor number. This is necessary in order to map message- signaled interrupts (MSIs) into a VM, as the hypervisor needs to know the right target VP. Signed-off-by: Jake Oshins --- drivers/hv/vmbus_drv.c | 16 ++++++++++++++++ include/linux/hyperv.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 067a469..65e4eb6 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1158,6 +1158,22 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, } EXPORT_SYMBOL_GPL(vmbus_allocate_mmio); +/** + * This function returns the mapping between the Linux processor + * number and + * the hypervisor's virtual processor number, useful in making + * hypercalls and such that talk about specific processors. + * + * @param procnum - in Linux terms + * + * @return int - in Hyper-V terms + */ +int vmbus_procnum_to_vpnum(int procnum) +{ + return hv_context.vp_index[procnum]; +} +EXPORT_SYMBOL_GPL(vmbus_procnum_to_vpnum); + static int vmbus_acpi_add(struct acpi_device *device) { acpi_status result; diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ffd98d7..6fec42d 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -987,6 +987,8 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, resource_size_t size, resource_size_t align, bool fb_overlap_ok); +int vmbus_procnum_to_vpnum(int procnum); + /** * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device *