linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator
@ 2017-02-16 10:38 Dou Liyang
  2017-02-16 10:38 ` [PATCH 2/2] acpi: Fix the check " Dou Liyang
  2017-02-16 13:06 ` [PATCH 1/2] acpi: Fix the mapping " Hanjun Guo
  0 siblings, 2 replies; 4+ messages in thread
From: Dou Liyang @ 2017-02-16 10:38 UTC (permalink / raw)
  To: rjw, rafael, lenb; +Cc: linux-acpi, linux-kernel, Dou Liyang

In ACPI spec, we can declare processors using both Processor and
Device operator. But now, we just handle the mapping of processors
which are declared by Processor operator.

It misses the processors declared by Device operator.

The patch adds this case of the Device operator.

Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
 drivers/acpi/processor_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 611a558..1aab5b0 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -344,8 +344,10 @@ void __init acpi_set_processor_mapping(void)
 {
 	/* Set persistent cpu <-> node mapping for all processors. */
 	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
-			    ACPI_UINT32_MAX, set_processor_node_mapping,
-			    NULL, NULL, NULL);
+				ACPI_UINT32_MAX, set_processor_node_mapping,
+				NULL, NULL, NULL);
+	acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, set_processor_node_mapping,
+				NULL, NULL);
 }
 #else
 void __init acpi_set_processor_mapping(void) {}
-- 
2.5.5

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

