From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dou Liyang Subject: [PATCH v2 3/4] acpi: Fix the check handle in case of declaring processors using the Device operator Date: Mon, 20 Feb 2017 16:47:50 +0800 Message-ID: <1487580471-17665-4-git-send-email-douly.fnst@cn.fujitsu.com> References: <1487580471-17665-1-git-send-email-douly.fnst@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1487580471-17665-1-git-send-email-douly.fnst@cn.fujitsu.com> Sender: linux-kernel-owner@vger.kernel.org To: mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, rjw@rjwysocki.net, hpa@zytor.com, rafael@kernel.org, cl@linux.com, tj@kernel.org, akpm@linux-foundation.org, rafael.j.wysocki@intel.com, len.brown@intel.com, izumi.taku@jp.fujitsu.com, xiaolong.ye@intel.com Cc: x86@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Dou Liyang List-Id: linux-acpi@vger.kernel.org In ACPI spec, we can declare processors using both Processor and Device operator. And before we use the ACPI table, we should check the correctness for all processors in ACPI namespace. But, Currently, the check handle is just include only the processors which are declared by Processor operator. It misses the processors declared by Device operator. The patch adds the case of Device operator. Signed-off-by: Dou Liyang --- drivers/acpi/acpi_processor.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index f43a586..eb500e1 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -633,25 +633,43 @@ static acpi_status __init acpi_processor_ids_walk(acpi_handle handle, void **rv) { acpi_status status; + acpi_object_type acpi_type; + unsigned long long uid; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; - status = acpi_evaluate_object(handle, NULL, NULL, &buffer); - if (ACPI_FAILURE(status)) - acpi_handle_info(handle, "Not get the processor object\n"); - else - processor_validated_ids_update(object.processor.proc_id); + status = acpi_get_type(handle, &acpi_type); + switch (acpi_type) { + case ACPI_TYPE_PROCESSOR: + status = acpi_evaluate_object(handle, NULL, NULL, &buffer); + if (ACPI_FAILURE(status)) + acpi_handle_info(handle, "Not get the processor object\n"); + else + processor_validated_ids_update( + object.processor.proc_id); + break; + case ACPI_TYPE_DEVICE: + status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); + if (ACPI_FAILURE(status)) + return false; + processor_validated_ids_update(uid); + break; + default: + return false; + } return AE_OK; } -static void __init acpi_processor_check_duplicates(void) +void __init acpi_processor_check_duplicates(void) { - /* Search all processor nodes in ACPI namespace */ + /* check the correctness for all processors in ACPI namespace */ acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, acpi_processor_ids_walk, NULL, NULL, NULL); + acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, + NULL, NULL); } bool __init acpi_processor_validate_proc_id(int proc_id) -- 2.5.5 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbdBTItZ (ORCPT ); Mon, 20 Feb 2017 03:49:25 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:32504 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752201AbdBTIsy (ORCPT ); Mon, 20 Feb 2017 03:48:54 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15760088" From: Dou Liyang To: , , , , , , , , , , , , CC: , , , Dou Liyang Subject: [PATCH v2 3/4] acpi: Fix the check handle in case of declaring processors using the Device operator Date: Mon, 20 Feb 2017 16:47:50 +0800 Message-ID: <1487580471-17665-4-git-send-email-douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1487580471-17665-1-git-send-email-douly.fnst@cn.fujitsu.com> References: <1487580471-17665-1-git-send-email-douly.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 0630248A2940.AF2E7 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ACPI spec, we can declare processors using both Processor and Device operator. And before we use the ACPI table, we should check the correctness for all processors in ACPI namespace. But, Currently, the check handle is just include only the processors which are declared by Processor operator. It misses the processors declared by Device operator. The patch adds the case of Device operator. Signed-off-by: Dou Liyang --- drivers/acpi/acpi_processor.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index f43a586..eb500e1 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -633,25 +633,43 @@ static acpi_status __init acpi_processor_ids_walk(acpi_handle handle, void **rv) { acpi_status status; + acpi_object_type acpi_type; + unsigned long long uid; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; - status = acpi_evaluate_object(handle, NULL, NULL, &buffer); - if (ACPI_FAILURE(status)) - acpi_handle_info(handle, "Not get the processor object\n"); - else - processor_validated_ids_update(object.processor.proc_id); + status = acpi_get_type(handle, &acpi_type); + switch (acpi_type) { + case ACPI_TYPE_PROCESSOR: + status = acpi_evaluate_object(handle, NULL, NULL, &buffer); + if (ACPI_FAILURE(status)) + acpi_handle_info(handle, "Not get the processor object\n"); + else + processor_validated_ids_update( + object.processor.proc_id); + break; + case ACPI_TYPE_DEVICE: + status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); + if (ACPI_FAILURE(status)) + return false; + processor_validated_ids_update(uid); + break; + default: + return false; + } return AE_OK; } -static void __init acpi_processor_check_duplicates(void) +void __init acpi_processor_check_duplicates(void) { - /* Search all processor nodes in ACPI namespace */ + /* check the correctness for all processors in ACPI namespace */ acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, acpi_processor_ids_walk, NULL, NULL, NULL); + acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, + NULL, NULL); } bool __init acpi_processor_validate_proc_id(int proc_id) -- 2.5.5