All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH v2 1/1] tunables: check usb autosuspend support before add
@ 2014-08-25 19:45 Nanley Chery
  0 siblings, 0 replies; 3+ messages in thread
From: Nanley Chery @ 2014-08-25 19:45 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

Some usb devices do not have drivers that support autosuspend.
These drivers should not be added to the list of tunables, because
toggling their good/bad value does nothing.

Signed-off-by: Nanley Chery <nanleychery(a)gmail.com>
---

Fixed the issue in the previous patch that allowed returning between
opendir and closedir (thanks Sergey). Also improve detection of interface 
folders.

 src/tuning/tuningusb.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
index 27a6dca..d2a0c11 100644
--- a/src/tuning/tuningusb.cpp
+++ b/src/tuning/tuningusb.cpp
@@ -28,6 +28,7 @@
 #include "unistd.h"
 #include "tuningusb.h"
 #include <string.h>
+#include <dirent.h>
 #include <utility>
 #include <iostream>
 #include <fstream>
@@ -117,6 +118,7 @@ static void add_usb_callback(const char *d_name)
 {
 	class usb_tunable *usb;
 	char filename[4096];
+	DIR *dir;
 
 	sprintf(filename, "/sys/bus/usb/devices/%s/power/control", d_name);
 	if (access(filename, R_OK) != 0)
@@ -126,6 +128,23 @@ static void add_usb_callback(const char *d_name)
 	if (access(filename, R_OK)!=0)
 		return;
 
+	/* every interface of this device should support autosuspend */
+	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
+	if ((dir = opendir(filename))) {
+		struct dirent *entry;
+		while ((entry = readdir(dir))) {
+			/* dirname: <busnum>-<devnum>...:<config num>-<interface num> */
+			if (!isdigit(entry->d_name[0]))
+				continue;
+			sprintf(filename, "/sys/bus/usb/devices/%s/%s/supports_autosuspend", d_name, entry->d_name);
+			if (access(filename, R_OK) == 0 && read_sysfs(filename) == 0)
+				break;
+		}
+		closedir(dir);
+		if (entry)
+			return;
+	}
+
 	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
 	usb = new class usb_tunable(filename, d_name);
 	all_tunables.push_back(usb);
-- 
2.0.4


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

* Re: [Powertop] [PATCH v2 1/1] tunables: check usb autosuspend support before add
@ 2014-09-30  0:52 Alexandra Yates
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandra Yates @ 2014-09-30  0:52 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]


> Some usb devices do not have drivers that support autosuspend.
> These drivers should not be added to the list of tunables, because
> toggling their good/bad value does nothing.
>
> Signed-off-by: Nanley Chery <nanleychery(a)gmail.com>
> ---
>
> Fixed the issue in the previous patch that allowed returning between
> opendir and closedir (thanks Sergey). Also improve detection of interface
> folders.
>
>  src/tuning/tuningusb.cpp | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
> index 27a6dca..d2a0c11 100644
> --- a/src/tuning/tuningusb.cpp
> +++ b/src/tuning/tuningusb.cpp
> @@ -28,6 +28,7 @@
>  #include "unistd.h"
>  #include "tuningusb.h"
>  #include <string.h>
> +#include <dirent.h>
>  #include <utility>
>  #include <iostream>
>  #include <fstream>
> @@ -117,6 +118,7 @@ static void add_usb_callback(const char *d_name)
>  {
>  	class usb_tunable *usb;
>  	char filename[4096];
> +	DIR *dir;
>
>  	sprintf(filename, "/sys/bus/usb/devices/%s/power/control", d_name);
>  	if (access(filename, R_OK) != 0)
> @@ -126,6 +128,23 @@ static void add_usb_callback(const char *d_name)
>  	if (access(filename, R_OK)!=0)
>  		return;
>
> +	/* every interface of this device should support autosuspend */
> +	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
> +	if ((dir = opendir(filename))) {
> +		struct dirent *entry;
> +		while ((entry = readdir(dir))) {
> +			/* dirname: <busnum>-<devnum>...:<config num>-<interface num> */
> +			if (!isdigit(entry->d_name[0]))
> +				continue;
> +			sprintf(filename, "/sys/bus/usb/devices/%s/%s/supports_autosuspend",
> d_name, entry->d_name);
> +			if (access(filename, R_OK) == 0 && read_sysfs(filename) == 0)
> +				break;
> +		}
> +		closedir(dir);
> +		if (entry)
> +			return;
> +	}
> +
>  	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
>  	usb = new class usb_tunable(filename, d_name);
>  	all_tunables.push_back(usb);
> --
> 2.0.4
>
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
>

Nanley,

Thank you very much for sending you patch. It was up-streamed today.

Alexandra.

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

* Re: [Powertop] [PATCH v2 1/1] tunables: check usb autosuspend support before add
@ 2014-09-30 15:14 Nanley Chery
  0 siblings, 0 replies; 3+ messages in thread
From: Nanley Chery @ 2014-09-30 15:14 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2878 bytes --]

