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

2015-03-25 Thread Suravee Suthikulpanit

On 3/24/15 15:20, Rafael J. Wysocki wrote:

On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:

On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:

On 3/9/15 10:20, Mika Westerberg wrote:

[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at the
moment. If you think this is the right approach going forward, we can work
on cleaning this up on a separate patch series. Please let me know what you
think.


I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)


I agree.


Okay, how should I organize this big change? Can we do this as a 
separate patch series?


Thanks,
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-25 Thread Suravee Suthikulpanit

On 3/24/15 15:20, Rafael J. Wysocki wrote:

On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:

On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:

On 3/9/15 10:20, Mika Westerberg wrote:

[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at the
moment. If you think this is the right approach going forward, we can work
on cleaning this up on a separate patch series. Please let me know what you
think.


I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)


I agree.


Okay, how should I organize this big change? Can we do this as a 
separate patch series?


Thanks,
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-25 Thread Mika Westerberg
On Wed, Mar 25, 2015 at 10:09:42AM -0500, Suravee Suthikulpanit wrote:
> On 3/24/15 15:20, Rafael J. Wysocki wrote:
> >On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:
> >>On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
> >>>On 3/9/15 10:20, Mika Westerberg wrote:
> >[]
> >diff --git a/include/linux/mod_devicetable.h 
> >b/include/linux/mod_devicetable.h
> >index e530533..9a42522 100644
> >--- a/include/linux/mod_devicetable.h
> >+++ b/include/linux/mod_devicetable.h
> >@@ -189,6 +189,7 @@ struct css_device_id {
> >  struct acpi_device_id {
> > __u8 id[ACPI_ID_LEN];
> > kernel_ulong_t driver_data;
> >+__u32 cls;
> 
> It would be nice if we could change ordering here but I understand that
> it breaks quite many drivers. Perhaps we should consider creating
> ACPI_DEVICE() macro and convert existing drivers to that at some point.
> >>>
> >>>Yes, a roughly grep in the drivers directory showing about 112 files at the
> >>>moment. If you think this is the right approach going forward, we can work
> >>>on cleaning this up on a separate patch series. Please let me know what you
> >>>think.
> >>
> >>I think having ACPI_DEVICE() macro would be pretty useful and it avoids
> >>things like this if we need to add new fields in the future. Rafael has
> >>the last word, though :-)
> >
> >I agree.
> 
> Okay, how should I organize this big change? Can we do this as a separate
> patch series?

Separate patch series is fine.
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-25 Thread Mika Westerberg
On Wed, Mar 25, 2015 at 10:09:42AM -0500, Suravee Suthikulpanit wrote:
 On 3/24/15 15:20, Rafael J. Wysocki wrote:
 On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:
 On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
 On 3/9/15 10:20, Mika Westerberg wrote:
 []
 diff --git a/include/linux/mod_devicetable.h 
 b/include/linux/mod_devicetable.h
 index e530533..9a42522 100644
 --- a/include/linux/mod_devicetable.h
 +++ b/include/linux/mod_devicetable.h
 @@ -189,6 +189,7 @@ struct css_device_id {
   struct acpi_device_id {
  __u8 id[ACPI_ID_LEN];
  kernel_ulong_t driver_data;
 +__u32 cls;
 
 It would be nice if we could change ordering here but I understand that
 it breaks quite many drivers. Perhaps we should consider creating
 ACPI_DEVICE() macro and convert existing drivers to that at some point.
 
 Yes, a roughly grep in the drivers directory showing about 112 files at the
 moment. If you think this is the right approach going forward, we can work
 on cleaning this up on a separate patch series. Please let me know what you
 think.
 
 I think having ACPI_DEVICE() macro would be pretty useful and it avoids
 things like this if we need to add new fields in the future. Rafael has
 the last word, though :-)
 
 I agree.
 
 Okay, how should I organize this big change? Can we do this as a separate
 patch series?

Separate patch series is fine.
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-25 Thread Suravee Suthikulpanit

On 3/24/15 15:20, Rafael J. Wysocki wrote:

On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:

On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:

On 3/9/15 10:20, Mika Westerberg wrote:

[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at the
moment. If you think this is the right approach going forward, we can work
on cleaning this up on a separate patch series. Please let me know what you
think.


I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)


I agree.


Okay, how should I organize this big change? Can we do this as a 
separate patch series?


Thanks,
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-25 Thread Suravee Suthikulpanit

On 3/24/15 15:20, Rafael J. Wysocki wrote:

On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:

On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:

On 3/9/15 10:20, Mika Westerberg wrote:

[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at the
moment. If you think this is the right approach going forward, we can work
on cleaning this up on a separate patch series. Please let me know what you
think.


I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)


I agree.


Okay, how should I organize this big change? Can we do this as a 
separate patch series?


Thanks,
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-24 Thread Rafael J. Wysocki
On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:
> On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
> > Not sure if this email went out originally. So, I am resending this.
> > 
> > On 3/9/15 10:20, Mika Westerberg wrote:
> > >On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },
> > >
> > >How about introducing macro like PCI already has and then do it like:
> > >
> > >   { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },
> > 
> > This is good.  I'll update this.
> > >
> > >Also should we allow mask here as well? This would allow partial match
> > >if, for example we are only interested in class and subclass.
> > 
> > Hm, I'm not familiar with how other drivers might be benefit from this.
> > Could you please give an example of a drivers that only deals with just the
> > class and/or subclass of devices?
> 
> If you check for example drivers/ata/ata_generic.c it has this:
> 
> { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFF00UL),
> .driver_data = ATA_GEN_CLASS_MATCH },
> 
> That seems to ignore programming interface.
> 
> > If so, could we use 0xFF to specify the don't care field?
> 
> In the above it seems that 0 is the don't care.
> 
> > >
> > >> {},
> > >> };
> > >>
> > >>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| 21 ++--
> > >>  drivers/acpi/acpica/utids.c   | 71 
> > >> +++
> > >
> > >I think you need to split the ACPICA part to be a separate patch. Those
> > >are merged through ACPICA.
> > 
> > I will update this in the next patch set.
> > 
> > >>[]
> > >>diff --git a/include/linux/mod_devicetable.h 
> > >>b/include/linux/mod_devicetable.h
> > >>index e530533..9a42522 100644
> > >>--- a/include/linux/mod_devicetable.h
> > >>+++ b/include/linux/mod_devicetable.h
> > >>@@ -189,6 +189,7 @@ struct css_device_id {
> > >>  struct acpi_device_id {
> > >>  __u8 id[ACPI_ID_LEN];
> > >>  kernel_ulong_t driver_data;
> > >>+ __u32 cls;
> > >
> > >It would be nice if we could change ordering here but I understand that
> > >it breaks quite many drivers. Perhaps we should consider creating
> > >ACPI_DEVICE() macro and convert existing drivers to that at some point.
> > 
> > Yes, a roughly grep in the drivers directory showing about 112 files at the
> > moment. If you think this is the right approach going forward, we can work
> > on cleaning this up on a separate patch series. Please let me know what you
> > think.
> 
> I think having ACPI_DEVICE() macro would be pretty useful and it avoids
> things like this if we need to add new fields in the future. Rafael has
> the last word, though :-)

I agree.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-24 Thread Mika Westerberg
On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
> Not sure if this email went out originally. So, I am resending this.
> 
> On 3/9/15 10:20, Mika Westerberg wrote:
> >On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },
> >
> >How about introducing macro like PCI already has and then do it like:
> >
> > { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },
> 
> This is good.  I'll update this.
> >
> >Also should we allow mask here as well? This would allow partial match
> >if, for example we are only interested in class and subclass.
> 
> Hm, I'm not familiar with how other drivers might be benefit from this.
> Could you please give an example of a drivers that only deals with just the
> class and/or subclass of devices?