* [PATCH 2/2] acpi: Fix the check handle in case of declaring processors using the Device operator
  2017-02-16 10:38 [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator Dou Liyang
@ 2017-02-16 10:38 ` Dou Liyang
  2017-02-16 13:06 ` [PATCH 1/2] acpi: Fix the mapping " Hanjun Guo
  1 sibling, 0 replies; 4+ messages in thread
From: Dou Liyang @ 2017-02-16 10:38 UTC (permalink / raw)
  To: rjw, rafael, lenb; +Cc: linux-acpi, linux-kernel, Dou Liyang

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 <douly.fnst@cn.fujitsu.com>
---
 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 3de3b6b..ff569cb 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -638,25 +638,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

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

* Re: [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator
  2017-02-16 10:38 [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator Dou Liyang
  2017-02-16 10:38 ` [PATCH 2/2] acpi: Fix the check " Dou Liyang
@ 2017-02-16 13:06 ` Hanjun Guo
  2017-02-17  1:48   ` Dou Liyang
  1 sibling, 1 reply; 4+ messages in thread
From: Hanjun Guo @ 2017-02-16 13:06 UTC (permalink / raw)
  To: Dou Liyang, rjw, rafael, lenb; +Cc: linux-acpi, linux-kernel

On 2017/2/16 18:38, Dou Liyang wrote:
> In ACPI spec, we can declare processors using both Processor and
> Device operator. But now, we just handle the mapping of processors
> which are declared by Processor operator.
>
> It misses the processors declared by Device operator.
>
> The patch adds this case of the Device operator.
>
> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
> ---
>  drivers/acpi/processor_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index 611a558..1aab5b0 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -344,8 +344,10 @@ void __init acpi_set_processor_mapping(void)
>  {
>  	/* Set persistent cpu <-> node mapping for all processors. */
>  	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
> -			    ACPI_UINT32_MAX, set_processor_node_mapping,
> -			    NULL, NULL, NULL);
> +				ACPI_UINT32_MAX, set_processor_node_mapping,
> +				NULL, NULL, NULL);

no need to update the code above.

> +	acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, set_processor_node_mapping,
> +				NULL, NULL);

It makes sense to me to add support for Processor devices of setting
persistent cpu <-> node mapping, but I just wondering if there is no
Processor device or Processor Operator for a processor entry(such as
local apic, the spec didn't say it's a mandatory) in MADT, how do we
set the mappings?

BTW, multi places in the ACPI driver are using the same pattern here
to scan all the processors, maybe we can add a function then call it
to reduce some lines of code?

Thanks
Hanjun

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

* Re: [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator
  2017-02-16 13:06 ` [PATCH 1/2] acpi: Fix the mapping " Hanjun Guo
@ 2017-02-17  1:48   ` Dou Liyang
  0 siblings, 0 replies; 4+ messages in thread
From: Dou Liyang @ 2017-02-17  1:48 UTC (permalink / raw)
  To: Hanjun Guo, rjw, rafael, lenb; +Cc: linux-acpi, linux-kernel



At 02/16/2017 09:06 PM, Hanjun Guo wrote:
> On 2017/2/16 18:38, Dou Liyang wrote:
>> In ACPI spec, we can declare processors using both Processor and
>> Device operator. But now, we just handle the mapping of processors
>> which are declared by Processor operator.
>>
>> It misses the processors declared by Device operator.
>>
>> The patch adds this case of the Device operator.
>>
>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>> ---
>>  drivers/acpi/processor_core.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/acpi/processor_core.c
>> b/drivers/acpi/processor_core.c
>> index 611a558..1aab5b0 100644
>> --- a/drivers/acpi/processor_core.c
>> +++ b/drivers/acpi/processor_core.c
>> @@ -344,8 +344,10 @@ void __init acpi_set_processor_mapping(void)
>>  {
>>      /* Set persistent cpu <-> node mapping for all processors. */
>>      acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
>> -                ACPI_UINT32_MAX, set_processor_node_mapping,
>> -                NULL, NULL, NULL);
>> +                ACPI_UINT32_MAX, set_processor_node_mapping,
>> +                NULL, NULL, NULL);
>
> no need to update the code above.

Here is some format problem I fixed, but it looks like I didn't do
anything. I will modify it in next version.

>
>> +    acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID,
>> set_processor_node_mapping,
>> +                NULL, NULL);
>
> It makes sense to me to add support for Processor devices of setting
> persistent cpu <-> node mapping, but I just wondering if there is no
> Processor device or Processor Operator for a processor entry(such as
> local apic, the spec didn't say it's a mandatory) in MADT,


It is in DSDT. Declare processprs like:

Processor (ProcessorName, ProcessorID, PBlockAddress, PblockLength) { 
ObjectList }

Or

Device (DeviceName) { ObjectList }

how do we
> set the mappings?

Step 1. we generate the logical CPU IDs by the Local APIC/x2APIC ID in
MADT. So, we have the mapping of CPU ID <-> Local Apic ID. We also can
get the mapping of Processor ID/UID <-> Local Apic ID directly in MADT.

  195 [0ECh 0236   1]                Subtable Type : 00 [Processor Local 
APIC]
  196 [0EDh 0237   1]                       Length : 08
  197 [0EEh 0238   1]                *Processor ID : 40*
  198 [0EFh 0239   1]                *Local Apic ID : 40*
  199 [0F0h 0240   4]        Flags (decoded below) : 00000001
  200                            Processor Enabled : 1

So, at last, we get the mapping of

*Processor ID/UID <-> Local Apic ID <-> CPU ID*

Step 2. we can get *processorID/_UID <-> Node ID(_PXM)* in DSDT.

So, we get the maaping of *Node ID <-> CPU ID* according to

*Node ID(_PXM) <-> Processor ID/UID <-> Local Apic ID <-> CPU ID*

>
> BTW, multi places in the ACPI driver are using the same pattern here
> to scan all the processors, maybe we can add a function then call it
> to reduce some lines of code?
>

Yes, I think so.

Thanks,
Liyang.

> Thanks
> Hanjun
> --
> 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
>
>
>

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

end of thread, other threads:[~2017-02-17  1:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 10:38 [PATCH 1/2] acpi: Fix the mapping handle in case of declaring processors using the Device operator Dou Liyang
2017-02-16 10:38 ` [PATCH 2/2] acpi: Fix the check " Dou Liyang
2017-02-16 13:06 ` [PATCH 1/2] acpi: Fix the mapping " Hanjun Guo
2017-02-17  1:48   ` Dou Liyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).