Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp302031imu; Tue, 22 Jan 2019 19:18:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6MsWGuSeKLjZ8xMRoIdRPbQprPeBzTNUNO296Op19oPWvGDn7Yu+w0AgBWihbfZ2hoCVqx X-Received: by 2002:a17:902:b90b:: with SMTP id bf11mr562863plb.284.1548213491535; Tue, 22 Jan 2019 19:18:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548213491; cv=none; d=google.com; s=arc-20160816; b=olQgs94YGjI1KpopEWvWTZMvNHOn+U8LGdTcn7PAnWrgohpba7kY+6HfgCW0Og6aHG lw/VhL3GEzb8SiJ8ZS+0o8QHDVHRWHQaFWMGOAz4PjxzEfqT22/PjsKgVCRxhBCbrgdJ faMwwjpx4KSex0EqkwiT5JItnm5J0m2Y1U2ZruHEQHDbP4ydlY4pxLSkzsKoa9knjN/p 6N3+wwGZUDASYkv/jZGrkryzwqlXfrBkoyL3GTTa7MFUQQPD7cDrt90gSVMFSeeZEBnt 6gcgvdU5bOJm3dCzyqcB4hzKcKZpA27IXRmb5E2S6/GnpDlhUGVndJcl+tchsIg8TIa/ 2zIw== 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=0yFe9uNapu5RaK239Gio85ykH8exc39QlYP5AMaNyKg=; b=tGaDlGOCuazltyX3PgmzO3Fmj/YvHR6GGNYSZMcGisTabmVQMBL7JkMVoI02HDUUb4 SnU7qEFM5fT5/pn6ZViSQyCENXwVKEnu9z/+96JDEHo9lA5kMfIz/5ocizlsE679JvxQ 7Ncmx+rwJxYzMW0essqzUfYFd8If2UjTCFGBB/057NyhJnh+z8o87l7v660Fb3v4FKFM p0tqav/wd05YI3K7pPtei+wbB/6eKkA6F0Wo8rZjoxXpwaJ8HFGkpKELKl5FzCOpiwSy fQs2dJvEmCZxS/rbh/v3cnXjJyfeECjzYtNgL7gOoqhkVktZ1jrTRQlIAveFhzs53Jzg u6MQ== 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 p23si17596814pgk.312.2019.01.22.19.17.55; Tue, 22 Jan 2019 19:18:11 -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 S1727209AbfAWDPP (ORCPT + 99 others); Tue, 22 Jan 2019 22:15:15 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:43082 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbfAWDOz (ORCPT ); Tue, 22 Jan 2019 22:14:55 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 67C7278D57569477E5D8; Wed, 23 Jan 2019 11:14:54 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x0N3EmPh000735; Wed, 23 Jan 2019 11:14:48 +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 2019012311150804-23654305 ; Wed, 23 Jan 2019 11:15:08 +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 V2 4/6] misc/pvpanic: add pvpanic acpi driver Date: Wed, 23 Jan 2019 19:37:55 +0800 Message-Id: <1548243477-60654-5-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548243477-60654-1-git-send-email-peng.hao2@zte.com.cn> References: <1548243477-60654-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-23 11:15:08, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-23 11:14:41, Serialize complete at 2019-01-23 11:14:41 X-MAIL: mse01.zte.com.cn x0N3EmPh000735 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make pvpanic acpi driver as seperate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 9 +++++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..d274130 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,12 @@ config PVPANIC This driver provides support for the pvpanic device. pvpanic is a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..c5b73ca 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,4 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC) += pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 0000000..a6153fa --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class = "QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner = THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(&r, 0, sizeof(r)); + if (acpi_dev_resource_io(res, &r) || acpi_dev_resource_memory(res, &r)) + ret = pvpanic_add_device(dev, &r); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, + pvpanic_walk_resources, &device->dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); -- 1.8.3.1