Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1722448imu; Thu, 24 Jan 2019 00:19:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN7y8Opmwcuvnc8GIruYDmNIlXTT2zmUWKA0/nU/EXhD70c2BWsR+EIgvLg5UtMyojsOz2Ct X-Received: by 2002:a63:eb52:: with SMTP id b18mr4962430pgk.213.1548317989212; Thu, 24 Jan 2019 00:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548317989; cv=none; d=google.com; s=arc-20160816; b=Ky8xJgUIVJOpcdrrE1n1Ar5ue/04yxWmaqI36FiYBKpNQuDzjVb1dy/kZ03QiEskqq 630JXQicwykooExRyy4PCsN1ebIZTzqbZTy3bC+H6SvJo2uX6vgHigDUm1H2KGtJ6WY2 BP+Zfz1r9RchEbTEI5hT3CZAHY5dq5GD8maOFMeCawndPy6Q3KaE5YcPAvqlk2kkmeqY WKq1ugZDpOIUTHRCIiINYZxcOX+SlLTlF7iaHeUNrM7z7bggbJ07y5JqC7Gi0wdmIKm0 4rpMzq6BcVtp50QB3CsjP7Xx1IidS4/GkE3Of0lXIFrQSbYPTjwd+mG059r6bYgyMw/c hotw== 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=6iqPV7zrDAVjqJnF5QHy6a6aLipHL9h/u4jUkXQUmWo=; b=BxZSQEjCI47d51H8Pzcwbyuxi7ihWGeUgJ2bDVWmV+KKBfbV17wlVGxdrE69tni3Sk o0O0uiX8mjmSLn7kd6X5hNUg0NW8Qa4MGYK84sB5AdaFwCswtwZT8RYVgPr7W0KYMIVO qhXrR5oYAgSkatTW+QHPt605SXv1hfuUD21AqLZBfCPDMc32RO6T/VRz3l8Z6ttkhsYI Nu5fvJMY1YZV1HVWWxGcKRhz2FFSFOl229VOIlfvRp5sf5WQRGkbT5HWGybdpy57OOdw vLD7QiI9v+w+b574cUuJUltdB5GEWyqtYIWv6RqrV81FSYZ40bNG9lA3b5COwKY9mxey P0Mw== 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 d8si19389926pgh.505.2019.01.24.00.19.33; Thu, 24 Jan 2019 00:19:49 -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 S1727573AbfAXIR6 (ORCPT + 99 others); Thu, 24 Jan 2019 03:17:58 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:12078 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727451AbfAXIRq (ORCPT ); Thu, 24 Jan 2019 03:17:46 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 7A3696C9EA06D97E7945; Thu, 24 Jan 2019 16:17:44 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x0O8HYo4030958; Thu, 24 Jan 2019 16:17:34 +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 2019012416180385-23928003 ; Thu, 24 Jan 2019 16:18:03 +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 V4 6/6] misc/pvpanic: add new pvpanic pci driver Date: Fri, 25 Jan 2019 00:40:38 +0800 Message-Id: <1548348038-69560-7-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548348038-69560-1-git-send-email-peng.hao2@zte.com.cn> References: <1548348038-69560-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 2019-01-24 16:18:04, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-24 16:17:22, Serialize complete at 2019-01-24 16:17:22 X-MAIL: mse01.zte.com.cn x0O8HYo4030958 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 10 ++++++- drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 14074af..f24c488 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -1,6 +1,6 @@ config PVPANIC tristate "pvpanic device support" - depends on HAS_IOMEM && (ACPI || OF) + depends on HAS_IOMEM && (ACPI || OF || PCI) help This driver provides support for the pvpanic device. pvpanic is a paravirtualized device provided by QEMU; it lets a virtual machine @@ -23,5 +23,13 @@ config PVPANIC_OF This driver is one specific driver for pvpanic driver framework. It provides a mmio device as pvpanic device. +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides a pci device as pvpanic device. + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 63ef0db..7c71f85 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.o +obj-$(CONFIG_PVPANIC_PCI) += pvpanic-pci.o diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c new file mode 100644 index 0000000..1261710 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 ret; + struct resource res; + + ret = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(&res, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(&pdev->dev, &res); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +static struct pci_driver pvpanic_pci_driver = { + .name = "pvpanic-pci", + .id_table = pvpanic_pci_id_tbl, + .probe = pvpanic_pci_probe, + .remove = pvpanic_pci_remove, +}; + +module_pci_driver(pvpanic_pci_driver); -- 1.8.3.1