Re: [V4 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-06 Thread Suravee Suthikulanit

On 3/2/2015 2:27 AM, Suravee Suthikulpanit wrote:

Device drivers typically use ACPI _HIDs/_CIDs listed in struct device_driver
acpi_match_table to match devices. However, for generic drivers, we do not
want to list _HID for all supported devices. Also, certain classes of devices
do not have _CID (e.g. SATA, USB). Instead, we can leverage ACPI _CLS,
which specifies PCI-defined class code (i.e. base-class, subclass and
programming interface). This patch adds support for matching ACPI devices using
the _CLS method.

To support loadable module, current design uses _HID or _CID to match device's
modalias. With the new way of matching with _CLS this would requires 
modification
to the current ACPI modalias key to include _CLS. This patch appends PCI-defined
class-code to the existing ACPI modalias as following.

 acpi..:::
E.g:
 # cat /sys/devices/platform/AMDI0600:00/modalias
 acpi:AMDI0600:010601:

where bb is th base-class code, ss is te sub-class code, and pp is the
programming interface code

Since there would not be _HID/_CID in the ACPI matching table of the driver,
this patch adds a field to acpi_device_id to specify the matching _CLS.

 static const struct acpi_device_id ahci_acpi_match[] = {
 { "", 0, PCI_CLASS_STORAGE_SATA_AHCI },
 {},
 };

In this case, the corresponded entry in modules.alias file would be:

 alias acpi*:010601:* ahci_platform

Signed-off-by: Suravee Suthikulpanit
---
  drivers/acpi/acpica/acutils.h |  3 ++
  drivers/acpi/acpica/nsxfname.c| 20 +--
  drivers/acpi/acpica/utids.c   | 71 +++
  drivers/acpi/scan.c   | 17 --
  include/acpi/acnames.h|  1 +
  include/acpi/actypes.h|  4 ++-
  include/linux/mod_devicetable.h   |  1 +
  scripts/mod/devicetable-offsets.c |  1 +
  scripts/mod/file2alias.c  | 13 +--
  9 files changed, 123 insertions(+), 8 deletions(-)

[]

>

diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index b034f10..50d8019 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -1148,7 +1148,7 @@ struct acpi_device_info {
u32 name;   /* ACPI object Name */
acpi_object_type type;  /* ACPI object Type */
u8 param_count; /* If a method, required parameter count */
-   u8 valid;   /* Indicates which optional fields are valid */
+   u16 valid;  /* Indicates which optional fields are valid */
u8 flags;   /* Miscellaneous info */
u8 highest_dstates[4];  /* _sx_d values: 0xFF indicates not valid */
u8 lowest_dstates[5];   /* _sx_w values: 0xFF indicates not valid */
@@ -1158,6 +1158,7 @@ struct acpi_device_info {
struct acpi_pnp_device_id unique_id;/* _UID value */
struct acpi_pnp_device_id subsystem_id; /* _SUB value */
struct acpi_pnp_device_id_list compatible_id_list;  /* _CID list  */
+   struct acpi_pnp_device_id cls;  /* _CLS value */
  };


Please disregard this patch. I found out a mistake on my part here.  I 
have sent out V5 here (https://lkml.org/lkml/2015/3/6/24)


Thank you,

Suravee

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [V4 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-06 Thread Suravee Suthikulanit

On 3/2/2015 2:27 AM, Suravee Suthikulpanit wrote:

Device drivers typically use ACPI _HIDs/_CIDs listed in struct device_driver
acpi_match_table to match devices. However, for generic drivers, we do not
want to list _HID for all supported devices. Also, certain classes of devices
do not have _CID (e.g. SATA, USB). Instead, we can leverage ACPI _CLS,
which specifies PCI-defined class code (i.e. base-class, subclass and
programming interface). This patch adds support for matching ACPI devices using
the _CLS method.

To support loadable module, current design uses _HID or _CID to match device's
modalias. With the new way of matching with _CLS this would requires 
modification
to the current ACPI modalias key to include _CLS. This patch appends PCI-defined
class-code to the existing ACPI modalias as following.

 acpi:HID:CID1:CID2:..:CIDn:bbsspp:
E.g:
 # cat /sys/devices/platform/AMDI0600:00/modalias
 acpi:AMDI0600:010601:

where bb is th base-class code, ss is te sub-class code, and pp is the
programming interface code

Since there would not be _HID/_CID in the ACPI matching table of the driver,
this patch adds a field to acpi_device_id to specify the matching _CLS.

 static const struct acpi_device_id ahci_acpi_match[] = {
 { , 0, PCI_CLASS_STORAGE_SATA_AHCI },
 {},
 };

In this case, the corresponded entry in modules.alias file would be:

 alias acpi*:010601:* ahci_platform

Signed-off-by: Suravee Suthikulpanitsuravee.suthikulpa...@amd.com
---
  drivers/acpi/acpica/acutils.h |  3 ++
  drivers/acpi/acpica/nsxfname.c| 20 +--
  drivers/acpi/acpica/utids.c   | 71 +++
  drivers/acpi/scan.c   | 17 --
  include/acpi/acnames.h|  1 +
  include/acpi/actypes.h|  4 ++-
  include/linux/mod_devicetable.h   |  1 +
  scripts/mod/devicetable-offsets.c |  1 +
  scripts/mod/file2alias.c  | 13 +--
  9 files changed, 123 insertions(+), 8 deletions(-)

[]



diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index b034f10..50d8019 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -1148,7 +1148,7 @@ struct acpi_device_info {
u32 name;   /* ACPI object Name */
acpi_object_type type;  /* ACPI object Type */
u8 param_count; /* If a method, required parameter count */
-   u8 valid;   /* Indicates which optional fields are valid */
+   u16 valid;  /* Indicates which optional fields are valid */
u8 flags;   /* Miscellaneous info */
u8 highest_dstates[4];  /* _sx_d values: 0xFF indicates not valid */
u8 lowest_dstates[5];   /* _sx_w values: 0xFF indicates not valid */
@@ -1158,6 +1158,7 @@ struct acpi_device_info {
struct acpi_pnp_device_id unique_id;/* _UID value */
struct acpi_pnp_device_id subsystem_id; /* _SUB value */
struct acpi_pnp_device_id_list compatible_id_list;  /* _CID list must 
be last */
+   struct acpi_pnp_device_id cls;  /* _CLS value */
  };


Please disregard this patch. I found out a mistake on my part here.  I 
have sent out V5 here (https://lkml.org/lkml/2015/3/6/24)


Thank you,

Suravee

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[V4 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-02 Thread Suravee Suthikulpanit
Device drivers typically use ACPI _HIDs/_CIDs listed in struct device_driver
acpi_match_table to match devices. However, for generic drivers, we do not
want to list _HID for all supported devices. Also, certain classes of devices
do not have _CID (e.g. SATA, USB). Instead, we can leverage ACPI _CLS,
which specifies PCI-defined class code (i.e. base-class, subclass and
programming interface). This patch adds support for matching ACPI devices using
the _CLS method.

To support loadable module, current design uses _HID or _CID to match device's
modalias. With the new way of matching with _CLS this would requires 
modification
to the current ACPI modalias key to include _CLS. This patch appends PCI-defined
class-code to the existing ACPI modalias as following.

acpi..:::
E.g:
# cat /sys/devices/platform/AMDI0600:00/modalias
acpi:AMDI0600:010601:

where bb is th base-class code, ss is te sub-class code, and pp is the
programming interface code

Since there would not be _HID/_CID in the ACPI matching table of the driver,
this patch adds a field to acpi_device_id to specify the matching _CLS.

static const struct acpi_device_id ahci_acpi_match[] = {
{ "", 0, PCI_CLASS_STORAGE_SATA_AHCI },
{},
};

In this case, the corresponded entry in modules.alias file would be:

alias acpi*:010601:* ahci_platform

Signed-off-by: Suravee Suthikulpanit 
---
 drivers/acpi/acpica/acutils.h |  3 ++
 drivers/acpi/acpica/nsxfname.c| 20 +--
 drivers/acpi/acpica/utids.c   | 71 +++
 drivers/acpi/scan.c   | 17 --
 include/acpi/acnames.h|  1 +
 include/acpi/actypes.h|  4 ++-
 include/linux/mod_devicetable.h   |  1 +
 scripts/mod/devicetable-offsets.c |  1 +
 scripts/mod/file2alias.c  | 13 +--
 9 files changed, 123 insertions(+), 8 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..e64dc7f 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
@@ -363,6 +364,14 @@ acpi_get_object_info(acpi_handle handle,
 sizeof(struct acpi_pnp_device_id_list));
valid |= ACPI_VALID_CID;
}
+
+   /* Execute the Device._CLS method */
+
+   status = acpi_ut_execute_CLS(node, );
+   if (ACPI_SUCCESS(status)) {
+   info_size += cls->length;
+   valid |= ACPI_VALID_CLS;
+   }
}
 
/*
@@ -486,6 +495,11 @@ acpi_get_object_info(acpi_handle handle,
}
}
 
+   if (cls) {
+   next_id_string = acpi_ns_copy_device_id(>cls,
+   cls, next_id_string);
+   }
+
/* Copy the fixed-length data */
 
info->info_size = info_size;
@@ -510,6 +524,8 @@ cleanup:
if (cid_list) {
ACPI_FREE(cid_list);
}
+   if (cls)
+   ACPI_FREE(cls);
return (status);
 }
 
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);
 }
+

[V4 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-02 Thread Suravee Suthikulpanit
Device drivers typically use ACPI _HIDs/_CIDs listed in struct device_driver
acpi_match_table to match devices. However, for generic drivers, we do not
want to list _HID for all supported devices. Also, certain classes of devices
do not have _CID (e.g. SATA, USB). Instead, we can leverage ACPI _CLS,
which specifies PCI-defined class code (i.e. base-class, subclass and
programming interface). This patch adds support for matching ACPI devices using
the _CLS method.

To support loadable module, current design uses _HID or _CID to match device's
modalias. With the new way of matching with _CLS this would requires 
modification
to the current ACPI modalias key to include _CLS. This patch appends PCI-defined
class-code to the existing ACPI modalias as following.

acpi:HID:CID1:CID2:..:CIDn:bbsspp:
E.g:
# cat /sys/devices/platform/AMDI0600:00/modalias
acpi:AMDI0600:010601:

where bb is th base-class code, ss is te sub-class code, and pp is the
programming interface code

Since there would not be _HID/_CID in the ACPI matching table of the driver,
this patch adds a field to acpi_device_id to specify the matching _CLS.

static const struct acpi_device_id ahci_acpi_match[] = {
{ , 0, PCI_CLASS_STORAGE_SATA_AHCI },
{},
};

In this case, the corresponded entry in modules.alias file would be:

alias acpi*:010601:* ahci_platform

Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 drivers/acpi/acpica/acutils.h |  3 ++
 drivers/acpi/acpica/nsxfname.c| 20 +--
 drivers/acpi/acpica/utids.c   | 71 +++
 drivers/acpi/scan.c   | 17 --
 include/acpi/acnames.h|  1 +
 include/acpi/actypes.h|  4 ++-
 include/linux/mod_devicetable.h   |  1 +
 scripts/mod/devicetable-offsets.c |  1 +
 scripts/mod/file2alias.c  | 13 +--
 9 files changed, 123 insertions(+), 8 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..e64dc7f 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
@@ -363,6 +364,14 @@ acpi_get_object_info(acpi_handle handle,
 sizeof(struct acpi_pnp_device_id_list));
valid |= ACPI_VALID_CID;
}
+
+   /* Execute the Device._CLS method */
+
+   status = acpi_ut_execute_CLS(node, cls);
+   if (ACPI_SUCCESS(status)) {
+   info_size += cls-length;
+   valid |= ACPI_VALID_CLS;
+   }
}
 
/*
@@ -486,6 +495,11 @@ acpi_get_object_info(acpi_handle handle,
}
}
 
+   if (cls) {
+   next_id_string = acpi_ns_copy_device_id(info-cls,
+   cls, next_id_string);
+   }
+
/* Copy the fixed-length data */
 
info-info_size = info_size;
@@ -510,6 +524,8 @@ cleanup:
if (cid_list) {
ACPI_FREE(cid_list);
}
+   if (cls)
+   ACPI_FREE(cls);
return (status);
 }
 
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);
 }
+