From patchwork Thu Jan 10 23:40:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshi Kani X-Patchwork-Id: 1963011 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AC70C40232 for ; Thu, 10 Jan 2013 23:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754817Ab3AJXuo (ORCPT ); Thu, 10 Jan 2013 18:50:44 -0500 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:46902 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754546Ab3AJXum (ORCPT ); Thu, 10 Jan 2013 18:50:42 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0009.atlanta.hp.com (Postfix) with ESMTP id A4817303F5; Thu, 10 Jan 2013 23:50:41 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.71.12.41]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id AA78314162; Thu, 10 Jan 2013 23:50:40 +0000 (UTC) From: Toshi Kani To: rjw@sisk.pl, lenb@kernel.org, gregkh@linuxfoundation.org, akpm@linux-foundation.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, bhelgaas@google.com, isimatu.yasuaki@jp.fujitsu.com, jiang.liu@huawei.com, wency@cn.fujitsu.com, guohanjun@huawei.com, yinghai@kernel.org, srivatsa.bhat@linux.vnet.ibm.com, Toshi Kani Subject: [RFC PATCH v2 01/12] Add sys_hotplug.h for system device hotplug framework Date: Thu, 10 Jan 2013 16:40:19 -0700 Message-Id: <1357861230-29549-2-git-send-email-toshi.kani@hp.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1357861230-29549-1-git-send-email-toshi.kani@hp.com> References: <1357861230-29549-1-git-send-email-toshi.kani@hp.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Added include/linux/sys_hotplug.h, which defines the system device hotplug framework interfaces used by the framework itself and handlers. The order values define the calling sequence of handlers. For add execute, the ordering is ACPI->MEM->CPU. Memory is onlined before CPU so that threads on new CPUs can start using their local memory. The ordering of the delete execute is symmetric to the add execute. struct shp_request defines a hot-plug request information. The device resource information is managed with a list so that a single request may target to multiple devices. Signed-off-by: Toshi Kani --- include/linux/sys_hotplug.h | 181 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 include/linux/sys_hotplug.h -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/sys_hotplug.h b/include/linux/sys_hotplug.h new file mode 100644 index 0000000..86674dd --- /dev/null +++ b/include/linux/sys_hotplug.h @@ -0,0 +1,181 @@ +/* + * sys_hotplug.h - System device hot-plug framework + * + * Copyright (C) 2012 Hewlett-Packard Development Company, L.P. + * Toshi Kani + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _LINUX_SYS_HOTPLUG_H +#define _LINUX_SYS_HOTPLUG_H + +#include +#include + +/* + * System device hot-plug operation proceeds in the following order. + * Validate phase -> Execute phase -> Commit phase + * + * The order values below define the calling sequence of platform + * neutral handlers for each phase in ascending order. The order + * values of firmware-specific handlers are defined in sys_hotplug.h + * under firmware specific directories. + */ + +/* All order values must be smaller than this value */ +#define SHP_ORDER_MAX 0xffffff + +/* Add Validate order values */ + +/* Add Execute order values */ +#define SHP_MEM_ADD_EXECUTE_ORDER 100 +#define SHP_CPU_ADD_EXECUTE_ORDER 110 + +/* Add Commit order values */ + +/* Delete Validate order values */ +#define SHP_CPU_DEL_VALIDATE_ORDER 100 +#define SHP_MEM_DEL_VALIDATE_ORDER 110 + +/* Delete Execute order values */ +#define SHP_CPU_DEL_EXECUTE_ORDER 10 +#define SHP_MEM_DEL_EXECUTE_ORDER 20 + +/* Delete Commit order values */ + +/* + * Hot-plug request types + */ +#define SHP_REQ_ADD 0x000000 +#define SHP_REQ_DELETE 0x000001 +#define SHP_REQ_MASK 0x0000ff + +/* + * Hot-plug phase types + */ +#define SHP_PH_VALIDATE 0x000000 +#define SHP_PH_EXECUTE 0x000100 +#define SHP_PH_COMMIT 0x000200 +#define SHP_PH_MASK 0x00ff00 + +/* + * Hot-plug operation types + */ +#define SHP_OP_HOTPLUG 0x000000 +#define SHP_OP_ONLINE 0x010000 +#define SHP_OP_MASK 0xff0000 + +/* + * Hot-plug phases + */ +enum shp_phase { + SHP_ADD_VALIDATE = (SHP_REQ_ADD|SHP_PH_VALIDATE), + SHP_ADD_EXECUTE = (SHP_REQ_ADD|SHP_PH_EXECUTE), + SHP_ADD_COMMIT = (SHP_REQ_ADD|SHP_PH_COMMIT), + SHP_DEL_VALIDATE = (SHP_REQ_DELETE|SHP_PH_VALIDATE), + SHP_DEL_EXECUTE = (SHP_REQ_DELETE|SHP_PH_EXECUTE), + SHP_DEL_COMMIT = (SHP_REQ_DELETE|SHP_PH_COMMIT) +}; + +/* + * Hot-plug operations + */ +enum shp_operation { + SHP_HOTPLUG_ADD = (SHP_OP_HOTPLUG|SHP_REQ_ADD), + SHP_HOTPLUG_DEL = (SHP_OP_HOTPLUG|SHP_REQ_DELETE), + SHP_ONLINE_ADD = (SHP_OP_ONLINE|SHP_REQ_ADD), + SHP_ONLINE_DEL = (SHP_OP_ONLINE|SHP_REQ_DELETE) +}; + +/* + * Hot-plug device classes + */ +enum shp_class { + SHP_CLS_INVALID = 0, + SHP_CLS_CPU = 1, + SHP_CLS_MEMORY = 2, + SHP_CLS_HOSTBRIDGE = 3, + SHP_CLS_CONTAINER = 4, +}; + +/* + * Hot-plug device information + */ +union shp_dev_info { + struct shp_cpu { + u32 cpu_id; + } cpu; + + struct shp_memory { + int node; + u64 start_addr; + u64 length; + } mem; + + struct shp_hostbridge { + } hb; + + struct shp_node { + } node; +}; + +struct shp_device { + struct list_head list; + struct device *device; + enum shp_class class; + union shp_dev_info info; +}; + +/* + * Hot-plug request + */ +struct shp_request { + /* common info */ + enum shp_operation operation; /* operation */ + + /* hot-plug event info: only valid for hot-plug operations */ + void *handle; /* FW handle */ + u32 event; /* FW event */ + + /* device resource info */ + struct list_head dev_list; /* shp_device list */ +}; + +/* + * Inline Utility Functions + */ +static inline bool shp_is_hotplug_op(enum shp_operation operation) +{ + return (operation & SHP_OP_MASK) == SHP_OP_HOTPLUG; +} + +static inline bool shp_is_online_op(enum shp_operation operation) +{ + return (operation & SHP_OP_MASK) == SHP_OP_ONLINE; +} + +static inline bool shp_is_add_op(enum shp_operation operation) +{ + return (operation & SHP_REQ_MASK) == SHP_REQ_ADD; +} + +static inline bool shp_is_add_phase(enum shp_phase phase) +{ + return (phase & SHP_REQ_MASK) == SHP_REQ_ADD; +} + +/* + * Externs + */ +typedef int (*shp_func)(struct shp_request *req, int rollback); +extern int shp_register_handler(enum shp_phase phase, shp_func func, u32 order); +extern int shp_unregister_handler(enum shp_phase phase, shp_func func); +extern int shp_submit_req(struct shp_request *req); +extern struct shp_request *shp_alloc_request(enum shp_operation operation); +extern void shp_add_dev_info(struct shp_request *shp_req, + struct shp_device *shp_dev); + +#endif /* _LINUX_SYS_HOTPLUG_H */