If you check for example drivers/ata/ata_generic.c it has this:

{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFF00UL),
  .driver_data = ATA_GEN_CLASS_MATCH },

That seems to ignore programming interface.

> If so, could we use 0xFF to specify the don't care field?

In the above it seems that 0 is the don't care.

> >
> >> {},
> >> };
> >>
> >>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| 21 ++--
> >>  drivers/acpi/acpica/utids.c   | 71 
> >> +++
> >
> >I think you need to split the ACPICA part to be a separate patch. Those
> >are merged through ACPICA.
> 
> I will update this in the next patch set.
> 
> >>[]
> >>diff --git a/include/linux/mod_devicetable.h 
> >>b/include/linux/mod_devicetable.h
> >>index e530533..9a42522 100644
> >>--- a/include/linux/mod_devicetable.h
> >>+++ b/include/linux/mod_devicetable.h
> >>@@ -189,6 +189,7 @@ struct css_device_id {
> >>  struct acpi_device_id {
> >>__u8 id[ACPI_ID_LEN];
> >>kernel_ulong_t driver_data;
> >>+   __u32 cls;
> >
> >It would be nice if we could change ordering here but I understand that
> >it breaks quite many drivers. Perhaps we should consider creating
> >ACPI_DEVICE() macro and convert existing drivers to that at some point.
> 
> Yes, a roughly grep in the drivers directory showing about 112 files at the
> moment. If you think this is the right approach going forward, we can work
> on cleaning this up on a separate patch series. Please let me know what you
> think.

I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-24 Thread Suravee Suthikulpanit

Not sure if this email went out originally. So, I am resending this.

On 3/9/15 10:20, Mika Westerberg wrote:

On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },


How about introducing macro like PCI already has and then do it like:

{ ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },


This is good.  I'll update this.


Also should we allow mask here as well? This would allow partial match
if, for example we are only interested in class and subclass.


Hm, I'm not familiar with how other drivers might be benefit from this. 
Could you please give an example of a drivers that only deals with just 
the class and/or subclass of devices?


If so, could we use 0xFF to specify the don't care field?




 {},
 };

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| 21 ++--
  drivers/acpi/acpica/utids.c   | 71 +++


I think you need to split the ACPICA part to be a separate patch. Those
are merged through ACPICA.


I will update this in the next patch set.


[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at 
the moment. If you think this is the right approach going forward, we 
can work on cleaning this up on a separate patch series. Please let me 
know what you think.


Thanks,

Suravee


  };

  #define PNP_ID_LEN8
diff --git a/scripts/mod/devicetable-offsets.c 
b/scripts/mod/devicetable-offsets.c
index f282516..7f68268 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -63,6 +63,7 @@ int main(void)

DEVID(acpi_device_id);
DEVID_FIELD(acpi_device_id, id);
+   DEVID_FIELD(acpi_device_id, cls);

DEVID(pnp_device_id);
DEVID_FIELD(pnp_device_id, id);
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e614ef6..ba5998c 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -511,12 +511,21 @@ static int do_serio_entry(const char *filename,
  }
  ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry);

-/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
+/* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B"  or "acpi:LNXVIDEO" or
+ * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if)
+ *
+ * NOTE: * Each driver should use one of the following : _HID, _CIDs or _CLS.
+ */
  static int do_acpi_entry(const char *filename,
void *symval, char *alias)
  {
DEF_FIELD_ADDR(symval, acpi_device_id, id);
-   sprintf(alias, "acpi*:%s:*", *id);
+   DEF_FIELD_ADDR(symval, acpi_device_id, cls);
+
+   if (id && strlen((const char *)*id))
+   sprintf(alias, "acpi*:%s:*", *id);
+   else if (cls)
+   sprintf(alias, "acpi*:%06x:*", *cls);
return 1;
  }
  ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry);
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

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

2015-03-24 Thread Suravee Suthikulpanit

Not sure if this email went out originally. So, I am resending this.

On 3/9/15 10:20, Mika Westerberg wrote:

On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },


How about introducing macro like PCI already has and then do it like:

{ ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },


This is good.  I'll update this.


Also should we allow mask here as well? This would allow partial match
if, for example we are only interested in class and subclass.


Hm, I'm not familiar with how other drivers might be benefit from this. 
Could you please give an example of a drivers that only deals with just 
the class and/or subclass of devices?


If so, could we use 0xFF to specify the don't care field?




 {},
 };

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| 21 ++--
  drivers/acpi/acpica/utids.c   | 71 +++


I think you need to split the ACPICA part to be a separate patch. Those
are merged through ACPICA.


I will update this in the next patch set.