Hello Alexandra,

Thank you for accepting this patch.

Nanley

On Mon, Sep 29, 2014 at 8:52 PM, Alexandra Yates <
alexandra.yates(a)linux.intel.com> wrote:

>
> > Some usb devices do not have drivers that support autosuspend.
> > These drivers should not be added to the list of tunables, because
> > toggling their good/bad value does nothing.
> >
> > Signed-off-by: Nanley Chery <nanleychery(a)gmail.com>
> > ---
> >
> > Fixed the issue in the previous patch that allowed returning between
> > opendir and closedir (thanks Sergey). Also improve detection of interface
> > folders.
> >
> >  src/tuning/tuningusb.cpp | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
> > index 27a6dca..d2a0c11 100644
> > --- a/src/tuning/tuningusb.cpp
> > +++ b/src/tuning/tuningusb.cpp
> > @@ -28,6 +28,7 @@
> >  #include "unistd.h"
> >  #include "tuningusb.h"
> >  #include <string.h>
> > +#include <dirent.h>
> >  #include <utility>
> >  #include <iostream>
> >  #include <fstream>
> > @@ -117,6 +118,7 @@ static void add_usb_callback(const char *d_name)
> >  {
> >       class usb_tunable *usb;
> >       char filename[4096];
> > +     DIR *dir;
> >
> >       sprintf(filename, "/sys/bus/usb/devices/%s/power/control", d_name);
> >       if (access(filename, R_OK) != 0)
> > @@ -126,6 +128,23 @@ static void add_usb_callback(const char *d_name)
> >       if (access(filename, R_OK)!=0)
> >               return;
> >
> > +     /* every interface of this device should support autosuspend */
> > +     sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
> > +     if ((dir = opendir(filename))) {
> > +             struct dirent *entry;
> > +             while ((entry = readdir(dir))) {
> > +                     /* dirname: <busnum>-<devnum>...:<config
> num>-<interface num> */
> > +                     if (!isdigit(entry->d_name[0]))
> > +                             continue;
> > +                     sprintf(filename,
> "/sys/bus/usb/devices/%s/%s/supports_autosuspend",
> > d_name, entry->d_name);
> > +                     if (access(filename, R_OK) == 0 &&
> read_sysfs(filename) == 0)
> > +                             break;
> > +             }
> > +             closedir(dir);
> > +             if (entry)
> > +                     return;
> > +     }
> > +
> >       sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
> >       usb = new class usb_tunable(filename, d_name);
> >       all_tunables.push_back(usb);
> > --
> > 2.0.4
> >
> > _______________________________________________
> > PowerTop mailing list
> > PowerTop(a)lists.01.org
> > https://lists.01.org/mailman/listinfo/powertop
> >
>
> Nanley,
>
> Thank you very much for sending you patch. It was up-streamed today.
>
> Alexandra.
>

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 4068 bytes --]

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

end of thread, other threads:[~2014-09-30 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30  0:52 [Powertop] [PATCH v2 1/1] tunables: check usb autosuspend support before add Alexandra Yates
  -- strict thread matches above, loose matches on Subject: below --
2014-09-30 15:14 Nanley Chery
2014-08-25 19:45 Nanley Chery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.