From 29e58d18a5028ee75605f2b68c6d13ad93a97cb3 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Thu, 4 Jun 2020 15:23:27 +0530 Subject: asoc: add new path for in call recording Add path for routing in call uplink and downlink to MultiMedia9. Change-Id: Ide7daf112f2aaa0eb0a987d80c491e85db61fae5 Signed-off-by: Soumya Managoli --- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c index d0fdf190d63d..a5c02b2dc1a3 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c @@ -18463,9 +18463,11 @@ static const struct snd_soc_dapm_route intercon[] = { {"MultiMedia1 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia4 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia8 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, + {"MultiMedia9 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia1 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia4 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia8 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, + {"MultiMedia9 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia1 Mixer", "SLIM_4_TX", "SLIMBUS_4_TX"}, {"MultiMedia1 Mixer", "SLIM_6_TX", "SLIMBUS_6_TX"}, {"MultiMedia1 Mixer", "SLIM_7_TX", "SLIMBUS_7_TX"}, -- cgit v1.2.3 From 3ba217f1e4b5569d4adf683f6eab3c047476a9c2 Mon Sep 17 00:00:00 2001 From: Rohan Sethi Date: Thu, 30 Jul 2020 16:26:57 +0530 Subject: msm: kgsl: Fix possible use-after-free while adding context to active list Consider a scenario where a context is valid when the check is made in adreno_dispatcher_queue_cmds(), but by the time we reach _track_context(), context has been detached. We would try to delete the entry from the active context list as part of detaching the context though the entry is not added yet. Now in _track_context() the context is actually added. When the context is finally destroyed, we would be left with invalid entry in the list. Next time when a context is added, an attempt would be made to use a freed entry. Fix this by moving the entry deletion part under drawctxt lock. Change-Id: Idab7cbf10987598b3e6395b2d50c20d1990d1f02 Signed-off-by: Puranam V G Tejaswi Signed-off-by: Rohan Sethi --- drivers/gpu/msm/adreno_drawctxt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/msm/adreno_drawctxt.c b/drivers/gpu/msm/adreno_drawctxt.c index 3e765a61bd5e..446df0e98217 100644 --- a/drivers/gpu/msm/adreno_drawctxt.c +++ b/drivers/gpu/msm/adreno_drawctxt.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002,2007-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2002,2007-2017,2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -473,11 +473,12 @@ void adreno_drawctxt_detach(struct kgsl_context *context) drawctxt = ADRENO_CONTEXT(context); rb = drawctxt->rb; + spin_lock(&drawctxt->lock); + spin_lock(&adreno_dev->active_list_lock); list_del_init(&drawctxt->active_node); spin_unlock(&adreno_dev->active_list_lock); - spin_lock(&drawctxt->lock); count = drawctxt_detach_drawobjs(drawctxt, list); spin_unlock(&drawctxt->lock); -- cgit v1.2.3 From a6e4cb81280abe3515ad9ed442ae96fd580688d2 Mon Sep 17 00:00:00 2001 From: Akhil P Oommen Date: Thu, 16 Jul 2020 00:49:09 +0530 Subject: msm: kgsl: Mark the scratch buffer as privileged Mark the scratch buffer as privileged so that it can only be accessed by GPU through the ringbuffer. To accomplish this, we need to: 1. Disable the shadow rptr feature. 2. Trigger RPTR update from GPU using a WHERE_AM_I packet. 3. Add support for the new ucode. Change-Id: I9b388f55f53b69028b9bbb2306cb43fd1297c52f Signed-off-by: Akhil P Oommen Signed-off-by: Pranav Patel --- drivers/gpu/msm/adreno.c | 15 +++++++++++- drivers/gpu/msm/adreno.h | 4 +++- drivers/gpu/msm/adreno_a5xx.c | 15 +++++++----- drivers/gpu/msm/adreno_a5xx.h | 4 ++-- drivers/gpu/msm/adreno_pm4types.h | 4 +++- drivers/gpu/msm/adreno_ringbuffer.c | 46 ++++++++++++++++++++++++++++++++++--- drivers/gpu/msm/adreno_ringbuffer.h | 5 +++- 7 files changed, 78 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index 000274c5146a..6df074cd2876 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002,2007-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2827,6 +2827,19 @@ static void adreno_resume_device(struct kgsl_device *device) adreno_dispatcher_unhalt(device); } +u32 adreno_get_ucode_version(const u32 *data) +{ + u32 version; + + version = data[1]; + + if ((version & 0xf) != 0xa) + return version; + + version &= ~0xfff; + return version | ((data[3] & 0xfff000) >> 12); +} + static const struct kgsl_functable adreno_functable = { /* Mandatory functions */ .regread = adreno_regread, diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index 1f598bf3d9f8..5434cfb4083b 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2008-2018,2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -942,6 +942,8 @@ int adreno_efuse_read_u32(struct adreno_device *adreno_dev, unsigned int offset, unsigned int *val); void adreno_efuse_unmap(struct adreno_device *adreno_dev); +u32 adreno_get_ucode_version(const u32 *data); + #define ADRENO_TARGET(_name, _id) \ static inline int adreno_is_##_name(struct adreno_device *adreno_dev) \ { \ diff --git a/drivers/gpu/msm/adreno_a5xx.c b/drivers/gpu/msm/adreno_a5xx.c index 2514d13b4cdc..c206bdac7d39 100644 --- a/drivers/gpu/msm/adreno_a5xx.c +++ b/drivers/gpu/msm/adreno_a5xx.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2018,2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2177,12 +2177,15 @@ static int a5xx_post_start(struct adreno_device *adreno_dev) *cmds++ = 0xF; } - if (adreno_is_preemption_enabled(adreno_dev)) + if (adreno_is_preemption_enabled(adreno_dev)) { cmds += _preemption_init(adreno_dev, rb, cmds, NULL); + rb->_wptr = rb->_wptr - (42 - (cmds - start)); + ret = adreno_ringbuffer_submit_spin_nosync(rb, NULL, 2000); + } else { + rb->_wptr = rb->_wptr - (42 - (cmds - start)); + ret = adreno_ringbuffer_submit_spin(rb, NULL, 2000); + } - rb->_wptr = rb->_wptr - (42 - (cmds - start)); - - ret = adreno_ringbuffer_submit_spin(rb, NULL, 2000); if (ret) spin_idle_debug(KGSL_DEVICE(adreno_dev), "hw initialization failed to idle\n"); @@ -2554,7 +2557,7 @@ static int _load_firmware(struct kgsl_device *device, const char *fwfile, memcpy(ucode->hostptr, &fw->data[4], fw->size - 4); *ucode_size = (fw->size - 4) / sizeof(uint32_t); - *ucode_version = *(unsigned int *)&fw->data[4]; + *ucode_version = adreno_get_ucode_version((u32 *)fw->data); done: release_firmware(fw); diff --git a/drivers/gpu/msm/adreno_a5xx.h b/drivers/gpu/msm/adreno_a5xx.h index 08fd16a83f30..8cfd297fa86d 100644 --- a/drivers/gpu/msm/adreno_a5xx.h +++ b/drivers/gpu/msm/adreno_a5xx.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2016,2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -112,7 +112,7 @@ void a5xx_crashdump_init(struct adreno_device *adreno_dev); void a5xx_hwcg_set(struct adreno_device *adreno_dev, bool on); -#define A5XX_CP_RB_CNTL_DEFAULT (((ilog2(4) << 8) & 0x1F00) | \ +#define A5XX_CP_RB_CNTL_DEFAULT ((1 << 27) | ((ilog2(4) << 8) & 0x1F00) | \ (ilog2(KGSL_RB_DWORDS >> 1) & 0x3F)) /* GPMU interrupt multiplexor */ #define FW_INTR_INFO (0) diff --git a/drivers/gpu/msm/adreno_pm4types.h b/drivers/gpu/msm/adreno_pm4types.h index ec2c29b929c1..fdd12f571b2e 100644 --- a/drivers/gpu/msm/adreno_pm4types.h +++ b/drivers/gpu/msm/adreno_pm4types.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2002,2007-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2002,2007-2016,2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -97,6 +97,8 @@ /* A5XX Enable yield in RB only */ #define CP_YIELD_ENABLE 0x1C +#define CP_WHERE_AM_I 0x62 + /* Enable/Disable/Defer A5x global preemption model */ #define CP_PREEMPT_ENABLE_GLOBAL 0x69 diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c index 3a3777823013..475e5e60163d 100644 --- a/drivers/gpu/msm/adreno_ringbuffer.c +++ b/drivers/gpu/msm/adreno_ringbuffer.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002,2007-2017,2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2002,2007-2017,2019-2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -138,7 +138,7 @@ void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb, adreno_ringbuffer_wptr(adreno_dev, rb); } -int adreno_ringbuffer_submit_spin(struct adreno_ringbuffer *rb, +int adreno_ringbuffer_submit_spin_nosync(struct adreno_ringbuffer *rb, struct adreno_submit_time *time, unsigned int timeout) { struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb); @@ -147,6 +147,38 @@ int adreno_ringbuffer_submit_spin(struct adreno_ringbuffer *rb, return adreno_spin_idle(adreno_dev, timeout); } +/* + * adreno_ringbuffer_submit_spin() - Submit the cmds and wait until GPU is idle + * @rb: Pointer to ringbuffer + * @time: Pointer to adreno_submit_time + * @timeout: timeout value in ms + * + * Add commands to the ringbuffer and wait until GPU goes to idle. This routine + * inserts a WHERE_AM_I packet to trigger a shadow rptr update. So, use + * adreno_ringbuffer_submit_spin_nosync() if the previous cmd in the RB is a + * CSY packet because CSY followed by WHERE_AM_I is not legal.. + */ +int adreno_ringbuffer_submit_spin(struct adreno_ringbuffer *rb, + struct adreno_submit_time *time, unsigned int timeout) +{ + struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb); + struct kgsl_device *device = KGSL_DEVICE(adreno_dev); + unsigned int *cmds; + + if (adreno_is_a3xx(adreno_dev)) + return adreno_ringbuffer_submit_spin_nosync(rb, time, timeout); + + cmds = adreno_ringbuffer_allocspace(rb, 3); + if (IS_ERR(cmds)) + return PTR_ERR(cmds); + + *cmds++ = cp_packet(adreno_dev, CP_WHERE_AM_I, 2); + cmds += cp_gpuaddr(adreno_dev, cmds, + SCRATCH_RPTR_GPU_ADDR(device, rb->id)); + + return adreno_ringbuffer_submit_spin_nosync(rb, time, timeout); +} + unsigned int *adreno_ringbuffer_allocspace(struct adreno_ringbuffer *rb, unsigned int dwords) { @@ -273,11 +305,12 @@ int adreno_ringbuffer_probe(struct adreno_device *adreno_dev, bool nopreempt) { struct kgsl_device *device = KGSL_DEVICE(adreno_dev); struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); + unsigned int priv = KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED; int i, status; if (!adreno_is_a3xx(adreno_dev)) { status = kgsl_allocate_global(device, &device->scratch, - PAGE_SIZE, 0, KGSL_MEMDESC_RANDOM, "scratch"); + PAGE_SIZE, 0, priv, "scratch"); if (status != 0) return status; } @@ -480,6 +513,8 @@ adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb, if (gpudev->preemption_post_ibsubmit && adreno_is_preemption_enabled(adreno_dev)) total_sizedwords += 5; + else if (!adreno_is_a3xx(adreno_dev)) + total_sizedwords += 3; /* * a5xx uses 64 bit memory address. pm4 commands that involve read/write @@ -670,6 +705,11 @@ adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb, adreno_is_preemption_enabled(adreno_dev)) ringcmds += gpudev->preemption_post_ibsubmit(adreno_dev, ringcmds); + else if (!adreno_is_a3xx(adreno_dev)) { + *ringcmds++ = cp_packet(adreno_dev, CP_WHERE_AM_I, 2); + ringcmds += cp_gpuaddr(adreno_dev, ringcmds, + SCRATCH_RPTR_GPU_ADDR(device, rb->id)); + } /* * If we have more ringbuffer commands than space reserved diff --git a/drivers/gpu/msm/adreno_ringbuffer.h b/drivers/gpu/msm/adreno_ringbuffer.h index d64ccbdc846c..a2bf92acf4af 100644 --- a/drivers/gpu/msm/adreno_ringbuffer.h +++ b/drivers/gpu/msm/adreno_ringbuffer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2002,2007-2016,2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2002,2007-2016,2019-2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -172,6 +172,9 @@ int adreno_ringbuffer_issuecmds(struct adreno_ringbuffer *rb, void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb, struct adreno_submit_time *time); +int adreno_ringbuffer_submit_spin_nosync(struct adreno_ringbuffer *rb, + struct adreno_submit_time *time, unsigned int timeout); + int adreno_ringbuffer_submit_spin(struct adreno_ringbuffer *rb, struct adreno_submit_time *time, unsigned int timeout); -- cgit v1.2.3 From cbc3abdd7f327200e94ff66bd4b4dad6a2123f3b Mon Sep 17 00:00:00 2001 From: Neeraja P Date: Wed, 19 Aug 2020 11:40:43 +0530 Subject: msm: kgsl: Correctly clean up dma buffer attachment in case of error In kgsl_ioctl_gpuobj_import(), user memory of type KGSL_USER_MEM_TYPE_ADDR can also lead to setting up a dma buffer. When attaching mem entry to process fails, dma buffer attachment is cleaned up only in case of KGSL_USER_MEM_TYPE_DMABUF. Similar situation can arise in case of kgsl_ioctl_map_user_mem(). Fix this by obtaining user memory type from the memdesc flags. Change-Id: I502bd0ae19241802e8f835f20391b2ce67999418 Signed-off-by: Puranam V G Tejaswi Signed-off-by: Neeraja P --- drivers/gpu/msm/kgsl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 90d9bd2339eb..44522cac7c42 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2008-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2486,7 +2486,7 @@ long kgsl_ioctl_gpuobj_import(struct kgsl_device_private *dev_priv, return 0; unmap: - if (param->type == KGSL_USER_MEM_TYPE_DMABUF) { + if (kgsl_memdesc_usermem_type(&entry->memdesc) == KGSL_MEM_ENTRY_ION) { kgsl_destroy_ion(entry->priv_data); entry->memdesc.sgt = NULL; } @@ -2795,7 +2795,7 @@ long kgsl_ioctl_map_user_mem(struct kgsl_device_private *dev_priv, return result; error_attach: - switch (memtype) { + switch (kgsl_memdesc_usermem_type(&entry->memdesc)) { case KGSL_MEM_ENTRY_ION: kgsl_destroy_ion(entry->priv_data); entry->memdesc.sgt = NULL; -- cgit v1.2.3 From cbc3c21971dfb3b5322e080df458ad9d2d477633 Mon Sep 17 00:00:00 2001 From: Indira Biruduraju Date: Tue, 11 Aug 2020 15:24:16 +0530 Subject: msm: kgsl: Remove VM_MAYWRITE flag to restrict mprotect When VM_MAYWRITE flag is used during mmap(), mprotect() can be used later to change the protection of memstore to allow write. Make sure this does not happen by removing VM_MAYWRITE from the vm_flags of vma. Change-Id: I6f69f05858ea40611d512cfa796caabeaa88cdb5 Signed-off-by: Indira Biruduraju --- drivers/gpu/msm/kgsl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 44522cac7c42..1e30cd9e3524 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -4202,6 +4202,8 @@ kgsl_mmap_memstore(struct kgsl_device *device, struct vm_area_struct *vma) if (vma->vm_flags & VM_WRITE) return -EPERM; + vma->vm_flags &= ~VM_MAYWRITE; + if (memdesc->size != vma_size) { KGSL_MEM_ERR(device, "memstore bad size: %d should be %llu\n", vma_size, memdesc->size); -- cgit v1.2.3 From 2ed5910704a5b4601e0eb0701889a9944554ae84 Mon Sep 17 00:00:00 2001 From: gkiranku Date: Wed, 29 Jul 2020 18:28:57 +0530 Subject: msm: kgsl: skip if requested address doesn't fall in the svm range User should not be provided address out of SVM region. Return error for any such requests from user. Change-Id: If149044039b156f8192f405714f5c1a0571004e7 Signed-off-by: gkiranku Signed-off-by: Sebanti Das --- drivers/gpu/msm/kgsl_iommu.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c index ffab5423d694..f6ff4658c93b 100644 --- a/drivers/gpu/msm/kgsl_iommu.c +++ b/drivers/gpu/msm/kgsl_iommu.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2389,6 +2389,22 @@ static uint64_t kgsl_iommu_find_svm_region(struct kgsl_pagetable *pagetable, return addr; } +static bool iommu_addr_in_svm_ranges(struct kgsl_iommu_pt *pt, + u64 gpuaddr, u64 size) +{ + if ((gpuaddr >= pt->compat_va_start && gpuaddr < pt->compat_va_end) && + ((gpuaddr + size) > pt->compat_va_start && + (gpuaddr + size) <= pt->compat_va_end)) + return true; + + if ((gpuaddr >= pt->svm_start && gpuaddr < pt->svm_end) && + ((gpuaddr + size) > pt->svm_start && + (gpuaddr + size) <= pt->svm_end)) + return true; + + return false; +} + static int kgsl_iommu_set_svm_region(struct kgsl_pagetable *pagetable, uint64_t gpuaddr, uint64_t size) { @@ -2396,9 +2412,8 @@ static int kgsl_iommu_set_svm_region(struct kgsl_pagetable *pagetable, struct kgsl_iommu_pt *pt = pagetable->priv; struct rb_node *node; - /* Make sure the requested address doesn't fall in the global range */ - if (ADDR_IN_GLOBAL(pagetable->mmu, gpuaddr) || - ADDR_IN_GLOBAL(pagetable->mmu, gpuaddr + size)) + /* Make sure the requested address doesn't fall out of SVM range */ + if (!iommu_addr_in_svm_ranges(pt, gpuaddr, size)) return -ENOMEM; spin_lock(&pagetable->lock); -- cgit v1.2.3 From a3d56a7137f68e935e03e6a763c8113fc699af2b Mon Sep 17 00:00:00 2001 From: Kassey Li Date: Wed, 20 May 2020 17:43:00 +0530 Subject: sched: Fix out of bounds issue in for_each_cluster macro [ 31.504753] ================================================================= [ 31.512215] BUG: KASAN: global-out-of-bounds in core_ctl_set_boost+0x554/0x558 [ 31.519637] Read of size 4 at addr ffffffd0327c18f4 by task init/456 [ 31.526160] [ 31.527707] CPU: 1 PID: 456 Comm: init Tainted: G S W 5.4.12-qgki-debug-gdc9adf3559a6-dirty #25 [ 31.537793] Hardware name: Qualcomm Technologies, Inc. 8350 venus (DT) [ 31.544499] Call trace: [ 31.547026] dump_backtrace+0x0/0x2e0 [ 31.550797] show_stack+0x14/0x20 [ 31.554220] dump_stack+0xf0/0x144 [ 31.557732] print_address_description.isra.7+0x3c/0x3d8 [ 31.563190] __kasan_report+0x158/0x23c [ 31.567144] kasan_report+0xc/0x18 [ 31.570649] __asan_report_load4_noabort+0x18/0x20 [ 31.575572] core_ctl_set_boost+0x554/0x558 [ 31.579881] z3d22747cee+0x14/0x58 [ 31.583385] z991cee001b+0x884/0xd70 [ 31.587071] sched_boost_handler+0xe4/0x108 [ 31.591381] proc_sys_call_handler+0x384/0x420 [ 31.595954] proc_sys_write+0x10/0x18 [ 31.599728] __vfs_write+0x54/0xe8 [ 31.603232] vfs_write+0x15c/0x430 [ 31.606736] ksys_write+0xe8/0x1c0 [ 31.610241] __arm64_sys_write+0x68/0x98 [ 31.614282] el0_svc_common.constprop.0+0x1c0/0x370 [ 31.619302] el0_svc_handler+0xd4/0x178 [ 31.623257] el0_svc+0x8/0xc Change-Id: I71e71d61e080c1ce948bd0400f9ebb0705a2210b Signed-off-by: Kassey Li Signed-off-by: Lingutla Chandrasekhar [rshaha: Resolved trivial merge conflicts] Signed-off-by: Rahul Shahare --- kernel/sched/core_ctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core_ctl.c b/kernel/sched/core_ctl.c index ce15ae7fe76b..70cd0649ac9b 100644 --- a/kernel/sched/core_ctl.c +++ b/kernel/sched/core_ctl.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2017, 2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -70,8 +70,8 @@ static struct cluster_data cluster_state[MAX_CLUSTERS]; static unsigned int num_clusters; #define for_each_cluster(cluster, idx) \ - for ((cluster) = &cluster_state[idx]; (idx) < num_clusters;\ - (idx)++, (cluster) = &cluster_state[idx]) + for (; (idx) < num_clusters && ((cluster) = &cluster_state[idx]);\ + (idx)++) static DEFINE_SPINLOCK(state_lock); static void apply_need(struct cluster_data *state); -- cgit v1.2.3 From 677201b9678c6cf617afc3c0a058919e0ee49e98 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 13 Dec 2019 14:56:16 -0800 Subject: Input: add safety guards to input_set_keycode() If we happen to have a garbage in input device's keycode table with values too big we'll end up doing clear_bit() with offset way outside of our bitmaps, damaging other objects within an input device or even outside of it. Let's add sanity checks to the returned old keycodes. Reported-by: syzbot+c769968809f9359b07aa@syzkaller.appspotmail.com Reported-by: syzbot+76f3a30e88d256644c78@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20191207212757.GA245964@dtor-ws Signed-off-by: Dmitry Torokhov Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Git-commit: cb222aed03d798fc074be55e59d9a112338ee784 Change-Id: I1bd01ea3ffa0ba0e0303d19cfcc27cc39947963b Signed-off-by: Alam Md Danish Signed-off-by: Rahul Shahare --- drivers/input/input.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index baaddd168804..857917086cb0 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -851,16 +851,18 @@ static int input_default_setkeycode(struct input_dev *dev, } } - __clear_bit(*old_keycode, dev->keybit); - __set_bit(ke->keycode, dev->keybit); - - for (i = 0; i < dev->keycodemax; i++) { - if (input_fetch_keycode(dev, i) == *old_keycode) { - __set_bit(*old_keycode, dev->keybit); - break; /* Setting the bit twice is useless, so break */ + if (*old_keycode <= KEY_MAX) { + __clear_bit(*old_keycode, dev->keybit); + for (i = 0; i < dev->keycodemax; i++) { + if (input_fetch_keycode(dev, i) == *old_keycode) { + __set_bit(*old_keycode, dev->keybit); + /* Setting the bit twice is useless, so break */ + break; + } } } + __set_bit(ke->keycode, dev->keybit); return 0; } @@ -916,9 +918,13 @@ int input_set_keycode(struct input_dev *dev, * Simulate keyup event if keycode is not present * in the keymap anymore */ - if (test_bit(EV_KEY, dev->evbit) && - !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && - __test_and_clear_bit(old_keycode, dev->key)) { + if (old_keycode > KEY_MAX) { + dev_warn(dev->dev.parent ?: &dev->dev, + "%s: got too big old keycode %#x\n", + __func__, old_keycode); + } else if (test_bit(EV_KEY, dev->evbit) && + !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && + __test_and_clear_bit(old_keycode, dev->key)) { struct input_value vals[] = { { EV_KEY, old_keycode, 0 }, input_value_sync -- cgit v1.2.3 From 4bbaeb87f060bd436ad053e9908aa3f6d739011a Mon Sep 17 00:00:00 2001 From: Shashi Kant Maurya Date: Sun, 30 Aug 2020 12:59:55 +0530 Subject: ARM: dts: msm: add CPU dai for additional proxy ports add CPU dai proxy ports 8194 and 8195 required for Call Screening. Change-Id: I022dce3694216d15cb5074cb338c8baceb04c0e5 Signed-off-by: Shashi Kant Maurya --- arch/arm/boot/dts/qcom/msm-audio.dtsi | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/arch/arm/boot/dts/qcom/msm-audio.dtsi b/arch/arm/boot/dts/qcom/msm-audio.dtsi index 69c7cd471e11..7cc300105a18 100644 --- a/arch/arm/boot/dts/qcom/msm-audio.dtsi +++ b/arch/arm/boot/dts/qcom/msm-audio.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, 2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2017, 2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -357,6 +357,16 @@ qcom,msm-dai-q6-dev-id = <32770>; }; + proxy_rx: qcom,msm-dai-q6-proxy-rx { + compatible = "qcom,msm-dai-q6-dev"; + qcom,msm-dai-q6-dev-id = <8194>; + }; + + proxy_tx: qcom,msm-dai-q6-proxy-tx { + compatible = "qcom,msm-dai-q6-dev"; + qcom,msm-dai-q6-dev-id = <8195>; + }; + usb_audio_rx: qcom,msm-dai-q6-usb-audio-rx { compatible = "qcom,msm-dai-q6-dev"; qcom,msm-dai-q6-dev-id = <28672>; @@ -679,7 +689,8 @@ <&dai_pri_tdm_rx_0>, <&dai_pri_tdm_tx_0>, <&dai_sec_tdm_rx_0>, <&dai_sec_tdm_tx_0>, <&dai_tert_tdm_rx_0>, <&dai_tert_tdm_tx_0>, - <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>; + <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>, + <&proxy_rx>, <&proxy_tx>; asoc-cpu-names = "msm-dai-q6-dp.24608", "msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1", "msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3", @@ -702,7 +713,8 @@ "msm-dai-q6-tdm.36865", "msm-dai-q6-tdm.36880", "msm-dai-q6-tdm.36881", "msm-dai-q6-tdm.36896", "msm-dai-q6-tdm.36897", "msm-dai-q6-tdm.36912", - "msm-dai-q6-tdm.36913"; + "msm-dai-q6-tdm.36913", + "msm-dai-q6-dev.8194", "msm-dai-q6-dev.8195"; asoc-codec = <&stub_codec>, <&ext_disp_audio_codec>; asoc-codec-names = "msm-stub-codec.1", "msm-ext-disp-audio-codec-rx"; @@ -784,7 +796,8 @@ <&dai_pri_tdm_rx_0>, <&dai_pri_tdm_tx_0>, <&dai_sec_tdm_rx_0>, <&dai_sec_tdm_tx_0>, <&dai_tert_tdm_rx_0>, <&dai_tert_tdm_tx_0>, - <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>; + <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>, + <&proxy_rx>, <&proxy_tx>; asoc-cpu-names = "msm-dai-q6-dp.24608", "msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1", "msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3", @@ -807,7 +820,8 @@ "msm-dai-q6-tdm.36865", "msm-dai-q6-tdm.36880", "msm-dai-q6-tdm.36881", "msm-dai-q6-tdm.36896", "msm-dai-q6-tdm.36897", "msm-dai-q6-tdm.36912", - "msm-dai-q6-tdm.36913"; + "msm-dai-q6-tdm.36913", + "msm-dai-q6-dev.8194", "msm-dai-q6-dev.8195"; asoc-codec = <&stub_codec>, <&ext_disp_audio_codec>; asoc-codec-names = "msm-stub-codec.1", "msm-ext-disp-audio-codec-rx"; @@ -893,7 +907,8 @@ <&dai_pri_tdm_rx_0>, <&dai_pri_tdm_tx_0>, <&dai_sec_tdm_rx_0>, <&dai_sec_tdm_tx_0>, <&dai_tert_tdm_rx_0>, <&dai_tert_tdm_tx_0>, - <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>; + <&dai_quat_tdm_rx_0>, <&dai_quat_tdm_tx_0>, + <&proxy_rx>, <&proxy_tx>; asoc-cpu-names = "msm-dai-q6-dp.24608", "msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1", "msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3", @@ -912,7 +927,8 @@ "msm-dai-q6-tdm.36864", "msm-dai-q6-tdm.36865", "msm-dai-q6-tdm.36880", "msm-dai-q6-tdm.36881", "msm-dai-q6-tdm.36896", "msm-dai-q6-tdm.36897", - "msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913"; + "msm-dai-q6-tdm.36912", "msm-dai-q6-tdm.36913", + "msm-dai-q6-dev.8194", "msm-dai-q6-dev.8195"; asoc-codec = <&stub_codec>, <&msm_digital_codec>, <&pmic_analog_codec>, <&msm_sdw_codec>, <&ext_disp_audio_codec>; -- cgit v1.2.3 From 8d23afe69d5505556635f208016a1cb8e24876c1 Mon Sep 17 00:00:00 2001 From: Shashi Kant Maurya Date: Mon, 17 Aug 2020 12:54:20 +0530 Subject: soc: add proxy ports for call screening in machine driver add machine driver changes for proxy port changes. Pseudo AFE port based BE DAIs can be used for various use cases, including but not limited to voice call. Add support for BE DAI link based on pseudo port. Change-Id: I02677676f6a23a05e3f10eb2ce09f3543837417c Signed-off-by: Shashi Kant Maurya --- include/sound/apr_audio-v2.h | 13 ++++++-- include/sound/q6afe-v2.h | 5 ++- sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c | 49 ++++++++++++++++++++++++++++-- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c | 41 +++++++++++++++++++++++-- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h | 4 +++ sound/soc/msm/qdsp6v2/q6afe.c | 12 +++++++- sound/soc/msm/qdsp6v2/q6audio-v2.c | 12 +++++++- sound/soc/msm/sdm660-ext-dai-links.c | 30 +++++++++++++++++- sound/soc/msm/sdm660-internal.c | 29 +++++++++++++++++- 9 files changed, 184 insertions(+), 11 deletions(-) diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h index 89e05abfd74b..f312284024a9 100644 --- a/include/sound/apr_audio-v2.h +++ b/include/sound/apr_audio-v2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1429,7 +1429,7 @@ struct adm_cmd_connect_afe_port_v5 { #define AFE_PORT_ID_SLIMBUS_RANGE_SIZE 0xA /* Size of the range of port IDs for real-time proxy ports. */ -#define AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE 0x2 +#define AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE 0x4 /* Size of the range of port IDs for pseudoports. */ #define AFE_PORT_ID_PSEUDOPORT_RANGE_SIZE 0x5 @@ -1643,6 +1643,15 @@ struct adm_cmd_connect_afe_port_v5 { */ #define AFE_PORT_ID_VOICE2_PLAYBACK_TX 0x8002 #define AFE_PORT_ID_VOICE_PLAYBACK_TX 0x8005 +/* + * Proxyport used for voice call data processing. + * In cases like call-screening feature, where user can communicate + * with caller with the help of "call screen" mode, and without + * connecting the call with any HW input/output devices in the phon, + * voice call can use Pseudo port to start voice data processing. + */ +#define RT_PROXY_PORT_002_TX 0x2003 +#define RT_PROXY_PORT_002_RX 0x2002 #define AFE_PORT_ID_PRIMARY_TDM_RX \ (AFE_PORT_ID_TDM_PORT_RANGE_START + 0x00) diff --git a/include/sound/q6afe-v2.h b/include/sound/q6afe-v2.h index a6d697d6a8f8..e171028839f7 100644 --- a/include/sound/q6afe-v2.h +++ b/include/sound/q6afe-v2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -235,6 +235,9 @@ enum { IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX_2, IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX_3, IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX_4, + /* IDX 167 -> 168 */ + IDX_RT_PROXY_PORT_002_RX, + IDX_RT_PROXY_PORT_002_TX, AFE_MAX_PORTS }; diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c index 39abecb64f0e..ec590593e7c4 100644 --- a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1876,6 +1876,8 @@ static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream, case RT_PROXY_DAI_001_RX: case RT_PROXY_DAI_002_TX: case RT_PROXY_DAI_002_RX: + case RT_PROXY_PORT_002_TX: + case RT_PROXY_PORT_002_RX: rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai); break; case VOICE_PLAYBACK_TX: @@ -2872,6 +2874,42 @@ static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = { }, }; +static struct snd_soc_dai_driver msm_dai_q6_proxy_tx_dai = { + .capture = { + .stream_name = "Proxy Capture", + .aif_name = "PROXY_TX", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels_min = 1, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &msm_dai_q6_ops, + .id = RT_PROXY_PORT_002_TX, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, +}; + +static struct snd_soc_dai_driver msm_dai_q6_proxy_rx_dai = { + .playback = { + .stream_name = "Proxy Playback", + .aif_name = "PROXY_RX", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels_min = 1, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &msm_dai_q6_ops, + .id = RT_PROXY_PORT_002_RX, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, +}; + static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = { .playback = { .stream_name = "USB Audio Playback", @@ -5872,7 +5910,14 @@ register_uplink_capture: pr_err("%s: Device not found stream name %s\n", __func__, stream_name); break; - + case RT_PROXY_PORT_002_RX: + rc = snd_soc_register_component(&pdev->dev, + &msm_dai_q6_component, &msm_dai_q6_proxy_rx_dai, 1); + break; + case RT_PROXY_PORT_002_TX: + rc = snd_soc_register_component(&pdev->dev, + &msm_dai_q6_component, &msm_dai_q6_proxy_tx_dai, 1); + break; default: rc = -ENODEV; break; diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c index a5c02b2dc1a3..e0a41de1e095 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c @@ -593,7 +593,11 @@ struct msm_pcm_routing_bdai_data msm_bedais[MSM_BACKEND_DAI_MAX] = { { AFE_PORT_ID_QUATERNARY_MI2S_TX_3, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_QUAT_MI2S_TX_3}, { AFE_PORT_ID_QUATERNARY_MI2S_TX_4, 0, {0}, {0}, 0, 0, 0, 0, {0}, - LPASS_BE_QUAT_MI2S_TX_4} + LPASS_BE_QUAT_MI2S_TX_4}, + { RT_PROXY_PORT_002_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, + LPASS_BE_PROXY_RX}, + { RT_PROXY_PORT_002_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, + LPASS_BE_PROXY_TX} }; /* Track ASM playback & capture sessions of DAI @@ -3028,7 +3032,7 @@ static const char *const be_name[] = { "INT0_MI2S_RX", "INT0_MI2S_TX", "INT1_MI2S_RX", "INT1_MI2S_TX", "INT2_MI2S_RX", "INT2_MI2S_TX", "INT3_MI2S_RX", "INT3_MI2S_TX", "INT4_MI2S_RX", "INT4_MI2S_TX", "INT5_MI2S_RX", "INT5_MI2S_TX", -"INT6_MI2S_RX", "INT6_MI2S_TX" +"INT6_MI2S_RX", "INT6_MI2S_TX", "PROXY_RX", "PROXY_TX" }; static SOC_ENUM_SINGLE_DECL(mm1_channel_mux, @@ -13262,6 +13266,17 @@ static const struct snd_kcontrol_new tx_vowlan_mixer_controls[] = { msm_routing_put_voice_mixer), }; +static const struct snd_kcontrol_new proxy_rx_voice_mixer_controls[] = { + SOC_DOUBLE_EXT("VoiceMMode1", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_RX, + MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer, + msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("VoiceMMode2", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_RX, + MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer, + msm_routing_put_voice_mixer), +}; + static const struct snd_kcontrol_new tx_voicemmode1_mixer_controls[] = { SOC_DOUBLE_EXT("PRI_TX_MMode1", SND_SOC_NOPM, MSM_BACKEND_DAI_PRI_I2S_TX, @@ -13314,6 +13329,12 @@ static const struct snd_kcontrol_new tx_voicemmode1_mixer_controls[] = { SOC_DOUBLE_EXT("QUAT_TDM_TX_0_MMode1", SND_SOC_NOPM, MSM_BACKEND_DAI_QUAT_TDM_TX_0, MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("PROXY_TX_MMode1", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_TX, MSM_FRONTEND_DAI_VOICEMMODE1, + 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("PROXY_TX_MMode2", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_TX, MSM_FRONTEND_DAI_VOICEMMODE2, + 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), }; static const struct snd_kcontrol_new tx_voicemmode2_mixer_controls[] = { @@ -17636,6 +17657,8 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { SND_SOC_DAPM_AIF_IN("SLIMBUS_8_TX", "Slimbus8 Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_OUT("USB_AUDIO_RX", "USB Audio Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("USB_AUDIO_TX", "USB Audio Capture", 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("PROXY_RX", "Proxy Playback", 0, 0, 0, 0), + SND_SOC_DAPM_AIF_IN("PROXY_TX", "Proxy Capture", 0, 0, 0, 0), /* Switch Definitions */ SND_SOC_DAPM_SWITCH("SLIMBUS_DL_HL", SND_SOC_NOPM, 0, 0, @@ -17985,6 +18008,10 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { SND_SOC_DAPM_MIXER("Voice2_Tx Mixer", SND_SOC_NOPM, 0, 0, tx_voice2_mixer_controls, ARRAY_SIZE(tx_voice2_mixer_controls)), + SND_SOC_DAPM_MIXER("PROXY_RX_Voice Mixer", + SND_SOC_NOPM, 0, 0, + proxy_rx_voice_mixer_controls, + ARRAY_SIZE(proxy_rx_voice_mixer_controls)), SND_SOC_DAPM_MIXER("Voip_Tx Mixer", SND_SOC_NOPM, 0, 0, tx_voip_mixer_controls, ARRAY_SIZE(tx_voip_mixer_controls)), @@ -20334,6 +20361,12 @@ static const struct snd_soc_dapm_route intercon[] = { {"QUAT_TDM_RX_2_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2_Voice Mixer"}, + {"PROXY_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"}, + {"PROXY_RX", NULL, "PROXY_RX_Voice Mixer"}, + + {"PROXY_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"}, + {"PROXY_RX", NULL, "PROXY_RX_Voice Mixer"}, + {"VOC_EXT_EC MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"VOC_EXT_EC MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"VOC_EXT_EC MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, @@ -20524,6 +20557,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"VoiceMMode1_Tx Mixer", "TERT_AUX_PCM_TX_MMode1", "TERT_AUX_PCM_TX"}, {"VoiceMMode1_Tx Mixer", "QUAT_AUX_PCM_TX_MMode1", "QUAT_AUX_PCM_TX"}, {"VoiceMMode1_Tx Mixer", "QUAT_TDM_TX_0_MMode1", "QUAT_TDM_TX_0"}, + {"VoiceMMode1_Tx Mixer", "PROXY_TX_MMode1", "PROXY_TX"}, {"VOICEMMODE1_UL", NULL, "VoiceMMode1_Tx Mixer"}, {"VoiceMMode2_Tx Mixer", "PRI_TX_MMode2", "PRI_I2S_TX"}, @@ -20541,6 +20575,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"VoiceMMode2_Tx Mixer", "SEC_AUX_PCM_TX_MMode2", "SEC_AUX_PCM_TX"}, {"VoiceMMode2_Tx Mixer", "TERT_AUX_PCM_TX_MMode2", "TERT_AUX_PCM_TX"}, {"VoiceMMode2_Tx Mixer", "QUAT_AUX_PCM_TX_MMode2", "QUAT_AUX_PCM_TX"}, + {"VoiceMMode2_Tx Mixer", "PROXY_TX_MMode2", "PROXY_TX"}, {"VOICEMMODE2_UL", NULL, "VoiceMMode2_Tx Mixer"}, {"Voip_Tx Mixer", "PRI_TX_Voip", "PRI_I2S_TX"}, @@ -21370,6 +21405,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"BE_OUT", NULL, "QUAT_MI2S_RX_2"}, {"BE_OUT", NULL, "QUAT_MI2S_RX_3"}, {"BE_OUT", NULL, "QUAT_MI2S_RX_4"}, + {"BE_OUT", NULL, "PROXY_RX"}, {"PRI_I2S_TX", NULL, "BE_IN"}, {"MI2S_TX", NULL, "BE_IN"}, @@ -21445,6 +21481,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"QUAT_TDM_TX_1", NULL, "BE_IN"}, {"QUAT_TDM_TX_2", NULL, "BE_IN"}, {"QUAT_TDM_TX_3", NULL, "BE_IN"}, + {"PROXY_TX", NULL, "BE_IN"}, }; static int msm_pcm_routing_hw_params(struct snd_pcm_substream *substream, diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h index 70a4152ad05a..30b66bb7ae63 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h @@ -45,6 +45,8 @@ #define LPASS_BE_VOICE2_PLAYBACK_TX "VOICE2_PLAYBACK_TX" #define LPASS_BE_INCALL_RECORD_RX "INCALL_RECORD_RX" #define LPASS_BE_INCALL_RECORD_TX "INCALL_RECORD_TX" +#define LPASS_BE_PROXY_RX "PROXY_RX" +#define LPASS_BE_PROXY_TX "PROXY_TX" #define LPASS_BE_SEC_I2S_RX "SECONDARY_I2S_RX" #define LPASS_BE_SPDIF_RX "SPDIF_RX" @@ -429,6 +431,8 @@ enum { MSM_BACKEND_DAI_QUATERNARY_MI2S_TX_2, MSM_BACKEND_DAI_QUATERNARY_MI2S_TX_3, MSM_BACKEND_DAI_QUATERNARY_MI2S_TX_4, + MSM_BACKEND_DAI_PROXY_RX, + MSM_BACKEND_DAI_PROXY_TX, MSM_BACKEND_DAI_MAX, }; diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c index 7ee774ddccf7..610604fcfe15 100644 --- a/sound/soc/msm/qdsp6v2/q6afe.c +++ b/sound/soc/msm/qdsp6v2/q6afe.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -785,6 +785,8 @@ int afe_get_port_type(u16 port_id) case VOICE_PLAYBACK_TX: case VOICE2_PLAYBACK_TX: case RT_PROXY_PORT_001_RX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: case AUDIO_PORT_ID_I2S_RX: case AFE_PORT_ID_PRIMARY_MI2S_RX: case AFE_PORT_ID_SECONDARY_MI2S_RX: @@ -3422,6 +3424,8 @@ static int __afe_port_start(u16 port_id, union afe_port_config *afe_config, break; case RT_PROXY_PORT_001_RX: case RT_PROXY_PORT_001_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: cfg_type = AFE_PARAM_ID_RT_PROXY_CONFIG; break; case INT_BT_SCO_RX: @@ -3833,6 +3837,10 @@ int afe_get_port_index(u16 port_id) return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX_3; case AFE_PORT_ID_QUATERNARY_MI2S_RX_4: return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX_4; + case RT_PROXY_PORT_002_RX: + return IDX_RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return IDX_RT_PROXY_PORT_002_TX; default: pr_err("%s: port 0x%x\n", __func__, port_id); return -EINVAL; @@ -5810,6 +5818,8 @@ int afe_validate_port(u16 port_id) case AFE_PORT_ID_INT4_MI2S_TX: case AFE_PORT_ID_INT5_MI2S_TX: case AFE_PORT_ID_INT6_MI2S_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: { ret = 0; break; diff --git a/sound/soc/msm/qdsp6v2/q6audio-v2.c b/sound/soc/msm/qdsp6v2/q6audio-v2.c index 94a6b0c42dee..9faf85e11ed7 100644 --- a/sound/soc/msm/qdsp6v2/q6audio-v2.c +++ b/sound/soc/msm/qdsp6v2/q6audio-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -309,6 +309,10 @@ int q6audio_get_port_index(u16 port_id) return IDX_AFE_PORT_ID_INT6_MI2S_RX; case AFE_PORT_ID_INT6_MI2S_TX: return IDX_AFE_PORT_ID_INT6_MI2S_TX; + case RT_PROXY_PORT_002_RX: + return IDX_RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return IDX_RT_PROXY_PORT_002_TX; default: return -EINVAL; } } @@ -604,6 +608,10 @@ int q6audio_get_port_id(u16 port_id) return AFE_PORT_ID_INT6_MI2S_RX; case AFE_PORT_ID_INT6_MI2S_TX: return AFE_PORT_ID_INT6_MI2S_TX; + case RT_PROXY_PORT_002_RX: + return RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return RT_PROXY_PORT_002_TX; default: pr_warn("%s: Invalid port_id %d\n", __func__, port_id); return -EINVAL; @@ -939,6 +947,8 @@ int q6audio_validate_port(u16 port_id) case AFE_PORT_ID_QUATERNARY_MI2S_TX_2: case AFE_PORT_ID_QUATERNARY_MI2S_TX_3: case AFE_PORT_ID_QUATERNARY_MI2S_TX_4: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: { ret = 0; break; diff --git a/sound/soc/msm/sdm660-ext-dai-links.c b/sound/soc/msm/sdm660-ext-dai-links.c index 9a3e8e2fad51..fb0042f48d84 100644 --- a/sound/soc/msm/sdm660-ext-dai-links.c +++ b/sound/soc/msm/sdm660-ext-dai-links.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2018, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1449,6 +1449,34 @@ static struct snd_soc_dai_link msm_ext_common_be_dai[] = { .be_hw_params_fixup = msm_ext_be_hw_params_fixup, .ignore_suspend = 1, }, + /* Proxy Tx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_TX, + .stream_name = "Proxy Capture", + .cpu_dai_name = "msm-dai-q6-dev.8195", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-tx", + .no_pcm = 1, + .dpcm_capture = 1, + .be_id = MSM_BACKEND_DAI_PROXY_TX, + .ignore_suspend = 1, + }, + /* Proxy Rx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_RX, + .stream_name = "Proxy Playback", + .cpu_dai_name = "msm-dai-q6-dev.8194", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-rx", + .no_pcm = 1, + .dpcm_playback = 1, + .be_id = MSM_BACKEND_DAI_PROXY_RX, + .ignore_pmdown_time = 1, + .ignore_suspend = 1, + }, + { .name = LPASS_BE_USB_AUDIO_RX, .stream_name = "USB Audio Playback", diff --git a/sound/soc/msm/sdm660-internal.c b/sound/soc/msm/sdm660-internal.c index e4a6d86e908d..929020f32213 100644 --- a/sound/soc/msm/sdm660-internal.c +++ b/sound/soc/msm/sdm660-internal.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2018, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2587,6 +2587,33 @@ static struct snd_soc_dai_link msm_int_be_dai[] = { .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, }, + /* Proxy Tx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_TX, + .stream_name = "Proxy Capture", + .cpu_dai_name = "msm-dai-q6-dev.8195", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-tx", + .no_pcm = 1, + .dpcm_capture = 1, + .be_id = MSM_BACKEND_DAI_PROXY_TX, + .ignore_suspend = 1, + }, + /* Proxy Rx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_RX, + .stream_name = "Proxy Playback", + .cpu_dai_name = "msm-dai-q6-dev.8194", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-rx", + .no_pcm = 1, + .dpcm_playback = 1, + .be_id = MSM_BACKEND_DAI_PROXY_RX, + .ignore_pmdown_time = 1, + .ignore_suspend = 1, + }, { .name = LPASS_BE_USB_AUDIO_RX, .stream_name = "USB Audio Playback", -- cgit v1.2.3 From 750411ad0a0d230d83e9fd8301ea1ec509f39cae Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Fri, 8 Nov 2019 16:48:38 +0100 Subject: media: uvcvideo: Avoid cyclic entity chains due to malformed USB descriptors commit 68035c80e129c4cfec659aac4180354530b26527 upstream. Way back in 2017, fuzzing the 4.14-rc2 USB stack with syzkaller kicked up the following WARNING from the UVC chain scanning code: | list_add double add: new=ffff880069084010, prev=ffff880069084010, | next=ffff880067d22298. | ------------[ cut here ]------------ | WARNING: CPU: 1 PID: 1846 at lib/list_debug.c:31 __list_add_valid+0xbd/0xf0 | Modules linked in: | CPU: 1 PID: 1846 Comm: kworker/1:2 Not tainted | 4.14.0-rc2-42613-g1488251d1a98 #238 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 | Workqueue: usb_hub_wq hub_event | task: ffff88006b01ca40 task.stack: ffff880064358000 | RIP: 0010:__list_add_valid+0xbd/0xf0 lib/list_debug.c:29 | RSP: 0018:ffff88006435ddd0 EFLAGS: 00010286 | RAX: 0000000000000058 RBX: ffff880067d22298 RCX: 0000000000000000 | RDX: 0000000000000058 RSI: ffffffff85a58800 RDI: ffffed000c86bbac | RBP: ffff88006435dde8 R08: 1ffff1000c86ba52 R09: 0000000000000000 | R10: 0000000000000002 R11: 0000000000000000 R12: ffff880069084010 | R13: ffff880067d22298 R14: ffff880069084010 R15: ffff880067d222a0 | FS: 0000000000000000(0000) GS:ffff88006c900000(0000) knlGS:0000000000000000 | CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 | CR2: 0000000020004ff2 CR3: 000000006b447000 CR4: 00000000000006e0 | Call Trace: | __list_add ./include/linux/list.h:59 | list_add_tail+0x8c/0x1b0 ./include/linux/list.h:92 | uvc_scan_chain_forward.isra.8+0x373/0x416 | drivers/media/usb/uvc/uvc_driver.c:1471 | uvc_scan_chain drivers/media/usb/uvc/uvc_driver.c:1585 | uvc_scan_device drivers/media/usb/uvc/uvc_driver.c:1769 | uvc_probe+0x77f2/0x8f00 drivers/media/usb/uvc/uvc_driver.c:2104 Looking into the output from usbmon, the interesting part is the following data packet: ffff880069c63e00 30710169 C Ci:1:002:0 0 143 = 09028f00 01030080 00090403 00000e01 00000924 03000103 7c003328 010204db If we drop the lead configuration and interface descriptors, we're left with an output terminal descriptor describing a generic display: /* Output terminal descriptor */ buf[0] 09 buf[1] 24 buf[2] 03 /* UVC_VC_OUTPUT_TERMINAL */ buf[3] 00 /* ID */ buf[4] 01 /* type == 0x0301 (UVC_OTT_DISPLAY) */ buf[5] 03 buf[6] 7c buf[7] 00 /* source ID refers to self! */ buf[8] 33 The problem with this descriptor is that it is self-referential: the source ID of 0 matches itself! This causes the 'struct uvc_entity' representing the display to be added to its chain list twice during 'uvc_scan_chain()': once via 'uvc_scan_chain_entity()' when it is processed directly from the 'dev->entities' list and then again immediately afterwards when trying to follow the source ID in 'uvc_scan_chain_forward()' Add a check before adding an entity to a chain list to ensure that the entity is not already part of a chain. Link: https://lore.kernel.org/linux-media/CAAeHK+z+Si69jUR+N-SjN9q4O+o5KFiNManqEa-PjUta7EOb7A@mail.gmail.com/ Cc: Fixes: c0efd232929c ("V4L/DVB (8145a): USB Video Class driver") Change-Id: I838d373590d2ad8722cb3e5fbf044bf497d22938 Reported-by: Andrey Konovalov Signed-off-by: Will Deacon Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman Git-commit: 68035c80e129c4cfec659aac4180354530b26527 Git-Repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Rohith Kollalsi --- drivers/media/usb/uvc/uvc_driver.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index ebd1b882556d..9cd0268b2767 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1411,6 +1411,11 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, break; if (forward == prev) continue; + if (forward->chain.next || forward->chain.prev) { + uvc_trace(UVC_TRACE_DESCR, "Found reference to " + "entity %d already in chain.\n", forward->id); + return -EINVAL; + } switch (UVC_ENTITY_TYPE(forward)) { case UVC_VC_EXTENSION_UNIT: @@ -1492,6 +1497,13 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain, return -1; } + if (term->chain.next || term->chain.prev) { + uvc_trace(UVC_TRACE_DESCR, "Found reference to " + "entity %d already in chain.\n", + term->id); + return -EINVAL; + } + if (uvc_trace_param & UVC_TRACE_PROBE) printk(" %d", term->id); -- cgit v1.2.3 From 6e91a4fb5f4752b34c5257a04e78d2c13278e964 Mon Sep 17 00:00:00 2001 From: Shashi Kant Maurya Date: Wed, 5 Aug 2020 12:45:12 +0530 Subject: Revert "include: Fix for compilation issue" This reverts commit 769b5eb47768ecc0662f02a7b42ec323df2841ab. These cal types are not supported. Change-Id: Iec7d2c171c49e6e1fc4562d13d111dcdc52523fe Signed-off-by: Shashi Kant Maurya --- include/uapi/linux/msm_audio_calibration.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/uapi/linux/msm_audio_calibration.h b/include/uapi/linux/msm_audio_calibration.h index 3da0d0842213..f05f9aaddb70 100644 --- a/include/uapi/linux/msm_audio_calibration.h +++ b/include/uapi/linux/msm_audio_calibration.h @@ -99,24 +99,12 @@ enum { AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE, AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE, AFE_SIDETONE_IIR_CAL_TYPE, - AFE_LSM_TOPOLOGY_CAL_TYPE, - AFE_LSM_TX_CAL_TYPE, - ADM_LSM_TOPOLOGY_CAL_TYPE, - ADM_LSM_AUDPROC_CAL_TYPE, - ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE, - ADM_AUDPROC_PERSISTENT_CAL_TYPE, MAX_CAL_TYPES, }; #define AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE #define AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE -#define ADM_AUDPROC_PERSISTENT_CAL_TYPE ADM_AUDPROC_PERSISTENT_CAL_TYPE -#define ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE -#define ADM_LSM_AUDPROC_CAL_TYPE ADM_LSM_AUDPROC_CAL_TYPE -#define AFE_LSM_TOPOLOGY_CAL_TYPE AFE_LSM_TOPOLOGY_CAL_TYPE -#define AFE_LSM_TX_CAL_TYPE AFE_LSM_TX_CAL_TYPE -#define ADM_LSM_AUDPROC_CAL_TYPE ADM_LSM_AUDPROC_CAL_TYPE #define AFE_SIDETONE_IIR_CAL_TYPE AFE_SIDETONE_IIR_CAL_TYPE enum { -- cgit v1.2.3 From a844e7d2b4f9583aa09e9af5d58ff084831cb509 Mon Sep 17 00:00:00 2001 From: xsang Date: Thu, 3 Sep 2020 23:49:59 +0800 Subject: asoc: add missing null check for pcm pointer of snd_pcm_volume In platform driver volume controls, add null check for pcm pointer of struct snd_pcm_volume. Change-Id: Icc139ae7dde0d45a3101b185ac69381df9e5e6c5 Signed-off-by: xsang --- sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c | 29 ++++++++++++++++++++++++-- sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c | 32 ++++++++++++++++++++++++----- sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c | 30 ++++++++++++++++++++++----- 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c index 0add46fb979f..24f9740a9511 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -545,11 +545,23 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, { int rc = 0; struct snd_pcm_volume *vol = kcontrol->private_data; - struct snd_pcm_substream *substream = vol->pcm->streams[0].substream; + struct snd_pcm_substream *substream = NULL; struct msm_pcm_loopback *prtd; int volume = ucontrol->value.integer.value[0]; pr_debug("%s: volume : 0x%x\n", __func__, volume); + + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[0].substream; mutex_lock(&loopback_session_lock); if ((!substream) || (!substream->runtime)) { pr_err("%s substream or runtime not found\n", __func__); @@ -579,6 +591,19 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, struct msm_pcm_loopback *prtd; pr_debug("%s\n", __func__); + + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + if ((!substream) || (!substream->runtime)) { pr_err("%s substream or runtime not found\n", __func__); rc = -ENODEV; diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c index 5c78349f8d70..4ef4ae7d72c8 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -662,12 +662,22 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, { struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); struct msm_plat_data *pdata = NULL; - struct snd_pcm_substream *substream = - vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV; @@ -699,13 +709,25 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, int rc = 0; struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); struct msm_plat_data *pdata = NULL; - struct snd_pcm_substream *substream = - vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; pr_debug("%s: volume : 0x%x\n", __func__, volume); + + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV; diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c index b2154620c8ae..c1ef60bd8cba 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1389,12 +1389,22 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, { struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); struct msm_plat_data *pdata = NULL; - struct snd_pcm_substream *substream = - vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV; @@ -1426,14 +1436,24 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, { int rc = 0; struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); - struct snd_pcm_substream *substream = - vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_plat_data *pdata = NULL; pr_debug("%s: volume : 0x%x\n", __func__, volume); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if (!substream) { pr_err("%s: substream not found\n", __func__); return -ENODEV; -- cgit v1.2.3