From: Takashi Iwai <tiwai@suse.de>
To: Wang Xingchao <xingchao.wang@linux.intel.com>
Cc: alsa-devel@alsa-project.org, daniel@ffwll.ch,
jocelyn.li@intel.com, mengdong.lin@intel.com,
intel-gfx@lists.freedesktop.org, jesse.barnes@intel.com,
liam.r.girdwood@intel.com, david.henningsson@canonical.com,
paulo.r.zanoni@intel.com
Subject: Re: [PATCH 4/5] ALSA: hda - Fix module dependency with gfx i915
Date: Mon, 13 May 2013 14:34:54 +0200 [thread overview]
Message-ID: <s5h7gj3rrbl.wl%tiwai@suse.de> (raw)
In-Reply-To: <1368430648-2353-5-git-send-email-xingchao.wang@linux.intel.com>
At Mon, 13 May 2013 15:37:27 +0800,
Wang Xingchao wrote:
>
> hda_i915 has dependency on i915 module, this patch check whether
> symbol exist before calling API there. If i915 module not loaded it
> will try to load before use.
>
> Signed-off-by: Wang Xingchao <xingchao.wang@linux.intel.com>
You need to manage the symbols more properly. The symbols must be
unreferenced upon the driver unbind. Also, I'm not sure whether
module refcount of i915 is changed via symbol_get. If not, you need
to keep i915 referred until unbind, which calls the corresponding
module_put().
Yet another question is whether it's appropriate to call
request_module_nowait(). What's wrong with a synchronized one?
thanks,
Takashi
> ---
> sound/pci/hda/hda_i915.c | 42 ++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
> index 00def82..edf1a08 100644
> --- a/sound/pci/hda/hda_i915.c
> +++ b/sound/pci/hda/hda_i915.c
> @@ -22,16 +22,54 @@
> #include <drm/i915_powerwell.h>
> #include "hda_i915.h"
>
> +const char *name = "i915";
> +static void (*get_power)(const char *name);
> +static void (*put_power)(const char *name);
> +
> /* Power well has impact on Haswell controller and codecs */
> void hda_display_power(bool enable)
> {
> snd_printk(KERN_INFO "HDA display power %s \n", enable ? "Enable" : "Disable");
> +
> + if (!get_power || !put_power)
> + return;
> +
> if (enable)
> - i915_request_power_well("hda");
> + get_power("hda");
> else
> - i915_release_power_well("hda");
> + put_power("hda");
> }
> EXPORT_SYMBOL(hda_display_power);
>
> +static int __init hda_i915_init(void)
> +{
> + struct module *i915;
> + mutex_lock(&module_mutex);
> + i915 = find_module(name);
> + mutex_unlock(&module_mutex);
> +
> + if (!i915)
> + request_module_nowait(name);
> +
> + if (!try_module_get(i915))
> + return -EFAULT;
> +
> + get_power = symbol_get(i915_request_power_well);
> + put_power = symbol_get(i915_release_power_well);
> +
> + module_put(i915);
> + return 0;
> +}
> +
> +#if 0
> +static void __exit hda_i915_exit(void)
> +{
> + drm_pci_exit(&driver, &i915_pci_driver);
> +}
> +
> +module_init(hda_i915_init);
> +module_exit(hda_i915_exit);
> +#endif
> +module_init(hda_i915_init);
> MODULE_DESCRIPTION("HDA power well");
> MODULE_LICENSE("GPL");
> --
> 1.7.9.5
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
next prev parent reply other threads:[~2013-05-13 12:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 7:37 [PATCH 0/5] Power-well API implementation for Haswell Wang Xingchao
2013-05-13 7:37 ` [PATCH 1/5] drm/915: Add private api for power well usage Wang Xingchao
2013-05-13 12:29 ` Takashi Iwai
2013-05-13 7:37 ` [PATCH 2/5] ALSA: hda - Add external module hda-i915 for power well Wang Xingchao
2013-05-13 12:32 ` Takashi Iwai
2013-05-13 7:37 ` [PATCH 3/5] ALSA: hda - Power well request/release for hda controller Wang Xingchao
2013-05-13 7:37 ` [PATCH 4/5] ALSA: hda - Fix module dependency with gfx i915 Wang Xingchao
2013-05-13 12:34 ` Takashi Iwai [this message]
2013-05-13 7:37 ` [PATCH 5/5] ALSA/i915: Check power well API existense before calling Wang Xingchao
2013-05-13 8:28 ` David Henningsson
2013-05-13 8:55 ` Jaroslav Kysela
2013-05-13 8:59 ` [alsa-devel] " Takashi Iwai
2013-05-13 9:53 ` Jaroslav Kysela
2013-05-13 12:00 ` Wang, Xingchao
2013-05-13 11:55 ` [alsa-devel] " Wang, Xingchao
2013-05-13 12:13 ` David Henningsson
2013-05-13 13:50 ` Wang, Xingchao
2013-05-13 15:37 ` David Henningsson
2013-05-13 12:17 ` Takashi Iwai
2013-05-13 13:43 ` Wang, Xingchao
2013-05-13 12:38 ` [alsa-devel] " Takashi Iwai
2013-05-13 7:51 ` [alsa-devel] [PATCH 0/5] Power-well API implementation for Haswell Wang, Xingchao
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=s5h7gj3rrbl.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=daniel@ffwll.ch \
--cc=david.henningsson@canonical.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jesse.barnes@intel.com \
--cc=jocelyn.li@intel.com \
--cc=liam.r.girdwood@intel.com \
--cc=mengdong.lin@intel.com \
--cc=paulo.r.zanoni@intel.com \
--cc=xingchao.wang@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox