All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Tvrtko Ursulin <tursulin@ursulin.net>, igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
Date: Mon, 23 Jul 2018 13:54:48 +0100	[thread overview]
Message-ID: <153235048851.26238.17694902495417158505@skylake-alporthouse-com> (raw)
In-Reply-To: <20180723124649.13719-1-tvrtko.ursulin@linux.intel.com>

Quoting Tvrtko Ursulin (2018-07-23 13:46:49)
> @@ -130,36 +132,77 @@ static void strchomp(char *str)
>   */
>  void igt_pm_enable_audio_runtime_pm(void)
>  {
> +       char *path = NULL;
> +       struct dirent *de;
> +       DIR *dir;
>         int fd;
>  
>         /* Check if already enabled. */
>         if (__igt_pm_audio_runtime_power_save[0])
>                 return;
>  
> -       fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
> -                               sizeof(__igt_pm_audio_runtime_power_save)) > 0);
> -               strchomp(__igt_pm_audio_runtime_power_save);
> -               igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
> -               igt_assert_eq(write(fd, "1\n", 2), 2);
> -               close(fd);
> -       }
> -       fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_control,
> -                               sizeof(__igt_pm_audio_runtime_control)) > 0);
> -               strchomp(__igt_pm_audio_runtime_control);
> -               igt_assert_eq(write(fd, "auto\n", 5), 5);
> -               close(fd);
> +       dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
> +       if (!dir)
> +               return;
> +
> +       while ((de = readdir(dir))) {
> +               const char *prefix = "/sys/bus/pci/devices/";
> +               const char *suffix = "/power/control";
> +               const char *match = "0000:00:";
> +
> +               if (strncmp(de->d_name, match, strlen(match)))
> +                       continue;
> +
> +               path = malloc(strlen(prefix) +
> +                             strlen(de->d_name) +
> +                             strlen(suffix) +
> +                             1);
> +               if (!path)
> +                       goto err;
> +
> +               strcpy(path, prefix);
> +               strcat(path, de->d_name);
> +               strcat(path, suffix);

if (asprintf(&path, "/sys/bus/pci/devices/%s/power/control", de->d_name) < 0)
	goto err;
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Tvrtko Ursulin <tursulin@ursulin.net>, igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
Date: Mon, 23 Jul 2018 13:54:48 +0100	[thread overview]
Message-ID: <153235048851.26238.17694902495417158505@skylake-alporthouse-com> (raw)
In-Reply-To: <20180723124649.13719-1-tvrtko.ursulin@linux.intel.com>

Quoting Tvrtko Ursulin (2018-07-23 13:46:49)
> @@ -130,36 +132,77 @@ static void strchomp(char *str)
>   */
>  void igt_pm_enable_audio_runtime_pm(void)
>  {
> +       char *path = NULL;
> +       struct dirent *de;
> +       DIR *dir;
>         int fd;
>  
>         /* Check if already enabled. */
>         if (__igt_pm_audio_runtime_power_save[0])
>                 return;
>  
> -       fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
> -                               sizeof(__igt_pm_audio_runtime_power_save)) > 0);
> -               strchomp(__igt_pm_audio_runtime_power_save);
> -               igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
> -               igt_assert_eq(write(fd, "1\n", 2), 2);
> -               close(fd);
> -       }
> -       fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_control,
> -                               sizeof(__igt_pm_audio_runtime_control)) > 0);
> -               strchomp(__igt_pm_audio_runtime_control);
> -               igt_assert_eq(write(fd, "auto\n", 5), 5);
> -               close(fd);
> +       dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
> +       if (!dir)
> +               return;
> +
> +       while ((de = readdir(dir))) {
> +               const char *prefix = "/sys/bus/pci/devices/";
> +               const char *suffix = "/power/control";
> +               const char *match = "0000:00:";
> +
> +               if (strncmp(de->d_name, match, strlen(match)))
> +                       continue;
> +
> +               path = malloc(strlen(prefix) +
> +                             strlen(de->d_name) +
> +                             strlen(suffix) +
> +                             1);
> +               if (!path)
> +                       goto err;
> +
> +               strcpy(path, prefix);
> +               strcat(path, de->d_name);
> +               strcat(path, suffix);

if (asprintf(&path, "/sys/bus/pci/devices/%s/power/control", de->d_name) < 0)
	goto err;
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-07-23 12:54 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 11:46 [PATCH i-g-t 1/4] lib/igt_pm: Make exit handlers signal safe Tvrtko Ursulin
2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
2018-07-23 11:46 ` [PATCH i-g-t 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM Tvrtko Ursulin
2018-07-23 11:46   ` [Intel-gfx] " Tvrtko Ursulin
2018-07-23 12:46   ` [PATCH i-g-t v2 " Tvrtko Ursulin
2018-07-23 12:46     ` [Intel-gfx] " Tvrtko Ursulin
2018-07-23 12:54     ` Chris Wilson [this message]
2018-07-23 12:54       ` [Intel-gfx] [igt-dev] " Chris Wilson
2018-07-23 15:31       ` [PATCH i-g-t v3 " Tvrtko Ursulin
2018-07-23 15:31         ` [igt-dev] " Tvrtko Ursulin
2018-07-24  9:59         ` [PATCH i-g-t v4 " Tvrtko Ursulin
2018-07-24  9:59           ` [igt-dev] " Tvrtko Ursulin
2018-07-24 10:08           ` [PATCH i-g-t v5 " Tvrtko Ursulin
2018-07-24 10:08             ` [igt-dev] " Tvrtko Ursulin
2018-07-24 10:29             ` [PATCH i-g-t v6 " Tvrtko Ursulin
2018-07-24 10:29               ` [Intel-gfx] " Tvrtko Ursulin
2018-07-24 12:27               ` [igt-dev] " Chris Wilson
2018-07-24 12:27                 ` [Intel-gfx] " Chris Wilson
2018-07-23 11:46 ` [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status Tvrtko Ursulin
2018-07-23 11:46   ` [igt-dev] " Tvrtko Ursulin
2018-07-23 11:46 ` [PATCH i-g-t 4/4] tests/perf_pmu: Restore runtime PM status at rc6 test exit Tvrtko Ursulin
2018-07-23 11:46   ` [igt-dev] " Tvrtko Ursulin
2018-07-23 12:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe Patchwork
2018-07-23 13:12 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2) Patchwork
2018-07-23 13:58 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe Patchwork
2018-07-23 15:20 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2) Patchwork
2018-07-23 15:54 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3) Patchwork
2018-07-23 16:35   ` Tvrtko Ursulin
2018-07-24 10:34 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5) Patchwork
2018-07-24 10:50 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6) Patchwork
2018-07-24 11:27 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5) Patchwork
2018-07-24 12:07 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6) Patchwork
2018-07-26 17:08 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153235048851.26238.17694902495417158505@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.