Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1721269imu; Thu, 24 Jan 2019 00:18:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mBhnirUop3PGOOvkHAdLtF7ftKaYE2l4HXLXmF92E2aLAfYk4iwmfyf7G0jKgmYtrodjA X-Received: by 2002:a62:2781:: with SMTP id n123mr5607594pfn.138.1548317905683; Thu, 24 Jan 2019 00:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548317905; cv=none; d=google.com; s=arc-20160816; b=YtSBpNM24WtXoxQlMYgLFaFuxezp0KWx8rQybHtvCUffqKjFKnSv6UNS4JWos1Lgim ZsetM0tvCgA7sezUag7PMQ3KILV09bseQvDg7LPjcH0HO/TzIgiVbpbq7mKfc2TSiTzB R/0Rxl7hv92fNCSqPCFrjFL0wNy6vikn9QSpFboAks6PzPoxoQVaLn8FVzr7nHWkVywl mcMnVyTrCb5hI4Kewq1vX19wnPjdY8urmr8s89vsms28t4VzL9SHAbrvMmcQXm4lEfOg PHYanpLknLOf3lxdIrzoQPpcG5nCIFckanyTep6zvGu8PHp96VVBjEm1gBJAE2iYkqhE pjWw== 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=0f59uIE40JL2jQF9+o50BnAMvw0WvMGawF/1OyhGho0=; b=YcoBmP5pTYMmDNTqZ4WjtnPQqlJvMBa3hrkIciuLKIa7MRAIcjm+Mbifrq5VhPdVnH q5QYiYqBYaQtv/aQlmhKU1IVdXX/n6GBU85nYO1i0ydanObrPJEEfy5r8o1EMfcwQdqv N21IVkaUQ2K+9LTvrEhuuyIoljcGLUeCmUDWMwcAN8LQBo2kZUcXGKH1G8bmVUGItwWQ FPqcrnS4MhxGiBTv6jy6AfvOYO8eOFnlsEf7vmM9JjGlnpeiVHW1rMZae13o4iznm+my Y0PyomVPPqZD5guHiUax9PljAlMUCzdmniXsvT8ecrRzc9d33pzUKcopk26/uTaTmXIV /yUA== 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 o19si16975517pfi.261.2019.01.24.00.18.10; Thu, 24 Jan 2019 00:18:25 -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 S1727557AbfAXIRw (ORCPT + 99 others); Thu, 24 Jan 2019 03:17:52 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:47436 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbfAXIRr (ORCPT ); Thu, 24 Jan 2019 03:17:47 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id BCA2FA101436AE2DC795; Thu, 24 Jan 2019 16:17:43 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x0O8HVAa030952; Thu, 24 Jan 2019 16:17:31 +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 2019012416180154-23927982 ; Thu, 24 Jan 2019 16:18:01 +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 4/6] misc/pvpanic: add pvpanic acpi driver Date: Fri, 25 Jan 2019 00:40:36 +0800 Message-Id: <1548348038-69560-5-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:01, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-24 16:17:20, Serialize complete at 2019-01-24 16:17:20 X-MAIL: mse01.zte.com.cn x0O8HVAa030952 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make pvpanic acpi driver as separate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 13 +++++++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..1dcfe20 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,16 @@ 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 + help + This driver is one specific driver for pvpanic driver framework. + It provides an acpi device as pvpanic device. + +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..8d10924 --- /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