/* * h1940-uda1380.c -- ALSA Soc Audio Layer * * Copyright (c) 2010 Arnaud Patard * Copyright (c) 2010 Vasily Khoruzhick * * Based on version from Arnaud Patard * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * */ #include #include #include #include #include #include "regs-iis.h" #include #include #include "s3c24xx-i2s.h" static const unsigned int rates[] = { 11025, 22050, 44100, }; static const struct snd_pcm_hw_constraint_list hw_rates = { .count = ARRAY_SIZE(rates), .list = rates, }; static struct snd_soc_jack hp_jack; static struct snd_soc_jack_pin hp_jack_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE, }, { .pin = "Speaker", .mask = SND_JACK_HEADPHONE, .invert = 1, }, }; static struct snd_soc_jack_gpio hp_jack_gpios[] = { { .gpio = S3C2410_GPG(4), .name = "hp-gpio", .report = SND_JACK_HEADPHONE, .invert = 1, .debounce_time = 200, }, }; static int h1940_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_rates); } static int h1940_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int div; int ret; unsigned int rate = params_rate(params); switch (rate) { case 11025: case 22050: case 44100: div = s3c24xx_i2s_get_clockrate() / (384 * rate); if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate)) div++; break; default: dev_err(rtd->dev, "%s: rate %d is not supported\n", __func__, rate); return -EINVAL; } /* select clock source */ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate, SND_SOC_CLOCK_OUT); if (ret < 0) return ret; /* set MCLK division for sample rate */ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK, S3C2410_IISMOD_384FS); if (ret < 0) return ret; /* set BCLK division for sample rate */ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK, S3C2410_IISMOD_32FS); if (ret < 0) return ret; /* set prescaler division for sample rate */ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER, S3C24XX_PRESCALE(div, div)); if (ret < 0) return ret; return 0; } static struct snd_soc_ops h1940_ops = { .startup = h1940_startup, .hw_params = h1940_hw_params, }; static int h1940_spk_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) gpio_set_value(S3C_GPIO_END + 9, 1); else gpio_set_value(S3C_GPIO_END + 9, 0); return 0; } /* h1940 machine dapm widgets */ static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_SPK("Speaker", h1940_spk_power), }; /* h1940 machine audio_map */ static const struct snd_soc_dapm_route audio_map[] = { /* headphone connected to VOUTLHP, VOUTRHP */ {"Headphone Jack", NULL, "VOUTLHP"}, {"Headphone Jack", NULL, "VOUTRHP"}, /* ext speaker connected to VOUTL, VOUTR */ {"Speaker", NULL, "VOUTL"}, {"Speaker", NULL, "VOUTR"}, /* mic is connected to VINM */ {"VINM", NULL, "Mic Jack"}, }; static struct platform_device *s3c24xx_snd_device; static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) { snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), hp_jack_gpios); return 0; } static int h1940_uda1380_card_remove(struct snd_soc_card *card) { snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), hp_jack_gpios); return 0; } /* s3c24xx digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link h1940_uda1380_dai[] = { { .name = "uda1380", .stream_name = "UDA1380 Duplex", .cpu_dai_name = "s3c24xx-iis", .codec_dai_name = "uda1380-hifi", .init = h1940_uda1380_init, .platform_name = "s3c24xx-iis", .codec_name = "uda1380-codec.0-001a", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &h1940_ops, }, }; static struct snd_soc_card h1940_asoc = { .name = "h1940", .owner = THIS_MODULE, .remove = h1940_uda1380_card_remove, .dai_link = h1940_uda1380_dai, .num_links = ARRAY_SIZE(h1940_uda1380_dai), .dapm_widgets = uda1380_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), }; static int __init h1940_init(void) { int ret; if (!machine_is_h1940()) return -ENODEV; /* configure some gpios */ ret = gpio_request(S3C_GPIO_END + 9, "speaker-power"); if (ret) goto err_out; ret = gpio_direction_output(S3C_GPIO_END + 9, 0); if (ret) goto err_gpio; s3c24xx_snd_device = platform_device_alloc("soc-audio", -1); if (!s3c24xx_snd_device) { ret = -ENOMEM; goto err_gpio; } platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc); ret = platform_device_add(s3c24xx_snd_device); if (ret) goto err_plat; return 0; err_plat: platform_device_put(s3c24xx_snd_device); err_gpio: gpio_free(S3C_GPIO_END + 9); err_out: return ret; } static void __exit h1940_exit(void) { platform_device_unregister(s3c24xx_snd_device); gpio_free(S3C_GPIO_END + 9); } module_init(h1940_init); module_exit(h1940_exit); /* Module information */ MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick"); MODULE_DESCRIPTION("ALSA SoC H1940"); MODULE_LICENSE("GPL"); ighand->siglock)->rlock){-.....}, at: [<ffffffffbd0a1bc6>] __lock_task_sighand+0xb6/0x2c0 but this lock took another, HARDIRQ-unsafe lock in the past: (ucounts_lock){+.+...} and interrupts could create inverse lock ordering between them. other info that might help us debug this: Chain exists of: &(&sighand->siglock)->rlock --> &(&tty->ctrl_lock)->rlock --> ucounts_lock Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(ucounts_lock); local_irq_disable(); lock(&(&sighand->siglock)->rlock); lock(&(&tty->ctrl_lock)->rlock); <Interrupt> lock(&(&sighand->siglock)->rlock); *** DEADLOCK *** This patch removes a dependency between rlock and ucount_lock. Fixes: f333c700c610 ("pidns: Add a limit on the number of pid namespaces") Cc: stable@vger.kernel.org Signed-off-by: Andrei Vagin <avagin@openvz.org> Acked-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'include/target')
to bit #7, we can atomically clear the lock bit and test the waiters bit on x86 too. And architectures with LL/SC (which is all the usual RISC suspects), the particular bit doesn't matter, so they are fine with this approach too. This avoids the extra access to the same atomic word, and thus avoids the costly stall at page unlock time. The only downside is that the interface ends up being a bit odd and specialized: clear a bit in a byte, and test the sign bit. Nick doesn't love the resulting name of the new primitive, but I'd rather make the name be descriptive and very clear about the limitation imposed by trying to work across all relevant architectures than make it be some generic thing that doesn't make the odd semantics explicit. So this introduces the new architecture primitive clear_bit_unlock_is_negative_byte(); and adds the trivial implementation for x86. We have a generic non-optimized fallback (that just does a "clear_bit()"+"test_bit(7)" combination) which can be overridden by any architecture that can do better. According to Nick, Power has the same hickup x86 has, for example, but some other architectures may not even care. All these optimizations mean that my page locking stress-test (which is just executing a lot of small short-lived shell scripts: "make test" in the git source tree) no longer makes our page locking look horribly bad. Before all these optimizations, just the unlock_page() costs were just over 3% of all CPU overhead on "make test". After this, it's down to 0.66%, so just a quarter of the cost it used to be. (The difference on NUMA is bigger, but there this micro-optimization is likely less noticeable, since the big issue on NUMA was not the accesses to 'struct page', but the waitqueue accesses that were already removed by Nick's earlier commit). Acked-by: Nick Piggin <npiggin@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Bob Peterson <rpeterso@redhat.com> Cc: Steven Whitehouse <swhiteho@redhat.com> Cc: Andrew Lutomirski <luto@kernel.org> Cc: Andreas Gruenbacher <agruenba@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mel Gorman <mgorman@techsingularity.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/core/usb.h')