From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Subject: [V7 PATCH 1/3] ACPICA: Add ACPI _CLS processing Date: Thu, 26 Mar 2015 14:13:13 -0500 Message-ID: <1427397195-15273-2-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1427397195-15273-1-git-send-email-Suravee.Suthikulpanit@amd.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1427397195-15273-1-git-send-email-Suravee.Suthikulpanit@amd.com> Sender: linux-acpi-owner@vger.kernel.org To: rjw@rjwysocki.net, mika.westerberg@linux.intel.com, robert.moore@intel.com, lv.zheng@intel.com, hanjun.guo@linaro.org Cc: lenb@kernel.org, hdegoede@redhat.com, tj@kernel.org, mjg59@srcf.ucam.org, gregkh@linuxfoundation.org, al.stone@linaro.org, graeme.gregory@linaro.org, leo.duran@amd.com, linux-ide@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Suravee Suthikulpanit List-Id: linux-ide@vger.kernel.org ACPI Device configuration often contain _CLS object to suppy PCI-defined class code for the device. This patch introduces logic to process the _CLS object. Acked-by: Mika Westerberg Reviewed-by: Hanjun Guo Signed-off-by: Suravee Suthikulpanit --- drivers/acpi/acpica/acutils.h | 3 ++ drivers/acpi/acpica/nsxfname.c | 21 +++++++++++-- drivers/acpi/acpica/utids.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index c2f03e8..2aef850 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -430,6 +430,9 @@ acpi_status acpi_ut_execute_CID(struct acpi_namespace_node *device_node, struct acpi_pnp_device_id_list ** return_cid_list); +acpi_status +acpi_ut_execute_CLS(struct acpi_namespace_node *device_node, + struct acpi_pnp_device_id **return_id); /* * utlock - reader/writer locks */ diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c index d66c326..590ef06 100644 --- a/drivers/acpi/acpica/nsxfname.c +++ b/drivers/acpi/acpica/nsxfname.c @@ -276,11 +276,12 @@ acpi_get_object_info(acpi_handle handle, struct acpi_pnp_device_id *hid = NULL; struct acpi_pnp_device_id *uid = NULL; struct acpi_pnp_device_id *sub = NULL; + struct acpi_pnp_device_id *cls = NULL; char *next_id_string; acpi_object_type type; acpi_name name; u8 param_count = 0; - u8 valid = 0; + u16 valid = 0; u32 info_size; u32 i; acpi_status status; @@ -320,7 +321,7 @@ acpi_get_object_info(acpi_handle handle, if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) { /* * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, _SUB, and _CID methods. + * Run the Device _HID, _UID, _SUB, _CID and _CLS methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used @@ -351,6 +352,14 @@ acpi_get_object_info(acpi_handle handle, valid |= ACPI_VALID_SUB; } + /* Execute the Device._CLS method */ + + status = acpi_ut_execute_CLS(node, &cls); + if (ACPI_SUCCESS(status)) { + info_size += cls->length; + valid |= ACPI_VALID_CLS; + } + /* Execute the Device._CID method */ status = acpi_ut_execute_CID(node, &cid_list); @@ -468,6 +477,11 @@ acpi_get_object_info(acpi_handle handle, sub, next_id_string); } + if (cls) { + next_id_string = acpi_ns_copy_device_id(&info->cls, + cls, next_id_string); + } + if (cid_list) { info->compatible_id_list.count = cid_list->count; info->compatible_id_list.list_size = cid_list->list_size; @@ -507,6 +521,9 @@ cleanup: if (sub) { ACPI_FREE(sub); } + if (cls) { + ACPI_FREE(cls); + } if (cid_list) { ACPI_FREE(cid_list); } diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c index 27431cf..a64b5d1 100644 --- a/drivers/acpi/acpica/utids.c +++ b/drivers/acpi/acpica/utids.c @@ -416,3 +416,74 @@ cleanup: acpi_ut_remove_reference(obj_desc); return_ACPI_STATUS(status); } + +/******************************************************************************* + * + * FUNCTION: acpi_ut_execute_CLS + * + * PARAMETERS: device_node - Node for the device + * return_id - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _CLS control method that returns PCI-defined + * class code of the device. The ACPI spec define _CLS as a + * package with three integers. The returned string has format: + * + * "bbsspp" + * where: + * bb = Base-class code + * ss = Sub-class code + * pp = Programming Interface code + * + ******************************************************************************/ + +acpi_status +acpi_ut_execute_CLS(struct acpi_namespace_node *device_node, + struct acpi_pnp_device_id **return_id) +{ + struct acpi_pnp_device_id *cls; + union acpi_operand_object *obj_desc; + union acpi_operand_object **cls_objects; + acpi_status status; + + ACPI_FUNCTION_TRACE(ut_execute_CLS); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CLS, + ACPI_BTYPE_PACKAGE, &obj_desc); + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(status); + + cls_objects = obj_desc->package.elements; + + if (obj_desc->common.type == ACPI_TYPE_PACKAGE && + obj_desc->package.count == 3 && + cls_objects[0]->common.type == ACPI_TYPE_INTEGER && + cls_objects[1]->common.type == ACPI_TYPE_INTEGER && + cls_objects[2]->common.type == ACPI_TYPE_INTEGER) { + + /* Allocate a buffer for the CLS */ + cls = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + + (acpi_size) 7); + if (!cls) { + status = AE_NO_MEMORY; + goto cleanup; + } + + cls->string = + ACPI_ADD_PTR(char, cls, sizeof(struct acpi_pnp_device_id)); + + sprintf(cls->string, "%02x%02x%02x", + (u8)ACPI_TO_INTEGER(cls_objects[0]->integer.value), + (u8)ACPI_TO_INTEGER(cls_objects[1]->integer.value), + (u8)ACPI_TO_INTEGER(cls_objects[2]->integer.value)); + cls->length = 7; + *return_id = cls; + } + +cleanup: + + /* On exit, we must delete the return object */ + + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); +} -- 2.1.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880AbbCZTNk (ORCPT ); Thu, 26 Mar 2015 15:13:40 -0400 Received: from mail-by2on0146.outbound.protection.outlook.com ([207.46.100.146]:4992 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752101AbbCZTNg (ORCPT ); Thu, 26 Mar 2015 15:13:36 -0400 X-WSS-ID: 0NLU2QH-08-6HR-02 X-M-MSG: From: Suravee Suthikulpanit To: , , , , CC: , , , , , , , , , , , , "Suravee Suthikulpanit" Subject: [V7 PATCH 1/3] ACPICA: Add ACPI _CLS processing Date: Thu, 26 Mar 2015 14:13:13 -0500 Message-ID: <1427397195-15273-2-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427397195-15273-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1427397195-15273-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; intel.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(428002)(199003)(189002)(86362001)(229853001)(50226001)(53416004)(77156002)(62966003)(101416001)(47776003)(76176999)(50986999)(2201001)(50466002)(48376002)(87936001)(19580395003)(46102003)(105586002)(92566002)(77096005)(19580405001)(2950100001)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0201MB0891;H:atltwp02.amd.com;FPR:;SPF:None;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB0891; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:CY1PR0201MB0891;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB0891; X-Forefront-PRVS: 0527DFA348 X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2015 19:13:32.8199 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB0891 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ACPI Device configuration often contain _CLS object to suppy PCI-defined class code for the device. This patch introduces logic to process the _CLS object. Acked-by: Mika Westerberg Reviewed-by: Hanjun Guo Signed-off-by: Suravee Suthikulpanit --- drivers/acpi/acpica/acutils.h | 3 ++ drivers/acpi/acpica/nsxfname.c | 21 +++++++++++-- drivers/acpi/acpica/utids.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index c2f03e8..2aef850 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -430,6 +430,9 @@ acpi_status acpi_ut_execute_CID(struct acpi_namespace_node *device_node, struct acpi_pnp_device_id_list ** return_cid_list); +acpi_status +acpi_ut_execute_CLS(struct acpi_namespace_node *device_node, + struct acpi_pnp_device_id **return_id); /* * utlock - reader/writer locks */ diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c index d66c326..590ef06 100644 --- a/drivers/acpi/acpica/nsxfname.c +++ b/drivers/acpi/acpica/nsxfname.c @@ -276,11 +276,12 @@ acpi_get_object_info(acpi_handle handle, struct acpi_pnp_device_id *hid = NULL; struct acpi_pnp_device_id *uid = NULL; struct acpi_pnp_device_id *sub = NULL; + struct acpi_pnp_device_id *cls = NULL; char *next_id_string; acpi_object_type type; acpi_name name; u8 param_count = 0; - u8 valid = 0; + u16 valid = 0; u32 info_size; u32 i; acpi_status status; @@ -320,7 +321,7 @@ acpi_get_object_info(acpi_handle handle, if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) { /* * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, _SUB, and _CID methods. + * Run the Device _HID, _UID, _SUB, _CID and _CLS methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used @@ -351,6 +352,14 @@ acpi_get_object_info(acpi_handle handle, valid |= ACPI_VALID_SUB; } + /* Execute the Device._CLS method */ + + status = acpi_ut_execute_CLS(node, &cls); + if (ACPI_SUCCESS(status)) { + info_size += cls->length; + valid |= ACPI_VALID_CLS; + } + /* Execute the Device._CID method */ status = acpi_ut_execute_CID(node, &cid_list); @@ -468,6 +477,11 @@ acpi_get_object_info(acpi_handle handle, sub, next_id_string); } + if (cls) { + next_id_string = acpi_ns_copy_device_id(&info->cls, + cls, next_id_string); + } + if (cid_list) { info->compatible_id_list.count = cid_list->count; info->compatible_id_list.list_size = cid_list->list_size; @@ -507,6 +521,9 @@ cleanup: if (sub) { ACPI_FREE(sub); } + if (cls) { + ACPI_FREE(cls); + } if (cid_list) { ACPI_FREE(cid_list); } diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c index 27431cf..a64b5d1 100644 --- a/drivers/acpi/acpica/utids.c +++ b/drivers/acpi/acpica/utids.c @@ -416,3 +416,74 @@ cleanup: acpi_ut_remove_reference(obj_desc); return_ACPI_STATUS(status); } + +/******************************************************************************* + * + * FUNCTION: acpi_ut_execute_CLS + * + * PARAMETERS: device_node - Node for the device + * return_id - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _CLS control method that returns PCI-defined + * class code of the device. The ACPI spec define _CLS as a + * package with three integers. The returned string has format: + * + * "bbsspp" + * where: + * bb = Base-class code + * ss = Sub-class code + * pp = Programming Interface code + * + ******************************************************************************/ + +acpi_status +acpi_ut_execute_CLS(struct acpi_namespace_node *device_node, + struct acpi_pnp_device_id **return_id) +{ + struct acpi_pnp_device_id *cls; + union acpi_operand_object *obj_desc; + union acpi_operand_object **cls_objects; + acpi_status status; + + ACPI_FUNCTION_TRACE(ut_execute_CLS); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CLS, + ACPI_BTYPE_PACKAGE, &obj_desc); + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(status); + + cls_objects = obj_desc->package.elements; + + if (obj_desc->common.type == ACPI_TYPE_PACKAGE && + obj_desc->package.count == 3 && + cls_objects[0]->common.type == ACPI_TYPE_INTEGER && + cls_objects[1]->common.type == ACPI_TYPE_INTEGER && + cls_objects[2]->common.type == ACPI_TYPE_INTEGER) { + + /* Allocate a buffer for the CLS */ + cls = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + + (acpi_size) 7); + if (!cls) { + status = AE_NO_MEMORY; + goto cleanup; + } + + cls->string = + ACPI_ADD_PTR(char, cls, sizeof(struct acpi_pnp_device_id)); + + sprintf(cls->string, "%02x%02x%02x", + (u8)ACPI_TO_INTEGER(cls_objects[0]->integer.value), + (u8)ACPI_TO_INTEGER(cls_objects[1]->integer.value), + (u8)ACPI_TO_INTEGER(cls_objects[2]->integer.value)); + cls->length = 7; + *return_id = cls; + } + +cleanup: + + /* On exit, we must delete the return object */ + + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); +} -- 2.1.0