public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/3] Add support for acpi_load_table/acpi_unload_table_id
@ 2006-12-04 23:32 akpm
  2006-12-14 22:42 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2006-12-04 23:32 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, akpm, jpk, ayoung, greg, len.brown, tony.luck

From: John Keller <jpk@sgi.com>

Make acpi_load_table() available for use by removing it from the #ifdef
ACPI_FUTURE_USAGE.

Also add a new routine used to unload an ACPI table of a given type and "id" -
acpi_unload_table_id().  The implementation of this new routine was almost a
direct copy of existing routine acpi_unload_table() - only difference being
that it only removes a specific table id instead of ALL tables of a given
type.  The SN hotplug driver (sgi_hotplug.c) now uses both of these interfaces
to dynamically load and unload SSDT ACPI tables.

Also, a few other ACPI routines now used by the SN hotplug driver are exported
(since the driver can be a loadable module):

 acpi_ns_map_handle_to_node
 acpi_ns_convert_entry_to_handle
 acpi_ns_get_next_node

Signed-off-by: Aaron Young <ayoung@sgi.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Greg KH <greg@kroah.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/namespace/nsxfobj.c |   44 +++++++++++++++++++++++
 drivers/acpi/tables/tbxface.c    |   54 ++++++++++++++++++++++++++++-
 include/acpi/acpixf.h            |    7 ++-
 3 files changed, 102 insertions(+), 3 deletions(-)

diff -puN drivers/acpi/namespace/nsutils.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nsutils.c
diff -puN drivers/acpi/namespace/nswalk.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nswalk.c
diff -puN drivers/acpi/tables/tbxface.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/tables/tbxface.c
--- a/drivers/acpi/tables/tbxface.c~add-support-for-acpi_load_table-acpi_unload_table_id
+++ a/drivers/acpi/tables/tbxface.c
@@ -123,7 +123,6 @@ acpi_status acpi_load_tables(void)
 
 ACPI_EXPORT_SYMBOL(acpi_load_tables)
 
