Merge tag 'sound-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"A series of small fixes in ASoC, HD-audio and core stuff:

- a UAF fix in ALSA PCM core

- yet more hardening for ALSA sequencer

- a regression fix for the previous HD-audio power_save option change

- various ASoC codec fixes (sgtl5000, rt5651, hdmi-codec, wm_adsp)

- minor ASoC platform fixes (AMD ACP, sun4i)"

* tag 'sound-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda - Revert power_save option default value
ALSA: pcm: Fix UAF in snd_pcm_oss_get_formats()
ALSA: seq: Clear client entry before deleting else at closing
ALSA: seq: Fix possible UAF in snd_seq_check_queue()
ASoC: amd: 16bit resolution support for i2s sp instance
ASoC: wm_adsp: For TLV controls only register TLV get/set
ASoC: sun4i-i2s: Fix RX slot number of SUN8I
ASoC: hdmi-codec: Fix module unloading caused kernel crash
ASoC: rt5651: Fix regcache sync errors on resume
ASoC: sgtl5000: Fix suspend/resume
MAINTAINERS: Add myself as sgtl5000 maintainer
ASoC: samsung: Add the DT binding files entry to MAINTAINERS
sgtl5000: change digital_mute policy

+92 -69
+8
MAINTAINERS
··· 9925 9925 F: include/linux/nvmem-consumer.h 9926 9926 F: include/linux/nvmem-provider.h 9927 9927 9928 + NXP SGTL5000 DRIVER 9929 + M: Fabio Estevam <fabio.estevam@nxp.com> 9930 + L: alsa-devel@alsa-project.org (moderated for non-subscribers) 9931 + S: Maintained 9932 + F: Documentation/devicetree/bindings/sound/sgtl5000.txt 9933 + F: sound/soc/codecs/sgtl5000* 9934 + 9928 9935 NXP TDA998X DRM DRIVER 9929 9936 M: Russell King <linux@armlinux.org.uk> 9930 9937 S: Supported ··· 12114 12107 L: alsa-devel@alsa-project.org (moderated for non-subscribers) 12115 12108 S: Supported 12116 12109 F: sound/soc/samsung/ 12110 + F: Documentation/devicetree/bindings/sound/samsung* 12117 12111 12118 12112 SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER 12119 12113 M: Krzysztof Kozlowski <krzk@kernel.org>
+6 -4
sound/core/oss/pcm_oss.c
··· 1762 1762 return -ENOMEM; 1763 1763 _snd_pcm_hw_params_any(params); 1764 1764 err = snd_pcm_hw_refine(substream, params); 1765 - format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT); 1766 - kfree(params); 1767 1765 if (err < 0) 1768 - return err; 1766 + goto error; 1767 + format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT); 1769 1768 for (fmt = 0; fmt < 32; ++fmt) { 1770 1769 if (snd_mask_test(format_mask, fmt)) { 1771 1770 int f = snd_pcm_oss_format_to(fmt); ··· 1772 1773 formats |= f; 1773 1774 } 1774 1775 } 1775 - return formats; 1776 + 1777 + error: 1778 + kfree(params); 1779 + return err < 0 ? err : formats; 1776 1780 } 1777 1781 1778 1782 static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format)
+2 -2
sound/core/seq/seq_clientmgr.c
··· 255 255 256 256 if (!client) 257 257 return 0; 258 - snd_seq_delete_all_ports(client); 259 - snd_seq_queue_client_leave(client->number); 260 258 spin_lock_irqsave(&clients_lock, flags); 261 259 clienttablock[client->number] = 1; 262 260 clienttab[client->number] = NULL; 263 261 spin_unlock_irqrestore(&clients_lock, flags); 262 + snd_seq_delete_all_ports(client); 263 + snd_seq_queue_client_leave(client->number); 264 264 snd_use_lock_sync(&client->use_lock); 265 265 snd_seq_queue_client_termination(client->number); 266 266 if (client->pool)
+14 -14
sound/core/seq/seq_prioq.c
··· 87 87 if (f->cells > 0) { 88 88 /* drain prioQ */ 89 89 while (f->cells > 0) 90 - snd_seq_cell_free(snd_seq_prioq_cell_out(f)); 90 + snd_seq_cell_free(snd_seq_prioq_cell_out(f, NULL)); 91 91 } 92 92 93 93 kfree(f); ··· 214 214 return 0; 215 215 } 216 216 217 + /* return 1 if the current time >= event timestamp */ 218 + static int event_is_ready(struct snd_seq_event *ev, void *current_time) 219 + { 220 + if ((ev->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK) 221 + return snd_seq_compare_tick_time(current_time, &ev->time.tick); 222 + else 223 + return snd_seq_compare_real_time(current_time, &ev->time.time); 224 + } 225 + 217 226 /* dequeue cell from prioq */ 218 - struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f) 227 + struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f, 228 + void *current_time) 219 229 { 220 230 struct snd_seq_event_cell *cell; 221 231 unsigned long flags; ··· 237 227 spin_lock_irqsave(&f->lock, flags); 238 228 239 229 cell = f->head; 230 + if (cell && current_time && !event_is_ready(&cell->event, current_time)) 231 + cell = NULL; 240 232 if (cell) { 241 233 f->head = cell->next; 242 234 ··· 263 251 } 264 252 return f->cells; 265 253 } 266 - 267 - 268 - /* peek at cell at the head of the prioq */ 269 - struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq * f) 270 - { 271 - if (f == NULL) { 272 - pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n"); 273 - return NULL; 274 - } 275 - return f->head; 276 - } 277 - 278 254 279 255 static inline int prioq_match(struct snd_seq_event_cell *cell, 280 256 int client, int timestamp)
+2 -4
sound/core/seq/seq_prioq.h
··· 44 44 int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell); 45 45 46 46 /* dequeue cell from prioq */ 47 - struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f); 47 + struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f, 48 + void *current_time); 48 49 49 50 /* return number of events available in prioq */ 50 51 int snd_seq_prioq_avail(struct snd_seq_prioq *f); 51 - 52 - /* peek at cell at the head of the prioq */ 53 - struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq *f); 54 52 55 53 /* client left queue */ 56 54 void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp);
+9 -19
sound/core/seq/seq_queue.c
··· 277 277 278 278 __again: 279 279 /* Process tick queue... */ 280 - while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) { 281 - if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, 282 - &cell->event.time.tick)) { 283 - cell = snd_seq_prioq_cell_out(q->tickq); 284 - if (cell) 285 - snd_seq_dispatch_event(cell, atomic, hop); 286 - } else { 287 - /* event remains in the queue */ 280 + for (;;) { 281 + cell = snd_seq_prioq_cell_out(q->tickq, 282 + &q->timer->tick.cur_tick); 283 + if (!cell) 288 284 break; 289 - } 285 + snd_seq_dispatch_event(cell, atomic, hop); 290 286 } 291 287 292 - 293 288 /* Process time queue... */ 294 - while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) { 295 - if (snd_seq_compare_real_time(&q->timer->cur_time, 296 - &cell->event.time.time)) { 297 - cell = snd_seq_prioq_cell_out(q->timeq); 298 - if (cell) 299 - snd_seq_dispatch_event(cell, atomic, hop); 300 - } else { 301 - /* event remains in the queue */ 289 + for (;;) { 290 + cell = snd_seq_prioq_cell_out(q->timeq, &q->timer->cur_time); 291 + if (!cell) 302 292 break; 303 - } 293 + snd_seq_dispatch_event(cell, atomic, hop); 304 294 } 305 295 306 296 /* free lock */
+6 -3
sound/pci/hda/hda_intel.c
··· 181 181 }; 182 182 #define param_check_xint param_check_int 183 183 184 - static int power_save = -1; 184 + static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; 185 185 module_param(power_save, xint, 0644); 186 186 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " 187 187 "(in second, 0 = disable)."); 188 + 189 + static bool pm_blacklist = true; 190 + module_param(pm_blacklist, bool, 0644); 191 + MODULE_PARM_DESC(pm_blacklist, "Enable power-management blacklist"); 188 192 189 193 /* reset the HD-audio controller in power save mode. 190 194 * this may give more power-saving, but will take longer time to ··· 2304 2300 2305 2301 val = power_save; 2306 2302 #ifdef CONFIG_PM 2307 - if (val == -1) { 2303 + if (pm_blacklist) { 2308 2304 const struct snd_pci_quirk *q; 2309 2305 2310 - val = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; 2311 2306 q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist); 2312 2307 if (q && val) { 2313 2308 dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n",
+9 -7
sound/soc/amd/acp-pcm-dma.c
··· 579 579 for (bank = 1; bank < 48; bank++) 580 580 acp_set_sram_bank_state(acp_mmio, bank, false); 581 581 } 582 - 583 - /* Stoney supports 16bit resolution */ 584 - if (asic_type == CHIP_STONEY) { 585 - val = acp_reg_read(acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN); 586 - val |= 0x03; 587 - acp_reg_write(val, acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN); 588 - } 589 582 return 0; 590 583 } 591 584 ··· 767 774 { 768 775 int status; 769 776 uint64_t size; 777 + u32 val = 0; 770 778 struct page *pg; 771 779 struct snd_pcm_runtime *runtime; 772 780 struct audio_substream_data *rtd; ··· 780 786 if (WARN_ON(!rtd)) 781 787 return -EINVAL; 782 788 789 + if (adata->asic_type == CHIP_STONEY) { 790 + val = acp_reg_read(adata->acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN); 791 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 792 + val |= ACP_I2S_SP_16BIT_RESOLUTION_EN; 793 + else 794 + val |= ACP_I2S_MIC_16BIT_RESOLUTION_EN; 795 + acp_reg_write(val, adata->acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN); 796 + } 783 797 size = params_buffer_bytes(params); 784 798 status = snd_pcm_lib_malloc_pages(substream, size); 785 799 if (status < 0)
+2
sound/soc/amd/acp.h
··· 70 70 #define CAPTURE_END_DMA_DESCR_CH15 7 71 71 72 72 #define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209 73 + #define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01 74 + #define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02 73 75 enum acp_dma_priority_level { 74 76 /* 0x0 Specifies the DMA channel is given normal priority */ 75 77 ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
+1 -6
sound/soc/codecs/hdmi-codec.c
··· 798 798 799 799 static int hdmi_codec_remove(struct platform_device *pdev) 800 800 { 801 - struct device *dev = &pdev->dev; 802 - struct hdmi_codec_priv *hcp; 803 - 804 - hcp = dev_get_drvdata(dev); 805 - kfree(hcp->chmap_info); 806 - snd_soc_unregister_codec(dev); 801 + snd_soc_unregister_codec(&pdev->dev); 807 802 808 803 return 0; 809 804 }
+1
sound/soc/codecs/rt5651.c
··· 1722 1722 .num_reg_defaults = ARRAY_SIZE(rt5651_reg), 1723 1723 .ranges = rt5651_ranges, 1724 1724 .num_ranges = ARRAY_SIZE(rt5651_ranges), 1725 + .use_single_rw = true, 1725 1726 }; 1726 1727 1727 1728 #if defined(CONFIG_OF)
+23 -3
sound/soc/codecs/sgtl5000.c
··· 529 529 static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) 530 530 { 531 531 struct snd_soc_codec *codec = codec_dai->codec; 532 - u16 adcdac_ctrl = SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT; 532 + u16 i2s_pwr = SGTL5000_I2S_IN_POWERUP; 533 533 534 - snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL, 535 - adcdac_ctrl, mute ? adcdac_ctrl : 0); 534 + /* 535 + * During 'digital mute' do not mute DAC 536 + * because LINE_IN would be muted aswell. We want to mute 537 + * only I2S block - this can be done by powering it off 538 + */ 539 + snd_soc_update_bits(codec, SGTL5000_CHIP_DIG_POWER, 540 + i2s_pwr, mute ? 0 : i2s_pwr); 536 541 537 542 return 0; 538 543 } ··· 876 871 static int sgtl5000_set_bias_level(struct snd_soc_codec *codec, 877 872 enum snd_soc_bias_level level) 878 873 { 874 + struct sgtl5000_priv *sgtl = snd_soc_codec_get_drvdata(codec); 875 + int ret; 876 + 879 877 switch (level) { 880 878 case SND_SOC_BIAS_ON: 881 879 case SND_SOC_BIAS_PREPARE: 882 880 case SND_SOC_BIAS_STANDBY: 881 + regcache_cache_only(sgtl->regmap, false); 882 + ret = regcache_sync(sgtl->regmap); 883 + if (ret) { 884 + regcache_cache_only(sgtl->regmap, true); 885 + return ret; 886 + } 887 + 883 888 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, 884 889 SGTL5000_REFTOP_POWERUP, 885 890 SGTL5000_REFTOP_POWERUP); 886 891 break; 887 892 case SND_SOC_BIAS_OFF: 893 + regcache_cache_only(sgtl->regmap, true); 888 894 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, 889 895 SGTL5000_REFTOP_POWERUP, 0); 890 896 break; ··· 1252 1236 * Enable DAP in kcontrol and dapm. 1253 1237 */ 1254 1238 snd_soc_write(codec, SGTL5000_DAP_CTRL, 0); 1239 + 1240 + /* Unmute DAC after start */ 1241 + snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL, 1242 + SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT, 0); 1255 1243 1256 1244 return 0; 1257 1245
+8 -6
sound/soc/codecs/wm_adsp.c
··· 1204 1204 kcontrol->put = wm_coeff_put_acked; 1205 1205 break; 1206 1206 default: 1207 - kcontrol->get = wm_coeff_get; 1208 - kcontrol->put = wm_coeff_put; 1209 - 1210 - ctl->bytes_ext.max = ctl->len; 1211 - ctl->bytes_ext.get = wm_coeff_tlv_get; 1212 - ctl->bytes_ext.put = wm_coeff_tlv_put; 1207 + if (kcontrol->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { 1208 + ctl->bytes_ext.max = ctl->len; 1209 + ctl->bytes_ext.get = wm_coeff_tlv_get; 1210 + ctl->bytes_ext.put = wm_coeff_tlv_put; 1211 + } else { 1212 + kcontrol->get = wm_coeff_get; 1213 + kcontrol->put = wm_coeff_put; 1214 + } 1213 1215 break; 1214 1216 } 1215 1217
+1 -1
sound/soc/sunxi/sun4i-i2s.c
··· 104 104 105 105 #define SUN8I_I2S_CHAN_CFG_REG 0x30 106 106 #define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK GENMASK(6, 4) 107 - #define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan) (chan - 1) 107 + #define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan) ((chan - 1) << 4) 108 108 #define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK GENMASK(2, 0) 109 109 #define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(chan) (chan - 1) 110 110