From patchwork Mon Jun 15 17:06:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jake Oshins X-Patchwork-Id: 6610921 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 891DE9F1C1 for ; Mon, 15 Jun 2015 17:10:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9752B20779 for ; Mon, 15 Jun 2015 17:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A9C5206EB for ; Mon, 15 Jun 2015 17:10:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbbFORJi (ORCPT ); Mon, 15 Jun 2015 13:09:38 -0400 Received: from o1.f.az.sendgrid.net ([208.117.55.132]:38480 "EHLO o1.f.az.sendgrid.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754405AbbFORI1 (ORCPT ); Mon, 15 Jun 2015 13:08:27 -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=pgccjYebe21YI4ZIY+yfh3GMsT4=; b=LLplUJYgJmVU+UV1Gj0NLXu7RIxyQ F4H23RZY/CRK3MiNljnuGA8YLiXpg5C9WdPtDcDvCTEIjmoDnnh6PnAThf86RWLO gZj9tSsez5THZPN2gzxZEsa/6lclTYfEywFAfSgbCwszjlUZ9z/yt4HEy1qbAVmc zYjEnv+gDsnMcw= Received: by filter-459.sjc1.sendgrid.net with SMTP id filter-459.25758.557F064125 2015-06-15 17:07:13.666872122 +0000 UTC Received: from jakeoshinsu2.jakeoshinsu2.d1.internal.cloudapp.net (unknown [104.210.40.47]) by ismtpd-091 (SG) with ESMTP id 14df8307004.28ee.104cea 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 3/6] arch:x86:hv: Add mechanism for Hyper-V paravirt drivers to hook msi message creation Date: Mon, 15 Jun 2015 17:06:36 +0000 Message-Id: <1434387999-1885-4-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: lfnueJVzSjg1mfuVqqukVH7tZvRy9mfCIcBnfbfzaMMAeeVlbCmBCzRyZ1cgoqqmytCPAj6ZVy7ZvE /2xq6qRAPfBUhpO1bf2M56BLZgjHkS506n2UVXIu4X/hsv/apO8ciTr8byOXBXdZ6AGoe7N7AbRcfF y4JXwo966+GJgYE= Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY, URIBL_GREY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jake Oshins This patch, when the kernel is built with CONFIG_HYPERV, exposes functions that would allow a paravirtual PCI front-end driver to hook MSI (message- signaled interrupt) message creation. Signed-off-by: Jake Oshins --- arch/x86/include/asm/mshyperv.h | 2 ++ arch/x86/kernel/cpu/mshyperv.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index c163215..bf7789e 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -19,5 +19,7 @@ void hyperv_callback_vector(void); void hyperv_vector_handler(struct pt_regs *regs); void hv_setup_vmbus_irq(void (*handler)(void)); void hv_remove_vmbus_irq(void); +void hyperv_install_interrupt_translation(struct x86_msi_ops *new_ops); +void hyperv_uninstall_interrupt_translation(void); #endif diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 939155f..816e329 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -69,6 +69,36 @@ void hv_remove_vmbus_irq(void) } EXPORT_SYMBOL_GPL(hv_setup_vmbus_irq); EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq); + +struct x86_msi_ops old_msi_ops; + +void hyperv_install_interrupt_translation(struct x86_msi_ops *new_ops) +{ + old_msi_ops.setup_msi_irqs = xchg(&(x86_msi.setup_msi_irqs), + new_ops->setup_msi_irqs); + old_msi_ops.compose_msi_msg = xchg(&(x86_msi.compose_msi_msg), + new_ops->compose_msi_msg); + old_msi_ops.teardown_msi_irqs = xchg(&(x86_msi.teardown_msi_irqs), + new_ops->teardown_msi_irqs); + old_msi_ops.restore_msi_irqs = xchg(&(x86_msi.restore_msi_irqs), + new_ops->restore_msi_irqs); + + new_ops->setup_msi_irqs = old_msi_ops.setup_msi_irqs; + new_ops->compose_msi_msg = old_msi_ops.compose_msi_msg; + new_ops->teardown_msi_irqs = old_msi_ops.teardown_msi_irqs; + new_ops->restore_msi_irqs = old_msi_ops.restore_msi_irqs; +} +EXPORT_SYMBOL_GPL(hyperv_install_interrupt_translation); + +void hyperv_uninstall_interrupt_translation(void) +{ + xchg(&(x86_msi.setup_msi_irqs), old_msi_ops.setup_msi_irqs); + xchg(&(x86_msi.compose_msi_msg), old_msi_ops.compose_msi_msg); + xchg(&(x86_msi.teardown_msi_irqs), old_msi_ops.teardown_msi_irqs); + xchg(&(x86_msi.restore_msi_irqs), old_msi_ops.restore_msi_irqs); +} +EXPORT_SYMBOL_GPL(hyperv_uninstall_interrupt_translation); + #endif static uint32_t __init ms_hyperv_platform(void)