[]
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e530533..9a42522 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -189,6 +189,7 @@ struct css_device_id {
  struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
+   __u32 cls;


It would be nice if we could change ordering here but I understand that
it breaks quite many drivers. Perhaps we should consider creating
ACPI_DEVICE() macro and convert existing drivers to that at some point.


Yes, a roughly grep in the drivers directory showing about 112 files at 
the moment. If you think this is the right approach going forward, we 
can work on cleaning this up on a separate patch series. Please let me 
know what you think.


Thanks,

Suravee


  };

  #define PNP_ID_LEN8
diff --git a/scripts/mod/devicetable-offsets.c 
b/scripts/mod/devicetable-offsets.c
index f282516..7f68268 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -63,6 +63,7 @@ int main(void)

DEVID(acpi_device_id);
DEVID_FIELD(acpi_device_id, id);
+   DEVID_FIELD(acpi_device_id, cls);

DEVID(pnp_device_id);
DEVID_FIELD(pnp_device_id, id);
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e614ef6..ba5998c 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -511,12 +511,21 @@ static int do_serio_entry(const char *filename,
  }
  ADD_TO_DEVTABLE(serio, serio_device_id, do_serio_entry);

-/* looks like: acpi:ACPI0003 or acpi:PNP0C0B or acpi:LNXVIDEO */
+/* looks like: acpi:ACPI0003 or acpi:PNP0C0B  or acpi:LNXVIDEO or
+ * acpi:bbsspp (bb=base-class, ss=sub-class, pp=prog-if)
+ *
+ * NOTE: * Each driver should use one of the following : _HID, _CIDs or _CLS.
+ */
  static int do_acpi_entry(const char *filename,
void *symval, char *alias)
  {
DEF_FIELD_ADDR(symval, acpi_device_id, id);
-   sprintf(alias, acpi*:%s:*, *id);
+   DEF_FIELD_ADDR(symval, acpi_device_id, cls);
+
+   if (id  strlen((const char *)*id))
+   sprintf(alias, acpi*:%s:*, *id);
+   else if (cls)
+   sprintf(alias, acpi*:%06x:*, *cls);
return 1;
  }
  ADD_TO_DEVTABLE(acpi, acpi_device_id, do_acpi_entry);
--
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-acpi in
the body of a message to majord...@vger.kernel.org

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

2015-03-24 Thread Mika Westerberg
On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
 Not sure if this email went out originally. So, I am resending this.
 
 On 3/9/15 10:20, Mika Westerberg wrote:
 On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },
 
 How about introducing macro like PCI already has and then do it like:
 
  { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },
 
 This is good.  I'll update this.
 
 Also should we allow mask here as well? This would allow partial match
 if, for example we are only interested in class and subclass.
 
 Hm, I'm not familiar with how other drivers might be benefit from this.
 Could you please give an example of a drivers that only deals with just the
 class and/or subclass of devices?

If you check for example drivers/ata/ata_generic.c it has this:

{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE  8, 0xFF00UL),
  .driver_data = ATA_GEN_CLASS_MATCH },

That seems to ignore programming interface.

 If so, could we use 0xFF to specify the don't care field?