-#ifdef ACPI_FUTURE_USAGE
 /*******************************************************************************
  *
  * FUNCTION:    acpi_load_table
@@ -221,6 +220,59 @@ ACPI_EXPORT_SYMBOL(acpi_load_table)
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_unload_table_id
+ *
+ * PARAMETERS:  table_type    - Type of table to be unloaded
+ *              id            - Owner ID of the table to be removed.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This routine is used to force the unload of a table (by id)
+ *
+ ******************************************************************************/
+acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id)
+{
+	struct acpi_table_desc *table_desc;
+	acpi_status status;
+
+	ACPI_FUNCTION_TRACE(acpi_unload_table);
+
+	/* Parameter validation */
+	if (table_type > ACPI_TABLE_ID_MAX)
+		return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+	/* Find table from the requested type list */
+	table_desc = acpi_gbl_table_lists[table_type].next;
+	while (table_desc && table_desc->owner_id != id)
+		table_desc = table_desc->next;
+
+	if (!table_desc)
+		return_ACPI_STATUS(AE_NOT_EXIST);
+
+	/*
+	 * Delete all namespace objects owned by this table. Note that these
+	 * objects can appear anywhere in the namespace by virtue of the AML
+	 * "Scope" operator. Thus, we need to track ownership by an ID, not
+	 * simply a position within the hierarchy
+	 */
+	acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
+
+	status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
+	if (ACPI_FAILURE(status))
+		return_ACPI_STATUS(status);
+
+	(void)acpi_tb_uninstall_table(table_desc);
+
+	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
+
+	return_ACPI_STATUS(AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
+
+#ifdef ACPI_FUTURE_USAGE
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_unload_table
  *
  * PARAMETERS:  table_type    - Type of table to be unloaded
diff -puN include/acpi/acpixf.h~add-support-for-acpi_load_table-acpi_unload_table_id include/acpi/acpixf.h
--- a/include/acpi/acpixf.h~add-support-for-acpi_load_table-acpi_unload_table_id
+++ a/include/acpi/acpixf.h
@@ -97,11 +97,12 @@ acpi_find_root_pointer(u32 flags, struct
 
 acpi_status acpi_load_tables(void);
 
-#ifdef ACPI_FUTURE_USAGE
 acpi_status acpi_load_table(struct acpi_table_header *table_ptr);
 
-acpi_status acpi_unload_table(acpi_table_type table_type);
+acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id);
 
+#ifdef ACPI_FUTURE_USAGE
+acpi_status acpi_unload_table(acpi_table_type table_type);
 acpi_status
 acpi_get_table_header(acpi_table_type table_type,
 		      u32 instance, struct acpi_table_header *out_table_header);
@@ -180,6 +181,8 @@ acpi_get_next_object(acpi_object_type ty
 
 acpi_status acpi_get_type(acpi_handle object, acpi_object_type * out_type);
 
+acpi_status acpi_get_id(acpi_handle object, acpi_owner_id * out_type);
+
 acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
 
 /*
diff -puN drivers/acpi/namespace/nsxfobj.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nsxfobj.c
--- a/drivers/acpi/namespace/nsxfobj.c~add-support-for-acpi_load_table-acpi_unload_table_id
+++ a/drivers/acpi/namespace/nsxfobj.c
@@ -50,6 +50,50 @@ ACPI_MODULE_NAME("nsxfobj")
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_get_id
+ *
+ * PARAMETERS:  Handle          - Handle of object whose id is desired
+ *              ret_id          - Where the id will be placed
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This routine returns the owner id associated with a handle
+ *
+ ******************************************************************************/
+acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
+{
+	struct acpi_namespace_node *node;
+	acpi_status status;
+
+	/* Parameter Validation */
+
+	if (!ret_id) {
+		return (AE_BAD_PARAMETER);
+	}
+
+	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE(status)) {
+		return (status);
+	}
+
+	/* Convert and validate the handle */
+
+	node = acpi_ns_map_handle_to_node(handle);
+	if (!node) {
+		(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+		return (AE_BAD_PARAMETER);
+	}
+
+	*ret_id = node->owner_id;
+
+	status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+	return (status);
+}
+
+ACPI_EXPORT_SYMBOL(acpi_get_id)
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_get_type
  *
  * PARAMETERS:  Handle          - Handle of object whose type is desired
_

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch 1/3] Add support for acpi_load_table/acpi_unload_table_id
  2006-12-04 23:32 [patch 1/3] Add support for acpi_load_table/acpi_unload_table_id akpm
@ 2006-12-14 22:42 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2006-12-14 22:42 UTC (permalink / raw)
  To: lenb, linux-acpi, jpk, ayoung, greg, len.brown, tony.luck


Well this patch was ignored and a bunch of other stuff got merged instead,
comprehensively destroying John's work.

Why is this so hard?


On Mon, 04 Dec 2006 15:32:11 -0800
akpm@osdl.org wrote:

> From: John Keller <jpk@sgi.com>
> 
> Make acpi_load_table() available for use by removing it from the #ifdef
> ACPI_FUTURE_USAGE.
> 
> Also add a new routine used to unload an ACPI table of a given type and "id" -
> acpi_unload_table_id().  The implementation of this new routine was almost a
> direct copy of existing routine acpi_unload_table() - only difference being
> that it only removes a specific table id instead of ALL tables of a given
> type.  The SN hotplug driver (sgi_hotplug.c) now uses both of these interfaces
> to dynamically load and unload SSDT ACPI tables.
> 
> Also, a few other ACPI routines now used by the SN hotplug driver are exported
> (since the driver can be a loadable module):
> 
>  acpi_ns_map_handle_to_node
>  acpi_ns_convert_entry_to_handle
>  acpi_ns_get_next_node
> 
> Signed-off-by: Aaron Young <ayoung@sgi.com>
> Cc: "Brown, Len" <len.brown@intel.com>
> Cc: Greg KH <greg@kroah.com>
> Cc: "Luck, Tony" <tony.luck@intel.com>
> Signed-off-by: Andrew Morton <akpm@osdl.org>
> ---
> 
>  drivers/acpi/namespace/nsxfobj.c |   44 +++++++++++++++++++++++
>  drivers/acpi/tables/tbxface.c    |   54 ++++++++++++++++++++++++++++-
>  include/acpi/acpixf.h            |    7 ++-
>  3 files changed, 102 insertions(+), 3 deletions(-)
> 
> diff -puN drivers/acpi/namespace/nsutils.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nsutils.c
> diff -puN drivers/acpi/namespace/nswalk.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nswalk.c
> diff -puN drivers/acpi/tables/tbxface.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/tables/tbxface.c
> --- a/drivers/acpi/tables/tbxface.c~add-support-for-acpi_load_table-acpi_unload_table_id
> +++ a/drivers/acpi/tables/tbxface.c
> @@ -123,7 +123,6 @@ acpi_status acpi_load_tables(void)
>  
>  ACPI_EXPORT_SYMBOL(acpi_load_tables)
>  
> -#ifdef ACPI_FUTURE_USAGE
>  /*******************************************************************************
>   *
>   * FUNCTION:    acpi_load_table
> @@ -221,6 +220,59 @@ ACPI_EXPORT_SYMBOL(acpi_load_table)
>  
>  /*******************************************************************************
>   *
> + * FUNCTION:    acpi_unload_table_id
> + *
> + * PARAMETERS:  table_type    - Type of table to be unloaded
> + *              id            - Owner ID of the table to be removed.
> + *
> + * RETURN:      Status
> + *
> + * DESCRIPTION: This routine is used to force the unload of a table (by id)
> + *
> + ******************************************************************************/
> +acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id)
> +{
> +	struct acpi_table_desc *table_desc;
> +	acpi_status status;
> +
> +	ACPI_FUNCTION_TRACE(acpi_unload_table);
> +
> +	/* Parameter validation */
> +	if (table_type > ACPI_TABLE_ID_MAX)
> +		return_ACPI_STATUS(AE_BAD_PARAMETER);
> +
> +	/* Find table from the requested type list */
> +	table_desc = acpi_gbl_table_lists[table_type].next;
> +	while (table_desc && table_desc->owner_id != id)
> +		table_desc = table_desc->next;
> +
> +	if (!table_desc)
> +		return_ACPI_STATUS(AE_NOT_EXIST);
> +
> +	/*
> +	 * Delete all namespace objects owned by this table. Note that these
> +	 * objects can appear anywhere in the namespace by virtue of the AML
> +	 * "Scope" operator. Thus, we need to track ownership by an ID, not
> +	 * simply a position within the hierarchy
> +	 */
> +	acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
> +
> +	status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
> +	if (ACPI_FAILURE(status))
> +		return_ACPI_STATUS(status);
> +
> +	(void)acpi_tb_uninstall_table(table_desc);
> +
> +	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
> +
> +	return_ACPI_STATUS(AE_OK);
> +}
> +
> +ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
> +
> +#ifdef ACPI_FUTURE_USAGE
> +/*******************************************************************************
> + *
>   * FUNCTION:    acpi_unload_table
>   *
>   * PARAMETERS:  table_type    - Type of table to be unloaded
> diff -puN include/acpi/acpixf.h~add-support-for-acpi_load_table-acpi_unload_table_id include/acpi/acpixf.h
> --- a/include/acpi/acpixf.h~add-support-for-acpi_load_table-acpi_unload_table_id
> +++ a/include/acpi/acpixf.h
> @@ -97,11 +97,12 @@ acpi_find_root_pointer(u32 flags, struct
>  
>  acpi_status acpi_load_tables(void);
>  
> -#ifdef ACPI_FUTURE_USAGE
>  acpi_status acpi_load_table(struct acpi_table_header *table_ptr);
>  
> -acpi_status acpi_unload_table(acpi_table_type table_type);
> +acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id);
>  
> +#ifdef ACPI_FUTURE_USAGE
> +acpi_status acpi_unload_table(acpi_table_type table_type);
>  acpi_status
>  acpi_get_table_header(acpi_table_type table_type,
>  		      u32 instance, struct acpi_table_header *out_table_header);
> @@ -180,6 +181,8 @@ acpi_get_next_object(acpi_object_type ty
>  
>  acpi_status acpi_get_type(acpi_handle object, acpi_object_type * out_type);
>  
> +acpi_status acpi_get_id(acpi_handle object, acpi_owner_id * out_type);
> +
>  acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
>  
>  /*
> diff -puN drivers/acpi/namespace/nsxfobj.c~add-support-for-acpi_load_table-acpi_unload_table_id drivers/acpi/namespace/nsxfobj.c
> --- a/drivers/acpi/namespace/nsxfobj.c~add-support-for-acpi_load_table-acpi_unload_table_id
> +++ a/drivers/acpi/namespace/nsxfobj.c
> @@ -50,6 +50,50 @@ ACPI_MODULE_NAME("nsxfobj")
>  
>  /*******************************************************************************
>   *
> + * FUNCTION:    acpi_get_id
> + *
> + * PARAMETERS:  Handle          - Handle of object whose id is desired
> + *              ret_id          - Where the id will be placed
> + *
> + * RETURN:      Status
> + *
> + * DESCRIPTION: This routine returns the owner id associated with a handle
> + *
> + ******************************************************************************/
> +acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
> +{
> +	struct acpi_namespace_node *node;
> +	acpi_status status;
> +
> +	/* Parameter Validation */
> +
> +	if (!ret_id) {
> +		return (AE_BAD_PARAMETER);
> +	}
> +
> +	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
> +	if (ACPI_FAILURE(status)) {
> +		return (status);
> +	}
> +
> +	/* Convert and validate the handle */
> +
> +	node = acpi_ns_map_handle_to_node(handle);
> +	if (!node) {
> +		(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
> +		return (AE_BAD_PARAMETER);
> +	}
> +
> +	*ret_id = node->owner_id;
> +
> +	status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
> +	return (status);
> +}
> +
> +ACPI_EXPORT_SYMBOL(acpi_get_id)
> +
> +/*******************************************************************************
> + *
>   * FUNCTION:    acpi_get_type
>   *
>   * PARAMETERS:  Handle          - Handle of object whose type is desired
> _

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-14 22:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 23:32 [patch 1/3] Add support for acpi_load_table/acpi_unload_table_id akpm
2006-12-14 22:42 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox