Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1818768imu; Fri, 14 Dec 2018 00:47:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/XJ4/0qOxQVMHx+vOpH7wSuLQyd0X4UcRzrw/03CrYdQRtQa/senqW20ZJV1yeUpT6pX3qg X-Received: by 2002:a17:902:3281:: with SMTP id z1mr2108175plb.296.1544777271820; Fri, 14 Dec 2018 00:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544777271; cv=none; d=google.com; s=arc-20160816; b=YKAPLN9hR/41Z7QKkGUgjPLql7MWluCzCCdybTPyuHruD7Bq1iVvFw0KjBEY3txdDP n21hLbD0Ug0PUGgxPLKLhECIfkwurDLFfWV9XPXHESpsWh6/XoLgpvWxt4A5J3eRVCT0 zogwg5CTvjP3u6RqEqKBNA5YuCPDCmtGrA/+N1EH2vmQjBcFWZL2AQznG4gyKLYLxghV Jfx38KaIC8zYl2kpATxRGGbyKMZ3yFktH078HCrNwVMQZQJ86nO8vyDv5pm3uZNy5kU8 BqC24/P1Q5PwBs4j5YwlsGtpdoNp/M3Y8Nd4lf2CFFkAm4rvdUbIkVh1yN2CSbmS+axA r3wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=z1agkp+fkAdd/Elo1pbzBfX0m4dbbTwKNbcbYrBJT/Y=; b=CvfbXvOYaXQ5GBLurNgR4PixU+il2Za1waeyrpPI2EqNxTYb4Wax0GtnTjn8C5K2h1 VwVuUAJOW5PV11eqTls42fubUePaLkBKrInnKI/F8WPMDTfGhnpVr4NphI11d31bl6i6 /Obi1SRXixDjuH7yx75hkojXjxMly45p7mwsC272kc695wWZUJSKC3SXeyeqbVaXS6/S R19ERrStZqItEIxdCHuoszfYYHo84p6WaDQ/bN4m4YmzQjJ0sL/bt6W/qfIzQsae7jVZ ZPu65vZqGzxNl3Y+1Rr2RpiPDb6j8nY1fDbde8X33AIiamtLY9Jk+K/wZGDki9wZOQ6S B4Cw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si3676878plr.189.2018.12.14.00.47.36; Fri, 14 Dec 2018 00:47:51 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727949AbeLNIpf (ORCPT + 99 others); Fri, 14 Dec 2018 03:45:35 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:53916 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727256AbeLNIpf (ORCPT ); Fri, 14 Dec 2018 03:45:35 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 2D16EE1F593223E19252; Fri, 14 Dec 2018 16:45:33 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wBE8jCRb022915; Fri, 14 Dec 2018 16:45:12 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018121416455105-16718675 ; Fri, 14 Dec 2018 16:45:51 +0800 From: Peng Hao To: gregkh@linuxfoundation.org, arnd@arndb.de, andy.shevchenko@gmail.com Cc: linux-kernel@vger.kernel.org, Peng Hao Subject: [PATCH 2/3] misc/pvpanic : add pci interface for pvpanic Date: Fri, 14 Dec 2018 17:06:50 +0800 Message-Id: <1544778411-121925-2-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544778411-121925-1-git-send-email-peng.hao2@zte.com.cn> References: <1544778411-121925-1-git-send-email-peng.hao2@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-14 16:45:51, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-14 16:44:57, Serialize complete at 2018-12-14 16:44:57 X-MAIL: mse01.zte.com.cn wBE8jCRb022915 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- drivers/misc/pvpanic.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index f84ed30..1fae67e 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include static void __iomem *base; +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 #define PVPANIC_PANICKED (1 << 0) MODULE_AUTHOR("Hu Tao "); @@ -172,12 +175,71 @@ static int pvpanic_mmio_remove(struct platform_device *pdev) .remove = pvpanic_mmio_remove, }; +#ifdef CONFIG_PCI +static const struct pci_device_id pvpanic_pci_id_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),}, + {} +}; + +static int pvpanic_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int err; + + err = pci_enable_device(pdev); + if (err) + return err; + if (pci_request_region(pdev, 0, "pvpanic-pci")) + goto disable; + + base = pci_ioremap_bar(pdev, 0); + if (!base) + goto release; + + atomic_notifier_chain_register(&panic_notifier_list, + &pvpanic_panic_nb); + return 0; + +release: + pci_release_region(pdev, 0); +disable: + pci_disable_device(pdev); + + return -ENODEV; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + atomic_notifier_chain_unregister(&panic_notifier_list, + &pvpanic_panic_nb); + iounmap(base); + pci_release_region(pdev, 0); + pci_disable_device(pdev); +} + +static struct pci_driver pvpanic_pci_driver = { + .name = "pvpanic-pci", + .id_table = pvpanic_pci_id_tbl, + .probe = pvpanic_pci_probe, + .remove = pvpanic_pci_remove, +}; + +#endif /* CONFIG_PCI */ + static int __init pvpanic_mmio_init(void) { + int r1, r2; + if (acpi_disabled) - return platform_driver_register(&pvpanic_mmio_driver); + r1 = platform_driver_register(&pvpanic_mmio_driver); + else + r1 = pvpanic_register_acpi_driver(); + r2 = pci_register_driver(&pvpanic_pci_driver); + + if (r1 && r2) /* all drivers register failed */ + return 1; else - return pvpanic_register_acpi_driver(); + return 0; } static void __exit pvpanic_mmio_exit(void) @@ -186,6 +248,7 @@ static void __exit pvpanic_mmio_exit(void) platform_driver_unregister(&pvpanic_mmio_driver); else pvpanic_unregister_acpi_driver(); + pci_unregister_driver(&pvpanic_pci_driver); } module_init(pvpanic_mmio_init); -- 1.8.3.1