In the above it seems that 0 is the don't care.

 
  {},
  };
 
 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| 21 ++--
   drivers/acpi/acpica/utids.c   | 71 
  +++
 
 I think you need to split the ACPICA part to be a separate patch. Those
 are merged through ACPICA.
 
 I will update this in the next patch set.
 
 []
 diff --git a/include/linux/mod_devicetable.h 
 b/include/linux/mod_devicetable.h
 index e530533..9a42522 100644
 --- a/include/linux/mod_devicetable.h
 +++ b/include/linux/mod_devicetable.h
 @@ -189,6 +189,7 @@ struct css_device_id {
   struct acpi_device_id {
 __u8 id[ACPI_ID_LEN];
 kernel_ulong_t driver_data;
 +   __u32 cls;
 
 It would be nice if we could change ordering here but I understand that
 it breaks quite many drivers. Perhaps we should consider creating
 ACPI_DEVICE() macro and convert existing drivers to that at some point.
 
 Yes, a roughly grep in the drivers directory showing about 112 files at the
 moment. If you think this is the right approach going forward, we can work
 on cleaning this up on a separate patch series. Please let me know what you
 think.

I think having ACPI_DEVICE() macro would be pretty useful and it avoids
things like this if we need to add new fields in the future. Rafael has
the last word, though :-)
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-24 Thread Rafael J. Wysocki
On Tuesday, March 24, 2015 04:43:46 PM Mika Westerberg wrote:
 On Tue, Mar 24, 2015 at 09:23:47AM -0500, Suravee Suthikulpanit wrote:
  Not sure if this email went out originally. So, I am resending this.
  
  On 3/9/15 10:20, Mika Westerberg wrote:
  On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },
  
  How about introducing macro like PCI already has and then do it like:
  
 { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },
  
  This is good.  I'll update this.
  
  Also should we allow mask here as well? This would allow partial match
  if, for example we are only interested in class and subclass.
  
  Hm, I'm not familiar with how other drivers might be benefit from this.
  Could you please give an example of a drivers that only deals with just the
  class and/or subclass of devices?
 
 If you check for example drivers/ata/ata_generic.c it has this:
 
 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE  8, 0xFF00UL),
 .driver_data = ATA_GEN_CLASS_MATCH },
 
 That seems to ignore programming interface.
 
  If so, could we use 0xFF to specify the don't care field?
 
 In the above it seems that 0 is the don't care.
 
  
   {},
   };
  
  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| 21 ++--
drivers/acpi/acpica/utids.c   | 71 
   +++
  
  I think you need to split the ACPICA part to be a separate patch. Those
  are merged through ACPICA.
  
  I will update this in the next patch set.
  
  []
  diff --git a/include/linux/mod_devicetable.h 
  b/include/linux/mod_devicetable.h
  index e530533..9a42522 100644
  --- a/include/linux/mod_devicetable.h
  +++ b/include/linux/mod_devicetable.h
  @@ -189,6 +189,7 @@ struct css_device_id {
struct acpi_device_id {
__u8 id[ACPI_ID_LEN];
kernel_ulong_t driver_data;
  + __u32 cls;
  
  It would be nice if we could change ordering here but I understand that
  it breaks quite many drivers. Perhaps we should consider creating
  ACPI_DEVICE() macro and convert existing drivers to that at some point.
  
  Yes, a roughly grep in the drivers directory showing about 112 files at the
  moment. If you think this is the right approach going forward, we can work
  on cleaning this up on a separate patch series. Please let me know what you
  think.
 
 I think having ACPI_DEVICE() macro would be pretty useful and it avoids
 things like this if we need to add new fields in the future. Rafael has
 the last word, though :-)

I agree.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: [V5 PATCH 1/2] ACPI / scan: Add support for ACPI _CLS device matching

2015-03-09 Thread Mika Westerberg
On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },

How about introducing macro like PCI already has and then do it like:

{ ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },

Also should we allow mask here as well? This would allow partial match
if, for example we are only interested in class and subclass.

> {},
> };
> 
> 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| 21 ++--
>  drivers/acpi/acpica/utids.c   | 71 
> +++

I think you need to split the ACPICA part to be a separate patch. Those
are merged through ACPICA.

>  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, 124 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..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, );
> + if (ACPI_SUCCESS(status)) {
> + info_size += cls->length;
> + valid |= ACPI_VALID_CLS;
> + }
> +
>   /* Execute the Device._CID method */
>  
>   status = acpi_ut_execute_CID(node, _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(>cls,
> + 

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

2015-03-09 Thread Mika Westerberg
On Fri, Mar 06, 2015 at 12:11:41AM -0600, 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 },

How about introducing macro like PCI already has and then do it like:

{ ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI) },

Also should we allow mask here as well? This would allow partial match
if, for example we are only interested in class and subclass.

 {},
 };
 
 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| 21 ++--
  drivers/acpi/acpica/utids.c   | 71 
 +++

I think you need to split the ACPICA part to be a separate patch. Those
are merged through ACPICA.

  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, 124 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..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);

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

2015-03-05 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| 21 ++--
 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, 124 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..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, );
+   if (ACPI_SUCCESS(status)) {
+   info_size += cls->length;
+   valid |= ACPI_VALID_CLS;
+   }
+
/* Execute the Device._CID method */
 
status = acpi_ut_execute_CID(node, _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(>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

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

2015-03-05 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| 21 ++--
 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, 124 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..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